aboutsummaryrefslogtreecommitdiff
path: root/gui/widget.cpp
diff options
context:
space:
mode:
authorMax Horn2002-07-26 15:34:04 +0000
committerMax Horn2002-07-26 15:34:04 +0000
commit89a65b7c015b919f97456e1883390986184e09b5 (patch)
treee4b9836b3ae67aa850fac91170cfa96bb0a0087d /gui/widget.cpp
parent84c8d4b689168335da090bae57f4a162ee10018d (diff)
downloadscummvm-rg350-89a65b7c015b919f97456e1883390986184e09b5.tar.gz
scummvm-rg350-89a65b7c015b919f97456e1883390986184e09b5.tar.bz2
scummvm-rg350-89a65b7c015b919f97456e1883390986184e09b5.zip
fixed crash on some systems by setting defaults for the slider value range
svn-id: r4636
Diffstat (limited to 'gui/widget.cpp')
-rw-r--r--gui/widget.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/gui/widget.cpp b/gui/widget.cpp
index 06c6161ce4..0989b86ec6 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -189,7 +189,8 @@ void CheckboxWidget::drawWidget(bool hilite)
#pragma mark -
SliderWidget::SliderWidget(Dialog *boss, int x, int y, int w, int h, const char *label, uint32 cmd, uint8 hotkey)
- : ButtonWidget(boss, x, y, w, h, label, cmd, hotkey), _value(0), _old_value(1)
+ : ButtonWidget(boss, x, y, w, h, label, cmd, hotkey),
+ _value(0), _old_value(1), _valueMin(0), _valueMax(100)
{
_flags = WIDGET_ENABLED | WIDGET_TRACK_MOUSE | WIDGET_CLEARBG;
_type = kSliderWidget;
@@ -219,18 +220,18 @@ void SliderWidget::drawWidget(bool hilite)
// Remove old 'bar' if necessary
if (_value != _old_value) {
- gui->fillRect(_x + 2 + ((_w - 5) * (_old_value - _valueMin) / _valueDelta), _y + 2, 2, _h - 4, gui->_bgcolor);
+ gui->fillRect(_x + 2 + ((_w - 5) * (_old_value - _valueMin) / (_valueMax - _valueMin)), _y + 2, 2, _h - 4, gui->_bgcolor);
_old_value = _value;
}
// Draw the 'bar'
- gui->fillRect(_x + 2 + ((_w - 5) * (_value - _valueMin) / _valueDelta), _y + 2, 2, _h - 4, hilite ? gui->_textcolorhi : gui->_textcolor);
+ gui->fillRect(_x + 2 + ((_w - 5) * (_value - _valueMin) / (_valueMax - _valueMin)), _y + 2, 2, _h - 4, hilite ? gui->_textcolorhi : gui->_textcolor);
}
void SliderWidget::handleMouseDown(int x, int y, int button) {
int barx;
- barx = 2 + ((_w - 5) * (_value - _valueMin) / _valueDelta);
+ barx = 2 + ((_w - 5) * (_value - _valueMin) / (_valueMax - _valueMin));
// only start dragging if mouse is over bar
if (x > (barx - 3) && x < (barx + 3))