summaryrefslogtreecommitdiffstats
path: root/scene/theme
diff options
context:
space:
mode:
Diffstat (limited to 'scene/theme')
-rw-r--r--scene/theme/default_theme.cpp25
-rw-r--r--scene/theme/theme_owner.cpp20
2 files changed, 44 insertions, 1 deletions
diff --git a/scene/theme/default_theme.cpp b/scene/theme/default_theme.cpp
index 7efbc74bf3..b65c372fab 100644
--- a/scene/theme/default_theme.cpp
+++ b/scene/theme/default_theme.cpp
@@ -360,6 +360,28 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_constant("check_v_offset", "CheckButton", 0);
theme->set_constant("outline_size", "CheckButton", 0);
+ // Button variations
+
+ theme->set_type_variation("FlatButton", "Button");
+ theme->set_type_variation("FlatMenuButton", "MenuButton");
+
+ Ref<StyleBoxEmpty> flat_button_normal = make_empty_stylebox();
+ for (int i = 0; i < 4; i++) {
+ flat_button_normal->set_content_margin((Side)i, button_normal->get_margin((Side)i) + button_normal->get_border_width((Side)i));
+ }
+ 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("normal", "FlatButton", flat_button_normal);
+ theme->set_stylebox("hover", "FlatButton", flat_button_normal);
+ theme->set_stylebox("pressed", "FlatButton", flat_button_pressed);
+ theme->set_stylebox("disabled", "FlatButton", flat_button_normal);
+
+ theme->set_stylebox("normal", "FlatMenuButton", flat_button_normal);
+ theme->set_stylebox("hover", "FlatMenuButton", flat_button_normal);
+ theme->set_stylebox("pressed", "FlatMenuButton", flat_button_pressed);
+ theme->set_stylebox("disabled", "FlatMenuButton", flat_button_normal);
+
// Label
theme->set_stylebox("normal", "Label", memnew(StyleBoxEmpty));
@@ -845,11 +867,13 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
style_tab_disabled->set_bg_color(style_disabled_color);
Ref<StyleBoxFlat> style_tab_hovered = style_tab_unselected->duplicate();
style_tab_hovered->set_bg_color(Color(0.1, 0.1, 0.1, 0.3));
+ Ref<StyleBoxFlat> style_tab_focus = focus->duplicate();
theme->set_stylebox("tab_selected", "TabContainer", style_tab_selected);
theme->set_stylebox("tab_hovered", "TabContainer", style_tab_hovered);
theme->set_stylebox("tab_unselected", "TabContainer", style_tab_unselected);
theme->set_stylebox("tab_disabled", "TabContainer", style_tab_disabled);
+ theme->set_stylebox("tab_focus", "TabContainer", style_tab_focus);
theme->set_stylebox("panel", "TabContainer", make_flat_stylebox(style_normal_color, 0, 0, 0, 0));
theme->set_stylebox("tabbar_background", "TabContainer", make_empty_stylebox(0, 0, 0, 0));
@@ -882,6 +906,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_stylebox("tab_hovered", "TabBar", style_tab_hovered);
theme->set_stylebox("tab_unselected", "TabBar", style_tab_unselected);
theme->set_stylebox("tab_disabled", "TabBar", style_tab_disabled);
+ theme->set_stylebox("tab_focus", "TabBar", style_tab_focus);
theme->set_stylebox("button_pressed", "TabBar", button_pressed);
theme->set_stylebox("button_highlight", "TabBar", button_normal);
diff --git a/scene/theme/theme_owner.cpp b/scene/theme/theme_owner.cpp
index 92cffeb228..2852a64e39 100644
--- a/scene/theme/theme_owner.cpp
+++ b/scene/theme/theme_owner.cpp
@@ -212,8 +212,26 @@ void ThemeOwner::get_theme_type_dependencies(const Node *p_for_node, const Strin
type_variation = for_w->get_theme_type_variation();
}
- // If we are looking for dependencies of the current class (or a variation of it), check themes from the context.
+ // If we are looking for dependencies of the current class (or a variation of it), check relevant themes.
if (p_theme_type == StringName() || p_theme_type == type_name || p_theme_type == type_variation) {
+ // We need one theme that can give us a valid dependency chain. It must be complete
+ // (i.e. variations can depend on other variations, but only within the same theme,
+ // and eventually the chain must lead to native types).
+
+ // First, look through themes owned by nodes in the tree.
+ Node *owner_node = get_owner_node();
+
+ 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);
+ return;
+ }
+
+ owner_node = _get_next_owner_node(owner_node);
+ }
+
+ // Second, check global contexts.
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()) {