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

Tanoku at users.sourceforge.net Tanoku at users.sourceforge.net
Tue Jun 10 13:25:01 CEST 2008


Revision: 32643
          http://scummvm.svn.sourceforge.net/scummvm/?rev=32643&view=rev
Author:   Tanoku
Date:     2008-06-10 04:25:00 -0700 (Tue, 10 Jun 2008)

Log Message:
-----------
Changed DrawStep for dynamic surface drawing.

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

Modified: scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.cpp	2008-06-09 23:15:17 UTC (rev 32642)
+++ scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.cpp	2008-06-10 11:25:00 UTC (rev 32643)
@@ -51,10 +51,10 @@
 /********************************************************************
  * DRAWSTEP handling functions
  ********************************************************************/
-void VectorRenderer::drawStep(DrawStep *step) {
+void VectorRenderer::drawStep(Common::Rect area, DrawStep *step) {
 
 	if (step->flags & DrawStep::kStepCallbackOnly) {
-		(this->*(step->drawing_call))(step);
+		(this->*(step->drawing_call))(&area, step->extra_data);
 		return;
 	}
 
@@ -83,7 +83,7 @@
 	if (step->flags & DrawStep::kStepSettingsOnly)
 		return;
 
-	(this->*(step->drawing_call))(step);	
+	(this->*(step->drawing_call))(&area, step->extra_data);	
 }
 
 /********************************************************************
@@ -248,7 +248,8 @@
 template<typename PixelType, typename PixelFormat>
 void VectorRendererSpec<PixelType, PixelFormat>::
 drawCircle(int x, int y, int r) {
-	if (x + r > Base::_activeSurface->w || y + r > Base::_activeSurface->h)
+	if (x + r > Base::_activeSurface->w || y + r > Base::_activeSurface->h ||
+		x - r < 0 || y - r < 0 || x == 0 || y == 0 || r <= 0)
 		return;
 
 	if (Base::_fillMode != kFillDisabled && Base::_shadowOffset 
@@ -286,7 +287,8 @@
 template<typename PixelType, typename PixelFormat>
 void VectorRendererSpec<PixelType, PixelFormat>::
 drawSquare(int x, int y, int w, int h) {
-	if (x + w > Base::_activeSurface->w || y + h > Base::_activeSurface->h)
+	if (x + w > Base::_activeSurface->w || y + h > Base::_activeSurface->h ||
+		w <= 0 || h <= 0 || x < 0 || y < 0)
 		return;
 
 	if (Base::_fillMode != kFillDisabled && Base::_shadowOffset
@@ -322,7 +324,8 @@
 template<typename PixelType, typename PixelFormat>
 void VectorRendererSpec<PixelType, PixelFormat>::
 drawRoundedSquare(int x, int y, int r, int w, int h) {
-	if (x + w > Base::_activeSurface->w || y + h > Base::_activeSurface->h)
+	if (x + w > Base::_activeSurface->w || y + h > Base::_activeSurface->h ||
+		w <= 0 || h <= 0 || x < 0 || y < 0 || r <= 0 || r > 128)
 		return;
 
 	if (Base::_fillMode != kFillDisabled && Base::_shadowOffset

Modified: scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h
===================================================================
--- scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h	2008-06-09 23:15:17 UTC (rev 32642)
+++ scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h	2008-06-10 11:25:00 UTC (rev 32643)
@@ -47,14 +47,12 @@
 	color1, /** Foreground color/gradient start */
 	color2; /** Background color/gradient end */
 
-	uint16 x, y, w, h, r; /** Shape size */
-	uint16 offset_x, offset_y; /** Offset when drawing directly to the whole screen */
 	uint8 shadow, stroke, factor; /** Misc options... */
 
 	int fill_mode; /** active fill mode */
-	int extra; /** Generic parameter for extra options */
+	int extra_data; /** Generic parameter for extra options (radius/orientation/bevel) */
 
-	void (VectorRenderer::*drawing_call)(DrawStep*); /** Pointer to drawing function */
+	void (VectorRenderer::*drawing_call)(Common::Rect*, int); /** Pointer to drawing function */
 
 	enum DrawStepFlags {
 		kStepCallbackOnly		= (1 << 0),
@@ -89,8 +87,7 @@
 class VectorRenderer {
 public:
 	VectorRenderer() : _shadowOffset(0), _fillMode(kFillDisabled), 
-		_activeSurface(NULL), _strokeWidth(1), _gradientFactor(1),
-	_stepOffsetX(0), _stepOffsetY(0) {
+		_activeSurface(NULL), _strokeWidth(1), _gradientFactor(1) {
 	
 	}
 
@@ -322,41 +319,42 @@
 	/**
 	 * DrawStep callback functions for each drawing feature 
 	 */
-	void drawCallback_CIRCLE(DrawStep *step) {
-		drawCircle(_stepOffsetX + step->x, _stepOffsetY + step->y, step->r);
+	void drawCallback_CIRCLE(Common::Rect *area, int data) {
+		drawCircle(area->left + data, area->top + data, data);
 	}
 
-	void drawCallback_SQUARE(DrawStep *step) {
-		drawSquare(_stepOffsetX + step->x, _stepOffsetY + step->y, step->w, step->h);
+	void drawCallback_SQUARE(Common::Rect *area, int data) {
+		drawSquare(area->left, area->top, area->width(), area->height());
 	}
 
-	void drawCallback_LINE(DrawStep *step) {
-		drawLine(_stepOffsetX + step->x, _stepOffsetY + step->y, step->x + step->w, step->y + step->h);
+	void drawCallback_LINE(Common::Rect *area, int data) {
+		drawLine(area->left, area->top, area->right, area->bottom);
 	}
 
-	void drawCallback_ROUNDSQ(DrawStep *step) {
-		drawRoundedSquare(_stepOffsetX + step->x, _stepOffsetY + step->y, step->r, step->w, step->h);
+	void drawCallback_ROUNDSQ(Common::Rect *area, int data) {
+		drawRoundedSquare(area->left, area->top, data, area->width(), area->height());
 	}
 
-	void drawCallback_FILLSURFACE(DrawStep *step) {
+	void drawCallback_FILLSURFACE(Common::Rect *area, int data) {
 		fillSurface();
 	}
 
-	void drawCallback_TRIANGLE(DrawStep *step) {
-		drawTriangle(_stepOffsetX + step->x, _stepOffsetY + step->y, step->w, step->h, (TriangleOrientation)step->extra);
+	void drawCallback_TRIANGLE(Common::Rect *area, int data) {
+		drawTriangle(area->top, area->left, area->width(), area->height(), (TriangleOrientation)data);
 	}
 
-	void drawCallback_BEVELSQ(DrawStep *step) {
-		drawBeveledSquare(_stepOffsetX + step->x, _stepOffsetY + step->y, step->w, step->h, step->extra);
+	void drawCallback_BEVELSQ(Common::Rect *area, int data) {
+		drawBeveledSquare(area->left, area->top, area->width(), area->height(), data);
 	}
 
 	/**
 	 * Draws the specified draw step on the screen.
 	 * 
 	 * @see DrawStep
+	 * @param area Zone to paint on
 	 * @param step Pointer to a DrawStep struct.
 	 */
-	virtual void drawStep(DrawStep *step);
+	virtual void drawStep(Common::Rect area, DrawStep *step);
 
 	/**
 	 * Copies the current surface to the system overlay 
@@ -365,32 +363,9 @@
 	 */
 	virtual void copyFrame(OSystem *sys) = 0;
 
-	/**
-	 * Enables drawing offset for all the Draw Step operations, 
-	 * i.e. when we are drawing widgets directly on a whole screen
-	 * instead of individual surfaces for caching/blitting.
-	 *
-	 * @param x Horizontal drawing offset.
-	 * @param y Veritcal drawing offset.
-	 */
-	void setDrawOffset(int x, int y) {
-		_stepOffsetX = x;
-		_stepOffsetY = y;
-	}
-
-	/**
-	 * Disables the drawing offset for draw step operations.
-	 */
-	void disableDrawOffset() {
-		_stepOffsetX = _stepOffsetY = 0;
-	}
-
 protected:
 	Surface *_activeSurface; /** Pointer to the surface currently being drawn */
 
-	int _stepOffsetX; /** Offset for all the drawing steps */
-	int _stepOffsetY; /** Offset for all the drawing steps */
-
 	FillMode _fillMode; /** Defines in which way (if any) are filled the drawn shapes */
 	
 	int _shadowOffset; /** offset for drawn shadows */

Modified: scummvm/branches/gsoc2008-gui/gui/InterfaceManager.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/InterfaceManager.cpp	2008-06-09 23:15:17 UTC (rev 32642)
+++ scummvm/branches/gsoc2008-gui/gui/InterfaceManager.cpp	2008-06-10 11:25:00 UTC (rev 32643)
@@ -72,6 +72,7 @@
 		return;
 	}
 
+	freeRenderer();
 	_vectorRenderer = createRenderer(mode);
 	_vectorRenderer->setSurface(_screen);
 }
@@ -80,46 +81,6 @@
 	return false;
 }
 
-void InterfaceManager::drawWidgetBackground(int x, int y, uint16 hints, WidgetBackground background, WidgetStateInfo state, float scale){
-
-}
-
-void InterfaceManager::drawButton(int x, int y, const Common::String &str, WidgetStateInfo state, uint16 hints, float scale) {
-
-}
-
-void InterfaceManager::drawSurface(int x, int y, const Graphics::Surface &surface, WidgetStateInfo state, int alpha, bool themeTrans, float scale) {
-
-}
-
-void InterfaceManager::drawSlider(int x, int y, int width, WidgetStateInfo state, float scale) {
-
-}
-
-void InterfaceManager::drawCheckbox(int x, int y, const Common::String &str, bool checked, WidgetStateInfo state, float scale) {
-
-}
-
-void InterfaceManager::drawTab(int x, int y, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, WidgetStateInfo state, float scale) {
-
-}
-
-void InterfaceManager::drawScrollbar(int x, int y, int sliderY, int sliderHeight, ScrollbarState, WidgetStateInfo state, float scale) {
-
-}
-
-void InterfaceManager::drawPopUpWidget(int x, int y, const Common::String &sel, int deltax, WidgetStateInfo state, TextAlign align, float scale) {
-
-}
-
-void InterfaceManager::drawCaret(int x, int y, bool erase, WidgetStateInfo state, float scale) {
-
-}
-
-void InterfaceManager::drawLineSeparator(int x, int y, WidgetStateInfo state, float scale) {
-
-}
-
 int InterfaceManager::runGUI() {
 	Common::EventManager *eventMan = _system->getEventManager();
 	_system->showOverlay();
@@ -142,43 +103,25 @@
 	steps[1].color2.r = 173;
 	steps[1].color2.g = 40;
 	steps[1].color2.b = 8;
-	steps[1].x = 500;
-	steps[1].y = 95;
-	steps[1].r = 8;
-	steps[1].w = 120;
-	steps[1].h = 30;
+	steps[1].extra_data = 8; // radius
 	steps[1].drawing_call = &VectorRenderer::drawCallback_ROUNDSQ;
 	steps[1].flags = DrawStep::kStepSetGradient;
 
-	steps[2].x = 500;
-	steps[2].y = 135;
-	steps[2].r = 8;
-	steps[2].w = 120;
-	steps[2].h = 30;
+	steps[2].extra_data = 8; // radius
 	steps[2].drawing_call = &VectorRenderer::drawCallback_ROUNDSQ;
 	steps[2].flags = DrawStep::kStepCallbackOnly;
 
-	steps[3].x = 500;
-	steps[3].y = 175;
-	steps[3].r = 8;
-	steps[3].w = 120;
-	steps[3].h = 30;
 	steps[3].drawing_call = &VectorRenderer::drawCallback_ROUNDSQ;
 	steps[3].flags = DrawStep::kStepCallbackOnly;
 
 	bool running = true;
 	while (running) { // draw!!
 
-		for (int i = 0; i < 4; ++i)
-			_vectorRenderer->drawStep(&steps[i]);
+		_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(Common::Rect(32, 32, 256, 256), &steps[3]);
 
-		_vectorRenderer->setFillMode(VectorRenderer::kFillGradient);
-		_vectorRenderer->setFgColor(0, 0, 0);
-		_vectorRenderer->setBgColor(128, 64, 255);
-		_vectorRenderer->drawTriangle(32, 32, 64, 64, VectorRenderer::kTriangleUp);
-
-		_vectorRenderer->drawBeveledSquare(128, 128, 256, 64, 4);
-
 		_vectorRenderer->copyFrame(_system);
 
 		Common::Event event;

Modified: scummvm/branches/gsoc2008-gui/gui/InterfaceManager.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/InterfaceManager.h	2008-06-09 23:15:17 UTC (rev 32642)
+++ scummvm/branches/gsoc2008-gui/gui/InterfaceManager.h	2008-06-10 11:25:00 UTC (rev 32643)
@@ -45,6 +45,7 @@
 class InterfaceManager : public Common::Singleton<InterfaceManager> {
 
 	friend class Common::Singleton<SingletonBaseType>;
+	typedef Common::String String;
 
 public:
 	enum Graphics_Mode {
@@ -139,16 +140,16 @@
 	int getCharWidth(byte c, FontStyle font) const { if (_initOk) return _font->getCharWidth(c); return 0; }
 
 	/** Widget drawing */
-	void drawWidgetBackground(int x, int y, uint16 hints, WidgetBackground background, WidgetStateInfo state, float scale = 1.0f);
-	void drawButton(int x, int y, const Common::String &str, WidgetStateInfo state, uint16 hints, float scale = 1.0f);
-	void drawSurface(int x, int y, const Graphics::Surface &surface, WidgetStateInfo state, int alpha, bool themeTrans, float scale = 1.0f);
-	void drawSlider(int x, int y, int width, WidgetStateInfo state, float scale = 1.0f);
-	void drawCheckbox(int x, int y, const Common::String &str, bool checked, WidgetStateInfo state, float scale = 1.0f);
-	void drawTab(int x, int y, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, WidgetStateInfo state, float scale = 1.0f);
-	void drawScrollbar(int x, int y, int sliderY, int sliderHeight, ScrollbarState, WidgetStateInfo state, float scale = 1.0f);
-	void drawPopUpWidget(int x, int y, const Common::String &sel, int deltax, WidgetStateInfo state, TextAlign align, float scale = 1.0f);
-	void drawCaret(int x, int y, bool erase, WidgetStateInfo state, float scale = 1.0f);
-	void drawLineSeparator(int x, int y, WidgetStateInfo state, float scale = 1.0f);
+	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 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 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 drawLineSeparator(const Common::Rect &r, WidgetStateInfo state = kStateEnabled) {}
 
 protected:
 	template<typename PixelType> void screenInit();
@@ -183,6 +184,9 @@
 };
 
 struct WidgetDrawData {
+	Common::Rect _realSize;
+	bool _scaled;
+
 	Graphics::DrawStep **_steps;
 	int _stepCount;
 


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