Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for type variations in inherited themes #82218

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion scene/theme/theme_owner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down