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

Tanoku at users.sourceforge.net Tanoku at users.sourceforge.net
Tue Jun 10 21:57:38 CEST 2008


Revision: 32647
          http://scummvm.svn.sourceforge.net/scummvm/?rev=32647&view=rev
Author:   Tanoku
Date:     2008-06-10 12:57:38 -0700 (Tue, 10 Jun 2008)

Log Message:
-----------
Another redesign on the Draw Steps. This time it's for real.

Modified Paths:
--------------
    scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.cpp
    scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h
    scummvm/branches/gsoc2008-gui/gui/InterfaceManager.cpp

Modified: scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.cpp	2008-06-10 19:08:53 UTC (rev 32646)
+++ scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.cpp	2008-06-10 19:57:38 UTC (rev 32647)
@@ -54,7 +54,7 @@
 void VectorRenderer::drawStep(Common::Rect area, DrawStep *step) {
 
 	if (step->flags & DrawStep::kStepCallbackOnly) {
-		(this->*(step->drawing_call))(&area, step->extra_data);
+		(this->*(step->drawing_call))(&area, step);
 		return;
 	}
 
@@ -83,7 +83,7 @@
 	if (step->flags & DrawStep::kStepSettingsOnly)
 		return;
 
-	(this->*(step->drawing_call))(&area, step->extra_data);	
+	(this->*(step->drawing_call))(&area, step);	
 }
 
 /********************************************************************

Modified: scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h
===================================================================
--- scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h	2008-06-10 19:08:53 UTC (rev 32646)
+++ scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h	2008-06-10 19:57:38 UTC (rev 32647)
@@ -47,13 +47,25 @@
 	color1, /** Foreground color/gradient start */
 	color2; /** Background color/gradient end */
 
-	uint8 shadow, stroke, factor; /** Misc options... */
+	bool fill_area; /** If enabled, the draw step occupies the whole drawing area */
 
-	int fill_mode; /** active fill mode */
-	int extra_data; /** Generic parameter for extra options (radius/orientation/bevel) */
+	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 */
 
-	void (VectorRenderer::*drawing_call)(Common::Rect*, int); /** Pointer to drawing function */
+	uint16 w, h; /** width and height */
 
+	uint8 shadow, stroke, factor, radius; /** Misc options... */
+
+	uint8 fill_mode; /** active fill mode */
+	uint8 extra_data; /** Generic parameter for extra options (orientation/bevel) */
+
+	uint32 scale; /** scale of all the coordinates in FIXED POINT with 16 bits mantissa */
+
+	void (VectorRenderer::*drawing_call)(Common::Rect*, DrawStep*); /** Pointer to drawing function */
+
 	enum DrawStepFlags {
 		kStepCallbackOnly		= (1 << 0),
 		kStepSettingsOnly		= (1 << 1),
@@ -65,6 +77,38 @@
 		kStepSetStroke			= (1 << 7),
 		kStepSetFillMode		= (1 << 8)
 	};
+
+	void getPositions(Common::Rect *area, uint16 &in_x, uint16 &in_y, uint16 &in_w, uint16 &in_h) {
+		if (fill_area) {
+			in_x = area->left;
+			in_y = area->top;
+			in_w = area->width();
+			in_h = area->height();
+		} else {
+			if (!x.relative) in_x = area->left + x.pos; 
+			else in_x = area->left + area->width() - x.pos;
+
+			if (!y.relative) in_y = area->top + y.pos;
+			else in_y = area->top + area->height() - y.pos;
+
+			if (in_x + w > area->right) in_w = area->right - in_x;
+			else in_w = w;
+
+			if (in_y + h > area->bottom) in_h = area->bottom - in_y;
+			else in_h = h;
+		}
+
+		if (scale != (1 << 16) && scale != 0) {
+			in_x = (in_x * scale) >> 16;
+			in_y = (in_y * scale) >> 16;
+			in_w = (in_w * scale) >> 16;
+			in_h = (in_h * scale) >> 16;
+		}
+	}
+
+	uint8 getRadius() {
+		return (((uint32)radius * scale) >> 16);
+	}
 };
 
 VectorRenderer *createRenderer(int mode);
@@ -319,32 +363,45 @@
 	/**
 	 * DrawStep callback functions for each drawing feature 
 	 */
