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

Fetch argument options from ThemeDB #85015

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
40 changes: 27 additions & 13 deletions scene/gui/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,28 +208,42 @@ void Control::set_root_layout_direction(int p_root_dir) {
#ifdef TOOLS_ENABLED
void Control::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
ERR_READ_THREAD_GUARD;
CanvasItem::get_argument_options(p_function, p_idx, r_options);

if (p_idx == 0) {
List<StringName> sn;
const String pf = p_function;
Theme::DataType type = Theme::DATA_TYPE_MAX;

if (pf == "add_theme_color_override" || pf == "has_theme_color" || pf == "has_theme_color_override" || pf == "get_theme_color") {
ThemeDB::get_singleton()->get_default_theme()->get_color_list(get_class(), &sn);
} else if (pf == "add_theme_style_override" || pf == "has_theme_style" || pf == "has_theme_style_override" || pf == "get_theme_style") {
ThemeDB::get_singleton()->get_default_theme()->get_stylebox_list(get_class(), &sn);
type = Theme::DATA_TYPE_COLOR;
} else if (pf == "add_theme_constant_override" || pf == "has_theme_constant" || pf == "has_theme_constant_override" || pf == "get_theme_constant") {
type = Theme::DATA_TYPE_CONSTANT;
} else if (pf == "add_theme_font_override" || pf == "has_theme_font" || pf == "has_theme_font_override" || pf == "get_theme_font") {
ThemeDB::get_singleton()->get_default_theme()->get_font_list(get_class(), &sn);
type = Theme::DATA_TYPE_FONT;
} else if (pf == "add_theme_font_size_override" || pf == "has_theme_font_size" || pf == "has_theme_font_size_override" || pf == "get_theme_font_size") {
ThemeDB::get_singleton()->get_default_theme()->get_font_size_list(get_class(), &sn);
} else if (pf == "add_theme_constant_override" || pf == "has_theme_constant" || pf == "has_theme_constant_override" || pf == "get_theme_constant") {
ThemeDB::get_singleton()->get_default_theme()->get_constant_list(get_class(), &sn);
type = Theme::DATA_TYPE_FONT_SIZE;
} else if (pf == "add_theme_icon_override" || pf == "has_theme_icon" || pf == "has_theme_icon_override" || pf == "get_theme_icon") {
type = Theme::DATA_TYPE_ICON;
} else if (pf == "add_theme_style_override" || pf == "has_theme_style" || pf == "has_theme_style_override" || pf == "get_theme_style") {
type = Theme::DATA_TYPE_STYLEBOX;
}

sn.sort_custom<StringName::AlphCompare>();
for (const StringName &name : sn) {
r_options->push_back(String(name).quote());
if (type != Theme::DATA_TYPE_MAX) {
List<ThemeDB::ThemeItemBind> theme_items;
ThemeDB::get_singleton()->get_class_items(get_class_name(), &theme_items, true, type);

List<StringName> sn;
for (const ThemeDB::ThemeItemBind &E : theme_items) {
if (E.data_type == type) {
sn.push_back(E.item_name);
}
}

sn.sort_custom<StringName::AlphCompare>();
for (const StringName &name : sn) {
r_options->push_back(String(name).quote());
}
}
}
CanvasItem::get_argument_options(p_function, p_idx, r_options);
}
#endif

Expand Down
Loading