[Scummvm-cvs-logs] SF.net SVN: scummvm: [22746] scummvm/trunk/gui

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Mon May 29 07:57:02 CEST 2006


Revision: 22746
Author:   lordhoto
Date:     2006-05-29 07:55:43 -0700 (Mon, 29 May 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=22746&view=rev

Log Message:
-----------
Introduces special switch for GraphicsWidget for use of theme transparency again.

Modified Paths:
--------------
    scummvm/trunk/gui/ThemeClassic.cpp
    scummvm/trunk/gui/ThemeNew.cpp
    scummvm/trunk/gui/launcher.cpp
    scummvm/trunk/gui/theme.h
    scummvm/trunk/gui/widget.cpp
    scummvm/trunk/gui/widget.h
Modified: scummvm/trunk/gui/ThemeClassic.cpp
===================================================================
--- scummvm/trunk/gui/ThemeClassic.cpp	2006-05-29 14:40:18 UTC (rev 22745)
+++ scummvm/trunk/gui/ThemeClassic.cpp	2006-05-29 14:55:43 UTC (rev 22746)
@@ -219,7 +219,7 @@
 	addDirtyRect(r);
 }
 
-void ThemeClassic::drawSurface(const Common::Rect &r, const Graphics::Surface &surface, kState state, int alpha) {
+void ThemeClassic::drawSurface(const Common::Rect &r, const Graphics::Surface &surface, kState state, int alpha, bool themeTrans) {
 	if (!_initOk)
 		return;
 

Modified: scummvm/trunk/gui/ThemeNew.cpp
===================================================================
--- scummvm/trunk/gui/ThemeNew.cpp	2006-05-29 14:40:18 UTC (rev 22745)
+++ scummvm/trunk/gui/ThemeNew.cpp	2006-05-29 14:55:43 UTC (rev 22746)
@@ -43,7 +43,7 @@
 #define kShadowTr4 128
 #define kShadowTr5 192
 
-#define THEME_VERSION 13
+#define THEME_VERSION 14
 
 using Graphics::Surface;
 
@@ -624,7 +624,7 @@
 	addDirtyRect(r2);
 }
 
-void ThemeNew::drawSurface(const Common::Rect &r, const Graphics::Surface &surface, kState state, int alpha) {
+void ThemeNew::drawSurface(const Common::Rect &r, const Graphics::Surface &surface, kState state, int alpha, bool themeTrans) {
 	if (!_initOk)
 		return;
 
@@ -639,7 +639,31 @@
 	if (alpha != 256)
 		restoreBackground(rect);
 
-	drawSurface(rect, &surface, false, false, alpha);
+	if (themeTrans)
+		drawSurface(rect, &surface, false, false, alpha);
+	else {
+		OverlayColor *dst = (OverlayColor*)_screen.getBasePtr(rect.left, rect.top);
+		const OverlayColor *src = (OverlayColor*)surface.pixels;
+
+		int h = rect.height();
+		if (alpha == 256) {
+			while (h--) {
+				memcpy(dst, src, surface.pitch);
+				dst += _screen.w;
+				src += surface.w;
+			}
+		} else {
+			int w = rect.width();
+			while (h--) {
+				for (int i = 0; i < w; ++i) {
+					*dst = getColorAlpha(*src, *dst, alpha);
+				}
+				dst += _screen.w;
+				src += surface.w;
+			}
+		}
+	}
+
 	addDirtyRect(rect);
 }
 

Modified: scummvm/trunk/gui/launcher.cpp
===================================================================
--- scummvm/trunk/gui/launcher.cpp	2006-05-29 14:40:18 UTC (rev 22745)
+++ scummvm/trunk/gui/launcher.cpp	2006-05-29 14:55:43 UTC (rev 22746)
@@ -451,6 +451,7 @@
 	_logo = 0;
 	if (g_gui.evaluator()->getVar("launcher_logo.visible") == 1) {
 		_logo = new GraphicsWidget(this, "launcher_logo");
+		_logo->useThemeTransparency(true);
 		ThemeNew *th = (ThemeNew *)g_gui.theme();
 
 		_logo->setGfx(th->getImageSurface(th->kThemeLogo));
@@ -780,6 +781,7 @@
 
 		if (!_logo)
 			_logo = new GraphicsWidget(this, "launcher_logo");
+		_logo->useThemeTransparency(true);
 		ThemeNew *th = (ThemeNew *)g_gui.theme();
 
 		_logo->setGfx(th->getImageSurface(th->kThemeLogo));

Modified: scummvm/trunk/gui/theme.h
===================================================================
--- scummvm/trunk/gui/theme.h	2006-05-29 14:40:18 UTC (rev 22745)
+++ scummvm/trunk/gui/theme.h	2006-05-29 14:55:43 UTC (rev 22746)
@@ -142,7 +142,7 @@
 
 	virtual void drawWidgetBackground(const Common::Rect &r, uint16 hints, kWidgetBackground background = kWidgetBackgroundPlain, kState state = kStateEnabled) = 0;
 	virtual void drawButton(const Common::Rect &r, const Common::String &str, kState state = kStateEnabled) = 0;
-	virtual void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, kState state = kStateEnabled, int alpha = 256) = 0;
+	virtual void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, kState state = kStateEnabled, int alpha = 256, bool themeTrans = false) = 0;
 	virtual void drawSlider(const Common::Rect &r, int width, kState state = kStateEnabled) = 0;
 	virtual void drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, kState state = kStateEnabled) = 0;
 	virtual void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, kState state = kStateEnabled) = 0;
