[Scummvm-cvs-logs] SF.net SVN: scummvm:[35867] scummvm/trunk/gui

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Wed Jan 14 21:58:41 CET 2009


Revision: 35867
          http://scummvm.svn.sourceforge.net/scummvm/?rev=35867&view=rev
Author:   fingolfin
Date:     2009-01-14 20:58:41 +0000 (Wed, 14 Jan 2009)

Log Message:
-----------
Renamed various ThemeLayout methods for clarity; removed unused setSpacing method, and moved _spacing to class ThemeLayoutStacked

Modified Paths:
--------------
    scummvm/trunk/gui/ThemeLayout.cpp
    scummvm/trunk/gui/ThemeLayout.h

Modified: scummvm/trunk/gui/ThemeLayout.cpp
===================================================================
--- scummvm/trunk/gui/ThemeLayout.cpp	2009-01-14 19:07:24 UTC (rev 35866)
+++ scummvm/trunk/gui/ThemeLayout.cpp	2009-01-14 20:58:41 UTC (rev 35867)
@@ -70,15 +70,16 @@
 	return false;
 }
 
-int16 ThemeLayoutStacked::getParentW() {
+int16 ThemeLayoutStacked::getParentWidth() {
 	ThemeLayout *p = _parent;
 	int width = 0;
 
 	while (p && p->getLayoutType() != kLayoutMain) {
 		width += p->_padding.right + p->_padding.left;
 		if (p->getLayoutType() == kLayoutHorizontal) {
+			const int spacing = ((ThemeLayoutStacked *)p)->_spacing;
 			for (uint i = 0; i < p->_children.size(); ++i)
-				width += p->_children[i]->getWidth() + p->_spacing;
+				width += p->_children[i]->getWidth() + spacing;
 		}
 		// FIXME: Do we really want to assume that any layout type different
 		// from kLayoutHorizontal corresponds to width 0 ?
@@ -89,15 +90,16 @@
 	return p->getWidth() - width;
 }
 
-int16 ThemeLayoutStacked::getParentH() {
+int16 ThemeLayoutStacked::getParentHeight() {
 	ThemeLayout *p = _parent;
 	int height = 0;
 
 	while (p && p->getLayoutType() != kLayoutMain) {
 		height += p->_padding.bottom + p->_padding.top;
 		if (p->getLayoutType() == kLayoutVertical) {
+			const int spacing = ((ThemeLayoutStacked *)p)->_spacing;
 			for (uint i = 0; i < p->_children.size(); ++i)
-				height += p->_children[i]->getHeight() + p->_spacing;
+				height += p->_children[i]->getHeight() + spacing;
 		}
 		// FIXME: Do we really want to assume that any layout type different
 		// from kLayoutVertical corresponds to height 0 ?
@@ -156,7 +158,7 @@
 	}
 }
 
-void ThemeLayoutStacked::reflowLayoutV() {
+void ThemeLayoutStacked::reflowLayoutVertical() {
 	int curX, curY;
 	int resize[8];
 	int rescount = 0;
@@ -171,7 +173,7 @@
 		_children[i]->reflowLayout();
 
 		if (_children[i]->getWidth() == -1)
-			_children[i]->setWidth((_w == -1 ? getParentW() : _w) - _padding.left - _padding.right);
+			_children[i]->setWidth((_w == -1 ? getParentWidth() : _w) - _padding.left - _padding.right);
 
 		if (_children[i]->getHeight() == -1) {
 			assert(rescount < ARRAYSIZE(resize));
@@ -179,13 +181,13 @@
 			_children[i]->setHeight(0);
 		}
 
-		_children[i]->setY(curY);
+		_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]->setX((_w >> 1) - (_children[i]->getWidth() >> 1));
+			_children[i]->offsetX((_w >> 1) - (_children[i]->getWidth() >> 1));
 		} else
-			_children[i]->setX(curX);
+			_children[i]->offsetX(curX);
 
 		curY += _children[i]->getHeight() + _spacing;
 		_w = MAX(_w, (int16)(_children[i]->getWidth() + _padding.left + _padding.right));
@@ -195,18 +197,18 @@
 	_h -= _spacing;
 
 	if (rescount) {
-		int newh = (getParentH() - _h - _padding.bottom) / rescount;
+		int newh = (getParentHeight() - _h - _padding.bottom) / 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);
+				_children[j]->offsetY(newh);
 		}
 	}
 }
 
