Add colored margin in Inspector for arrays and dictionaries.

Apply suggestions from code review

Co-Authored-By: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
Co-Authored-By: Tomek <kobewi4e@gmail.com>
This commit is contained in:
ajreckof 2024-04-25 23:16:18 +02:00
parent 479b2ab777
commit cba9606611
9 changed files with 191 additions and 116 deletions

View File

@ -750,6 +750,10 @@
- [b]Localized:[/b] Displays the localized string for the current editor language if a translation is available for the given property. If no translation is available, falls back to [b]Capitalized[/b]. - [b]Localized:[/b] Displays the localized string for the current editor language if a translation is available for the given property. If no translation is available, falls back to [b]Capitalized[/b].
[b]Note:[/b] To display translated setting names in Project Settings and Editor Settings, use [member interface/editor/localize_settings] instead. [b]Note:[/b] To display translated setting names in Project Settings and Editor Settings, use [member interface/editor/localize_settings] instead.
</member> </member>
<member name="interface/inspector/delimitate_all_container_and_resources" type="bool" setter="" getter="">
If [code]true[/code], add a margin around Array, Dictionary, and Resource Editors that are not already colored.
[b]Note:[/b] If [member interface/inspector/nested_color_mode] is set to [b]Containers &amp; Resources[/b] this parameter will have no effect since those editors will already be colored
</member>
<member name="interface/inspector/disable_folding" type="bool" setter="" getter=""> <member name="interface/inspector/disable_folding" type="bool" setter="" getter="">
If [code]true[/code], forces all property groups to be expanded in the Inspector dock and prevents collapsing them. If [code]true[/code], forces all property groups to be expanded in the Inspector dock and prevents collapsing them.
</member> </member>
@ -765,6 +769,12 @@
<member name="interface/inspector/max_array_dictionary_items_per_page" type="int" setter="" getter=""> <member name="interface/inspector/max_array_dictionary_items_per_page" type="int" setter="" getter="">
The number of [Array] or [Dictionary] items to display on each "page" in the inspector. Higher values allow viewing more values per page, but take more time to load. This increased load time is noticeable when selecting nodes that have array or dictionary properties in the editor. The number of [Array] or [Dictionary] items to display on each "page" in the inspector. Higher values allow viewing more values per page, but take more time to load. This increased load time is noticeable when selecting nodes that have array or dictionary properties in the editor.
</member> </member>
<member name="interface/inspector/nested_color_mode" type="int" setter="" getter="">
Control which property editors are colored when they are opened.
- [b]Containers &amp; Resources:[/b] Color all Array, Dictionary, and Resource Editors.
- [b]Resources:[/b] Color all Resource Editors.
- [b]External Resources:[/b] Color Resource Editors that edits an external resource.
</member>
<member name="interface/inspector/open_resources_in_current_inspector" type="bool" setter="" getter=""> <member name="interface/inspector/open_resources_in_current_inspector" type="bool" setter="" getter="">
If [code]true[/code], subresources can be edited in the current inspector view. If the resource type is defined in [member interface/inspector/resources_to_open_in_new_inspector] or if this setting is [code]false[/code], attempting to edit a subresource always opens a new inspector view. If [code]true[/code], subresources can be edited in the current inspector view. If the resource type is defined in [member interface/inspector/resources_to_open_in_new_inspector] or if this setting is [code]false[/code], attempting to edit a subresource always opens a new inspector view.
</member> </member>

View File

