aboutsummaryrefslogtreecommitdiff
path: root/gui/widget.cpp
diff options
context:
space:
mode:
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;
}