[Scummvm-cvs-logs] SF.net SVN: scummvm: [33016] scummvm/branches/gsoc2008-gui
Tanoku at users.sourceforge.net
Tanoku at users.sourceforge.net
Sat Jul 12 20:17:11 CEST 2008
Revision: 33016
http://scummvm.svn.sourceforge.net/scummvm/?rev=33016&view=rev
Author: Tanoku
Date: 2008-07-12 11:17:11 -0700 (Sat, 12 Jul 2008)
Log Message:
-----------
- Better support for relative positions in Vector Renderer.
- More widgets.
Modified Paths:
--------------
scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h
scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp
scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp
scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp
Modified: scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h
===================================================================
--- scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h 2008-07-12 17:12:38 UTC (rev 33015)
+++ scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h 2008-07-12 18:17:11 UTC (rev 33016)
@@ -62,16 +62,10 @@
gradColor1, /** gradient start*/
gradColor2; /** gradient end */
- bool fillArea; /** If enabled, the draw step occupies the whole drawing area */
+ bool autoWidth, autoHeight;
+ int16 x, y, w, h; /** width, height and position, if not measured automatically.
+ negative values mean counting from the opposite direction */
- 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 */
-
uint8 shadow, stroke, factor, radius; /** Misc options... */
uint8 fillMode; /** active fill mode */
@@ -332,23 +326,22 @@
}
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) {
Modified: scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp 2008-07-12 17:12:38 UTC (rev 33015)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp 2008-07-12 18:17:11 UTC (rev 33016)
@@ -50,28 +50,33 @@
"<drawstep func = 'fill' fill = 'gradient' gradient_start = '214, 113, 8' gradient_end = '240, 200, 25' />"
"</drawdata>"
+ "<drawdata id = 'popup' cache = false>"
+ "<drawstep func = 'square' stroke = 0 fg_color = '0, 0, 0' fill = 'gradient' gradient_start = '214, 113, 8' gradient_end = '240, 200, 25' shadow = 3 size = 'auto' />"
+ "/*<drawstep func = 'triangle' fg_color = '0, 0, 0' fill = 'foreground' orientation = 'bottom' /> */"
+ "</drawdata>"
+
"<drawdata id = 'default_bg' cache = false>"
- "<drawstep func = 'roundedsq' radius = 12 stroke = 8 fg_color = '0, 0, 0' fill = 'gradient' gradient_start = '255, 231, 140' gradient_end = '255, 243, 206' shadow = 3 size = 'auto' />"
+ "<drawstep func = 'roundedsq' radius = 12 stroke = 4 fg_color = '206, 121, 99' fill = 'gradient' gradient_start = '255, 231, 140' gradient_end = '255, 243, 206' shadow = 3 size = 'auto' />"
"</drawdata>"
"<drawdata id = 'button_idle' cache = false>"
"<text vertical_align = 'center' horizontal_align = 'center' color = '255, 255, 255' />"
- "<drawstep func = 'roundedsq' radius = '8' stroke = 0 fill = 'gradient' gradient_start = '206, 121, 99' gradient_end = '173, 40, 8' size = 'auto' shadow = 3 />"
+ "<drawstep func = 'roundedsq' radius = '8' stroke = 0 fill = 'gradient' gradient_start = '206, 121, 99' gradient_end = '173, 40, 8' shadow = 3 />"
"</drawdata>"
"<drawdata id = 'button_hover' cache = false>"
"<text vertical_align = 'center' horizontal_align = 'center' color = '255, 255, 255' />"
- "<drawstep func = 'roundedsq' radius = '8' fill = 'gradient' gradient_start = '206, 121, 99' gradient_end = '173, 40, 8' size = 'auto' shadow = 3 />"
+ "<drawstep func = 'roundedsq' radius = '8' fill = 'gradient' gradient_start = '206, 121, 99' gradient_end = '173, 40, 8' shadow = 3 />"
"</drawdata>"
"<drawdata id = 'checkbox_disabled' cache = false>"
"<text vertical_align = 'top' horizontal_align = 'left' color = '255, 255, 255' />"
- "<drawstep func = 'square' fill = 'gradient' gradient_start = '206, 121, 99' gradient_end = '173, 40, 8' size = 'auto' shadow = 0 />"
+ "<drawstep func = 'square' fill = 'gradient' gradient_start = '206, 121, 99' gradient_end = '173, 40, 8' shadow = 0 />"
"</drawdata>"
"<drawdata id = 'checkbox_enabled' cache = false>"
"<text vertical_align = 'top' horizontal_align = 'left' color = '255, 255, 255' />"
- "<drawstep func = 'square' fill = 'gradient' gradient_start = '206, 121, 99' gradient_end = '173, 40, 8' size = 'auto' shadow = 0 />"
+ "<drawstep func = 'square' fill = 'gradient' gradient_start = '206, 121, 99' gradient_end = '173, 40, 8' shadow = 0 />"
"<drawstep func = 'circle' radius = 'auto' fill = 'foreground' />"
"</drawdata>"
"</render_info>"
Modified: scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp 2008-07-12 17:12:38 UTC (rev 33015)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp 2008-07-12 18:17:11 UTC (rev 33016)
@@ -91,7 +91,8 @@
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::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 @@
* 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 @@
}
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 <size> keyword has been deprecated. Use <width> and <height> 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")) {
Modified: scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp 2008-07-12 17:12:38 UTC (rev 33015)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp 2008-07-12 18:17:11 UTC (rev 33016)
@@ -388,6 +388,8 @@
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::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);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list