From 8aa667e342e8c8dc203fb6811f01523bacfcffab Mon Sep 17 00:00:00 2001 From: Max Horn Date: Thu, 2 Jul 2009 21:16:36 +0000 Subject: Enhanced the quicksearch box in the launcher to match words in the search string individually svn-id: r42038 --- gui/ListWidget.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'gui/ListWidget.cpp') diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp index e46d5e9b1e..07d22973ac 100644 --- a/gui/ListWidget.cpp +++ b/gui/ListWidget.cpp @@ -561,8 +561,10 @@ void ListWidget::setFilter(const String &filter, bool redraw) { // No filter -> display everything _list = _dataList; } else { - // Restrict the list to everything which contains _filter as a substring, - // ignoring case. + // Restrict the list to everything which contains all words in _filter + // as substrings, ignoring case. + + Common::StringTokenizer tok(filter); String tmp; int n = 0; @@ -572,7 +574,16 @@ void ListWidget::setFilter(const String &filter, bool redraw) { for (StringList::iterator i = _dataList.begin(); i != _dataList.end(); ++i, ++n) { tmp = *i; tmp.toLowercase(); - if (tmp.contains(_filter)) { + bool matches = true; + tok.reset(); + while (!tok.empty()) { + if (!tmp.contains(tok.nextToken())) { + matches = false; + break; + } + } + + if (matches) { _list.push_back(*i); _listIndex.push_back(n); } -- cgit v1.2.3 From 32f1e47effadf6e361f3e6c658ca43a36f37852a Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 12 Jul 2009 14:29:59 +0000 Subject: Fix typo, which in fact fixes bug #2820353 "GUI: Search doesn't handle uppercase properly". svn-id: r42418 --- gui/ListWidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gui/ListWidget.cpp') diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp index 07d22973ac..8661444cf3 100644 --- a/gui/ListWidget.cpp +++ b/gui/ListWidget.cpp @@ -564,7 +564,7 @@ void ListWidget::setFilter(const String &filter, bool redraw) { // Restrict the list to everything which contains all words in _filter // as substrings, ignoring case. - Common::StringTokenizer tok(filter); + Common::StringTokenizer tok(_filter); String tmp; int n = 0; -- cgit v1.2.3 From 7b55b5f5e2dbfd59a5936cb4671060d7b3b6ff81 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 15 Jul 2009 17:07:45 +0000 Subject: Fix "search" filter being settings lost in launcher, when using the "Edit Game..." menu for example. svn-id: r42510 --- gui/ListWidget.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'gui/ListWidget.cpp') diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp index 8661444cf3..78372fcba8 100644 --- a/gui/ListWidget.cpp +++ b/gui/ListWidget.cpp @@ -105,6 +105,22 @@ Widget *ListWidget::findWidget(int x, int y) { } void ListWidget::setSelected(int item) { + // HACK/FIXME: If our _listIndex has a non zero size, + // we will need to look up, whether the user selected + // item is present in that list + if (_listIndex.size()) { + int filteredItem = -1; + + for (uint i = 0; i < _listIndex.size(); ++i) { + if (_listIndex[i] == item) { + filteredItem = i; + break; + } + } + + item = filteredItem; + } + assert(item >= -1 && item < (int)_list.size()); // We only have to do something if the widget is enabled and the selection actually changes @@ -131,6 +147,7 @@ void ListWidget::setList(const StringList &list) { _dataList = list; _list = list; _filter.clear(); + _listIndex.clear(); int size = list.size(); if (_currentPos >= size) @@ -560,6 +577,7 @@ void ListWidget::setFilter(const String &filter, bool redraw) { if (_filter.empty()) { // No filter -> display everything _list = _dataList; + _listIndex.clear(); } else { // Restrict the list to everything which contains all words in _filter // as substrings, ignoring case. -- cgit v1.2.3 From 6a15e14d3ff0804efb08020c86c60c6c818aa1b4 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 15 Jul 2009 17:23:27 +0000 Subject: Fix bug, which caused the ListWidget to draw a widget background around the selected item, when the ListWidget had no focus. svn-id: r42511 --- gui/ListWidget.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'gui/ListWidget.cpp') diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp index 78372fcba8..fe6ec5383f 100644 --- a/gui/ListWidget.cpp +++ b/gui/ListWidget.cpp @@ -407,13 +407,8 @@ void ListWidget::drawWidget() { bool inverted = false; // Draw the selected item inverted, on a highlighted background. - if (_selectedItem == pos) { - if (_hasFocus) - inverted = true; - else - g_gui.theme()->drawWidgetBackground(Common::Rect(_x, y - 1, _x + _w - 1, y + fontHeight - 1), - 0, ThemeEngine::kWidgetBackgroundBorderSmall); - } + if (_selectedItem == pos) + inverted = true; Common::Rect r(getEditRect()); int pad = _leftPadding; -- cgit v1.2.3 From 6a26f1b56f0317af4099c978a5cd1511d7fbcb7c Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 15 Jul 2009 18:05:37 +0000 Subject: For a smoother user experience, use different colors for inverted text of the ListWidget, depending on whether the widget has focus or not. svn-id: r42512 --- gui/ListWidget.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'gui/ListWidget.cpp') diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp index fe6ec5383f..3d4c10859f 100644 --- a/gui/ListWidget.cpp +++ b/gui/ListWidget.cpp @@ -404,11 +404,15 @@ void ListWidget::drawWidget() { for (i = 0, pos = _currentPos; i < _entriesPerPage && pos < len; i++, pos++) { const int y = _y + _topPadding + kLineHeight * i; const int fontHeight = kLineHeight; - bool inverted = false; + ThemeEngine::TextInversionState inverted = ThemeEngine::kTextInversionNone; // Draw the selected item inverted, on a highlighted background. - if (_selectedItem == pos) - inverted = true; + if (_selectedItem == pos) { + if (_hasFocus) + inverted = ThemeEngine::kTextInversionFocus; + else + inverted = ThemeEngine::kTextInversion; + } Common::Rect r(getEditRect()); int pad = _leftPadding; -- cgit v1.2.3