diff --git a/gui/ThemeEval.cpp b/gui/ThemeEval.cpp index ec5c1e6abdb..e13ccc01765 100644 --- a/gui/ThemeEval.cpp +++ b/gui/ThemeEval.cpp @@ -36,7 +36,7 @@ namespace GUI { -bool ThemeLayoutWidget::getWidgetData(const Common::String &name, int16 &x, int16 &y, int16 &w, int16 &h) { +bool ThemeLayoutWidget::getWidgetData(const Common::String &name, int16 &x, int16 &y, uint16 &w, uint16 &h) { if (name == _name) { x = _x; y = _y; w = _w; h = _h; @@ -46,7 +46,7 @@ bool ThemeLayoutWidget::getWidgetData(const Common::String &name, int16 &x, int1 return false; } -bool ThemeLayout::getWidgetData(const Common::String &name, int16 &x, int16 &y, int16 &w, int16 &h) { +bool ThemeLayout::getWidgetData(const Common::String &name, int16 &x, int16 &y, uint16 &w, uint16 &h) { for (uint i = 0; i < _children.size(); ++i) { if (_children[i]->getWidgetData(name, x, y, w, h)) return true; @@ -82,15 +82,19 @@ void ThemeLayoutVertical::reflowLayout() { if (i == 0) assert(_children[i]->getWidth() != -1); - - _children[i]->setX(curX); - _children[i]->setY(curY); if (_children[i]->getWidth() == -1) _children[i]->setWidth(_w - _paddingLeft - _paddingRight); if (_children[i]->getHeight() == -1) _children[i]->setHeight(getParentH() - _h - _spacing); + + _children[i]->setY(curY); + + if (_centered) + _children[i]->setX((_w >> 1) - (_children[i]->getWidth() >> 1)); + else + _children[i]->setX(curX); if (_reverse) { for (int j = i - 1; j >= 0; --j) @@ -121,9 +125,6 @@ void ThemeLayoutHorizontal::reflowLayout() { if (i == 0) assert(_children[i]->getHeight() != -1); - - _children[i]->setX(curX); - _children[i]->setY(curY); if (_children[i]->getHeight() == -1) _children[i]->setHeight(_h - _paddingTop - _paddingBottom); @@ -131,6 +132,9 @@ void ThemeLayoutHorizontal::reflowLayout() { if (_children[i]->getWidth() == -1) _children[i]->setWidth(getParentW() - _w - _spacing); + _children[i]->setX(curX); + _children[i]->setY(curY); + if (_reverse) { for (int j = i - 1; j >= 0; --j) _children[j]->setX(_children[i]->getWidth() + _spacing); @@ -172,13 +176,13 @@ void ThemeEval::addDialog(const Common::String &name) { _curLayout.push(layout); } -void ThemeEval::addLayout(ThemeLayout::LayoutType type, bool reverse) { +void ThemeEval::addLayout(ThemeLayout::LayoutType type, bool reverse, bool center) { ThemeLayout *layout = 0; if (type == ThemeLayout::kLayoutVertical) - layout = new ThemeLayoutVertical(_curLayout.top(), getVar("Globals.Layout.Spacing", 4), reverse); + layout = new ThemeLayoutVertical(_curLayout.top(), getVar("Globals.Layout.Spacing", 4), reverse, center); else if (type == ThemeLayout::kLayoutHorizontal) - layout = new ThemeLayoutHorizontal(_curLayout.top(), getVar("Globals.Layout.Spacing", 4), reverse); + layout = new ThemeLayoutHorizontal(_curLayout.top(), getVar("Globals.Layout.Spacing", 4), reverse, center); layout->setPadding( getVar("Globals.Padding.Left", 0), @@ -187,8 +191,6 @@ void ThemeEval::addLayout(ThemeLayout::LayoutType type, bool reverse) { getVar("Globals.Padding.Bottom", 0) ); - layout->setSpacing(4); - _curLayout.top()->addChild(layout); _curLayout.push(layout); } diff --git a/gui/ThemeEval.h b/gui/ThemeEval.h index 87af99c944f..b412ba67987 100644 --- a/gui/ThemeEval.h +++ b/gui/ThemeEval.h @@ -51,7 +51,8 @@ public: ThemeLayout(ThemeLayout *p, const Common::String &name) : _parent(p), _name(name), _x(0), _y(0), _w(-1), _h(-1), _reverse(false), - _paddingLeft(0), _paddingRight(0), _paddingTop(0), _paddingBottom(0) { } + _paddingLeft(0), _paddingRight(0), _paddingTop(0), _paddingBottom(0), + _centered(false) { } virtual ~ThemeLayout() { _children.clear(); @@ -144,7 +145,7 @@ public: virtual LayoutType getLayoutType() = 0; virtual const char *getName() { return _name.c_str(); } - virtual bool getWidgetData(const Common::String &name, int16 &x, int16 &y, int16 &w, int16 &h); + virtual bool getWidgetData(const Common::String &name, int16 &x, int16 &y, uint16 &w, uint16 &h); protected: int16 _x, _y, _w, _h; @@ -153,6 +154,7 @@ protected: Common::Array _children; ThemeLayout *_parent; bool _reverse; + bool _centered; Common::String _name; }; @@ -166,9 +168,11 @@ public: class ThemeLayoutVertical : public ThemeLayout { public: - ThemeLayoutVertical(ThemeLayout *p, int spacing, bool reverse) : ThemeLayout(p, "") { + ThemeLayoutVertical(ThemeLayout *p, int spacing, bool reverse, bool center) : + ThemeLayout(p, "") { _spacing = spacing; _reverse = reverse; + _centered = center; } void reflowLayout(); @@ -178,10 +182,11 @@ public: class ThemeLayoutHorizontal : public ThemeLayout { public: - ThemeLayoutHorizontal(ThemeLayout *p, int spacing, bool reverse) : + ThemeLayoutHorizontal(ThemeLayout *p, int spacing, bool reverse, bool center) : ThemeLayout(p, "") { _spacing = spacing; _reverse = reverse; + _centered = center; } void reflowLayout(); @@ -192,7 +197,7 @@ public: class ThemeLayoutWidget : public ThemeLayout { public: ThemeLayoutWidget(ThemeLayout *p, const Common::String &name) : ThemeLayout(p, name) {} - bool getWidgetData(const Common::String &name, int16 &x, int16 &y, int16 &w, int16 &h); + bool getWidgetData(const Common::String &name, int16 &x, int16 &y, uint16 &w, uint16 &h); void reflowLayout() {} LayoutType getLayoutType() { return kLayoutWidget; } }; @@ -209,7 +214,7 @@ public: } } - bool getWidgetData(const Common::String &name, int16 &x, int16 &y, int16 &w, int16 &h) { return false; } + bool getWidgetData(const Common::String &name, int16 &x, int16 &y, uint16 &w, uint16 &h) { return false; } void reflowLayout() {} LayoutType getLayoutType() { return kLayoutWidget; } const char *getName() { return "SPACE"; } @@ -242,14 +247,27 @@ public: bool hasVar(const Common::String &name) { return _vars.contains(name); } void addDialog(const Common::String &name); - void addLayout(ThemeLayout::LayoutType type, bool reverse); + void addLayout(ThemeLayout::LayoutType type, bool reverse, bool center = false); void addWidget(const Common::String &name, int w, int h); void addSpacing(int size); + void addPadding(int16 l, int16 r, int16 t, int16 b) { + _curLayout.top()->setPadding(l, r, t, b); + } + void closeLayout() { _curLayout.pop(); } void closeDialog() { _curLayout.pop()->reflowLayout(); } - + bool getWidgetData(const Common::String &widget, int16 &x, int16 &y, uint16 &w, uint16 &h) { + Common::StringTokenizer tokenizer(widget, "."); + Common::String dialogName = "Dialog." + tokenizer.nextToken(); + Common::String widgetName = tokenizer.nextToken(); + + if (!_layouts.contains(dialogName)) + return false; + + return _layouts[dialogName]->getWidgetData(widgetName, x, y, w, h); + } void debugPrint() { printf("Debug variable list:\n"); diff --git a/gui/ThemeParser.cpp b/gui/ThemeParser.cpp index 889acfedbaf..6c5c900f509 100644 --- a/gui/ThemeParser.cpp +++ b/gui/ThemeParser.cpp @@ -501,9 +501,23 @@ bool ThemeParser::parserCallback_dialog(ParserNode *node) { bool ThemeParser::parserCallback_layout(ParserNode *node) { if (node->values["type"] == "vertical") - _theme->themeEval()->addLayout(GUI::ThemeLayout::kLayoutVertical, node->values["direction"] == "bottom2top"); + _theme->themeEval()->addLayout(GUI::ThemeLayout::kLayoutVertical, + node->values["direction"] == "bottom2top", + node->values["center"] == "true"); + else if (node->values["type"] == "horizontal") - _theme->themeEval()->addLayout(GUI::ThemeLayout::kLayoutHorizontal, node->values["direction"] == "right2left"); + _theme->themeEval()->addLayout(GUI::ThemeLayout::kLayoutHorizontal, + node->values["direction"] == "right2left", + node->values["center"] == "true"); + + if (node->values.contains("padding")) { + int paddingL, paddingR, paddingT, paddingB; + + if (!parseIntegerKey(node->values["padding"].c_str(), 4, &paddingL, &paddingR, &paddingT, &paddingB)) + return false; + + _theme->themeEval()->addPadding(paddingL, paddingR, paddingT, paddingB); + } return true; } diff --git a/gui/ThemeParser.h b/gui/ThemeParser.h index e94e8cbc8e4..61d72629462 100644 --- a/gui/ThemeParser.h +++ b/gui/ThemeParser.h @@ -437,7 +437,7 @@ protected: XML_PROP(name, true) XML_KEY(layout) XML_PROP(type, true) - XML_PROP(align, false) + XML_PROP(center, false) XML_PROP(direction, false) XML_PROP(padding, false) XML_PROP(spacing, false) diff --git a/gui/ThemeRenderer.cpp b/gui/ThemeRenderer.cpp index f154f018b9f..4a83982c8c4 100644 --- a/gui/ThemeRenderer.cpp +++ b/gui/ThemeRenderer.cpp @@ -693,11 +693,11 @@ void ThemeRenderer::updateScreen() { _textQueue.clear(); } -// renderDirtyScreen(); + renderDirtyScreen(); - _vectorRenderer->fillSurface(); - themeEval()->debugDraw(_screen, _font); - _vectorRenderer->copyWholeFrame(_system); +// _vectorRenderer->fillSurface(); +// themeEval()->debugDraw(_screen, _font); +// _vectorRenderer->copyWholeFrame(_system); } void ThemeRenderer::renderDirtyScreen() { diff --git a/gui/launcher.cpp b/gui/launcher.cpp index 34c4ebf4747..451c089d3af 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -481,35 +481,35 @@ LauncherDialog::LauncherDialog() #ifndef DISABLE_FANCY_THEMES _logo = 0; if (g_gui.evaluator()->getVar("launcher_logo.visible") == 1 && g_gui.theme()->supportsImages()) { - _logo = new GraphicsWidget(this, "launcher_logo"); + _logo = new GraphicsWidget(this, "Launcher.Logo"); _logo->useThemeTransparency(true); _logo->setGfx(g_gui.theme()->getImageSurface(Theme::kImageLogo)); - new StaticTextWidget(this, "launcher_version", gScummVMVersionDate); + new StaticTextWidget(this, "Launcher.Version", gScummVMVersionDate); } else - new StaticTextWidget(this, "launcher_version", gScummVMFullVersion); + new StaticTextWidget(this, "Launcher.Version", gScummVMFullVersion); #else // Show ScummVM version - new StaticTextWidget(this, "launcher_version", gScummVMFullVersion); + new StaticTextWidget(this, "Launcher.Version", gScummVMFullVersion); #endif - new ButtonWidget(this, "launcher_quit_button", "Quit", kQuitCmd, 'Q'); - new ButtonWidget(this, "launcher_about_button", "About", kAboutCmd, 'B'); - new ButtonWidget(this, "launcher_options_button", "Options", kOptionsCmd, 'O'); + new ButtonWidget(this, "Launcher.QuitButton", "Quit", kQuitCmd, 'Q'); + new ButtonWidget(this, "Launcher.AboutButton", "About", kAboutCmd, 'B'); + new ButtonWidget(this, "Launcher.OptionsButton", "Options", kOptionsCmd, 'O'); _startButton = - new ButtonWidget(this, "launcher_start_button", "Start", kStartCmd, 'S'); + new ButtonWidget(this, "Launcher.StartButton", "Start", kStartCmd, 'S'); // Above the lowest button rows: two more buttons (directly below the list box) _addButton = - new ButtonWidget(this, "launcher_addGame_button", "Add Game...", kAddGameCmd, 'A'); + new ButtonWidget(this, "Launcher.AddGameButton", "Add Game...", kAddGameCmd, 'A'); _editButton = - new ButtonWidget(this, "launcher_editGame_button", "Edit Game...", kEditGameCmd, 'E'); + new ButtonWidget(this, "Launcher.EditGameButton", "Edit Game...", kEditGameCmd, 'E'); _removeButton = - new ButtonWidget(this, "launcher_removeGame_button", "Remove Game", kRemoveGameCmd, 'R'); + new ButtonWidget(this, "Launcher.RemoveGameButton", "Remove Game", kRemoveGameCmd, 'R'); // Add list with game titles - _list = new ListWidget(this, "launcher_list"); + _list = new ListWidget(this, "Launcher.GameList"); _list->setEditable(false); _list->setNumberingMode(kListNumberingOff); diff --git a/gui/newgui.cpp b/gui/newgui.cpp index 3c58633923c..e829a2c6f5d 100644 --- a/gui/newgui.cpp +++ b/gui/newgui.cpp @@ -58,15 +58,11 @@ enum { void GuiObject::reflowLayout() { if (!_name.empty()) { - if ((_x = g_gui.evaluator()->getVar(_name + ".x")) == EVAL_UNDEF_VAR) - error("Undefined variable %s.x", _name.c_str()); - if ((_y = g_gui.evaluator()->getVar(_name + ".y")) == EVAL_UNDEF_VAR) - error("Undefined variable %s.y", _name.c_str()); - _w = g_gui.evaluator()->getVar(_name + ".w"); - _h = g_gui.evaluator()->getVar(_name + ".h"); + if (!g_gui.xmlEval()->getWidgetData(_name, _x, _y, _w, _h)) + error("Could not load widget position for '%s'", _name.c_str()); if (_x < 0) - error("Widget <%s> has x < 0", _name.c_str()); + error("Widget <%s> has x < 0: %d", _name.c_str(), _x); if (_x >= g_system->getOverlayWidth()) error("Widget <%s> has x > %d", _name.c_str(), g_system->getOverlayWidth()); if (_x + _w > g_system->getOverlayWidth()) diff --git a/gui/themes/default.inc b/gui/themes/default.inc index 04fd9418197..d5ee4cc8b36 100644 --- a/gui/themes/default.inc +++ b/gui/themes/default.inc @@ -1 +1 @@ -" " +" " diff --git a/gui/themes/modern.stx b/gui/themes/modern.stx index b13dc1fc984..e4fc5d5c3ec 100644 --- a/gui/themes/modern.stx +++ b/gui/themes/modern.stx @@ -465,7 +465,7 @@ - + - - + + + + - +