diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-05-17 08:22:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-17 08:22:12 +0200 |
commit | 743fce68340c9f4e0aa171efb8e9c513e764cd00 (patch) | |
tree | d8e6a2d66ff9a838ea48a5fea3bd70aecc0e1fd7 /editor/plugins/canvas_item_editor_plugin.cpp | |
parent | 067c1eb923dd38bac7ad86da52d94394eeac44e5 (diff) | |
parent | 4cb74a52707cdbf64827e72ada2cc8b58d609fac (diff) |
Merge pull request #59242 from Sauermann/fix-editor-select-toplevel
Fix that Top Level CanvasItems are unselectable in editor
Diffstat (limited to 'editor/plugins/canvas_item_editor_plugin.cpp')
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 54408e953e..a7e3d17fdc 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -562,7 +562,11 @@ void CanvasItemEditor::_expand_encompassing_rect_using_children(Rect2 &r_rect, c } if (canvas_item && canvas_item->is_visible_in_tree() && (include_locked_nodes || !_is_node_locked(canvas_item))) { - Transform2D xform = p_parent_xform * p_canvas_xform * canvas_item->get_transform(); + Transform2D xform = p_canvas_xform; + if (!canvas_item->is_set_as_top_level()) { + xform *= p_parent_xform; + } + xform *= canvas_item->get_transform(); Rect2 rect = canvas_item->_edit_get_rect(); if (r_first) { r_rect = Rect2(xform.xform(rect.get_center()), Size2()); @@ -608,7 +612,11 @@ void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_no } if (canvas_item && canvas_item->is_visible_in_tree()) { - Transform2D xform = (p_parent_xform * p_canvas_xform * canvas_item->get_transform()).affine_inverse(); + Transform2D xform = p_canvas_xform; + if (!canvas_item->is_set_as_top_level()) { + xform *= p_parent_xform; + } + xform = (xform * canvas_item->get_transform()).affine_inverse(); const real_t local_grab_distance = xform.basis_xform(Vector2(grab_distance, 0)).length() / zoom; if (canvas_item->_edit_is_selected_on_click(xform.xform(p_pos), local_grab_distance)) { Node2D *node = Object::cast_to<Node2D>(canvas_item); @@ -698,7 +706,11 @@ void CanvasItemEditor::_find_canvas_items_in_rect(const Rect2 &p_rect, Node *p_n } if (canvas_item && canvas_item->is_visible_in_tree() && !locked && editable) { - Transform2D xform = p_parent_xform * p_canvas_xform * canvas_item->get_transform(); + Transform2D xform = p_canvas_xform; + if (!canvas_item->is_set_as_top_level()) { + xform *= p_parent_xform; + } + xform *= canvas_item->get_transform(); if (canvas_item->_edit_use_rect()) { Rect2 rect = canvas_item->_edit_get_rect(); |