summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
authorGilles Roudiere <gilles.roudiere@gmail.com>2017-10-03 22:44:34 +0200
committerGilles Roudiere <gilles.roudiere@gmail.com>2017-10-03 22:44:34 +0200
commit3f279d2a3e22702930681ba6808cb9195c32734e (patch)
treead351821be42658580ca2956625ae0021edd3103 /editor/plugins
parenta848fa6cdeb00f0c40f259cde2d59112272e3c51 (diff)
Fixes the pre drag rect not drawn correctly
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp14
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h1
2 files changed, 10 insertions, 5 deletions
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<Control>(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<Node2D>(selection[0])) {
@@ -1517,6 +1518,7 @@ void CanvasItemEditor::_viewport_base_gui_input(const Ref<InputEvent> &p_event)
if (Object::cast_to<Control>(canvas_item))
se->undo_pivot = Object::cast_to<Control>(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<InputEvent> &p_event)
if (Object::cast_to<Control>(canvas_item))
se->undo_pivot = Object::cast_to<Control>(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<InputEvent> &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; }
};