aboutsummaryrefslogtreecommitdiff
path: root/gui/ThemeEngine.cpp
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2017-02-26 18:34:02 +0100
committerWillem Jan Palenstijn2017-02-28 15:55:52 +0100
commit5510640dbcd1bda6ae41942ed56c9ac037fc5228 (patch)
treebca82176d700bce72a948f046bc4acb43a740d98 /gui/ThemeEngine.cpp
parentaf831f26b97590024218801528f50e008f3b2f72 (diff)
downloadscummvm-rg350-5510640dbcd1bda6ae41942ed56c9ac037fc5228.tar.gz
scummvm-rg350-5510640dbcd1bda6ae41942ed56c9ac037fc5228.tar.bz2
scummvm-rg350-5510640dbcd1bda6ae41942ed56c9ac037fc5228.zip
GUI: Give each tab in TabWidget its own width
The width of each tab is now computed from its title, independently of the other tabs. This increases the number of tabs that fit on the screen. This rewrite also fixes a bug where if the window size increased while _firstVisibleTab > 0, some tabs would become inaccessible when the scroll buttons were hidden. The layout key Globals.TabWidget.Tab.Width is now treated as minimal tab width. This is set so that the tabs fit reasonably well in lowres layouts. At the same time, this reduces the lowres scroll buttons heights to fit. This patch makes the Nintento DS hacks in TabWidget obsolete. (Hopefully! I'm not able to test.)
Diffstat (limited to 'gui/ThemeEngine.cpp')
-rw-r--r--gui/ThemeEngine.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index d859a88da5..64b25d85f6 100644
--- a/gui/ThemeEngine.cpp
+++ b/gui/ThemeEngine.cpp
@@ -1620,28 +1620,34 @@ void ThemeEngine::drawTab(const Common::Rect &r, int tabHeight, int tabWidth, co
}
}
-void ThemeEngine::drawTabClip(const Common::Rect &r, const Common::Rect &clip, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, WidgetStateInfo state) {
+void ThemeEngine::drawTabClip(const Common::Rect &r, const Common::Rect &clip, int tabHeight, const Common::Array<int> &tabWidths, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, WidgetStateInfo state) {
if (!ready())
return;
+ assert(tabs.size() == tabWidths.size());
+
queueDDClip(kDDTabBackground, Common::Rect(r.left, r.top, r.right, r.top + tabHeight), clip);
- for (int i = 0; i < (int)tabs.size(); ++i) {
- if (i == active)
+ int width = 0;
+ int activePos = -1;
+ for (int i = 0; i < (int)tabs.size(); width += tabWidths[i++]) {
+ if (r.left + width > r.right || r.left + width + tabWidths[i] > r.right)
continue;
- if (r.left + i * tabWidth > r.right || r.left + (i + 1) * tabWidth > r.right)
+ if (i == active) {
+ activePos = width;
continue;
+ }
- Common::Rect tabRect(r.left + i * tabWidth, r.top, r.left + (i + 1) * tabWidth, r.top + tabHeight);
+
+ Common::Rect tabRect(r.left + width, r.top, r.left + width + tabWidths[i], r.top + tabHeight);
queueDDClip(kDDTabInactive, tabRect, clip);
queueDDTextClip(getTextData(kDDTabInactive), getTextColor(kDDTabInactive), tabRect, clip, tabs[i], false, false, _widgets[kDDTabInactive]->_textAlignH, _widgets[kDDTabInactive]->_textAlignV);
}
- if (active >= 0 &&
- (r.left + active * tabWidth < r.right) && (r.left + (active + 1) * tabWidth < r.right)) {
- Common::Rect tabRect(r.left + active * tabWidth, r.top, r.left + (active + 1) * tabWidth, r.top + tabHeight);
- const uint16 tabLeft = active * tabWidth;
+ if (activePos >= 0) {
+ Common::Rect tabRect(r.left + activePos, r.top, r.left + activePos + tabWidths[active], r.top + tabHeight);
+ const uint16 tabLeft = activePos;
const uint16 tabRight = MAX(r.right - tabRect.right, 0);
queueDDClip(kDDTabActive, tabRect, clip, (tabLeft << 16) | (tabRight & 0xFFFF));
queueDDTextClip(getTextData(kDDTabActive), getTextColor(kDDTabActive), tabRect, clip, tabs[active], false, false, _widgets[kDDTabActive]->_textAlignH, _widgets[kDDTabActive]->_textAlignV);