diff options
author | Juan Linietsky <reduzio@gmail.com> | 2016-06-27 10:47:51 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2016-06-27 10:47:51 -0300 |
commit | e2d208f1226f802b941d099c2f16223e7446cb07 (patch) | |
tree | 304fe6f6cb880ee88a28028acc10268c89c6ab96 /tools | |
parent | 47d6cc08bbd745d63829e02ae408c4ce09ce1299 (diff) |
Ability to rotate controls using tool, closes #3800
Diffstat (limited to 'tools')
-rw-r--r-- | tools/editor/plugins/canvas_item_editor_plugin.cpp | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp index 0cbc867b47..81601a81a7 100644 --- a/tools/editor/plugins/canvas_item_editor_plugin.cpp +++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp @@ -1382,6 +1382,8 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) { se->undo_state=canvas_item->edit_get_state(); if (canvas_item->cast_to<Node2D>()) se->undo_pivot=canvas_item->cast_to<Node2D>()->edit_get_pivot(); + if (canvas_item->cast_to<Control>()) + se->undo_pivot=Vector2(); return; } @@ -1566,14 +1568,34 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) { if (drag==DRAG_ROTATE) { Vector2 center = canvas_item->get_global_transform_with_canvas().get_origin(); - if (Node2D *node = canvas_item->cast_to<Node2D>()) { - Matrix32 rot; - rot.elements[1] = (dfrom - center).normalized(); - rot.elements[0] = rot.elements[1].tangent(); - node->set_rot(snap_angle(rot.xform_inv(dto-center).angle() + node->get_rot(), node->get_rot())); - display_rotate_to = dto; - display_rotate_from = center; - viewport->update(); + { + Node2D *node = canvas_item->cast_to<Node2D>(); + + + if (node) { + Matrix32 rot; + rot.elements[1] = (dfrom - center).normalized(); + rot.elements[0] = rot.elements[1].tangent(); + node->set_rot(snap_angle(rot.xform_inv(dto-center).angle() + node->get_rot(), node->get_rot())); + display_rotate_to = dto; + display_rotate_from = center; + viewport->update(); + } + } + + { + Control *node = canvas_item->cast_to<Control>(); + + + if (node) { + Matrix32 rot; + rot.elements[1] = (dfrom - center).normalized(); + rot.elements[0] = rot.elements[1].tangent(); + node->set_rotation(snap_angle(rot.xform_inv(dto-center).angle() + node->get_rotation(), node->get_rotation())); + display_rotate_to = dto; + display_rotate_from = center; + viewport->update(); + } } continue; |