aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorBastien Bouclet2019-09-08 14:55:58 +0200
committerBastien Bouclet2019-10-17 19:33:50 +0200
commit1dce33dd9f909b09a73902b3939b61a81a149b7a (patch)
treedfb909ebc52134143a7e1f7a82d6bdd2c2b5e671 /gui
parent9bc03dc117bcb65a7f0becca75df523dab03ee63 (diff)
downloadscummvm-rg350-1dce33dd9f909b09a73902b3939b61a81a149b7a.tar.gz
scummvm-rg350-1dce33dd9f909b09a73902b3939b61a81a149b7a.tar.bz2
scummvm-rg350-1dce33dd9f909b09a73902b3939b61a81a149b7a.zip
GUI: Fix launcher layout for small widths
* Testing if a widget can be centered was ignoring the padding. * Only resize a layout based on its content if it was not explicitely sized by its parent. Fixes the logo causing incorrect layout computations when the window width is lower than the image width.
Diffstat (limited to 'gui')
-rw-r--r--gui/ThemeLayout.cpp48
1 files changed, 32 insertions, 16 deletions
diff --git a/gui/ThemeLayout.cpp b/gui/ThemeLayout.cpp
index 71e4b2c9fd..4e3499b99e 100644
--- a/gui/ThemeLayout.cpp
+++ b/gui/ThemeLayout.cpp
@@ -202,18 +202,11 @@ void ThemeLayoutStacked::reflowLayoutVertical() {
_children[i]->offsetY(curY);
- // Center child if it this has been requested *and* the space permits it.
- if (_centered && _children[i]->getWidth() < _w && _w != -1) {
- _children[i]->offsetX((_w >> 1) - (_children[i]->getWidth() >> 1));
- } else
- _children[i]->offsetX(curX);
-
// Advance the vertical offset by the height of the newest item, plus
// the item spacing value.
curY += _children[i]->getHeight() + _spacing;
- // Update width and height of this stack layout
- _w = MAX(_w, (int16)(_children[i]->getWidth() + _padding.left + _padding.right));
+ // Update the height of this stack layout
_h += _children[i]->getHeight() + _spacing;
}
@@ -238,6 +231,21 @@ void ThemeLayoutStacked::reflowLayoutVertical() {
_children[j]->offsetY(newh);
}
}
+
+ // Set stack width from its children if it was not set by its parent
+ if (_w == -1) {
+ for (uint i = 0; i < _children.size(); ++i) {
+ _w = MAX(_w, (int16)(_children[i]->getWidth() + _padding.left + _padding.right));
+ }
+ }
+
+ for (uint i = 0; i < _children.size(); ++i) {
+ // Center child if it this has been requested *and* the space permits it.
+ if (_centered && _children[i]->getWidth() < (_w - _padding.left - _padding.right) && _w != -1) {
+ _children[i]->offsetX((_w >> 1) - (_children[i]->getWidth() >> 1));
+ } else
+ _children[i]->offsetX(curX);
+ }
}
void ThemeLayoutStacked::reflowLayoutHorizontal() {
@@ -265,19 +273,12 @@ void ThemeLayoutStacked::reflowLayoutHorizontal() {
_children[i]->offsetX(curX);
- // Center child if it this has been requested *and* the space permits it.
- if (_centered && _children[i]->getHeight() < _h && _h != -1)
- _children[i]->offsetY((_h >> 1) - (_children[i]->getHeight() >> 1));
- else
- _children[i]->offsetY(curY);
-
// Advance the horizontal offset by the width of the newest item, plus
// the item spacing value.
curX += (_children[i]->getWidth() + _spacing);
- // Update width and height of this stack layout
+ // Update the width of this stack layout
_w += _children[i]->getWidth() + _spacing;
- _h = MAX(_h, (int16)(_children[i]->getHeight() + _padding.top + _padding.bottom));
}
// If there are any children at all, then we added the spacing value once
@@ -301,6 +302,21 @@ void ThemeLayoutStacked::reflowLayoutHorizontal() {
_children[j]->offsetX(neww);
}
}
+
+ // Set stack height from its children if it was not set by its parent
+ if (_h == -1) {
+ for (uint i = 0; i < _children.size(); ++i) {
+ _h = MAX(_h, (int16)(_children[i]->getHeight() + _padding.top + _padding.bottom));
+ }
+ }
+
+ for (uint i = 0; i < _children.size(); ++i) {
+ // Center child if it this has been requested *and* the space permits it.
+ if (_centered && _children[i]->getHeight() < (_h - _padding.top - _padding.bottom) && _h != -1)
+ _children[i]->offsetY((_h >> 1) - (_children[i]->getHeight() >> 1));
+ else
+ _children[i]->offsetY(curY);
+ }
}
} // End of namespace GUI