summaryrefslogtreecommitdiffstats
path: root/editor
diff options
context:
space:
mode:
authorkobewi <kobewi4e@gmail.com>2023-08-28 02:37:47 +0200
committerkobewi <kobewi4e@gmail.com>2023-08-28 02:37:47 +0200
commitb88007b6c55bd383a9a0f052cf4a7f6d8dd56e4e (patch)
treeefb9f29d57a88fcef3c01adc53f072c9d5b49369 /editor
parent6da4ad16624484398331f393b503f8b5e2888c51 (diff)
downloadredot-engine-b88007b6c55bd383a9a0f052cf4a7f6d8dd56e4e.tar.gz
Properly remember custom text color in scene tree
Diffstat (limited to 'editor')
-rw-r--r--editor/gui/scene_tree_editor.cpp26
-rw-r--r--editor/gui/scene_tree_editor.h1
2 files changed, 19 insertions, 8 deletions
diff --git a/editor/gui/scene_tree_editor.cpp b/editor/gui/scene_tree_editor.cpp
index 1a02e45f84..0862af37b6 100644
--- a/editor/gui/scene_tree_editor.cpp
+++ b/editor/gui/scene_tree_editor.cpp
@@ -234,7 +234,7 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
item->add_button(0, get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), BUTTON_SCRIPT);
} else {
//has no script (or script is a custom type)
- item->set_custom_color(0, get_theme_color(SNAME("disabled_font_color"), SNAME("Editor")));
+ _set_item_custom_color(item, get_theme_color(SNAME("disabled_font_color"), SNAME("Editor")));
item->set_selectable(0, false);
if (!scr.is_null()) { // make sure to mark the script if a custom type
@@ -251,11 +251,11 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
node_name += " " + TTR("(Connecting From)");
}
item->set_text(0, node_name);
- item->set_custom_color(0, accent);
+ _set_item_custom_color(item, accent);
}
} else if (part_of_subscene) {
if (valid_types.size() == 0) {
- item->set_custom_color(0, get_theme_color(SNAME("warning_color"), SNAME("Editor")));
+ _set_item_custom_color(item, get_theme_color(SNAME("warning_color"), SNAME("Editor")));
}
} else if (marked.has(p_node)) {
String node_name = p_node->get_name();
@@ -264,15 +264,15 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
}
item->set_text(0, node_name);
item->set_selectable(0, marked_selectable);
- item->set_custom_color(0, get_theme_color(SNAME("accent_color"), SNAME("Editor")));
+ _set_item_custom_color(item, get_theme_color(SNAME("accent_color"), SNAME("Editor")));
} else if (!p_node->can_process()) {
- item->set_custom_color(0, get_theme_color(SNAME("disabled_font_color"), SNAME("Editor")));
+ _set_item_custom_color(item, get_theme_color(SNAME("disabled_font_color"), SNAME("Editor")));
} else if (!marked_selectable && !marked_children_selectable) {
Node *node = p_node;
while (node) {
if (marked.has(node)) {
item->set_selectable(0, false);
- item->set_custom_color(0, get_theme_color(SNAME("error_color"), SNAME("Editor")));
+ _set_item_custom_color(item, get_theme_color(SNAME("error_color"), SNAME("Editor")));
break;
}
node = node->get_parent();
@@ -500,7 +500,7 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
}
if (!valid) {
- item->set_custom_color(0, get_theme_color(SNAME("disabled_font_color"), SNAME("Editor")));
+ _set_item_custom_color(item, get_theme_color(SNAME("disabled_font_color"), SNAME("Editor")));
item->set_selectable(0, false);
}
}
@@ -550,6 +550,11 @@ void SceneTreeEditor::_update_visibility_color(Node *p_node, TreeItem *p_item) {
}
}
+void SceneTreeEditor::_set_item_custom_color(TreeItem *p_item, Color p_color) {
+ p_item->set_custom_color(0, p_color);
+ p_item->set_meta(SNAME("custom_color"), p_color);
+}
+
void SceneTreeEditor::_node_script_changed(Node *p_node) {
if (tree_dirty) {
return;
@@ -661,7 +666,12 @@ bool SceneTreeEditor::_update_filter(TreeItem *p_parent, bool p_scroll_to_select
}
if (selectable) {
- p_parent->clear_custom_color(0);
+ Color custom_color = p_parent->get_meta(SNAME("custom_color"), Color(0, 0, 0, 0));
+ if (custom_color == Color(0, 0, 0, 0)) {
+ p_parent->clear_custom_color(0);
+ } else {
+ p_parent->set_custom_color(0, custom_color);
+ }
p_parent->set_selectable(0, true);
} else if (keep_for_children) {
p_parent->set_custom_color(0, get_theme_color(SNAME("disabled_font_color"), SNAME("Editor")));
diff --git a/editor/gui/scene_tree_editor.h b/editor/gui/scene_tree_editor.h
index 9e38b49bd5..f38c76a21a 100644
--- a/editor/gui/scene_tree_editor.h
+++ b/editor/gui/scene_tree_editor.h
@@ -117,6 +117,7 @@ class SceneTreeEditor : public Control {
void _node_script_changed(Node *p_node);
void _node_visibility_changed(Node *p_node);
void _update_visibility_color(Node *p_node, TreeItem *p_item);
+ void _set_item_custom_color(TreeItem *p_item, Color p_color);
void _selection_changed();
Node *get_scene_node();