Display width and height when dragging a node side

This commit is contained in:
Gilles Roudiere 2017-08-18 23:32:23 +02:00
parent ad1028471c
commit 100c788884
1 changed files with 5 additions and 1 deletions

View File

@ -2149,7 +2149,7 @@ void CanvasItemEditor::_viewport_draw() {
anchor_handle->draw_rect(ci, anchor_rects[i]);
}
// Draw the margin values when dragging control side
// Draw the margin values and the node width/height when dragging control side
float ratio = 0.33;
Transform2D parent_transform = xform * control->get_transform().affine_inverse();
float node_pos_in_parent[4];
@ -2162,6 +2162,7 @@ void CanvasItemEditor::_viewport_draw() {
case DRAG_LEFT:
case DRAG_TOP_LEFT:
case DRAG_BOTTOM_LEFT:
_draw_margin_at_position(control->get_size().width, parent_transform.xform(Vector2((node_pos_in_parent[0] + node_pos_in_parent[2]) / 2, node_pos_in_parent[3])) + Vector2(0, 5), MARGIN_BOTTOM);
case DRAG_ALL:
Point2 start = Vector2(node_pos_in_parent[0], Math::lerp(node_pos_in_parent[1], node_pos_in_parent[3], ratio));
Point2 end = start - Vector2(control->get_margin(MARGIN_LEFT), 0);
@ -2173,6 +2174,7 @@ void CanvasItemEditor::_viewport_draw() {
case DRAG_RIGHT:
case DRAG_TOP_RIGHT:
case DRAG_BOTTOM_RIGHT:
_draw_margin_at_position(control->get_size().width, parent_transform.xform(Vector2((node_pos_in_parent[0] + node_pos_in_parent[2]) / 2, node_pos_in_parent[3])) + Vector2(0, 5), MARGIN_BOTTOM);
case DRAG_ALL:
Point2 start = Vector2(node_pos_in_parent[2], Math::lerp(node_pos_in_parent[3], node_pos_in_parent[1], ratio));
Point2 end = start - Vector2(control->get_margin(MARGIN_RIGHT), 0);
@ -2184,6 +2186,7 @@ void CanvasItemEditor::_viewport_draw() {
case DRAG_TOP:
case DRAG_TOP_LEFT:
case DRAG_TOP_RIGHT:
_draw_margin_at_position(control->get_size().height, parent_transform.xform(Vector2(node_pos_in_parent[2], (node_pos_in_parent[1] + node_pos_in_parent[3]) / 2)) + Vector2(5, 0), MARGIN_RIGHT);
case DRAG_ALL:
Point2 start = Vector2(Math::lerp(node_pos_in_parent[0], node_pos_in_parent[2], ratio), node_pos_in_parent[1]);
Point2 end = start - Vector2(0, control->get_margin(MARGIN_TOP));
@ -2195,6 +2198,7 @@ void CanvasItemEditor::_viewport_draw() {
case DRAG_BOTTOM:
case DRAG_BOTTOM_LEFT:
case DRAG_BOTTOM_RIGHT:
_draw_margin_at_position(control->get_size().height, parent_transform.xform(Vector2(node_pos_in_parent[2], (node_pos_in_parent[1] + node_pos_in_parent[3]) / 2) + Vector2(5, 0)), MARGIN_RIGHT);
case DRAG_ALL:
Point2 start = Vector2(Math::lerp(node_pos_in_parent[2], node_pos_in_parent[0], ratio), node_pos_in_parent[3]);
Point2 end = start - Vector2(0, control->get_margin(MARGIN_BOTTOM));