[Scummvm-cvs-logs] CVS: scummvm/gui widget.cpp,1.18,1.19

Max Horn fingolfin at users.sourceforge.net
Tue Jul 16 05:02:02 CEST 2002


Update of /cvsroot/scummvm/scummvm/gui
In directory usw-pr-cvs1:/tmp/cvs-serv22995

Modified Files:
	widget.cpp 
Log Message:
limit slider drag range

Index: widget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/widget.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- widget.cpp	16 Jul 2002 10:52:48 -0000	1.18
+++ widget.cpp	16 Jul 2002 12:01:03 -0000	1.19
@@ -197,10 +197,14 @@
 
 void SliderWidget::handleMouseMoved(int x, int y, int button) { 
 	if (_isDragging) {
-		int newvalue = x * 100 / _w;
+		int newValue = x * 100 / _w;
+		if (newValue < 0)
+			newValue = 0;
+		else if (newValue > 100)
+			newValue = 100;
 
-		if (newvalue != _value) {
-			_value = newvalue; 
+		if (newValue != _value) {
+			_value = newValue; 
 			draw();
 		}
 	}
@@ -226,14 +230,13 @@
 void SliderWidget::handleMouseDown(int x, int y, int button) {
 	int barx;
 
-	barx=2 + ((_w - 5) * _old_value / 100);
+	barx = 2 + ((_w - 5) * _old_value / 100);
 	
 	// only start dragging if mouse is over bar
-	if (x > (barx-3) && x < (barx+3))
-		_isDragging=true;
+	if (x > (barx - 3) && x < (barx + 3))
+		_isDragging = true;
 }
 
 void SliderWidget::handleMouseUp(int x, int y, int button) {
-	if (_isDragging)
-		_isDragging=false;
+	_isDragging = false;
 }





More information about the Scummvm-git-logs mailing list