From 956affd3d23cc8030775dc1a81984891a344d134 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 8 Feb 2007 23:25:07 +0000 Subject: Moved definition of ThemeClassic and ThemeModern to their own files. svn-id: r25432 --- gui/ThemeClassic.cpp | 2 +- gui/ThemeClassic.h | 124 ++++++++++++++++ gui/ThemeModern.cpp | 2 +- gui/ThemeModern.h | 337 +++++++++++++++++++++++++++++++++++++++++++ gui/newgui.cpp | 2 + gui/newgui.h | 1 + gui/theme.h | 398 --------------------------------------------------- 7 files changed, 466 insertions(+), 400 deletions(-) create mode 100644 gui/ThemeClassic.h create mode 100644 gui/ThemeModern.h (limited to 'gui') diff --git a/gui/ThemeClassic.cpp b/gui/ThemeClassic.cpp index 7faa5973f7..eb0da48ce2 100644 --- a/gui/ThemeClassic.cpp +++ b/gui/ThemeClassic.cpp @@ -19,7 +19,7 @@ * $Id$ */ -#include "gui/theme.h" +#include "gui/ThemeClassic.h" #include "gui/eval.h" namespace GUI { diff --git a/gui/ThemeClassic.h b/gui/ThemeClassic.h new file mode 100644 index 0000000000..df7ad7b2d6 --- /dev/null +++ b/gui/ThemeClassic.h @@ -0,0 +1,124 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2006 The ScummVM project + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + */ + +#ifndef GUI_THEMECLASSIC_H +#define GUI_THEMECLASSIC_H + +#include "gui/theme.h" + +namespace GUI { + +// enable this to disable transparency support for the classic theme +//#define CT_NO_TRANSPARENCY + +class ThemeClassic : public Theme { +public: + ThemeClassic(OSystem *system, const Common::String &config = "classic", const Common::ConfigFile *cfg = 0); + virtual ~ThemeClassic(); + + bool init(); + void deinit(); + + void refresh(); + + void enable(); + void disable(); + + void openDialog(bool topDialog); + void closeDialog(); + + void clearAll(); + void drawAll(); + + void resetDrawArea(); + + const Graphics::Font *getFont(FontStyle font) const { return _font; } + int getFontHeight(FontStyle font = kFontStyleBold) const { if (_initOk) return _font->getFontHeight(); return 0; } + int getStringWidth(const Common::String &str, FontStyle font) const { if (_initOk) return _font->getStringWidth(str); return 0; } + int getCharWidth(byte c, FontStyle font) const { if (_initOk) return _font->getCharWidth(c); return 0; } + + void drawDialogBackground(const Common::Rect &r, uint16 hints, State state); + void drawText(const Common::Rect &r, const Common::String &str, State state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font); + void drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, State state); + + void drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background, State state); + void drawButton(const Common::Rect &r, const Common::String &str, State state, uint16 hints); + void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, State state, int alpha, bool themeTrans); + void drawSlider(const Common::Rect &r, int width, State state); + void drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, State state); + void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array &tabs, int active, uint16 hints, int titleVPad, State state); + void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState, State state); + void drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, State state, TextAlign align); + void drawCaret(const Common::Rect &r, bool erase, State state); + void drawLineSeparator(const Common::Rect &r, State state); + void restoreBackground(Common::Rect r, bool special = false); + bool addDirtyRect(Common::Rect r, bool save = false, bool special = false); + + int getTabSpacing() const; + int getTabPadding() const; + +private: + void box(int x, int y, int width, int height, OverlayColor colorA, OverlayColor colorB, bool skipLastRow = false); + void box(int x, int y, int width, int height); + + OverlayColor getColor(State state); + + OSystem *_system; + Graphics::Surface _screen; + +#ifndef CT_NO_TRANSPARENCY + struct DialogState { + Graphics::Surface screen; + } *_dialog; + + void blendScreenToDialog(); +#endif + bool _enableBlending; + + bool _forceRedraw; + bool _initOk; + bool _enabled; + + Common::String _fontName; + const Graphics::Font *_font; + OverlayColor _color, _shadowcolor; + OverlayColor _bgcolor; + OverlayColor _textcolor; + OverlayColor _textcolorhi; + + enum { + kColor = 0, + kShadowColor = 1, + kBGColor = 2, + kTextColor = 3, + kTextColorHi = 4, + kMaxColors = 5 + }; + uint8 _colors[kMaxColors][3]; + + void setupConfig(); + bool loadConfig(); +}; + +} // end of namespace GUI + +#endif + diff --git a/gui/ThemeModern.cpp b/gui/ThemeModern.cpp index 6805604456..cfe3a963a8 100644 --- a/gui/ThemeModern.cpp +++ b/gui/ThemeModern.cpp @@ -21,7 +21,7 @@ #ifndef DISABLE_FANCY_THEMES -#include "gui/theme.h" +#include "gui/ThemeModern.h" #include "gui/eval.h" #include "graphics/imageman.h" diff --git a/gui/ThemeModern.h b/gui/ThemeModern.h new file mode 100644 index 0000000000..b83bec9425 --- /dev/null +++ b/gui/ThemeModern.h @@ -0,0 +1,337 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2006 The ScummVM project + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + */ + +#ifndef GUI_THEMEMODERN_H +#define GUI_THEMEMODERN_H + +#ifndef DISABLE_FANCY_THEMES + +#include "gui/theme.h" + +namespace GUI { + +class ThemeModern : public Theme { +public: + ThemeModern(OSystem *system, const Common::String &stylefile, const Common::ConfigFile *cfg = 0); + virtual ~ThemeModern(); + + bool init(); + void deinit(); + + void refresh(); + + bool ownCursor() { return _useCursor; } + + void enable(); + void disable(); + + void openDialog(bool topDialog); + void closeDialog(); + + void clearAll(); + void drawAll(); + + void setDrawArea(const Common::Rect &r); + void resetDrawArea(); + + const Graphics::Font *getFont(FontStyle font = kFontStyleBold) const { return _fonts[font]; } + int getFontHeight(FontStyle font = kFontStyleBold) const { if (_fonts[font]) return _fonts[font]->getFontHeight(); return 0; } + int getStringWidth(const Common::String &str, FontStyle font = kFontStyleBold) const { if (_fonts[font]) return _fonts[font]->getStringWidth(str); return 0; } + int getCharWidth(byte c, FontStyle font = kFontStyleBold) const { if (_fonts[font]) return _fonts[font]->getCharWidth(c); return 0; } + + void drawDialogBackground(const Common::Rect &r, uint16 hints, State state); + void drawText(const Common::Rect &r, const Common::String &str, State state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font); + void drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, State state); + + void drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background, State state); + void drawButton(const Common::Rect &r, const Common::String &str, State state, uint16 hints); + void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, State state, int alpha, bool themeTrans); + void drawSlider(const Common::Rect &r, int width, State state); + void drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, State state); + void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array &tabs, int active, uint16 hints, int titleVPad, State state); + void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState, State state); + void drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, State state, TextAlign align); + void drawCaret(const Common::Rect &r, bool erase, State state); + void drawLineSeparator(const Common::Rect &r, State state); + + void restoreBackground(Common::Rect r, bool special = false); + bool addDirtyRect(Common::Rect r, bool backup = false, bool special = false); + + int getTabSpacing() const; + int getTabPadding() const; + + bool supportsImages() const { return true; } + const Graphics::Surface *getImageSurface(const kThemeImages n) const { return n == kImageLogo ? _images[kThemeLogo] : 0; } +private: + void colorFade(const Common::Rect &r, OverlayColor start, OverlayColor end, uint factor = 1); + void drawRect(const Common::Rect &r, const Graphics::Surface *corner, const Graphics::Surface *top, + const Graphics::Surface *left, const Graphics::Surface *fill, int alpha, bool skipLastRow = false); + void drawRectMasked(const Common::Rect &r, const Graphics::Surface *corner, const Graphics::Surface *top, + const Graphics::Surface *left, const Graphics::Surface *fill, int alpha, + OverlayColor start, OverlayColor end, uint factor = 1, bool skipLastRow = false, bool skipTopRow = false); + void drawSurface(const Common::Rect &r, const Graphics::Surface *surf, bool upDown, bool leftRight, int alpha); + void drawSurfaceMasked(const Common::Rect &r, const Graphics::Surface *surf, bool upDown, bool leftRight, int alpha, + OverlayColor start, OverlayColor end, uint factor = 1); + + enum ShadowStyles { + kShadowFull = 0, + kShadowSmall = 1, + kShadowButton = 2, + kShadowEmboss = 3, + kShadowPopUp = 4 + }; + + Common::Rect shadowRect(const Common::Rect &r, uint32 shadowStyle); + void drawShadow(const Common::Rect &r, const Graphics::Surface *corner, const Graphics::Surface *top, + const Graphics::Surface *left, const Graphics::Surface *fill, uint32 shadowStyle, bool skipLastRow = false, + bool skipTopRow = false); + void drawShadowRect(const Common::Rect &r, const Common::Rect &area, const Graphics::Surface *corner, + const Graphics::Surface *top, const Graphics::Surface *left, const Graphics::Surface *fill, + int alpha, bool skipLastRow = false, bool skipTopRow = false); + + int _shadowLeftWidth, _shadowRightWidth; + int _shadowTopHeight, _shadowBottomHeight; + + OSystem *_system; + Graphics::Surface _screen; + Common::Rect _shadowDrawArea; + + bool _initOk; + bool _forceRedraw; + bool _enabled; + + int _lastUsedBitMask; + void resetupGuiRenderer(); + void setupColors(); + + OverlayColor getColor(State state); + + struct DialogState { + Graphics::Surface screen; + } *_dialog; + + void setupFonts(); + void deleteFonts(); + + void setupFont(const Common::String &key, const Common::String &name, FontStyle style); + + const Graphics::Font *_fonts[kFontStyleMax]; + +private: + void processExtraValues(); + + enum ImageHandles { + kDialogBkgdCorner = 0, + kDialogBkgdTop = 1, + kDialogBkgdLeft = 2, + kDialogBkgd = 3, + + kWidgetBkgdCorner = 4, + kWidgetBkgdTop = 5, + kWidgetBkgdLeft = 6, + kWidgetBkgd = 7, + + kCheckboxEmpty = 8, + kCheckboxChecked = 9, + + kWidgetArrow = 10, + + kTabBkgdCorner = 11, + kTabBkgdTop = 12, + kTabBkgdLeft = 13, + kTabBkgd = 14, + + kSliderBkgdCorner = 15, + kSliderBkgdTop = 16, + kSliderBkgdLeft = 17, + kSliderBkgd = 18, + + kSliderCorner = 19, + kSliderTop = 20, + kSliderLeft = 21, + kSlider = 22, + + kScrollbarBkgdCorner = 23, + kScrollbarBkgdTop = 24, + kScrollbarBkgdLeft = 25, + kScrollbarBkgd = 26, + + kScrollbarCorner = 27, + kScrollbarTop = 28, + kScrollbarLeft = 29, + kScrollbar = 30, + + kButtonBkgdCorner = 31, + kButtonBkgdTop = 32, + kButtonBkgdLeft = 33, + kButtonBkgd = 34, + + kWidgetSmallBkgdCorner = 35, + kWidgetSmallBkgdTop = 36, + kWidgetSmallBkgdLeft = 37, + kWidgetSmallBkgd = 38, + + kThemeLogo = 39, + + kPopUpWidgetBkgdCorner = 40, + kPopUpWidgetBkgdTop = 41, + kPopUpWidgetBkgdLeft = 42, + kPopUpWidgetBkgd = 43, + + kEditTextBkgdCorner = 44, + kEditTextBkgdTop = 45, + kEditTextBkgdLeft = 46, + kEditTextBkgd = 47, + + kGUICursor = 48, + + kImageHandlesMax + }; + +private: + int _dimPercentValue; + typedef OverlayColor (ThemeModern::*InactiveDialogCallback)(OverlayColor col); + InactiveDialogCallback _dialogShadingCallback; + + OverlayColor calcLuminance(OverlayColor col); + OverlayColor calcDimColor(OverlayColor col); + + bool _useCursor; + void setUpCursor(); + void createCursor(); + int _cursorHotspotX, _cursorHotspotY; + int _cursorTargetScale; +#define MAX_CURS_COLORS 255 + byte *_cursor; + bool _needPaletteUpdates; + uint _cursorWidth, _cursorHeight; + byte _cursorPal[4*MAX_CURS_COLORS]; + +private: + Common::String _imageHandles[kImageHandlesMax]; + const Graphics::Surface **_images; + + enum ColorHandles { + kMainDialogStart = 0, + kMainDialogEnd = 1, + + kDialogStart = 2, + kDialogEnd = 3, + + kColorStateDisabled = 4, + kColorStateHighlight = 5, + kColorStateEnabled = 6, + kColorTransparency = 7, + + kTextInvertedBackground = 8, + kTextInvertedColor = 9, + + kWidgetBackgroundStart = 10, + kWidgetBackgroundEnd = 11, + kWidgetBackgroundSmallStart = 12, + kWidgetBackgroundSmallEnd = 13, + + kButtonBackgroundStart = 14, + kButtonBackgroundEnd = 15, + kButtonTextEnabled = 16, + kButtonTextDisabled = 17, + kButtonTextHighlight = 18, + + kSliderBackgroundStart = 19, + kSliderBackgroundEnd = 20, + kSliderStart = 21, + kSliderEnd = 22, + + kTabBackgroundStart = 23, + kTabBackgroundEnd = 24, + + kScrollbarBackgroundStart = 25, + kScrollbarBackgroundEnd = 26, + kScrollbarButtonStart = 27, + kScrollbarButtonEnd = 28, + kScrollbarSliderStart = 29, + kScrollbarSliderEnd = 30, + + kCaretColor = 31, + + kSliderHighStart = 32, + kSliderHighEnd = 33, + + kButtonBackgroundHighlightStart = 34, + kButtonBackgroundHighlightEnd = 35, + + kScrollbarButtonHighlightStart = 36, + kScrollbarButtonHighlightEnd = 37, + kScrollbarSliderHighlightStart = 38, + kScrollbarSliderHighlightEnd = 39, + + kPopUpWidgetStart = 40, + kPopUpWidgetEnd = 41, + kPopUpWidgetHighlightStart = 42, + kPopUpWidgetHighlightEnd = 43, + + kEditTextBackgroundStart = 44, + kEditTextBackgroundEnd = 45, + + kTabActiveStart = 46, + kTabActiveEnd = 47, + kTabInactiveStart = 48, + kTabInactiveEnd = 49, + + kColorHandlesMax + }; + + OverlayColor _colors[kColorHandlesMax]; + + enum GradientFactors { + kMainDialogFactor = 0, + kDialogFactor = 1, + kDialogSpecialFactor = 2, + + kWidgetSmallFactor = 3, + kWidgetFactor = 4, + + kButtonFactor = 5, + + kSliderFactor = 6, + kSliderBackground = 7, + + kTabFactor = 7, + + kScrollbarFactor = 8, + kScrollbarBkgdFactor = 9, + + kPopUpWidgetFactor = 10, + + kEditTextFactor = 11, + + kMaxGradientFactors + }; + + uint _gradientFactors[kMaxGradientFactors]; +}; + +} // end of namespace GUI + +#endif + +#endif + diff --git a/gui/newgui.cpp b/gui/newgui.cpp index a7770df365..fd8a71efc9 100644 --- a/gui/newgui.cpp +++ b/gui/newgui.cpp @@ -27,6 +27,8 @@ #include "gui/newgui.h" #include "gui/dialog.h" #include "gui/eval.h" +#include "gui/ThemeModern.h" +#include "gui/ThemeClassic.h" #include "common/config-manager.h" diff --git a/gui/newgui.h b/gui/newgui.h index 9cf6902e8a..5a1c237475 100644 --- a/gui/newgui.h +++ b/gui/newgui.h @@ -28,6 +28,7 @@ #include "common/str.h" #include "graphics/fontman.h" #include "gui/theme.h" +#include "gui/widget.h" class OSystem; diff --git a/gui/theme.h b/gui/theme.h index 136eccd0a2..d049706b77 100644 --- a/gui/theme.h +++ b/gui/theme.h @@ -32,8 +32,6 @@ #include "graphics/surface.h" #include "graphics/fontman.h" -#include "gui/widget.h" - #define THEME_VERSION 19 namespace GUI { @@ -247,402 +245,6 @@ private: static const char *_defaultConfigINI; int _loadedThemeX, _loadedThemeY; }; - -// enable this to disable transparency support for the classic theme -//#define CT_NO_TRANSPARENCY - -class ThemeClassic : public Theme { -public: - ThemeClassic(OSystem *system, const Common::String &config = "classic", const Common::ConfigFile *cfg = 0); - virtual ~ThemeClassic(); - - bool init(); - void deinit(); - - void refresh(); - - void enable(); - void disable(); - - void openDialog(bool topDialog); - void closeDialog(); - - void clearAll(); - void drawAll(); - - void resetDrawArea(); - - const Graphics::Font *getFont(FontStyle font) const { return _font; } - int getFontHeight(FontStyle font = kFontStyleBold) const { if (_initOk) return _font->getFontHeight(); return 0; } - int getStringWidth(const Common::String &str, FontStyle font) const { if (_initOk) return _font->getStringWidth(str); return 0; } - int getCharWidth(byte c, FontStyle font) const { if (_initOk) return _font->getCharWidth(c); return 0; } - - void drawDialogBackground(const Common::Rect &r, uint16 hints, State state); - void drawText(const Common::Rect &r, const Common::String &str, State state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font); - void drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, State state); - - void drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background, State state); - void drawButton(const Common::Rect &r, const Common::String &str, State state, uint16 hints); - void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, State state, int alpha, bool themeTrans); - void drawSlider(const Common::Rect &r, int width, State state); - void drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, State state); - void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array &tabs, int active, uint16 hints, int titleVPad, State state); - void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState, State state); - void drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, State state, TextAlign align); - void drawCaret(const Common::Rect &r, bool erase, State state); - void drawLineSeparator(const Common::Rect &r, State state); - void restoreBackground(Common::Rect r, bool special = false); - bool addDirtyRect(Common::Rect r, bool save = false, bool special = false); - - int getTabSpacing() const; - int getTabPadding() const; - -private: - void box(int x, int y, int width, int height, OverlayColor colorA, OverlayColor colorB, bool skipLastRow = false); - void box(int x, int y, int width, int height); - - OverlayColor getColor(State state); - - OSystem *_system; - Graphics::Surface _screen; - -#ifndef CT_NO_TRANSPARENCY - struct DialogState { - Graphics::Surface screen; - } *_dialog; - - void blendScreenToDialog(); -#endif - bool _enableBlending; - - bool _forceRedraw; - bool _initOk; - bool _enabled; - - Common::String _fontName; - const Graphics::Font *_font; - OverlayColor _color, _shadowcolor; - OverlayColor _bgcolor; - OverlayColor _textcolor; - OverlayColor _textcolorhi; - - enum { - kColor = 0, - kShadowColor = 1, - kBGColor = 2, - kTextColor = 3, - kTextColorHi = 4, - kMaxColors = 5 - }; - uint8 _colors[kMaxColors][3]; - - void setupConfig(); - bool loadConfig(); -}; - -#ifndef DISABLE_FANCY_THEMES - -class ThemeModern : public Theme { -public: - ThemeModern(OSystem *system, const Common::String &stylefile, const Common::ConfigFile *cfg = 0); - virtual ~ThemeModern(); - - bool init(); - void deinit(); - - void refresh(); - - bool ownCursor() { return _useCursor; } - - void enable(); - void disable(); - - void openDialog(bool topDialog); - void closeDialog(); - - void clearAll(); - void drawAll(); - - void setDrawArea(const Common::Rect &r); - void resetDrawArea(); - - const Graphics::Font *getFont(FontStyle font = kFontStyleBold) const { return _fonts[font]; } - int getFontHeight(FontStyle font = kFontStyleBold) const { if (_fonts[font]) return _fonts[font]->getFontHeight(); return 0; } - int getStringWidth(const Common::String &str, FontStyle font = kFontStyleBold) const { if (_fonts[font]) return _fonts[font]->getStringWidth(str); return 0; } - int getCharWidth(byte c, FontStyle font = kFontStyleBold) const { if (_fonts[font]) return _fonts[font]->getCharWidth(c); return 0; } - - void drawDialogBackground(const Common::Rect &r, uint16 hints, State state); - void drawText(const Common::Rect &r, const Common::String &str, State state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font); - void drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, State state); - - void drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background, State state); - void drawButton(const Common::Rect &r, const Common::String &str, State state, uint16 hints); - void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, State state, int alpha, bool themeTrans); - void drawSlider(const Common::Rect &r, int width, State state); - void drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, State state); - void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array &tabs, int active, uint16 hints, int titleVPad, State state); - void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState, State state); - void drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, State state, TextAlign align); - void drawCaret(const Common::Rect &r, bool erase, State state); - void drawLineSeparator(const Common::Rect &r, State state); - - void restoreBackground(Common::Rect r, bool special = false); - bool addDirtyRect(Common::Rect r, bool backup = false, bool special = false); - - int getTabSpacing() const; - int getTabPadding() const; - - bool supportsImages() const { return true; } - const Graphics::Surface *getImageSurface(const kThemeImages n) const { return n == kImageLogo ? _images[kThemeLogo] : 0; } -private: - void colorFade(const Common::Rect &r, OverlayColor start, OverlayColor end, uint factor = 1); - void drawRect(const Common::Rect &r, const Graphics::Surface *corner, const Graphics::Surface *top, - const Graphics::Surface *left, const Graphics::Surface *fill, int alpha, bool skipLastRow = false); - void drawRectMasked(const Common::Rect &r, const Graphics::Surface *corner, const Graphics::Surface *top, - const Graphics::Surface *left, const Graphics::Surface *fill, int alpha, - OverlayColor start, OverlayColor end, uint factor = 1, bool skipLastRow = false, bool skipTopRow = false); - void drawSurface(const Common::Rect &r, const Graphics::Surface *surf, bool upDown, bool leftRight, int alpha); - void drawSurfaceMasked(const Common::Rect &r, const Graphics::Surface *surf, bool upDown, bool leftRight, int alpha, - OverlayColor start, OverlayColor end, uint factor = 1); - - enum ShadowStyles { - kShadowFull = 0, - kShadowSmall = 1, - kShadowButton = 2, - kShadowEmboss = 3, - kShadowPopUp = 4 - }; - - Common::Rect shadowRect(const Common::Rect &r, uint32 shadowStyle); - void drawShadow(const Common::Rect &r, const Graphics::Surface *corner, const Graphics::Surface *top, - const Graphics::Surface *left, const Graphics::Surface *fill, uint32 shadowStyle, bool skipLastRow = false, - bool skipTopRow = false); - void drawShadowRect(const Common::Rect &r, const Common::Rect &area, const Graphics::Surface *corner, - const Graphics::Surface *top, const Graphics::Surface *left, const Graphics::Surface *fill, - int alpha, bool skipLastRow = false, bool skipTopRow = false); - - int _shadowLeftWidth, _shadowRightWidth; - int _shadowTopHeight, _shadowBottomHeight; - - OSystem *_system; - Graphics::Surface _screen; - Common::Rect _shadowDrawArea; - - bool _initOk; - bool _forceRedraw; - bool _enabled; - - int _lastUsedBitMask; - void resetupGuiRenderer(); - void setupColors(); - - OverlayColor getColor(State state); - - struct DialogState { - Graphics::Surface screen; - } *_dialog; - - void setupFonts(); - void deleteFonts(); - - void setupFont(const Common::String &key, const Common::String &name, FontStyle style); - - const Graphics::Font *_fonts[kFontStyleMax]; - -private: - void processExtraValues(); - - enum ImageHandles { - kDialogBkgdCorner = 0, - kDialogBkgdTop = 1, - kDialogBkgdLeft = 2, - kDialogBkgd = 3, - - kWidgetBkgdCorner = 4, - kWidgetBkgdTop = 5, - kWidgetBkgdLeft = 6, - kWidgetBkgd = 7, - - kCheckboxEmpty = 8, - kCheckboxChecked = 9, - - kWidgetArrow = 10, - - kTabBkgdCorner = 11, - kTabBkgdTop = 12, - kTabBkgdLeft = 13, - kTabBkgd = 14, - - kSliderBkgdCorner = 15, - kSliderBkgdTop = 16, - kSliderBkgdLeft = 17, - kSliderBkgd = 18, - - kSliderCorner = 19, - kSliderTop = 20, - kSliderLeft = 21, - kSlider = 22, - - kScrollbarBkgdCorner = 23, - kScrollbarBkgdTop = 24, - kScrollbarBkgdLeft = 25, - kScrollbarBkgd = 26, - - kScrollbarCorner = 27, - kScrollbarTop = 28, - kScrollbarLeft = 29, - kScrollbar = 30, - - kButtonBkgdCorner = 31, - kButtonBkgdTop = 32, - kButtonBkgdLeft = 33, - kButtonBkgd = 34, - - kWidgetSmallBkgdCorner = 35, - kWidgetSmallBkgdTop = 36, - kWidgetSmallBkgdLeft = 37, - kWidgetSmallBkgd = 38, - - kThemeLogo = 39, - - kPopUpWidgetBkgdCorner = 40, - kPopUpWidgetBkgdTop = 41, - kPopUpWidgetBkgdLeft = 42, - kPopUpWidgetBkgd = 43, - - kEditTextBkgdCorner = 44, - kEditTextBkgdTop = 45, - kEditTextBkgdLeft = 46, - kEditTextBkgd = 47, - - kGUICursor = 48, - - kImageHandlesMax - }; - -private: - int _dimPercentValue; - typedef OverlayColor (ThemeModern::*InactiveDialogCallback)(OverlayColor col); - InactiveDialogCallback _dialogShadingCallback; - - OverlayColor calcLuminance(OverlayColor col); - OverlayColor calcDimColor(OverlayColor col); - - bool _useCursor; - void setUpCursor(); - void createCursor(); - int _cursorHotspotX, _cursorHotspotY; - int _cursorTargetScale; -#define MAX_CURS_COLORS 255 - byte *_cursor; - bool _needPaletteUpdates; - uint _cursorWidth, _cursorHeight; - byte _cursorPal[4*MAX_CURS_COLORS]; - -private: - Common::String _imageHandles[kImageHandlesMax]; - const Graphics::Surface **_images; - - enum ColorHandles { - kMainDialogStart = 0, - kMainDialogEnd = 1, - - kDialogStart = 2, - kDialogEnd = 3, - - kColorStateDisabled = 4, - kColorStateHighlight = 5, - kColorStateEnabled = 6, - kColorTransparency = 7, - - kTextInvertedBackground = 8, - kTextInvertedColor = 9, - - kWidgetBackgroundStart = 10, - kWidgetBackgroundEnd = 11, - kWidgetBackgroundSmallStart = 12, - kWidgetBackgroundSmallEnd = 13, - - kButtonBackgroundStart = 14, - kButtonBackgroundEnd = 15, - kButtonTextEnabled = 16, - kButtonTextDisabled = 17, - kButtonTextHighlight = 18, - - kSliderBackgroundStart = 19, - kSliderBackgroundEnd = 20, - kSliderStart = 21, - kSliderEnd = 22, - - kTabBackgroundStart = 23, - kTabBackgroundEnd = 24, - - kScrollbarBackgroundStart = 25, - kScrollbarBackgroundEnd = 26, - kScrollbarButtonStart = 27, - kScrollbarButtonEnd = 28, - kScrollbarSliderStart = 29, - kScrollbarSliderEnd = 30, - - kCaretColor = 31, - - kSliderHighStart = 32, - kSliderHighEnd = 33, - - kButtonBackgroundHighlightStart = 34, - kButtonBackgroundHighlightEnd = 35, - - kScrollbarButtonHighlightStart = 36, - kScrollbarButtonHighlightEnd = 37, - kScrollbarSliderHighlightStart = 38, - kScrollbarSliderHighlightEnd = 39, - - kPopUpWidgetStart = 40, - kPopUpWidgetEnd = 41, - kPopUpWidgetHighlightStart = 42, - kPopUpWidgetHighlightEnd = 43, - - kEditTextBackgroundStart = 44, - kEditTextBackgroundEnd = 45, - - kTabActiveStart = 46, - kTabActiveEnd = 47, - kTabInactiveStart = 48, - kTabInactiveEnd = 49, - - kColorHandlesMax - }; - - OverlayColor _colors[kColorHandlesMax]; - - enum GradientFactors { - kMainDialogFactor = 0, - kDialogFactor = 1, - kDialogSpecialFactor = 2, - - kWidgetSmallFactor = 3, - kWidgetFactor = 4, - - kButtonFactor = 5, - - kSliderFactor = 6, - kSliderBackground = 7, - - kTabFactor = 7, - - kScrollbarFactor = 8, - kScrollbarBkgdFactor = 9, - - kPopUpWidgetFactor = 10, - - kEditTextFactor = 11, - - kMaxGradientFactors - }; - - uint _gradientFactors[kMaxGradientFactors]; -}; -#endif // DISABLE_FANCY_THEMES } // end of namespace GUI #endif // GUI_THEME_H -- cgit v1.2.3