Classes | |
struct | Renderer |
struct | ThemeDescriptor |
Public Types | |
enum | TextAlignVertical { kTextAlignVInvalid, kTextAlignVBottom, kTextAlignVCenter, kTextAlignVTop } |
Vertical alignment of the text. | |
enum | WidgetBackground { kWidgetBackgroundNo, kWidgetBackgroundPlain, kWidgetBackgroundBorder, kWidgetBackgroundBorderSmall, kWidgetBackgroundEditText, kWidgetBackgroundSlider, kThumbnailBackground, kGridItemBackground, kGridItemHighlight } |
Widget background type. More... | |
enum | DialogBackground { kDialogBackgroundMain, kDialogBackgroundSpecial, kDialogBackgroundPlain, kDialogBackgroundTooltip, kDialogBackgroundDefault, kDialogBackgroundNone } |
Dialog background type. | |
enum | State { kStateDisabled, kStateEnabled, kStateHighlight, kStatePressed } |
State of the widget to be drawn. More... | |
enum | TextInversionState { kTextInversionNone, kTextInversion, kTextInversionFocus } |
Text inversion state of the text to be draw. More... | |
enum | ScrollbarState { kScrollbarStateNo, kScrollbarStateUp, kScrollbarStateDown, kScrollbarStateSlider, kScrollbarStateSinglePage } |
enum | FontStyle { kFontStyleBold = 0, kFontStyleNormal = 1, kFontStyleItalic = 2, kFontStyleFixedNormal = 3, kFontStyleFixedBold = 4, kFontStyleFixedItalic = 5, kFontStyleTooltip = 6, kFontStyleConsole = 7, kFontStyleLangExtra = 8, kFontStyleMax } |
Font style selector. More... | |
enum | FontColor { kFontColorFormatting = -1, kFontColorNormal = 0, kFontColorAlternate = 1, kFontColorOverride = 2, kFontColorMax } |
Font color selector. More... | |
enum | ShadingStyle { kShadingNone, kShadingDim, kShadingLuminance } |
Function used to process areas other than the current dialog. More... | |
enum | AutoScaleMode { kAutoScaleNone = 0, kAutoScaleStretch = 1, kAutoScaleFit = 2, kAutoScaleNinePatch = 3 } |
AlphaBitmap scale mode selector. More... | |
enum | GraphicsMode { kGfxDisabled = 0, kGfxStandard, kGfxAntialias } |
typedef State | WidgetStateInfo |
Public Member Functions | |
ThemeEngine (Common::String id, GraphicsMode mode) | |
~ThemeEngine () | |
void | setBaseResolution (int w, int h, float s) |
bool | init () |
void | clearAll () |
void | refresh () |
void | enable () |
void | showCursor () |
void | hideCursor () |
void | disable () |
const Graphics::PixelFormat | getPixelFormat () const |
void | applyScreenShading (ShadingStyle shading) |
void | drawToBackbuffer () |
void | drawToScreen () |
void | updateScreen () |
void | copyBackBufferToScreen () |
Common::Rect | swapClipRect (const Common::Rect &newRect) |
const Common::Rect | getClipRect () |
void | disableClipRect () |
void | addDirtyRect (Common::Rect r) |
DrawData | parseDrawDataId (const Common::String &name) const |
TextData | getTextData (DrawData ddId) const |
TextColor | getTextColor (DrawData ddId) const |
TextColorData * | getTextColorData (TextColor color) const |
void | addDrawStep (const Common::String &drawDataId, const Graphics::DrawStep &step) |
bool | addDrawData (const Common::String &data, bool cached) |
bool | addFont (TextData textId, const Common::String &language, const Common::String &file, const Common::String &scalableFile, const int pointsize) |
void | storeFontNames (TextData textId, const Common::String &language, const Common::String &file, const Common::String &scalableFile, const int pointsize) |
bool | loadExtraFont (FontStyle style, Common::Language lang) |
bool | addTextColor (TextColor colorId, int r, int g, int b) |
bool | addBitmap (const Common::String &filename, const Common::String &scalablefile, int widht, int height) |
bool | addTextData (const Common::String &drawDataId, TextData textId, TextColor id, Graphics::TextAlign alignH, TextAlignVertical alignV) |
ThemeEval * | getEvaluator () |
Graphics::VectorRenderer * | renderer () |
bool | supportsImages () const |
bool | ownCursor () const |
Graphics::ManagedSurface * | getImageSurface (const Common::String &name) const |
bool | createCursor (const Common::String &filename, int hotspotX, int hotspotY) |
void | restoreBackground (Common::Rect r) |
const Common::String & | getThemeName () const |
const Common::String & | getThemeId () const |
int | getGraphicsMode () const |
FONT MANAGEMENT METHODS | |
TextData | fontStyleToData (FontStyle font) const |
const Graphics::Font * | getFont (FontStyle font=kFontStyleBold) const |
int | getFontHeight (FontStyle font=kFontStyleBold) const |
int | getStringWidth (const Common::U32String &str, FontStyle font=kFontStyleBold) const |
int | getCharWidth (uint32 c, FontStyle font=kFontStyleBold) const |
int | getKerningOffset (uint32 left, uint32 right, FontStyle font=kFontStyleBold) const |
WIDGET DRAWING METHODS | |
void | drawWidgetBackground (const Common::Rect &r, WidgetBackground background) |
void | drawButton (const Common::Rect &r, const Common::U32String &str, WidgetStateInfo state=kStateEnabled, uint16 hints=0) |
void | drawDropDownButton (const Common::Rect &r, uint32 dropdownWidth, const Common::U32String &str, WidgetStateInfo buttonState, bool inButton, bool inDropdown, bool rtl=false) |
void | drawManagedSurface (const Common::Point &p, const Graphics::ManagedSurface &surface, Graphics::AlphaType alphaType) |
void | drawSlider (const Common::Rect &r, int width, WidgetStateInfo state=kStateEnabled, bool rtl=false) |
void | drawCheckbox (const Common::Rect &r, int spacing, const Common::U32String &str, bool checked, WidgetStateInfo state=kStateEnabled, bool override=false, bool rtl=false) |
void | drawRadiobutton (const Common::Rect &r, int spacing, const Common::U32String &str, bool checked, WidgetStateInfo state=kStateEnabled, bool rtl=false) |
void | drawTab (const Common::Rect &r, int tabHeight, const Common::Array< int > &tabWidths, const Common::Array< Common::U32String > &tabs, int active, bool rtl, ThemeEngine::TextAlignVertical alignV) |
void | drawScrollbar (const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState scrollState) |
void | drawPopUpWidget (const Common::Rect &r, const Common::U32String &sel, int deltax, WidgetStateInfo state=kStateEnabled, bool rtl=false) |
void | drawCaret (const Common::Rect &r, bool erase) |
void | drawLineSeparator (const Common::Rect &r) |
void | drawDialogBackground (const Common::Rect &r, DialogBackground type) |
void | drawText (const Common::Rect &r, const Common::U32String &str, WidgetStateInfo state=kStateEnabled, Graphics::TextAlign align=Graphics::kTextAlignCenter, TextInversionState inverted=kTextInversionNone, int deltax=0, bool useEllipsis=true, FontStyle font=kFontStyleBold, FontColor color=kFontColorNormal, bool restore=true, const Common::Rect &drawableTextArea=Common::Rect(0, 0, 0, 0)) |
void | drawChar (const Common::Rect &r, byte ch, const Graphics::Font *font, FontColor color=kFontColorNormal, TextInversionState inverted=ThemeEngine::kTextInversionNone) |
void | drawFoldIndicator (const Common::Rect &r, bool expanded) |
Static Public Member Functions | |
static GraphicsMode | findMode (const Common::String &cfg) |
static const char * | findModeConfigName (GraphicsMode mode) |
static void | listUsableThemes (Common::List< ThemeDescriptor > &list) |
Static Public Attributes | |
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 | kImageSearch |
Search tool image used in the launcher. | |
static const char *const | kImageGroup |
Select Group image used in the launcher. | |
static const char *const | kImageEraser |
Clear input image used in the launcher. | |
static const char *const | kImageDelButton |
Delete characters in the predictive dialog. | |
static const char *const | kImageList |
List image used in save/load chooser selection. | |
static const char *const | kImageGrid |
Grid image used in save/load chooser selection. | |
static const char *const | kImageStopButton |
Stop recording button in recorder onscreen dialog. | |
static const char *const | kImageEditButton |
Edit recording metadata in recorder onscreen dialog. | |
static const char *const | kImageSwitchModeButton |
Switch mode button in recorder onscreen dialog. | |
static const char *const | kImageFastReplayButton |
Fast playback mode button in recorder onscreen dialog. | |
static const char *const | kImageStopSmallButton |
Stop recording button in recorder onscreen dialog (for 320xY) | |
static const char *const | kImageEditSmallButton |
Edit recording metadata in recorder onscreen dialog (for 320xY) | |
static const char *const | kImageSwitchModeSmallButton |
Switch mode button in recorder onscreen dialog (for 320xY) | |
static const char *const | kImageFastReplaySmallButton |
Fast playback mode button in recorder onscreen dialog (for 320xY) | |
static const int | kDirtyRectangleThreshold = 1 |
static const Renderer | _rendererModes [] |
static const uint | _rendererModesSize |
static const GraphicsMode | _defaultRendererMode |
Protected Types | |
enum | { MAX_CURS_COLORS = 255 } |
typedef Common::HashMap< Common::String, Graphics::ManagedSurface * > | ImagesMap |
Protected Member Functions | |
bool | ready () const |
void | loadTheme (const Common::String &themeid) |
void | setGraphicsMode (GraphicsMode mode) |
bool | loadThemeXML (const Common::String &themeId) |
bool | loadDefaultXML () |
void | unloadTheme () |
void | unloadExtraFont () |
const Graphics::Font * | loadScalableFont (const Common::String &filename, const int pointsize, Common::String &name) |
const Graphics::Font * | loadFont (const Common::String &filename, Common::String &name) |
Common::String | genCacheFilename (const Common::String &filename) const |
const Graphics::Font * | loadFont (const Common::String &filename, const Common::String &scalableFilename, const int pointsize, const bool makeLocalizedFont) |
void | updateDirtyScreen () |
void | drawDD (DrawData type, const Common::Rect &r, uint32 dynamic=0, bool forceRestore=false) |
void | drawDDText (TextData type, TextColor color, const Common::Rect &r, const Common::U32String &text, bool restoreBg, bool elipsis, Graphics::TextAlign alignH=Graphics::kTextAlignLeft, TextAlignVertical alignV=kTextAlignVTop, int deltax=0, const Common::Rect &drawableTextArea=Common::Rect(0, 0, 0, 0)) |
void | debugWidgetPosition (const char *name, const Common::Rect &r) |
Protected Attributes | |
OSystem * | _system |
Graphics::VectorRenderer * | _vectorRenderer |
GUI::ThemeParser * | _parser |
GUI::ThemeEval * | _themeEval |
Graphics::ManagedSurface | _screen |
Graphics::ManagedSurface | _backBuffer |
DrawLayer | _layerToDraw |
int | _bytesPerPixel |
GraphicsMode | _graphicsMode |
int16 | _baseWidth |
int16 | _baseHeight |
float | _scaleFactor |
bool | _needScaleRefresh = false |
const Graphics::Font * | _font |
WidgetDrawData * | _widgets [kDrawDataMAX] |
TextDrawData * | _texts [kTextDataMAX] |
TextColorData * | _textColors [kTextColorMAX] |
Common::Array< LangExtraFont > | _langExtraFonts |
ImagesMap | _bitmaps |
Graphics::PixelFormat | _overlayFormat |
Graphics::PixelFormat | _cursorFormat |
Common::List< Common::Rect > | _dirtyScreen |
bool | _initOk |
Class and renderer properly initialized. | |
bool | _themeOk |
Theme data successfully loaded. | |
bool | _enabled |
Whether the Theme is currently shown on the overlay. | |
Common::String | _themeName |
Name of the currently loaded theme. | |
Common::String | _themeId |
Common::Path | _themeFile |
Common::Archive * | _themeArchive |
Common::SearchSet | _themeFiles |
bool | _useCursor |
int | _cursorHotspotX |
int | _cursorHotspotY |
uint32 | _cursorTransparent |
byte * | _cursor |
uint | _cursorWidth |
uint | _cursorHeight |
byte | _cursorPal [3 *MAX_CURS_COLORS] |
byte | _cursorPalSize |
Common::Rect | _clip |
Widget background type.
State of the widget to be drawn.
Font style selector.
Graphics mode enumeration. Each item represents a set of BPP and Renderer modes for a given surface.
Enumerator | |
---|---|
kGfxDisabled | No GFX. |
kGfxStandard | Standard (aliased) renderer. |
kGfxAntialias | Optimized AA renderer. |
GUI::ThemeEngine::ThemeEngine | ( | Common::String | id, |
GraphicsMode | mode | ||
) |
Default constructor
GUI::ThemeEngine::~ThemeEngine | ( | ) |
Default destructor
|
inline |
Query the set up pixel format.
void GUI::ThemeEngine::applyScreenShading | ( | ShadingStyle | shading | ) |
Draw full screen shading with the supplied style
This is used to dim the inactive dialogs so the active one stands out.
void GUI::ThemeEngine::drawToBackbuffer | ( | ) |
Sets the active drawing surface to the back buffer.
All drawing from this point on will be done on that surface. The back buffer surface needs to be copied to the screen surface in order to become visible.
void GUI::ThemeEngine::drawToScreen | ( | ) |
Sets the active drawing surface to the screen.
All drawing from this point on will be done on that surface.
void GUI::ThemeEngine::updateScreen | ( | ) |
The updateScreen() method is called every frame. It copies dirty rectangles in the Screen surface to the overlay.
void GUI::ThemeEngine::copyBackBufferToScreen | ( | ) |
Copy the entire backbuffer surface to the screen surface
Common::Rect GUI::ThemeEngine::swapClipRect | ( | const Common::Rect & | newRect | ) |
Set the clipping rect to be used by the widget drawing methods defined below.
Widgets are not drawn outside of the clipping rect. Widgets that overlap the clipping rect are drawn partially.
newRect | The new clipping rect |
void GUI::ThemeEngine::disableClipRect | ( | ) |
Set the clipping rect to allow rendering on the whole surface.
void GUI::ThemeEngine::addDirtyRect | ( | Common::Rect | r | ) |
Actual implementation of a dirty rect handling. Dirty rectangles are queued on a list, merged and optimized when possible and are later used for the actual drawing.
r | Area of the dirty rect. |
DrawData GUI::ThemeEngine::parseDrawDataId | ( | const Common::String & | name | ) | const |
Returns the DrawData enumeration value that represents the given string in the DrawDataDefaults enumeration. It's slow, but called sparsely.
name | The representing name, as found on Theme Description XML files. |
void GUI::ThemeEngine::addDrawStep | ( | const Common::String & | drawDataId, |
const Graphics::DrawStep & | step | ||
) |
Interface for ThemeParser class: Parsed DrawSteps are added via this function. There is no return type because DrawSteps can always be added, unless something goes horribly wrong. The specified step will be added to the Steps list of the given DrawData id.
drawDataId | The representing DrawData name, as found on Theme Description XML files. |
step | The actual DrawStep struct to be added. |
bool GUI::ThemeEngine::addDrawData | ( | const Common::String & | data, |
bool | cached | ||
) |
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 be added, hence this must be called for each DD set before addDrawStep() can be called for that given set.
data | The representing DrawData name, as found on Theme Description XML files. |
cached | Whether this DD set will be cached beforehand. |
bool GUI::ThemeEngine::addFont | ( | TextData | textId, |
const Common::String & | language, | ||
const Common::String & | file, | ||
const Common::String & | scalableFile, | ||
const int | pointsize | ||
) |
Interface for the ThemeParser class: Loads a font to use on the GUI from the given filename.
textId | Identifier name for the font. |
language | Wildcard for the language(s) to use. |
file | Filename of the non-scalable font version. |
scalableFile | Filename of the scalable version. (Optional) |
pointsize | Point size for the scalable font. (Optional) |
void GUI::ThemeEngine::storeFontNames | ( | TextData | textId, |
const Common::String & | language, | ||
const Common::String & | file, | ||
const Common::String & | scalableFile, | ||
const int | pointsize | ||
) |
Store language specific font names for ingame GUI dialogs which might require a different language than the current GUI setting
textId,language,file,scalableFile,pointsize | All exactly the same as with addFont() |
bool GUI::ThemeEngine::loadExtraFont | ( | FontStyle | style, |
Common::Language | lang | ||
) |
Load language specific font for ingame use
style | font style associated with the font file |
lang | language associated with the font file |
bool GUI::ThemeEngine::addTextColor | ( | TextColor | colorId, |
int | r, | ||
int | g, | ||
int | b | ||
) |
Interface for the ThemeParser class: adds a text color value.
colorId | Identifier for the color type. |
r | Red color component |
g | Green color component |
b | Blue color component |
bool GUI::ThemeEngine::addBitmap | ( | const Common::String & | filename, |
const Common::String & | scalablefile, | ||
int | widht, | ||
int | height | ||
) |
Interface for the ThemeParser class: Loads a bitmap file to use on the GUI. The filename is also used as its identifier.
filename | Name of the bitmap file. |
filename | Name of the scalable (SVG) file, could be empty |
width,height | Default image dimensions |
bool GUI::ThemeEngine::addTextData | ( | const Common::String & | drawDataId, |
TextData | textId, | ||
TextColor | id, | ||
Graphics::TextAlign | alignH, | ||
TextAlignVertical | alignV | ||
) |
Adds a new TextStep from the ThemeParser. This will be deprecated/removed once the new Font API is in place. FIXME: Is that so ???
|
inlineprotected |
Returns if the Theme is ready to draw stuff on screen. Must be called instead of just checking _initOk, because this checks if the renderer is initialized AND if the theme is loaded.
|
protected |
Load the them from the file with the specified name.
|
protected |
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.
bool GUI::ThemeEngine::createCursor | ( | const Common::String & | filename, |
int | hotspotX, | ||
int | hotspotY | ||
) |
Interface for the Theme Parser: Creates a new cursor by loading the given bitmap and sets it as the active cursor.
filename | File name of the bitmap to load. |
hotspotX | X Coordinate of the bitmap which does the cursor click. |
hotspotY | Y Coordinate of the bitmap which does the cursor click. |
void GUI::ThemeEngine::restoreBackground | ( | Common::Rect | r | ) |
Wrapper for restoring data from the Back Buffer to the screen. The actual processing is done in the VectorRenderer.
r | Area to restore. |
|
protected |
Loads the given theme into the ThemeEngine.
themeId | Theme identifier. |
|
protected |
Loads the default theme file (the embedded XML file found in ThemeDefaultXML.cpp). Called only when no other themes are available.
|
protected |
Unloads the currently loaded theme so another one can be loaded.
|
protected |
Unload the language specific font loaded via loadExtraFont()
|
protected |
Dirty Screen handling function. Draws all the dirty rectangles in the list to the overlay.
|
protected |
Draws a GUI element according to a DrawData descriptor.
Only calls with a DrawData layer attribute matching the active layer are actually drawn to the active surface.
These functions are called from all the Widget drawing methods.
|
protected |
DEBUG: Draws a white square and writes some text next to it.
|
static |
Lists all theme files useable.
|
static |
Constant value to expand dirty rectangles, to make sure they are fully copied
|
protected |
Global system object. Vector Renderer object, does the actual drawing on screen
|
protected |
XML Parser, does the Theme parsing instead of the default parser
|
protected |
Theme getEvaluator (changed from GUI::Eval to add functionality)
|
protected |
Main screen surface. This is blitted straight into the overlay.
|
protected |
Backbuffer surface. Stores previous states of the screen to blit back
|
protected |
Filter the submitted DrawData descriptors according to their layer attribute
This is used to selectively draw the background or foreground layer of the dialogs.
|
protected |
Bytes per pixel of the Active Drawing Surface (i.e. the screen)
|
protected |
Current graphics mode
|
protected |
Font info.
|
protected |
Array of all the DrawData elements than can be drawn to the screen. Must be full so the renderer can work.
|
protected |
Array of all the text fonts that can be drawn.
|
protected |
Array of all font colors available.
|
protected |
Extra font file names for languages like Japanese, Korean or Chinese for use in ingame dialogs (like the SCUMM pause/restart dialogs)
|
protected |
List of all the dirty screens that must be blitted to the overlay.