[Scummvm-cvs-logs] SF.net SVN: scummvm:[35513] scummvm/trunk/gui

jvprat at users.sourceforge.net jvprat at users.sourceforge.net
Wed Dec 24 00:36:38 CET 2008


Revision: 35513
          http://scummvm.svn.sourceforge.net/scummvm/?rev=35513&view=rev
Author:   jvprat
Date:     2008-12-23 23:36:38 +0000 (Tue, 23 Dec 2008)

Log Message:
-----------
Modify the SliderWidget value by using the mouse wheel

Modified Paths:
--------------
    scummvm/trunk/gui/widget.cpp
    scummvm/trunk/gui/widget.h

Modified: scummvm/trunk/gui/widget.cpp
===================================================================
--- scummvm/trunk/gui/widget.cpp	2008-12-23 22:37:24 UTC (rev 35512)
+++ scummvm/trunk/gui/widget.cpp	2008-12-23 23:36:38 UTC (rev 35513)
@@ -309,16 +309,34 @@
 	_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 -

Modified: scummvm/trunk/gui/widget.h
===================================================================
--- scummvm/trunk/gui/widget.h	2008-12-23 22:37:24 UTC (rev 35512)
+++ scummvm/trunk/gui/widget.h	2008-12-23 23:36:38 UTC (rev 35513)
@@ -229,6 +229,7 @@
 	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();


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list