1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-11 13:10:58 +00:00

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,9 +848,13 @@ CanvasItemEditor::DragType CanvasItemEditor::_get_anchor_handle_drag_type(const
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
if (anchor_rects[i].has_point(p_click)) { if (anchor_rects[i].has_point(p_click)) {
r_point = transform.affine_inverse().xform(anchor_pos[i]); r_point = transform.affine_inverse().xform(anchor_pos[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]; return dragger[i];
} }
} }
}
return DRAG_NONE; return DRAG_NONE;
} }
@@ -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))); control->set_anchor(MARGIN_BOTTOM, _anchor_snap(anchor.y, NULL, control->get_anchor(MARGIN_TOP)));
continue; continue;
break; 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 // Get which anchor is dragged
int dragged_anchor = -1; int dragged_anchor = -1;
switch (drag) { switch (drag) {
case DRAG_ANCHOR_ALL:
case DRAG_ANCHOR_TOP_LEFT: case DRAG_ANCHOR_TOP_LEFT:
dragged_anchor = 0; dragged_anchor = 0;
break; break;

View File

@@ -148,6 +148,7 @@ class CanvasItemEditor : public VBoxContainer {
DRAG_ANCHOR_TOP_RIGHT, DRAG_ANCHOR_TOP_RIGHT,
DRAG_ANCHOR_BOTTOM_RIGHT, DRAG_ANCHOR_BOTTOM_RIGHT,
DRAG_ANCHOR_BOTTOM_LEFT, DRAG_ANCHOR_BOTTOM_LEFT,
DRAG_ANCHOR_ALL,
DRAG_ALL, DRAG_ALL,
DRAG_ROTATE, DRAG_ROTATE,
DRAG_PIVOT, DRAG_PIVOT,