Added the possibility to move all anchors at once when they are clustered

This commit is contained in:
Gilles Roudiere 2017-08-04 19:27:30 +02:00
parent f5ff7e9fa0
commit e8c83b31bd
2 changed files with 14 additions and 1 deletions

View File

@ -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;

View File

@ -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,