aboutsummaryrefslogtreecommitdiff
path: root/gui
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
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')
-rw-r--r--gui/widget.cpp9
-rw-r--r--gui/widget.h6
2 files changed, 8 insertions, 7 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))
diff --git a/gui/widget.h b/gui/widget.h
index 7f1e663e2e..af3a0dd854 100644
--- a/gui/widget.h
+++ b/gui/widget.h
@@ -171,16 +171,16 @@ protected:
class SliderWidget : public ButtonWidget {
protected:
int _value, _old_value;
- int _valueMin, _valueMax, _valueDelta;
+ int _valueMin, _valueMax;
bool _isDragging;
public:
SliderWidget(Dialog *boss, int x, int y, int w, int h, const char *label, uint32 cmd = 0, uint8 hotkey = 0);
void setValue(uint8 value) { _value = value; }
uint8 getValue() const { return _value; }
- void setMinValue(int value) { _valueMin = value; _valueDelta = _valueMax - _valueMin; }
+ void setMinValue(int value) { _valueMin = value; }
int getMinValue() const { return _valueMin; }
- void setMaxValue(int value) { _valueMax = value; _valueDelta = _valueMax - _valueMin; }
+ void setMaxValue(int value) { _valueMax = value; }
int getMaxValue() const { return _valueMax; }
void handleMouseMoved(int x, int y, int button);