diff options
author | Johannes Schickel | 2006-01-28 23:03:39 +0000 |
---|---|---|
committer | Johannes Schickel | 2006-01-28 23:03:39 +0000 |
commit | 5fda0cc6f1addedb4e3c671a9f124e6c5b253323 (patch) | |
tree | b869dc52a415e20e8eb5aed5704fe539216f5c2c /gui | |
parent | d84cefec75e8dfe6a33042c246a5f980829235a7 (diff) | |
download | scummvm-rg350-5fda0cc6f1addedb4e3c671a9f124e6c5b253323.tar.gz scummvm-rg350-5fda0cc6f1addedb4e3c671a9f124e6c5b253323.tar.bz2 scummvm-rg350-5fda0cc6f1addedb4e3c671a9f124e6c5b253323.zip |
- 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
svn-id: r20276
Diffstat (limited to 'gui')
-rw-r--r-- | gui/ThemeNew.cpp | 44 | ||||
-rw-r--r-- | gui/console.cpp | 8 | ||||
-rw-r--r-- | gui/dialog.cpp | 7 | ||||
-rw-r--r-- | gui/dialog.h | 2 | ||||
-rw-r--r-- | gui/launcher.cpp | 3 | ||||
-rw-r--r-- | gui/options.cpp | 1 | ||||
-rw-r--r-- | gui/theme.cpp | 2 | ||||
-rw-r--r-- | gui/theme.h | 14 | ||||
-rw-r--r-- | gui/widget.cpp | 2 |
9 files changed, 55 insertions, 28 deletions
diff --git a/gui/ThemeNew.cpp b/gui/ThemeNew.cpp index b5e043221b..a196487101 100644 --- a/gui/ThemeNew.cpp +++ b/gui/ThemeNew.cpp @@ -274,24 +274,32 @@ void ThemeNew::resetDrawArea() { #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 @@ void ThemeNew::drawWidgetBackground(const Common::Rect &r, uint16 hints, kWidget 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 @@ void ThemeNew::drawButton(const Common::Rect &r, const Common::String &str, kSta 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 @@ void ThemeNew::drawSlider(const Common::Rect &r, int width, kState state) { 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 @@ void ThemeNew::drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeigh 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 @@ void ThemeNew::drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeigh 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 @@ void ThemeNew::drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeigh 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 @@ void ThemeNew::drawCaret(const Common::Rect &r, bool erase, kState state) { 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 @@ inline uint8 calcGradient(uint8 start, uint8 end, int pos, int max) { } OverlayColor calcGradient(OverlayColor start, OverlayColor end, int pos, int max, uint factor = 1) { - pos *= factor; + max /= factor; if (pos > max) { pos = max; } diff --git a/gui/console.cpp b/gui/console.cpp index 57c374ddef..a2418772e2 100644 --- a/gui/console.cpp +++ b/gui/console.cpp @@ -104,6 +104,8 @@ ConsoleDialog::ConsoleDialog(float widthPercent, float heightPercent) // 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 @@ void ConsoleDialog::open() { // 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 @@ void ConsoleDialog::drawDialog() { 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 @@ void ConsoleDialog::handleTickle() { // 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)); diff --git a/gui/dialog.cpp b/gui/dialog.cpp index c6be54248d..93fdb43460 100644 --- a/gui/dialog.cpp +++ b/gui/dialog.cpp @@ -40,7 +40,8 @@ namespace GUI { 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 @@ void Dialog::handleScreenChanged() { // 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 @@ void Dialog::drawDialog() { 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; diff --git a/gui/dialog.h b/gui/dialog.h index 5170e7c9b2..f9a03d3f67 100644 --- a/gui/dialog.h +++ b/gui/dialog.h @@ -44,7 +44,7 @@ protected: 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; diff --git a/gui/launcher.cpp b/gui/launcher.cpp index 6fb9b0975d..af6cd71266 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -181,6 +181,7 @@ EditGameDialog::EditGameDialog(const String &domain, GameSettings target) // 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 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat 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(); diff --git a/gui/options.cpp b/gui/options.cpp index 628f6757a3..01745d33bd 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -515,6 +515,7 @@ GlobalOptionsDialog::GlobalOptionsDialog() // 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 diff --git a/gui/theme.cpp b/gui/theme.cpp index eacda895b9..7447e9c86f 100644 --- a/gui/theme.cpp +++ b/gui/theme.cpp @@ -129,7 +129,7 @@ void ThemeClassic::resetDrawArea() { } } -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; diff --git a/gui/theme.h b/gui/theme.h index 474e233f4f..f251e9888c 100644 --- a/gui/theme.h +++ b/gui/theme.h @@ -41,7 +41,13 @@ enum { // 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 @@ public: 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 @@ public: 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 @@ public: 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); diff --git a/gui/widget.cpp b/gui/widget.cpp index 6608c4fd57..4e7bf5adf6 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -33,6 +33,8 @@ Widget::Widget(GuiObject *boss, int x, int y, int w, int h) // 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() { |