summaryrefslogtreecommitdiff
path: root/editor/scene_tree_editor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/scene_tree_editor.cpp')
-rw-r--r--editor/scene_tree_editor.cpp55
1 files changed, 33 insertions, 22 deletions
diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp
index e7ba80677d..73523474ef 100644
--- a/editor/scene_tree_editor.cpp
+++ b/editor/scene_tree_editor.cpp
@@ -66,7 +66,7 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i
emit_signal(SNAME("open"), n->get_scene_inherited_state()->get_path());
}
} else {
- emit_signal(SNAME("open"), n->get_filename());
+ emit_signal(SNAME("open"), n->get_scene_file_path());
}
} else if (p_id == BUTTON_SCRIPT) {
Ref<Script> script_typed = n->get_script();
@@ -102,7 +102,7 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i
undo_redo->commit_action();
} else if (p_id == BUTTON_PIN) {
if (n->is_class("AnimationPlayer")) {
- AnimationPlayerEditor::singleton->unpin();
+ AnimationPlayerEditor::get_singleton()->unpin();
_update_tree();
}
@@ -291,19 +291,21 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll
}
}
+ // Display the node name in all tooltips so that long node names can be previewed
+ // without having to rename them.
if (p_node == get_scene_node() && p_node->get_scene_inherited_state().is_valid()) {
item->add_button(0, get_theme_icon(SNAME("InstanceOptions"), SNAME("EditorIcons")), BUTTON_SUBSCENE, false, TTR("Open in Editor"));
- String tooltip = TTR("Inherits:") + " " + p_node->get_scene_inherited_state()->get_path() + "\n" + TTR("Type:") + " " + p_node->get_class();
+ String tooltip = String(p_node->get_name()) + "\n" + TTR("Inherits:") + " " + p_node->get_scene_inherited_state()->get_path() + "\n" + TTR("Type:") + " " + p_node->get_class();
if (p_node->get_editor_description() != String()) {
tooltip += "\n\n" + p_node->get_editor_description();
}
item->set_tooltip(0, tooltip);
- } else if (p_node != get_scene_node() && p_node->get_filename() != "" && can_open_instance) {
+ } else if (p_node != get_scene_node() && p_node->get_scene_file_path() != "" && can_open_instance) {
item->add_button(0, get_theme_icon(SNAME("InstanceOptions"), SNAME("EditorIcons")), BUTTON_SUBSCENE, false, TTR("Open in Editor"));
- String tooltip = TTR("Instance:") + " " + p_node->get_filename() + "\n" + TTR("Type:") + " " + p_node->get_class();
+ String tooltip = String(p_node->get_name()) + "\n" + TTR("Instance:") + " " + p_node->get_scene_file_path() + "\n" + TTR("Type:") + " " + p_node->get_class();
if (p_node->get_editor_description() != String()) {
tooltip += "\n\n" + p_node->get_editor_description();
}
@@ -315,7 +317,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll
type = p_node->get_class();
}
- String tooltip = TTR("Type:") + " " + type;
+ String tooltip = String(p_node->get_name()) + "\n" + TTR("Type:") + " " + type;
if (p_node->get_editor_description() != String()) {
tooltip += "\n\n" + p_node->get_editor_description();
}
@@ -384,7 +386,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll
_update_visibility_color(p_node, item);
} else if (p_node->is_class("AnimationPlayer")) {
- bool is_pinned = AnimationPlayerEditor::singleton->get_player() == p_node && AnimationPlayerEditor::singleton->is_pinned();
+ bool is_pinned = AnimationPlayerEditor::get_singleton()->get_player() == p_node && AnimationPlayerEditor::get_singleton()->is_pinned();
if (is_pinned) {
item->add_button(0, get_theme_icon(SNAME("Pin"), SNAME("EditorIcons")), BUTTON_PIN, false, TTR("AnimationPlayer is pinned.\nClick to unpin."));
@@ -520,12 +522,12 @@ void SceneTreeEditor::_node_removed(Node *p_node) {
if (p_node == selected) {
selected = nullptr;
- emit_signal("node_selected");
+ emit_signal(SNAME("node_selected"));
}
}
void SceneTreeEditor::_node_renamed(Node *p_node) {
- if (!get_scene_node()->is_ancestor_of(p_node)) {
+ if (p_node != get_scene_node() && !get_scene_node()->is_ancestor_of(p_node)) {
return;
}
@@ -628,7 +630,7 @@ void SceneTreeEditor::_selected_changed() {
selected = get_node(np);
blocked++;
- emit_signal("node_selected");
+ emit_signal(SNAME("node_selected"));
blocked--;
}
@@ -735,17 +737,18 @@ void SceneTreeEditor::set_selected(Node *p_node, bool p_emit_selected) {
TreeItem *item = p_node ? _find(tree->get_root(), p_node->get_path()) : nullptr;
if (item) {
- // make visible when it's collapsed
- TreeItem *node = item->get_parent();
- while (node && node != tree->get_root()) {
- node->set_collapsed(false);
- node = node->get_parent();
+ if (auto_expand_selected) {
+ // Make visible when it's collapsed.
+ TreeItem *node = item->get_parent();
+ while (node && node != tree->get_root()) {
+ node->set_collapsed(false);
+ node = node->get_parent();
+ }
+ item->select(0);
+ item->set_as_cursor(0);
+ selected = p_node;
+ tree->ensure_cursor_is_visible();
}
- item->select(0);
- item->set_as_cursor(0);
- selected = p_node;
- tree->ensure_cursor_is_visible();
-
} else {
if (!p_node) {
selected = nullptr;
@@ -755,7 +758,7 @@ void SceneTreeEditor::set_selected(Node *p_node, bool p_emit_selected) {
}
if (p_emit_selected) {
- emit_signal("node_selected");
+ emit_signal(SNAME("node_selected"));
}
}
@@ -952,7 +955,7 @@ Variant SceneTreeEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from
Node *n = get_node(np);
if (n) {
// Only allow selection if not part of an instantiated scene.
- if (!n->get_owner() || n->get_owner() == get_scene_node() || n->get_owner()->get_filename() == String()) {
+ if (!n->get_owner() || n->get_owner() == get_scene_node() || n->get_owner()->get_scene_file_path() == String()) {
selected.push_back(n);
icons.push_back(next->get_icon(0));
}
@@ -1125,11 +1128,19 @@ void SceneTreeEditor::_rmb_select(const Vector2 &p_pos) {
void SceneTreeEditor::update_warning() {
_warning_changed(nullptr);
}
+
void SceneTreeEditor::_warning_changed(Node *p_for_node) {
//should use a timer
update_timer->start();
}
+void SceneTreeEditor::set_auto_expand_selected(bool p_auto, bool p_update_settings) {
+ if (p_update_settings) {
+ EditorSettings::get_singleton()->set("docks/scene_tree/auto_expand_to_selected", p_auto);
+ }
+ auto_expand_selected = p_auto;
+}
+
void SceneTreeEditor::set_connect_to_script_mode(bool p_enable) {
connect_to_script_mode = p_enable;
update_tree();