diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-12-07 23:18:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-07 23:18:27 +0100 |
commit | 41d1dba35fc851258d5aabad819d09f6a43e324c (patch) | |
tree | a78ecef835b51f30509f832b71dbf12c205ce799 /scene/gui | |
parent | 4191e5316b16d61a59df40740fd46f7b211a09fe (diff) | |
parent | 16cac24c9d2d1bd444038d3ffefef2fc42aa4c61 (diff) |
Merge pull request #22431 from DualMatrix/pivot
Fixed pivot tool not setting position of Controls correctly
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/control.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 79e1d35b94..a580d89439 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -451,6 +451,11 @@ void Control::_update_canvas_item_transform() { Transform2D xform = _get_internal_transform(); xform[2] += get_position(); + // We use a little workaround to avoid flickering when moving the pivot with _edit_set_pivot() + if (is_inside_tree() && Math::abs(Math::sin(data.rotation * 4.0f)) < 0.00001f && get_viewport()->is_snap_controls_to_pixels_enabled()) { + xform[2] = xform[2].round(); + } + VisualServer::get_singleton()->canvas_item_set_transform(get_canvas_item(), xform); } @@ -1336,11 +1341,6 @@ void Control::_size_changed() { new_size_cache.height = minimum_size.height; } - // We use a little workaround to avoid flickering when moving the pivot with _edit_set_pivot() - if (is_inside_tree() && Math::abs(Math::sin(data.rotation * 4.0f)) < 0.00001f && get_viewport()->is_snap_controls_to_pixels_enabled()) { - new_size_cache = new_size_cache.round(); - new_pos_cache = new_pos_cache.round(); - } bool pos_changed = new_pos_cache != data.pos_cache; bool size_changed = new_size_cache != data.size_cache; @@ -1740,10 +1740,10 @@ Rect2 Control::_compute_child_rect(const float p_anchors[4], const float p_margi void Control::_compute_margins(Rect2 p_rect, const float p_anchors[4], float (&r_margins)[4]) { Size2 parent_rect_size = get_parent_anchorable_rect().size; - r_margins[0] = Math::floor(p_rect.position.x - (p_anchors[0] * parent_rect_size.x)); - r_margins[1] = Math::floor(p_rect.position.y - (p_anchors[1] * parent_rect_size.y)); - r_margins[2] = Math::floor(p_rect.position.x + p_rect.size.x - (p_anchors[2] * parent_rect_size.x)); - r_margins[3] = Math::floor(p_rect.position.y + p_rect.size.y - (p_anchors[3] * parent_rect_size.y)); + r_margins[0] = p_rect.position.x - (p_anchors[0] * parent_rect_size.x); + r_margins[1] = p_rect.position.y - (p_anchors[1] * parent_rect_size.y); + r_margins[2] = p_rect.position.x + p_rect.size.x - (p_anchors[2] * parent_rect_size.x); + r_margins[3] = p_rect.position.y + p_rect.size.y - (p_anchors[3] * parent_rect_size.y); } void Control::set_position(const Size2 &p_point) { |