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:
parent
479b2ab777
commit
cba9606611
9 changed files with 191 additions and 116 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue