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

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Tue Apr 18 11:41:08 CEST 2006


Revision: 22011
Author:   lordhoto
Date:     2006-04-18 11:40:33 -0700 (Tue, 18 Apr 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=22011&view=rev

Log Message:
-----------
- adds own drawing function for (not expanded) popup widgets
- adds pixmaps, colorfades, and gradient factor for the (not expanded) popup widget in new theme
- bumps themeconfig version

Modified Paths:
--------------
    scummvm/trunk/gui/PopUpWidget.cpp
    scummvm/trunk/gui/ThemeClassic.cpp
    scummvm/trunk/gui/ThemeNew.cpp
    scummvm/trunk/gui/theme.h
    scummvm/trunk/gui/themes/modern.ini
Modified: scummvm/trunk/gui/PopUpWidget.cpp
===================================================================
--- scummvm/trunk/gui/PopUpWidget.cpp	2006-04-18 18:25:44 UTC (rev 22010)
+++ scummvm/trunk/gui/PopUpWidget.cpp	2006-04-18 18:40:33 UTC (rev 22011)
@@ -408,36 +408,15 @@
 	int x = _x + _labelWidth;
 	int w = _w - _labelWidth;
 
-	// Draw a thin frame around us.
-	g_gui.theme()->drawWidgetBackground(Common::Rect(x, _y, x+w, _y+_h), _hints | THEME_HINT_USE_SHADOW, Theme::kWidgetBackgroundBorderSmall);
-
 	// Draw the label, if any
 	if (_labelWidth > 0)
 		g_gui.theme()->drawText(Common::Rect(_x+2,_y+3,_x+2+_labelWidth, _y+3+g_gui.theme()->getFontHeight()), _label,
 								isEnabled() ? Theme::kStateEnabled : Theme::kStateDisabled, Theme::kTextAlignRight);
 
-	// Draw a set of arrows at the right end to signal this is a dropdown/popup
-	/*Common::Point p0, p1;
-
-	p0 = Common::Point(x + w + 1 - _h / 2, _y + 4);
-	p1 = Common::Point(x + w + 1 - _h / 2, _y + _h - 4);
-
-	Graphics::Surface &surf = g_gui.getScreen();
-	OverlayColor color = !isEnabled() ? gui->_color : hilite ? gui->_textcolorhi : gui->_textcolor;
-
-	// Evil HACK to draw filled triangles
-	// FIXME: The "big" version is pretty ugly.
-	for (; p1.y - p0.y > 1; p0.y++, p0.x--, p1.y--, p1.x++) {
-		surf.drawLine(p0.x, p0.y, p1.x, p0.y, color);
-		surf.drawLine(p0.x, p1.y, p1.x, p1.y, color);
-	}*/
-
-	// Draw the selected entry, if any
-	if (_selectedItem >= 0) {
-		TextAlignment align = (g_gui.getStringWidth(_entries[_selectedItem].name) > w-6) ? kTextAlignRight : kTextAlignLeft;
-		g_gui.theme()->drawText(Common::Rect(x+2, _y+3, _x+2+w-6, _y+3+g_gui.theme()->getFontHeight()), _entries[_selectedItem].name,
-								isEnabled() ? Theme::kStateEnabled : Theme::kStateDisabled, g_gui.theme()->convertAligment(align), false, _leftPadding);
-	}
+	Common::String sel = "";
+	if (_selectedItem >= 0)
+		sel = _entries[_selectedItem].name;
+	g_gui.theme()->drawPopUpWidget(Common::Rect(x, _y, x+w, _y+_h), sel, _leftPadding, isEnabled() ? Theme::kStateEnabled : Theme::kStateDisabled, g_gui.theme()->convertAligment(kTextAlignLeft));
 }
 
 } // End of namespace GUI

Modified: scummvm/trunk/gui/ThemeClassic.cpp
===================================================================
--- scummvm/trunk/gui/ThemeClassic.cpp	2006-04-18 18:25:44 UTC (rev 22010)
+++ scummvm/trunk/gui/ThemeClassic.cpp	2006-04-18 18:40:33 UTC (rev 22011)
@@ -261,6 +261,36 @@
 	addDirtyRect(r);
 }
 
