[Scummvm-cvs-logs] SF.net SVN: scummvm:[33906] scummvm/branches/gsoc2008-gui/gui

Tanoku at users.sourceforge.net Tanoku at users.sourceforge.net
Fri Aug 15 19:40:59 CEST 2008


Revision: 33906
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33906&view=rev
Author:   Tanoku
Date:     2008-08-15 17:40:58 +0000 (Fri, 15 Aug 2008)

Log Message:
-----------
Added support for automatically resizing more than one widget in a flowing layout. Classic theme launcher now looks ok in g3x.

Modified Paths:
--------------
    scummvm/branches/gsoc2008-gui/gui/ThemeEval.cpp
    scummvm/branches/gsoc2008-gui/gui/newgui.cpp
    scummvm/branches/gsoc2008-gui/gui/themes/default.inc
    scummvm/branches/gsoc2008-gui/gui/themes/scummclassic/classic_layout.stx
    scummvm/branches/gsoc2008-gui/gui/themes/scummclassic/classic_layout_320.stx
    scummvm/branches/gsoc2008-gui/gui/themes/scummclassic.zip
    scummvm/branches/gsoc2008-gui/gui/themes/scummodern/scummodern_layout_320.stx
    scummvm/branches/gsoc2008-gui/gui/themes/scummodern.zip

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeEval.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeEval.cpp	2008-08-15 16:47:03 UTC (rev 33905)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeEval.cpp	2008-08-15 17:40:58 UTC (rev 33906)
@@ -81,8 +81,8 @@
 
 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 @@
 			_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 @@
 			_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 @@
 			_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() {

Modified: scummvm/branches/gsoc2008-gui/gui/newgui.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/newgui.cpp	2008-08-15 16:47:03 UTC (rev 33905)
+++ scummvm/branches/gsoc2008-gui/gui/newgui.cpp	2008-08-15 17:40:58 UTC (rev 33906)
@@ -58,6 +58,8 @@
 		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);

Modified: scummvm/branches/gsoc2008-gui/gui/themes/default.inc
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/themes/default.inc	2008-08-15 16:47:03 UTC (rev 33905)
+++ scummvm/branches/gsoc2008-gui/gui/themes/default.inc	2008-08-15 17:40:58 UTC (rev 33906)
@@ -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' "

Modified: scummvm/branches/gsoc2008-gui/gui/themes/scummclassic/classic_layout.stx
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/themes/scummclassic/classic_layout.stx	2008-08-15 16:47:03 UTC (rev 33905)
+++ scummvm/branches/gsoc2008-gui/gui/themes/scummclassic/classic_layout.stx	2008-08-15 17:40:58 UTC (rev 33906)
@@ -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>

Modified: scummvm/branches/gsoc2008-gui/gui/themes/scummclassic/classic_layout_320.stx
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/themes/scummclassic/classic_layout_320.stx	2008-08-15 16:47:03 UTC (rev 33905)
+++ scummvm/branches/gsoc2008-gui/gui/themes/scummclassic/classic_layout_320.stx	2008-08-15 17:40:58 UTC (rev 33906)
@@ -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'

Modified: scummvm/branches/gsoc2008-gui/gui/themes/scummodern/scummodern_layout_320.stx
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/themes/scummodern/scummodern_layout_320.stx	2008-08-15 16:47:03 UTC (rev 33905)
+++ scummvm/branches/gsoc2008-gui/gui/themes/scummodern/scummodern_layout_320.stx	2008-08-15 17:40:58 UTC (rev 33906)
@@ -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'


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list