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

Tanoku at users.sourceforge.net Tanoku at users.sourceforge.net
Sun Jul 13 12:50:58 CEST 2008


Revision: 33027
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33027&view=rev
Author:   Tanoku
Date:     2008-07-13 03:50:57 -0700 (Sun, 13 Jul 2008)

Log Message:
-----------
Improved support for graphics positioning.
More widgets.
New triangle drawing function.

Modified Paths:
--------------
    scummvm/branches/gsoc2008-gui/base/main.cpp
    scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.cpp
    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/base/main.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/base/main.cpp	2008-07-13 09:33:53 UTC (rev 33026)
+++ scummvm/branches/gsoc2008-gui/base/main.cpp	2008-07-13 10:50:57 UTC (rev 33027)
@@ -70,17 +70,6 @@
 	// Clear the main screen
 	system.clearScreen();
 
-//	GUI::ThemeRenderer *test = new GUI::ThemeRenderer("modern", GUI::ThemeRenderer::kGfxAntialias16bit);
-
-#if defined LOL
-
-//	g_InterfaceManager.runGUI();
-	InterfaceManager *manager = new InterfaceManager();
-	manager->openDialog(kDialogLauncher);
-	return (manager.runGUI() != -1);
-
-#else
-
 #if defined(_WIN32_WCE)
 	CELauncherDialog dlg;
 #elif defined(__DC__)
@@ -89,8 +78,6 @@
 	GUI::LauncherDialog dlg;
 #endif
 	return (dlg.runModal() != -1);
-
-#endif // vector renderer debug
 }
 
 static const EnginePlugin *detectPlugin() {

Modified: scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.cpp	2008-07-13 09:33:53 UTC (rev 33026)
+++ scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.cpp	2008-07-13 10:50:57 UTC (rev 33027)
@@ -399,7 +399,12 @@
 	switch(orient) {
 		case kTriangleUp:
 		case kTriangleDown:
-			drawTriangleVertAlg(x, y, w, h, (orient == kTriangleDown), color, Base::_fillMode);
+#ifdef VECTOR_RENDERER_FAST_TRIANGLES
+			if (w == h)
+				drawTriangleFast(x, y, w, (orient == kTriangleDown), color, Base::_fillMode);
+			else
+#endif
+				drawTriangleVertAlg(x, y, w, h, (orient == kTriangleDown), color, Base::_fillMode);
 			break;
 
 		case kTriangleLeft:
@@ -408,8 +413,14 @@
 	}
 
 	if (Base::_strokeWidth > 0)
-		if (Base::_fillMode == kFillBackground || Base::_fillMode == kFillGradient)
-			drawTriangleVertAlg(x, y, w, h, (orient == kTriangleDown), _fgColor, kFillDisabled);
+		if (Base::_fillMode == kFillBackground || Base::_fillMode == kFillGradient) {
+#ifdef VECTOR_RENDERER_FAST_TRIANGLES
+			if (w == h)
+				drawTriangleFast(x, y, w, (orient == kTriangleDown), _fgColor, kFillDisabled);
+			else
+#endif
+				drawTriangleVertAlg(x, y, w, h, (orient == kTriangleDown), _fgColor, kFillDisabled);
+		}
 }
 
 /********************************************************************
@@ -616,6 +627,35 @@
 }
 
 
+/** VERTICAL TRIANGLE DRAWING - FAST VERSION FOR SQUARED TRIANGLES */
+template<typename PixelType, typename PixelFormat>
+void VectorRendererSpec<PixelType,PixelFormat>::
+drawTriangleFast(int x1, int y1, int size, bool inverted, PixelType color, VectorRenderer::FillMode fill_m) {
+	int pitch = Base::surfacePitch();
+	int hstep = 0;
+	
+	PixelType *ptr_right = 0, *ptr_left = 0;
+	
+	if (inverted) {
+		ptr_left = (PixelType *)_activeSurface->getBasePtr(x1, y1);
+		ptr_right = (PixelType *)_activeSurface->getBasePtr(x1 + size, y1);
+	} else {
+		ptr_left = (PixelType *)_activeSurface->getBasePtr(x1, y1 + size);
+		ptr_right = (PixelType *)_activeSurface->getBasePtr(x1 + size, y1 + size);
+		pitch = -pitch;
+	}
+	
+	while (ptr_left != ptr_right) {
+		colorFill(ptr_left, ptr_right, color);
+		ptr_left += pitch;
+		ptr_right += pitch;
+		if (hstep++ % 3) {
+			ptr_left++;
+			ptr_right--;
+		}	
+	}	
+}
+
 /** ROUNDED SQUARE ALGORITHM **/
 template<typename PixelType, typename PixelFormat>
 void VectorRendererSpec<PixelType, PixelFormat>::