+void ThemeClassic::drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, kState state, kTextAlign align) {
+	if (!_initOk)
+		return;
+
+	restoreBackground(r);
+
+	box(r.left, r.top, r.width(), r.height());
+
+	Common::Point p0, p1;
+
+	p0 = Common::Point(r.right + 1 - r.height() / 2, r.top + 4);
+	p1 = Common::Point(r.right + 1 - r.height() / 2, r.bottom - 4);
+
+	OverlayColor color = getColor(state);
+
+	// Evil HACK to draw filled triangles
+	// FIXME: The "big" version is pretty ugly.
+	for (; p1.y - p0.y > 1; p0.y++, p0.x--, p1.y--, p1.x++) {
+		_screen.drawLine(p0.x, p0.y, p1.x, p0.y, color);
+		_screen.drawLine(p0.x, p1.y, p1.x, p1.y, color);
+	}
+
+	if (sel != "") {
+		Common::Rect text(r.left + 2, r.top + 3, r.right - 4, r.top + 3 + _font->getFontHeight());
+		_font->drawString(&_screen, sel, text.left, text.top, text.width(), color, convertAligment(align), deltax, false);
+	}
+
+	addDirtyRect(r);
+}
+
 void ThemeClassic::drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, kState state) {
 	if (!_initOk)
 		return;

Modified: scummvm/trunk/gui/ThemeNew.cpp
===================================================================
--- scummvm/trunk/gui/ThemeNew.cpp	2006-04-18 18:25:44 UTC (rev 22010)
+++ scummvm/trunk/gui/ThemeNew.cpp	2006-04-18 18:40:33 UTC (rev 22011)
@@ -38,7 +38,7 @@
 #define kShadowTr3 64
 #define kShadowTr4 128
 
-#define THEME_VERSION 8
+#define THEME_VERSION 9
 
 using Graphics::Surface;
 
@@ -211,6 +211,11 @@
 	_configFile.getKey("button_bkgd", "pixmaps", imageHandlesTable[kButtonBkgd]);
 
 	_configFile.getKey("theme_logo", "pixmaps", imageHandlesTable[kThemeLogo]);
+
+	_configFile.getKey("popupwidget_corner", "pixmaps", imageHandlesTable[kPopUpWidgetBkgdCorner]);
+	_configFile.getKey("popupwidget_top", "pixmaps", imageHandlesTable[kPopUpWidgetBkgdTop]);
+	_configFile.getKey("popupwidget_left", "pixmaps", imageHandlesTable[kPopUpWidgetBkgdLeft]);
+	_configFile.getKey("popupwidget_bkgd", "pixmaps", imageHandlesTable[kPopUpWidgetBkgd]);
 	
 	// load the gradient factors from the config file
 	getFactorFromConfig(_configFile, "main_dialog", _gradientFactors[kMainDialogFactor]);
@@ -229,6 +234,8 @@
 	
 	getFactorFromConfig(_configFile, "scrollbar", _gradientFactors[kScrollbarFactor]);
 	getFactorFromConfig(_configFile, "scrollbar_background", _gradientFactors[kScrollbarBkgdFactor]);
+
+	getFactorFromConfig(_configFile, "popupwidget", _gradientFactors[kPopUpWidgetFactor]);
 	
 	// load values with default values from the config file
 	getExtraValueFromConfig(_configFile, "shadow_left_width", _shadowLeftWidth, 2);
@@ -616,6 +623,38 @@
 	addDirtyRect(r);
 }
 
+void ThemeNew::drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, kState state, kTextAlign align) {
+	if (!_initOk)
+		return;
+
+	OverlayColor start = _colors[kPopUpWidgetStart], end = _colors[kPopUpWidgetEnd];
+	if (state == kStateHighlight) {
+		start = _colors[kPopUpWidgetHighlightStart];
+		end = _colors[kPopUpWidgetHighlightEnd];
+	}
+
+	drawRectMasked(r, surface(kPopUpWidgetBkgdCorner), surface(kPopUpWidgetBkgdTop), surface(kPopUpWidgetBkgdLeft), surface(kPopUpWidgetBkgd),
+						(state == kStateDisabled) ? -30 : 256, start, end, _gradientFactors[kPopUpWidgetFactor]);
+
+	const Graphics::Surface *arrow = surface(kWidgetArrow);
+	Common::Rect arrowRect(r.right - 4 - arrow->w, r.top + 4, r.right - 4, r.top + 4 + arrow->h);
+	arrowRect.clip(r);
+
+	drawSurface(arrowRect, arrow, false, false, (state == kStateDisabled) ? -30 : 256);
+
+	arrowRect.top += arrow->h + 1;
+	arrowRect.bottom += arrow->h + 1;
+	arrowRect.clip(r);
+	drawSurface(arrowRect, arrow, true, false, (state == kStateDisabled) ? -30 : 256);
+
+	if (sel != "") {
+		Common::Rect text(r.left + 2, r.top + 3, r.right - 4, r.top + 3 + getFont()->getFontHeight());
+		getFont()->drawString(&_screen, sel, text.left, text.top, text.width(), getColor(state), convertAligment(align), deltax, false);
+	}
+
+	addDirtyRect(r);
+}
+
 void ThemeNew::drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, kState state) {
 	if (!_initOk)
 		return;
@@ -1236,6 +1275,11 @@
 	getColorFromConfig(_configFile, "scrollbar_slider_highlight_end", _colors[kScrollbarSliderHighlightEnd]);
 	
 	getColorFromConfig(_configFile, "caret_color", _colors[kCaretColor]);
+
+	getColorFromConfig(_configFile, "popupwidget_start", _colors[kPopUpWidgetStart]);
+	getColorFromConfig(_configFile, "pupupwidget_end", _colors[kPopUpWidgetEnd]);
+	getColorFromConfig(_configFile, "popupwidget_highlight_start", _colors[kPopUpWidgetHighlightStart]);
+	getColorFromConfig(_configFile, "popupwidget_highlight_end", _colors[kPopUpWidgetHighlightEnd]);
 }
 
 #define FONT_NAME_NORMAL "newgui_normal"

