[haiku-commits] r36145 - in haiku/trunk: headers/os/interface src/kits/interface

  • From: korli@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 11 Apr 2010 14:57:58 +0200 (CEST)

Author: korli
Date: 2010-04-11 14:57:58 +0200 (Sun, 11 Apr 2010)
New Revision: 36145
Changeset: http://dev.haiku-os.org/changeset/36145/haiku

Modified:
   haiku/trunk/headers/os/interface/Slider.h
   haiku/trunk/src/kits/interface/Slider.cpp
Log:
* fixes a BSlider issue noticed by Matt on the mailing list: 
Invoke() wasn't called the first time you grab a slider and slide it all the 
way to the left.
Thanks for the test case.


Modified: haiku/trunk/headers/os/interface/Slider.h
===================================================================
--- haiku/trunk/headers/os/interface/Slider.h   2010-04-11 12:05:59 UTC (rev 
36144)
+++ haiku/trunk/headers/os/interface/Slider.h   2010-04-11 12:57:58 UTC (rev 
36145)
@@ -166,7 +166,7 @@
                        void                            _DrawTriangleThumb();
 
                        BPoint                          _Location() const;
-                       void                            _SetLocation(BPoint 
point);
+                       void                            
_SetLocationForValue(int32 value);
 
                        float                           _MinPosition() const;
                        float                           _MaxPosition() const;

Modified: haiku/trunk/src/kits/interface/Slider.cpp
===================================================================
--- haiku/trunk/src/kits/interface/Slider.cpp   2010-04-11 12:05:59 UTC (rev 
36144)
+++ haiku/trunk/src/kits/interface/Slider.cpp   2010-04-11 12:57:58 UTC (rev 
36145)
@@ -363,8 +363,6 @@
 {
        ResizeToPreferred();
 
-       fLocation.Set(9.0f, 0.0f);
-       
 #if USE_OFF_SCREEN_VIEW
        BRect bounds(Bounds());
 
@@ -395,8 +393,11 @@
                view->UnlockLooper();
        }
 
-       SetValue(Value());
+       int32 value = Value();
+       SetValue(value);
                // makes sure the value is within valid bounds
+       _SetLocationForValue(Value());
+               // makes sure the location is correct
        UpdateTextChanged();
 }
 
@@ -672,23 +673,9 @@
 
        if (value == Value())
                return;
+       
+       _SetLocationForValue(value);
 
-       BPoint loc;
-       float range = (float)(fMaxValue - fMinValue);
-       if (range == 0)
-               range = 1;
-
-       float pos = (float)(value - fMinValue) / range *
-               (_MaxPosition() - _MinPosition());
-
-       if (fOrientation == B_HORIZONTAL) {
-               loc.x = ceil(_MinPosition() + pos);
-               loc.y = 0;
-       } else {
-               loc.x = 0;
-               loc.y = floor(_MaxPosition() - pos);
-       }
-
        BRect oldThumbFrame = ThumbFrame();
 
        // While it would be enough to do this dependent on fUseFillColor,
@@ -698,8 +685,6 @@
        else
                oldThumbFrame.right = BarFrame().right;
 
-       _SetLocation(loc);
-
        BControl::SetValueNoUpdate(value);
        BRect invalid = oldThumbFrame | ThumbFrame();
 
@@ -2030,9 +2015,24 @@
 
 
 void
-BSlider::_SetLocation(BPoint p)
+BSlider::_SetLocationForValue(int32 value)
 {
-       fLocation = p;
+       BPoint loc;
+       float range = (float)(fMaxValue - fMinValue);
+       if (range == 0)
+               range = 1;
+
+       float pos = (float)(value - fMinValue) / range *
+               (_MaxPosition() - _MinPosition());
+
+       if (fOrientation == B_HORIZONTAL) {
+               loc.x = ceil(_MinPosition() + pos);
+               loc.y = 0;
+       } else {
+               loc.x = 0;
+               loc.y = floor(_MaxPosition() - pos);
+       }
+       fLocation = loc;
 }
 
 


Other related posts:

  • » [haiku-commits] r36145 - in haiku/trunk: headers/os/interface src/kits/interface - korli