mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-20 19:21:46 +00:00
Modify the SliderWidget value by using the mouse wheel
svn-id: r35513
This commit is contained in:
parent
51c22d9905
commit
f75893a294
@ -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 -
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user