mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-03 23:52:41 +00:00
Fix for bug #2802492 (GUI: search query causes game list scrollbar glitches)
svn-id: r41334
This commit is contained in:
parent
a39048877a
commit
de88db5f36
@ -107,11 +107,14 @@ Widget *ListWidget::findWidget(int x, int y) {
|
||||
void ListWidget::setSelected(int item) {
|
||||
assert(item >= -1 && item < (int)_list.size());
|
||||
|
||||
// We only have to do something if the widget is enabled and the selection actually changes
|
||||
if (isEnabled() && _selectedItem != item) {
|
||||
if (_editMode)
|
||||
abortEditMode();
|
||||
|
||||
_selectedItem = item;
|
||||
|
||||
// Notify clients that the selection changed.
|
||||
sendCommand(kListSelectionChangedCmd, _selectedItem);
|
||||
|
||||
_currentPos = _selectedItem - _entriesPerPage / 2;
|
||||
@ -123,14 +126,13 @@ void ListWidget::setSelected(int item) {
|
||||
void ListWidget::setList(const StringList &list) {
|
||||
if (_editMode && _caretVisible)
|
||||
drawCaret(true);
|
||||
int size = list.size();
|
||||
_dataList = list;
|
||||
|
||||
// Copy everything
|
||||
_dataList = list;
|
||||
_list = list;
|
||||
_filter = "";
|
||||
setFilter(_filter, false);
|
||||
_filter.clear();
|
||||
|
||||
int size = list.size();
|
||||
if (_currentPos >= size)
|
||||
_currentPos = size - 1;
|
||||
if (_currentPos < 0)
|
||||
@ -543,10 +545,11 @@ void ListWidget::reflowLayout() {
|
||||
}
|
||||
|
||||
void ListWidget::setFilter(const String &filter, bool redraw) {
|
||||
String filt;
|
||||
|
||||
filt = filter;
|
||||
// FIXME: This method does not deal correctly with edit mode!
|
||||
// Until we fix that, let's make sure it isn't called while editing takes place
|
||||
assert(!_editMode);
|
||||
|
||||
String filt = filter;
|
||||
filt.toLowercase();
|
||||
|
||||
if (_filter == filt) // Filter was not changed
|
||||
@ -554,20 +557,22 @@ void ListWidget::setFilter(const String &filter, bool redraw) {
|
||||
|
||||
_filter = filt;
|
||||
|
||||
if (_filter == "") {
|
||||
if (_filter.empty()) {
|
||||
// No filter -> display everything
|
||||
_list = _dataList;
|
||||
} else {
|
||||
// Restrict the list to everything which contains _filter as a substring,
|
||||
// ignoring case.
|
||||
String tmp;
|
||||
int n = 0;
|
||||
|
||||
_list.clear();
|
||||
|
||||
_listIndex.clear();
|
||||
|
||||
for (StringList::iterator i = _dataList.begin(); i != _dataList.end(); ++i, n++) {
|
||||
for (StringList::iterator i = _dataList.begin(); i != _dataList.end(); ++i, ++n) {
|
||||
tmp = *i;
|
||||
tmp.toLowercase();
|
||||
if (tmp.contains(_filter.c_str())) {
|
||||
if (tmp.contains(_filter)) {
|
||||
_list.push_back(*i);
|
||||
_listIndex.push_back(n);
|
||||
}
|
||||
@ -579,8 +584,18 @@ void ListWidget::setFilter(const String &filter, bool redraw) {
|
||||
|
||||
if (redraw) {
|
||||
scrollBarRecalc();
|
||||
|
||||
draw();
|
||||
// Redraw the whole dialog. This is annoying, as this might be rather
|
||||
// expensive when really only the list widget and its scroll bar area
|
||||
// to be redrawn. However, since the scrollbar might change its
|
||||
// visibility status, and the list its width, we cannot just redraw
|
||||
// the two.
|
||||
// TODO: A more efficient (and elegant?) way to handle this would be to
|
||||
// introduce a kind of "BoxWidget" or "GroupWidget" which defines a
|
||||
// rectangular region and subwidgets can be placed within it.
|
||||
// Such a widget could also (optionally) draw a border (or even different
|
||||
// kinds of borders) around the objects it groups; and also a 'title'
|
||||
// (I am borrowing these "ideas" from the NSBox class in Cocoa :).
|
||||
_boss->draw();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ public:
|
||||
void setList(const StringList &list);
|
||||
void append(const String &s);
|
||||
const StringList &getList() const { return _dataList; }
|
||||
int getSelected() const { return (_filter == "" || _selectedItem == -1) ? _selectedItem : _listIndex[_selectedItem]; }
|
||||
int getSelected() const { return (_filter.empty() || _selectedItem == -1) ? _selectedItem : _listIndex[_selectedItem]; }
|
||||
void setSelected(int item);
|
||||
const String &getSelectedString() const { return _list[_selectedItem]; }
|
||||
void setNumberingMode(NumberingMode numberingMode) { _numberingMode = numberingMode; }
|
||||
|
Loading…
Reference in New Issue
Block a user