-	void drawCallback_CIRCLE(Common::Rect *area, int data) {
-		drawCircle(area->left + data, area->top + data, data);
+	void drawCallback_CIRCLE(Common::Rect *area, DrawStep *step) {
+		uint16 x, y, w, h;
+		step->getPositions(area, x, y, w, h);
+		drawCircle(x, y, step->getRadius());
 	}
 
-	void drawCallback_SQUARE(Common::Rect *area, int data) {
-		drawSquare(area->left, area->top, area->width(), area->height());
+	void drawCallback_SQUARE(Common::Rect *area, DrawStep *step) {
+		uint16 x, y, w, h;
+		step->getPositions(area, x, y, w, h);
+		drawSquare(x, y, w, h);
 	}
 
-	void drawCallback_LINE(Common::Rect *area, int data) {
-		drawLine(area->left, area->top, area->right, area->bottom);
+	void drawCallback_LINE(Common::Rect *area, DrawStep *step) {
+		uint16 x, y, w, h;
+		step->getPositions(area, x, y, w, h);
+		drawLine(x, y, x + w, y + w);
 	}
 
-	void drawCallback_ROUNDSQ(Common::Rect *area, int data) {
-		drawRoundedSquare(area->left, area->top, data, area->width(), area->height());
+	void drawCallback_ROUNDSQ(Common::Rect *area, DrawStep *step) {
+		uint16 x, y, w, h;
+		step->getPositions(area, x, y, w, h);
+		/* HACK! Radius of the rounded squares isn't scaled */
+		drawRoundedSquare(x, y, step->radius, w, h);
 	}
 
-	void drawCallback_FILLSURFACE(Common::Rect *area, int data) {
+	void drawCallback_FILLSURFACE(Common::Rect *area, DrawStep *step) {
 		fillSurface();
 	}
 
-	void drawCallback_TRIANGLE(Common::Rect *area, int data) {
-		drawTriangle(area->top, area->left, area->width(), area->height(), (TriangleOrientation)data);
+	void drawCallback_TRIANGLE(Common::Rect *area, DrawStep *step) {
+		uint16 x, y, w, h;
+		step->getPositions(area, x, y, w, h);
+		drawTriangle(x, y, w, h, (TriangleOrientation)step->extra_data);
 	}
 
-	void drawCallback_BEVELSQ(Common::Rect *area, int data) {
-		drawBeveledSquare(area->left, area->top, area->width(), area->height(), data);
+	void drawCallback_BEVELSQ(Common::Rect *area, DrawStep *step) {
+		uint16 x, y, w, h;
+		step->getPositions(area, x, y, w, h);
+		drawBeveledSquare(x, y, w, h, step->extra_data);
 	}
 
 	/**

Modified: scummvm/branches/gsoc2008-gui/gui/InterfaceManager.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/InterfaceManager.cpp	2008-06-10 19:08:53 UTC (rev 32646)
+++ scummvm/branches/gsoc2008-gui/gui/InterfaceManager.cpp	2008-06-10 19:57:38 UTC (rev 32647)
@@ -103,23 +103,35 @@
 	steps[1].color2.r = 173;
 	steps[1].color2.g = 40;
 	steps[1].color2.b = 8;
-	steps[1].extra_data = 8; // radius
+	steps[1].radius = 8; // radius
+	steps[1].fill_area = true;
 	steps[1].drawing_call = &VectorRenderer::drawCallback_ROUNDSQ;
 	steps[1].flags = DrawStep::kStepSetGradient;
+	steps[1].scale = (1 << 16);
 
-	steps[2].extra_data = 8; // radius
+	steps[2].radius = 8; // radius
+	steps[2].fill_area = false;
+	steps[2].x.relative = true;
+	steps[2].x.pos = 32;
+	steps[2].y.relative = false;
+	steps[2].y.pos = 32;
+	steps[2].w = 128;
+	steps[2].h = 32;
 	steps[2].drawing_call = &VectorRenderer::drawCallback_ROUNDSQ;
 	steps[2].flags = DrawStep::kStepCallbackOnly;
+	steps[2].scale = (1 << 16);
 
 	steps[3].drawing_call = &VectorRenderer::drawCallback_ROUNDSQ;
 	steps[3].flags = DrawStep::kStepCallbackOnly;
 
+	Common::Rect area = Common::Rect(32, 32, 256, 256);
+
 	bool running = true;
 	while (running) { // draw!!
 
 		_vectorRenderer->drawStep(Common::Rect(), &steps[0]);
-		_vectorRenderer->drawStep(Common::Rect(32, 32, 256, 256), &steps[1]);
-		_vectorRenderer->drawStep(Common::Rect(128, 128, 512, 190), &steps[2]);
+		_vectorRenderer->drawStep(area, &steps[1]);
+		_vectorRenderer->drawStep(area, &steps[2]);
 //		_vectorRenderer->drawStep(Common::Rect(32, 32, 256, 256), &steps[3]);
 
 		_vectorRenderer->copyFrame(_system);


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