diff options
author | Eugene Sandulenko | 2009-06-06 17:54:08 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2009-06-06 17:54:08 +0000 |
commit | 5fc047dddfcad4e712bea97aadd561493f4f388c (patch) | |
tree | 9b1dc2e81b2ed0c194f06676c2c5a30ce2758d32 | |
parent | dcc90445f6ea424bd4576f04afbc790fc43a5c76 (diff) | |
download | scummvm-rg350-5fc047dddfcad4e712bea97aadd561493f4f388c.tar.gz scummvm-rg350-5fc047dddfcad4e712bea97aadd561493f4f388c.tar.bz2 scummvm-rg350-5fc047dddfcad4e712bea97aadd561493f4f388c.zip |
Implement FR#1970293: "LAUNCHER: Add "quick search" input field like in iTunes"
svn-id: r41268
-rw-r--r-- | gui/ListWidget.cpp | 37 | ||||
-rw-r--r-- | gui/ListWidget.h | 7 | ||||
-rw-r--r-- | gui/launcher.cpp | 36 | ||||
-rw-r--r-- | gui/launcher.h | 1 | ||||
-rw-r--r-- | gui/themes/default.inc | 26 | ||||
-rw-r--r-- | gui/themes/scummclassic.zip | bin | 50347 -> 50934 bytes | |||
-rw-r--r-- | gui/themes/scummclassic/classic_layout.stx | 17 | ||||
-rw-r--r-- | gui/themes/scummclassic/classic_layout_lowres.stx | 14 | ||||
-rw-r--r-- | gui/themes/scummmodern.zip | bin | 155905 -> 156302 bytes | |||
-rw-r--r-- | gui/themes/scummmodern/scummmodern_layout.stx | 1 | ||||
-rw-r--r-- | gui/themes/scummmodern/scummmodern_layout_lowres.stx | 14 |
11 files changed, 146 insertions, 7 deletions
diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp index 8e5ef99f06..b96019af04 100644 --- a/gui/ListWidget.cpp +++ b/gui/ListWidget.cpp @@ -122,7 +122,12 @@ void ListWidget::setList(const StringList &list) { if (_editMode && _caretVisible) drawCaret(true); int size = list.size(); + _dataList = list; + + // Copy everything _list = list; + _filter = ""; + if (_currentPos >= size) _currentPos = size - 1; if (_currentPos < 0) @@ -134,6 +139,7 @@ void ListWidget::setList(const StringList &list) { } void ListWidget::append(const String &s) { + _dataList.push_back(s); _list.push_back(s); scrollBarRecalc(); } @@ -529,4 +535,35 @@ void ListWidget::reflowLayout() { } } +void ListWidget::setFilter(const String &filter) { + String filt; + + filt = filter; + + filt.toLowercase(); + _filter = filt; + + if (_filter == "") { + _list = _dataList; + } else { + String tmp; + + _list.clear(); + + for (StringList::iterator i = _dataList.begin(); i != _dataList.end(); ++i) { + tmp = *i; + tmp.toLowercase(); + if (tmp.contains(_filter.c_str())) { + _list.push_back(*i); + } + } + } + + _currentPos = 0; + _selectedItem = -1; + scrollBarRecalc(); + + draw(); +} + } // End of namespace GUI diff --git a/gui/ListWidget.h b/gui/ListWidget.h index 7478da930d..680a931025 100644 --- a/gui/ListWidget.h +++ b/gui/ListWidget.h @@ -53,6 +53,7 @@ public: typedef Common::StringList StringList; protected: StringList _list; + StringList _dataList; bool _editable; bool _editMode; NumberingMode _numberingMode; @@ -73,6 +74,8 @@ protected: int _bottomPadding; int _scrollBarWidth; + String _filter; + public: ListWidget(GuiObject *boss, const String &name); ListWidget(GuiObject *boss, int x, int y, int w, int h); @@ -82,7 +85,7 @@ public: void setList(const StringList &list); void append(const String &s); - const StringList &getList() const { return _list; } + const StringList &getList() const { return _dataList; } int getSelected() const { return _selectedItem; } void setSelected(int item); const String &getSelectedString() const { return _list[_selectedItem]; } @@ -92,6 +95,8 @@ public: void scrollTo(int item); void scrollToEnd(); + void setFilter(const String &filter); + virtual void handleTickle(); virtual void handleMouseDown(int x, int y, int button, int clickCount); virtual void handleMouseUp(int x, int y, int button, int clickCount); diff --git a/gui/launcher.cpp b/gui/launcher.cpp index f9c0775444..aa147cab16 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -510,8 +510,16 @@ LauncherDialog::LauncherDialog() new ButtonWidget(this, "Launcher.RemoveGameButton", "Remove Game", kRemoveGameCmd, 'R'); // Search box - _searchPic = new GraphicsWidget(this, "Launcher.SearchPic"); - _searchPic->setGfx(g_gui.theme()->getImageSurface(ThemeEngine::kImageSearch)); + _searchDesc = 0; +#ifndef DISABLE_FANCY_THEMES + _searchPic = 0; + if (g_gui.xmlEval()->getVar("Globals.ShowSearchPic") == 1 && g_gui.theme()->supportsImages()) { + _searchPic = new GraphicsWidget(this, "Launcher.SearchPic"); + _searchPic->setGfx(g_gui.theme()->getImageSurface(ThemeEngine::kImageSearch)); + } else +#endif + _searchDesc = new StaticTextWidget(this, "Launcher.SearchDesc", "Search:"); + _searchWidget = new EditTextWidget(this, "Launcher.Search", _search, kSearchCmd); // Add list with game titles @@ -913,6 +921,7 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat close(); break; case kSearchCmd: + _list->setFilter(_searchWidget->getEditString()); break; default: Dialog::handleCommand(sender, cmd, data); @@ -975,6 +984,29 @@ void LauncherDialog::reflowLayout() { _logo = 0; } } + + if (g_gui.xmlEval()->getVar("Globals.ShowSearchPic") == 1 && g_gui.theme()->supportsImages()) { + if (!_searchPic) + _searchPic = new GraphicsWidget(this, "Launcher.SearchPic"); + _searchPic->setGfx(g_gui.theme()->getImageSurface(ThemeEngine::kImageSearch)); + + if (_searchDesc) { + removeWidget(_searchDesc); + _searchDesc->setNext(0); + delete _searchDesc; + _searchDesc = 0; + } + } else { + if (!_searchDesc) + _searchDesc = new StaticTextWidget(this, "Launcher.SearchDesc", "Search:"); + + if (_searchPic) { + removeWidget(_searchPic); + _searchPic->setNext(0); + delete _searchPic; + _searchPic = 0; + } + } #endif _w = g_system->getOverlayWidth(); diff --git a/gui/launcher.h b/gui/launcher.h index 0f4bdd8ed7..ea50d679c1 100644 --- a/gui/launcher.h +++ b/gui/launcher.h @@ -62,6 +62,7 @@ protected: GraphicsWidget *_logo; GraphicsWidget *_searchPic; #endif + StaticTextWidget *_searchDesc; StringList _domains; BrowserDialog *_browser; SaveLoadChooser *_loadDialog; diff --git a/gui/themes/default.inc b/gui/themes/default.inc index e4df6b0509..ebdc7b89e4 100644 --- a/gui/themes/default.inc +++ b/gui/themes/default.inc @@ -332,6 +332,7 @@ "<def var='Layout.Spacing' value='8' /> " "<def var='ShowLauncherLogo' value='0'/> " "<def var='ShowGlobalMenuLogo' value='0'/> " +"<def var='ShowSearchPic' value='0'/> " "<def var='ScummSaveLoad.ExtInfo.Visible' value='1'/> " "<widget name='OptionsLabel' " "size='110,Globals.Line.Height' " @@ -384,6 +385,18 @@ "<widget name='Version' " "height='Globals.Line.Height' " "/> " +"<layout type='horizontal' spacing='5' padding='10,0,0,0'> " +"<widget name='SearchDesc' " +"width='60' " +"height='Globals.Line.Height' " +"textalign='right' " +"/> " +"<widget name='Search' " +"width='150' " +"height='Globals.Line.Height' " +"/> " +"<space /> " +"</layout> " "<widget name='GameList'/> " "<layout type='horizontal' padding='0,0,0,0' spacing='10'> " "<widget name='LoadGameButton' " @@ -1044,6 +1057,7 @@ "<def var='Layout.Spacing' value='8'/> " "<def var='ShowLauncherLogo' value='0'/> " "<def var='ShowGlobalMenuLogo' value='0'/> " +"<def var='ShowSearchPic' value='0'/> " "<def var='ScummSaveLoad.ExtInfo.Visible' value='0'/> " "<widget name='Button' " "size='72,16' " @@ -1093,6 +1107,18 @@ "<widget name='Version' " "height='Globals.Line.Height' " "/> " +"<layout type='horizontal' spacing='5' padding='10,0,0,0'> " +"<widget name='SearchDesc' " +"width='50' " +"height='Globals.Line.Height' " +"textalign='right' " +"/> " +"<widget name='Search' " +"width='150' " +"height='Globals.Line.Height' " +"/> " +"<space /> " +"</layout> " "<widget name='GameList'/> " "<layout type='horizontal' padding='0,0,0,0' spacing='10'> " "<widget name='LoadGameButton' " diff --git a/gui/themes/scummclassic.zip b/gui/themes/scummclassic.zip Binary files differindex daefaa9d78..0d2339ccc3 100644 --- a/gui/themes/scummclassic.zip +++ b/gui/themes/scummclassic.zip diff --git a/gui/themes/scummclassic/classic_layout.stx b/gui/themes/scummclassic/classic_layout.stx index 5569f68523..431db7756d 100644 --- a/gui/themes/scummclassic/classic_layout.stx +++ b/gui/themes/scummclassic/classic_layout.stx @@ -29,14 +29,11 @@ <def var = 'Font.Height' value = '16' /> <def var = 'About.OuterBorder' value = '80'/> -<!-- - <def var = 'PopUpWidget.labelSpacing' value = '10' /> - <def var = 'PopUpWidget.labelWidth' value = '110' /> ---> <def var = 'Layout.Spacing' value = '8' /> <def var = 'ShowLauncherLogo' value = '0'/> <def var = 'ShowGlobalMenuLogo' value = '0'/> + <def var = 'ShowSearchPic' value = '0'/> <def var = 'ScummSaveLoad.ExtInfo.Visible' value = '1'/> @@ -95,6 +92,18 @@ <widget name = 'Version' height = 'Globals.Line.Height' /> + <layout type = 'horizontal' spacing = '5' padding = '10, 0, 0, 0'> + <widget name = 'SearchDesc' + width = '60' + height = 'Globals.Line.Height' + textalign = 'right' + /> + <widget name = 'Search' + width = '150' + height = 'Globals.Line.Height' + /> + <space /> + </layout> <widget name = 'GameList'/> <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10'> <widget name = 'LoadGameButton' diff --git a/gui/themes/scummclassic/classic_layout_lowres.stx b/gui/themes/scummclassic/classic_layout_lowres.stx index a557b14f65..a5f8e627e9 100644 --- a/gui/themes/scummclassic/classic_layout_lowres.stx +++ b/gui/themes/scummclassic/classic_layout_lowres.stx @@ -34,6 +34,8 @@ <def var = 'ShowLauncherLogo' value = '0'/> <def var = 'ShowGlobalMenuLogo' value = '0'/> + <def var = 'ShowSearchPic' value = '0'/> + <def var = 'ScummSaveLoad.ExtInfo.Visible' value = '0'/> <widget name = 'Button' @@ -87,6 +89,18 @@ <widget name = 'Version' height = 'Globals.Line.Height' /> + <layout type = 'horizontal' spacing = '5' padding = '10, 0, 0, 0'> + <widget name = 'SearchDesc' + width = '50' + height = 'Globals.Line.Height' + textalign = 'right' + /> + <widget name = 'Search' + width = '150' + height = 'Globals.Line.Height' + /> + <space /> + </layout> <widget name = 'GameList'/> <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10'> <widget name = 'LoadGameButton' diff --git a/gui/themes/scummmodern.zip b/gui/themes/scummmodern.zip Binary files differindex 360afa5996..f85e74e1b8 100644 --- a/gui/themes/scummmodern.zip +++ b/gui/themes/scummmodern.zip diff --git a/gui/themes/scummmodern/scummmodern_layout.stx b/gui/themes/scummmodern/scummmodern_layout.stx index d90d6cd8da..1d26edc42c 100644 --- a/gui/themes/scummmodern/scummmodern_layout.stx +++ b/gui/themes/scummmodern/scummmodern_layout.stx @@ -40,6 +40,7 @@ <def var = 'ShowLauncherLogo' value = '1'/> <def var = 'ShowGlobalMenuLogo' value = '1'/> + <def var = 'ShowSearchPic' value = '1'/> <def var = 'ScummSaveLoad.ExtInfo.Visible' value = '1'/> diff --git a/gui/themes/scummmodern/scummmodern_layout_lowres.stx b/gui/themes/scummmodern/scummmodern_layout_lowres.stx index 4fbce354ae..96b3763540 100644 --- a/gui/themes/scummmodern/scummmodern_layout_lowres.stx +++ b/gui/themes/scummmodern/scummmodern_layout_lowres.stx @@ -32,6 +32,8 @@ <def var = 'ShowLauncherLogo' value = '0'/> <def var = 'ShowGlobalMenuLogo' value = '0'/> + <def var = 'ShowSearchPic' value = '0'/> + <def var = 'ScummSaveLoad.ExtInfo.Visible' value = '0'/> <widget name = 'Button' @@ -85,6 +87,18 @@ <widget name = 'Version' height = 'Globals.Line.Height' /> + <layout type = 'horizontal' spacing = '5' padding = '10, 0, 0, 0'> + <widget name = 'SearchDesc' + width = '50' + height = 'Globals.Line.Height' + textalign = 'right' + /> + <widget name = 'Search' + width = '150' + height = 'Globals.Line.Height' + /> + <space /> + </layout> <widget name = 'GameList'/> <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6'> <widget name = 'LoadGameButton' |