* 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.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36145 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2010-04-11 12:57:58 +00:00
parent 1a1a8f33d1
commit 03e6434ec0
2 changed files with 24 additions and 24 deletions
+1 -1
View File
@@ -166,7 +166,7 @@ private:
void _DrawTriangleThumb();
BPoint _Location() const;
void _SetLocation(BPoint point);
void _SetLocationForValue(int32 value);
float _MinPosition() const;
float _MaxPosition() const;
+23 -23
View File
@@ -363,8 +363,6 @@ BSlider::AttachedToWindow()
{
ResizeToPreferred();
fLocation.Set(9.0f, 0.0f);
#if USE_OFF_SCREEN_VIEW
BRect bounds(Bounds());
@@ -395,8 +393,11 @@ BSlider::AttachedToWindow()
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,22 +673,8 @@ BSlider::SetValue(int32 value)
if (value == Value())
return;
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);
}
_SetLocationForValue(value);
BRect oldThumbFrame = ThumbFrame();
@@ -698,8 +685,6 @@ BSlider::SetValue(int32 value)
else
oldThumbFrame.right = BarFrame().right;
_SetLocation(loc);
BControl::SetValueNoUpdate(value);
BRect invalid = oldThumbFrame | ThumbFrame();
@@ -2030,9 +2015,24 @@ BSlider::_Location() const
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;
}