[Scummvm-cvs-logs] SF.net SVN: scummvm: [32946] scummvm/branches/gsoc2008-gui

Tanoku at users.sourceforge.net Tanoku at users.sourceforge.net
Mon Jul 7 20:37:23 CEST 2008


Revision: 32946
          http://scummvm.svn.sourceforge.net/scummvm/?rev=32946&view=rev
Author:   Tanoku
Date:     2008-07-07 11:37:22 -0700 (Mon, 07 Jul 2008)

Log Message:
-----------
Rendering pipeline. Bugfixes / debug 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
    scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h

Modified: scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h
===================================================================
--- scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h	2008-07-07 17:03:05 UTC (rev 32945)
+++ scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h	2008-07-07 18:37:22 UTC (rev 32946)
@@ -39,6 +39,16 @@
 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 @@
 	 * @see shadowDisable()
 	 */
 	virtual void shadowEnable(int offset) {
-		if (offset > 0)
+		if (offset >= 0)
 			_shadowOffset = offset;
 	}
 
@@ -346,13 +356,30 @@
 		}
 	}
 
+	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 @@
 	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) {

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp	2008-07-07 17:03:05 UTC (rev 32945)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp	2008-07-07 18:37:22 UTC (rev 32946)
@@ -57,6 +57,15 @@
 	"<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>"

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp	2008-07-07 17:03:05 UTC (rev 32945)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp	2008-07-07 18:37:22 UTC (rev 32946)
@@ -95,6 +95,7 @@
 	step->scale = (1 << 16);
 	step->shadow = 0;
 	step->stroke = 1;
+	step->radius = 0xFF;
 
 	return step;
 }
@@ -341,7 +342,11 @@
 		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") {

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp	2008-07-07 17:03:05 UTC (rev 32945)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp	2008-07-07 18:37:22 UTC (rev 32946)
@@ -275,6 +275,7 @@
 	// TODO: Add text drawing.
 
 	addDirtyRect(r);
+	debugWidgetPosition(r);
 }
 
 void ThemeRenderer::drawLineSeparator(const Common::Rect &r, WidgetStateInfo state) {
@@ -283,21 +284,30 @@
 
 	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 @@
 	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() {

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h	2008-07-07 17:03:05 UTC (rev 32945)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h	2008-07-07 18:37:22 UTC (rev 32946)
@@ -143,18 +143,18 @@
 	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 @@
 		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 @@
 	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) {}


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