]> git.tdb.fi Git - libs/gltk.git/commitdiff
Fix HSlider
authorMikko Rasa <tdb@tdb.fi>
Thu, 6 Mar 2008 01:46:11 +0000 (01:46 +0000)
committerMikko Rasa <tdb@tdb.fi>
Thu, 6 Mar 2008 01:46:11 +0000 (01:46 +0000)
source/hslider.cpp

index a0caca54b17d2292a68f9fc219d27ace4b74a74f..e9db05f16cf950860cccd69002e82356c79c71dd 100644 (file)
@@ -23,9 +23,9 @@ HSlider::HSlider(const Resources &r):
 
 void HSlider::button_press(int x, int y, unsigned btn)
 {
-       if(geom.is_inside(x, y))
+       if(geom.is_inside_relative(x, y) && max>min)
        {
-               int sx=geom.x+static_cast<int>((geom.w-slider_size)*(value-min)/(max-min));
+               int sx=static_cast<int>((geom.w-slider_size)*(value-min)/(max-min));
                if(btn==1 && x>=sx && x<static_cast<int>(sx+slider_size))
                        start_drag(x);
        }
@@ -33,7 +33,7 @@ void HSlider::button_press(int x, int y, unsigned btn)
 
 void HSlider::button_release(int, int, unsigned btn)
 {
-       if(btn==1)
+       if(btn==1 && dragging)
                end_drag();
 }