aboutsummaryrefslogtreecommitdiff
path: root/gui/ThemeEval.cpp
diff options
context:
space:
mode:
authorVicent Marti2008-08-15 17:40:58 +0000
committerVicent Marti2008-08-15 17:40:58 +0000
commit9aaf83df03276cc3428cd392dc6100a2bbe3579d (patch)
treeb1872e37dbc6c363c425c01a1e8f692aa646806d /gui/ThemeEval.cpp
parent9fc0a9b31e14092689a1c2a22eb5fc551416e87a (diff)
downloadscummvm-rg350-9aaf83df03276cc3428cd392dc6100a2bbe3579d.tar.gz
scummvm-rg350-9aaf83df03276cc3428cd392dc6100a2bbe3579d.tar.bz2
scummvm-rg350-9aaf83df03276cc3428cd392dc6100a2bbe3579d.zip
Added support for automatically resizing more than one widget in a flowing layout. Classic theme launcher now looks ok in g3x.
svn-id: r33906
Diffstat (limited to 'gui/ThemeEval.cpp')
-rw-r--r--gui/ThemeEval.cpp74
1 files changed, 34 insertions, 40 deletions
diff --git a/gui/ThemeEval.cpp b/gui/ThemeEval.cpp
index ecf48e71b4..614f2089d1 100644
--- a/gui/ThemeEval.cpp
+++ b/gui/ThemeEval.cpp
@@ -81,8 +81,8 @@ void ThemeLayoutMain::reflowLayout() {
void ThemeLayoutVertical::reflowLayout() {
int curX, curY;
- int autoWidget = -1;
- int extraHeight = 0;
+ int resize[8];
+ int rescount = 0;
curX = _paddingLeft;
curY = _paddingTop;
@@ -97,43 +97,41 @@ void ThemeLayoutVertical::reflowLayout() {
_children[i]->setWidth((_w == -1 ? getParentW() : _w) - _paddingLeft - _paddingRight);
if (_children[i]->getHeight() == -1) {
- if (autoWidget != -1)
- error("Cannot expand automatically two different widgets.");
-
- autoWidget = i;
- _children[i]->setHeight(getParentH() - _h - _spacing);
+ resize[rescount++] = i;
+ _children[i]->setHeight(0);
}
_children[i]->setY(curY);
- if (_centered && _children[i]->getWidth() < _w && _w != -1)
+ if (_centered && _children[i]->getWidth() < _w && _w != -1) {
_children[i]->setX((_w >> 1) - (_children[i]->getWidth() >> 1));
+ }
else
_children[i]->setX(curX);
curY += _children[i]->getHeight() + _spacing;
_w = MAX(_w, (int16)(_children[i]->getWidth() + _paddingLeft + _paddingRight));
-
- if (autoWidget != -1 && autoWidget != (int)i) {
- _children[autoWidget]->setHeight(_children[autoWidget]->getHeight() - (_children[i]->getHeight() + _spacing));
-
- extraHeight -= (_children[i]->getHeight() + _spacing);
- _children[i]->setY(extraHeight);
-
- for (int j = i - 1; j > autoWidget; --j)
- _children[j]->setY(-(_children[i]->getHeight() + _spacing));
- } else {
- _h += _children[i]->getHeight() + _spacing;
- }
+ _h += _children[i]->getHeight() + _spacing;
}
_h -= _spacing;
+
+ if (rescount) {
+ int newh = (getParentH() - _h - _paddingBottom) / rescount;
+
+ for (int i = 0; i < rescount; ++i) {
+ _children[resize[i]]->setHeight(newh);
+ _h += newh;
+ for (uint j = resize[i] + 1; j < _children.size(); ++j)
+ _children[j]->setY(newh);
+ }
+ }
}
void ThemeLayoutHorizontal::reflowLayout() {
int curX, curY;
- int autoWidget = -1;
- int autoWidth = 0;
+ int resize[8];
+ int rescount = 0;
curX = _paddingLeft;
curY = _paddingTop;
@@ -148,11 +146,8 @@ void ThemeLayoutHorizontal::reflowLayout() {
_children[i]->setHeight((_h == -1 ? getParentH() : _h) - _paddingTop - _paddingBottom);
if (_children[i]->getWidth() == -1) {
- if (autoWidget != -1)
- error("Cannot expand automatically two different widgets.");
-
- autoWidget = i;
- _children[i]->setWidth(getParentW() - _w - _spacing);
+ resize[rescount++] = i;
+ _children[i]->setWidth(0);
}
_children[i]->setX(curX);
@@ -163,23 +158,22 @@ void ThemeLayoutHorizontal::reflowLayout() {
_children[i]->setY(curY);
curX += (_children[i]->getWidth() + _spacing);
-
- if (autoWidget != -1 && autoWidget != (int)i) {
- _children[autoWidget]->setWidth(_children[autoWidget]->getWidth() - (_children[i]->getWidth() + _spacing));
-
- autoWidth -= (_children[i]->getWidth() + _spacing);
- _children[i]->setX(autoWidth);
-
- for (int j = i - 1; j > autoWidget; --j)
- _children[j]->setX(-(_children[i]->getWidth() + _spacing));
- } else {
- _w += _children[i]->getWidth() + _spacing;
- }
-
+ _w += _children[i]->getWidth() + _spacing;
_h = MAX(_h, (int16)(_children[i]->getHeight() + _paddingTop + _paddingBottom));
}
_w -= _spacing;
+
+ if (rescount) {
+ int neww = (getParentW() - _w - _paddingRight) / rescount;
+
+ for (int i = 0; i < rescount; ++i) {
+ _children[resize[i]]->setWidth(neww);
+ _w += neww;
+ for (uint j = resize[i] + 1; j < _children.size(); ++j)
+ _children[j]->setX(neww);
+ }
+ }
}
ThemeEval::~ThemeEval() {