Fixed ValueForPoint() to correctly limit the value to the slider bounds.
This fixes bug #294. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16839 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -632,9 +632,16 @@ BSlider::SetValue(int32 value)
|
|||||||
int32
|
int32
|
||||||
BSlider::ValueForPoint(BPoint location) const
|
BSlider::ValueForPoint(BPoint location) const
|
||||||
{
|
{
|
||||||
return (int32)(((fOrientation == B_HORIZONTAL ? location.x : location.y)
|
float position = fOrientation == B_HORIZONTAL ? location.x : location.y;
|
||||||
- _MinPosition())
|
float min = _MinPosition();
|
||||||
* (fMaxValue - fMinValue) / (_MaxPosition() - _MinPosition())) + fMinValue;
|
float max = _MaxPosition();
|
||||||
|
|
||||||
|
if (position < min)
|
||||||
|
position = min;
|
||||||
|
if (position > max)
|
||||||
|
position = max;
|
||||||
|
|
||||||
|
return (int32)roundf(((position - min) * (fMaxValue - fMinValue) / (max - min)) + fMinValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user