[Scummvm-cvs-logs] CVS: scummvm/gui ListWidget.cpp,1.5,1.6 ListWidget.h,1.4,1.5 launcher.cpp,1.2,1.3 newgui.cpp,1.19,1.20 newgui.h,1.12,1.13

Max Horn fingolfin at users.sourceforge.net
Mon Sep 30 05:58:56 CEST 2002


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

Modified Files:
	ListWidget.cpp ListWidget.h launcher.cpp newgui.cpp newgui.h 
Log Message:
fixed key repeat in NewGui; made the launcher game list non-editable

Index: ListWidget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/ListWidget.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- ListWidget.cpp	9 Sep 2002 20:28:48 -0000	1.5
+++ ListWidget.cpp	30 Sep 2002 12:56:59 -0000	1.6
@@ -125,7 +125,8 @@
 		case '\n':	// enter
 		case '\r':
 			if (_selectedItem >= 0) {
-				if ((_currentKeyDown != '\n' && _currentKeyDown != '\r')) {		// override continuous enter keydown
+				// override continuous enter keydown
+				if (_editable && (_currentKeyDown != '\n' && _currentKeyDown != '\r')) {
 					_editMode = true;
 					dirty = true;
 					_backupString = _list[_selectedItem];

Index: ListWidget.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/ListWidget.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- ListWidget.h	26 Sep 2002 11:44:02 -0000	1.4
+++ ListWidget.h	30 Sep 2002 12:56:59 -0000	1.5
@@ -62,6 +62,8 @@
 	int getSelected() const						{ return _selectedItem; }
 	const String& getSelectedString() const		{ return _list[_selectedItem]; }
 	void setNumberingMode(int numberingMode)	{ _numberingMode = numberingMode; }
+	bool isEditable() const						{ return _editable; }
+	void setEditable(bool editable)				{ _editable = editable; }
 	
 	virtual void handleMouseDown(int x, int y, int button, int clickCount);
 	virtual void handleMouseUp(int x, int y, int button, int clickCount);

Index: launcher.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/launcher.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- launcher.cpp	30 Sep 2002 00:55:47 -0000	1.2
+++ launcher.cpp	30 Sep 2002 12:56:59 -0000	1.3
@@ -54,6 +54,7 @@
 
 	// Add list with game titles
 	_list = new ListWidget(this, 10, 10, 300, 112);
+	_list->setEditable(false);
 	_list->setNumberingMode(kListNumberingOff);
 	
 	const VersionSettings *v = version_settings;

Index: newgui.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/newgui.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- newgui.cpp	28 Sep 2002 16:19:27 -0000	1.19
+++ newgui.cpp	30 Sep 2002 12:56:59 -0000	1.20
@@ -25,9 +25,7 @@
 
 
 #ifdef _MSC_VER
-
 #	pragma warning( disable : 4068 ) // unknown pragma
-
 #endif
 
 
@@ -44,6 +42,14 @@
  * - ...
  */
 
+enum {
+	kDoubleClickDelay = 500,    // milliseconds
+	kCursorAnimateDelay = 500,
+	
+	kKeyRepeatInitialDelay = 400,
+	kKeyRepeatSustainDelay = 100,
+};
+
 // Built-in font
 static byte guifont[] = {
 0,0,99,1,226,8,4,8,6,8,6,0,0,0,0,0,0,0,0,0,0,0,8,2,1,8,0,0,0,0,0,0,0,0,0,0,0,0,4,3,7,8,7,7,8,4,5,5,8,7,4,7,3,8,7,7,7,7,8,7,7,7,7,7,3,4,7,5,7,7,8,7,7,7,7,7,7,7,7,5,7,7,
@@ -126,6 +132,8 @@
 	
 		_system->update_screen();		
 
+		uint32 time = _system->get_msecs();
+
 		while (_system->poll_event(&event)) {
 			switch(event.event_code) {
 				case OSystem::EVENT_KEYDOWN:
@@ -134,8 +142,7 @@
 					// init continuous event stream
 					_currentKeyDown = event.kbd.ascii;
 					_currentKeyDownFlags = event.kbd.flags;
-					_keyRepeatEvenCount = 1;
-					_keyRepeatLoopCount = 0;
+					_keyRepeatTime = time + kKeyRepeatInitialDelay;
 					break;
 				case OSystem::EVENT_KEYUP:
 					activeDialog->handleKeyUp((byte)event.kbd.ascii, event.kbd.flags);
@@ -150,7 +157,6 @@
 				// We don'event distinguish between mousebuttons (for now at least)
 				case OSystem::EVENT_LBUTTONDOWN:
 				case OSystem::EVENT_RBUTTONDOWN: {
-					uint32 time = _system->get_msecs();
 					if (_lastClick.count && (time < _lastClick.time + kDoubleClickDelay)
 					      && ABS(_lastClick.x - event.mouse.x) < 3
 					      && ABS(_lastClick.y - event.mouse.y) < 3) {
@@ -174,17 +180,12 @@
 		// check if event should be sent again (keydown)
 		if (_currentKeyDown != 0)
 		{
-			// if only fired once, wait longer
-			if ( _keyRepeatLoopCount >= ((_keyRepeatEvenCount > 1) ? 2 : 4) )
-			//                                                           ^  loops to wait first event
-			//                                                       ^      loops to wait after first event
+			if (_keyRepeatTime < time)
 			{
 				// fire event
 				activeDialog->handleKeyDown(_currentKeyDown, _currentKeyDownFlags);
-				_keyRepeatEvenCount++;
-				_keyRepeatLoopCount = 0;
+				_keyRepeatTime = time + kKeyRepeatSustainDelay;
 			}
-			_keyRepeatLoopCount++;
 		}
 
 		// Delay for a moment

Index: newgui.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/newgui.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- newgui.h	28 Sep 2002 16:19:28 -0000	1.12
+++ newgui.h	30 Sep 2002 12:56:59 -0000	1.13
@@ -43,11 +43,6 @@
 	kTextAlignRight,
 };
 
-enum {
-	kDoubleClickDelay = 500,    // milliseconds
-	kCursorAnimateDelay = 500
-};
-
 // Extremly simple stack class, doesn't even do any error checking (for now)
 class DialogStack {
 protected:
@@ -88,8 +83,7 @@
 	
 	// for continuous events (keyDown)
 	int			_currentKeyDown, _currentKeyDownFlags;
-	int			_keyRepeatLoopCount;
-	int			_keyRepeatEvenCount;
+	uint32		_keyRepeatTime;
 	
 	// position and time of last mouse click (used to detect double clicks)
 	struct {





More information about the Scummvm-git-logs mailing list