diff options
author | Max Horn | 2002-12-14 17:59:22 +0000 |
---|---|---|
committer | Max Horn | 2002-12-14 17:59:22 +0000 |
commit | 3575a2db06f393f6105b87019564d7e2cd44b9e8 (patch) | |
tree | 03da25810d99d450324fa2f82916e3e93d9e8b2a /gui | |
parent | 32b4bfacb2767cdc5960f24fd3096eb10c0a42f5 (diff) | |
download | scummvm-rg350-3575a2db06f393f6105b87019564d7e2cd44b9e8.tar.gz scummvm-rg350-3575a2db06f393f6105b87019564d7e2cd44b9e8.tar.bz2 scummvm-rg350-3575a2db06f393f6105b87019564d7e2cd44b9e8.zip |
fixed arrow/mouse wheel scrolling: now honors seperator items (i.e. you can't select the anymore); seperator items are now marked by an empty string
svn-id: r5961
Diffstat (limited to 'gui')
-rw-r--r-- | gui/PopUpWidget.cpp | 55 | ||||
-rw-r--r-- | gui/options.cpp | 2 |
2 files changed, 43 insertions, 14 deletions
diff --git a/gui/PopUpWidget.cpp b/gui/PopUpWidget.cpp index 464388f257..ea7a005b96 100644 --- a/gui/PopUpWidget.cpp +++ b/gui/PopUpWidget.cpp @@ -70,6 +70,9 @@ protected: int findItem(int x, int y) const; void setSelection(int item); bool isMouseDown(); + + void moveUp(); + void moveDown(); }; PopUpDialog::PopUpDialog(PopUpWidget *boss, int clickX, int clickY) @@ -139,13 +142,10 @@ void PopUpDialog::handleMouseUp(int x, int y, int button, int clickCount) void PopUpDialog::handleMouseWheel(int x, int y, int direction) { - if (direction < 0) { - if (_selection > 0) - setSelection(_selection-1); - } else if (direction > 0) { - if (_selection < _popUpBoss->_entries.size()-1) - setSelection(_selection+1); - } + if (direction < 0) + moveUp(); + else if (direction > 0) + moveDown(); } void PopUpDialog::handleMouseMoved(int x, int y, int button) @@ -153,7 +153,7 @@ void PopUpDialog::handleMouseMoved(int x, int y, int button) // Compute over which item the mouse is... int item = findItem(x, y); - if (item >= 0 && _popUpBoss->_entries[item].name[0] == '-') + if (item >= 0 && _popUpBoss->_entries[item].name.size() == 0) item = -1; if (item == -1 && !isMouseDown()) @@ -180,12 +180,10 @@ void PopUpDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) close(); break; case 256+17: // up arrow - if (_selection > 0) - setSelection(_selection-1); + moveUp(); break; case 256+18: // down arrow - if (_selection < _popUpBoss->_entries.size()-1) - setSelection(_selection+1); + moveDown(); break; case 256+22: // home setSelection(0); @@ -229,6 +227,37 @@ bool PopUpDialog::isMouseDown() return false; } +void PopUpDialog::moveUp() +{ + if (_selection < 0) { + setSelection(_popUpBoss->_entries.size() - 1); + } else if (_selection > 0) { + int item = _selection; + do { + item--; + } while (item >= 0 && _popUpBoss->_entries[item].name.size() == 0); + if (item >= 0) + setSelection(item); + } +} + +void PopUpDialog::moveDown() +{ + int lastItem = _popUpBoss->_entries.size() - 1; + + if (_selection < 0) { + setSelection(0); + } else if (_selection < lastItem) { + int item = _selection; + do { + item++; + } while (item <= lastItem && _popUpBoss->_entries[item].name.size() == 0); + if (item <= lastItem) + setSelection(item); + } +} + + void PopUpDialog::drawMenuEntry(int entry, bool hilite) { // Draw one entry of the popup menu, including selection @@ -239,7 +268,7 @@ void PopUpDialog::drawMenuEntry(int entry, bool hilite) ScummVM::String &name = _popUpBoss->_entries[entry].name; _gui->fillRect(x, y, w, kLineHeight, hilite ? _gui->_textcolorhi : _gui->_bgcolor); - if (name[0] == '-') { + if (name.size() == 0) { // Draw a seperator _gui->hline(x, y+kLineHeight/2, x+w-1, _gui->_color); _gui->hline(x+1, y+1+kLineHeight/2, x+w-1, _gui->_shadowcolor); diff --git a/gui/options.cpp b/gui/options.cpp index eebdcdc3cb..68f3beb616 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -61,7 +61,7 @@ GlobalOptionsDialog::GlobalOptionsDialog(NewGui *gui) PopUpWidget *gfxPopUp; gfxPopUp = new PopUpWidget(this, 105, 10, 180, kLineHeight); gfxPopUp->appendEntry("<default>"); - gfxPopUp->appendEntry("-"); + gfxPopUp->appendEntry(""); gfxPopUp->appendEntry("Normal (no scaling)"); gfxPopUp->appendEntry("2x"); gfxPopUp->appendEntry("3x"); |