aboutsummaryrefslogtreecommitdiff
path: root/gui/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'gui/widgets')
-rw-r--r--gui/widgets/tab.cpp18
-rw-r--r--gui/widgets/tab.h3
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;