-void ThemeLayoutStacked::reflowLayoutH() {
+void ThemeLayoutStacked::reflowLayoutHorizontal() {
 	int curX, curY;
 	int resize[8];
 	int rescount = 0;
@@ -221,7 +223,7 @@
 		_children[i]->reflowLayout();
 
 		if (_children[i]->getHeight() == -1)
-			_children[i]->setHeight((_h == -1 ? getParentH() : _h) - _padding.top - _padding.bottom);
+			_children[i]->setHeight((_h == -1 ? getParentHeight() : _h) - _padding.top - _padding.bottom);
 
 		if (_children[i]->getWidth() == -1) {
 			assert(rescount < ARRAYSIZE(resize));
@@ -229,13 +231,13 @@
 			_children[i]->setWidth(0);
 		}
 
-		_children[i]->setX(curX);
+		_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]->setY((_h >> 1) - (_children[i]->getHeight() >> 1));
+			_children[i]->offsetY((_h >> 1) - (_children[i]->getHeight() >> 1));
 		else
-			_children[i]->setY(curY);
+			_children[i]->offsetY(curY);
 
 		curX += (_children[i]->getWidth() + _spacing);
 		_w += _children[i]->getWidth() + _spacing;
@@ -245,13 +247,13 @@
 	_w -= _spacing;
 
 	if (rescount) {
-		int neww = (getParentW() - _w - _padding.right) / rescount;
+		int neww = (getParentWidth() - _w - _padding.right) / 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);
+				_children[j]->offsetX(neww);
 		}
 	}
 }

Modified: scummvm/trunk/gui/ThemeLayout.h
===================================================================
--- scummvm/trunk/gui/ThemeLayout.h	2009-01-14 19:07:24 UTC (rev 35866)
+++ scummvm/trunk/gui/ThemeLayout.h	2009-01-14 20:58:41 UTC (rev 35867)
@@ -72,24 +72,20 @@
 		_padding.bottom = bottom;
 	}
 
-	void setSpacing(int8 spacing) {
-		_spacing = spacing;
-	}
-
 protected:
 	int16 getWidth() { return _w; }
 	int16 getHeight() { return _h; }
 
-	void setX(int newX) {
+	void offsetX(int newX) {
 		_x += newX;
 		for (uint i = 0; i < _children.size(); ++i)
-			_children[i]->setX(newX);
+			_children[i]->offsetX(newX);
 	}
 
-	void setY(int newY) {
+	void offsetY(int newY) {
 		_y += newY;
 		for (uint i = 0; i < _children.size(); ++i)
-			_children[i]->setY(newY);
+			_children[i]->offsetY(newY);
 	}
 
 	void setWidth(int16 width) { _w = width; }
@@ -114,7 +110,6 @@
 	ThemeLayout *_parent;
 	int16 _x, _y, _w, _h;
 	Common::Rect _padding;
-	int8 _spacing;
 	Common::Array<ThemeLayout *> _children;
 	bool _centered;
 	int16 _defaultW, _defaultH;
@@ -159,12 +154,12 @@
 
 	void reflowLayout() {
 		if (_type == kLayoutVertical)
-			reflowLayoutV();
+			reflowLayoutVertical();
 		else
-			reflowLayoutH();
+			reflowLayoutHorizontal();
 	}
-	void reflowLayoutH();
-	void reflowLayoutV();
+	void reflowLayoutHorizontal();
+	void reflowLayoutVertical();
 
 #ifdef LAYOUT_DEBUG_DIALOG
 	const char *getName() const {
@@ -174,8 +169,8 @@
 #endif
 
 protected:
-	int16 getParentW();
-	int16 getParentH();
+	int16 getParentWidth();
+	int16 getParentHeight();
 
 	LayoutType getLayoutType() { return _type; }
 
@@ -190,6 +185,7 @@
 	}
 
 	const LayoutType _type;
+	int8 _spacing;
 };
 
 class ThemeLayoutWidget : public ThemeLayout {


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