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

sev at users.sourceforge.net sev at users.sourceforge.net
Sat Jun 6 19:54:28 CEST 2009


Revision: 41269
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41269&view=rev
Author:   sev
Date:     2009-06-06 17:54:28 +0000 (Sat, 06 Jun 2009)

Log Message:
-----------
Improvements to laucher dialog
- Made quicksearch turned off in the launcher game list
- Turn ListWidget into CommandSender
- Turn quicksearch off in launcher game list
- Connect laucher list widget with search box so search is initiated by typing

Modified Paths:
--------------
    scummvm/trunk/gui/ListWidget.cpp
    scummvm/trunk/gui/ListWidget.h
    scummvm/trunk/gui/launcher.cpp

Modified: scummvm/trunk/gui/ListWidget.cpp
===================================================================
--- scummvm/trunk/gui/ListWidget.cpp	2009-06-06 17:54:08 UTC (rev 41268)
+++ scummvm/trunk/gui/ListWidget.cpp	2009-06-06 17:54:28 UTC (rev 41269)
@@ -33,8 +33,8 @@
 
 namespace GUI {
 
-ListWidget::ListWidget(GuiObject *boss, const String &name)
-	: EditableWidget(boss, name) {
+ListWidget::ListWidget(GuiObject *boss, const String &name, uint32 cmd)
+	: EditableWidget(boss, name), _cmd(cmd) {
 
 	_scrollBar = NULL;
 	_textWidth = NULL;
@@ -60,10 +60,12 @@
 
 	// FIXME: This flag should come from widget definition
 	_editable = true;
+
+	_quickSelect = true;
 }
 
-ListWidget::ListWidget(GuiObject *boss, int x, int y, int w, int h)
-	: EditableWidget(boss, x, y, w, h) {
+ListWidget::ListWidget(GuiObject *boss, int x, int y, int w, int h, uint32 cmd)
+	: EditableWidget(boss, x, y, w, h), _cmd(cmd) {
 
 	_scrollBar = NULL;
 	_textWidth = NULL;
@@ -234,8 +236,6 @@
 		// Quick selection mode: Go to first list item starting with this key
 		// (or a substring accumulated from the last couple key presses).
 		// Only works in a useful fashion if the list entries are sorted.
-		// TODO: Maybe this should be off by default, and instead we add a
-		// method "enableQuickSelect()" or so ?
 		uint32 time = getMillis();
 		if (_quickSelectTime < time) {
 			_quickSelectStr = (char)state.ascii;
@@ -244,26 +244,29 @@
 		}
 		_quickSelectTime = time + 300;	// TODO: Turn this into a proper constant (kQuickSelectDelay ?)
 
+		if (_quickSelect) {
+			// FIXME: This is bad slow code (it scans the list linearly each time a
+			// key is pressed); it could be much faster. Only of importance if we have
+			// quite big lists to deal with -- so for now we can live with this lazy
+			// implementation :-)
+			int newSelectedItem = 0;
+			int bestMatch = 0;
+			bool stop;
+			for (StringList::const_iterator i = _list.begin(); i != _list.end(); ++i) {
+				const int match = matchingCharsIgnoringCase(i->c_str(), _quickSelectStr.c_str(), stop);
+				if (match > bestMatch || stop) {
+					_selectedItem = newSelectedItem;
+					bestMatch = match;
+					if (stop)
+						break;
+				}
+				newSelectedItem++;
+			}
 
-		// FIXME: This is bad slow code (it scans the list linearly each time a
-		// key is pressed); it could be much faster. Only of importance if we have
-		// quite big lists to deal with -- so for now we can live with this lazy
-		// implementation :-)
-		int newSelectedItem = 0;
-		int bestMatch = 0;
-		bool stop;
-		for (StringList::const_iterator i = _list.begin(); i != _list.end(); ++i) {
-			const int match = matchingCharsIgnoringCase(i->c_str(), _quickSelectStr.c_str(), stop);
-			if (match > bestMatch || stop) {
-				_selectedItem = newSelectedItem;
-				bestMatch = match;
-				if (stop)
-					break;
-			}
-			newSelectedItem++;
+			scrollToCurrent();
+		} else {
+			sendCommand(_cmd, 0);
 		}
-
-		scrollToCurrent();
 	} else if (_editMode) {
 		// Class EditableWidget handles all text editing related key presses for us
 		handled = EditableWidget::handleKeyDown(state);

Modified: scummvm/trunk/gui/ListWidget.h
===================================================================
--- scummvm/trunk/gui/ListWidget.h	2009-06-06 17:54:08 UTC (rev 41268)
+++ scummvm/trunk/gui/ListWidget.h	2009-06-06 17:54:28 UTC (rev 41269)
@@ -75,10 +75,13 @@
 	int				_scrollBarWidth;
 
 	String			_filter;
+	bool			_quickSelect;
 
+	uint32			_cmd;
+
 public:
-	ListWidget(GuiObject *boss, const String &name);
-	ListWidget(GuiObject *boss, int x, int y, int w, int h);
+	ListWidget(GuiObject *boss, const String &name, uint32 cmd = 0);
+	ListWidget(GuiObject *boss, int x, int y, int w, int h, uint32 cmd = 0);
 	virtual ~ListWidget();
 
 	virtual Widget *findWidget(int x, int y);
@@ -94,6 +97,8 @@
 	void setEditable(bool editable)				{ _editable = editable; }
 	void scrollTo(int item);
 	void scrollToEnd();
+	void enableQuickSelect(bool enable) 		{ _quickSelect = enable; }
+	String getQuickSelectString() const 		{ return _quickSelectStr; }
 
 	void setFilter(const String &filter);
 

Modified: scummvm/trunk/gui/launcher.cpp
===================================================================
--- scummvm/trunk/gui/launcher.cpp	2009-06-06 17:54:08 UTC (rev 41268)
+++ scummvm/trunk/gui/launcher.cpp	2009-06-06 17:54:28 UTC (rev 41269)
@@ -65,8 +65,8 @@
 	kLoadGameCmd = 'LOAD',
 	kQuitCmd = 'QUIT',
 	kSearchCmd = 'SRCH',
+	kListSearchCmd = 'LSSR',
 
-
 	kCmdGlobalGraphicsOverride = 'OGFX',
 	kCmdGlobalAudioOverride = 'OSFX',
 	kCmdGlobalMIDIOverride = 'OMID',
@@ -523,9 +523,10 @@
 	_searchWidget = new EditTextWidget(this, "Launcher.Search", _search, kSearchCmd);
 
 	// Add list with game titles
-	_list = new ListWidget(this, "Launcher.GameList");
+	_list = new ListWidget(this, "Launcher.GameList", kListSearchCmd);
 	_list->setEditable(false);
 	_list->setNumberingMode(kListNumberingOff);
+	_list->enableQuickSelect(false);
 
 
 	// Populate the list
@@ -923,6 +924,11 @@
 	case kSearchCmd:
 		_list->setFilter(_searchWidget->getEditString());
 		break;
+	case kListSearchCmd:
+		_searchWidget->setEditString(_list->getQuickSelectString());
+		_searchWidget->draw();
+		_list->setFilter(_list->getQuickSelectString());
+		break;
 	default:
 		Dialog::handleCommand(sender, cmd, data);
 	}


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