[Scummvm-cvs-logs] scummvm master -> 09bbcced02f62c7805891a305851182ce1128077

sev- sev at scummvm.org
Mon Apr 28 19:50:52 CEST 2014


This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
80d34a8a7c GUI: Add Tab cycling to  TabWidget
5df3c14eba GUI: Fix tab cycling when total tabs increase.
5c12e09ed1 GUI: Tab cycling handles multiple themes.
09bbcced02 Merge pull request #455 from Zerophase/master


Commit: 80d34a8a7cc6960006bc90f80686c2241f60226f
    https://github.com/scummvm/scummvm/commit/80d34a8a7cc6960006bc90f80686c2241f60226f
Author: Zerophase (mikelojkovic at gmail.com)
Date: 2014-04-01T07:28:48-05:00

Commit Message:
GUI: Add Tab cycling to  TabWidget

Tab and Shift-Tab can now cycle between each Tab of the Edit Game menu.

Changed paths:
    gui/dialog.cpp
    gui/widgets/tab.cpp
    gui/widgets/tab.h



diff --git a/gui/dialog.cpp b/gui/dialog.cpp
index ec392a8..fa4e508 100644
--- a/gui/dialog.cpp
+++ b/gui/dialog.cpp
@@ -250,7 +250,18 @@ void Dialog::handleKeyDown(Common::KeyState state) {
 		close();
 	}
 
-	// TODO: tab/shift-tab should focus the next/previous focusable widget
+	if (state.keycode == Common::KEYCODE_TAB) {
+		// TODO: Maybe add Tab behaviours for all widgets too.
+		// searches through widgets on screen for tab widget
+		Widget *w = _firstWidget;
+		while (w) {
+			if (w->_type == kTabWidget)
+				if (w->handleKeyDown(state))
+					return;
+
+			w = w->_next;
+		}
+	}
 }
 
 void Dialog::handleKeyUp(Common::KeyState state) {
diff --git a/gui/widgets/tab.cpp b/gui/widgets/tab.cpp
index a8b3f54..87c6b65 100644
--- a/gui/widgets/tab.cpp
+++ b/gui/widgets/tab.cpp
@@ -226,12 +226,33 @@ 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(-1);
+	else if (state.keycode == Common::KEYCODE_TAB)
+		adjustTabs(1);
+
 	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);
+
+	// If tabbing moves the last tab out of sight slide tabs over
+	if ((tabID * _tabWidth) > (_w - getAbsX()))
+		_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);
+}
+
 void TabWidget::reflowLayout() {
 	Widget::reflowLayout();
 
diff --git a/gui/widgets/tab.h b/gui/widgets/tab.h
index 38aa089..08f29f9 100644
--- a/gui/widgets/tab.h
+++ b/gui/widgets/tab.h
@@ -109,6 +109,8 @@ protected:
 	virtual void drawWidget();
 
 	virtual Widget *findWidget(int x, int y);
+
+	virtual void adjustTabs(int value);
 };
 
 } // End of namespace GUI


Commit: 5df3c14eba68e299d270e773194608808adaa1ae
    https://github.com/scummvm/scummvm/commit/5df3c14eba68e299d270e773194608808adaa1ae
Author: Zerophase (mikelojkovic at gmail.com)
Date: 2014-04-01T07:28:57-05:00

Commit Message:
GUI: Fix tab cycling when total tabs increase.

Tab cycling ignores tab width, and slides correctly for larger tab counts.

Changed paths:
    gui/widgets/tab.cpp
    gui/widgets/tab.h



diff --git a/gui/widgets/tab.cpp b/gui/widgets/tab.cpp
index 87c6b65..3ba6be8 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 08f29f9..bf41768 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;


Commit: 5c12e09ed1e2c2b83d74d824a941220b8faa11c9
    https://github.com/scummvm/scummvm/commit/5c12e09ed1e2c2b83d74d824a941220b8faa11c9
Author: Zerophase (mikelojkovic at gmail.com)
Date: 2014-04-06T19:58:56-05:00

Commit Message:
GUI: Tab cycling handles multiple themes.

First visible tab moves up when a theme's width cannot fit another tab.

Changed paths:
    gui/widgets/tab.cpp
    gui/widgets/tab.h



diff --git a/gui/widgets/tab.cpp b/gui/widgets/tab.cpp
index 3ba6be8..756781a 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 bf41768..a01ee2d 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;


Commit: 09bbcced02f62c7805891a305851182ce1128077
    https://github.com/scummvm/scummvm/commit/09bbcced02f62c7805891a305851182ce1128077
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2014-04-28T20:50:12+03:00

Commit Message:
Merge pull request #455 from Zerophase/master

GUI: Add Tab cycling to  TabWidget

Changed paths:
    gui/dialog.cpp
    gui/widgets/tab.cpp
    gui/widgets/tab.h









More information about the Scummvm-git-logs mailing list