[Scummvm-cvs-logs] CVS: scummvm/gui ThemeNew.cpp,1.6,1.7 console.cpp,1.71,1.72 dialog.cpp,1.65,1.66 dialog.h,1.44,1.45 launcher.cpp,1.134,1.135 options.cpp,1.101,1.102 theme.cpp,1.3,1.4 theme.h,1.2,1.3 widget.cpp,1.57,1.58

Johannes Schickel lordhoto at users.sourceforge.net
Sat Jan 28 15:04:03 CET 2006


Update of /cvsroot/scummvm/scummvm/gui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31992/gui

Modified Files:
	ThemeNew.cpp console.cpp dialog.cpp dialog.h launcher.cpp 
	options.cpp theme.cpp theme.h widget.cpp 
Log Message:
- Fixes a bug that the debugger crashed while opening
- Changed gradient calculating
- added background saving for all dialog/widget backgrounds for now (change that later maybe)
- changed ScummDialog to use the colors of our launcher dialog


Index: ThemeNew.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/ThemeNew.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- ThemeNew.cpp	27 Jan 2006 23:13:51 -0000	1.6
+++ ThemeNew.cpp	28 Jan 2006 23:03:39 -0000	1.7
@@ -274,24 +274,32 @@
 
 #define surface(x) (_images[x])
 
-void ThemeNew::drawDialogBackground(const Common::Rect &r, kState state, bool mainDialog) {
+void ThemeNew::drawDialogBackground(const Common::Rect &r, uint16 hints, kState state) {
 	if (!_initOk)
 		return;
+		
+	if ((hints & THEME_HINT_SAVE_BACKGROUND) && !(hints & THEME_HINT_FIRST_DRAW) && !_forceRedraw) {
+		restoreBackground(r);
+		return;
+	}
 
-	if (mainDialog) {
+	if (hints & THEME_HINT_MAIN_DIALOG) {
 		colorFade(r, _colors[kMainDialogStart], _colors[kMainDialogEnd]);
+	} else if (hints & THEME_HINT_SPECIAL_COLOR) {
+		drawRectMasked(r, surface(kDialogBkgdCorner), surface(kDialogBkgdTop), surface(kDialogBkgdLeft), surface(kDialogBkgd),
+				256, _colors[kMainDialogStart], _colors[kMainDialogEnd]);
 	} else {
 		drawRectMasked(r, surface(kDialogBkgdCorner), surface(kDialogBkgdTop), surface(kDialogBkgdLeft), surface(kDialogBkgd),
-				255, _colors[kDialogStart], _colors[kDialogEnd]);
+				256, _colors[kDialogStart], _colors[kDialogEnd], 2);
 	}
 
-	addDirtyRect(r, true);
+	addDirtyRect(r, (hints & THEME_HINT_SAVE_BACKGROUND) != 0);
 }
 
 void ThemeNew::drawText(const Common::Rect &r, const Common::String &str, kState state, kTextAlign align, bool inverted, int deltax, bool useEllipsis) {
 	if (!_initOk)
 		return;
-	Common::Rect r2(r.left, r.top, r.right, r.top+_font->getFontHeight());
+	Common::Rect r2(r.left, r.top, r.right, r.top+_font->getFontHeight()+2);
 
 	restoreBackground(r2);
 
@@ -326,10 +334,10 @@
 
 	if (background == kWidgetBackgroundBorderSmall) {
 		drawRectMasked(r, surface(kDialogBkgdCorner), surface(kDialogBkgdTop), surface(kDialogBkgdLeft), surface(kDialogBkgd),
-						(state == kStateDisabled) ? 128 : 256, _colors[kWidgetBackgroundSmallStart], _colors[kWidgetBackgroundSmallEnd]);
+						(state == kStateDisabled) ? 128 : 256, _colors[kWidgetBackgroundSmallStart], _colors[kWidgetBackgroundSmallEnd], 3);
 	} else {
 		drawRectMasked(r, surface(kWidgetBkgdCorner), surface(kWidgetBkgdTop), surface(kWidgetBkgdLeft), surface(kWidgetBkgd),
-						(state == kStateDisabled) ? 128 : 256, _colors[kWidgetBackgroundStart], _colors[kWidgetBackgroundEnd], 2);
+						(state == kStateDisabled) ? 128 : 256, _colors[kWidgetBackgroundStart], _colors[kWidgetBackgroundEnd], 3);
 	}
 
 	addDirtyRect(r, (hints & THEME_HINT_SAVE_BACKGROUND) != 0);
