diff options
author | Willem Jan Palenstijn | 2013-04-18 23:55:01 +0200 |
---|---|---|
committer | Willem Jan Palenstijn | 2013-05-08 20:47:44 +0200 |
commit | 102299630901d08a44ef3aec367fcbcae065b9fe (patch) | |
tree | 98db4bbe0c54176c0a43e2f5076f8b3d63b8065c /gui/widgets | |
parent | 583f9abaf98f64895546b75573e9442ca47426e3 (diff) | |
parent | 78ba3210a57094086d44b25d5a8507c33ce9bef3 (diff) | |
download | scummvm-rg350-102299630901d08a44ef3aec367fcbcae065b9fe.tar.gz scummvm-rg350-102299630901d08a44ef3aec367fcbcae065b9fe.tar.bz2 scummvm-rg350-102299630901d08a44ef3aec367fcbcae065b9fe.zip |
Merge branch 'master'
Diffstat (limited to 'gui/widgets')
-rw-r--r-- | gui/widgets/list.cpp | 17 | ||||
-rw-r--r-- | gui/widgets/list.h | 1 | ||||
-rw-r--r-- | gui/widgets/popup.cpp | 26 |
3 files changed, 27 insertions, 17 deletions
diff --git a/gui/widgets/list.cpp b/gui/widgets/list.cpp index 13784ddf7f..473d5f04df 100644 --- a/gui/widgets/list.cpp +++ b/gui/widgets/list.cpp @@ -206,6 +206,7 @@ void ListWidget::scrollTo(int item) { if (_currentPos != item) { _currentPos = item; + checkBounds(); scrollBarRecalc(); } } @@ -284,7 +285,7 @@ bool ListWidget::handleKeyDown(Common::KeyState state) { bool dirty = false; int oldSelectedItem = _selectedItem; - if (!_editMode && state.keycode <= Common::KEYCODE_z && isprint((unsigned char)state.ascii)) { + if (!_editMode && state.keycode <= Common::KEYCODE_z && Common::isPrint(state.ascii)) { // Quick selection mode: Go to first list item starting with this key // (or a substring accumulated from the last couple key presses). // Only works in a useful fashion if the list entries are sorted. @@ -467,6 +468,7 @@ void ListWidget::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { case kSetPositionCmd: if (_currentPos != (int)data) { _currentPos = data; + checkBounds(); draw(); // Scrollbar actions cause list focus (which triggers a redraw) @@ -550,6 +552,13 @@ Common::Rect ListWidget::getEditRect() const { return r; } +void ListWidget::checkBounds() { + if (_currentPos < 0 || _entriesPerPage > (int)_list.size()) + _currentPos = 0; + else if (_currentPos + _entriesPerPage > (int)_list.size()) + _currentPos = _list.size() - _entriesPerPage; +} + void ListWidget::scrollToCurrent() { // Only do something if the current item is not in our view port if (_selectedItem < _currentPos) { @@ -560,11 +569,7 @@ void ListWidget::scrollToCurrent() { _currentPos = _selectedItem - _entriesPerPage + 1; } - if (_currentPos < 0 || _entriesPerPage > (int)_list.size()) - _currentPos = 0; - else if (_currentPos + _entriesPerPage > (int)_list.size()) - _currentPos = _list.size() - _entriesPerPage; - + checkBounds(); _scrollBar->_currentPos = _currentPos; _scrollBar->recalc(); } diff --git a/gui/widgets/list.h b/gui/widgets/list.h index 47613b79f3..d18a82dd3f 100644 --- a/gui/widgets/list.h +++ b/gui/widgets/list.h @@ -145,6 +145,7 @@ protected: void receivedFocusWidget(); void lostFocusWidget(); + void checkBounds(); void scrollToCurrent(); int *_textWidth; diff --git a/gui/widgets/popup.cpp b/gui/widgets/popup.cpp index 1a552e97c0..829a49c53e 100644 --- a/gui/widgets/popup.cpp +++ b/gui/widgets/popup.cpp @@ -388,24 +388,28 @@ void PopUpWidget::handleMouseDown(int x, int y, int button, int clickCount) { if (newSel != -1 && _selectedItem != newSel) { _selectedItem = newSel; sendCommand(kPopUpItemSelectedCmd, _entries[_selectedItem].tag); + draw(); } } } void PopUpWidget::handleMouseWheel(int x, int y, int direction) { - int newSelection = _selectedItem + direction; + if (isEnabled()) { + int newSelection = _selectedItem + direction; - // Skip separator entries - while ((newSelection >= 0) && (newSelection < (int)_entries.size()) && - _entries[newSelection].name.equals("")) { - newSelection += direction; - } + // Skip separator entries + while ((newSelection >= 0) && (newSelection < (int)_entries.size()) && + _entries[newSelection].name.equals("")) { + newSelection += direction; + } - // Just update the selected item when we're in range - if ((newSelection >= 0) && (newSelection < (int)_entries.size()) && - (newSelection != _selectedItem)) { - _selectedItem = newSelection; - draw(); + // Just update the selected item when we're in range + if ((newSelection >= 0) && (newSelection < (int)_entries.size()) && + (newSelection != _selectedItem)) { + _selectedItem = newSelection; + sendCommand(kPopUpItemSelectedCmd, _entries[_selectedItem].tag); + draw(); + } } } |