@@ -244,7 +244,7 @@
 
 	void drawWidgetBackground(const Common::Rect &r, uint16 hints, kWidgetBackground background, kState state);
 	void drawButton(const Common::Rect &r, const String &str, kState state);
-	void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, kState state, int alpha);
+	void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, kState state, int alpha, bool themeTrans);
 	void drawSlider(const Common::Rect &r, int width, kState state);
 	void drawCheckbox(const Common::Rect &r, const String &str, bool checked, kState state);
 	void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<String> &tabs, int active, uint16 hints, kState state);
@@ -321,7 +321,7 @@
 
 	void drawWidgetBackground(const Common::Rect &r, uint16 hints, kWidgetBackground background, kState state);
 	void drawButton(const Common::Rect &r, const String &str, kState state);
-	void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, kState state, int alpha);
+	void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, kState state, int alpha, bool themeTrans);
 	void drawSlider(const Common::Rect &r, int width, kState state);
 	void drawCheckbox(const Common::Rect &r, const String &str, bool checked, kState state);
 	void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<String> &tabs, int active, uint16 hints, kState state);

Modified: scummvm/trunk/gui/widget.cpp
===================================================================
--- scummvm/trunk/gui/widget.cpp	2006-05-29 14:40:18 UTC (rev 22745)
+++ scummvm/trunk/gui/widget.cpp	2006-05-29 14:55:43 UTC (rev 22746)
@@ -316,7 +316,7 @@
 #pragma mark -
 
 GraphicsWidget::GraphicsWidget(GuiObject *boss, int x, int y, int w, int h)
-	: Widget(boss, x, y, w, h), _gfx(), _alpha(256) {
+	: Widget(boss, x, y, w, h), _gfx(), _alpha(256), _transparency(false) {
 	_flags = WIDGET_ENABLED | WIDGET_CLEARBG;
 	_type = kGraphicsWidget;
 	// HACK: Don't save the background. We want to be sure that redrawing
@@ -326,7 +326,7 @@
 }
 
 GraphicsWidget::GraphicsWidget(GuiObject *boss, String name)
-	: Widget(boss, name), _gfx(), _alpha(256) {
+	: Widget(boss, name), _gfx(), _alpha(256), _transparency(false) {
 	_flags = WIDGET_ENABLED | WIDGET_CLEARBG;
 	_type = kGraphicsWidget;
 	// HACK: Don't save the background. We want to be sure that redrawing
@@ -371,7 +371,7 @@
 
 void GraphicsWidget::drawWidget(bool hilite) {
 	if (sizeof(OverlayColor) == _gfx.bytesPerPixel && _gfx.pixels) {
-		g_gui.theme()->drawSurface(Common::Rect(_x, _y, _x+_w, _y+_h), _gfx, Theme::kStateEnabled,  _alpha);
+		g_gui.theme()->drawSurface(Common::Rect(_x, _y, _x+_w, _y+_h), _gfx, Theme::kStateEnabled, _alpha, _transparency);
 	}
 }
 

Modified: scummvm/trunk/gui/widget.h
===================================================================
--- scummvm/trunk/gui/widget.h	2006-05-29 14:40:18 UTC (rev 22745)
+++ scummvm/trunk/gui/widget.h	2006-05-29 14:55:43 UTC (rev 22746)
@@ -273,12 +273,14 @@
 	void setGfx(int w, int h, int r, int g, int b);
 
 	void useAlpha(int alpha) { _alpha = alpha; }
+	void useThemeTransparency(bool enable) { _transparency = enable; }
 
 protected:
 	void drawWidget(bool hilite);
 
 	Graphics::Surface _gfx;
 	int _alpha;
+	bool _transparency;
 };
 
 /* ContainerWidget */


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