summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorMason Ashbridge <masonjash@gmail.com>2016-08-24 03:17:54 -0400
committerMason Ashbridge <masonjash@gmail.com>2016-08-24 03:17:54 -0400
commitfb54ba63975a748b2a0dc9d68a94e4e27d0a8c7f (patch)
tree70cf932c98c462ac94be19604fcb744020315989 /scene/gui
parent2cf781d3c66cbc53739ff91d4608ac979ae17262 (diff)
Slider value accounts for grabber offset
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/slider.cpp9
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 {