diff options
author | Vicent Marti | 2008-08-15 17:40:58 +0000 |
---|---|---|
committer | Vicent Marti | 2008-08-15 17:40:58 +0000 |
commit | 9aaf83df03276cc3428cd392dc6100a2bbe3579d (patch) | |
tree | b1872e37dbc6c363c425c01a1e8f692aa646806d /gui | |
parent | 9fc0a9b31e14092689a1c2a22eb5fc551416e87a (diff) | |
download | scummvm-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')
-rw-r--r-- | gui/ThemeEval.cpp | 74 | ||||
-rw-r--r-- | gui/newgui.cpp | 2 | ||||
-rw-r--r-- | gui/themes/default.inc | 18 | ||||
-rw-r--r-- | gui/themes/scummclassic.zip | bin | 40155 -> 40072 bytes | |||
-rw-r--r-- | gui/themes/scummclassic/classic_layout.stx | 7 | ||||
-rw-r--r-- | gui/themes/scummclassic/classic_layout_320.stx | 11 | ||||
-rw-r--r-- | gui/themes/scummodern.zip | bin | 122543 -> 122565 bytes | |||
-rw-r--r-- | gui/themes/scummodern/scummodern_layout_320.stx | 17 |
8 files changed, 47 insertions, 82 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() { diff --git a/gui/newgui.cpp b/gui/newgui.cpp index d90431503d..c49b3cdb8f 100644 --- a/gui/newgui.cpp +++ b/gui/newgui.cpp @@ -58,6 +58,8 @@ void GuiObject::reflowLayout() { if (!g_gui.xmlEval()->getWidgetData(_name, _x, _y, _w, _h)) { warning("Could not load widget position for '%s'", _name.c_str()); } + + return; if (_x < 0) error("Widget <%s> has x < 0: %d", _name.c_str(), _x); diff --git a/gui/themes/default.inc b/gui/themes/default.inc index 3462b928c8..fd948ab3fa 100644 --- a/gui/themes/default.inc +++ b/gui/themes/default.inc @@ -360,34 +360,27 @@ "<widget name = 'GameList'/> " "<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10'> " "<widget name = 'AddGameButton' " -"width = '190' " "height = '20' " "/> " "<widget name = 'EditGameButton' " -"width = '190' " "height = '20' " "/> " "<widget name = 'RemoveGameButton' " -"width = '190' " "height = '20' " "/> " "</layout> " "<space size = '12'/> " "<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10'> " "<widget name = 'QuitButton' " -"width = '140' " "height = '20' " "/> " "<widget name = 'AboutButton' " -"width = '140' " "height = '20' " "/> " "<widget name = 'OptionsButton' " -"width = '140' " "height = '20' " "/> " "<widget name = 'StartButton' " -"width = '140' " "height = '20' " "/> " "</layout> " @@ -904,34 +897,27 @@ "<widget name = 'GameList'/> " "<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10'> " "<widget name = 'AddGameButton' " -"width = '90' " "height = '12' " "/> " "<widget name = 'EditGameButton' " -"width = '90' " "height = '12' " "/> " "<widget name = 'RemoveGameButton' " -"width = '90' " "height = '12' " "/> " "</layout> " "<space size = '4'/> " "<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10'> " "<widget name = 'QuitButton' " -"width = '65' " "height = '12' " "/> " "<widget name = 'AboutButton' " -"width = '65' " "height = '12' " "/> " "<widget name = 'OptionsButton' " -"width = '65' " "height = '12' " "/> " "<widget name = 'StartButton' " -"width = '65' " "height = '12' " "/> " "</layout> " @@ -963,7 +949,7 @@ "<dialog name = 'GlobalOptions' overlays = 'screen' inset = '16' shading = 'dim'> " "<layout type = 'vertical' padding = '0, 0, 0, 0'> " "<widget name = 'TabWidget'/> " -"<layout type = 'horizontal' padding = '8, 8, 8, 2'> " +"<layout type = 'horizontal' padding = '8, 8, 8, 8'> " "<space/> " "<widget name = 'Cancel' " "type = 'Button' " @@ -1151,7 +1137,7 @@ "<dialog name = 'GameOptions' overlays = 'screen' inset = '16' shading = 'dim'> " "<layout type = 'vertical' padding = '0, 0, 0, 0' spacing = '16'> " "<widget name = 'TabWidget'/> " -"<layout type = 'horizontal' padding = '8, 8, 8, 2'> " +"<layout type = 'horizontal' padding = '8, 8, 8, 8'> " "<space/> " "<widget name = 'Cancel' " "type = 'Button' " diff --git a/gui/themes/scummclassic.zip b/gui/themes/scummclassic.zip Binary files differindex a8d9bf90e6..91704798b6 100644 --- a/gui/themes/scummclassic.zip +++ b/gui/themes/scummclassic.zip diff --git a/gui/themes/scummclassic/classic_layout.stx b/gui/themes/scummclassic/classic_layout.stx index 48c8c181ee..8be91e9de6 100644 --- a/gui/themes/scummclassic/classic_layout.stx +++ b/gui/themes/scummclassic/classic_layout.stx @@ -92,34 +92,27 @@ <widget name = 'GameList'/> <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10'> <widget name = 'AddGameButton' - width = '190' height = '20' /> <widget name = 'EditGameButton' - width = '190' height = '20' /> <widget name = 'RemoveGameButton' - width = '190' height = '20' /> </layout> <space size = '12'/> <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10'> <widget name = 'QuitButton' - width = '140' height = '20' /> <widget name = 'AboutButton' - width = '140' height = '20' /> <widget name = 'OptionsButton' - width = '140' height = '20' /> <widget name = 'StartButton' - width = '140' height = '20' /> </layout> diff --git a/gui/themes/scummclassic/classic_layout_320.stx b/gui/themes/scummclassic/classic_layout_320.stx index 9608fad7b8..0a9c84c71b 100644 --- a/gui/themes/scummclassic/classic_layout_320.stx +++ b/gui/themes/scummclassic/classic_layout_320.stx @@ -88,34 +88,27 @@ <widget name = 'GameList'/> <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10'> <widget name = 'AddGameButton' - width = '90' height = '12' /> <widget name = 'EditGameButton' - width = '90' height = '12' /> <widget name = 'RemoveGameButton' - width = '90' height = '12' /> </layout> <space size = '4'/> <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10'> <widget name = 'QuitButton' - width = '65' height = '12' /> <widget name = 'AboutButton' - width = '65' height = '12' /> <widget name = 'OptionsButton' - width = '65' height = '12' /> <widget name = 'StartButton' - width = '65' height = '12' /> </layout> @@ -150,7 +143,7 @@ <dialog name = 'GlobalOptions' overlays = 'screen' inset = '16' shading = 'dim'> <layout type = 'vertical' padding = '0, 0, 0, 0'> <widget name = 'TabWidget'/> - <layout type = 'horizontal' padding = '8, 8, 8, 2'> + <layout type = 'horizontal' padding = '8, 8, 8, 8'> <space/> <widget name = 'Cancel' type = 'Button' @@ -346,7 +339,7 @@ <dialog name = 'GameOptions' overlays = 'screen' inset = '16' shading = 'dim'> <layout type = 'vertical' padding = '0, 0, 0, 0' spacing = '16'> <widget name = 'TabWidget'/> - <layout type = 'horizontal' padding = '8, 8, 8, 2'> + <layout type = 'horizontal' padding = '8, 8, 8, 8'> <space/> <widget name = 'Cancel' type = 'Button' diff --git a/gui/themes/scummodern.zip b/gui/themes/scummodern.zip Binary files differindex 09fd31b8ab..8584433625 100644 --- a/gui/themes/scummodern.zip +++ b/gui/themes/scummodern.zip diff --git a/gui/themes/scummodern/scummodern_layout_320.stx b/gui/themes/scummodern/scummodern_layout_320.stx index 75dd08a753..e545f5f98d 100644 --- a/gui/themes/scummodern/scummodern_layout_320.stx +++ b/gui/themes/scummodern/scummodern_layout_320.stx @@ -79,37 +79,34 @@ </globals> <dialog name = 'Launcher' overlays = 'screen'> - <layout type = 'vertical' center = 'true' padding = '8, 8, 8, 8'> + <layout type = 'vertical' center = 'true' padding = '8, 8, 8, 4' spacing = '8'> <widget name = 'Version' height = 'Globals.Line.Height' /> <widget name = 'GameList'/> <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6'> <widget name = 'AddGameButton' - width = '95' height = 'Globals.Button.Height' /> <widget name = 'EditGameButton' - width = '95' height = 'Globals.Button.Height' /> <widget name = 'RemoveGameButton' - width = '95' height = 'Globals.Button.Height' /> </layout> <layout type = 'horizontal' padding = '0, 0, 0, 0'> <widget name = 'QuitButton' - type = 'Button' + height = 'Globals.Button.Height' /> <widget name = 'AboutButton' - type = 'Button' + height = 'Globals.Button.Height' /> <widget name = 'OptionsButton' - type = 'Button' + height = 'Globals.Button.Height' /> <widget name = 'StartButton' - type = 'Button' + height = 'Globals.Button.Height' /> </layout> </layout> @@ -143,7 +140,7 @@ <dialog name = 'GlobalOptions' overlays = 'screen' inset = '16' shading = 'dim'> <layout type = 'vertical' padding = '0, 0, 0, 0'> <widget name = 'TabWidget'/> - <layout type = 'horizontal' padding = '8, 8, 8, 2'> + <layout type = 'horizontal' padding = '8, 8, 8, 8'> <space/> <widget name = 'Cancel' type = 'Button' @@ -339,7 +336,7 @@ <dialog name = 'GameOptions' overlays = 'screen' inset = '16' shading = 'dim'> <layout type = 'vertical' padding = '0, 0, 0, 0' spacing = '16'> <widget name = 'TabWidget'/> - <layout type = 'horizontal' padding = '8, 8, 8, 2'> + <layout type = 'horizontal' padding = '8, 8, 8, 8'> <space/> <widget name = 'Cancel' type = 'Button' |