diff options
author | Zerophase | 2014-04-06 19:56:55 -0500 |
---|---|---|
committer | Zerophase | 2014-04-06 19:58:56 -0500 |
commit | 5c12e09ed1e2c2b83d74d824a941220b8faa11c9 (patch) | |
tree | 39528989c7a7b7839ad30baaa86441422676e212 /gui | |
parent | 5df3c14eba68e299d270e773194608808adaa1ae (diff) | |
download | scummvm-rg350-5c12e09ed1e2c2b83d74d824a941220b8faa11c9.tar.gz scummvm-rg350-5c12e09ed1e2c2b83d74d824a941220b8faa11c9.tar.bz2 scummvm-rg350-5c12e09ed1e2c2b83d74d824a941220b8faa11c9.zip |
GUI: Tab cycling handles multiple themes.
First visible tab moves up when a theme's width cannot fit another tab.
Diffstat (limited to 'gui')
-rw-r--r-- | gui/widgets/tab.cpp | 16 | ||||
-rw-r--r-- | gui/widgets/tab.h | 8 |
2 files changed, 14 insertions, 10 deletions
diff --git a/gui/widgets/tab.cpp b/gui/widgets/tab.cpp index 3ba6be8166..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(); } } @@ -227,28 +228,29 @@ 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(-kAheadTab); + adjustTabs(kTabBackwards); else if (state.keycode == Common::KEYCODE_TAB) - adjustTabs(kAheadTab); + adjustTabs(kTabForwards); return Widget::handleKeyDown(state); } void TabWidget::adjustTabs(int value) { - // determine which tab is next + // 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 - while (_firstVisibleTab < tabID - kMaxTabs) + // Slides _firstVisibleTab forward to the correct tab + int maxTabsOnScreen = (_w / _tabWidth); + if (tabID >= maxTabsOnScreen && (_firstVisibleTab + maxTabsOnScreen) < (int)_tabs.size()) _firstVisibleTab++; - // slide _firstVisibleTab backwards to the correct tab + // Slides _firstVisibleTab backwards to the correct tab while (tabID < _firstVisibleTab) - _firstVisibleTab--; + _firstVisibleTab--; setActiveTab(tabID); } diff --git a/gui/widgets/tab.h b/gui/widgets/tab.h index bf4176887c..a01ee2d9dc 100644 --- a/gui/widgets/tab.h +++ b/gui/widgets/tab.h @@ -28,6 +28,11 @@ #include "common/array.h" namespace GUI { + +enum { + kTabForwards = 1, + kTabBackwards = -1 +}; class TabWidget : public Widget { typedef Common::String String; @@ -38,9 +43,6 @@ class TabWidget : public Widget { typedef Common::Array<Tab> TabList; protected: - const int kMaxTabs = 5; - const int kAheadTab = 1; - int _activeTab; int _firstVisibleTab; TabList _tabs; |