[Scummvm-cvs-logs] CVS: scummvm/gui widget.cpp,1.9,1.10
Max Horn
fingolfin at users.sourceforge.net
Thu Dec 12 15:22:03 CET 2002
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/scumm script_v1.cpp,1.41,NONE
- Next message: [Scummvm-cvs-logs] CVS: scummvm/gui options.cpp,NONE,1.1 options.h,NONE,1.1 PopUpWidget.cpp,1.1,1.2 launcher.cpp,1.29,1.30 module.mk,1.3,1.4 newgui.cpp,1.32,1.33 newgui.h,1.19,1.20
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/gui
In directory sc8-pr-cvs1:/tmp/cvs-serv27532
Modified Files:
widget.cpp
Log Message:
changed the slider widget, better suited to represent volume settings this way (IMO)
Index: widget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/widget.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- widget.cpp 21 Nov 2002 15:20:52 -0000 1.9
+++ widget.cpp 12 Dec 2002 23:21:29 -0000 1.10
@@ -202,16 +202,17 @@
SliderWidget::SliderWidget(Dialog *boss, int x, int y, int w, int h, const String &label, uint32 cmd, uint8 hotkey)
: ButtonWidget(boss, x, y, w, h, label, cmd, hotkey),
- _value(0), _oldValue(1), _valueMin(0), _valueMax(100)
+ _value(0), _valueMin(0), _valueMax(100)
{
_flags = WIDGET_ENABLED | WIDGET_TRACK_MOUSE | WIDGET_CLEARBG;
_type = kSliderWidget;
}
-void SliderWidget::handleMouseMoved(int x, int y, int button) {
+void SliderWidget::handleMouseMoved(int x, int y, int button) {
+ // TODO: when the mouse is dragged outside the widget, the slider should
+ // snap back to the old value.
if (isEnabled() && _isDragging) {
int newValue = posToValue(x);
-
if (newValue < _valueMin)
newValue = _valueMin;
else if (newValue > _valueMax)
@@ -228,13 +229,8 @@
void SliderWidget::handleMouseDown(int x, int y, int button, int clickCount) {
if (isEnabled()) {
- int barx;
-
- barx = valueToPos(_value);
-
- // only start dragging if mouse is over bar
- if (x > (barx - 3) && x < (barx + 3))
- _isDragging = true;
+ _isDragging = true;
+ handleMouseMoved(x, y, button);
}
}
@@ -254,22 +250,16 @@
// Draw the box
gui->box(_x, _y, _w, _h);
- // Remove old 'bar' if necessary
- if (_value != _oldValue) {
- gui->fillRect(_x + valueToPos(_oldValue), _y + 2, 2, _h - 4, gui->_bgcolor);
- _oldValue = _value;
- }
-
// Draw the 'bar'
- gui->fillRect(_x + valueToPos(_value), _y + 2, 2, _h - 4, hilite ? gui->_textcolorhi : gui->_textcolor);
+ gui->fillRect(_x + 2, _y + 2, valueToPos(_value), _h - 4, hilite ? gui->_textcolorhi : gui->_textcolor);
}
int SliderWidget::valueToPos(int value)
{
- return 2 + ((_w - 6) * (value - _valueMin) / (_valueMax - _valueMin));
+ return ((_w - 4) * (value - _valueMin) / (_valueMax - _valueMin));
}
int SliderWidget::posToValue(int pos)
{
- return (pos - 2) * (_valueMax - _valueMin) / (_w - 6) + _valueMin;
+ return (pos) * (_valueMax - _valueMin) / (_w - 4) + _valueMin;
}
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/scumm script_v1.cpp,1.41,NONE
- Next message: [Scummvm-cvs-logs] CVS: scummvm/gui options.cpp,NONE,1.1 options.h,NONE,1.1 PopUpWidget.cpp,1.1,1.2 launcher.cpp,1.29,1.30 module.mk,1.3,1.4 newgui.cpp,1.32,1.33 newgui.h,1.19,1.20
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list