feat: updated engine version to 4.4-rc1

This commit is contained in:
Sara 2025-02-23 14:38:14 +01:00
parent ee00efde1f
commit 21ba8e33af
5459 changed files with 1128836 additions and 198305 deletions

View file

@ -1,4 +1,5 @@
#!/usr/bin/env python
from misc.utility.scons_hints import *
Import("env")

View file

@ -30,7 +30,7 @@
#include "default_theme.h"
#include "core/os/os.h"
#include "core/io/image.h"
#include "default_font.gen.h"
#include "default_theme_icons.gen.h"
#include "scene/resources/font.h"
@ -128,6 +128,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
// StyleBox colors
const Color style_normal_color = Color(0.1, 0.1, 0.1, 0.6);
const Color style_hover_color = Color(0.225, 0.225, 0.225, 0.6);
const Color style_hover_selected_color = Color(1, 1, 1, 0.4);
const Color style_pressed_color = Color(0, 0, 0, 0.6);
const Color style_disabled_color = Color(0.1, 0.1, 0.1, 0.3);
const Color style_focus_color = Color(1, 1, 1, 0.75);
@ -156,11 +157,11 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
const Ref<StyleBoxFlat> button_pressed = make_flat_stylebox(style_pressed_color);
const Ref<StyleBoxFlat> button_disabled = make_flat_stylebox(style_disabled_color);
Ref<StyleBoxFlat> focus = make_flat_stylebox(style_focus_color, default_margin, default_margin, default_margin, default_margin, default_corner_radius, false, 2);
// Make the focus outline appear to be flush with the buttons it's focusing.
// Make the focus outline appear to be flush with the buttons it's focusing, so not draw on top of the content.
focus->set_expand_margin_all(Math::round(2 * scale));
theme->set_stylebox(CoreStringName(normal), "Button", button_normal);
theme->set_stylebox("hover", "Button", button_hover);
theme->set_stylebox(SceneStringName(hover), "Button", button_hover);
theme->set_stylebox(SceneStringName(pressed), "Button", button_pressed);
theme->set_stylebox("disabled", "Button", button_disabled);
theme->set_stylebox("focus", "Button", focus);
@ -191,7 +192,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
// MenuBar
theme->set_stylebox(CoreStringName(normal), "MenuBar", button_normal);
theme->set_stylebox("hover", "MenuBar", button_hover);
theme->set_stylebox(SceneStringName(hover), "MenuBar", button_hover);
theme->set_stylebox(SceneStringName(pressed), "MenuBar", button_pressed);
theme->set_stylebox("disabled", "MenuBar", button_disabled);
@ -234,7 +235,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
Ref<StyleBox> sb_optbutton_disabled = make_flat_stylebox(style_disabled_color, 2 * default_margin, default_margin, 2 * default_margin, default_margin);
theme->set_stylebox(CoreStringName(normal), "OptionButton", sb_optbutton_normal);
theme->set_stylebox("hover", "OptionButton", sb_optbutton_hover);
theme->set_stylebox(SceneStringName(hover), "OptionButton", sb_optbutton_hover);
theme->set_stylebox(SceneStringName(pressed), "OptionButton", sb_optbutton_pressed);
theme->set_stylebox("disabled", "OptionButton", sb_optbutton_disabled);
@ -270,7 +271,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_stylebox(CoreStringName(normal), "MenuButton", button_normal);
theme->set_stylebox(SceneStringName(pressed), "MenuButton", button_pressed);
theme->set_stylebox("hover", "MenuButton", button_hover);
theme->set_stylebox(SceneStringName(hover), "MenuButton", button_hover);
theme->set_stylebox("disabled", "MenuButton", button_disabled);
theme->set_stylebox("focus", "MenuButton", focus);
@ -297,7 +298,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_stylebox(CoreStringName(normal), "CheckBox", cbx_empty);
theme->set_stylebox(SceneStringName(pressed), "CheckBox", cbx_empty);
theme->set_stylebox("disabled", "CheckBox", cbx_empty);
theme->set_stylebox("hover", "CheckBox", cbx_empty);
theme->set_stylebox(SceneStringName(hover), "CheckBox", cbx_empty);
theme->set_stylebox("hover_pressed", "CheckBox", cbx_empty);
theme->set_stylebox("focus", "CheckBox", cbx_focus);
@ -333,7 +334,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_stylebox(CoreStringName(normal), "CheckButton", cb_empty);
theme->set_stylebox(SceneStringName(pressed), "CheckButton", cb_empty);
theme->set_stylebox("disabled", "CheckButton", cb_empty);
theme->set_stylebox("hover", "CheckButton", cb_empty);
theme->set_stylebox(SceneStringName(hover), "CheckButton", cb_empty);
theme->set_stylebox("hover_pressed", "CheckButton", cb_empty);
theme->set_stylebox("focus", "CheckButton", focus);
@ -364,7 +365,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
// Button variations
theme->set_type_variation("FlatButton", "Button");
theme->set_type_variation(SceneStringName(FlatButton), "Button");
theme->set_type_variation("FlatMenuButton", "MenuButton");
Ref<StyleBoxEmpty> flat_button_normal = make_empty_stylebox();
@ -374,13 +375,13 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
Ref<StyleBoxFlat> flat_button_pressed = button_pressed->duplicate();
flat_button_pressed->set_bg_color(style_pressed_color * Color(1, 1, 1, 0.85));
theme->set_stylebox(CoreStringName(normal), "FlatButton", flat_button_normal);
theme->set_stylebox("hover", "FlatButton", flat_button_normal);
theme->set_stylebox(SceneStringName(pressed), "FlatButton", flat_button_pressed);
theme->set_stylebox("disabled", "FlatButton", flat_button_normal);
theme->set_stylebox(CoreStringName(normal), SceneStringName(FlatButton), flat_button_normal);
theme->set_stylebox(SceneStringName(hover), SceneStringName(FlatButton), flat_button_normal);
theme->set_stylebox(SceneStringName(pressed), SceneStringName(FlatButton), flat_button_pressed);
theme->set_stylebox("disabled", SceneStringName(FlatButton), flat_button_normal);
theme->set_stylebox(CoreStringName(normal), "FlatMenuButton", flat_button_normal);
theme->set_stylebox("hover", "FlatMenuButton", flat_button_normal);
theme->set_stylebox(SceneStringName(hover), "FlatMenuButton", flat_button_normal);
theme->set_stylebox(SceneStringName(pressed), "FlatMenuButton", flat_button_pressed);
theme->set_stylebox("disabled", "FlatMenuButton", flat_button_normal);
@ -504,6 +505,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_icon("can_fold_code_region", "CodeEdit", icons["region_unfolded"]);
theme->set_icon("folded_code_region", "CodeEdit", icons["region_folded"]);
theme->set_icon("folded_eol_icon", "CodeEdit", icons["text_edit_ellipsis"]);
theme->set_icon("completion_color_bg", "CodeEdit", icons["mini_checkerboard"]);
theme->set_font(SceneStringName(font), "CodeEdit", Ref<Font>());
theme->set_font_size(SceneStringName(font_size), "CodeEdit", -1);
@ -613,7 +615,43 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
// SpinBox
theme->set_icon("updown", "SpinBox", icons["updown"]);
theme->set_icon("updown", "SpinBox", empty_icon);
theme->set_icon("up", "SpinBox", icons["value_up"]);
theme->set_icon("up_hover", "SpinBox", icons["value_up"]);
theme->set_icon("up_pressed", "SpinBox", icons["value_up"]);
theme->set_icon("up_disabled", "SpinBox", icons["value_up"]);
theme->set_icon("down", "SpinBox", icons["value_down"]);
theme->set_icon("down_hover", "SpinBox", icons["value_down"]);
theme->set_icon("down_pressed", "SpinBox", icons["value_down"]);
theme->set_icon("down_disabled", "SpinBox", icons["value_down"]);
theme->set_stylebox("up_background", "SpinBox", make_empty_stylebox());
theme->set_stylebox("up_background_hovered", "SpinBox", button_hover);
theme->set_stylebox("up_background_pressed", "SpinBox", button_pressed);
theme->set_stylebox("up_background_disabled", "SpinBox", make_empty_stylebox());
theme->set_stylebox("down_background", "SpinBox", make_empty_stylebox());
theme->set_stylebox("down_background_hovered", "SpinBox", button_hover);
theme->set_stylebox("down_background_pressed", "SpinBox", button_pressed);
theme->set_stylebox("down_background_disabled", "SpinBox", make_empty_stylebox());
theme->set_color("up_icon_modulate", "SpinBox", control_font_color);
theme->set_color("up_hover_icon_modulate", "SpinBox", control_font_hover_color);
theme->set_color("up_pressed_icon_modulate", "SpinBox", control_font_hover_color);
theme->set_color("up_disabled_icon_modulate", "SpinBox", control_font_disabled_color);
theme->set_color("down_icon_modulate", "SpinBox", control_font_color);
theme->set_color("down_hover_icon_modulate", "SpinBox", control_font_hover_color);
theme->set_color("down_pressed_icon_modulate", "SpinBox", control_font_hover_color);
theme->set_color("down_disabled_icon_modulate", "SpinBox", control_font_disabled_color);
theme->set_stylebox("field_and_buttons_separator", "SpinBox", make_empty_stylebox());
theme->set_stylebox("up_down_buttons_separator", "SpinBox", make_empty_stylebox());
theme->set_constant("buttons_vertical_separation", "SpinBox", 0);
theme->set_constant("field_and_buttons_separation", "SpinBox", 2);
theme->set_constant("buttons_width", "SpinBox", 16);
#ifndef DISABLE_DEPRECATED
theme->set_constant("set_min_buttons_width_from_icons", "SpinBox", 1);
#endif
// ScrollContainer
@ -621,6 +659,14 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
empty.instantiate();
theme->set_stylebox(SceneStringName(panel), "ScrollContainer", empty);
const Ref<StyleBoxFlat> focus_style = make_flat_stylebox(style_focus_color);
// Make the focus outline appear to be flush with the buttons it's focusing, so not draw on top of the content.
sb_expand(focus_style, 4, 4, 4, 4);
focus_style->set_border_width_all(Math::round(2 * scale));
focus_style->set_draw_center(false);
focus_style->set_border_color(style_focus_color);
theme->set_stylebox("focus", "ScrollContainer", focus_style);
// Window
theme->set_stylebox("embedded_border", "Window", sb_expand(make_flat_stylebox(style_popup_color, 10, 28, 10, 8), 8, 32, 8, 6));
@ -647,11 +693,15 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
// File Dialog
theme->set_icon("load", "FileDialog", icons["load"]);
theme->set_icon("save", "FileDialog", icons["save"]);
theme->set_icon("clear", "FileDialog", icons["clear"]);
theme->set_icon("parent_folder", "FileDialog", icons["folder_up"]);
theme->set_icon("back_folder", "FileDialog", icons["arrow_left"]);
theme->set_icon("forward_folder", "FileDialog", icons["arrow_right"]);
theme->set_icon("reload", "FileDialog", icons["reload"]);
theme->set_icon("toggle_hidden", "FileDialog", icons["visibility_visible"]);
theme->set_icon("toggle_filename_filter", "FileDialog", icons["toggle_filename_filter"]);
theme->set_icon("folder", "FileDialog", icons["folder"]);
theme->set_icon("file", "FileDialog", icons["file"]);
theme->set_icon("create_folder", "FileDialog", icons["folder_create"]);
@ -683,7 +733,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
style_popup_panel->set_border_color(style_popup_border_color);
theme->set_stylebox(SceneStringName(panel), "PopupMenu", style_popup_panel);
theme->set_stylebox("hover", "PopupMenu", make_flat_stylebox(style_popup_hover_color));
theme->set_stylebox(SceneStringName(hover), "PopupMenu", make_flat_stylebox(style_popup_hover_color));
theme->set_stylebox("separator", "PopupMenu", separator_horizontal);
theme->set_stylebox("labeled_separator_left", "PopupMenu", separator_horizontal);
theme->set_stylebox("labeled_separator_right", "PopupMenu", separator_horizontal);
@ -794,10 +844,13 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_stylebox(SceneStringName(panel), "Tree", make_flat_stylebox(style_normal_color, 4, 4, 4, 5));
theme->set_stylebox("focus", "Tree", focus);
theme->set_stylebox("hovered", "Tree", make_flat_stylebox(Color(1, 1, 1, 0.07)));
theme->set_stylebox("hovered_dimmed", "Tree", make_flat_stylebox(Color(1, 1, 1, 0.03)));
theme->set_stylebox("selected", "Tree", make_flat_stylebox(style_selected_color));
theme->set_stylebox("selected_focus", "Tree", make_flat_stylebox(style_selected_color));
theme->set_stylebox("cursor", "Tree", focus);
theme->set_stylebox("cursor_unfocused", "Tree", focus);
theme->set_stylebox("button_hover", "Tree", make_flat_stylebox(Color(1, 1, 1, 0.07)));
theme->set_stylebox("button_pressed", "Tree", button_pressed);
theme->set_stylebox("title_button_normal", "Tree", make_flat_stylebox(style_pressed_color, 4, 4, 4, 4));
theme->set_stylebox("title_button_pressed", "Tree", make_flat_stylebox(style_hover_color, 4, 4, 4, 4));
@ -825,6 +878,8 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_color("title_button_color", "Tree", control_font_color);
theme->set_color(SceneStringName(font_color), "Tree", control_font_low_color);
theme->set_color("font_hovered_color", "Tree", control_font_hover_color);
theme->set_color("font_hovered_dimmed_color", "Tree", control_font_color);
theme->set_color("font_selected_color", "Tree", control_font_pressed_color);
theme->set_color("font_disabled_color", "Tree", control_font_disabled_color);
theme->set_color("font_outline_color", "Tree", Color(0, 0, 0));
@ -874,10 +929,13 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_color(SceneStringName(font_color), "ItemList", control_font_lower_color);
theme->set_color("font_hovered_color", "ItemList", control_font_hover_color);
theme->set_color("font_hovered_selected_color", "ItemList", control_font_pressed_color);
theme->set_color("font_selected_color", "ItemList", control_font_pressed_color);
theme->set_color("font_outline_color", "ItemList", Color(0, 0, 0));
theme->set_color("guide_color", "ItemList", Color(0.7, 0.7, 0.7, 0.25));
theme->set_stylebox("hovered", "ItemList", make_flat_stylebox(Color(1, 1, 1, 0.07)));
theme->set_stylebox("hovered_selected", "ItemList", make_flat_stylebox(style_hover_selected_color));
theme->set_stylebox("hovered_selected_focus", "ItemList", make_flat_stylebox(style_hover_selected_color));
theme->set_stylebox("selected", "ItemList", make_flat_stylebox(style_selected_color));
theme->set_stylebox("selected_focus", "ItemList", make_flat_stylebox(style_selected_color));
theme->set_stylebox("cursor", "ItemList", focus);
@ -982,6 +1040,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_constant("label_width", "ColorPicker", Math::round(10 * scale));
theme->set_constant("center_slider_grabbers", "ColorPicker", 1);
theme->set_icon("menu_option", "ColorPicker", icons["tabs_menu_hl"]);
theme->set_icon("folded_arrow", "ColorPicker", icons["arrow_right"]);
theme->set_icon("expanded_arrow", "ColorPicker", icons["arrow_down"]);
theme->set_icon("screen_picker", "ColorPicker", icons["color_picker_pipette"]);
@ -994,6 +1053,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_icon("overbright_indicator", "ColorPicker", icons["color_picker_overbright"]);
theme->set_icon("bar_arrow", "ColorPicker", icons["color_picker_bar_arrow"]);
theme->set_icon("picker_cursor", "ColorPicker", icons["color_picker_cursor"]);
theme->set_icon("picker_cursor_bg", "ColorPicker", icons["color_picker_cursor_bg"]);
{
const int precision = 7;
@ -1022,39 +1082,12 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_icon("color_hue", "ColorPicker", hue_texture);
}
{
const int precision = 7;
Ref<Gradient> hue_gradient;
hue_gradient.instantiate();
PackedFloat32Array offsets;
offsets.resize(precision);
PackedColorArray colors;
colors.resize(precision);
for (int i = 0; i < precision; i++) {
float h = i / float(precision - 1);
offsets.write[i] = h;
colors.write[i] = Color::from_ok_hsl(h, 1, 0.5);
}
hue_gradient->set_offsets(offsets);
hue_gradient->set_colors(colors);
Ref<GradientTexture2D> hue_texture;
hue_texture.instantiate();
hue_texture->set_width(800);
hue_texture->set_height(6);
hue_texture->set_gradient(hue_gradient);
theme->set_icon("color_okhsl_hue", "ColorPicker", hue_texture);
}
// ColorPickerButton
theme->set_icon("bg", "ColorPickerButton", icons["mini_checkerboard"]);
theme->set_stylebox(CoreStringName(normal), "ColorPickerButton", button_normal);
theme->set_stylebox(SceneStringName(pressed), "ColorPickerButton", button_pressed);
theme->set_stylebox("hover", "ColorPickerButton", button_hover);
theme->set_stylebox(SceneStringName(hover), "ColorPickerButton", button_hover);
theme->set_stylebox("disabled", "ColorPickerButton", button_disabled);
theme->set_stylebox("focus", "ColorPickerButton", focus);
@ -1174,6 +1207,9 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_constant("v_separation", "VFlowContainer", Math::round(4 * scale));
theme->set_stylebox(SceneStringName(panel), "PanelContainer", make_flat_stylebox(style_normal_color, 0, 0, 0, 0));
theme->set_stylebox("split_bar_background", "SplitContainer", make_empty_stylebox(0, 0, 0, 0));
theme->set_stylebox("split_bar_background", "VSplitContainer", make_empty_stylebox(0, 0, 0, 0));
theme->set_stylebox("split_bar_background", "HSplitContainer", make_empty_stylebox(0, 0, 0, 0));
theme->set_icon("zoom_out", "GraphEdit", icons["zoom_less"]);
theme->set_icon("zoom_in", "GraphEdit", icons["zoom_more"]);
@ -1194,6 +1230,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_color("selection_stroke", "GraphEdit", Color(1, 1, 1, 0.8));
theme->set_color("activity", "GraphEdit", Color(1, 1, 1));
theme->set_color("connection_hover_tint_color", "GraphEdit", Color(0, 0, 0, 0.3));
theme->set_constant("connection_hover_thickness", "GraphEdit", 0);
theme->set_color("connection_valid_target_tint_color", "GraphEdit", Color(1, 1, 1, 0.4));
theme->set_color("connection_rim_color", "GraphEdit", style_normal_color);

