[Scummvm-cvs-logs] CVS: scummvm/gui PopUpWidget.cpp,1.5,1.6 options.cpp,1.7,1.8

Max Horn fingolfin at users.sourceforge.net
Sat Dec 14 10:00:04 CET 2002


Update of /cvsroot/scummvm/scummvm/gui
In directory sc8-pr-cvs1:/tmp/cvs-serv26961/gui

Modified Files:
	PopUpWidget.cpp options.cpp 
Log Message:
fixed arrow/mouse wheel scrolling: now honors seperator items (i.e. you can't select the anymore); seperator items are now marked by an empty string

Index: PopUpWidget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/PopUpWidget.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- PopUpWidget.cpp	13 Dec 2002 22:19:26 -0000	1.5
+++ PopUpWidget.cpp	14 Dec 2002 17:59:22 -0000	1.6
@@ -70,6 +70,9 @@
 	int findItem(int x, int y) const;
 	void setSelection(int item);
 	bool isMouseDown();
+	
+	void moveUp();
+	void moveDown();
 };
 
 PopUpDialog::PopUpDialog(PopUpWidget *boss, int clickX, int clickY)
@@ -139,13 +142,10 @@
 
 void PopUpDialog::handleMouseWheel(int x, int y, int direction)
 {
-	if (direction < 0) {
-		if (_selection > 0)
-			setSelection(_selection-1);
-	} else if (direction > 0) {
-		if (_selection < _popUpBoss->_entries.size()-1)
-			setSelection(_selection+1);
-	}
+	if (direction < 0)
+		moveUp();
+	else if (direction > 0)
+		moveDown();
 }
 
 void PopUpDialog::handleMouseMoved(int x, int y, int button)
@@ -153,7 +153,7 @@
 	// Compute over which item the mouse is...
 	int item = findItem(x, y);
 
-	if (item >= 0 && _popUpBoss->_entries[item].name[0] == '-')
+	if (item >= 0 && _popUpBoss->_entries[item].name.size() == 0)
 		item = -1;
 
 	if (item == -1 && !isMouseDown())
@@ -180,12 +180,10 @@
 			close();
 			break;
 		case 256+17:	// up arrow
-			if (_selection > 0)
-				setSelection(_selection-1);
+			moveUp();
 			break;
 		case 256+18:	// down arrow
-			if (_selection < _popUpBoss->_entries.size()-1)
-				setSelection(_selection+1);
+			moveDown();
 			break;
 		case 256+22:	// home
 			setSelection(0);
@@ -229,6 +227,37 @@
 	return false;
 }
 
+void PopUpDialog::moveUp()
+{
+	if (_selection < 0) {
+		setSelection(_popUpBoss->_entries.size() - 1);
+	} else if (_selection > 0) {
+		int item = _selection;
+		do {
+			item--;
+		} while (item >= 0 && _popUpBoss->_entries[item].name.size() == 0);
+		if (item >= 0)
+			setSelection(item);
+	}
+}
+
+void PopUpDialog::moveDown()
+{
+	int lastItem = _popUpBoss->_entries.size() - 1;
+
+	if (_selection < 0) {
+		setSelection(0);
+	} else if (_selection < lastItem) {
+		int item = _selection;
+		do {
+			item++;
+		} while (item <= lastItem && _popUpBoss->_entries[item].name.size() == 0);
+		if (item <= lastItem)
+			setSelection(item);
+	}
+}
+
+
 void PopUpDialog::drawMenuEntry(int entry, bool hilite)
 {
 	// Draw one entry of the popup menu, including selection
@@ -239,7 +268,7 @@
 	ScummVM::String &name = _popUpBoss->_entries[entry].name;
 
 	_gui->fillRect(x, y, w, kLineHeight, hilite ? _gui->_textcolorhi : _gui->_bgcolor);
-	if (name[0] == '-') {
+	if (name.size() == 0) {
 		// Draw a seperator
 		_gui->hline(x, y+kLineHeight/2, x+w-1, _gui->_color);
 		_gui->hline(x+1, y+1+kLineHeight/2, x+w-1, _gui->_shadowcolor);

Index: options.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/options.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- options.cpp	14 Dec 2002 14:32:19 -0000	1.7
+++ options.cpp	14 Dec 2002 17:59:22 -0000	1.8
@@ -61,7 +61,7 @@
 	PopUpWidget *gfxPopUp;
 	gfxPopUp = new PopUpWidget(this, 105, 10, 180, kLineHeight);
 	gfxPopUp->appendEntry("<default>");
-	gfxPopUp->appendEntry("-");
+	gfxPopUp->appendEntry("");
 	gfxPopUp->appendEntry("Normal (no scaling)");
 	gfxPopUp->appendEntry("2x");
 	gfxPopUp->appendEntry("3x");





More information about the Scummvm-git-logs mailing list