@ -489,6 +489,49 @@ StringName EditorProperty::_get_revert_property() const {
return property; return property;
} }
void EditorProperty::_update_property_bg() {
// This function is to be called on EditorPropertyResource, EditorPropertyArray, and EditorPropertyDictionary.
// Behavior is undetermined on any other EditorProperty.
if (!is_inside_tree()) {
return;
}
begin_bulk_theme_override();
if (bottom_editor) {
ColorationMode nested_color_mode = (ColorationMode)(int)EDITOR_GET("interface/inspector/nested_color_mode");
bool delimitate_all_container_and_resources = EDITOR_GET("interface/inspector/delimitate_all_container_and_resources");
int count_subinspectors = 0;
if (is_colored(nested_color_mode)) {
Node *n = this;
while (n) {
EditorProperty *ep = Object::cast_to<EditorProperty>(n);
if (ep && ep->is_colored(nested_color_mode)) {
count_subinspectors++;
}
n = n->get_parent();
}
count_subinspectors = MIN(16, count_subinspectors);
}
add_theme_style_override(SNAME("DictionaryAddItem"), get_theme_stylebox("DictionaryAddItem" + itos(count_subinspectors), EditorStringName(EditorStyles)));
add_theme_constant_override("v_separation", 0);
if (delimitate_all_container_and_resources || is_colored(nested_color_mode)) {
add_theme_style_override("bg_selected", get_theme_stylebox("sub_inspector_property_bg" + itos(count_subinspectors), EditorStringName(EditorStyles)));
add_theme_style_override("bg", get_theme_stylebox("sub_inspector_property_bg" + itos(count_subinspectors), EditorStringName(EditorStyles)));
add_theme_color_override("property_color", get_theme_color(SNAME("sub_inspector_property_color"), EditorStringName(EditorStyles)));
bottom_editor->add_theme_style_override("panel", get_theme_stylebox("sub_inspector_bg" + itos(count_subinspectors), EditorStringName(EditorStyles)));
} else {
bottom_editor->add_theme_style_override("panel", get_theme_stylebox("sub_inspector_bg_no_border", EditorStringName(EditorStyles)));
}
} else {
remove_theme_style_override("bg_selected");
remove_theme_style_override("bg");
remove_theme_color_override("property_color");
}
end_bulk_theme_override();
queue_redraw();
}
void EditorProperty::update_editor_property_status() { void EditorProperty::update_editor_property_status() {
if (property == StringName()) { if (property == StringName()) {
return; //no property, so nothing to do return; //no property, so nothing to do
@ -3481,8 +3524,8 @@ void EditorInspector::edit(Object *p_object) {
next_object = p_object; // Some plugins need to know the next edited object when clearing the inspector. next_object = p_object; // Some plugins need to know the next edited object when clearing the inspector.
if (object) { if (object) {
_clear();
object->disconnect("property_list_changed", callable_mp(this, &EditorInspector::_changed_callback)); object->disconnect("property_list_changed", callable_mp(this, &EditorInspector::_changed_callback));
_clear();
} }
per_array_page.clear(); per_array_page.clear();
@ -3676,30 +3719,11 @@ void EditorInspector::set_use_wide_editors(bool p_enable) {
wide_editors = p_enable; wide_editors = p_enable;
} }
void EditorInspector::_update_inspector_bg() {
if (sub_inspector) {
int count_subinspectors = 0;
Node *n = get_parent();
while (n) {
EditorInspector *ei = Object::cast_to<EditorInspector>(n);
if (ei && ei->sub_inspector) {
count_subinspectors++;
}
n = n->get_parent();
}
count_subinspectors = MIN(15, count_subinspectors);
add_theme_style_override("panel", get_theme_stylebox("sub_inspector_bg" + itos(count_subinspectors), EditorStringName(Editor)));
} else {
add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree")));
}
}
void EditorInspector::set_sub_inspector(bool p_enable) { void EditorInspector::set_sub_inspector(bool p_enable) {
sub_inspector = p_enable; sub_inspector = p_enable;
if (!is_inside_tree()) { if (!is_inside_tree()) {
return; return;
} }
_update_inspector_bg();
} }
void EditorInspector::set_use_deletable_properties(bool p_enabled) { void EditorInspector::set_use_deletable_properties(bool p_enabled) {
@ -4014,7 +4038,7 @@ void EditorInspector::_notification(int p_what) {
case NOTIFICATION_READY: { case NOTIFICATION_READY: {
EditorFeatureProfileManager::get_singleton()->connect("current_feature_profile_changed", callable_mp(this, &EditorInspector::_feature_profile_changed)); EditorFeatureProfileManager::get_singleton()->connect("current_feature_profile_changed", callable_mp(this, &EditorInspector::_feature_profile_changed));
set_process(is_visible_in_tree()); set_process(is_visible_in_tree());
_update_inspector_bg(); add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree")));
} break; } break;
case NOTIFICATION_ENTER_TREE: { case NOTIFICATION_ENTER_TREE: {
@ -4088,10 +4112,6 @@ void EditorInspector::_notification(int p_what) {
} break; } break;
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
if (EditorThemeManager::is_generated_theme_outdated()) {
_update_inspector_bg();
}
bool needs_update = false; bool needs_update = false;
if (use_settings_name_style && EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor/localize_settings")) { if (use_settings_name_style && EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor/localize_settings")) {
@ -4101,6 +4121,7 @@ void EditorInspector::_notification(int p_what) {
needs_update = true; needs_update = true;
} }
} }
if (EditorSettings::get_singleton()->check_changed_settings_in_group("interface/inspector")) { if (EditorSettings::get_singleton()->check_changed_settings_in_group("interface/inspector")) {
needs_update = true; needs_update = true;
} }

View File

@ -67,6 +67,12 @@ public:
MENU_OPEN_DOCUMENTATION, MENU_OPEN_DOCUMENTATION,
}; };
enum ColorationMode {
COLORATION_CONTAINER_RESOURCE,
COLORATION_RESOURCE,
COLORATION_EXTERNAL,
};
private: private:
String label; String label;
int text_size; int text_size;
@ -141,6 +147,8 @@ protected:
virtual Variant _get_cache_value(const StringName &p_prop, bool &r_valid) const; virtual Variant _get_cache_value(const StringName &p_prop, bool &r_valid) const;
virtual StringName _get_revert_property() const; virtual StringName _get_revert_property() const;
void _update_property_bg();
public: public:
void emit_changed(const StringName &p_property, const Variant &p_value, const StringName &p_field = StringName(), bool p_changing = false); void emit_changed(const StringName &p_property, const Variant &p_value, const StringName &p_field = StringName(), bool p_changing = false);
@ -177,6 +185,8 @@ public:
void set_keying(bool p_keying); void set_keying(bool p_keying);
bool is_keying() const; bool is_keying() const;
virtual bool is_colored(ColorationMode p_mode) { return false; }
void set_deletable(bool p_enable); void set_deletable(bool p_enable);
bool is_deletable() const; bool is_deletable() const;
void add_focusable(Control *p_control); void add_focusable(Control *p_control);
@ -557,8 +567,6 @@ class EditorInspector : public ScrollContainer {
bool _is_property_disabled_by_feature_profile(const StringName &p_property); bool _is_property_disabled_by_feature_profile(const StringName &p_property);
void _update_inspector_bg();
ConfirmationDialog *add_meta_dialog = nullptr; ConfirmationDialog *add_meta_dialog = nullptr;
LineEdit *add_meta_name = nullptr; LineEdit *add_meta_name = nullptr;
OptionButton *add_meta_type = nullptr; OptionButton *add_meta_type = nullptr;

View File

@ -48,6 +48,7 @@
#include "editor/property_selector.h" #include "editor/property_selector.h"
#include "editor/scene_tree_dock.h" #include "editor/scene_tree_dock.h"
#include "editor/themes/editor_scale.h" #include "editor/themes/editor_scale.h"
#include "editor/themes/editor_theme_manager.h"
#include "scene/2d/gpu_particles_2d.h" #include "scene/2d/gpu_particles_2d.h"
#include "scene/3d/fog_volume.h" #include "scene/3d/fog_volume.h"
#include "scene/3d/gpu_particles_3d.h" #include "scene/3d/gpu_particles_3d.h"
@ -3220,42 +3221,6 @@ void EditorPropertyResource::_open_editor_pressed() {
} }
} }
void EditorPropertyResource::_update_property_bg() {
if (!is_inside_tree()) {
return;
}
updating_theme = true;
begin_bulk_theme_override();
if (sub_inspector != nullptr) {
int count_subinspectors = 0;
Node *n = get_parent();
while (n) {
EditorInspector *ei = Object::cast_to<EditorInspector>(n);
if (ei && ei->is_sub_inspector()) {
count_subinspectors++;
}
n = n->get_parent();
}
count_subinspectors = MIN(15, count_subinspectors);
add_theme_color_override("property_color", get_theme_color(SNAME("sub_inspector_property_color"), EditorStringName(Editor)));
add_theme_style_override("bg_selected", get_theme_stylebox("sub_inspector_property_bg" + itos(count_subinspectors), EditorStringName(Editor)));
add_theme_style_override("bg", get_theme_stylebox("sub_inspector_property_bg" + itos(count_subinspectors), EditorStringName(Editor)));
add_theme_constant_override("v_separation", 0);
} else {
add_theme_color_override("property_color", get_theme_color(SNAME("property_color"), SNAME("EditorProperty")));
add_theme_style_override("bg_selected", get_theme_stylebox(SNAME("bg_selected"), SNAME("EditorProperty")));
add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("EditorProperty")));
add_theme_constant_override("v_separation", get_theme_constant(SNAME("v_separation"), SNAME("EditorProperty")));
}
end_bulk_theme_override();
updating_theme = false;
queue_redraw();
}
void EditorPropertyResource::_update_preferred_shader() { void EditorPropertyResource::_update_preferred_shader() {
Node *parent = get_parent(); Node *parent = get_parent();
EditorProperty *parent_property = nullptr; EditorProperty *parent_property = nullptr;
@ -3362,12 +3327,10 @@ void EditorPropertyResource::update_property() {
sub_inspector->set_read_only(is_read_only()); sub_inspector->set_read_only(is_read_only());
sub_inspector->set_use_folding(is_using_folding()); sub_inspector->set_use_folding(is_using_folding());
sub_inspector_vbox = memnew(VBoxContainer); sub_inspector->set_mouse_filter(MOUSE_FILTER_STOP);
sub_inspector_vbox->set_mouse_filter(MOUSE_FILTER_STOP); add_child(sub_inspector);
add_child(sub_inspector_vbox); set_bottom_editor(sub_inspector);
set_bottom_editor(sub_inspector_vbox);
sub_inspector_vbox->add_child(sub_inspector);
resource_picker->set_toggle_pressed(true); resource_picker->set_toggle_pressed(true);
Array editor_list; Array editor_list;
@ -3383,20 +3346,18 @@ void EditorPropertyResource::update_property() {
_open_editor_pressed(); _open_editor_pressed();
opened_editor = true; opened_editor = true;
} }
_update_property_bg();
} }
if (res.ptr() != sub_inspector->get_edited_object()) { if (res.ptr() != sub_inspector->get_edited_object()) {
sub_inspector->edit(res.ptr()); sub_inspector->edit(res.ptr());
_update_property_bg();
} }
} else { } else {
if (sub_inspector) { if (sub_inspector) {
set_bottom_editor(nullptr); set_bottom_editor(nullptr);
memdelete(sub_inspector_vbox); memdelete(sub_inspector);
sub_inspector = nullptr; sub_inspector = nullptr;
sub_inspector_vbox = nullptr;
if (opened_editor) { if (opened_editor) {
EditorNode::get_singleton()->hide_unused_editors(); EditorNode::get_singleton()->hide_unused_editors();
@ -3442,10 +3403,26 @@ void EditorPropertyResource::fold_resource() {
} }
} }
bool EditorPropertyResource::is_colored(ColorationMode p_mode) {
switch (p_mode) {
case COLORATION_CONTAINER_RESOURCE:
return sub_inspector != nullptr;
case COLORATION_RESOURCE:
return true;
case COLORATION_EXTERNAL:
if (sub_inspector) {
Resource *edited_resource = Object::cast_to<Resource>(sub_inspector->get_edited_object());
return edited_resource && !edited_resource->is_built_in();
}
break;
}
return false;
}
void EditorPropertyResource::_notification(int p_what) { void EditorPropertyResource::_notification(int p_what) {
switch (p_what) { switch (p_what) {
case NOTIFICATION_THEME_CHANGED: { case NOTIFICATION_THEME_CHANGED: {
if (!updating_theme) { if (EditorThemeManager::is_generated_theme_outdated()) {
_update_property_bg(); _update_property_bg();
} }
} break; } break;

View File

@ -699,8 +699,6 @@ class EditorPropertyResource : public EditorProperty {
bool use_sub_inspector = false; bool use_sub_inspector = false;
EditorInspector *sub_inspector = nullptr; EditorInspector *sub_inspector = nullptr;
VBoxContainer *sub_inspector_vbox = nullptr;
bool updating_theme = false;
bool opened_editor = false; bool opened_editor = false;
void _resource_selected(const Ref<Resource> &p_resource, bool p_inspect); void _resource_selected(const Ref<Resource> &p_resource, bool p_inspect);
@ -713,7 +711,6 @@ class EditorPropertyResource : public EditorProperty {
void _sub_inspector_object_id_selected(int p_id); void _sub_inspector_object_id_selected(int p_id);
void _open_editor_pressed(); void _open_editor_pressed();
void _update_property_bg();
void _update_preferred_shader(); void _update_preferred_shader();
protected: protected:
@ -731,6 +728,8 @@ public:
void set_use_sub_inspector(bool p_enable); void set_use_sub_inspector(bool p_enable);
void fold_resource(); void fold_resource();
virtual bool is_colored(ColorationMode p_mode) override;
EditorPropertyResource(); EditorPropertyResource();
}; };

View File

@ -39,6 +39,7 @@
#include "editor/gui/editor_spin_slider.h" #include "editor/gui/editor_spin_slider.h"
#include "editor/inspector_dock.h" #include "editor/inspector_dock.h"
#include "editor/themes/editor_scale.h" #include "editor/themes/editor_scale.h"
#include "editor/themes/editor_theme_manager.h"
#include "scene/gui/button.h" #include "scene/gui/button.h"
#include "scene/gui/margin_container.h" #include "scene/gui/margin_container.h"
#include "scene/resources/packed_scene.h" #include "scene/resources/packed_scene.h"
@ -353,8 +354,7 @@ void EditorPropertyArray::update_property() {
updating = true; updating = true;
if (!container) { if (!container) {
container = memnew(MarginContainer); container = memnew(PanelContainer);
container->set_theme_type_variation("MarginContainer4px");
container->set_mouse_filter(MOUSE_FILTER_STOP); container->set_mouse_filter(MOUSE_FILTER_STOP);
add_child(container); add_child(container);
set_bottom_editor(container); set_bottom_editor(container);
@ -391,6 +391,8 @@ void EditorPropertyArray::update_property() {
paginator->connect("page_changed", callable_mp(this, &EditorPropertyArray::_page_changed)); paginator->connect("page_changed", callable_mp(this, &EditorPropertyArray::_page_changed));
vbox->add_child(paginator); vbox->add_child(paginator);
_update_property_bg();
for (int i = 0; i < page_length; i++) { for (int i = 0; i < page_length; i++) {
_create_new_property_slot(); _create_new_property_slot();
} }
@ -452,6 +454,7 @@ void EditorPropertyArray::update_property() {
memdelete(container); memdelete(container);
button_add_item = nullptr; button_add_item = nullptr;
container = nullptr; container = nullptr;
_update_property_bg();
slots.clear(); slots.clear();
} }
} }
@ -625,6 +628,10 @@ Node *EditorPropertyArray::get_base_node() {
void EditorPropertyArray::_notification(int p_what) { void EditorPropertyArray::_notification(int p_what) {
switch (p_what) { switch (p_what) {
case NOTIFICATION_THEME_CHANGED: case NOTIFICATION_THEME_CHANGED:
if (EditorThemeManager::is_generated_theme_outdated()) {
_update_property_bg();
}
[[fallthrough]];
case NOTIFICATION_ENTER_TREE: { case NOTIFICATION_ENTER_TREE: {
change_type->clear(); change_type->clear();
for (int i = 0; i < Variant::VARIANT_MAX; i++) { for (int i = 0; i < Variant::VARIANT_MAX; i++) {
@ -815,6 +822,10 @@ void EditorPropertyArray::_reorder_button_up() {
_page_changed(page_index); _page_changed(page_index);
} }
bool EditorPropertyArray::is_colored(ColorationMode p_mode) {
return p_mode == COLORATION_CONTAINER_RESOURCE;
}
void EditorPropertyArray::_bind_methods() { void EditorPropertyArray::_bind_methods() {
} }
@ -974,8 +985,7 @@ void EditorPropertyDictionary::update_property() {
updating = true; updating = true;
if (!container) { if (!container) {
container = memnew(MarginContainer); container = memnew(PanelContainer);
container->set_theme_type_variation("MarginContainer4px");
container->set_mouse_filter(MOUSE_FILTER_STOP); container->set_mouse_filter(MOUSE_FILTER_STOP);
add_child(container); add_child(container);
set_bottom_editor(container); set_bottom_editor(container);
@ -990,6 +1000,7 @@ void EditorPropertyDictionary::update_property() {
paginator = memnew(EditorPaginator); paginator = memnew(EditorPaginator);
paginator->connect("page_changed", callable_mp(this, &EditorPropertyDictionary::_page_changed)); paginator->connect("page_changed", callable_mp(this, &EditorPropertyDictionary::_page_changed));
vbox->add_child(paginator); vbox->add_child(paginator);
_update_property_bg();
for (int i = 0; i < page_length; i++) { for (int i = 0; i < page_length; i++) {
_create_new_property_slot(slots.size()); _create_new_property_slot(slots.size());
@ -997,7 +1008,7 @@ void EditorPropertyDictionary::update_property() {
add_panel = memnew(PanelContainer); add_panel = memnew(PanelContainer);
property_vbox->add_child(add_panel); property_vbox->add_child(add_panel);
add_panel->add_theme_style_override(SNAME("panel"), get_theme_stylebox(SNAME("DictionaryAddItem"), EditorStringName(EditorStyles))); add_panel->add_theme_style_override(SNAME("panel"), get_theme_stylebox(SNAME("DictionaryAddItem")));
VBoxContainer *add_vbox = memnew(VBoxContainer); VBoxContainer *add_vbox = memnew(VBoxContainer);
add_panel->add_child(add_vbox); add_panel->add_child(add_vbox);
@ -1064,6 +1075,7 @@ void EditorPropertyDictionary::update_property() {
memdelete(container); memdelete(container);
button_add_item = nullptr; button_add_item = nullptr;
container = nullptr; container = nullptr;
_update_property_bg();
add_panel = nullptr; add_panel = nullptr;
slots.clear(); slots.clear();
} }
@ -1077,6 +1089,10 @@ void EditorPropertyDictionary::_object_id_selected(const StringName &p_property,
void EditorPropertyDictionary::_notification(int p_what) { void EditorPropertyDictionary::_notification(int p_what) {
switch (p_what) { switch (p_what) {
case NOTIFICATION_THEME_CHANGED: case NOTIFICATION_THEME_CHANGED:
if (EditorThemeManager::is_generated_theme_outdated()) {
_update_property_bg();
}
[[fallthrough]];
case NOTIFICATION_ENTER_TREE: { case NOTIFICATION_ENTER_TREE: {
change_type->clear(); change_type->clear();
for (int i = 0; i < Variant::VARIANT_MAX; i++) { for (int i = 0; i < Variant::VARIANT_MAX; i++) {
@ -1127,6 +1143,10 @@ void EditorPropertyDictionary::_page_changed(int p_page) {
void EditorPropertyDictionary::_bind_methods() { void EditorPropertyDictionary::_bind_methods() {
} }
bool EditorPropertyDictionary::is_colored(ColorationMode p_mode) {
return p_mode == COLORATION_CONTAINER_RESOURCE;
}
EditorPropertyDictionary::EditorPropertyDictionary() { EditorPropertyDictionary::EditorPropertyDictionary() {
object.instantiate(); object.instantiate();
page_length = int(EDITOR_GET("interface/inspector/max_array_dictionary_items_per_page")); page_length = int(EDITOR_GET("interface/inspector/max_array_dictionary_items_per_page"));

View File

@ -113,7 +113,7 @@ class EditorPropertyArray : public EditorProperty {
int page_index = 0; int page_index = 0;
int changing_type_index; int changing_type_index;
Button *edit = nullptr; Button *edit = nullptr;
MarginContainer *container = nullptr; PanelContainer *container = nullptr;
VBoxContainer *property_vbox = nullptr; VBoxContainer *property_vbox = nullptr;
EditorSpinSlider *size_slider = nullptr; EditorSpinSlider *size_slider = nullptr;
Button *button_add_item = nullptr; Button *button_add_item = nullptr;
@ -165,6 +165,7 @@ protected:
public: public:
void setup(Variant::Type p_array_type, const String &p_hint_string = ""); void setup(Variant::Type p_array_type, const String &p_hint_string = "");
virtual void update_property() override; virtual void update_property() override;
virtual bool is_colored(ColorationMode p_mode) override;
EditorPropertyArray(); EditorPropertyArray();
}; };
@ -207,7 +208,7 @@ class EditorPropertyDictionary : public EditorProperty {
int page_index = 0; int page_index = 0;
int changing_type_index; int changing_type_index;
Button *edit = nullptr; Button *edit = nullptr;
MarginContainer *container = nullptr; PanelContainer *container = nullptr;
VBoxContainer *property_vbox = nullptr; VBoxContainer *property_vbox = nullptr;
PanelContainer *add_panel = nullptr; PanelContainer *add_panel = nullptr;
EditorSpinSlider *size_sliderv = nullptr; EditorSpinSlider *size_sliderv = nullptr;
@ -233,6 +234,7 @@ protected:
public: public:
void setup(PropertyHint p_hint); void setup(PropertyHint p_hint);
virtual void update_property() override; virtual void update_property() override;
virtual bool is_colored(ColorationMode p_mode) override;
EditorPropertyDictionary(); EditorPropertyDictionary();
}; };

View File

@ -479,6 +479,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_RANGE, "interface/inspector/max_array_dictionary_items_per_page", 20, "10,100,1") EDITOR_SETTING(Variant::INT, PROPERTY_HINT_RANGE, "interface/inspector/max_array_dictionary_items_per_page", 20, "10,100,1")
EDITOR_SETTING(Variant::BOOL, PROPERTY_HINT_NONE, "interface/inspector/show_low_level_opentype_features", false, "") EDITOR_SETTING(Variant::BOOL, PROPERTY_HINT_NONE, "interface/inspector/show_low_level_opentype_features", false, "")
EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "interface/inspector/float_drag_speed", 5.0, "0.1,100,0.01") EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "interface/inspector/float_drag_speed", 5.0, "0.1,100,0.01")
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "interface/inspector/nested_color_mode", 0, "Containers & Resources,Resources,External Resources")
EDITOR_SETTING(Variant::BOOL, PROPERTY_HINT_NONE, "interface/inspector/delimitate_all_container_and_resources", true, "")
EDITOR_SETTING_USAGE(Variant::INT, PROPERTY_HINT_ENUM, "interface/inspector/default_property_name_style", EditorPropertyNameProcessor::STYLE_CAPITALIZED, "Raw,Capitalized,Localized", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); EDITOR_SETTING_USAGE(Variant::INT, PROPERTY_HINT_ENUM, "interface/inspector/default_property_name_style", EditorPropertyNameProcessor::STYLE_CAPITALIZED, "Raw,Capitalized,Localized", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
// The lowest value is equal to the minimum float step for 32-bit floats. // The lowest value is equal to the minimum float step for 32-bit floats.
// The step must be set manually, as changing this setting should not change the step here. // The step must be set manually, as changing this setting should not change the step here.

View File

@ -2036,36 +2036,6 @@ void EditorThemeManager::_populate_editor_styles(const Ref<EditorTheme> &p_theme
// Editor inspector. // Editor inspector.
{ {
// Sub-inspectors.
for (int i = 0; i < 16; i++) {
Color si_base_color = p_config.accent_color;
float hue_rotate = (i * 2 % 16) / 16.0;
si_base_color.set_hsv(Math::fmod(float(si_base_color.get_h() + hue_rotate), float(1.0)), si_base_color.get_s(), si_base_color.get_v());
si_base_color = p_config.accent_color.lerp(si_base_color, p_config.subresource_hue_tint);
// Sub-inspector background.
Ref<StyleBoxFlat> sub_inspector_bg = p_config.base_style->duplicate();
sub_inspector_bg->set_bg_color(p_config.dark_color_1.lerp(si_base_color, 0.08));
sub_inspector_bg->set_border_width_all(2 * EDSCALE);
sub_inspector_bg->set_border_color(si_base_color * Color(0.7, 0.7, 0.7, 0.8));
sub_inspector_bg->set_content_margin_all(4 * EDSCALE);
sub_inspector_bg->set_corner_radius(CORNER_TOP_LEFT, 0);
sub_inspector_bg->set_corner_radius(CORNER_TOP_RIGHT, 0);
p_theme->set_stylebox("sub_inspector_bg" + itos(i), EditorStringName(Editor), sub_inspector_bg);
// EditorProperty background while it has a sub-inspector open.
Ref<StyleBoxFlat> bg_color = make_flat_stylebox(si_base_color * Color(0.7, 0.7, 0.7, 0.8), 0, 0, 0, 0, p_config.corner_radius);
bg_color->set_anti_aliased(false);
bg_color->set_corner_radius(CORNER_BOTTOM_LEFT, 0);
bg_color->set_corner_radius(CORNER_BOTTOM_RIGHT, 0);
p_theme->set_stylebox("sub_inspector_property_bg" + itos(i), EditorStringName(Editor), bg_color);
}
p_theme->set_color("sub_inspector_property_color", EditorStringName(Editor), p_config.dark_theme ? Color(1, 1, 1, 1) : Color(0, 0, 0, 1));
// EditorProperty. // EditorProperty.
Ref<StyleBoxFlat> style_property_bg = p_config.base_style->duplicate(); Ref<StyleBoxFlat> style_property_bg = p_config.base_style->duplicate();
@ -2125,13 +2095,79 @@ void EditorThemeManager::_populate_editor_styles(const Ref<EditorTheme> &p_theme
p_theme->set_constant("inspector_margin", EditorStringName(Editor), 12 * EDSCALE); p_theme->set_constant("inspector_margin", EditorStringName(Editor), 12 * EDSCALE);
// Colored EditorProperty.
for (int i = 0; i < 16; i++) {
Color si_base_color = p_config.accent_color;
float hue_rotate = (i * 2 % 16) / 16.0;
si_base_color.set_hsv(Math::fmod(float(si_base_color.get_h() + hue_rotate), float(1.0)), si_base_color.get_s(), si_base_color.get_v());
si_base_color = p_config.accent_color.lerp(si_base_color, p_config.subresource_hue_tint);
// Sub-inspector background.
Ref<StyleBoxFlat> sub_inspector_bg = p_config.base_style->duplicate();
sub_inspector_bg->set_bg_color(p_config.dark_color_1.lerp(si_base_color, 0.08));
sub_inspector_bg->set_border_width_all(2 * EDSCALE);
sub_inspector_bg->set_border_color(si_base_color * Color(0.7, 0.7, 0.7, 0.8));
sub_inspector_bg->set_content_margin_all(4 * EDSCALE);
sub_inspector_bg->set_corner_radius(CORNER_TOP_LEFT, 0);
sub_inspector_bg->set_corner_radius(CORNER_TOP_RIGHT, 0);
p_theme->set_stylebox("sub_inspector_bg" + itos(i + 1), EditorStringName(EditorStyles), sub_inspector_bg);
// EditorProperty background while it has a sub-inspector open.
Ref<StyleBoxFlat> bg_color = make_flat_stylebox(si_base_color * Color(0.7, 0.7, 0.7, 0.8), 0, 0, 0, 0, p_config.corner_radius);
bg_color->set_anti_aliased(false);
bg_color->set_corner_radius(CORNER_BOTTOM_LEFT, 0);
bg_color->set_corner_radius(CORNER_BOTTOM_RIGHT, 0);
p_theme->set_stylebox("sub_inspector_property_bg" + itos(i + 1), EditorStringName(EditorStyles), bg_color);
// Dictionary editor add item.
// Expand to the left and right by 4px to compensate for the dictionary editor margins.
Color style_dictionary_bg_color = p_config.dark_color_3.lerp(si_base_color, 0.08);
Ref<StyleBoxFlat> style_dictionary_add_item = make_flat_stylebox(style_dictionary_bg_color, 0, 4, 0, 4, p_config.corner_radius);
style_dictionary_add_item->set_expand_margin(SIDE_LEFT, 2 * EDSCALE);
style_dictionary_add_item->set_expand_margin(SIDE_RIGHT, 2 * EDSCALE);
p_theme->set_stylebox("DictionaryAddItem" + itos(i + 1), EditorStringName(EditorStyles), style_dictionary_add_item);
}
Color si_base_color = p_config.accent_color;
// Sub-inspector background.
Ref<StyleBoxFlat> sub_inspector_bg = p_config.base_style->duplicate();
sub_inspector_bg->set_bg_color(Color(1, 1, 1, 0));
sub_inspector_bg->set_border_width_all(2 * EDSCALE);
sub_inspector_bg->set_border_color(p_config.dark_color_1.lerp(si_base_color, 0.15));
sub_inspector_bg->set_content_margin_all(4 * EDSCALE);
sub_inspector_bg->set_corner_radius(CORNER_TOP_LEFT, 0);
sub_inspector_bg->set_corner_radius(CORNER_TOP_RIGHT, 0);
p_theme->set_stylebox("sub_inspector_bg0", EditorStringName(EditorStyles), sub_inspector_bg);
// Sub-inspector background no border.
Ref<StyleBoxFlat> sub_inspector_bg_no_border = p_config.base_style->duplicate();
sub_inspector_bg_no_border->set_content_margin_all(2 * EDSCALE);
sub_inspector_bg_no_border->set_bg_color(p_config.dark_color_2.lerp(p_config.dark_color_3, 0.15));
p_theme->set_stylebox("sub_inspector_bg_no_border", EditorStringName(EditorStyles), sub_inspector_bg_no_border);
// EditorProperty background while it has a sub-inspector open.
Ref<StyleBoxFlat> bg_color = make_flat_stylebox(p_config.dark_color_1.lerp(si_base_color, 0.15), 0, 0, 0, 0, p_config.corner_radius);
bg_color->set_anti_aliased(false);
bg_color->set_corner_radius(CORNER_BOTTOM_LEFT, 0);
bg_color->set_corner_radius(CORNER_BOTTOM_RIGHT, 0);
p_theme->set_stylebox("sub_inspector_property_bg0", EditorStringName(EditorStyles), bg_color);
p_theme->set_color("sub_inspector_property_color", EditorStringName(EditorStyles), p_config.dark_theme ? Color(1, 1, 1, 1) : Color(0, 0, 0, 1));
// Dictionary editor. // Dictionary editor.
// Expand to the left and right by 4px to compensate for the dictionary editor margins. // Expand to the left and right by 4px to compensate for the dictionary editor margins.
Ref<StyleBoxFlat> style_dictionary_add_item = make_flat_stylebox(prop_subsection_color, 0, 4, 0, 4, p_config.corner_radius); Ref<StyleBoxFlat> style_dictionary_add_item = make_flat_stylebox(prop_subsection_color, 0, 4, 0, 4, p_config.corner_radius);
style_dictionary_add_item->set_expand_margin(SIDE_LEFT, 4 * EDSCALE); style_dictionary_add_item->set_expand_margin(SIDE_LEFT, 2 * EDSCALE);
style_dictionary_add_item->set_expand_margin(SIDE_RIGHT, 4 * EDSCALE); style_dictionary_add_item->set_expand_margin(SIDE_RIGHT, 2 * EDSCALE);
p_theme->set_stylebox("DictionaryAddItem", EditorStringName(EditorStyles), style_dictionary_add_item); p_theme->set_stylebox("DictionaryAddItem0", EditorStringName(EditorStyles), style_dictionary_add_item);
} }
// Editor help. // Editor help.