aboutsummaryrefslogtreecommitdiff
path: root/gui/widget.cpp
diff options
context:
space:
mode:
authorMax Horn2002-07-16 12:01:03 +0000
committerMax Horn2002-07-16 12:01:03 +0000
commite277d392b8b35d5bcfb7f59dde0abc00bb08d8d9 (patch)
tree4d923f159ddcc92249cd31c74d5e94aad1f04550 /gui/widget.cpp
parent76e6d7a1973ddf55370e0c364f1e4218c5e9a7af (diff)
downloadscummvm-rg350-e277d392b8b35d5bcfb7f59dde0abc00bb08d8d9.tar.gz
scummvm-rg350-e277d392b8b35d5bcfb7f59dde0abc00bb08d8d9.tar.bz2
scummvm-rg350-e277d392b8b35d5bcfb7f59dde0abc00bb08d8d9.zip
limit slider drag range
svn-id: r4566
Diffstat (limited to 'gui/widget.cpp')
-rw-r--r--gui/widget.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/gui/widget.cpp b/gui/widget.cpp
index fa31e2f6d2..8dc40e8740 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -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) {
if (_isDragging) {
- int newvalue = x * 100 / _w;
-
- if (newvalue != _value) {
- _value = newvalue;
+ int newValue = x * 100 / _w;
+ if (newValue < 0)
+ newValue = 0;
+ else if (newValue > 100)
+ newValue = 100;
+
+ if (newValue != _value) {
+ _value = newValue;
draw();
}
}
@@ -226,14 +230,13 @@ void SliderWidget::drawWidget(bool hilite)
void SliderWidget::handleMouseDown(int x, int y, int button) {
int barx;
- barx=2 + ((_w - 5) * _old_value / 100);
+ barx = 2 + ((_w - 5) * _old_value / 100);
// only start dragging if mouse is over bar
- if (x > (barx-3) && x < (barx+3))
- _isDragging=true;
+ if (x > (barx - 3) && x < (barx + 3))
+ _isDragging = true;
}
void SliderWidget::handleMouseUp(int x, int y, int button) {
- if (_isDragging)
- _isDragging=false;
+ _isDragging = false;
}