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:
parent
db823da57e
commit
5eae27a4d0
@ -632,9 +632,16 @@ BSlider::SetValue(int32 value)
|
||||
int32
|
||||
BSlider::ValueForPoint(BPoint location) const
|
||||
{
|
||||
return (int32)(((fOrientation == B_HORIZONTAL ? location.x : location.y)
|
||||
- _MinPosition())
|
||||
* (fMaxValue - fMinValue) / (_MaxPosition() - _MinPosition())) + fMinValue;
|
||||
float position = fOrientation == B_HORIZONTAL ? location.x : location.y;
|
||||
float min = _MinPosition();
|
||||
float max = _MaxPosition();
|
||||
|
||||
if (position < min)
|
||||
position = min;
|
||||
if (position > max)
|
||||
position = max;
|
||||
|
||||
return (int32)roundf(((position - min) * (fMaxValue - fMinValue) / (max - min)) + fMinValue);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user