diff --git a/gui/widgets/tab.cpp b/gui/widgets/tab.cpp index 3ba6be81667..756781a04bf 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 bf4176887ce..a01ee2d9dca 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 TabList; protected: - const int kMaxTabs = 5; - const int kAheadTab = 1; - int _activeTab; int _firstVisibleTab; TabList _tabs;