limit slider drag range
svn-id: r4566
This commit is contained in:
parent
76e6d7a197
commit
e277d392b8
1 changed files with 11 additions and 8 deletions
|
@ -197,10 +197,14 @@ SliderWidget::SliderWidget(Dialog *boss, int x, int y, int w, int h, const char
|
||||||
|
|
||||||
void SliderWidget::handleMouseMoved(int x, int y, int button) {
|
void SliderWidget::handleMouseMoved(int x, int y, int button) {
|
||||||
if (_isDragging) {
|
if (_isDragging) {
|
||||||
int newvalue = x * 100 / _w;
|
int newValue = x * 100 / _w;
|
||||||
|
if (newValue < 0)
|
||||||
|
newValue = 0;
|
||||||
|
else if (newValue > 100)
|
||||||
|
newValue = 100;
|
||||||
|
|
||||||
if (newvalue != _value) {
|
if (newValue != _value) {
|
||||||
_value = newvalue;
|
_value = newValue;
|
||||||
draw();
|
draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -234,6 +238,5 @@ void SliderWidget::handleMouseDown(int x, int y, int button) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SliderWidget::handleMouseUp(int x, int y, int button) {
|
void SliderWidget::handleMouseUp(int x, int y, int button) {
|
||||||
if (_isDragging)
|
|
||||||
_isDragging = false;
|
_isDragging = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue