aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
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