Merge pull request #11196 from poke1024/canvas-old-rect
Adds display of old bounding box as suggested by Zephilinox in issue …
This commit is contained in:
commit
53990c7bb9
|
@ -845,6 +845,8 @@ void CanvasItemEditor::_prepare_drag(const Point2 &p_click_pos) {
|
||||||
se->undo_pivot = Object::cast_to<Node2D>(canvas_item)->edit_get_pivot();
|
se->undo_pivot = Object::cast_to<Node2D>(canvas_item)->edit_get_pivot();
|
||||||
if (Object::cast_to<Control>(canvas_item))
|
if (Object::cast_to<Control>(canvas_item))
|
||||||
se->undo_pivot = Object::cast_to<Control>(canvas_item)->get_pivot_offset();
|
se->undo_pivot = Object::cast_to<Control>(canvas_item)->get_pivot_offset();
|
||||||
|
|
||||||
|
se->pre_drag_xform = canvas_item->get_global_transform_with_canvas();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selection.size() == 1 && Object::cast_to<Node2D>(selection[0])) {
|
if (selection.size() == 1 && Object::cast_to<Node2D>(selection[0])) {
|
||||||
|
@ -1411,6 +1413,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
|
||||||
se->undo_pivot = Object::cast_to<Node2D>(canvas_item)->edit_get_pivot();
|
se->undo_pivot = Object::cast_to<Node2D>(canvas_item)->edit_get_pivot();
|
||||||
if (Object::cast_to<Control>(canvas_item))
|
if (Object::cast_to<Control>(canvas_item))
|
||||||
se->undo_pivot = Object::cast_to<Control>(canvas_item)->get_pivot_offset();
|
se->undo_pivot = Object::cast_to<Control>(canvas_item)->get_pivot_offset();
|
||||||
|
se->pre_drag_xform = canvas_item->get_global_transform_with_canvas();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1432,6 +1435,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
|
||||||
se->undo_pivot = Object::cast_to<Node2D>(canvas_item)->edit_get_pivot();
|
se->undo_pivot = Object::cast_to<Node2D>(canvas_item)->edit_get_pivot();
|
||||||
if (Object::cast_to<Control>(canvas_item))
|
if (Object::cast_to<Control>(canvas_item))
|
||||||
se->undo_pivot = Object::cast_to<Control>(canvas_item)->get_pivot_offset();
|
se->undo_pivot = Object::cast_to<Control>(canvas_item)->get_pivot_offset();
|
||||||
|
se->pre_drag_xform = canvas_item->get_global_transform_with_canvas();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1441,6 +1445,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
|
||||||
if (drag != DRAG_NONE) {
|
if (drag != DRAG_NONE) {
|
||||||
drag_from = transform.affine_inverse().xform(click);
|
drag_from = transform.affine_inverse().xform(click);
|
||||||
se->undo_state = canvas_item->edit_get_state();
|
se->undo_state = canvas_item->edit_get_state();
|
||||||
|
se->pre_drag_xform = canvas_item->get_global_transform_with_canvas();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1993,6 +1998,23 @@ void CanvasItemEditor::_viewport_draw() {
|
||||||
|
|
||||||
Rect2 rect = canvas_item->get_item_rect();
|
Rect2 rect = canvas_item->get_item_rect();
|
||||||
|
|
||||||
|
if (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))
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
viewport->draw_line(pre_drag_endpoints[i], pre_drag_endpoints[(i + 1) % 4], pre_drag_color, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Transform2D xform = transform * canvas_item->get_global_transform_with_canvas();
|
Transform2D xform = transform * canvas_item->get_global_transform_with_canvas();
|
||||||
VisualServer::get_singleton()->canvas_item_add_set_transform(ci, xform);
|
VisualServer::get_singleton()->canvas_item_add_set_transform(ci, xform);
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,8 @@ public:
|
||||||
Vector2 prev_pivot;
|
Vector2 prev_pivot;
|
||||||
float prev_anchors[4];
|
float prev_anchors[4];
|
||||||
|
|
||||||
|
Transform2D pre_drag_xform;
|
||||||
|
|
||||||
CanvasItemEditorSelectedItem() { prev_rot = 0; }
|
CanvasItemEditorSelectedItem() { prev_rot = 0; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue