diff options
author | Max Horn | 2008-12-27 14:30:30 +0000 |
---|---|---|
committer | Max Horn | 2008-12-27 14:30:30 +0000 |
commit | 69f4b7a38388c444d2911d07a3636a65dd1a4d20 (patch) | |
tree | 30226f3b0bc736fdb8dbd4f87e5fb5d6960080c0 | |
parent | 109d55f8d331ec8d70442d20eccc7046c8901b27 (diff) | |
download | scummvm-rg350-69f4b7a38388c444d2911d07a3636a65dd1a4d20.tar.gz scummvm-rg350-69f4b7a38388c444d2911d07a3636a65dd1a4d20.tar.bz2 scummvm-rg350-69f4b7a38388c444d2911d07a3636a65dd1a4d20.zip |
Got rid of ThemeLayout::getDialogData; added some comments, asserts; moved getParentW & getParentH to class ThemeLayoutStacked
svn-id: r35571
-rw-r--r-- | gui/ThemeEval.cpp | 3 | ||||
-rw-r--r-- | gui/ThemeLayout.cpp | 19 | ||||
-rw-r--r-- | gui/ThemeLayout.h | 26 |
3 files changed, 29 insertions, 19 deletions
diff --git a/gui/ThemeEval.cpp b/gui/ThemeEval.cpp index 6a0056c63b..3729c1b499 100644 --- a/gui/ThemeEval.cpp +++ b/gui/ThemeEval.cpp @@ -63,9 +63,6 @@ bool ThemeEval::getWidgetData(const Common::String &widget, int16 &x, int16 &y, 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); } diff --git a/gui/ThemeLayout.cpp b/gui/ThemeLayout.cpp index be14671e69..390b6e13ef 100644 --- a/gui/ThemeLayout.cpp +++ b/gui/ThemeLayout.cpp @@ -55,6 +55,13 @@ void ThemeLayout::importLayout(ThemeLayout *layout) { } 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 @@ bool ThemeLayout::getWidgetData(const Common::String &name, int16 &x, int16 &y, return false; } -int16 ThemeLayout::getParentW() { +int16 ThemeLayoutStacked::getParentW() { ThemeLayout *p = _parent; int width = 0; @@ -73,13 +80,16 @@ int16 ThemeLayout::getParentW() { 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 @@ int16 ThemeLayout::getParentH() { 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 @@ void ThemeLayoutStacked::reflowLayoutV() { _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 @@ void ThemeLayoutStacked::reflowLayoutH() { _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 diff --git a/gui/ThemeLayout.h b/gui/ThemeLayout.h index 0824893441..c32fa44528 100644 --- a/gui/ThemeLayout.h +++ b/gui/ThemeLayout.h @@ -77,8 +77,6 @@ public: } protected: - int16 getParentW(); - int16 getParentH(); int16 getWidth() { return _w; } int16 getHeight() { return _h; } @@ -104,13 +102,6 @@ protected: 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 @@ public: #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 @@ public: } #endif +protected: + int16 getParentW(); + int16 getParentH(); + LayoutType getLayoutType() { return _type; } ThemeLayout *makeClone(ThemeLayout *newParent) { @@ -194,7 +189,6 @@ public: return n; } -protected: const LayoutType _type; }; @@ -207,9 +201,12 @@ public: 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 @@ public: return n; } -protected: Common::String _name; }; @@ -236,11 +232,13 @@ public: 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; |