Skip to content

Commit b22eba1

Browse files
Jesusemoraakien-mga
authored andcommitted
Show theme_type_variations in the inspector on Controls that inherit a theme
`theme_type_variation`s are now shown in the children and children of children that inherit a theme from a parent `Control` node.
1 parent 19bb187 commit b22eba1

File tree

2 files changed

+46
-4
lines changed

2 files changed

+46
-4
lines changed

scene/gui/control.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,9 +461,30 @@ void Control::_validate_property(PropertyInfo &p_property) const {
461461
if (p_property.name == "theme_type_variation") {
462462
List<StringName> names;
463463

464-
// Only the default theme and the project theme are used for the list of options.
465-
// This is an imposed limitation to simplify the logic needed to leverage those options.
466464
ThemeDB::get_singleton()->get_default_theme()->get_type_variation_list(get_class_name(), &names);
465+
466+
// Iterate to find all themes.
467+
Control *tmp_control = Object::cast_to<Control>(get_parent());
468+
Window *tmp_window = Object::cast_to<Window>(get_parent());
469+
while (tmp_control || tmp_window) {
470+
// We go up and any non Control/Window will break the chain.
471+
if (tmp_control) {
472+
if (tmp_control->get_theme().is_valid()) {
473+
tmp_control->get_theme()->get_type_variation_list(get_class_name(), &names);
474+
}
475+
tmp_window = Object::cast_to<Window>(tmp_control->get_parent());
476+
tmp_control = Object::cast_to<Control>(tmp_control->get_parent());
477+
} else { // Window.
478+
if (tmp_window->get_theme().is_valid()) {
479+
tmp_window->get_theme()->get_type_variation_list(get_class_name(), &names);
480+
}
481+
tmp_control = Object::cast_to<Control>(tmp_window->get_parent());
482+
tmp_window = Object::cast_to<Window>(tmp_window->get_parent());
483+
}
484+
}
485+
if (get_theme().is_valid()) {
486+
get_theme()->get_type_variation_list(get_class_name(), &names);
487+
}
467488
if (ThemeDB::get_singleton()->get_project_theme().is_valid()) {
468489
ThemeDB::get_singleton()->get_project_theme()->get_type_variation_list(get_class_name(), &names);
469490
}

scene/main/window.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,30 @@ void Window::_validate_property(PropertyInfo &p_property) const {
247247
} else if (p_property.name == "theme_type_variation") {
248248
List<StringName> names;
249249

250-
// Only the default theme and the project theme are used for the list of options.
251-
// This is an imposed limitation to simplify the logic needed to leverage those options.
252250
ThemeDB::get_singleton()->get_default_theme()->get_type_variation_list(get_class_name(), &names);
251+
252+
// Iterate to find all themes.
253+
Control *tmp_control = Object::cast_to<Control>(get_parent());
254+
Window *tmp_window = Object::cast_to<Window>(get_parent());
255+
while (tmp_control || tmp_window) {
256+
// We go up and any non Control/Window will break the chain.
257+
if (tmp_control) {
258+
if (tmp_control->get_theme().is_valid()) {
259+
tmp_control->get_theme()->get_type_variation_list(get_class_name(), &names);
260+
}
261+
tmp_window = Object::cast_to<Window>(tmp_control->get_parent());
262+
tmp_control = Object::cast_to<Control>(tmp_control->get_parent());
263+
} else { // Window.
264+
if (tmp_window->get_theme().is_valid()) {
265+
tmp_window->get_theme()->get_type_variation_list(get_class_name(), &names);
266+
}
267+
tmp_control = Object::cast_to<Control>(tmp_window->get_parent());
268+
tmp_window = Object::cast_to<Window>(tmp_window->get_parent());
269+
}
270+
}
271+
if (get_theme().is_valid()) {
272+
get_theme()->get_type_variation_list(get_class_name(), &names);
273+
}
253274
if (ThemeDB::get_singleton()->get_project_theme().is_valid()) {
254275
ThemeDB::get_singleton()->get_project_theme()->get_type_variation_list(get_class_name(), &names);
255276
}

0 commit comments

Comments
 (0)