From 4539cdf2188d6461ecdc2fbc485d49eab1fb7311 Mon Sep 17 00:00:00 2001
From: Vicent Marti
Date: Sat, 12 Jul 2008 18:17:11 +0000
Subject: - Better support for relative positions in Vector Renderer. - More
widgets.
svn-id: r33016
---
graphics/VectorRenderer.h | 39 ++++++++++++++++-----------------------
gui/ThemeDefaultXML.cpp | 15 ++++++++++-----
gui/ThemeParser.cpp | 30 +++++++++++++++++-------------
gui/ThemeRenderer.cpp | 4 +++-
4 files changed, 46 insertions(+), 42 deletions(-)
diff --git a/graphics/VectorRenderer.h b/graphics/VectorRenderer.h
index 01fccb8c30..4dcef24e31 100644
--- a/graphics/VectorRenderer.h
+++ b/graphics/VectorRenderer.h
@@ -62,15 +62,9 @@ struct DrawStep {
gradColor1, /** gradient start*/
gradColor2; /** gradient end */
- bool fillArea; /** If enabled, the draw step occupies the whole drawing area */
-
- struct {
- uint16 pos;
- bool relative;
- } x, y; /** Horizontal and vertical coordinates. Relative specifies if they are
- measured from the opposite direction of the drawing area */
-
- uint16 w, h; /** width and height */
+ bool autoWidth, autoHeight;
+ int16 x, y, w, h; /** width, height and position, if not measured automatically.
+ negative values mean counting from the opposite direction */
uint8 shadow, stroke, factor, radius; /** Misc options... */
@@ -332,23 +326,22 @@ public:
}
void stepGetPositions(const DrawStep &step, const Common::Rect &area, uint16 &in_x, uint16 &in_y, uint16 &in_w, uint16 &in_h) {
- if (step.fillArea) {
+ if (!step.autoWidth) {
+ in_w = step.w;
+ if (step.x >= 0) in_x = area.left + step.x;
+ else in_x = area.left + area.width() + step.x; // value relative to the opposite corner.
+ } else {
in_x = area.left;
- in_y = area.top;
in_w = area.width();
- in_h = area.height();
+ }
+
+ if (!step.autoHeight) {
+ in_h = step.h;
+ if (step.y >= 0) in_y = area.top + step.y;
+ else in_y = area.top + area.height() + step.y; // relative
} else {
- if (!step.x.relative) in_x = area.left + step.x.pos;
- else in_x = area.left + area.width() - step.x.pos;
-
- if (!step.y.relative) in_y = area.top + step.y.pos;
- else in_y = area.top + area.height() - step.y.pos;
-
- if (in_x + step.w > area.right) in_w = area.right - in_x;
- else in_w = step.w;
-
- if (in_y + step.h > area.bottom) in_h = area.bottom - in_y;
- else in_h = step.h;
+ in_y = area.top;
+ in_h = area.height();
}
if (step.scale != (1 << 16) && step.scale != 0) {
diff --git a/gui/ThemeDefaultXML.cpp b/gui/ThemeDefaultXML.cpp
index 9227514a66..0c35fa1e1f 100644
--- a/gui/ThemeDefaultXML.cpp
+++ b/gui/ThemeDefaultXML.cpp
@@ -50,28 +50,33 @@ bool ThemeRenderer::loadDefaultXML() {
""
""
+ ""
+
""
- ""
+ ""
""
""
""
- ""
+ ""
""
""
""
- ""
+ ""
""
""
""
- ""
+ ""
""
""
""
- ""
+ ""
""
""
""
diff --git a/gui/ThemeParser.cpp b/gui/ThemeParser.cpp
index 7f02c1eb57..e882945ff1 100644
--- a/gui/ThemeParser.cpp
+++ b/gui/ThemeParser.cpp
@@ -91,7 +91,8 @@ Graphics::DrawStep *ThemeParser::defaultDrawStep() {
step->extraData = 0;
step->factor = 1;
- step->fillArea = true;
+ step->autoWidth = true;
+ step->autoHeight = true;
step->fillMode = Graphics::VectorRenderer::kFillDisabled;
step->scale = (1 << 16);
step->shadow = 0;
@@ -335,7 +336,7 @@ bool ThemeParser::parserCallback_DRAWDATA() {
}
bool ThemeParser::parseDrawStep(ParserNode *stepNode, Graphics::DrawStep *drawstep, bool functionSpecific) {
- int red, green, blue, w, h, x;
+ int red, green, blue, x;
Common::String val;
/**
@@ -362,8 +363,6 @@ bool ThemeParser::parseDrawStep(ParserNode *stepNode, Graphics::DrawStep *drawst
* Helper macro to sanitize and assign a RGB value from a key to the draw
* step. RGB values have the following syntax: "R, G, B".
*
- * TODO: Handle also specific name colors such as "red", "green", etc.
- *
* @param struct_name Name of the field of a DrawStep struct that must be
* assigned.
* @param key_name Name as STRING of the key identifier as it appears in the
@@ -431,16 +430,21 @@ bool ThemeParser::parseDrawStep(ParserNode *stepNode, Graphics::DrawStep *drawst
}
if (stepNode->values.contains("size")) {
- if (stepNode->values["size"] == "auto") {
- drawstep->fillArea = true;
- } else if (sscanf(stepNode->values["size"].c_str(), "%d, %d", &w, &h) == 2) {
- drawstep->fillArea = false;
- drawstep->w = w;
- drawstep->h = h;
- } else {
- return parserError("Invalid value in 'size' subkey: Valid options are 'auto' or 'X, X' to define width and height.");
- }
+ warning("The keyword has been deprecated. Use and instead");
+ }
+
+ if (stepNode->values.contains("width")) {
+ drawstep->autoWidth = false;
+ __PARSER_ASSIGN_INT(x, "xpos", true);
+ }
+
+ if (stepNode->values.contains("height")) {
+ drawstep->autoHeight = false;
+ __PARSER_ASSIGN_INT(y, "ypos", true);
}
+
+ __PARSER_ASSIGN_INT(w, "width", false);
+ __PARSER_ASSIGN_INT(h, "height", false);
}
if (stepNode->values.contains("fill")) {
diff --git a/gui/ThemeRenderer.cpp b/gui/ThemeRenderer.cpp
index 1587a356e4..2df58ed343 100644
--- a/gui/ThemeRenderer.cpp
+++ b/gui/ThemeRenderer.cpp
@@ -388,6 +388,8 @@ void ThemeRenderer::drawCaret(const Common::Rect &r, bool erase, WidgetStateInfo
void ThemeRenderer::drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, WidgetStateInfo state, TextAlign align) {
if (!ready())
return;
+
+ drawDD(kDDPopUp, r);
debugWidgetPosition("Popup Widget", r);
}
@@ -414,7 +416,7 @@ void ThemeRenderer::drawTab(const Common::Rect &r, int tabHeight, int tabWidth,
}
void ThemeRenderer::debugWidgetPosition(const char *name, const Common::Rect &r) {
- _font->drawString(_screen, name, r.left, r.top, r.width(), 0xFFFF, Graphics::kTextAlignLeft, 0, true);
+ _font->drawString(_screen, name, r.left, r.top, r.width(), 0xFFFF, Graphics::kTextAlignRight, 0, true);
_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);
--
cgit v1.2.3