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:
风青山 2025-02-03 23:06:15 +08:00
parent f60f69aa57
commit bef64baa18
No known key found for this signature in database
GPG key ID: 056264D70ECB0FD5
5 changed files with 76 additions and 11 deletions

View file

@ -567,6 +567,16 @@ StringName EditorProperty::get_edited_property() const {
return property;
}
Variant EditorProperty::get_edited_property_display_value() const {
ERR_FAIL_NULL_V(object, Variant());
Control *control = Object::cast_to<Control>(object);
if (checkable && !checked && control && String(property).begins_with("theme_override_")) {
return control->get_used_theme_item(property);
} else {
return get_edited_property_value();
}
}
EditorInspector *EditorProperty::get_parent_inspector() const {
Node *parent = get_parent();
while (parent) {
@ -4386,13 +4396,26 @@ void EditorInspector::_property_checked(const String &p_path, bool p_checked) {
_edit_set(p_path, Variant(), false, "");
} else {
Variant to_create;
List<PropertyInfo> pinfo;
object->get_property_list(&pinfo);
for (const PropertyInfo &E : pinfo) {
if (E.name == p_path) {
Callable::CallError ce;
Variant::construct(E.type, to_create, nullptr, 0, ce);
break;
Control *control = Object::cast_to<Control>(object);
bool skip = false;
if (control && p_path.begins_with("theme_override_")) {
to_create = control->get_used_theme_item(p_path);
Ref<Resource> resource = to_create;
if (resource.is_valid()) {
to_create = resource->duplicate();
}
skip = true;
}
if (!skip) {
List<PropertyInfo> pinfo;
object->get_property_list(&pinfo);
for (const PropertyInfo &E : pinfo) {
if (E.name == p_path) {
Callable::CallError ce;
Variant::construct(E.type, to_create, nullptr, 0, ce);
break;
}
}
}
_edit_set(p_path, to_create, false, "");