* 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:
@@ -166,7 +166,7 @@ private:
|
|||||||
void _DrawTriangleThumb();
|
void _DrawTriangleThumb();
|
||||||
|
|
||||||
BPoint _Location() const;
|
BPoint _Location() const;
|
||||||
void _SetLocation(BPoint point);
|
void _SetLocationForValue(int32 value);
|
||||||
|
|
||||||
float _MinPosition() const;
|
float _MinPosition() const;
|
||||||
float _MaxPosition() const;
|
float _MaxPosition() const;
|
||||||
|
|||||||
@@ -363,8 +363,6 @@ BSlider::AttachedToWindow()
|
|||||||
{
|
{
|
||||||
ResizeToPreferred();
|
ResizeToPreferred();
|
||||||
|
|
||||||
fLocation.Set(9.0f, 0.0f);
|
|
||||||
|
|
||||||
#if USE_OFF_SCREEN_VIEW
|
#if USE_OFF_SCREEN_VIEW
|
||||||
BRect bounds(Bounds());
|
BRect bounds(Bounds());
|
||||||
|
|
||||||
@@ -395,8 +393,11 @@ BSlider::AttachedToWindow()
|
|||||||
view->UnlockLooper();
|
view->UnlockLooper();
|
||||||
}
|
}
|
||||||
|
|
||||||
SetValue(Value());
|
int32 value = Value();
|
||||||
|
SetValue(value);
|
||||||
// makes sure the value is within valid bounds
|
// makes sure the value is within valid bounds
|
||||||
|
_SetLocationForValue(Value());
|
||||||
|
// makes sure the location is correct
|
||||||
UpdateTextChanged();
|
UpdateTextChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -673,21 +674,7 @@ BSlider::SetValue(int32 value)
|
|||||||
if (value == Value())
|
if (value == Value())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BPoint loc;
|
_SetLocationForValue(value);
|
||||||
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();
|
BRect oldThumbFrame = ThumbFrame();
|
||||||
|
|
||||||
@@ -698,8 +685,6 @@ BSlider::SetValue(int32 value)
|
|||||||
else
|
else
|
||||||
oldThumbFrame.right = BarFrame().right;
|
oldThumbFrame.right = BarFrame().right;
|
||||||
|
|
||||||
_SetLocation(loc);
|
|
||||||
|
|
||||||
BControl::SetValueNoUpdate(value);
|
BControl::SetValueNoUpdate(value);
|
||||||
BRect invalid = oldThumbFrame | ThumbFrame();
|
BRect invalid = oldThumbFrame | ThumbFrame();
|
||||||
|
|
||||||
@@ -2030,9 +2015,24 @@ BSlider::_Location() const
|
|||||||
|
|
||||||
|
|
||||||
void
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user