View file

@ -1,19 +1,12 @@
#!/usr/bin/env python
from misc.utility.scons_hints import *
Import("env")
import default_theme_icons_builders
env["BUILDERS"]["MakeDefaultThemeIconsBuilder"] = Builder(
action=env.Run(default_theme_icons_builders.make_default_theme_icons_action),
suffix=".h",
src_suffix=".svg",
)
# Default theme icons
icon_sources = Glob("*.svg")
env.Alias(
"default_theme_icons",
[env.MakeDefaultThemeIconsBuilder("#scene/theme/default_theme_icons.gen.h", icon_sources)],
env.CommandNoCache(
"#scene/theme/default_theme_icons.gen.h",
Glob("*.svg"),
env.Run(default_theme_icons_builders.make_default_theme_icons_action),
)

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#e0e0e0" d="m8 1a1 1 0 0 0 -1 1v5h-2c-1.108 0-2 .892-2 2v1h10v-1c0-1.108-.892-2-2-2h-2v-5a1 1 0 0 0 -1-1zm-5 10v4l10-1v-3z"/></svg>

After

Width:  |  Height:  |  Size: 206 B

View file

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><circle cx="8" cy="8" r="5.5" fill="none" stroke="#fff"/><circle cx="8" cy="8" r="4.5" fill="none" stroke="#000"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12"><circle cx="6" cy="6" r="5" fill="none" stroke="#fff"/><circle cx="6" cy="6" r="4" fill="none" stroke="#000"/></svg>

Before

Width:  |  Height:  |  Size: 183 B

After

Width:  |  Height:  |  Size: 179 B

Before After
Before After

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12"><circle cx="6" cy="6" r="4" fill="#fff"/></svg>

After

Width:  |  Height:  |  Size: 110 B

View file

@ -3,6 +3,8 @@
import os
from io import StringIO
from methods import to_raw_cstring
# See also `editor/icons/editor_icons_builders.py`.
def make_default_theme_icons_action(target, source, env):
@ -10,21 +12,9 @@ def make_default_theme_icons_action(target, source, env):
svg_icons = [str(x) for x in source]
with StringIO() as icons_string, StringIO() as s:
for f in svg_icons:
fname = str(f)
icons_string.write('\t"')
with open(fname, "rb") as svgf:
b = svgf.read(1)
while len(b) == 1:
icons_string.write("\\" + str(hex(ord(b)))[1:])
b = svgf.read(1)
icons_string.write('"')
if fname != svg_icons[-1]:
icons_string.write(",")
icons_string.write("\n")
for svg in svg_icons:
with open(svg, "r") as svgf:
icons_string.write("\t%s,\n" % to_raw_cstring(svgf.read()))
s.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n\n")
s.write('#include "modules/modules_enabled.gen.h"\n\n')

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#e0e0e0" d="M3 2a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h9c1.105 0 1.818-.91 2-2l1-6a1 1 0 0 0-1-1H6c-.552 0-.909.455-1 1l-1 6c-.091.545-.448 1-1 1a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1 1 1 0 0 0 1 1h5a1 1 0 0 0-1-1H7a2 2 0 0 0-2-2H3z"/></svg>

After

Width:  |  Height:  |  Size: 316 B

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#e0e0e0" d="M3 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V4l-3-3h-1v6H3zm1 0v5h3V1zm4 8a1 1 0 0 1 0 4 1 1 0 0 1 0-4z"/></svg>

After

Width:  |  Height:  |  Size: 207 B

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><g fill="#e0e0e0"><path d="m13.297.714h-13.013a.454.454 0 0 0 -.318.779l4.615 4.507v7.086a.45.45 0 0 0 .738.354l3.511-2.812a.454.454 0 0 0 .17-.354v-4.274l4.614-4.506a.454.454 0 0 0 -.317-.779z"/><path d="m11.085832 14.18196c3.399443 1.97457 6.855925-2.441094 4.074102-5.1815164-2.781825-2.7404217-7.2642008.6646174-5.2597994 4.0134654l-1.9001346 1.871854 1.1856973 1.168051zm1.699723-4.4945981c2.236109 0 2.236109 3.3042441 0 3.3042441-2.236108 0-2.236108-3.3042441 0-3.3042441z"/></g></svg>

After

Width:  |  Height:  |  Size: 555 B

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="8"><path fill="none" stroke="#fff" stroke-width="2" d="m12 2-4 3.5L4 2"/></svg>

After

Width:  |  Height:  |  Size: 138 B

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="8"><path fill="none" stroke="#fff" stroke-width="2" d="m4 6 4-3.5L12 6"/></svg>

After

Width:  |  Height:  |  Size: 138 B

View file

@ -198,21 +198,21 @@ Ref<StyleBox> ThemeDB::get_fallback_stylebox() {
return fallback_stylebox;
}
void ThemeDB::get_native_type_dependencies(const StringName &p_base_type, List<StringName> *p_list) {
ERR_FAIL_NULL(p_list);
void ThemeDB::get_native_type_dependencies(const StringName &p_base_type, Vector<StringName> &r_result) {
if (p_base_type == StringName()) {
return;
}
// TODO: It may make sense to stop at Control/Window, because their parent classes cannot be used in
// a meaningful way.
StringName class_name = p_base_type;
while (class_name != StringName()) {
p_list->push_back(class_name);
class_name = ClassDB::get_parent_class_nocheck(class_name);
if (!ClassDB::get_inheritance_chain_nocheck(p_base_type, r_result)) {
r_result.push_back(p_base_type);
}
}
// Global theme contexts.
ThemeContext *ThemeDB::create_theme_context(Node *p_node, List<Ref<Theme>> &p_themes) {
ThemeContext *ThemeDB::create_theme_context(Node *p_node, Vector<Ref<Theme>> &p_themes) {
ERR_FAIL_COND_V(!p_node->is_inside_tree(), nullptr);
ERR_FAIL_COND_V(theme_contexts.has(p_node), nullptr);
ERR_FAIL_COND_V(p_themes.is_empty(), nullptr);
@ -270,7 +270,7 @@ void ThemeDB::_propagate_theme_context(Node *p_from_node, ThemeContext *p_contex
void ThemeDB::_init_default_theme_context() {
default_theme_context = memnew(ThemeContext);
List<Ref<Theme>> themes;
Vector<Ref<Theme>> themes;
// Only add the project theme to the default context when running projects.
@ -365,7 +365,7 @@ void ThemeDB::update_class_instance_items(Node *p_instance) {
HashMap<StringName, HashMap<StringName, ThemeItemBind>>::Iterator E = theme_item_binds.find(class_name);
if (E) {
for (const KeyValue<StringName, ThemeItemBind> &F : E->value) {
F.value.setter(p_instance);
F.value.setter(p_instance, F.value.item_name, F.value.type_name);
}
}
@ -475,7 +475,7 @@ void ThemeContext::_emit_changed() {
emit_signal(CoreStringName(changed));
}
void ThemeContext::set_themes(List<Ref<Theme>> &p_themes) {
void ThemeContext::set_themes(Vector<Ref<Theme>> &p_themes) {
for (const Ref<Theme> &theme : themes) {
theme->disconnect_changed(callable_mp(this, &ThemeContext::_emit_changed));
}
@ -494,7 +494,7 @@ void ThemeContext::set_themes(List<Ref<Theme>> &p_themes) {
_emit_changed();
}
List<Ref<Theme>> ThemeContext::get_themes() const {
const Vector<Ref<Theme>> ThemeContext::get_themes() const {
return themes;
}
@ -504,7 +504,7 @@ Ref<Theme> ThemeContext::get_fallback_theme() const {
return ThemeDB::get_singleton()->get_default_theme();
}
return themes.back()->get();
return themes[themes.size() - 1];
}
void ThemeContext::_bind_methods() {

View file

@ -31,7 +31,6 @@
#ifndef THEME_DB_H
#define THEME_DB_H
#include "core/object/class_db.h"
#include "core/object/ref_counted.h"
#include "scene/resources/theme.h"
@ -46,26 +45,29 @@ class ThemeContext;
// Macros for binding theme items of this class. This information is used for the documentation, theme
// overrides, etc. This is also the basis for theme cache.
#define BIND_THEME_ITEM(m_data_type, m_class, m_prop) \
ThemeDB::get_singleton()->bind_class_item(m_data_type, get_class_static(), #m_prop, #m_prop, [](Node *p_instance) { \
m_class *p_cast = Object::cast_to<m_class>(p_instance); \
p_cast->theme_cache.m_prop = p_cast->get_theme_item(m_data_type, _scs_create(#m_prop)); \
})
#define BIND_THEME_ITEM(m_data_type, m_class, m_prop) \
ThemeDB::get_singleton()->bind_class_item(m_data_type, get_class_static(), #m_prop, #m_prop, \
[](Node *p_instance, const StringName &p_item_name, const StringName &p_type_name) { \
m_class *p_cast = Object::cast_to<m_class>(p_instance); \
p_cast->theme_cache.m_prop = p_cast->get_theme_item(m_data_type, p_item_name, p_type_name); \
})
#define BIND_THEME_ITEM_CUSTOM(m_data_type, m_class, m_prop, m_item_name) \
ThemeDB::get_singleton()->bind_class_item(m_data_type, get_class_static(), #m_prop, m_item_name, [](Node *p_instance) { \
m_class *p_cast = Object::cast_to<m_class>(p_instance); \
p_cast->theme_cache.m_prop = p_cast->get_theme_item(m_data_type, _scs_create(m_item_name)); \
})
#define BIND_THEME_ITEM_CUSTOM(m_data_type, m_class, m_prop, m_item_name) \
ThemeDB::get_singleton()->bind_class_item(m_data_type, get_class_static(), #m_prop, m_item_name, \
[](Node *p_instance, const StringName &p_item_name, const StringName &p_type_name) { \
m_class *p_cast = Object::cast_to<m_class>(p_instance); \
p_cast->theme_cache.m_prop = p_cast->get_theme_item(m_data_type, p_item_name, p_type_name); \
})
// Macro for binding theme items used by this class, but defined/binded by other classes. This is primarily used for
// the theme cache. Can also be used to list such items in documentation.
#define BIND_THEME_ITEM_EXT(m_data_type, m_class, m_prop, m_item_name, m_type_name) \
ThemeDB::get_singleton()->bind_class_external_item(m_data_type, get_class_static(), #m_prop, m_item_name, m_type_name, [](Node *p_instance) { \
m_class *p_cast = Object::cast_to<m_class>(p_instance); \
p_cast->theme_cache.m_prop = p_cast->get_theme_item(m_data_type, _scs_create(m_item_name), _scs_create(m_type_name)); \
})
#define BIND_THEME_ITEM_EXT(m_data_type, m_class, m_prop, m_item_name, m_type_name) \
ThemeDB::get_singleton()->bind_class_external_item(m_data_type, get_class_static(), #m_prop, m_item_name, m_type_name, \
[](Node *p_instance, const StringName &p_item_name, const StringName &p_type_name) { \
m_class *p_cast = Object::cast_to<m_class>(p_instance); \
p_cast->theme_cache.m_prop = p_cast->get_theme_item(m_data_type, p_item_name, p_type_name); \
})
class ThemeDB : public Object {
GDCLASS(ThemeDB, Object);
@ -97,7 +99,7 @@ class ThemeDB : public Object {
// Binding of theme items to Node classes.
public:
typedef std::function<void(Node *)> ThemeItemSetter;
typedef std::function<void(Node *, const StringName &, const StringName &)> ThemeItemSetter;
struct ThemeItemBind {
Theme::DataType data_type;
@ -154,11 +156,11 @@ public:
void set_fallback_stylebox(const Ref<StyleBox> &p_stylebox);
Ref<StyleBox> get_fallback_stylebox();
void get_native_type_dependencies(const StringName &p_base_type, List<StringName> *p_list);
void get_native_type_dependencies(const StringName &p_base_type, Vector<StringName> &r_result);
// Global theme contexts.
ThemeContext *create_theme_context(Node *p_node, List<Ref<Theme>> &p_themes);
ThemeContext *create_theme_context(Node *p_node, Vector<Ref<Theme>> &p_themes);
void destroy_theme_context(Node *p_node);
ThemeContext *get_theme_context(Node *p_node) const;
@ -191,7 +193,7 @@ class ThemeContext : public Object {
// Themes are stacked in the order of relevance, for easy iteration.
// This means that the first theme is the one you should check first,
// and the last theme is the fallback theme where every lookup ends.
List<Ref<Theme>> themes;
Vector<Ref<Theme>> themes;
void _emit_changed();
@ -199,8 +201,8 @@ protected:
static void _bind_methods();
public:
void set_themes(List<Ref<Theme>> &p_themes);
List<Ref<Theme>> get_themes() const;
void set_themes(Vector<Ref<Theme>> &p_themes);
const Vector<Ref<Theme>> get_themes() const;
Ref<Theme> get_fallback_theme() const;
};

View file

@ -199,7 +199,7 @@ void ThemeOwner::propagate_theme_changed(Node *p_to_node, Node *p_owner_node, bo
// Theme lookup.
void ThemeOwner::get_theme_type_dependencies(const Node *p_for_node, const StringName &p_theme_type, List<StringName> *r_list) const {
void ThemeOwner::get_theme_type_dependencies(const Node *p_for_node, const StringName &p_theme_type, Vector<StringName> &r_result) const {
const Control *for_c = Object::cast_to<Control>(p_for_node);
const Window *for_w = Object::cast_to<Window>(p_for_node);
ERR_FAIL_COND_MSG(!for_c && !for_w, "Only Control and Window nodes and derivatives can be polled for theming.");
@ -224,7 +224,7 @@ void ThemeOwner::get_theme_type_dependencies(const Node *p_for_node, const Strin
while (owner_node) {
Ref<Theme> owner_theme = _get_owner_node_theme(owner_node);
if (owner_theme.is_valid() && owner_theme->get_type_variation_base(type_variation) != StringName()) {
owner_theme->get_type_dependencies(type_name, type_variation, r_list);
owner_theme->get_type_dependencies(type_name, type_variation, r_result);
return;
}
@ -235,21 +235,21 @@ void ThemeOwner::get_theme_type_dependencies(const Node *p_for_node, const Strin
ThemeContext *global_context = _get_active_owner_context();
for (const Ref<Theme> &theme : global_context->get_themes()) {
if (theme.is_valid() && theme->get_type_variation_base(type_variation) != StringName()) {
theme->get_type_dependencies(type_name, type_variation, r_list);
theme->get_type_dependencies(type_name, type_variation, r_result);
return;
}
}
// If nothing was found, get the native dependencies for the current class.
ThemeDB::get_singleton()->get_native_type_dependencies(type_name, r_list);
ThemeDB::get_singleton()->get_native_type_dependencies(type_name, r_result);
return;
}
// Otherwise, get the native dependencies for the provided theme type.
ThemeDB::get_singleton()->get_native_type_dependencies(p_theme_type, r_list);
ThemeDB::get_singleton()->get_native_type_dependencies(p_theme_type, r_result);
}
Variant ThemeOwner::get_theme_item_in_types(Theme::DataType p_data_type, const StringName &p_name, const List<StringName> &p_theme_types) {
Variant ThemeOwner::get_theme_item_in_types(Theme::DataType p_data_type, const StringName &p_name, const Vector<StringName> &p_theme_types) {
ERR_FAIL_COND_V_MSG(p_theme_types.is_empty(), Variant(), "At least one theme type must be specified.");
// First, look through each control or window node in the branch, until no valid parent can be found.
@ -285,7 +285,7 @@ Variant ThemeOwner::get_theme_item_in_types(Theme::DataType p_data_type, const S
return global_context->get_fallback_theme()->get_theme_item(p_data_type, p_name, StringName());
}
bool ThemeOwner::has_theme_item_in_types(Theme::DataType p_data_type, const StringName &p_name, const List<StringName> &p_theme_types) {
bool ThemeOwner::has_theme_item_in_types(Theme::DataType p_data_type, const StringName &p_name, const Vector<StringName> &p_theme_types) {
ERR_FAIL_COND_V_MSG(p_theme_types.is_empty(), false, "At least one theme type must be specified.");
// First, look through each control or window node in the branch, until no valid parent can be found.

View file

@ -69,10 +69,10 @@ public:
// Theme lookup.
void get_theme_type_dependencies(const Node *p_for_node, const StringName &p_theme_type, List<StringName> *r_list) const;
void get_theme_type_dependencies(const Node *p_for_node, const StringName &p_theme_type, Vector<StringName> &r_result) const;
Variant get_theme_item_in_types(Theme::DataType p_data_type, const StringName &p_name, const List<StringName> &p_theme_types);
bool has_theme_item_in_types(Theme::DataType p_data_type, const StringName &p_name, const List<StringName> &p_theme_types);
Variant get_theme_item_in_types(Theme::DataType p_data_type, const StringName &p_name, const Vector<StringName> &p_theme_types);
bool has_theme_item_in_types(Theme::DataType p_data_type, const StringName &p_name, const Vector<StringName> &p_theme_types);
float get_theme_default_base_scale();
Ref<Font> get_theme_default_font();