Modified: scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h
===================================================================
--- scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h	2008-07-13 09:33:53 UTC (rev 33026)
+++ scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h	2008-07-13 10:50:57 UTC (rev 33027)
@@ -65,6 +65,15 @@
 	bool autoWidth, autoHeight;
 	int16 x, y, w, h; /** width, height and position, if not measured automatically.
 	 					  negative values mean counting from the opposite direction */
+	
+	enum VectorAlignment {
+		kVectorAlignManual,
+		kVectorAlignLeft,
+		kVectorAlignRight,
+		kVectorAlignBottom,
+		kVectorAlignTop,
+		kVectorAlignCenter
+	} xAlign, yAlign;
 
 	uint8 shadow, stroke, factor, radius; /** Misc options... */
 
@@ -327,18 +336,58 @@
 
 	void stepGetPositions(const DrawStep &step, const Common::Rect &area, uint16 &in_x, uint16 &in_y, uint16 &in_w, uint16 &in_h) {
 		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.
+			in_w = step.w == -1 ? area.height() : step.w;
+			
+			switch(step.xAlign) {
+				case Graphics::DrawStep::kVectorAlignManual:
+					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.
+					break;
+					
+				case Graphics::DrawStep::kVectorAlignCenter:
+					in_x = area.left + (area.width() / 2) - (in_w / 2); 
+					break;
+					
+				case Graphics::DrawStep::kVectorAlignLeft:
+					in_x = area.left;
+					break;
+					
+				case Graphics::DrawStep::kVectorAlignRight:
+					in_x = area.left + area.width() - in_w;
+					break;
+					
+				default:
+					error("Vertical alignment in horizontal data.");
+			}
 		} else {
 			in_x = area.left;
 			in_w = area.width();
 		}
 		
 		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
+			in_h = step.h == -1 ? area.width() : step.h;
+			
+			switch(step.yAlign) {
+				case Graphics::DrawStep::kVectorAlignManual:
+					if (step.y >= 0) in_y = area.top + step.y;
+					else in_y = area.top + area.height() + step.y; // relative
+					break;
+					
+				case Graphics::DrawStep::kVectorAlignCenter:
+					in_y = area.top + (area.height() / 2) - (in_h / 2); 
+					break;
+					
+				case Graphics::DrawStep::kVectorAlignTop:
+					in_y = area.top;
+					break;
+					
+				case Graphics::DrawStep::kVectorAlignBottom:
+					in_y = area.top + area.height() - in_h;
+					break;
+					
+				default:
+					error("Horizontal alignment in vertical data.");
+			}
 		} else {
 			in_y = area.top;
 			in_h = area.height();
@@ -682,6 +731,7 @@
 	virtual void drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, FillMode fill_m);
 	virtual void drawSquareAlg(int x, int y, int w, int h, PixelType color, FillMode fill_m);
 	virtual void drawTriangleVertAlg(int x, int y, int w, int h, bool inverted, PixelType color, FillMode fill_m);
+	virtual void drawTriangleFast(int x, int y, int size, bool inverted, PixelType color, FillMode fill_m);
 	virtual void drawBevelSquareAlg(int x, int y, int w, int h, int bevel, PixelType top_color, PixelType bottom_color);
 
 	/**

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp	2008-07-13 09:33:53 UTC (rev 33026)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp	2008-07-13 10:50:57 UTC (rev 33027)
@@ -51,12 +51,12 @@
 	"</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' /> */"
+		"<drawstep func = 'square' stroke = 0 fg_color = '0, 0, 0' fill = 'gradient' gradient_start = '214, 113, 8' gradient_end = '240, 200, 25' shadow = 3 />"
+		"<drawstep func = 'triangle' fg_color = '0, 0, 0' fill = 'foreground' width = '12' height = '12' xpos = '-16' ypos = 'center' orientation = 'bottom' />"
 	"</drawdata>"
 	
 	"<drawdata id = 'default_bg' cache = false>"
