diff options
| author | Vicent Marti | 2008-07-12 18:17:11 +0000 | 
|---|---|---|
| committer | Vicent Marti | 2008-07-12 18:17:11 +0000 | 
| commit | 4539cdf2188d6461ecdc2fbc485d49eab1fb7311 (patch) | |
| tree | 871a4dab59e777f9a75d60031cdd9626cf4c3c91 | |
| parent | db932dce89eac7664eb9fc654f87ba89576da66f (diff) | |
| download | scummvm-rg350-4539cdf2188d6461ecdc2fbc485d49eab1fb7311.tar.gz scummvm-rg350-4539cdf2188d6461ecdc2fbc485d49eab1fb7311.tar.bz2 scummvm-rg350-4539cdf2188d6461ecdc2fbc485d49eab1fb7311.zip  | |
- Better support for relative positions in Vector Renderer. 
- More widgets.
svn-id: r33016
| -rw-r--r-- | graphics/VectorRenderer.h | 39 | ||||
| -rw-r--r-- | gui/ThemeDefaultXML.cpp | 15 | ||||
| -rw-r--r-- | gui/ThemeParser.cpp | 30 | ||||
| -rw-r--r-- | 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() {  		"<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>" 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 <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")) { 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);  | 
