BSlider didn't like if minimum and maximum limit were the same. Now the slider is
drawn correctly in that case, and the thumb stays at the start of the slider (minimal position). This fixes bug #193. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17705 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -574,7 +574,11 @@ BSlider::SetValue(int32 value)
|
||||
|
||||
if (value != Value()) {
|
||||
BPoint loc;
|
||||
float pos = (float)(value - fMinValue) / (float)(fMaxValue - fMinValue) *
|
||||
float range = (float)(fMaxValue - fMinValue);
|
||||
if (range == 0)
|
||||
range = 1;
|
||||
|
||||
float pos = (float)(value - fMinValue) / range *
|
||||
_MaxPosition() - _MinPosition();
|
||||
|
||||
if (fOrientation == B_HORIZONTAL) {
|
||||
@@ -662,7 +666,11 @@ BSlider::SetPosition(float position)
|
||||
float
|
||||
BSlider::Position() const
|
||||
{
|
||||
return ((float)(Value() - fMinValue) / (float)(fMaxValue - fMinValue));
|
||||
float range = (float)(fMaxValue - fMinValue);
|
||||
if (range == 0.0f)
|
||||
range = 1.0f;
|
||||
|
||||
return (float)(Value() - fMinValue) / range;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user