diff options
author | Zerophase | 2014-04-01 05:42:16 -0500 |
---|---|---|
committer | Zerophase | 2014-04-01 07:28:57 -0500 |
commit | 5df3c14eba68e299d270e773194608808adaa1ae (patch) | |
tree | 390823b2db4cc2554d78413cf588e8d5864f326e /gui/widgets | |
parent | 80d34a8a7cc6960006bc90f80686c2241f60226f (diff) | |
download | scummvm-rg350-5df3c14eba68e299d270e773194608808adaa1ae.tar.gz scummvm-rg350-5df3c14eba68e299d270e773194608808adaa1ae.tar.bz2 scummvm-rg350-5df3c14eba68e299d270e773194608808adaa1ae.zip |
GUI: Fix tab cycling when total tabs increase.
Tab cycling ignores tab width, and slides correctly for larger tab counts.
Diffstat (limited to 'gui/widgets')
-rw-r--r-- | gui/widgets/tab.cpp | 18 | ||||
-rw-r--r-- | gui/widgets/tab.h | 3 |
2 files changed, 12 insertions, 9 deletions
diff --git a/gui/widgets/tab.cpp b/gui/widgets/tab.cpp index 87c6b652d3..3ba6be8166 100644 --- a/gui/widgets/tab.cpp +++ b/gui/widgets/tab.cpp @@ -227,9 +227,9 @@ void TabWidget::handleMouseDown(int x, int y, int button, int clickCount) { bool TabWidget::handleKeyDown(Common::KeyState state) { if (state.hasFlags(Common::KBD_SHIFT) && state.keycode == Common::KEYCODE_TAB) - adjustTabs(-1); + adjustTabs(-kAheadTab); else if (state.keycode == Common::KEYCODE_TAB) - adjustTabs(1); + adjustTabs(kAheadTab); return Widget::handleKeyDown(state); } @@ -242,15 +242,15 @@ void TabWidget::adjustTabs(int value) { 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())) + // slides _firstVisibleTab forward to the correct tab + while (_firstVisibleTab < tabID - kMaxTabs) _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); + // slide _firstVisibleTab backwards to the correct tab + while (tabID < _firstVisibleTab) + _firstVisibleTab--; + + setActiveTab(tabID); } void TabWidget::reflowLayout() { diff --git a/gui/widgets/tab.h b/gui/widgets/tab.h index 08f29f9929..bf4176887c 100644 --- a/gui/widgets/tab.h +++ b/gui/widgets/tab.h @@ -38,6 +38,9 @@ class TabWidget : public Widget { typedef Common::Array<Tab> TabList; protected: + const int kMaxTabs = 5; + const int kAheadTab = 1; + int _activeTab; int _firstVisibleTab; TabList _tabs; |