diff options
author | Vicent Marti | 2008-07-07 18:37:22 +0000 |
---|---|---|
committer | Vicent Marti | 2008-07-07 18:37:22 +0000 |
commit | 92ef8dd7502eb86185989a9e2e2b9d722930ec1e (patch) | |
tree | 306ba186fb7855db84635a71eea385f60f62c2ef | |
parent | 9b7faedb0de9f9c3bc18bff5bfc0a629142806b5 (diff) | |
download | scummvm-rg350-92ef8dd7502eb86185989a9e2e2b9d722930ec1e.tar.gz scummvm-rg350-92ef8dd7502eb86185989a9e2e2b9d722930ec1e.tar.bz2 scummvm-rg350-92ef8dd7502eb86185989a9e2e2b9d722930ec1e.zip |
Rendering pipeline. Bugfixes / debug widgets.
svn-id: r32946
-rw-r--r-- | graphics/VectorRenderer.h | 36 | ||||
-rw-r--r-- | gui/ThemeDefaultXML.cpp | 9 | ||||
-rw-r--r-- | gui/ThemeParser.cpp | 7 | ||||
-rw-r--r-- | gui/ThemeRenderer.cpp | 71 | ||||
-rw-r--r-- | gui/ThemeRenderer.h | 24 |
5 files changed, 120 insertions, 27 deletions
diff --git a/graphics/VectorRenderer.h b/graphics/VectorRenderer.h index 08c8a8435d..7b04191f91 100644 --- a/graphics/VectorRenderer.h +++ b/graphics/VectorRenderer.h @@ -39,6 +39,16 @@ namespace Graphics { class VectorRenderer; struct DrawStep; +struct TextStep { + struct { + uint8 r, g, b; + bool set; + } + color; /** text color */ + + GUI::Theme::TextAlign align; +}; + struct DrawStep { struct { uint8 r, g, b; @@ -294,7 +304,7 @@ public: * @see shadowDisable() */ virtual void shadowEnable(int offset) { - if (offset > 0) + if (offset >= 0) _shadowOffset = offset; } @@ -346,13 +356,30 @@ public: } } + int stepGetRadius(const DrawStep &step, const Common::Rect &area) { + int radius = 0; + + if (step.radius == 0xFF) + radius = MIN(area.width(), area.height()) / 2; + else + radius = step.radius; + + if (step.scale != (1 << 16) && step.scale != 0) + radius = (radius * step.scale) >> 16; + + return radius; + } + /** * DrawStep callback functions for each drawing feature */ void drawCallback_CIRCLE(const Common::Rect &area, const DrawStep &step) { - uint16 x, y, w, h; + uint16 x, y, w, h, radius; + + radius = stepGetRadius(step, area); stepGetPositions(step, area, x, y, w, h); - drawCircle(x, y, (step.radius * step.scale) >> 16); + + drawCircle(x + radius, y + radius, radius); } void drawCallback_SQUARE(const Common::Rect &area, const DrawStep &step) { @@ -370,8 +397,7 @@ public: void drawCallback_ROUNDSQ(const Common::Rect &area, const DrawStep &step) { uint16 x, y, w, h; stepGetPositions(step, area, x, y, w, h); - /* HACK! Radius of the rounded squares isn't scaled */ - drawRoundedSquare(x, y, step.radius, w, h); + drawRoundedSquare(x, y, stepGetRadius(step, area), w, h); } void drawCallback_FILLSURFACE(const Common::Rect &area, const DrawStep &step) { diff --git a/gui/ThemeDefaultXML.cpp b/gui/ThemeDefaultXML.cpp index 182535a9c6..fe14fbb403 100644 --- a/gui/ThemeDefaultXML.cpp +++ b/gui/ThemeDefaultXML.cpp @@ -57,6 +57,15 @@ bool ThemeRenderer::loadDefaultXML() { "<drawdata id = 'button_hover' cache = false>" "<drawstep func = 'roundedsq' radius = '8' fill = 'gradient' gradient_start = '206, 121, 99' gradient_end = '173, 40, 8' size = 'auto' shadow = 3 />" "</drawdata>" + + "<drawdata id = 'checkbox_disabled' cache = false>" + "<drawstep func = 'square' fill = 'gradient' gradient_start = '206, 121, 99' gradient_end = '173, 40, 8' size = 'auto' shadow = 0 />" + "</drawdata>" + + "<drawdata id = 'checkbox_enabled' cache = false>" + "<drawstep func = 'square' fill = 'gradient' gradient_start = '206, 121, 99' gradient_end = '173, 40, 8' size = 'auto' shadow = 0 />" + "<drawstep func = 'circle' radius = 'auto' fill = 'foreground' />" + "</drawdata>" "</render_info>" "<layout_info>" diff --git a/gui/ThemeParser.cpp b/gui/ThemeParser.cpp index 2726e15587..463e8c81ea 100644 --- a/gui/ThemeParser.cpp +++ b/gui/ThemeParser.cpp @@ -95,6 +95,7 @@ Graphics::DrawStep *ThemeParser::defaultDrawStep() { step->scale = (1 << 16); step->shadow = 0; step->stroke = 1; + step->radius = 0xFF; return step; } @@ -341,7 +342,11 @@ bool ThemeParser::parseDrawStep(ParserNode *stepNode, Graphics::DrawStep *drawst Common::String functionName = stepNode->values["func"]; if (functionName == "roundedsq" || functionName == "circle") { - __PARSER_ASSIGN_INT(radius, "radius", true) + if (stepNode->values.contains("radius") && stepNode->values["radius"] == "auto") { + drawstep->radius = 0xFF; + } else { + __PARSER_ASSIGN_INT(radius, "radius", true); + } } if (functionName == "bevelsq") { diff --git a/gui/ThemeRenderer.cpp b/gui/ThemeRenderer.cpp index 281c02f8f4..bf481fabb8 100644 --- a/gui/ThemeRenderer.cpp +++ b/gui/ThemeRenderer.cpp @@ -275,6 +275,7 @@ void ThemeRenderer::drawButton(const Common::Rect &r, const Common::String &str, // TODO: Add text drawing. addDirtyRect(r); + debugWidgetPosition(r); } void ThemeRenderer::drawLineSeparator(const Common::Rect &r, WidgetStateInfo state) { @@ -283,21 +284,30 @@ void ThemeRenderer::drawLineSeparator(const Common::Rect &r, WidgetStateInfo sta drawDD(kDDSeparator, r); addDirtyRect(r); + + debugWidgetPosition(r); } void ThemeRenderer::drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state) { if (!ready()) return; - drawDD(checked ? kDDCheckboxEnabled : kDDCheckboxDisabled, r); - Common::Rect r2 = r; - r2.left += 16; // TODO: add variable for checkbox text offset. + int checkBoxSize = getFontHeight(); + + if (checkBoxSize > r.height()) + checkBoxSize = r.height(); + + r2.bottom = r2.top + checkBoxSize; + r2.right = r2.left + checkBoxSize; + + drawDD(checked ? kDDCheckboxEnabled : kDDCheckboxDisabled, r2); // TODO: text drawing // getFont()->drawString(&_screen, str, r2.left, r2.top, r2.width(), getColor(state), Graphics::kTextAlignLeft, 0, false); addDirtyRect(r); + debugWidgetPosition(r); } void ThemeRenderer::drawSlider(const Common::Rect &r, int width, WidgetStateInfo state) { @@ -312,15 +322,68 @@ void ThemeRenderer::drawSlider(const Common::Rect &r, int width, WidgetStateInfo drawDD(kDDSliderFull, r2); addDirtyRect(r); + debugWidgetPosition(r); } void ThemeRenderer::drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState sb_state, WidgetStateInfo state) { if (!ready()) return; + + debugWidgetPosition(r); +} + +void ThemeRenderer::drawDialogBackground(const Common::Rect &r, uint16 hints, WidgetStateInfo state) { + if (!ready()) + return; + + debugWidgetPosition(r); +} + +void ThemeRenderer::drawCaret(const Common::Rect &r, bool erase, WidgetStateInfo state) { + if (!ready()) + return; + + debugWidgetPosition(r); +} + +void ThemeRenderer::drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, WidgetStateInfo state, TextAlign align) { + if (!ready()) + return; + + debugWidgetPosition(r); +} + +void ThemeRenderer::drawSurface(const Common::Rect &r, const Graphics::Surface &surface, WidgetStateInfo state, int alpha, bool themeTrans) { + if (!ready()) + return; + + debugWidgetPosition(r); +} + +void ThemeRenderer::drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background, WidgetStateInfo state) { + if (!ready()) + return; + + debugWidgetPosition(r); +} + +void ThemeRenderer::drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, WidgetStateInfo state) { + if (!ready()) + return; + + debugWidgetPosition(r); +} + +void ThemeRenderer::debugWidgetPosition(const Common::Rect &r) { + _screen->hLine(r.left, r.top, r.right, 0xFFFF); + _screen->hLine(r.left, r.bottom, r.right, 0xFFFF); + _screen->vLine(r.left, r.top, r.bottom, 0xFFFF); + _screen->vLine(r.right, r.top, r.bottom, 0xFFFF); } void ThemeRenderer::updateScreen() { - renderDirtyScreen(); +// renderDirtyScreen(); + _vectorRenderer->copyWholeFrame(_system); } void ThemeRenderer::renderDirtyScreen() { diff --git a/gui/ThemeRenderer.h b/gui/ThemeRenderer.h index 56b81b21fc..21fd53bf1d 100644 --- a/gui/ThemeRenderer.h +++ b/gui/ThemeRenderer.h @@ -143,18 +143,18 @@ public: int getCharWidth(byte c, FontStyle font) const { if (_initOk) return _font->getCharWidth(c); return 0; } /** Widget drawing */ - void drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background = kWidgetBackgroundPlain, WidgetStateInfo state = kStateEnabled) {} + void drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background = kWidgetBackgroundPlain, WidgetStateInfo state = kStateEnabled); void drawButton(const Common::Rect &r, const Common::String &str, WidgetStateInfo state = kStateEnabled, uint16 hints = 0); - void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, WidgetStateInfo state = kStateEnabled, int alpha = 256, bool themeTrans = false) {} + void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, WidgetStateInfo state = kStateEnabled, int alpha = 256, bool themeTrans = false); void drawSlider(const Common::Rect &r, int width, WidgetStateInfo state = kStateEnabled); void drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state = kStateEnabled); - void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, WidgetStateInfo state = kStateEnabled) {} + void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, WidgetStateInfo state = kStateEnabled); void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState, WidgetStateInfo state = kStateEnabled); - void drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, WidgetStateInfo state = kStateEnabled, TextAlign align = kTextAlignLeft) {} - void drawCaret(const Common::Rect &r, bool erase, WidgetStateInfo state = kStateEnabled) {} + void drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, WidgetStateInfo state = kStateEnabled, TextAlign align = kTextAlignLeft); + void drawCaret(const Common::Rect &r, bool erase, WidgetStateInfo state = kStateEnabled); void drawLineSeparator(const Common::Rect &r, WidgetStateInfo state = kStateEnabled); - void drawDialogBackground(const Common::Rect &r, uint16 hints, WidgetStateInfo state) {} + void drawDialogBackground(const Common::Rect &r, uint16 hints, WidgetStateInfo state); void drawText(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font) {} void drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, WidgetStateInfo state) {} @@ -184,17 +184,6 @@ public: return _initOk && _themeOk; } - // REMOVED: theme name is looked up in NewGUI and passed to the constructor -/* bool loadTheme() { - ConfMan.registerDefault("gui_theme", "default"); - Common::String style(ConfMan.get("gui_theme")); - - if (style.compareToIgnoreCase("default") == 0) - style = "modern"; - - return loadTheme(style); - } */ - bool loadTheme(Common::String themeName); void setGraphicsMode(GraphicsMode mode); @@ -242,6 +231,7 @@ protected: void drawCached(DrawData type, const Common::Rect &r); inline void drawDD(DrawData type, const Common::Rect &r); + inline void ThemeRenderer::debugWidgetPosition(const Common::Rect &r); // TODO void restoreBackground(Common::Rect r, bool special = false) {} |