diff options
author | Vicent Marti | 2008-08-04 17:44:18 +0000 |
---|---|---|
committer | Vicent Marti | 2008-08-04 17:44:18 +0000 |
commit | dd46f8305e5c430b3af5511e81f621262149380d (patch) | |
tree | 3ed0438343fb294297cfd9567273f8c428b69048 | |
parent | 85c36885f5bbf2d47276c7702f1b8ccbf22ecc34 (diff) | |
download | scummvm-rg350-dd46f8305e5c430b3af5511e81f621262149380d.tar.gz scummvm-rg350-dd46f8305e5c430b3af5511e81f621262149380d.tar.bz2 scummvm-rg350-dd46f8305e5c430b3af5511e81f621262149380d.zip |
Layout parsing. Work in progress. Looks like a GUI!
svn-id: r33616
-rw-r--r-- | gui/ThemeEval.h | 35 | ||||
-rw-r--r-- | gui/ThemeParser.cpp | 8 |
2 files changed, 25 insertions, 18 deletions
diff --git a/gui/ThemeEval.h b/gui/ThemeEval.h index f53dfe2cd1..2c57e2732c 100644 --- a/gui/ThemeEval.h +++ b/gui/ThemeEval.h @@ -79,8 +79,8 @@ public: virtual const char *getName() { return "Global Layout"; } - int16 getParentW() { return parent ? parent->w : g_system->getOverlayWidth(); } - int16 getParentH() { return parent ? parent->w : g_system->getOverlayHeight(); } + int16 getParentW() { return parent ? parent->w - parent->paddingLeft - parent->paddingRight : g_system->getOverlayWidth(); } + int16 getParentH() { return parent ? parent->h - parent->paddingTop - parent->paddingBottom : g_system->getOverlayHeight(); } int16 getParentX() { return parent ? parent->x : 0; } int16 getParentY() { return parent ? parent->y : 0; } @@ -209,18 +209,10 @@ public: const char *getName() { return "Horizontal Layout"; } void reflowLayout() { - int curX, curY, mul; - - if (parsingMode == kLayoutParseLeft2Right) { - curX = paddingLeft; - curY = paddingTop; - mul = 1; - } else { - curX = getParentW() - paddingRight; - curY = paddingTop; - mul = -1; - } - + int curX, curY; + + curX = paddingLeft; + curY = paddingTop; w = paddingLeft + paddingRight; for (uint i = 0; i < children.size(); ++i) { @@ -235,15 +227,24 @@ public: assert(children[i]->h != -1); - children[i]->setX((parsingMode == kLayoutParseRight2Left) ? (curX - children[i]->w) : (curX)); + children[i]->setX(curX); children[i]->setY(curY); if (children[i]->h == -1) children[i]->h = h - paddingTop - paddingBottom; + + if (children[i]->w == -1) + children[i]->w = getParentW() - w - spacing; h = MAX(h, (int16)(children[i]->h + paddingTop + paddingBottom)); - - curX += (children[i]->w + spacing) * mul; + + if (parsingMode == kLayoutParseRight2Left) { + for (int j = i - 1; j >= 0; --j) + children[j]->setX(children[i]->w + spacing); + } else { + curX += (children[i]->w + spacing); + } + w += children[i]->w + spacing; } } diff --git a/gui/ThemeParser.cpp b/gui/ThemeParser.cpp index 530f613fdb..982a2b59ae 100644 --- a/gui/ThemeParser.cpp +++ b/gui/ThemeParser.cpp @@ -508,13 +508,19 @@ bool ThemeParser::parserCallback_layout(ParserNode *node) { return parserError("Layouts need a specific type (vertical or horizontal)."); GUI::ThemeLayout::LayoutType type = GUI::ThemeLayout::kLayoutNone; + GUI::ThemeLayout::LayoutParsing parsing = GUI::ThemeLayout::kLayoutParseDefault; if (node->values["type"] == "vertical") type = GUI::ThemeLayout::kLayoutVertical; else if (node->values["type"] == "horizontal") type = GUI::ThemeLayout::kLayoutHorizontal; + + if (node->values.contains("direction")) { + if (node->values["direction"] == "right2left") + parsing = GUI::ThemeLayout::kLayoutParseRight2Left; + } - _theme->themeEval()->addLayout(type, GUI::ThemeLayout::kLayoutParseDefault); + _theme->themeEval()->addLayout(type, parsing); return true; } |