-		"<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' />"
+		"<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 />"
 	"</drawdata>"
 
 	"<drawdata id = 'button_idle' cache = false>"

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp	2008-07-13 09:33:53 UTC (rev 33026)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp	2008-07-13 10:50:57 UTC (rev 33027)
@@ -89,6 +89,13 @@
 	step->gradColor1.set = false;
 	step->gradColor2.set = false;
 
+	step->xAlign = Graphics::DrawStep::kVectorAlignManual;
+	step->yAlign = Graphics::DrawStep::kVectorAlignManual;
+	step->x = 0;
+	step->y = 0;
+	step->w = 0;
+	step->h = 0;
+	
 	step->extraData = 0;
 	step->factor = 1;
 	step->autoWidth = true;
@@ -433,18 +440,64 @@
 			warning("The <size> keyword has been deprecated. Use <width> and <height> instead");
 		}
 		
-		if (stepNode->values.contains("width")) {
+		if (stepNode->values.contains("width") && stepNode->values["width"] != "auto") {
 			drawstep->autoWidth = false;
-			__PARSER_ASSIGN_INT(x, "xpos", true);
+			
+			val = stepNode->values["width"];
+			if (parseIntegerKey(val.c_str(), 1, &x))
+				drawstep->w = x;
+			else if (val == "height")
+				drawstep->w = -1;
+			else return parserError("Invalid value for vector width.");
+			
+			if (stepNode->values.contains("xpos")) {
+				val = stepNode->values["xpos"];
+				
+				if (parseIntegerKey(val.c_str(), 1, &x))
+					drawstep->x = x;
+				else if (val == "center")
+					drawstep->xAlign = Graphics::DrawStep::kVectorAlignCenter;
+				else if (val == "left")
+					drawstep->xAlign = Graphics::DrawStep::kVectorAlignLeft;
+				else if (val == "right")
+					drawstep->xAlign = Graphics::DrawStep::kVectorAlignRight;
+				else 
+					return parserError("Invalid value for X Position");
+			} else {
+				return parserError("When width is not set to 'auto', a <xpos> tag must be included.");
+			}
 		}
 		
-		if (stepNode->values.contains("height")) {
+		if (stepNode->values.contains("height") && stepNode->values["height"] != "auto") {
 			drawstep->autoHeight = false;
-			__PARSER_ASSIGN_INT(y, "ypos", true);
+			
+			val = stepNode->values["height"];
+			if (parseIntegerKey(val.c_str(), 1, &x))
+				drawstep->h = x;
+			else if (val == "width")
+				drawstep->h = -1;
+			else return parserError("Invalid value for vector height.");
+
+			if (stepNode->values.contains("ypos")) {
+				val = stepNode->values["ypos"];
+				
+				if (parseIntegerKey(val.c_str(), 1, &x))
+					drawstep->y = x;
+				else if (val == "center")
+					drawstep->yAlign = Graphics::DrawStep::kVectorAlignCenter;
+				else if (val == "top")
+					drawstep->yAlign = Graphics::DrawStep::kVectorAlignTop;
+				else if (val == "bottom")
+					drawstep->yAlign = Graphics::DrawStep::kVectorAlignBottom;
+				else 
+					return parserError("Invalid value for Y Position");
+			} else {
+				return parserError("When height is not set to 'auto', a <ypos> tag must be included.");
+			}
 		}
-			
-		__PARSER_ASSIGN_INT(w, "width", false);
-		__PARSER_ASSIGN_INT(h, "height", false);
+		
+		if (drawstep->h == -1 && drawstep->w == -1)
+			return parserError("Cross-reference in Vector Size: Height is set to width and width is set to height.");
 	}
 
 	if (stepNode->values.contains("fill")) {

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp	2008-07-13 09:33:53 UTC (rev 33026)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp	2008-07-13 10:50:57 UTC (rev 33027)
@@ -416,11 +416,11 @@
 }
 
 void ThemeRenderer::debugWidgetPosition(const char *name, const Common::Rect &r) {
-	_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);
-	_screen->vLine(r.right, r.top, r.bottom, 0xFFFF);
+	// _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);
+	// _screen->vLine(r.right, r.top, r.bottom, 0xFFFF);
 }
 
 void ThemeRenderer::updateScreen() {


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