From 592c0632a170d801c34b8993b8cc6b3524bb1cf2 Mon Sep 17 00:00:00 2001 From: jmb462 Date: Fri, 5 Mar 2021 15:06:05 +0100 Subject: [PATCH] fix-EditorSpinSlider-grabber-zoomed-position (cherry picked from commit 919b097b9e61098815a00a26e47c56f26b0abe38) --- editor/editor_spin_slider.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp index 67099f368e2..67287988372 100644 --- a/editor/editor_spin_slider.cpp +++ b/editor/editor_spin_slider.cpp @@ -185,7 +185,9 @@ void EditorSpinSlider::_grabber_gui_input(const Ref &p_event) { if (mousewheel_over_grabber) return; - float grabbing_ofs = (grabber->get_transform().xform(mm->get_position()).x - grabbing_from) / float(grabber_range); + float scale_x = get_global_transform_with_canvas().get_scale().x; + ERR_FAIL_COND(Math::is_zero_approx(scale_x)); + float grabbing_ofs = (grabber->get_transform().xform(mm->get_position()).x - grabbing_from) / float(grabber_range) / scale_x; set_as_ratio(grabbing_ratio + grabbing_ofs); update(); } @@ -311,8 +313,10 @@ void EditorSpinSlider::_notification(int p_what) { grabber->set_texture(grabber_tex); } + Vector2 scale = get_global_transform_with_canvas().get_scale(); + grabber->set_scale(scale); grabber->set_size(Size2(0, 0)); - grabber->set_position(get_global_position() + grabber_rect.position + grabber_rect.size * 0.5 - grabber->get_size() * 0.5); + grabber->set_position(get_global_position() + (grabber_rect.position + grabber_rect.size * 0.5 - grabber->get_size() * 0.5) * scale); if (mousewheel_over_grabber) { Input::get_singleton()->warp_mouse_position(grabber->get_position() + grabber_rect.size);