Display the actual used theme items in the Inspector
Closes: godotengine/godot-proposals#4439. Allows viewing the default values of the currently used theme item in the Inspector. For theme item properties of resource type, editing the default resource does not make sense. Use **Make Unique** to create a copy before editing.
This commit is contained in:
parent
f60f69aa57
commit
bef64baa18
5 changed files with 76 additions and 11 deletions
|
|
@ -2808,6 +2808,44 @@ Variant Control::get_theme_item(Theme::DataType p_data_type, const StringName &p
|
|||
return Variant();
|
||||
}
|
||||
|
||||
Variant Control::get_used_theme_item(const String &p_full_name, const StringName &p_theme_type) const {
|
||||
if (p_full_name.begins_with("theme_override_icons/")) {
|
||||
String name = p_full_name.substr(strlen("theme_override_icons/"));
|
||||
if (has_theme_icon(name)) { // Exclude cached and default ones.
|
||||
return get_theme_icon(name);
|
||||
}
|
||||
} else if (p_full_name.begins_with("theme_override_styles/")) {
|
||||
String name = p_full_name.substr(strlen("theme_override_styles/"));
|
||||
if (has_theme_stylebox(name)) {
|
||||
return get_theme_stylebox(name);
|
||||
}
|
||||
} else if (p_full_name.begins_with("theme_override_fonts/")) {
|
||||
String name = p_full_name.substr(strlen("theme_override_fonts/"));
|
||||
if (has_theme_font(name)) {
|
||||
return get_theme_font(name);
|
||||
}
|
||||
} else if (p_full_name.begins_with("theme_override_font_sizes/")) {
|
||||
String name = p_full_name.substr(strlen("theme_override_font_sizes/"));
|
||||
if (has_theme_font_size(name)) {
|
||||
return get_theme_font_size(name);
|
||||
}
|
||||
} else if (p_full_name.begins_with("theme_override_colors/")) {
|
||||
String name = p_full_name.substr(strlen("theme_override_colors/"));
|
||||
if (has_theme_color(name)) {
|
||||
return get_theme_color(name);
|
||||
}
|
||||
} else if (p_full_name.begins_with("theme_override_constants/")) {
|
||||
String name = p_full_name.substr(strlen("theme_override_constants/"));
|
||||
if (has_theme_constant(name)) {
|
||||
return get_theme_constant(name);
|
||||
}
|
||||
} else {
|
||||
ERR_FAIL_V_MSG(Variant(), vformat("The property %s is not a theme item.", p_full_name));
|
||||
}
|
||||
|
||||
return Variant();
|
||||
}
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
Ref<Texture2D> Control::get_editor_theme_icon(const StringName &p_name) const {
|
||||
return get_theme_icon(p_name, SNAME("EditorIcons"));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue