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

Tanoku at users.sourceforge.net Tanoku at users.sourceforge.net
Tue Jul 15 12:50:31 CEST 2008


Revision: 33071
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33071&view=rev
Author:   Tanoku
Date:     2008-07-15 03:50:31 -0700 (Tue, 15 Jul 2008)

Log Message:
-----------
More 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/ThemeParser.h
    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-15 10:47:24 UTC (rev 33070)
+++ scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h	2008-07-15 10:50:31 UTC (rev 33071)
@@ -489,6 +489,8 @@
 	 */
 	virtual void blitSurface(Graphics::Surface *source, const Common::Rect &r) = 0;
 	
+	virtual uint32 buildColor(uint8 r, uint8 g, uint8 b) = 0;
+	
 	virtual void drawString(const Graphics::Font *font, const Common::String &text, const Common::Rect &area, GUI::Theme::TextAlign alignH, GUI::Theme::TextAlignVertical alignV) = 0;
 
 protected:
@@ -650,6 +652,10 @@
 			src_ptr += src_pitch;
 		}
 	}
+	
+	virtual uint32 buildColor(uint8 r, uint8 g, uint8 b) {
+		return RGBToColor<PixelFormat>(r, g, b);
+	}
 
 protected:
 

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp	2008-07-15 10:47:24 UTC (rev 33070)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp	2008-07-15 10:50:31 UTC (rev 33071)
@@ -12,7 +12,7 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * GNU General Public License for more details.	
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
@@ -41,7 +41,10 @@
 	"<palette>"
 		"<color name = 'red' rgb = '255, 0, 0' />"
 		"<color name = 'green' rgb = '0, 255, 0' />"
-		"<color name = 'blue' rgb = '0, 0, 255' />"
+		"<color name = 'blue' rgb = '0, 255, 255' />"
+		"<color name = 'text_default' rgb = '0, 0, 0' />"
+		"<color name = 'text_hover' rgb = '255, 255, 255' />"
+		"<color name = 'text_disabled' rgb = '128, 128, 128' />"
 	"</palette>"
 
 	"<default fill = 'gradient' fg_color = '255, 255, 255' />"
@@ -54,6 +57,10 @@
 		"<drawstep func = 'square' fill = 'foreground' height = '3' ypos = 'center' fg_color = '0, 0, 0' />"
 	"</drawdata>"
 	
+	"<drawdata id = 'scrollbar_base' cache = false>"
+		"<drawstep func = 'roundedsq' stroke = 1 radius = 4 fill = 'none' fg_color = '255, 255, 255' />"
+	"</drawdata>"
+	
 	"<drawdata id = 'popup_idle' 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 />"
 		"<drawstep func = 'triangle' fg_color = '0, 0, 0' fill = 'foreground' width = '12' height = '12' xpos = '-16' ypos = 'center' orientation = 'bottom' />"

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp	2008-07-15 10:47:24 UTC (rev 33070)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp	2008-07-15 10:50:31 UTC (rev 33071)
@@ -173,30 +173,32 @@
 		step.alignVertical = GUI::Theme::kTextAlignVBottom;
 	else return parserError("Invalid value for text alignment.");
 	
+	Common::String paletteColor = "text_default";
+	int red, green, blue;
+	
+	if (tNode->name.contains("hover"))
+		paletteColor = "text_hover";
+	
+	if (tNode->name.contains("disabled"))
+		paletteColor = "text_disabled";
+	
 	if (tNode->values.contains("color")) {
-		int red, green, blue;
 
-		if (parseIntegerKey(tNode->values["color"].c_str(), 3, &red, &green, &blue) == false ||
-			red < 0 || red > 255 || green < 0 || green > 255 || blue < 0 || blue > 255)
-			return parserError("Error when parsing color value for text definition");
+		if (_palette.contains(tNode->values["color"]))
+			getPaletteColor(tNode->values["color"], red, green, blue);
+		else if (!parseIntegerKey(tNode->values["color"].c_str(), 3, &red, &green, &blue))
+			return parserError("Error when parsing color value for text definition");		
 			
-		step.color.r = red;
-		step.color.g = green;
-		step.color.b = blue;
-		step.color.set = true;
-	} else if (_defaultStepLocal && _defaultStepLocal->fgColor.set) {
-		step.color.r = _defaultStepLocal->fgColor.r;
-		step.color.g = _defaultStepLocal->fgColor.g;
-		step.color.b = _defaultStepLocal->fgColor.b;
-		step.color.set = true;
-	} 	else if (_defaultStepGlobal && _defaultStepGlobal->fgColor.set) {
-		step.color.r = _defaultStepGlobal->fgColor.r;
-		step.color.g = _defaultStepGlobal->fgColor.g;
-		step.color.b = _defaultStepGlobal->fgColor.b;
-		step.color.set = true;
+	} else if (_palette.contains(paletteColor)) {
+		getPaletteColor(paletteColor, red, green, blue);
 	} else {
 		return parserError("Cannot assign color for text drawing.");
 	}
+	
+	step.color.r = red;
+	step.color.g = green;
+	step.color.b = blue;
+	step.color.set = true;
 
 	_theme->addTextStep(parentNode->values["id"], step);
 	return true;

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeParser.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeParser.h	2008-07-15 10:47:24 UTC (rev 33070)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeParser.h	2008-07-15 10:50:31 UTC (rev 33071)
@@ -316,6 +316,17 @@
 
 public:
 	ThemeParser(GUI::ThemeRenderer *parent);
+	
+	bool getPaletteColor(const Common::String &name, int &r, int &g, int &b) {
+		if (!_palette.contains(name))
+			return false;
+			
+		r = _palette[name].r;
+		g = _palette[name].g;
+		b = _palette[name].b;
+		
+		return true;
+	}
 
 protected:
 	ThemeRenderer *_theme;

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp	2008-07-15 10:47:24 UTC (rev 33070)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp	2008-07-15 10:50:31 UTC (rev 33071)
@@ -69,7 +69,8 @@
 	"popup_hover",
 	
 	"caret",
-	"separator"
+	"separator",
+	"default_text"
 };
 
 ThemeRenderer::ThemeRenderer(Common::String themeName, GraphicsMode mode) : 
@@ -234,7 +235,20 @@
 			// draw the cached widget to the cache surface
 		}
 	}
+	
+	int r, g, b;
+	
+#define __LOAD_COLOR(id, name) { \
+	if (parser()->getPaletteColor(name, r, g, b))\
+		_textColors[id] = _vectorRenderer->buildColor(r, g, b); \
+}
+	
+	__LOAD_COLOR(kTextColorDefault, "text_default");
+	__LOAD_COLOR(kTextColorHover, "text_hover");
+	__LOAD_COLOR(kTextColorDisabled, "text_disabled");
 
+#undef __LOAD_COLOR
+	
 	_themeOk = true;
 	return true;
 }
@@ -360,6 +374,9 @@
 void ThemeRenderer::drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState sb_state, WidgetStateInfo state) {
 	if (!ready())
 		return;
+		
+	drawDD(kDDScrollbarBase, r);
+	
 
 	debugWidgetPosition("SCB", r);
 }
@@ -399,7 +416,7 @@
 	if (!sel.empty()) {
 		Common::Rect text(r.left, r.top, r.right - 16, r.bottom);
 		drawDDText(dd, text, sel);
-	}	
+	}
 	
 	debugWidgetPosition("Popup Widget", r);
 }
@@ -443,6 +460,15 @@
 	debugWidgetPosition("Tab widget", r);
 }
 
+void ThemeRenderer::drawText(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font) {
+	if (!_initOk)
+		return;
+
+	getFont(font)->drawString(_screen, str, r.left, r.top, r.width(), getTextColor(state), convertAligment(align), deltax, useEllipsis);
+	addDirtyRect(r);
+}
+
+
 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);

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h	2008-07-15 10:47:24 UTC (rev 33070)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h	2008-07-15 10:50:31 UTC (rev 33071)
@@ -112,8 +112,17 @@
 		
 		kDDCaret,
 		kDDSeparator,
+		kDDDefaultText,
 		kDrawDataMAX
 	};
+	
+	enum TextColor {
+		kTextColorDefault,
+		kTextColorHover,
+		kTextColorDisabled,
+		kTextColorInverted,
+		kTextColorMAX
+	};
 
 	ThemeRenderer(Common::String themeName, GraphicsMode mode);
 
@@ -160,7 +169,7 @@
 	void drawLineSeparator(const Common::Rect &r, WidgetStateInfo state = kStateEnabled);
 
 	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 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) {}
 
 	bool addDirtyRect(Common::Rect r, bool backup = false, bool special = false) {
@@ -254,6 +263,19 @@
 	int getTabPadding() const {
 		return 3;
 	}
+	
+	uint32 getTextColor(WidgetStateInfo state) {
+		switch (state) {
+			case kStateDisabled:
+				return _textColors[kTextColorDisabled];
+			
+			case kStateHighlight:
+				return _textColors[kTextColorHover];
+			
+			default:
+				return _textColors[kTextColorDefault];
+		}
+	}
 
 	OSystem *_system;
 	Graphics::VectorRenderer *_vectorRenderer;
@@ -266,6 +288,7 @@
 
 	Common::String _fontName;
 	const Graphics::Font *_font;
+	uint32 _textColors[kTextColorMAX];
 
 	WidgetDrawData *_widgets[kDrawDataMAX];
 	Common::Array<Common::Rect> _dirtyScreen;


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