diff options
| author | Zerophase | 2014-03-31 00:43:54 -0500 |
|---|---|---|
| committer | Zerophase | 2014-04-01 07:28:48 -0500 |
| commit | 80d34a8a7cc6960006bc90f80686c2241f60226f (patch) | |
| tree | 3f49cdfdb70fae63ab47f6ccbbbf24cee9683bd9 /gui/widgets | |
| parent | d91c8b9add255828bb363020077d91a49ebe3d99 (diff) | |
| download | scummvm-rg350-80d34a8a7cc6960006bc90f80686c2241f60226f.tar.gz scummvm-rg350-80d34a8a7cc6960006bc90f80686c2241f60226f.tar.bz2 scummvm-rg350-80d34a8a7cc6960006bc90f80686c2241f60226f.zip | |
GUI: Add Tab cycling to TabWidget
Tab and Shift-Tab can now cycle between each Tab of the Edit Game menu.
Diffstat (limited to 'gui/widgets')
| -rw-r--r-- | gui/widgets/tab.cpp | 27 | ||||
| -rw-r--r-- | gui/widgets/tab.h | 2 |
2 files changed, 26 insertions, 3 deletions
diff --git a/gui/widgets/tab.cpp b/gui/widgets/tab.cpp index a8b3f5450d..87c6b652d3 100644 --- a/gui/widgets/tab.cpp +++ b/gui/widgets/tab.cpp @@ -226,12 +226,33 @@ void TabWidget::handleMouseDown(int x, int y, int button, int clickCount) { } bool TabWidget::handleKeyDown(Common::KeyState state) { - // TODO: maybe there should be a way to switch between tabs - // using the keyboard? E.g. Alt-Shift-Left/Right-Arrow or something - // like that. + if (state.hasFlags(Common::KBD_SHIFT) && state.keycode == Common::KEYCODE_TAB) + adjustTabs(-1); + else if (state.keycode == Common::KEYCODE_TAB) + adjustTabs(1); + return Widget::handleKeyDown(state); } +void TabWidget::adjustTabs(int value) { + // determine which tab is next + int tabID = _activeTab + value; + if (tabID >= (int)_tabs.size()) + tabID = 0; + else if (tabID < 0) + tabID = ((int)_tabs.size() - 1); + + // If tabbing moves the last tab out of sight slide tabs over + if ((tabID * _tabWidth) > (_w - getAbsX())) + _firstVisibleTab++; + else if (tabID == 0) + _firstVisibleTab = tabID; + + // If a tab was clicked, switch to that pane + if (tabID >= 0 && tabID < (int)_tabs.size()) + setActiveTab(tabID); +} + void TabWidget::reflowLayout() { Widget::reflowLayout(); diff --git a/gui/widgets/tab.h b/gui/widgets/tab.h index 38aa089eb5..08f29f9929 100644 --- a/gui/widgets/tab.h +++ b/gui/widgets/tab.h @@ -109,6 +109,8 @@ protected: virtual void drawWidget(); virtual Widget *findWidget(int x, int y); + + virtual void adjustTabs(int value); }; } // End of namespace GUI |
