mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-11 11:45:21 +00:00
Implement FR#1970293: "LAUNCHER: Add "quick search" input field like in iTunes"
svn-id: r41268
This commit is contained in:
parent
dcc90445f6
commit
5fc047dddf
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -62,6 +62,7 @@ protected:
|
||||
GraphicsWidget *_logo;
|
||||
GraphicsWidget *_searchPic;
|
||||
#endif
|
||||
StaticTextWidget *_searchDesc;
|
||||
StringList _domains;
|
||||
BrowserDialog *_browser;
|
||||
SaveLoadChooser *_loadDialog;
|
||||
|
@ -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' "
|
||||
|
Binary file not shown.
@ -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'
|
||||
|
@ -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'
|
||||
|
Binary file not shown.
@ -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'/>
|
||||
|
||||
|
@ -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'
|
||||
|
Loading…
Reference in New Issue
Block a user