mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-19 00:15:30 +00:00
Got rid of ThemeLayout::getDialogData; added some comments, asserts; moved getParentW & getParentH to class ThemeLayoutStacked
svn-id: r35571
This commit is contained in:
parent
109d55f8d3
commit
69f4b7a383
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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; }
|
||||
|
||||
ThemeLayout *makeClone(ThemeLayout *newParent) { assert(!"Do not copy Main Layouts!"); return 0; }
|
||||
|
||||
protected:
|
||||
LayoutType getLayoutType() { return kLayoutMain; }
|
||||
ThemeLayout *makeClone(ThemeLayout *newParent) { assert(!"Do not copy Main Layouts!"); return 0; }
|
||||
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user