summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGilles Roudiere <gilles.roudiere@gmail.com>2017-08-04 19:27:30 +0200
committerGilles Roudiere <gilles.roudiere@gmail.com>2017-08-13 21:20:13 +0200
commite8c83b31bddd1767a828aaed2f34c1a442bd6919 (patch)
treeec531efaf1235f21e586303bc8200274a631f31e
parentf5ff7e9fa039e54de2e48bfb46239bbda497287a (diff)
Added the possibility to move all anchors at once when they are clustered
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp14
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h1
2 files changed, 14 insertions, 1 deletions
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index fc3cee033f..d9550f979b 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -848,7 +848,11 @@ CanvasItemEditor::DragType CanvasItemEditor::_get_anchor_handle_drag_type(const
for (int i = 0; i < 4; i++) {
if (anchor_rects[i].has_point(p_click)) {
r_point = transform.affine_inverse().xform(anchor_pos[i]);
- return dragger[i];
+ if ((anchor_pos[0] == anchor_pos[2]) && (anchor_pos[0].distance_to(p_click) < anchor_handle->get_size().length() / 3.0)) {
+ return DRAG_ANCHOR_ALL;
+ } else {
+ return dragger[i];
+ }
}
}
@@ -1614,6 +1618,13 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
control->set_anchor(MARGIN_BOTTOM, _anchor_snap(anchor.y, NULL, control->get_anchor(MARGIN_TOP)));
continue;
break;
+ case DRAG_ANCHOR_ALL:
+ control->set_anchor(MARGIN_LEFT, _anchor_snap(anchor.x));
+ control->set_anchor(MARGIN_RIGHT, _anchor_snap(anchor.x));
+ control->set_anchor(MARGIN_TOP, _anchor_snap(anchor.y));
+ control->set_anchor(MARGIN_BOTTOM, _anchor_snap(anchor.y));
+ continue;
+ break;
}
}
@@ -2038,6 +2049,7 @@ void CanvasItemEditor::_viewport_draw() {
// Get which anchor is dragged
int dragged_anchor = -1;
switch (drag) {
+ case DRAG_ANCHOR_ALL:
case DRAG_ANCHOR_TOP_LEFT:
dragged_anchor = 0;
break;
diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h
index c6b4289967..49c9cd9dc0 100644
--- a/editor/plugins/canvas_item_editor_plugin.h
+++ b/editor/plugins/canvas_item_editor_plugin.h
@@ -148,6 +148,7 @@ class CanvasItemEditor : public VBoxContainer {
DRAG_ANCHOR_TOP_RIGHT,
DRAG_ANCHOR_BOTTOM_RIGHT,
DRAG_ANCHOR_BOTTOM_LEFT,
+ DRAG_ANCHOR_ALL,
DRAG_ALL,
DRAG_ROTATE,
DRAG_PIVOT,