GUI: Save/restore last scroll position in the list save/load dialog.

This should give a better user experience, since the user will not have to
scroll back to where he was when he used the dialog last.

Thanks to wjp for suggesting this.
This commit is contained in:
Johannes Schickel 2012-09-26 02:45:34 +02:00
parent 66fb399227
commit bc1743b225
3 changed files with 23 additions and 0 deletions

View File

@ -422,7 +422,28 @@ void SaveLoadChooserSimple::updateSelection(bool redraw) {
}
}
void SaveLoadChooserSimple::open() {
SaveLoadChooserDialog::open();
// Scroll the list to the last used entry.
_list->scrollTo(ConfMan.getInt("gui_saveload_last_pos"));
}
void SaveLoadChooserSimple::close() {
// Save the current scroll position/used entry.
const int result = getResult();
if (result >= 0) {
ConfMan.setInt("gui_saveload_last_pos", result);
} else {
// Use the current scroll position here.
// TODO: This means we canceled the dialog (or switch to the grid). Do
// we want to save this position here? Does the user want that?
// TODO: Do we want to save the current scroll position or the
// currently selected item here? The scroll position is what the user
// currently sees and seems to make more sense.
ConfMan.setInt("gui_saveload_last_pos", _list->getCurrentScrollPos());
}
_metaEngine = 0;
_target.clear();
_saveList.clear();

View File

@ -103,6 +103,7 @@ public:
virtual SaveLoadChooserType getType() const { return kSaveLoadDialogList; }
#endif // !DISABLE_SAVELOADCHOOSER_GRID
virtual void open();
virtual void close();
private:
virtual int runIntern();

View File

@ -105,6 +105,7 @@ public:
void scrollTo(int item);
void scrollToEnd();
int getCurrentScrollPos() const { return _currentPos; }
void enableQuickSelect(bool enable) { _quickSelect = enable; }
String getQuickSelectString() const { return _quickSelectStr; }