Modified: scummvm/trunk/gui/theme.h
===================================================================
--- scummvm/trunk/gui/theme.h	2006-04-18 18:25:44 UTC (rev 22010)
+++ scummvm/trunk/gui/theme.h	2006-04-18 18:40:33 UTC (rev 22011)
@@ -138,6 +138,7 @@
 	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;
 	virtual void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, kScrollbarState, kState state = kStateEnabled) = 0;
+	virtual void drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, kState state = kStateEnabled, kTextAlign align = kTextAlignLeft) = 0;
 	virtual void drawCaret(const Common::Rect &r, bool erase, kState state = kStateEnabled) = 0;
 	virtual void drawLineSeparator(const Common::Rect &r, kState state = kStateEnabled) = 0;
 
@@ -234,6 +235,7 @@
 	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);
 	void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, kScrollbarState, kState state);
+	void drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, kState state, kTextAlign align);
 	void drawCaret(const Common::Rect &r, bool erase, kState state);
 	void drawLineSeparator(const Common::Rect &r, kState state);
 private:
@@ -307,6 +309,7 @@
 	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);
 	void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, kScrollbarState, kState state);
+	void drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, kState state, kTextAlign align);
 	void drawCaret(const Common::Rect &r, bool erase, kState state);
 	void drawLineSeparator(const Common::Rect &r, kState state);
 	const Graphics::Surface *getImageSurface(int n) { return _images[n]; }
@@ -420,6 +423,11 @@
 		kWidgetSmallBkgd = 38,
 
 		kThemeLogo = 39,
+
+		kPopUpWidgetBkgdCorner = 40,
+		kPopUpWidgetBkgdTop = 41,
+		kPopUpWidgetBkgdLeft = 42,
+		kPopUpWidgetBkgd = 43,
 		
 		kImageHandlesMax
 	};
@@ -490,6 +498,11 @@
 		kScrollbarButtonHighlightEnd = 37,
 		kScrollbarSliderHighlightStart = 38,
 		kScrollbarSliderHighlightEnd = 39,
+
+		kPopUpWidgetStart = 40,
+		kPopUpWidgetEnd = 41,
+		kPopUpWidgetHighlightStart = 42,
+		kPopUpWidgetHighlightEnd = 43,
 		
 		kColorHandlesMax
 	};
@@ -513,6 +526,8 @@
 		
 		kScrollbarFactor = 8,
 		kScrollbarBkgdFactor = 9,
+
+		kPopUpWidgetFactor = 10,
 		
 		kMaxGradientFactors
 	};

Modified: scummvm/trunk/gui/themes/modern.ini
===================================================================
--- scummvm/trunk/gui/themes/modern.ini	2006-04-18 18:25:44 UTC (rev 22010)
+++ scummvm/trunk/gui/themes/modern.ini	2006-04-18 18:40:33 UTC (rev 22011)
@@ -1,7 +1,7 @@
 # $URL$
 # $Id$
 [theme]
-version=8
+version=9
 
 [pixmaps]
 dialog_corner=dialog_bkgd_corner.bmp
@@ -54,6 +54,11 @@
 button_left=button_bkgd_left.bmp
 button_bkgd=button_bkgd.bmp
 
+popupwidget_corner=widget_small_bkgd_corner.bmp
+popupwidget_top=widget_small_bkgd_top.bmp
+popupwidget_left=widget_small_bkgd_left.bmp
+popupwidget_bkgd=widget_small_bkgd.bmp
+
 theme_logo=logo.bmp
 
 [colors]
@@ -106,6 +111,11 @@
 scrollbar_slider_highlight_start=255 210 200
 scrollbar_slider_highlight_end=200 70 50
 
+popupwidget_start=246 224 139
+pupupwidget_end=251 241 206
+popupwidget_highlight_start=246 224 139
+popupwidget_highlight_end=251 241 206
+
 caret_color=0 0 0
 
 [gradients]
@@ -126,6 +136,8 @@
 scrollbar=1
 scrollbar_background=1
 
+popupwidget=3
+
 [extra]
 shadow_left_width=2
 shadow_right_width=4


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