summaryrefslogtreecommitdiffstats
path: root/scene/gui/control.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui/control.cpp')
-rw-r--r--scene/gui/control.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 0682c11a9b..d169e82e5d 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -696,7 +696,7 @@ void Control::_update_canvas_item_transform() {
// 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();
+ xform[2] = (xform[2] + Vector2(0.5, 0.5)).floor();
}
RenderingServer::get_singleton()->canvas_item_set_transform(get_canvas_item(), xform);
@@ -1732,11 +1732,15 @@ void Control::_size_changed() {
new_size_cache.height = minimum_size.height;
}
- bool pos_changed = new_pos_cache != data.pos_cache;
- bool size_changed = new_size_cache != data.size_cache;
+ bool pos_changed = !new_pos_cache.is_equal_approx(data.pos_cache);
+ bool size_changed = !new_size_cache.is_equal_approx(data.size_cache);
- data.pos_cache = new_pos_cache;
- data.size_cache = new_size_cache;
+ if (pos_changed) {
+ data.pos_cache = new_pos_cache;
+ }
+ if (size_changed) {
+ data.size_cache = new_size_cache;
+ }
if (is_inside_tree()) {
if (pos_changed || size_changed) {
@@ -1751,12 +1755,10 @@ void Control::_size_changed() {
}
if (pos_changed && !size_changed) {
- _update_canvas_item_transform(); //move because it won't be updated
- }
- } else {
- if (pos_changed) {
- _notify_transform();
+ _update_canvas_item_transform();
}
+ } else if (pos_changed) {
+ _notify_transform();
}
}