fix-EditorSpinSlider-grabber-zoomed-position

This commit is contained in:
jmb462 2021-03-05 15:06:05 +01:00
parent bf309b8a13
commit 919b097b9e

View file

@ -175,7 +175,9 @@ void EditorSpinSlider::_grabber_gui_input(const Ref<InputEvent> &p_event) {
return; 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); set_as_ratio(grabbing_ratio + grabbing_ofs);
update(); update();
} }
@ -300,8 +302,10 @@ void EditorSpinSlider::_notification(int p_what) {
grabber->set_texture(grabber_tex); 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_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) { if (mousewheel_over_grabber) {
Input::get_singleton()->warp_mouse_position(grabber->get_position() + grabber_rect.size); Input::get_singleton()->warp_mouse_position(grabber->get_position() + grabber_rect.size);