diff options
| -rw-r--r-- | gui/ThemeLayout.cpp | 38 | ||||
| -rw-r--r-- | gui/ThemeLayout.h | 26 | 
2 files changed, 31 insertions, 33 deletions
| diff --git a/gui/ThemeLayout.cpp b/gui/ThemeLayout.cpp index 390b6e13ef..dc493168ff 100644 --- a/gui/ThemeLayout.cpp +++ b/gui/ThemeLayout.cpp @@ -70,15 +70,16 @@ bool ThemeLayout::getWidgetData(const Common::String &name, int16 &x, int16 &y,  	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 @@ int16 ThemeLayoutStacked::getParentW() {  	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 ThemeLayoutMain::reflowLayout() {  	}  } -void ThemeLayoutStacked::reflowLayoutV() { +void ThemeLayoutStacked::reflowLayoutVertical() {  	int curX, curY;  	int resize[8];  	int rescount = 0; @@ -171,7 +173,7 @@ void ThemeLayoutStacked::reflowLayoutV() {  		_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 @@ void ThemeLayoutStacked::reflowLayoutV() {  			_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 @@ void ThemeLayoutStacked::reflowLayoutV() {  	_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 @@ void ThemeLayoutStacked::reflowLayoutH() {  		_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 @@ void ThemeLayoutStacked::reflowLayoutH() {  			_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 @@ void ThemeLayoutStacked::reflowLayoutH() {  	_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);  		}  	}  } diff --git a/gui/ThemeLayout.h b/gui/ThemeLayout.h index c32fa44528..ac17e5744b 100644 --- a/gui/ThemeLayout.h +++ b/gui/ThemeLayout.h @@ -72,24 +72,20 @@ public:  		_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 @@ protected:  	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 @@ public:  	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 @@ public:  #endif  protected: -	int16 getParentW(); -	int16 getParentH(); +	int16 getParentWidth(); +	int16 getParentHeight();  	LayoutType getLayoutType() { return _type; } @@ -190,6 +185,7 @@ protected:  	}  	const LayoutType _type; +	int8 _spacing;  };  class ThemeLayoutWidget : public ThemeLayout { | 
