diff options
Diffstat (limited to 'editor/scene_tree_editor.cpp')
-rw-r--r-- | editor/scene_tree_editor.cpp | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index 73523474ef..dc95b73569 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -120,7 +120,7 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i undo_redo->commit_action(); } else if (p_id == BUTTON_WARNING) { String config_err = n->get_configuration_warnings_as_string(); - if (config_err == String()) { + if (config_err.is_empty()) { return; } config_err = config_err.word_wrap(80); @@ -297,16 +297,16 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll item->add_button(0, get_theme_icon(SNAME("InstanceOptions"), SNAME("EditorIcons")), BUTTON_SUBSCENE, false, TTR("Open in Editor")); 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()) { + if (!p_node->get_editor_description().is_empty()) { tooltip += "\n\n" + p_node->get_editor_description(); } item->set_tooltip(0, tooltip); - } else if (p_node != get_scene_node() && p_node->get_scene_file_path() != "" && can_open_instance) { + } else if (p_node != get_scene_node() && !p_node->get_scene_file_path().is_empty() && can_open_instance) { item->add_button(0, get_theme_icon(SNAME("InstanceOptions"), SNAME("EditorIcons")), BUTTON_SUBSCENE, false, TTR("Open in Editor")); 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()) { + if (!p_node->get_editor_description().is_empty()) { tooltip += "\n\n" + p_node->get_editor_description(); } @@ -318,7 +318,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll } String tooltip = String(p_node->get_name()) + "\n" + TTR("Type:") + " " + type; - if (p_node->get_editor_description() != String()) { + if (!p_node->get_editor_description().is_empty()) { tooltip += "\n\n" + p_node->get_editor_description(); } @@ -955,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_scene_file_path() == String()) { + if (!n->get_owner() || n->get_owner() == get_scene_node() || n->get_owner()->get_scene_file_path().is_empty()) { selected.push_back(n); icons.push_back(next->get_icon(0)); } @@ -1069,7 +1069,7 @@ bool SceneTreeEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_d } } - return String(d["type"]) == "nodes" && filter == String(); + return String(d["type"]) == "nodes" && filter.is_empty(); } void SceneTreeEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) { @@ -1122,7 +1122,7 @@ void SceneTreeEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, } void SceneTreeEditor::_rmb_select(const Vector2 &p_pos) { - emit_signal(SNAME("rmb_pressed"), tree->get_screen_transform().xform(p_pos)); + emit_signal(SNAME("rmb_pressed"), tree->get_screen_position() + p_pos); } void SceneTreeEditor::update_warning() { @@ -1256,6 +1256,10 @@ void SceneTreeDialog::popup_scenetree_dialog() { popup_centered_clamped(Size2(350, 700) * EDSCALE); } +void SceneTreeDialog::_update_theme() { + filter->set_right_icon(tree->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); +} + void SceneTreeDialog::_notification(int p_what) { switch (p_what) { case NOTIFICATION_VISIBILITY_CHANGED: { @@ -1265,8 +1269,10 @@ void SceneTreeDialog::_notification(int p_what) { } break; case NOTIFICATION_ENTER_TREE: { connect("confirmed", callable_mp(this, &SceneTreeDialog::_select)); - filter->set_right_icon(tree->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); - filter->set_clear_button_enabled(true); + _update_theme(); + } break; + case NOTIFICATION_THEME_CHANGED: { + _update_theme(); } break; case NOTIFICATION_EXIT_TREE: { disconnect("confirmed", callable_mp(this, &SceneTreeDialog::_select)); @@ -1303,6 +1309,7 @@ SceneTreeDialog::SceneTreeDialog() { filter = memnew(LineEdit); filter->set_h_size_flags(Control::SIZE_EXPAND_FILL); filter->set_placeholder(TTR("Filter nodes")); + filter->set_clear_button_enabled(true); filter->add_theme_constant_override("minimum_character_width", 0); filter->connect("text_changed", callable_mp(this, &SceneTreeDialog::_filter_changed)); vbc->add_child(filter); |