From f9dc108928a98e2cf4c49d2fdd0b9df41e7f7e6c Mon Sep 17 00:00:00 2001 From: kobewi Date: Fri, 10 Jun 2022 03:02:09 +0200 Subject: [PATCH] Remove viewport restrictions in 2D editor --- editor/plugins/canvas_item_editor_plugin.cpp | 29 +------------------- editor/plugins/control_editor_plugin.cpp | 2 +- scene/gui/control.cpp | 2 +- 3 files changed, 3 insertions(+), 30 deletions(-) diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 40894cdb8b11..63bcbe32bba8 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -763,7 +763,7 @@ List CanvasItemEditor::_get_edited_canvas_items(bool retrieve_lock List selection; for (const KeyValue &E : editor_selection->get_selection()) { CanvasItem *canvas_item = Object::cast_to(E.key); - if (canvas_item && canvas_item->is_visible_in_tree() && canvas_item->get_viewport() == EditorNode::get_singleton()->get_scene_root() && (retrieve_locked || !_is_node_locked(canvas_item))) { + if (canvas_item && canvas_item->is_visible_in_tree() && (retrieve_locked || !_is_node_locked(canvas_item))) { CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data(canvas_item); if (se) { selection.push_back(canvas_item); @@ -4107,10 +4107,6 @@ void CanvasItemEditor::_insert_animation_keys(bool p_location, bool p_rotation, continue; } - if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { - continue; - } - if (Object::cast_to(canvas_item)) { Node2D *n2d = Object::cast_to(canvas_item); @@ -4311,9 +4307,6 @@ void CanvasItemEditor::_popup_callback(int p_op) { if (!canvas_item || !canvas_item->is_inside_tree()) { continue; } - if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { - continue; - } undo_redo->add_do_method(canvas_item, "set_meta", "_edit_lock_", true); undo_redo->add_undo_method(canvas_item, "remove_meta", "_edit_lock_"); @@ -4333,9 +4326,6 @@ void CanvasItemEditor::_popup_callback(int p_op) { if (!canvas_item || !canvas_item->is_inside_tree()) { continue; } - if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { - continue; - } undo_redo->add_do_method(canvas_item, "remove_meta", "_edit_lock_"); undo_redo->add_undo_method(canvas_item, "set_meta", "_edit_lock_", true); @@ -4355,9 +4345,6 @@ void CanvasItemEditor::_popup_callback(int p_op) { if (!canvas_item || !canvas_item->is_inside_tree()) { continue; } - if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { - continue; - } undo_redo->add_do_method(canvas_item, "set_meta", "_edit_group_", true); undo_redo->add_undo_method(canvas_item, "remove_meta", "_edit_group_"); @@ -4377,9 +4364,6 @@ void CanvasItemEditor::_popup_callback(int p_op) { if (!canvas_item || !canvas_item->is_inside_tree()) { continue; } - if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { - continue; - } undo_redo->add_do_method(canvas_item, "remove_meta", "_edit_group_"); undo_redo->add_undo_method(canvas_item, "set_meta", "_edit_group_", true); @@ -4418,10 +4402,6 @@ void CanvasItemEditor::_popup_callback(int p_op) { continue; } - if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { - continue; - } - if (Object::cast_to(canvas_item)) { Node2D *n2d = Object::cast_to(canvas_item); PoseClipboard pc; @@ -4464,10 +4444,6 @@ void CanvasItemEditor::_popup_callback(int p_op) { continue; } - if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { - continue; - } - if (Object::cast_to(canvas_item)) { Node2D *n2d = Object::cast_to(canvas_item); @@ -4579,9 +4555,6 @@ void CanvasItemEditor::_focus_selection(int p_op) { if (!canvas_item) { continue; } - if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { - continue; - } // counting invisible items, for now //if (!canvas_item->is_visible_in_tree()) continue; diff --git a/editor/plugins/control_editor_plugin.cpp b/editor/plugins/control_editor_plugin.cpp index ebb0da1ad725..539bbb344e2c 100644 --- a/editor/plugins/control_editor_plugin.cpp +++ b/editor/plugins/control_editor_plugin.cpp @@ -624,7 +624,7 @@ List ControlEditorToolbar::_get_edited_controls(bool retrieve_locked, List selection; for (const KeyValue &E : editor_selection->get_selection()) { Control *control = Object::cast_to(E.key); - if (control && control->is_visible_in_tree() && control->get_viewport() == EditorNode::get_singleton()->get_scene_root() && (retrieve_locked || !_is_node_locked(control))) { + if (control && control->is_visible_in_tree() && (retrieve_locked || !_is_node_locked(control))) { selection.push_back(control); } } diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index db78b4adb692..4dc96164e482 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -1417,7 +1417,7 @@ Rect2 Control::get_parent_anchorable_rect() const { } else { #ifdef TOOLS_ENABLED Node *edited_root = get_tree()->get_edited_scene_root(); - if (edited_root && (this == edited_root || edited_root->is_ancestor_of(this))) { + if (edited_root && this == edited_root) { parent_rect.size = Size2(ProjectSettings::get_singleton()->get("display/window/size/viewport_width"), ProjectSettings::get_singleton()->get("display/window/size/viewport_height")); } else { parent_rect = get_viewport()->get_visible_rect();