diff options
Diffstat (limited to 'scene/gui/slider.cpp')
-rw-r--r-- | scene/gui/slider.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp index d5d14ad649..3b9ca40bd8 100644 --- a/scene/gui/slider.cpp +++ b/scene/gui/slider.cpp @@ -47,12 +47,15 @@ void Slider::_input_event(InputEvent p_event) { if (mb.button_index==BUTTON_LEFT) { if (mb.pressed) { + Ref<Texture> grabber = get_icon(mouse_inside||has_focus()?"grabber_hilite":"grabber"); grab.pos=orientation==VERTICAL?mb.y:mb.x; - double max = orientation==VERTICAL ? get_size().height : get_size().width ; + double grab_width = (double)grabber->get_size().width; + double grab_height = (double)grabber->get_size().height; + double max = orientation==VERTICAL ? get_size().height - grab_height : get_size().width - grab_width; if (orientation==VERTICAL) - set_unit_value( 1 - ((double)grab.pos / max) ); + set_unit_value( 1 - (((double)grab.pos - (grab_height / 2.0)) / max) ); else - set_unit_value((double)grab.pos / max); + set_unit_value(((double)grab.pos - (grab_width/2.0)) / max); grab.active=true; grab.uvalue=get_unit_value(); } else { |