aboutsummaryrefslogtreecommitdiff
path: root/gui/widgets/tab.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gui/widgets/tab.cpp')
-rw-r--r--gui/widgets/tab.cpp30
1 files changed, 27 insertions, 3 deletions
diff --git a/gui/widgets/tab.cpp b/gui/widgets/tab.cpp
index 66f33907ca..756781a04b 100644
--- a/gui/widgets/tab.cpp
+++ b/gui/widgets/tab.cpp
@@ -17,6 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
*/
#include "common/util.h"
@@ -182,6 +183,7 @@ void TabWidget::setActiveTab(int tabID) {
}
_activeTab = tabID;
_firstWidget = _tabs[tabID].firstWidget;
+
_boss->draw();
}
}
@@ -225,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();