From 3f279d2a3e22702930681ba6808cb9195c32734e Mon Sep 17 00:00:00 2001 From: Gilles Roudiere Date: Tue, 3 Oct 2017 22:44:34 +0200 Subject: Fixes the pre drag rect not drawn correctly --- editor/plugins/canvas_item_editor_plugin.cpp | 14 +++++++++----- editor/plugins/canvas_item_editor_plugin.h | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'editor/plugins') diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 1aa24c8172..4f6c8f89ee 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -990,6 +990,7 @@ void CanvasItemEditor::_prepare_drag(const Point2 &p_click_pos) { se->undo_pivot = Object::cast_to(canvas_item)->get_pivot_offset(); se->pre_drag_xform = canvas_item->get_global_transform_with_canvas(); + se->pre_drag_rect = canvas_item->get_item_rect(); } if (selection.size() == 1 && Object::cast_to(selection[0])) { @@ -1517,6 +1518,7 @@ void CanvasItemEditor::_viewport_base_gui_input(const Ref &p_event) if (Object::cast_to(canvas_item)) se->undo_pivot = Object::cast_to(canvas_item)->get_pivot_offset(); se->pre_drag_xform = canvas_item->get_global_transform_with_canvas(); + se->pre_drag_rect = canvas_item->get_item_rect(); return; } @@ -1539,6 +1541,7 @@ void CanvasItemEditor::_viewport_base_gui_input(const Ref &p_event) if (Object::cast_to(canvas_item)) se->undo_pivot = Object::cast_to(canvas_item)->get_pivot_offset(); se->pre_drag_xform = canvas_item->get_global_transform_with_canvas(); + se->pre_drag_rect = canvas_item->get_item_rect(); return; } @@ -1550,6 +1553,7 @@ void CanvasItemEditor::_viewport_base_gui_input(const Ref &p_event) drag_from = transform.affine_inverse().xform(click); se->undo_state = canvas_item->edit_get_state(); se->pre_drag_xform = canvas_item->get_global_transform_with_canvas(); + se->pre_drag_rect = canvas_item->get_item_rect(); return; } } @@ -2206,16 +2210,16 @@ void CanvasItemEditor::_draw_selection() { Rect2 rect = canvas_item->get_item_rect(); - if (drag != DRAG_NONE && drag != DRAG_PIVOT) { + if (show_helpers && drag != DRAG_NONE && drag != DRAG_PIVOT) { const Transform2D pre_drag_xform = transform * se->pre_drag_xform; const Color pre_drag_color = Color(0.4, 0.6, 1, 0.7); Vector2 pre_drag_endpoints[4] = { - pre_drag_xform.xform(rect.position), - pre_drag_xform.xform(rect.position + Vector2(rect.size.x, 0)), - pre_drag_xform.xform(rect.position + rect.size), - pre_drag_xform.xform(rect.position + Vector2(0, rect.size.y)) + pre_drag_xform.xform(se->pre_drag_rect.position), + pre_drag_xform.xform(se->pre_drag_rect.position + Vector2(se->pre_drag_rect.size.x, 0)), + pre_drag_xform.xform(se->pre_drag_rect.position + se->pre_drag_rect.size), + pre_drag_xform.xform(se->pre_drag_rect.position + Vector2(0, se->pre_drag_rect.size.y)) }; for (int i = 0; i < 4; i++) { diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index bb4e584f2a..f87bfef8ad 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -59,6 +59,7 @@ public: float prev_anchors[4]; Transform2D pre_drag_xform; + Rect2 pre_drag_rect; CanvasItemEditorSelectedItem() { prev_rot = 0; } }; -- cgit v1.2.3