GUI: ThemeEngine.cpp/.h formatting fixes.

This commit is contained in:
Johannes Schickel 2011-04-03 15:04:20 +02:00
parent 407b9c9b2e
commit 28e6859a69
2 changed files with 205 additions and 203 deletions

View file

@ -69,18 +69,18 @@ struct WidgetDrawData {
/** Extra space that the widget occupies when it's drawn. /** Extra space that the widget occupies when it's drawn.
E.g. when taking into account rounded corners, drop shadows, etc E.g. when taking into account rounded corners, drop shadows, etc
Used when restoring the widget background */ Used when restoring the widget background */
uint16 _backgroundOffset; uint16 _backgroundOffset;
bool _buffer; bool _buffer;
/** /**
* Calculates the background threshold offset of a given DrawData item. * Calculates the background threshold offset of a given DrawData item.
* After fully loading all DrawSteps of a DrawData item, this function must be * After fully loading all DrawSteps of a DrawData item, this function must be
* called in order to calculate if such draw steps would be drawn outside of * called in order to calculate if such draw steps would be drawn outside of
* the actual widget drawing zone (e.g. shadows). If this is the case, a constant * the actual widget drawing zone (e.g. shadows). If this is the case, a constant
* value will be added when restoring the background of the widget. * value will be added when restoring the background of the widget.
*/ */
void calcBackgroundOffset(); void calcBackgroundOffset();
}; };
@ -114,8 +114,8 @@ protected:
class ThemeItemTextData : public ThemeItem { class ThemeItemTextData : public ThemeItem {
public: public:
ThemeItemTextData(ThemeEngine *engine, const TextDrawData *data, const TextColorData *color, const Common::Rect &area, const Common::String &text, ThemeItemTextData(ThemeEngine *engine, const TextDrawData *data, const TextColorData *color, const Common::Rect &area, const Common::String &text,
Graphics::TextAlign alignH, GUI::ThemeEngine::TextAlignVertical alignV, Graphics::TextAlign alignH, GUI::ThemeEngine::TextAlignVertical alignV,
bool ellipsis, bool restoreBg, int deltaX) : bool ellipsis, bool restoreBg, int deltaX) :
ThemeItem(engine, area), _data(data), _color(color), _text(text), _alignH(alignH), _alignV(alignV), ThemeItem(engine, area), _data(data), _color(color), _text(text), _alignH(alignH), _alignV(alignV),
_ellipsis(ellipsis), _restoreBg(restoreBg), _deltax(deltaX) {} _ellipsis(ellipsis), _restoreBg(restoreBg), _deltax(deltaX) {}
@ -147,71 +147,71 @@ protected:
/********************************************************** /**********************************************************
* Data definitions for theme engine elements * Data definitions for theme engine elements
*********************************************************/ *********************************************************/
struct DrawDataInfo { struct DrawDataInfo {
DrawData id; ///< The actual ID of the DrawData item. DrawData id; ///< The actual ID of the DrawData item.
const char *name; ///< The name of the DrawData item as it appears in the Theme Description files const char *name; ///< The name of the DrawData item as it appears in the Theme Description files
bool buffer; ///< Sets whether this item is buffered on the backbuffer or drawn directly to the screen. bool buffer; ///< Sets whether this item is buffered on the backbuffer or drawn directly to the screen.
DrawData parent; ///< Parent DrawData item, for items that overlay. E.g. kButtonIdle -> kButtonHover DrawData parent; ///< Parent DrawData item, for items that overlay. E.g. kButtonIdle -> kButtonHover
}; };
/** /**
* Default values for each DrawData item. * Default values for each DrawData item.
*/ */
static const DrawDataInfo kDrawDataDefaults[] = { static const DrawDataInfo kDrawDataDefaults[] = {
{kDDMainDialogBackground, "mainmenu_bg", true, kDDNone}, {kDDMainDialogBackground, "mainmenu_bg", true, kDDNone},
{kDDSpecialColorBackground, "special_bg", true, kDDNone}, {kDDSpecialColorBackground, "special_bg", true, kDDNone},
{kDDPlainColorBackground, "plain_bg", true, kDDNone}, {kDDPlainColorBackground, "plain_bg", true, kDDNone},
{kDDTooltipBackground, "tooltip_bg", true, kDDNone}, {kDDTooltipBackground, "tooltip_bg", true, kDDNone},
{kDDDefaultBackground, "default_bg", true, kDDNone}, {kDDDefaultBackground, "default_bg", true, kDDNone},
{kDDTextSelectionBackground, "text_selection", false, kDDNone}, {kDDTextSelectionBackground, "text_selection", false, kDDNone},
{kDDTextSelectionFocusBackground, "text_selection_focus", false, kDDNone}, {kDDTextSelectionFocusBackground, "text_selection_focus", false, kDDNone},
{kDDWidgetBackgroundDefault, "widget_default", true, kDDNone}, {kDDWidgetBackgroundDefault, "widget_default", true, kDDNone},
{kDDWidgetBackgroundSmall, "widget_small", true, kDDNone}, {kDDWidgetBackgroundSmall, "widget_small", true, kDDNone},
{kDDWidgetBackgroundEditText, "widget_textedit", true, kDDNone}, {kDDWidgetBackgroundEditText, "widget_textedit", true, kDDNone},
{kDDWidgetBackgroundSlider, "widget_slider", true, kDDNone}, {kDDWidgetBackgroundSlider, "widget_slider", true, kDDNone},
{kDDButtonIdle, "button_idle", true, kDDWidgetBackgroundSlider}, {kDDButtonIdle, "button_idle", true, kDDWidgetBackgroundSlider},
{kDDButtonHover, "button_hover", false, kDDButtonIdle}, {kDDButtonHover, "button_hover", false, kDDButtonIdle},
{kDDButtonDisabled, "button_disabled", true, kDDNone}, {kDDButtonDisabled, "button_disabled", true, kDDNone},
{kDDSliderFull, "slider_full", false, kDDNone}, {kDDSliderFull, "slider_full", false, kDDNone},
{kDDSliderHover, "slider_hover", false, kDDNone}, {kDDSliderHover, "slider_hover", false, kDDNone},
{kDDSliderDisabled, "slider_disabled", false, kDDNone}, {kDDSliderDisabled, "slider_disabled", false, kDDNone},
{kDDCheckboxDefault, "checkbox_default", true, kDDNone}, {kDDCheckboxDefault, "checkbox_default", true, kDDNone},
{kDDCheckboxDisabled, "checkbox_disabled", true, kDDNone}, {kDDCheckboxDisabled, "checkbox_disabled", true, kDDNone},
{kDDCheckboxSelected, "checkbox_selected", false, kDDCheckboxDefault}, {kDDCheckboxSelected, "checkbox_selected", false, kDDCheckboxDefault},
{kDDRadiobuttonDefault, "radiobutton_default", true, kDDNone}, {kDDRadiobuttonDefault, "radiobutton_default", true, kDDNone},
{kDDRadiobuttonDisabled, "radiobutton_disabled", true, kDDNone}, {kDDRadiobuttonDisabled, "radiobutton_disabled", true, kDDNone},
{kDDRadiobuttonSelected, "radiobutton_selected", false, kDDRadiobuttonDefault}, {kDDRadiobuttonSelected, "radiobutton_selected", false, kDDRadiobuttonDefault},
{kDDTabActive, "tab_active", false, kDDTabInactive}, {kDDTabActive, "tab_active", false, kDDTabInactive},
{kDDTabInactive, "tab_inactive", true, kDDNone}, {kDDTabInactive, "tab_inactive", true, kDDNone},
{kDDTabBackground, "tab_background", true, kDDNone}, {kDDTabBackground, "tab_background", true, kDDNone},
{kDDScrollbarBase, "scrollbar_base", true, kDDNone}, {kDDScrollbarBase, "scrollbar_base", true, kDDNone},
{kDDScrollbarButtonIdle, "scrollbar_button_idle", true, kDDNone}, {kDDScrollbarButtonIdle, "scrollbar_button_idle", true, kDDNone},
{kDDScrollbarButtonHover, "scrollbar_button_hover", false, kDDScrollbarButtonIdle}, {kDDScrollbarButtonHover, "scrollbar_button_hover", false, kDDScrollbarButtonIdle},
{kDDScrollbarHandleIdle, "scrollbar_handle_idle", false, kDDNone}, {kDDScrollbarHandleIdle, "scrollbar_handle_idle", false, kDDNone},
{kDDScrollbarHandleHover, "scrollbar_handle_hover", false, kDDScrollbarBase}, {kDDScrollbarHandleHover, "scrollbar_handle_hover", false, kDDScrollbarBase},
{kDDPopUpIdle, "popup_idle", true, kDDNone}, {kDDPopUpIdle, "popup_idle", true, kDDNone},
{kDDPopUpHover, "popup_hover", false, kDDPopUpIdle}, {kDDPopUpHover, "popup_hover", false, kDDPopUpIdle},
{kDDPopUpDisabled, "popup_disabled", true, kDDNone}, {kDDPopUpDisabled, "popup_disabled", true, kDDNone},
{kDDCaret, "caret", false, kDDNone}, {kDDCaret, "caret", false, kDDNone},
{kDDSeparator, "separator", true, kDDNone}, {kDDSeparator, "separator", true, kDDNone},
}; };
/********************************************************** /**********************************************************
* ThemeItem functions for drawing queues. * ThemeItem functions for drawing queues.
*********************************************************/ *********************************************************/
void ThemeItemDrawData::drawSelf(bool draw, bool restore) { void ThemeItemDrawData::drawSelf(bool draw, bool restore) {
@ -259,7 +259,7 @@ void ThemeItemBitmap::drawSelf(bool draw, bool restore) {
/********************************************************** /**********************************************************
* ThemeEngine class * ThemeEngine class
*********************************************************/ *********************************************************/
ThemeEngine::ThemeEngine(Common::String id, GraphicsMode mode) : ThemeEngine::ThemeEngine(Common::String id, GraphicsMode mode) :
_system(0), _vectorRenderer(0), _system(0), _vectorRenderer(0),
@ -326,7 +326,7 @@ ThemeEngine::~ThemeEngine() {
/********************************************************** /**********************************************************
* Rendering mode management * Rendering mode management
*********************************************************/ *********************************************************/
const ThemeEngine::Renderer ThemeEngine::_rendererModes[] = { const ThemeEngine::Renderer ThemeEngine::_rendererModes[] = {
{ _s("Disabled GFX"), _sc("Disabled GFX", "lowres"), "none", kGfxDisabled }, { _s("Disabled GFX"), _sc("Disabled GFX", "lowres"), "none", kGfxDisabled },
@ -368,7 +368,7 @@ const char *ThemeEngine::findModeConfigName(GraphicsMode mode) {
/********************************************************** /**********************************************************
* Theme setup/initialization * Theme setup/initialization
*********************************************************/ *********************************************************/
bool ThemeEngine::init() { bool ThemeEngine::init() {
// reset everything and reload the graphics // reset everything and reload the graphics
@ -512,7 +512,7 @@ void ThemeEngine::setGraphicsMode(GraphicsMode mode) {
void WidgetDrawData::calcBackgroundOffset() { void WidgetDrawData::calcBackgroundOffset() {
uint maxShadow = 0; uint maxShadow = 0;
for (Common::List<Graphics::DrawStep>::const_iterator step = _steps.begin(); for (Common::List<Graphics::DrawStep>::const_iterator step = _steps.begin();
step != _steps.end(); ++step) { step != _steps.end(); ++step) {
if ((step->autoWidth || step->autoHeight) && step->shadow > maxShadow) if ((step->autoWidth || step->autoHeight) && step->shadow > maxShadow)
maxShadow = step->shadow; maxShadow = step->shadow;
@ -531,7 +531,7 @@ void ThemeEngine::restoreBackground(Common::Rect r) {
/********************************************************** /**********************************************************
* Theme elements management * Theme elements management
*********************************************************/ *********************************************************/
void ThemeEngine::addDrawStep(const Common::String &drawDataId, const Graphics::DrawStep &step) { void ThemeEngine::addDrawStep(const Common::String &drawDataId, const Graphics::DrawStep &step) {
DrawData id = parseDrawDataId(drawDataId); DrawData id = parseDrawDataId(drawDataId);
@ -659,7 +659,7 @@ bool ThemeEngine::addDrawData(const Common::String &data, bool cached) {
/********************************************************** /**********************************************************
* Theme XML loading * Theme XML loading
*********************************************************/ *********************************************************/
void ThemeEngine::loadTheme(const Common::String &themeId) { void ThemeEngine::loadTheme(const Common::String &themeId) {
unloadTheme(); unloadTheme();
@ -717,9 +717,9 @@ bool ThemeEngine::loadDefaultXML() {
#ifndef DISABLE_GUI_BUILTIN_THEME #ifndef DISABLE_GUI_BUILTIN_THEME
const char *defaultXML = const char *defaultXML =
#include "themes/default.inc" #include "themes/default.inc"
; ;
if (!_parser->loadBuffer((const byte*)defaultXML, strlen(defaultXML))) if (!_parser->loadBuffer((const byte *)defaultXML, strlen(defaultXML)))
return false; return false;
_themeName = "ScummVM Classic Theme (Builtin Version)"; _themeName = "ScummVM Classic Theme (Builtin Version)";
@ -793,7 +793,7 @@ bool ThemeEngine::loadThemeXML(const Common::String &themeId) {
/********************************************************** /**********************************************************
* Drawing Queue management * Drawing Queue management
*********************************************************/ *********************************************************/
void ThemeEngine::queueDD(DrawData type, const Common::Rect &r, uint32 dynamic, bool restore) { void ThemeEngine::queueDD(DrawData type, const Common::Rect &r, uint32 dynamic, bool restore) {
if (_widgets[type] == 0) if (_widgets[type] == 0)
@ -820,7 +820,7 @@ void ThemeEngine::queueDD(DrawData type, const Common::Rect &r, uint32 dynamic,
} }
void ThemeEngine::queueDDText(TextData type, TextColor color, const Common::Rect &r, const Common::String &text, bool restoreBg, void ThemeEngine::queueDDText(TextData type, TextColor color, const Common::Rect &r, const Common::String &text, bool restoreBg,
bool ellipsis, Graphics::TextAlign alignH, TextAlignVertical alignV, int deltax) { bool ellipsis, Graphics::TextAlign alignH, TextAlignVertical alignV, int deltax) {
if (_texts[type] == 0) if (_texts[type] == 0)
return; return;
@ -856,7 +856,7 @@ void ThemeEngine::queueBitmap(const Graphics::Surface *bitmap, const Common::Rec
/********************************************************** /**********************************************************
* Widget drawing functions * Widget drawing functions
*********************************************************/ *********************************************************/
void ThemeEngine::drawButton(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, uint16 hints) { void ThemeEngine::drawButton(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, uint16 hints) {
if (!ready()) if (!ready())
@ -1088,7 +1088,7 @@ void ThemeEngine::drawTab(const Common::Rect &r, int tabHeight, int tabWidth, co
} }
if (active >= 0 && if (active >= 0 &&
(r.left + active * tabWidth < r.right) && (r.left + (active + 1) * tabWidth < r.right)) { (r.left + active * tabWidth < r.right) && (r.left + (active + 1) * tabWidth < r.right)) {
Common::Rect tabRect(r.left + active * tabWidth, r.top, r.left + (active + 1) * tabWidth, r.top + tabHeight); Common::Rect tabRect(r.left + active * tabWidth, r.top, r.left + (active + 1) * tabWidth, r.top + tabHeight);
const uint16 tabLeft = active * tabWidth; const uint16 tabLeft = active * tabWidth;
const uint16 tabRight = MAX(r.right - tabRect.right, 0); const uint16 tabRight = MAX(r.right - tabRect.right, 0);
@ -1191,25 +1191,25 @@ void ThemeEngine::debugWidgetPosition(const char *name, const Common::Rect &r) {
} }
/********************************************************** /**********************************************************
* Screen/overlay management * Screen/overlay management
*********************************************************/ *********************************************************/
void ThemeEngine::updateScreen(bool render) { void ThemeEngine::updateScreen(bool render) {
if (!_bufferQueue.empty()) { if (!_bufferQueue.empty()) {
_vectorRenderer->setSurface(&_backBuffer); _vectorRenderer->setSurface(&_backBuffer);
for (Common::List<ThemeItem*>::iterator q = _bufferQueue.begin(); q != _bufferQueue.end(); ++q) { for (Common::List<ThemeItem *>::iterator q = _bufferQueue.begin(); q != _bufferQueue.end(); ++q) {
(*q)->drawSelf(true, false); (*q)->drawSelf(true, false);
delete *q; delete *q;
} }
_vectorRenderer->setSurface(&_screen); _vectorRenderer->setSurface(&_screen);
memcpy(_screen.getBasePtr(0,0), _backBuffer.getBasePtr(0,0), _screen.pitch * _screen.h); memcpy(_screen.getBasePtr(0, 0), _backBuffer.getBasePtr(0, 0), _screen.pitch * _screen.h);
_bufferQueue.clear(); _bufferQueue.clear();
} }
if (!_screenQueue.empty()) { if (!_screenQueue.empty()) {
_vectorRenderer->disableShadows(); _vectorRenderer->disableShadows();
for (Common::List<ThemeItem*>::iterator q = _screenQueue.begin(); q != _screenQueue.end(); ++q) { for (Common::List<ThemeItem *>::iterator q = _screenQueue.begin(); q != _screenQueue.end(); ++q) {
(*q)->drawSelf(true, false); (*q)->drawSelf(true, false);
delete *q; delete *q;
} }
@ -1232,7 +1232,7 @@ void ThemeEngine::addDirtyRect(Common::Rect r) {
// Check if the new rectangle is contained within another in the list // Check if the new rectangle is contained within another in the list
Common::List<Common::Rect>::iterator it; Common::List<Common::Rect>::iterator it;
for (it = _dirtyScreen.begin(); it != _dirtyScreen.end(); ) { for (it = _dirtyScreen.begin(); it != _dirtyScreen.end();) {
// If we find a rectangle which fully contains the new one, // If we find a rectangle which fully contains the new one,
// we can abort the search. // we can abort the search.
if (it->contains(r)) if (it->contains(r))
@ -1271,7 +1271,7 @@ void ThemeEngine::openDialog(bool doBuffer, ShadingStyle style) {
addDirtyRect(Common::Rect(0, 0, _screen.w, _screen.h)); addDirtyRect(Common::Rect(0, 0, _screen.w, _screen.h));
} }
memcpy(_backBuffer.getBasePtr(0,0), _screen.getBasePtr(0,0), _screen.pitch * _screen.h); memcpy(_backBuffer.getBasePtr(0, 0), _screen.getBasePtr(0, 0), _screen.pitch * _screen.h);
_vectorRenderer->setSurface(&_screen); _vectorRenderer->setSurface(&_screen);
} }
@ -1310,8 +1310,8 @@ bool ThemeEngine::createCursor(const Common::String &filename, int hotspotX, int
// Now, scan the bitmap. We have to convert it from 16 bit color mode // Now, scan the bitmap. We have to convert it from 16 bit color mode
// to 8 bit mode, and have to create a suitable palette on the fly. // to 8 bit mode, and have to create a suitable palette on the fly.
uint colorsFound = 0; uint colorsFound = 0;
Common::HashMap<int, int> colorToIndex; Common::HashMap<int, int> colorToIndex;
const OverlayColor *src = (const OverlayColor*)cursor->pixels; const OverlayColor *src = (const OverlayColor *)cursor->pixels;
for (uint y = 0; y < _cursorHeight; ++y) { for (uint y = 0; y < _cursorHeight; ++y) {
for (uint x = 0; x < _cursorWidth; ++x) { for (uint x = 0; x < _cursorWidth; ++x) {
byte r, g, b; byte r, g, b;
@ -1353,7 +1353,7 @@ bool ThemeEngine::createCursor(const Common::String &filename, int hotspotX, int
/********************************************************** /**********************************************************
* Legacy GUI::Theme support functions * Legacy GUI::Theme support functions
*********************************************************/ *********************************************************/
const Graphics::Font *ThemeEngine::getFont(FontStyle font) const { const Graphics::Font *ThemeEngine::getFont(FontStyle font) const {
@ -1389,7 +1389,7 @@ DrawData ThemeEngine::parseDrawDataId(const Common::String &name) const {
} }
/********************************************************** /**********************************************************
* External data loading * External data loading
*********************************************************/ *********************************************************/
const Graphics::Font *ThemeEngine::loadFontFromArchive(const Common::String &filename) { const Graphics::Font *ThemeEngine::loadFontFromArchive(const Common::String &filename) {
@ -1498,7 +1498,7 @@ Common::String ThemeEngine::genLocalizedFontFilename(const Common::String &filen
/********************************************************** /**********************************************************
* Static Theme XML functions * Static Theme XML functions
*********************************************************/ *********************************************************/
bool ThemeEngine::themeConfigParseHeader(Common::String header, Common::String &themeName) { bool ThemeEngine::themeConfigParseHeader(Common::String header, Common::String &themeName) {
@ -1584,7 +1584,9 @@ struct TDComparator {
const Common::String _id; const Common::String _id;
TDComparator(const Common::String &id) : _id(id) {} TDComparator(const Common::String &id) : _id(id) {}
bool operator()(const ThemeEngine::ThemeDescriptor &r) { return _id == r.id; } bool operator()(const ThemeEngine::ThemeDescriptor &r) {
return _id == r.id;
}
}; };
} // end of anonymous namespace } // end of anonymous namespace
@ -1626,7 +1628,7 @@ void ThemeEngine::listUsableThemes(Common::Archive &archive, Common::List<ThemeD
Common::ArchiveMemberList fileList; Common::ArchiveMemberList fileList;
archive.listMatchingMembers(fileList, "*.zip"); archive.listMatchingMembers(fileList, "*.zip");
for (Common::ArchiveMemberList::iterator i = fileList.begin(); for (Common::ArchiveMemberList::iterator i = fileList.begin();
i != fileList.end(); ++i) { i != fileList.end(); ++i) {
td.name.clear(); td.name.clear();
if (themeConfigUsable(**i, td.name)) { if (themeConfigUsable(**i, td.name)) {
td.filename = (*i)->getName(); td.filename = (*i)->getName();

View file

@ -35,8 +35,8 @@
#define SCUMMVM_THEME_VERSION_STR "SCUMMVM_STX0.8.3" #define SCUMMVM_THEME_VERSION_STR "SCUMMVM_STX0.8.3"
namespace Graphics { namespace Graphics {
struct DrawStep; struct DrawStep;
class VectorRenderer; class VectorRenderer;
} }
namespace GUI { namespace GUI {
@ -53,9 +53,9 @@ class ThemeItem;
class ThemeParser; class ThemeParser;
/** /**
* DrawData sets enumeration. * DrawData sets enumeration.
* Each DD set corresponds to the actual looks * Each DD set corresponds to the actual looks
* of a widget in a given state. * of a widget in a given state.
*/ */
enum DrawData { enum DrawData {
kDDMainDialogBackground, kDDMainDialogBackground,
@ -134,7 +134,7 @@ enum TextColor {
class ThemeEngine { class ThemeEngine {
protected: protected:
typedef Common::HashMap<Common::String, Graphics::Surface*> ImagesMap; typedef Common::HashMap<Common::String, Graphics::Surface *> ImagesMap;
friend class GUI::Dialog; friend class GUI::Dialog;
friend class GUI::GuiObject; friend class GUI::GuiObject;
@ -150,12 +150,12 @@ public:
/// Widget background type /// Widget background type
enum WidgetBackground { enum WidgetBackground {
kWidgetBackgroundNo, ///< No background at all kWidgetBackgroundNo, ///< No background at all
kWidgetBackgroundPlain, ///< Simple background, this may not include borders kWidgetBackgroundPlain, ///< Simple background, this may not include borders
kWidgetBackgroundBorder, ///< Same as kWidgetBackgroundPlain just with a border kWidgetBackgroundBorder, ///< Same as kWidgetBackgroundPlain just with a border
kWidgetBackgroundBorderSmall, ///< Same as kWidgetBackgroundPlain just with a small border kWidgetBackgroundBorderSmall, ///< Same as kWidgetBackgroundPlain just with a small border
kWidgetBackgroundEditText, ///< Background used for edit text fields kWidgetBackgroundEditText, ///< Background used for edit text fields
kWidgetBackgroundSlider ///< Background used for sliders kWidgetBackgroundSlider ///< Background used for sliders
}; };
/// Dialog background type /// Dialog background type
@ -169,18 +169,18 @@ public:
/// State of the widget to be drawn /// State of the widget to be drawn
enum State { enum State {
kStateDisabled, ///< Indicates that the widget is disabled, that does NOT include that it is invisible kStateDisabled, ///< Indicates that the widget is disabled, that does NOT include that it is invisible
kStateEnabled, ///< Indicates that the widget is enabled kStateEnabled, ///< Indicates that the widget is enabled
kStateHighlight ///< Indicates that the widget is highlighted by the user kStateHighlight ///< Indicates that the widget is highlighted by the user
}; };
typedef State WidgetStateInfo; typedef State WidgetStateInfo;
/// Text inversion state of the text to be draw /// Text inversion state of the text to be draw
enum TextInversionState { enum TextInversionState {
kTextInversionNone, ///< Indicates that the text should not be drawn inverted kTextInversionNone, ///< Indicates that the text should not be drawn inverted
kTextInversion, ///< Indicates that the text should be drawn inverted, but not focused kTextInversion, ///< Indicates that the text should be drawn inverted, but not focused
kTextInversionFocus ///< Indicates that the text should be drawn inverted, and focused kTextInversionFocus ///< Indicates that the text should be drawn inverted, and focused
}; };
enum ScrollbarState { enum ScrollbarState {
@ -193,34 +193,34 @@ public:
/// Font style selector /// Font style selector
enum FontStyle { enum FontStyle {
kFontStyleBold = 0, ///< A bold font. This is also the default font. kFontStyleBold = 0, ///< A bold font. This is also the default font.
kFontStyleNormal = 1, ///< A normal font. kFontStyleNormal = 1, ///< A normal font.
kFontStyleItalic = 2, ///< Italic styled font. kFontStyleItalic = 2, ///< Italic styled font.
kFontStyleFixedNormal = 3, ///< Fixed size font. kFontStyleFixedNormal = 3, ///< Fixed size font.
kFontStyleFixedBold = 4, ///< Fixed size bold font. kFontStyleFixedBold = 4, ///< Fixed size bold font.
kFontStyleFixedItalic = 5, ///< Fixed size italic font. kFontStyleFixedItalic = 5, ///< Fixed size italic font.
kFontStyleTooltip = 6, ///< Tiny console font kFontStyleTooltip = 6, ///< Tiny console font
kFontStyleMax kFontStyleMax
}; };
/// Font color selector /// Font color selector
enum FontColor { enum FontColor {
kFontColorNormal = 0, ///< The default color of the theme kFontColorNormal = 0, ///< The default color of the theme
kFontColorAlternate = 1, ///< Alternative font color kFontColorAlternate = 1, ///< Alternative font color
kFontColorMax kFontColorMax
}; };
/// Function used to process areas other than the current dialog /// Function used to process areas other than the current dialog
enum ShadingStyle { enum ShadingStyle {
kShadingNone, ///< No special post processing kShadingNone, ///< No special post processing
kShadingDim, ///< Dimming unused areas kShadingDim, ///< Dimming unused areas
kShadingLuminance ///< Converting colors to luminance for unused areas kShadingLuminance ///< Converting colors to luminance for unused areas
}; };
// Special image ids for images used in the GUI // Special image ids for images used in the GUI
static const char * const kImageLogo; ///< ScummVM logo used in the launcher static const char *const kImageLogo; ///< ScummVM logo used in the launcher
static const char * const kImageLogoSmall; ///< ScummVM logo used in the GMM static const char *const kImageLogoSmall; ///< ScummVM logo used in the GMM
static const char * const kImageSearch; ///< Search tool image used in the launcher static const char *const kImageSearch; ///< Search tool image used in the launcher
/** /**
* Graphics mode enumeration. * Graphics mode enumeration.
@ -228,9 +228,9 @@ public:
* surface. * surface.
*/ */
enum GraphicsMode { enum GraphicsMode {
kGfxDisabled = 0, ///< No GFX kGfxDisabled = 0, ///< No GFX
kGfxStandard16bit, ///< 2BPP with the standard (aliased) renderer. kGfxStandard16bit, ///< 2BPP with the standard (aliased) renderer.
kGfxAntialias16bit ///< 2BPP with the optimized AA renderer. kGfxAntialias16bit ///< 2BPP with the optimized AA renderer.
}; };
/** Constant value to expand dirty rectangles, to make sure they are fully copied */ /** Constant value to expand dirty rectangles, to make sure they are fully copied */
@ -265,20 +265,20 @@ public:
void disable(); void disable();
/** /**
* Implementation of the GUI::Theme API. Called when a * Implementation of the GUI::Theme API. Called when a
* new dialog is opened. Note that the boolean parameter * new dialog is opened. Note that the boolean parameter
* meaning has been changed. * meaning has been changed.
* *
* @param enableBuffering If set to true, buffering is enabled for * @param enableBuffering If set to true, buffering is enabled for
* drawing this dialog, and will continue enabled * drawing this dialog, and will continue enabled
* until disabled. * until disabled.
*/ */
void openDialog(bool enableBuffering, ShadingStyle shading = kShadingNone); void openDialog(bool enableBuffering, ShadingStyle shading = kShadingNone);
/** /**
* The updateScreen() method is called every frame. * The updateScreen() method is called every frame.
* It processes all the drawing queues and then copies dirty rects * It processes all the drawing queues and then copies dirty rects
* in the current Screen surface to the overlay. * in the current Screen surface to the overlay.
*/ */
void updateScreen(bool render = true); void updateScreen(bool render = true);
@ -309,35 +309,35 @@ public:
//@{ //@{
void drawWidgetBackground(const Common::Rect &r, uint16 hints, void drawWidgetBackground(const Common::Rect &r, uint16 hints,
WidgetBackground background = kWidgetBackgroundPlain, WidgetStateInfo state = kStateEnabled); WidgetBackground background = kWidgetBackgroundPlain, WidgetStateInfo state = kStateEnabled);
void drawButton(const Common::Rect &r, const Common::String &str, void drawButton(const Common::Rect &r, const Common::String &str,
WidgetStateInfo state = kStateEnabled, uint16 hints = 0); WidgetStateInfo state = kStateEnabled, uint16 hints = 0);
void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, void drawSurface(const Common::Rect &r, const Graphics::Surface &surface,
WidgetStateInfo state = kStateEnabled, int alpha = 256, bool themeTrans = false); WidgetStateInfo state = kStateEnabled, int alpha = 256, bool themeTrans = false);
void drawSlider(const Common::Rect &r, int width, void drawSlider(const Common::Rect &r, int width,
WidgetStateInfo state = kStateEnabled); WidgetStateInfo state = kStateEnabled);
void drawCheckbox(const Common::Rect &r, const Common::String &str, void drawCheckbox(const Common::Rect &r, const Common::String &str,
bool checked, WidgetStateInfo state = kStateEnabled); bool checked, WidgetStateInfo state = kStateEnabled);
void drawRadiobutton(const Common::Rect &r, const Common::String &str, void drawRadiobutton(const Common::Rect &r, const Common::String &str,
bool checked, WidgetStateInfo state = kStateEnabled); bool checked, WidgetStateInfo state = kStateEnabled);
void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, void drawTab(const Common::Rect &r, int tabHeight, int tabWidth,
const Common::Array<Common::String> &tabs, int active, uint16 hints, const Common::Array<Common::String> &tabs, int active, uint16 hints,
int titleVPad, WidgetStateInfo state = kStateEnabled); int titleVPad, WidgetStateInfo state = kStateEnabled);
void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight,
ScrollbarState, WidgetStateInfo state = kStateEnabled); ScrollbarState, WidgetStateInfo state = kStateEnabled);
void drawPopUpWidget(const Common::Rect &r, const Common::String &sel, void drawPopUpWidget(const Common::Rect &r, const Common::String &sel,
int deltax, WidgetStateInfo state = kStateEnabled, Graphics::TextAlign align = Graphics::kTextAlignLeft); int deltax, WidgetStateInfo state = kStateEnabled, Graphics::TextAlign align = Graphics::kTextAlignLeft);
void drawCaret(const Common::Rect &r, bool erase, void drawCaret(const Common::Rect &r, bool erase,
WidgetStateInfo state = kStateEnabled); WidgetStateInfo state = kStateEnabled);
void drawLineSeparator(const Common::Rect &r, WidgetStateInfo state = kStateEnabled); void drawLineSeparator(const Common::Rect &r, WidgetStateInfo state = kStateEnabled);
@ -362,13 +362,13 @@ public:
/** /**
* Returns the DrawData enumeration value that represents the given string * Returns the DrawData enumeration value that represents the given string
* in the DrawDataDefaults enumeration. * in the DrawDataDefaults enumeration.
* It's slow, but called sparsely. * It's slow, but called sparsely.
* *
* @returns The drawdata enum value, or -1 if not found. * @returns The drawdata enum value, or -1 if not found.
* @param name The representing name, as found on Theme Description XML files. * @param name The representing name, as found on Theme Description XML files.
* @see kDrawDataDefaults[] * @see kDrawDataDefaults[]
*/ */
DrawData parseDrawDataId(const Common::String &name) const; DrawData parseDrawDataId(const Common::String &name) const;
@ -377,34 +377,34 @@ public:
/** /**
* Interface for ThemeParser class: Parsed DrawSteps are added via this function. * Interface for ThemeParser class: Parsed DrawSteps are added via this function.
* There is no return type because DrawSteps can always be added, unless something * There is no return type because DrawSteps can always be added, unless something
* goes horribly wrong. * goes horribly wrong.
* The specified step will be added to the Steps list of the given DrawData id. * The specified step will be added to the Steps list of the given DrawData id.
* *
* @param drawDataId The representing DrawData name, as found on Theme Description XML files. * @param drawDataId The representing DrawData name, as found on Theme Description XML files.
* @param step The actual DrawStep struct to be added. * @param step The actual DrawStep struct to be added.
*/ */
void addDrawStep(const Common::String &drawDataId, const Graphics::DrawStep &step); void addDrawStep(const Common::String &drawDataId, const Graphics::DrawStep &step);
/** /**
* Interface for the ThemeParser class: Parsed DrawData sets are added via this function. * Interface for the ThemeParser class: Parsed DrawData sets are added via this function.
* The goal of the function is to initialize each DrawData set before their DrawSteps can * The goal of the function is to initialize each DrawData set before their DrawSteps can
* be added, hence this must be called for each DD set before addDrawStep() can be called * be added, hence this must be called for each DD set before addDrawStep() can be called
* for that given set. * for that given set.
* *
* @param data The representing DrawData name, as found on Theme Description XML files. * @param data The representing DrawData name, as found on Theme Description XML files.
* @param cached Whether this DD set will be cached beforehand. * @param cached Whether this DD set will be cached beforehand.
*/ */
bool addDrawData(const Common::String &data, bool cached); bool addDrawData(const Common::String &data, bool cached);
/** /**
* Interface for the ThemeParser class: Loads a font to use on the GUI from the given * Interface for the ThemeParser class: Loads a font to use on the GUI from the given
* filename. * filename.
* *
* @param fontName Identifier name for the font. * @param fontName Identifier name for the font.
* @param file Name of the font file. * @param file Name of the font file.
*/ */
bool addFont(TextData textId, const Common::String &file); bool addFont(TextData textId, const Common::String &file);
@ -418,25 +418,25 @@ public:
/** /**
* Interface for the ThemeParser class: Loads a bitmap file to use on the GUI. * Interface for the ThemeParser class: Loads a bitmap file to use on the GUI.
* The filename is also used as its identifier. * The filename is also used as its identifier.
* *
* @param filename Name of the bitmap file. * @param filename Name of the bitmap file.
*/ */
bool addBitmap(const Common::String &filename); bool addBitmap(const Common::String &filename);
/** /**
* Adds a new TextStep from the ThemeParser. This will be deprecated/removed once the * Adds a new TextStep from the ThemeParser. This will be deprecated/removed once the
* new Font API is in place. FIXME: Is that so ??? * new Font API is in place. FIXME: Is that so ???
*/ */
bool addTextData(const Common::String &drawDataId, TextData textId, TextColor id, Graphics::TextAlign alignH, TextAlignVertical alignV); bool addTextData(const Common::String &drawDataId, TextData textId, TextColor id, Graphics::TextAlign alignH, TextAlignVertical alignV);
protected: protected:
/** /**
* Returns if the Theme is ready to draw stuff on screen. * Returns if the Theme is ready to draw stuff on screen.
* Must be called instead of just checking _initOk, because * Must be called instead of just checking _initOk, because
* this checks if the renderer is initialized AND if the theme * this checks if the renderer is initialized AND if the theme
* is loaded. * is loaded.
*/ */
bool ready() const { bool ready() const {
return _initOk && _themeOk; return _initOk && _themeOk;
@ -446,15 +446,15 @@ protected:
void loadTheme(const Common::String &themeid); void loadTheme(const Common::String &themeid);
/** /**
* Changes the active graphics mode of the GUI; may be used to either * Changes the active graphics mode of the GUI; may be used to either
* initialize the GUI or to change the mode while the GUI is already running. * initialize the GUI or to change the mode while the GUI is already running.
*/ */
void setGraphicsMode(GraphicsMode mode); void setGraphicsMode(GraphicsMode mode);
public: public:
/** /**
* Finishes buffering: widgets from then on will be drawn straight on the screen * Finishes buffering: widgets from then on will be drawn straight on the screen
* without drawing queues. * without drawing queues.
*/ */
inline void finishBuffering() { _buffering = false; } inline void finishBuffering() { _buffering = false; }
inline void startBuffering() { _buffering = true; } inline void startBuffering() { _buffering = true; }
@ -474,21 +474,21 @@ public:
} }
/** /**
* Interface for the Theme Parser: Creates a new cursor by loading the given * Interface for the Theme Parser: Creates a new cursor by loading the given
* bitmap and sets it as the active cursor. * bitmap and sets it as the active cursor.
* *
* @param filename File name of the bitmap to load. * @param filename File name of the bitmap to load.
* @param hotspotX X Coordinate of the bitmap which does the cursor click. * @param hotspotX X Coordinate of the bitmap which does the cursor click.
* @param hotspotY Y Coordinate of the bitmap which does the cursor click. * @param hotspotY Y Coordinate of the bitmap which does the cursor click.
* @param scale Scale at which the bitmap is supposed to be used. * @param scale Scale at which the bitmap is supposed to be used.
*/ */
bool createCursor(const Common::String &filename, int hotspotX, int hotspotY, int scale); bool createCursor(const Common::String &filename, int hotspotX, int hotspotY, int scale);
/** /**
* Wrapper for restoring data from the Back Buffer to the screen. * Wrapper for restoring data from the Back Buffer to the screen.
* The actual processing is done in the VectorRenderer. * The actual processing is done in the VectorRenderer.
* *
* @param r Area to restore. * @param r Area to restore.
*/ */
void restoreBackground(Common::Rect r); void restoreBackground(Common::Rect r);
@ -498,33 +498,33 @@ public:
protected: protected:
/** /**
* Initializes the drawing screen surfaces, _screen and _backBuffer. * Initializes the drawing screen surfaces, _screen and _backBuffer.
* If the surfaces already exist, they are cleared and re-initialized. * If the surfaces already exist, they are cleared and re-initialized.
* *
* @param backBuffer Sets whether the _backBuffer surface should be initialized. * @param backBuffer Sets whether the _backBuffer surface should be initialized.
* @template PixelType C type which specifies the size of each pixel. * @template PixelType C type which specifies the size of each pixel.
* Defaults to uint16 (2 BPP for the surfaces) * Defaults to uint16 (2 BPP for the surfaces)
*/ */
template<typename PixelType> void screenInit(bool backBuffer = true); template<typename PixelType> void screenInit(bool backBuffer = true);
/** /**
* Loads the given theme into the ThemeEngine. * Loads the given theme into the ThemeEngine.
* *
* @param themeId Theme identifier. * @param themeId Theme identifier.
* @returns true if the theme was successfully loaded. * @returns true if the theme was successfully loaded.
*/ */
bool loadThemeXML(const Common::String &themeId); bool loadThemeXML(const Common::String &themeId);
/** /**
* Loads the default theme file (the embedded XML file found * Loads the default theme file (the embedded XML file found
* in ThemeDefaultXML.cpp). * in ThemeDefaultXML.cpp).
* Called only when no other themes are available. * Called only when no other themes are available.
*/ */
bool loadDefaultXML(); bool loadDefaultXML();
/** /**
* Unloads the currently loaded theme so another one can * Unloads the currently loaded theme so another one can
* be loaded. * be loaded.
*/ */
void unloadTheme(); void unloadTheme();
@ -535,31 +535,31 @@ protected:
Common::String genLocalizedFontFilename(const Common::String &filename) const; Common::String genLocalizedFontFilename(const Common::String &filename) const;
/** /**
* Actual Dirty Screen handling function. * Actual Dirty Screen handling function.
* Handles all the dirty squares in the list, merges and optimizes * Handles all the dirty squares in the list, merges and optimizes
* them when possible and draws them to the screen. * them when possible and draws them to the screen.
* Called from updateScreen() * Called from updateScreen()
*/ */
void renderDirtyScreen(); void renderDirtyScreen();
/** /**
* Generates a DrawQueue item and enqueues it so it's drawn to the screen * Generates a DrawQueue item and enqueues it so it's drawn to the screen
* when the drawing queue is processed. * when the drawing queue is processed.
* *
* If Buffering is enabled, the DrawQueue item will be automatically placed * If Buffering is enabled, the DrawQueue item will be automatically placed
* on its corresponding queue. * on its corresponding queue.
* If Buffering is disabled, the DrawQueue item will be processed immediately * If Buffering is disabled, the DrawQueue item will be processed immediately
* and drawn to the screen. * and drawn to the screen.
* *
* This function is called from all the Widget Drawing methods. * This function is called from all the Widget Drawing methods.
*/ */
void queueDD(DrawData type, const Common::Rect &r, uint32 dynamic = 0, bool restore = false); void queueDD(DrawData type, const Common::Rect &r, uint32 dynamic = 0, bool restore = false);
void queueDDText(TextData type, TextColor color, const Common::Rect &r, const Common::String &text, bool restoreBg, void queueDDText(TextData type, TextColor color, const Common::Rect &r, const Common::String &text, bool restoreBg,
bool elipsis, Graphics::TextAlign alignH = Graphics::kTextAlignLeft, TextAlignVertical alignV = kTextAlignVTop, int deltax = 0); bool elipsis, Graphics::TextAlign alignH = Graphics::kTextAlignLeft, TextAlignVertical alignV = kTextAlignVTop, int deltax = 0);
void queueBitmap(const Graphics::Surface *bitmap, const Common::Rect &r, bool alpha); void queueBitmap(const Graphics::Surface *bitmap, const Common::Rect &r, bool alpha);
/** /**
* DEBUG: Draws a white square and writes some text next to it. * DEBUG: Draws a white square and writes some text next to it.
*/ */
void debugWidgetPosition(const char *name, const Common::Rect &r); void debugWidgetPosition(const char *name, const Common::Rect &r);
@ -603,7 +603,7 @@ protected:
Graphics::Surface _backBuffer; Graphics::Surface _backBuffer;
/** Sets whether the current drawing is being buffered (stored for later /** Sets whether the current drawing is being buffered (stored for later
processing) or drawn directly to the screen. */ processing) or drawn directly to the screen. */
bool _buffering; bool _buffering;
/** Bytes per pixel of the Active Drawing Surface (i.e. the screen) */ /** Bytes per pixel of the Active Drawing Surface (i.e. the screen) */
@ -643,7 +643,7 @@ protected:
/** Queue with all the drawing that must be done to the screen */ /** Queue with all the drawing that must be done to the screen */
Common::List<ThemeItem *> _screenQueue; Common::List<ThemeItem *> _screenQueue;
bool _initOk; ///< Class and renderer properly initialized bool _initOk; ///< Class and renderer properly initialized
bool _themeOk; ///< Theme data successfully loaded. bool _themeOk; ///< Theme data successfully loaded.
bool _enabled; ///< Whether the Theme is currently shown on the overlay bool _enabled; ///< Whether the Theme is currently shown on the overlay
@ -661,7 +661,7 @@ protected:
byte *_cursor; byte *_cursor;
bool _needPaletteUpdates; bool _needPaletteUpdates;
uint _cursorWidth, _cursorHeight; uint _cursorWidth, _cursorHeight;
byte _cursorPal[3*MAX_CURS_COLORS]; byte _cursorPal[3 * MAX_CURS_COLORS];
byte _cursorPalSize; byte _cursorPalSize;
}; };