@@ -340,7 +348,7 @@
 		return;
 
 	drawRectMasked(r, surface(kWidgetBkgdCorner), surface(kWidgetBkgdTop), surface(kWidgetBkgdLeft), surface(kWidgetBkgd),
-					255, _colors[kButtonBackgroundStart], _colors[kButtonBackgroundEnd],  2);
+					256, _colors[kButtonBackgroundStart], _colors[kButtonBackgroundEnd], 2);
 
 	const int off = (r.height() - _font->getFontHeight()) / 2;
 
@@ -394,7 +402,7 @@
 	if (!_initOk)
 		return;
 
-	drawRectMasked(r, surface(kDialogBkgdCorner), surface(kDialogBkgdTop), surface(kDialogBkgdLeft), surface(kDialogBkgd), 255,
+	drawRectMasked(r, surface(kDialogBkgdCorner), surface(kDialogBkgdTop), surface(kDialogBkgdLeft), surface(kDialogBkgd), 256,
 					_colors[kSliderBackgroundStart], _colors[kSliderBackgroundEnd]);
 
 	Common::Rect r2 = r;
@@ -447,12 +455,12 @@
 	Common::Rect r2 = r;
 
 	// draws the scrollbar background
-	drawRectMasked(r2, surface(kDialogBkgdCorner), surface(kDialogBkgdTop), surface(kDialogBkgdLeft), surface(kDialogBkgd), 255,
+	drawRectMasked(r2, surface(kDialogBkgdCorner), surface(kDialogBkgdTop), surface(kDialogBkgdLeft), surface(kDialogBkgd), 256,
 					_colors[kScrollbarBackgroundStart], _colors[kScrollbarBackgroundEnd]);
 
 	// draws the 'up' button
 	r2.bottom = r2.top + UP_DOWN_BOX_HEIGHT;
-	drawRectMasked(r2, surface(kDialogBkgdCorner), surface(kDialogBkgdTop), surface(kDialogBkgdLeft), surface(kDialogBkgd), 255,
+	drawRectMasked(r2, surface(kDialogBkgdCorner), surface(kDialogBkgdTop), surface(kDialogBkgdLeft), surface(kDialogBkgd), 256,
 					_colors[kScrollbarButtonStart], _colors[kScrollbarButtonEnd]);
 
 	const Graphics::Surface *arrow = surface(kWidgetArrow);
@@ -460,7 +468,7 @@
 	r2.right = r2.left + arrow->w;
 	r2.top += (r2.height() - arrow->h) / 2;
 	r2.bottom = r2.top + arrow->h;
-	drawSurface(r2, arrow, false, false, 255);
+	drawSurface(r2, arrow, false, false, 256);
 
 	// draws the slider
 	r2 = r;
@@ -468,24 +476,24 @@
 	r2.right -= 2;
 	r2.top += sliderY;
 	r2.bottom = r2.top + sliderHeight / 2 + surface(kWidgetBkgdCorner)->h + 4;
-	drawRectMasked(r2, surface(kWidgetBkgdCorner), surface(kWidgetBkgdTop), surface(kWidgetBkgdLeft), surface(kWidgetBkgd), 255,
+	drawRectMasked(r2, surface(kWidgetBkgdCorner), surface(kWidgetBkgdTop), surface(kWidgetBkgdLeft), surface(kWidgetBkgd), 256,
 					_colors[kScrollbarSliderStart], _colors[kScrollbarSliderEnd]);
 	r2.top += sliderHeight / 2;
 	r2.bottom += sliderHeight / 2 - surface(kWidgetBkgdCorner)->h - 4;
-	drawRectMasked(r2, surface(kWidgetBkgdCorner), surface(kWidgetBkgdTop), surface(kWidgetBkgdLeft), surface(kWidgetBkgd), 255,
+	drawRectMasked(r2, surface(kWidgetBkgdCorner), surface(kWidgetBkgdTop), surface(kWidgetBkgdLeft), surface(kWidgetBkgd), 256,
 					_colors[kScrollbarSliderEnd], _colors[kScrollbarSliderStart]);
 
 	// draws the 'down' button
 	r2 = r;
 	r2.top = r2.bottom - UP_DOWN_BOX_HEIGHT;
-	drawRectMasked(r2, surface(kDialogBkgdCorner), surface(kDialogBkgdTop), surface(kDialogBkgdLeft), surface(kDialogBkgd), 255,
+	drawRectMasked(r2, surface(kDialogBkgdCorner), surface(kDialogBkgdTop), surface(kDialogBkgdLeft), surface(kDialogBkgd), 256,
 					_colors[kScrollbarButtonStart], _colors[kScrollbarButtonEnd]);
 
 	r2.left += 1 + (r2.width() - arrow->w) / 2;
 	r2.right = r2.left + arrow->w;
 	r2.top += (r2.height() - arrow->h) / 2;
 	r2.bottom = r2.top + arrow->h;
-	drawSurface(r2, arrow, true, false, 255);
+	drawSurface(r2, arrow, true, false, 256);
 
 	addDirtyRect(r);
 }
@@ -497,7 +505,7 @@
 	restoreBackground(Common::Rect(r.left, r.top, r.left+1, r.bottom));
 	if (!erase) {
 		_screen.vLine(r.left, r.top, r.bottom, _colors[kCaretColor]);
-	} else {
+	} else if (r.top >= 0) {
 		// FIXME: hack to restore the caret background correctly
 		const OverlayColor search = _colors[kTextInvertedBackground];
 		const OverlayColor *src = (const OverlayColor*)_screen.getBasePtr(r.left-1, r.top-1);
@@ -575,7 +583,7 @@
 }
 
 OverlayColor calcGradient(OverlayColor start, OverlayColor end, int pos, int max, uint factor = 1) {
-	pos *= factor;
+	max /= factor;
 	if (pos > max) {
 		pos = max;
 	}

Index: console.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/console.cpp,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- console.cpp	27 Jan 2006 15:43:23 -0000	1.71
+++ console.cpp	28 Jan 2006 23:03:39 -0000	1.72
@@ -104,6 +104,8 @@
 	// Display greetings & prompt
 	print(gScummVMFullVersion);
 	print("\nConsole is ready\n");
+	
+	_drawingHints = THEME_HINT_FIRST_DRAW | THEME_HINT_SAVE_BACKGROUND;
 }
 
 void ConsoleDialog::slideUpAndClose() {
@@ -119,6 +121,8 @@
 	// this effect: we simply move the console dialog just above (outside) the
 	// visible screen area, then shift it down in handleTickle() over a
 	// certain period of time.
+	
+	_drawingHints = THEME_HINT_FIRST_DRAW | THEME_HINT_SAVE_BACKGROUND;
 
 	_y = -_h;
 	_slideTime = g_system->getMillis();
@@ -140,7 +144,8 @@
 	int start = _scrollLine - _linesPerPage + 1;
 	int y = _y + 2;
 
-	g_gui.theme()->drawDialogBackground(Common::Rect(_x, _y, _x+_w, _y+_h));
+	g_gui.theme()->drawDialogBackground(Common::Rect(_x, _y, _x+_w, _y+_h), _drawingHints);
+	_drawingHints = THEME_HINT_SAVE_BACKGROUND;
 
 	for (int line = 0; line < _linesPerPage; line++) {
 		int x = _x + 1;
@@ -175,6 +180,7 @@
 
 	// Perform the "slide animation".
 	if (_slideMode != kNoSlideMode) {
+		_drawingHints = THEME_HINT_FIRST_DRAW | THEME_HINT_SAVE_BACKGROUND;
 		const float tmp = (float)(g_system->getMillis() - _slideTime) / kConsoleSlideDownDuration;
 		if (_slideMode == kUpSlideMode) {
 			_y = (int)(_h * (0.0 - tmp));

Index: dialog.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.cpp,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -d -r1.65 -r1.66
--- dialog.cpp	27 Jan 2006 15:43:23 -0000	1.65
+++ dialog.cpp	28 Jan 2006 23:03:39 -0000	1.66
@@ -40,7 +40,8 @@
 
 Dialog::Dialog(int x, int y, int w, int h)
 	: GuiObject(x, y, w, h),
-	  _mouseWidget(0), _focusedWidget(0), _dragWidget(0), _visible(false), _mainDialog(false) {
+	  _mouseWidget(0), _focusedWidget(0), _dragWidget(0), _visible(false), _drawingHints(0) {
+	_drawingHints = THEME_HINT_FIRST_DRAW | THEME_HINT_SAVE_BACKGROUND;
 }
 
 Dialog::~Dialog() {
@@ -93,6 +94,7 @@
 	// changed, so any cached image may be invalid. The subsequent redraw
 	// should be treated as the very first draw.
 
+	_drawingHints |= THEME_HINT_FIRST_DRAW; 
 	Widget *w = _firstWidget;
 	while (w) {
 		w->setHints(THEME_HINT_FIRST_DRAW);
@@ -116,7 +118,8 @@
 	if (!isVisible())
 		return;
 
-	g_gui.theme()->drawDialogBackground(Common::Rect(_x, _y, _x+_w, _y+_h), Theme::kStateEnabled, _mainDialog);
+	g_gui.theme()->drawDialogBackground(Common::Rect(_x, _y, _x+_w, _y+_h), _drawingHints);
+	_drawingHints &= ~THEME_HINT_FIRST_DRAW;
 
 	// Draw all children
 	Widget *w = _firstWidget;

Index: dialog.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.h,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- dialog.h	27 Jan 2006 15:43:23 -0000	1.44
+++ dialog.h	28 Jan 2006 23:03:39 -0000	1.45
@@ -44,7 +44,7 @@
 	Widget  *_focusedWidget;
 	Widget  *_dragWidget;
 	bool	_visible;
-	bool	_mainDialog; // FIXME: find a better solution for this and change the Theme class to handle it then
+	uint16	_drawingHints;
 
 private:
 	int		_result;

Index: launcher.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/launcher.cpp,v
retrieving revision 1.134
retrieving revision 1.135
diff -u -d -r1.134 -r1.135
--- launcher.cpp	28 Jan 2006 00:22:02 -0000	1.134
+++ launcher.cpp	28 Jan 2006 23:03:39 -0000	1.135
@@ -181,6 +181,7 @@
 
 	// GUI:  Add tab widget
 	TabWidget *tab = new TabWidget(this, 0, vBorder, _w, _h - buttonHeight - 8 - 2 * vBorder, ws);
+	tab->setHints(THEME_HINT_FIRST_DRAW | THEME_HINT_SAVE_BACKGROUND);
 
 	//
 	// 1) The game tab
@@ -490,7 +491,7 @@
 
 LauncherDialog::LauncherDialog(GameDetector &detector)
 	: Dialog(0, 0, 320, 200), _detector(detector) {
-	_mainDialog = true;
+	_drawingHints |= THEME_HINT_MAIN_DIALOG;
 
 	const int screenW = g_system->getOverlayWidth();
 	const int screenH = g_system->getOverlayHeight();

Index: options.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/options.cpp,v
retrieving revision 1.101
retrieving revision 1.102
diff -u -d -r1.101 -r1.102
--- options.cpp	18 Jan 2006 17:39:36 -0000	1.101
+++ options.cpp	28 Jan 2006 23:03:39 -0000	1.102
@@ -515,6 +515,7 @@
 
 	// The tab widget
 	TabWidget *tab = new TabWidget(this, 0, vBorder, _w, _h - buttonHeight - 8 - 2 * vBorder, ws);
+	tab->setHints(THEME_HINT_FIRST_DRAW | THEME_HINT_SAVE_BACKGROUND);
 
 	//
 	// 1) The graphics tab

Index: theme.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/theme.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- theme.cpp	27 Jan 2006 23:13:51 -0000	1.3
+++ theme.cpp	28 Jan 2006 23:03:39 -0000	1.4
@@ -129,7 +129,7 @@
 	}
 }
 
-void ThemeClassic::drawDialogBackground(const Common::Rect &r, kState state, bool mainDialog) {
+void ThemeClassic::drawDialogBackground(const Common::Rect &r, uint16 hints, kState state) {
 	if (!_initOk)
 		return;
 

Index: theme.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/theme.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- theme.h	27 Jan 2006 19:04:15 -0000	1.2
+++ theme.h	28 Jan 2006 23:03:39 -0000	1.3
@@ -41,7 +41,13 @@
 	// Indicates that the widget will be redrawn often, e.g. list widgets.
 	// It may therefore be a good idea to save the background so that it
 	// can be redrawn quickly.
-	THEME_HINT_SAVE_BACKGROUND = 1 << 1
+	THEME_HINT_SAVE_BACKGROUND = 1 << 1,
+	
+	// Indicates that this is the launcher dialog (maybe delete this in the future)
+	THEME_HINT_MAIN_DIALOG = 1 << 2,
+	
+	// Indicates special colorfade
+	THEME_HINT_SPECIAL_COLOR = 1 << 3
 };
 
 class Theme {
@@ -101,7 +107,7 @@
 	virtual int getStringWidth(const Common::String &str) const = 0;
 	virtual int getCharWidth(byte c) const = 0;
 
-	virtual void drawDialogBackground(const Common::Rect &r, kState state = kStateEnabled, bool mainDialog = false) = 0;
+	virtual void drawDialogBackground(const Common::Rect &r, uint16 hints, kState state = kStateEnabled) = 0;
 	virtual void drawText(const Common::Rect &r, const Common::String &str, kState state = kStateEnabled, kTextAlign align = kTextAlignCenter, bool inverted = false, int deltax = 0, bool useEllipsis = true) = 0;
 	// this should ONLY be used by the debugger until we get a nicer solution
 	virtual void drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, kState state = kStateEnabled) = 0;
@@ -181,7 +187,7 @@
 	int getStringWidth(const Common::String &str) const { if (_initOk) return _font->getStringWidth(str); return 0; }
 	int getCharWidth(byte c) const { if (_initOk) return _font->getCharWidth(c); return 0; }
 
-	void drawDialogBackground(const Common::Rect &r, kState state, bool mainDialog);
+	void drawDialogBackground(const Common::Rect &r, uint16 hints, kState state);
 	void drawText(const Common::Rect &r, const Common::String &str, kState state, kTextAlign align, bool inverted, int deltax, bool useEllipsis);
 	void drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, kState state);
 
@@ -249,7 +255,7 @@
 	int getStringWidth(const Common::String &str) const { if (_font) return _font->getStringWidth(str); return 0; }
 	int getCharWidth(byte c) const { if (_font) return _font->getCharWidth(c); return 0; }
 
-	void drawDialogBackground(const Common::Rect &r, kState state, bool mainDialog);
+	void drawDialogBackground(const Common::Rect &r, uint16 hints, kState state);
 	void drawText(const Common::Rect &r, const Common::String &str, kState state, kTextAlign align, bool inverted, int deltax, bool useEllipsis);
 	void drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, kState state);
 

Index: widget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/widget.cpp,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- widget.cpp	27 Jan 2006 15:43:23 -0000	1.57
+++ widget.cpp	28 Jan 2006 23:03:39 -0000	1.58
@@ -33,6 +33,8 @@
 	// Insert into the widget list of the boss
 	_next = _boss->_firstWidget;
 	_boss->_firstWidget = this;
+	// HACK: we enable background saving for all widgets by default for now
+	_hints = THEME_HINT_FIRST_DRAW | THEME_HINT_SAVE_BACKGROUND;
 }
 
 Widget::~Widget() {





More information about the Scummvm-git-logs mailing list