[Scummvm-cvs-logs] CVS: scummvm/gui PopUpWidget.cpp,1.2,1.3

Max Horn fingolfin at users.sourceforge.net
Thu Dec 12 15:33:04 CET 2002


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

Modified Files:
	PopUpWidget.cpp 
Log Message:
added timeout for popup; fixed notifcation sent when popup item is chosen

Index: PopUpWidget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/PopUpWidget.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- PopUpWidget.cpp	12 Dec 2002 23:22:45 -0000	1.2
+++ PopUpWidget.cpp	12 Dec 2002 23:31:58 -0000	1.3
@@ -22,6 +22,7 @@
 #include "PopUpWidget.h"
 #include "dialog.h"
 #include "newgui.h"
+#include "common/engine.h"
 
 /* TODO:
  * - draw an (unselectable) sepeator line for items that start with a '-'
@@ -52,6 +53,7 @@
 	int			_clickX, _clickY;
 	byte		*_buffer;
 	int			_selection;
+	uint32		_openTime;
 public:
 	PopUpDialog(PopUpWidget *boss, int clickX, int clickY);
 	
@@ -93,6 +95,9 @@
 	// Remember original mouse position
 	_clickX = clickX - _x;
 	_clickY = clickY - _y;
+	
+	// Time the popup was opened
+	_openTime = g_system->get_msecs();
 }
 
 void PopUpDialog::drawDialog()
@@ -123,12 +128,13 @@
 	// Mouse was released. If it wasn't moved much since the original mouse down, 
 	// let the popup stay open. If it did move, assume the user made his selection.
 	int dist = (_clickX - x) * (_clickX - x) + (_clickY - y) * (_clickY - y);
-	if (dist > 3*3) {
+	if (dist > 3*3 || g_system->get_msecs() - _openTime > 300) {
 		setResult(_selection);
 		close();
 	}
 	_clickX = -1;
 	_clickY = -1;
+	_openTime = (uint32)-1;
 }
 
 void PopUpDialog::handleMouseMoved(int x, int y, int button)
@@ -214,7 +220,7 @@
 	int newSel = popupDialog.runModal();
 	if (newSel != -1 && _selectedItem != newSel) {
 		_selectedItem = newSel;
-		sendCommand(kPopUpItemSelectedCmd, _selectedItem);
+		sendCommand(kPopUpItemSelectedCmd, _entries[_selectedItem].tag);
 	}
 }
 





More information about the Scummvm-git-logs mailing list