summaryrefslogtreecommitdiffstats
path: root/editor/editor_properties.cpp
diff options
context:
space:
mode:
authorajreckof <tbonhoure@ymail.com>2024-04-25 23:16:18 +0200
committerajreckof <tbonhoure@ymail.com>2024-05-03 10:56:23 +0200
commitcba96066115626d5e7d86caf47284c7b83e59dfb (patch)
treebc7df2d6f650e8227ee0501d2244800b5ddcc1f6 /editor/editor_properties.cpp
parent479b2ab777188e21109bcfe803c2599c35bb9042 (diff)
downloadredot-engine-cba96066115626d5e7d86caf47284c7b83e59dfb.tar.gz
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>
Diffstat (limited to 'editor/editor_properties.cpp')
-rw-r--r--editor/editor_properties.cpp69
1 files changed, 23 insertions, 46 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 2964fb364b..f34994a10d 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -48,6 +48,7 @@
#include "editor/property_selector.h"
#include "editor/scene_tree_dock.h"
#include "editor/themes/editor_scale.h"
+#include "editor/themes/editor_theme_manager.h"
#include "scene/2d/gpu_particles_2d.h"
#include "scene/3d/fog_volume.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() {
Node *parent = get_parent();
EditorProperty *parent_property = nullptr;
@@ -3362,12 +3327,10 @@ void EditorPropertyResource::update_property() {
sub_inspector->set_read_only(is_read_only());
sub_inspector->set_use_folding(is_using_folding());
- sub_inspector_vbox = memnew(VBoxContainer);
- sub_inspector_vbox->set_mouse_filter(MOUSE_FILTER_STOP);
- add_child(sub_inspector_vbox);
- set_bottom_editor(sub_inspector_vbox);
+ sub_inspector->set_mouse_filter(MOUSE_FILTER_STOP);
+ add_child(sub_inspector);
+ set_bottom_editor(sub_inspector);
- sub_inspector_vbox->add_child(sub_inspector);
resource_picker->set_toggle_pressed(true);
Array editor_list;
@@ -3383,20 +3346,18 @@ void EditorPropertyResource::update_property() {
_open_editor_pressed();
opened_editor = true;
}
-
- _update_property_bg();
}
if (res.ptr() != sub_inspector->get_edited_object()) {
sub_inspector->edit(res.ptr());
+ _update_property_bg();
}
} else {
if (sub_inspector) {
set_bottom_editor(nullptr);
- memdelete(sub_inspector_vbox);
+ memdelete(sub_inspector);
sub_inspector = nullptr;
- sub_inspector_vbox = nullptr;
if (opened_editor) {
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) {
switch (p_what) {
case NOTIFICATION_THEME_CHANGED: {
- if (!updating_theme) {
+ if (EditorThemeManager::is_generated_theme_outdated()) {
_update_property_bg();
}
} break;