diff options
author | Eugene Sandulenko | 2014-04-28 20:50:12 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2014-04-28 20:50:12 +0300 |
commit | 09bbcced02f62c7805891a305851182ce1128077 (patch) | |
tree | b68396dc9bcb866a9a2ef67a5feeb640acdc910b /gui/widgets/tab.cpp | |
parent | 31b094892aae7572cd027efd53ad63a635ffeb04 (diff) | |
parent | 5c12e09ed1e2c2b83d74d824a941220b8faa11c9 (diff) | |
download | scummvm-rg350-09bbcced02f62c7805891a305851182ce1128077.tar.gz scummvm-rg350-09bbcced02f62c7805891a305851182ce1128077.tar.bz2 scummvm-rg350-09bbcced02f62c7805891a305851182ce1128077.zip |
Merge pull request #455 from Zerophase/master
GUI: Add Tab cycling to TabWidget
Diffstat (limited to 'gui/widgets/tab.cpp')
-rw-r--r-- | gui/widgets/tab.cpp | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/gui/widgets/tab.cpp b/gui/widgets/tab.cpp index a8b3f5450d..756781a04b 100644 --- a/gui/widgets/tab.cpp +++ b/gui/widgets/tab.cpp @@ -183,6 +183,7 @@ void TabWidget::setActiveTab(int tabID) { } _activeTab = tabID; _firstWidget = _tabs[tabID].firstWidget; + _boss->draw(); } } @@ -226,12 +227,34 @@ 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(kTabBackwards); + else if (state.keycode == Common::KEYCODE_TAB) + adjustTabs(kTabForwards); + 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); + + // Slides _firstVisibleTab forward to the correct tab + int maxTabsOnScreen = (_w / _tabWidth); + if (tabID >= maxTabsOnScreen && (_firstVisibleTab + maxTabsOnScreen) < (int)_tabs.size()) + _firstVisibleTab++; + + // Slides _firstVisibleTab backwards to the correct tab + while (tabID < _firstVisibleTab) + _firstVisibleTab--; + + setActiveTab(tabID); +} + void TabWidget::reflowLayout() { Widget::reflowLayout(); |