[Scummvm-cvs-logs] SF.net SVN: scummvm:[35571] scummvm/trunk/gui
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Sat Dec 27 15:30:30 CET 2008
Revision: 35571
http://scummvm.svn.sourceforge.net/scummvm/?rev=35571&view=rev
Author: fingolfin
Date: 2008-12-27 14:30:30 +0000 (Sat, 27 Dec 2008)
Log Message:
-----------
Got rid of ThemeLayout::getDialogData; added some comments, asserts; moved getParentW & getParentH to class ThemeLayoutStacked
Modified Paths:
--------------
scummvm/trunk/gui/ThemeEval.cpp
scummvm/trunk/gui/ThemeLayout.cpp
scummvm/trunk/gui/ThemeLayout.h
Modified: scummvm/trunk/gui/ThemeEval.cpp
===================================================================
--- scummvm/trunk/gui/ThemeEval.cpp 2008-12-27 07:17:46 UTC (rev 35570)
+++ scummvm/trunk/gui/ThemeEval.cpp 2008-12-27 14:30:30 UTC (rev 35571)
@@ -63,9 +63,6 @@
if (!_layouts.contains(dialogName))
return false;
- if (widgetName.empty())
- return _layouts[dialogName]->getDialogData(x, y, w, h);
-
return _layouts[dialogName]->getWidgetData(widgetName, x, y, w, h);
}
Modified: scummvm/trunk/gui/ThemeLayout.cpp
===================================================================
--- scummvm/trunk/gui/ThemeLayout.cpp 2008-12-27 07:17:46 UTC (rev 35570)
+++ scummvm/trunk/gui/ThemeLayout.cpp 2008-12-27 14:30:30 UTC (rev 35571)
@@ -55,6 +55,13 @@
}
bool ThemeLayout::getWidgetData(const Common::String &name, int16 &x, int16 &y, uint16 &w, uint16 &h) {
+ if (name.empty()) {
+ assert(getLayoutType() == kLayoutMain);
+ x = _x; y = _y;
+ w = _w; h = _h;
+ return true;
+ }
+
for (uint i = 0; i < _children.size(); ++i) {
if (_children[i]->getWidgetData(name, x, y, w, h))
return true;
@@ -63,7 +70,7 @@
return false;
}
-int16 ThemeLayout::getParentW() {
+int16 ThemeLayoutStacked::getParentW() {
ThemeLayout *p = _parent;
int width = 0;
@@ -73,13 +80,16 @@
for (uint i = 0; i < p->_children.size(); ++i)
width += p->_children[i]->getWidth() + p->_spacing;
}
+ // FIXME: Do we really want to assume that any layout type different
+ // from kLayoutHorizontal corresponds to width 0 ?
p = p->_parent;
}
+ assert(p && p->getLayoutType() == kLayoutMain);
return p->getWidth() - width;
}
-int16 ThemeLayout::getParentH() {
+int16 ThemeLayoutStacked::getParentH() {
ThemeLayout *p = _parent;
int height = 0;
@@ -89,9 +99,12 @@
for (uint i = 0; i < p->_children.size(); ++i)
height += p->_children[i]->getHeight() + p->_spacing;
}
+ // FIXME: Do we really want to assume that any layout type different
+ // from kLayoutVertical corresponds to height 0 ?
p = p->_parent;
}
+ assert(p && p->getLayoutType() == kLayoutMain);
return p->getHeight() - height;
}
@@ -168,6 +181,7 @@
_children[i]->setY(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));
} else
@@ -217,6 +231,7 @@
_children[i]->setX(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));
else
Modified: scummvm/trunk/gui/ThemeLayout.h
===================================================================
--- scummvm/trunk/gui/ThemeLayout.h 2008-12-27 07:17:46 UTC (rev 35570)
+++ scummvm/trunk/gui/ThemeLayout.h 2008-12-27 14:30:30 UTC (rev 35571)
@@ -77,8 +77,6 @@
}
protected:
- int16 getParentW();
- int16 getParentH();
int16 getWidth() { return _w; }
int16 getHeight() { return _h; }
@@ -104,13 +102,6 @@
public:
virtual bool getWidgetData(const Common::String &name, int16 &x, int16 &y, uint16 &w, uint16 &h);
- virtual bool getDialogData(int16 &x, int16 &y, uint16 &w, uint16 &h) {
- assert(getLayoutType() == kLayoutMain);
- x = _x; y = _y;
- w = _w; h = _h;
- return true;
- }
-
void importLayout(ThemeLayout *layout);
#ifdef LAYOUT_DEBUG_DIALOG
@@ -148,11 +139,11 @@
#ifdef LAYOUT_DEBUG_DIALOG
const char *getName() const { return "Global Layout"; }
#endif
- LayoutType getLayoutType() { return kLayoutMain; }
+protected:
+ LayoutType getLayoutType() { return kLayoutMain; }
ThemeLayout *makeClone(ThemeLayout *newParent) { assert(!"Do not copy Main Layouts!"); return 0; }
-protected:
int16 _defaultX;
int16 _defaultY;
};
@@ -182,6 +173,10 @@
}
#endif
+protected:
+ int16 getParentW();
+ int16 getParentH();
+
LayoutType getLayoutType() { return _type; }
ThemeLayout *makeClone(ThemeLayout *newParent) {
@@ -194,7 +189,6 @@
return n;
}
-protected:
const LayoutType _type;
};
@@ -207,9 +201,12 @@
bool getWidgetData(const Common::String &name, int16 &x, int16 &y, uint16 &w, uint16 &h);
void reflowLayout() {}
+
#ifdef LAYOUT_DEBUG_DIALOG
virtual const char *getName() const { return _name.c_str(); }
#endif
+
+protected:
LayoutType getLayoutType() { return kLayoutWidget; }
ThemeLayout *makeClone(ThemeLayout *newParent) {
@@ -218,7 +215,6 @@
return n;
}
-protected:
Common::String _name;
};
@@ -236,11 +232,13 @@
bool getWidgetData(const Common::String &name, int16 &x, int16 &y, uint16 &w, uint16 &h) { return false; }
void reflowLayout() {}
- LayoutType getLayoutType() { return kLayoutWidget; }
#ifdef LAYOUT_DEBUG_DIALOG
const char *getName() const { return "SPACE"; }
#endif
+protected:
+ LayoutType getLayoutType() { return kLayoutWidget; }
+
ThemeLayout *makeClone(ThemeLayout *newParent) {
ThemeLayout *n = new ThemeLayoutSpacing(*this);
n->_parent = newParent;
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