From c318fed6338fd232deff621141f58789ffbbad89 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 27 Jul 2002 00:05:46 +0000 Subject: improved the sound dialog; but my goal is to get rid of it, and merge the sound & misc dialogs into the options dialog svn-id: r4648 --- gui/widget.cpp | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'gui/widget.cpp') diff --git a/gui/widget.cpp b/gui/widget.cpp index bb0e419d71..c13ae7f4e1 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -104,6 +104,16 @@ void StaticTextWidget::setLabel(const char *label) _label = 0; } +void StaticTextWidget::setValue(int value) +{ + // Free old label if any + if (_label) + free(_label); + + _label = (char *)malloc(10); + sprintf(_label, "%d", value); +} + void StaticTextWidget::drawWidget(bool hilite) { NewGui *gui = _boss->getGui(); @@ -197,7 +207,7 @@ SliderWidget::SliderWidget(Dialog *boss, int x, int y, int w, int h, const char } void SliderWidget::handleMouseMoved(int x, int y, int button) { - if (_isDragging) { + if ((_flags & WIDGET_ENABLED) && _isDragging) { int newValue = posToValue(x); if (newValue < _valueMin) @@ -208,25 +218,28 @@ void SliderWidget::handleMouseMoved(int x, int y, int button) { if (newValue != _value) { _value = newValue; draw(); + sendCommand(_cmd, _value); // FIXME - hack to allow for "live update" in sound dialog } } } void SliderWidget::handleMouseDown(int x, int y, int button) { - int barx; - - barx = valueToPos(_value); - // only start dragging if mouse is over bar - if (x > (barx - 3) && x < (barx + 3)) - _isDragging = true; + if (_flags & WIDGET_ENABLED) { + int barx; + + barx = valueToPos(_value); + + // only start dragging if mouse is over bar + if (x > (barx - 3) && x < (barx + 3)) + _isDragging = true; + } } void SliderWidget::handleMouseUp(int x, int y, int button) { - if (_isDragging) { - if (_flags & WIDGET_ENABLED) - sendCommand(_cmd, 0); + if ((_flags & WIDGET_ENABLED) && _isDragging) { + sendCommand(_cmd, _value); } _isDragging = false; -- cgit v1.2.3