aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/widget.cpp24
-rw-r--r--gui/widget.h1
2 files changed, 22 insertions, 3 deletions
diff --git a/gui/widget.cpp b/gui/widget.cpp
index f8af13ccbc..ade68fd46d 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -309,16 +309,34 @@ void SliderWidget::handleMouseUp(int x, int y, int button, int clickCount) {
_isDragging = false;
}
+void SliderWidget::handleMouseWheel(int x, int y, int direction) {
+ if (isEnabled() && !_isDragging) {
+ // Increment or decrement one position
+ int newValue = posToValue(valueToPos(_value) - 1 * direction);
+
+ if (newValue < _valueMin)
+ newValue = _valueMin;
+ else if (newValue > _valueMax)
+ newValue = _valueMax;
+
+ if (newValue != _value) {
+ _value = newValue;
+ draw();
+ sendCommand(_cmd, _value); // FIXME - hack to allow for "live update" in sound dialog
+ }
+ }
+}
+
void SliderWidget::drawWidget() {
- g_gui.theme()->drawSlider(Common::Rect(_x, _y, _x+_w, _y+_h), valueToPos(_value), _state);
+ g_gui.theme()->drawSlider(Common::Rect(_x, _y, _x + _w, _y + _h), valueToPos(_value) + 1, _state);
}
int SliderWidget::valueToPos(int value) {
- return (_w * (value - _valueMin) / (_valueMax - _valueMin));
+ return ((_w - 1) * (value - _valueMin + 1) / (_valueMax - _valueMin));
}
int SliderWidget::posToValue(int pos) {
- return (pos) * (_valueMax - _valueMin) / _w + _valueMin;
+ return (pos) * (_valueMax - _valueMin) / (_w - 1) + _valueMin;
}
#pragma mark -
diff --git a/gui/widget.h b/gui/widget.h
index a37ef5c7f4..39bf81b352 100644
--- a/gui/widget.h
+++ b/gui/widget.h
@@ -229,6 +229,7 @@ public:
void handleMouseUp(int x, int y, int button, int clickCount);
void handleMouseEntered(int button) { setFlags(WIDGET_HILITED); draw(); }
void handleMouseLeft(int button) { clearFlags(WIDGET_HILITED); draw(); }
+ void handleMouseWheel(int x, int y, int direction);
protected:
void drawWidget();