From 7d58a50c46ecb7001702a696a3c92eb5ab3d0a36 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 6 Nov 2015 15:14:42 +0100 Subject: GUI: Removed 64k limit on built-in theme XML size --- gui/ThemeEngine.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'gui/ThemeEngine.cpp') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index ed01204180..016cfc136d 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -739,12 +739,24 @@ bool ThemeEngine::loadDefaultXML() { // Use the Python script "makedeftheme.py" to convert a normal XML theme // into the "default.inc" file, which is ready to be included in the code. #ifndef DISABLE_GUI_BUILTIN_THEME - const char *defaultXML = #include "themes/default.inc" - ; + int xmllen = 0; + + for (int i = 0; i < ARRAYSIZE(defaultXML); i++) + xmllen += strlen(defaultXML[i]); + + byte *tmpXML = (byte *)malloc(xmllen + 1); + + for (int i = 0; i < ARRAYSIZE(defaultXML); i++) + strncat((char *)tmpXML, defaultXML[i], xmllen); + + if (!_parser->loadBuffer(tmpXML, xmllen)) { + free(tmpXML); - if (!_parser->loadBuffer((const byte *)defaultXML, strlen(defaultXML))) return false; + } + + free(tmpXML); _themeName = "ScummVM Classic Theme (Builtin Version)"; _themeId = "builtin"; -- cgit v1.2.3 From 06d83f148f8167fbe3e7c671a91f69e36decf1fe Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Mon, 9 Nov 2015 23:25:49 +0100 Subject: GUI: strncat needs a destination C-string --- gui/ThemeEngine.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'gui/ThemeEngine.cpp') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 016cfc136d..6c40001b26 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -746,6 +746,7 @@ bool ThemeEngine::loadDefaultXML() { xmllen += strlen(defaultXML[i]); byte *tmpXML = (byte *)malloc(xmllen + 1); + tmpXML[0] = '\0'; for (int i = 0; i < ARRAYSIZE(defaultXML); i++) strncat((char *)tmpXML, defaultXML[i], xmllen); -- cgit v1.2.3 From 91e6abd3050ed028bab3fd4d1746adb79fe8adcd Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Mon, 9 Nov 2015 23:56:10 +0100 Subject: GUI: Use after free --- gui/ThemeEngine.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gui/ThemeEngine.cpp') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 6c40001b26..6562a1d922 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -757,8 +757,6 @@ bool ThemeEngine::loadDefaultXML() { return false; } - free(tmpXML); - _themeName = "ScummVM Classic Theme (Builtin Version)"; _themeId = "builtin"; _themeFile.clear(); @@ -766,6 +764,8 @@ bool ThemeEngine::loadDefaultXML() { bool result = _parser->parse(); _parser->close(); + free(tmpXML); + return result; #else warning("The built-in theme is not enabled in the current build. Please load an external theme"); -- cgit v1.2.3 From 2d86f6da9c0ee2ffa80a2b570c148ea337b09cec Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Sun, 22 Nov 2015 14:18:14 +0100 Subject: GRAPHICS: Introduce a size mode for TrueType fonts Allows to match Windows font size selection by converting font heights to point sizes using the TrueType tables. --- gui/ThemeEngine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gui/ThemeEngine.cpp') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 6562a1d922..536e5192e0 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -1459,7 +1459,7 @@ const Graphics::Font *ThemeEngine::loadScalableFont(const Common::String &filena for (Common::ArchiveMemberList::const_iterator i = members.begin(), end = members.end(); i != end; ++i) { Common::SeekableReadStream *stream = (*i)->createReadStream(); if (stream) { - font = Graphics::loadTTFFont(*stream, pointsize, 0, Graphics::kTTFRenderModeLight, + font = Graphics::loadTTFFont(*stream, pointsize, Graphics::kTTFSizeModeCharacter, 0, Graphics::kTTFRenderModeLight, #ifdef USE_TRANSLATION TransMan.getCharsetMapping() #else -- cgit v1.2.3 From 5a63ee537506c4a0e90a25ee9fe96cfef4a90519 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 24 Jan 2016 03:41:29 +0100 Subject: GUI: Use "button" instead of "btn" in variable names. --- gui/ThemeEngine.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'gui/ThemeEngine.cpp') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 536e5192e0..c840816db1 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -48,17 +48,17 @@ const char * const ThemeEngine::kImageLogo = "logo.bmp"; const char * const ThemeEngine::kImageLogoSmall = "logo_small.bmp"; const char * const ThemeEngine::kImageSearch = "search.bmp"; const char * const ThemeEngine::kImageEraser = "eraser.bmp"; -const char * const ThemeEngine::kImageDelbtn = "delbtn.bmp"; +const char * const ThemeEngine::kImageDelButton = "delbtn.bmp"; const char * const ThemeEngine::kImageList = "list.bmp"; const char * const ThemeEngine::kImageGrid = "grid.bmp"; -const char * const ThemeEngine::kImageStopbtn = "stopbtn.bmp"; -const char * const ThemeEngine::kImageEditbtn = "editbtn.bmp"; -const char * const ThemeEngine::kImageSwitchModebtn = "switchbtn.bmp"; -const char * const ThemeEngine::kImageFastReplaybtn = "fastreplay.bmp"; -const char * const ThemeEngine::kImageStopSmallbtn = "stopbtn_small.bmp"; -const char * const ThemeEngine::kImageEditSmallbtn = "editbtn_small.bmp"; -const char * const ThemeEngine::kImageSwitchModeSmallbtn = "switchbtn_small.bmp"; -const char * const ThemeEngine::kImageFastReplaySmallbtn = "fastreplay_small.bmp"; +const char * const ThemeEngine::kImageStopButton = "stopbtn.bmp"; +const char * const ThemeEngine::kImageEditButton = "editbtn.bmp"; +const char * const ThemeEngine::kImageSwitchModeButton = "switchbtn.bmp"; +const char * const ThemeEngine::kImageFastReplayButton = "fastreplay.bmp"; +const char * const ThemeEngine::kImageStopSmallButton = "stopbtn_small.bmp"; +const char * const ThemeEngine::kImageEditSmallButton = "editbtn_small.bmp"; +const char * const ThemeEngine::kImageSwitchModeSmallButton = "switchbtn_small.bmp"; +const char * const ThemeEngine::kImageFastReplaySmallButton = "fastreplay_small.bmp"; struct TextDrawData { const Graphics::Font *_fontPtr; -- cgit v1.2.3 From a7dba17fece00548f52426a20a8c4948a6dd0870 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 24 Jan 2016 03:41:49 +0100 Subject: GUI: Fix pointer formatting in ThemeEngine.cpp. --- gui/ThemeEngine.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'gui/ThemeEngine.cpp') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index c840816db1..1b95a11e03 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -44,21 +44,21 @@ namespace GUI { -const char * const ThemeEngine::kImageLogo = "logo.bmp"; -const char * const ThemeEngine::kImageLogoSmall = "logo_small.bmp"; -const char * const ThemeEngine::kImageSearch = "search.bmp"; -const char * const ThemeEngine::kImageEraser = "eraser.bmp"; -const char * const ThemeEngine::kImageDelButton = "delbtn.bmp"; -const char * const ThemeEngine::kImageList = "list.bmp"; -const char * const ThemeEngine::kImageGrid = "grid.bmp"; -const char * const ThemeEngine::kImageStopButton = "stopbtn.bmp"; -const char * const ThemeEngine::kImageEditButton = "editbtn.bmp"; -const char * const ThemeEngine::kImageSwitchModeButton = "switchbtn.bmp"; -const char * const ThemeEngine::kImageFastReplayButton = "fastreplay.bmp"; -const char * const ThemeEngine::kImageStopSmallButton = "stopbtn_small.bmp"; -const char * const ThemeEngine::kImageEditSmallButton = "editbtn_small.bmp"; -const char * const ThemeEngine::kImageSwitchModeSmallButton = "switchbtn_small.bmp"; -const char * const ThemeEngine::kImageFastReplaySmallButton = "fastreplay_small.bmp"; +const char *const ThemeEngine::kImageLogo = "logo.bmp"; +const char *const ThemeEngine::kImageLogoSmall = "logo_small.bmp"; +const char *const ThemeEngine::kImageSearch = "search.bmp"; +const char *const ThemeEngine::kImageEraser = "eraser.bmp"; +const char *const ThemeEngine::kImageDelButton = "delbtn.bmp"; +const char *const ThemeEngine::kImageList = "list.bmp"; +const char *const ThemeEngine::kImageGrid = "grid.bmp"; +const char *const ThemeEngine::kImageStopButton = "stopbtn.bmp"; +const char *const ThemeEngine::kImageEditButton = "editbtn.bmp"; +const char *const ThemeEngine::kImageSwitchModeButton = "switchbtn.bmp"; +const char *const ThemeEngine::kImageFastReplayButton = "fastreplay.bmp"; +const char *const ThemeEngine::kImageStopSmallButton = "stopbtn_small.bmp"; +const char *const ThemeEngine::kImageEditSmallButton = "editbtn_small.bmp"; +const char *const ThemeEngine::kImageSwitchModeSmallButton = "switchbtn_small.bmp"; +const char *const ThemeEngine::kImageFastReplaySmallButton = "fastreplay_small.bmp"; struct TextDrawData { const Graphics::Font *_fontPtr; -- cgit v1.2.3 From ccc7506666c50a2a13dba9759f605260d50eaebf Mon Sep 17 00:00:00 2001 From: Ori Avtalion Date: Wed, 23 Mar 2016 18:01:13 +0200 Subject: GUI: Fix constant names mentioned in comment --- gui/ThemeEngine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gui/ThemeEngine.cpp') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 1b95a11e03..c2deb8c61e 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -164,7 +164,7 @@ struct DrawDataInfo { 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 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. kDDButtonIdle -> kDDButtonHover }; /** -- cgit v1.2.3 From c7ad2155fc9153b700d55aea08eafa03d7343fc8 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 1 Jun 2016 12:10:33 +0200 Subject: GUI: More object initialization cleanup --- gui/ThemeEngine.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gui/ThemeEngine.cpp') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index c2deb8c61e..aec5c79dab 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -311,6 +311,12 @@ ThemeEngine::ThemeEngine(Common::String id, GraphicsMode mode) : _themeArchive = 0; _initOk = false; + _cursorHotspotX = _cursorHotspotY = 0; + _cursorWidth = _cursorHeight = 0; + _cursorPalSize = 0; + + _needPaletteUpdates = false; + // We prefer files in archive bundles over the common search paths. _themeFiles.add("default", &SearchMan, 0, false); } -- cgit v1.2.3 From a612b0a173eefc80d635a2711cd9f20e4601839d Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 9 May 2014 23:16:02 +0300 Subject: GRAPHICS: Restore layout debugging capabilities --- gui/ThemeEngine.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'gui/ThemeEngine.cpp') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index aec5c79dab..90cb612e19 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -1265,8 +1265,15 @@ void ThemeEngine::updateScreen(bool render) { _screenQueue.clear(); } - if (render) + if (render) { +#ifdef LAYOUT_DEBUG_DIALOG + _vectorRenderer->fillSurface(); + _themeEval->debugDraw(&_screen, _font); + _vectorRenderer->copyWholeFrame(_system); +#else renderDirtyScreen(); +#endif + } } void ThemeEngine::addDirtyRect(Common::Rect r) { -- cgit v1.2.3 From 61235e7f551f72495d1c0848998fd8698a2a788d Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 5 Jun 2016 14:23:07 +0200 Subject: GUI: Fix possible negative index access --- gui/ThemeEngine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gui/ThemeEngine.cpp') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 90cb612e19..262b2d7b5a 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -564,7 +564,7 @@ void ThemeEngine::restoreBackground(Common::Rect r) { void ThemeEngine::addDrawStep(const Common::String &drawDataId, const Graphics::DrawStep &step) { DrawData id = parseDrawDataId(drawDataId); - assert(_widgets[id] != 0); + assert(id != kDDNone && _widgets[id] != 0); _widgets[id]->_steps.push_back(step); } -- cgit v1.2.3 From 786780ccb905277445b5d17d47fdc6669005bfb8 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 5 Jun 2016 14:30:12 +0200 Subject: GUI: Prevent potential negative index access --- gui/ThemeEngine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gui/ThemeEngine.cpp') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 262b2d7b5a..f093846bec 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -865,7 +865,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, bool ellipsis, Graphics::TextAlign alignH, TextAlignVertical alignV, int deltax, const Common::Rect &drawableTextArea) { - if (_texts[type] == 0) + if (type != kTextDataNone && _texts[type] == 0) return; Common::Rect area = r; -- cgit v1.2.3 From 8e4f892ef9e6ad6c2809449373adb8cbad88aa9b Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 6 Jun 2016 08:04:36 +0200 Subject: GUI: Fixed negative index check --- gui/ThemeEngine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gui/ThemeEngine.cpp') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index f093846bec..5e2bbb0419 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -865,7 +865,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, bool ellipsis, Graphics::TextAlign alignH, TextAlignVertical alignV, int deltax, const Common::Rect &drawableTextArea) { - if (type != kTextDataNone && _texts[type] == 0) + if (type != kTextDataNone || _texts[type] == 0) return; Common::Rect area = r; -- cgit v1.2.3 From 04bb80bc7191069797edfcbb523439c805eef599 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 6 Jun 2016 18:43:36 +0200 Subject: GUI: Fix regression --- gui/ThemeEngine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gui/ThemeEngine.cpp') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 5e2bbb0419..0ed020ebb8 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -865,7 +865,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, bool ellipsis, Graphics::TextAlign alignH, TextAlignVertical alignV, int deltax, const Common::Rect &drawableTextArea) { - if (type != kTextDataNone || _texts[type] == 0) + if (type == kTextDataNone || _texts[type] == 0) return; Common::Rect area = r; -- cgit v1.2.3 From 08727857bcea96a5963db4913cc081ed65341678 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Mon, 20 Jun 2016 21:10:37 +0600 Subject: GUI: Use boss's x/y/w/h instead of clippingArea --- gui/ThemeEngine.cpp | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) (limited to 'gui/ThemeEngine.cpp') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 0ed020ebb8..c1167127ae 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -881,6 +881,28 @@ void ThemeEngine::queueDDText(TextData type, TextColor color, const Common::Rect } } +void ThemeEngine::queueDDTextClip(TextData type, TextColor color, const Common::Rect &r, const Common::Rect &clippingArea, const Common::String &text, bool restoreBg, + bool ellipsis, Graphics::TextAlign alignH, TextAlignVertical alignV, int deltax, const Common::Rect &drawableTextArea) { + + if (_texts[type] == 0) + return; + + Common::Rect area = r; + area.clip(_screen.w, _screen.h); + Common::Rect textArea = drawableTextArea; + if (textArea.isEmpty()) textArea = clippingArea; + else textArea.clip(clippingArea); + + ThemeItemTextData *q = new ThemeItemTextData(this, _texts[type], _textColors[color], area, textArea, text, alignH, alignV, ellipsis, restoreBg, deltax); + + if (_buffering) { + _screenQueue.push_back(q); + } else { + q->drawSelf(true, false); + delete q; + } +} + void ThemeEngine::queueBitmap(const Graphics::Surface *bitmap, const Common::Rect &r, bool alpha) { Common::Rect area = r; @@ -1215,6 +1237,79 @@ void ThemeEngine::drawText(const Common::Rect &r, const Common::String &str, Wid queueDDText(textId, colorId, r, str, restore, useEllipsis, align, kTextAlignVCenter, deltax, drawableTextArea); } +void ThemeEngine::drawTextClip(const Common::Rect &r, const Common::Rect &clippingArea, const Common::String &str, WidgetStateInfo state, Graphics::TextAlign align, TextInversionState inverted, int deltax, bool useEllipsis, FontStyle font, FontColor color, bool restore, const Common::Rect &drawableTextArea) { + if (!ready()) + return; + + TextColor colorId = kTextColorMAX; + + switch (color) { + case kFontColorNormal: + if (inverted) { + colorId = kTextColorNormalInverted; + } else { + switch (state) { + case kStateDisabled: + colorId = kTextColorNormalDisabled; + break; + + case kStateHighlight: + colorId = kTextColorNormalHover; + break; + + case kStateEnabled: + case kStatePressed: + colorId = kTextColorNormal; + break; + } + } + break; + + case kFontColorAlternate: + if (inverted) { + colorId = kTextColorAlternativeInverted; + } else { + switch (state) { + case kStateDisabled: + colorId = kTextColorAlternativeDisabled; + break; + + case kStateHighlight: + colorId = kTextColorAlternativeHover; + break; + + case kStateEnabled: + case kStatePressed: + colorId = kTextColorAlternative; + break; + } + } + break; + + default: + return; + } + + TextData textId = fontStyleToData(font); + + switch (inverted) { + case kTextInversion: + queueDD(kDDTextSelectionBackground, r); + restore = false; + break; + + case kTextInversionFocus: + queueDD(kDDTextSelectionFocusBackground, r); + restore = false; + break; + + default: + break; + } + + queueDDTextClip(textId, colorId, r, clippingArea, str, restore, useEllipsis, align, kTextAlignVCenter, deltax, drawableTextArea); +} + void ThemeEngine::drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, WidgetStateInfo state, FontColor color) { if (!ready()) return; -- cgit v1.2.3 From 49caaf77a1aa5f2668a1b21cc2722fb536558929 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Tue, 21 Jun 2016 14:36:21 +0600 Subject: GUI: Add ScrollContainer --- gui/ThemeEngine.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gui/ThemeEngine.cpp') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index c1167127ae..b10349e442 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -1042,8 +1042,8 @@ void ThemeEngine::drawScrollbar(const Common::Rect &r, int sliderY, int sliderHe r2.top += sliderY; r2.bottom = r2.top + sliderHeight; - r2.top += r.width() / 5; - r2.bottom -= r.width() / 5; + //r2.top += r.width() / 5; + //r2.bottom -= r.width() / 5; queueDD(scrollState == kScrollbarStateSlider ? kDDScrollbarHandleHover : kDDScrollbarHandleIdle, r2); } -- cgit v1.2.3 From d7278cc48b7fd9c1848da6402316663af2d0c7bd Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Tue, 21 Jun 2016 15:15:15 +0600 Subject: GUI: Prepare button to be clipped --- gui/ThemeEngine.cpp | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) (limited to 'gui/ThemeEngine.cpp') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index b10349e442..12788c2233 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -121,6 +121,19 @@ protected: const WidgetDrawData *_data; }; +class ThemeItemDrawDataClip: public ThemeItem{ +public: + ThemeItemDrawDataClip(ThemeEngine *engine, const WidgetDrawData *data, const Common::Rect &area, const Common::Rect &clip, uint32 dynData) : + ThemeItem(engine, area), _dynamicData(dynData), _data(data), _clip(clip) {} + + void drawSelf(bool draw, bool restore); + +protected: + uint32 _dynamicData; + const WidgetDrawData *_data; + const Common::Rect _clip; +}; + class ThemeItemTextData : public ThemeItem { public: ThemeItemTextData(ThemeEngine *engine, const TextDrawData *data, const TextColorData *color, const Common::Rect &area, const Common::Rect &textDrawableArea, @@ -242,6 +255,23 @@ void ThemeItemDrawData::drawSelf(bool draw, bool restore) { _engine->addDirtyRect(extendedRect); } +void ThemeItemDrawDataClip::drawSelf(bool draw, bool restore) { + + Common::Rect extendedRect = _area; + extendedRect.grow(_engine->kDirtyRectangleThreshold + _data->_backgroundOffset); + + if (restore) + _engine->restoreBackground(extendedRect); + + if (draw) { + Common::List::const_iterator step; + for (step = _data->_steps.begin(); step != _data->_steps.end(); ++step) + _engine->renderer()->drawStep(_area, *step, _dynamicData); + } + + _engine->addDirtyRect(extendedRect); +} + void ThemeItemTextData::drawSelf(bool draw, bool restore) { if (_restoreBg || restore) _engine->restoreBackground(_area); @@ -862,6 +892,31 @@ void ThemeEngine::queueDD(DrawData type, const Common::Rect &r, uint32 dynamic, } } +void ThemeEngine::queueDDClip(DrawData type, const Common::Rect &r, const Common::Rect &clippingRect, uint32 dynamic, bool restore) { + if (_widgets[type] == 0) + return; + + Common::Rect area = r; + area.clip(_screen.w, _screen.h); + area.clip(clippingRect); + + ThemeItemDrawData *q = new ThemeItemDrawData(this, _widgets[type], area, dynamic); + + if (_buffering) { + if (_widgets[type]->_buffer) { + _bufferQueue.push_back(q); + } else { + if (kDrawDataDefaults[type].parent != kDDNone && kDrawDataDefaults[type].parent != type) + queueDDClip(kDrawDataDefaults[type].parent, r, clippingRect); + + _screenQueue.push_back(q); + } + } else { + q->drawSelf(!_widgets[type]->_buffer, restore || _widgets[type]->_buffer); + delete q; + } +} + 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, const Common::Rect &drawableTextArea) { @@ -942,6 +997,25 @@ void ThemeEngine::drawButton(const Common::Rect &r, const Common::String &str, W queueDDText(getTextData(dd), getTextColor(dd), r, str, false, true, _widgets[dd]->_textAlignH, _widgets[dd]->_textAlignV); } +void ThemeEngine::drawButtonClip(const Common::Rect &r, const Common::Rect &clippingRect, const Common::String &str, WidgetStateInfo state, uint16 hints) { + if (!ready()) + return; + + DrawData dd = kDDButtonIdle; + + if (state == kStateEnabled) + dd = kDDButtonIdle; + else if (state == kStateHighlight) + dd = kDDButtonHover; + else if (state == kStateDisabled) + dd = kDDButtonDisabled; + else if (state == kStatePressed) + dd = kDDButtonPressed; + + queueDDClip(dd, r, clippingRect, 0, hints & WIDGET_CLEARBG); + queueDDTextClip(getTextData(dd), getTextColor(dd), r, clippingRect, str, false, true, _widgets[dd]->_textAlignH, _widgets[dd]->_textAlignV); +} + void ThemeEngine::drawLineSeparator(const Common::Rect &r, WidgetStateInfo state) { if (!ready()) return; -- cgit v1.2.3 From 3d2730a0ddd1e1e33e6639775727beb954d7bfc0 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Tue, 21 Jun 2016 16:45:07 +0600 Subject: GUI: clippingRect propagated deeper --- gui/ThemeEngine.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'gui/ThemeEngine.cpp') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 12788c2233..3c6f5956a8 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -898,9 +898,8 @@ void ThemeEngine::queueDDClip(DrawData type, const Common::Rect &r, const Common Common::Rect area = r; area.clip(_screen.w, _screen.h); - area.clip(clippingRect); - ThemeItemDrawData *q = new ThemeItemDrawData(this, _widgets[type], area, dynamic); + ThemeItemDrawDataClip *q = new ThemeItemDrawDataClip(this, _widgets[type], area, clippingRect, dynamic); if (_buffering) { if (_widgets[type]->_buffer) { -- cgit v1.2.3 From 8f2d35b0b89c4b8912df96ec3c403e00c85c5875 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Wed, 22 Jun 2016 14:29:02 +0600 Subject: GUI: drawRoundedSquareClip() --- gui/ThemeEngine.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'gui/ThemeEngine.cpp') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 3c6f5956a8..1204f00a68 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -265,8 +265,9 @@ void ThemeItemDrawDataClip::drawSelf(bool draw, bool restore) { if (draw) { Common::List::const_iterator step; - for (step = _data->_steps.begin(); step != _data->_steps.end(); ++step) - _engine->renderer()->drawStep(_area, *step, _dynamicData); + for (step = _data->_steps.begin(); step != _data->_steps.end(); ++step) { + _engine->renderer()->drawStepClip(_area, _clip, *step, _dynamicData); + } } _engine->addDirtyRect(extendedRect); -- cgit v1.2.3 From fca0f0ed3496530fc0d63efdde9f32fb995cd671 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Wed, 22 Jun 2016 15:02:46 +0600 Subject: GUI: Make PopUpWidget clip --- gui/ThemeEngine.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'gui/ThemeEngine.cpp') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 1204f00a68..037940dfd4 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -270,6 +270,8 @@ void ThemeItemDrawDataClip::drawSelf(bool draw, bool restore) { } } + extendedRect.clip(_clip); + _engine->addDirtyRect(extendedRect); } @@ -1180,6 +1182,27 @@ void ThemeEngine::drawPopUpWidget(const Common::Rect &r, const Common::String &s } } +void ThemeEngine::drawPopUpWidgetClip(const Common::Rect &r, const Common::Rect &clip, const Common::String &sel, int deltax, WidgetStateInfo state, Graphics::TextAlign align) { + if (!ready()) + return; + + DrawData dd = kDDPopUpIdle; + + if (state == kStateEnabled) + dd = kDDPopUpIdle; + else if (state == kStateHighlight) + dd = kDDPopUpHover; + else if (state == kStateDisabled) + dd = kDDPopUpDisabled; + + queueDDClip(dd, r, clip); + + if (!sel.empty()) { + Common::Rect text(r.left + 3, r.top + 1, r.right - 10, r.bottom); + queueDDTextClip(getTextData(dd), getTextColor(dd), text, clip, sel, true, false, _widgets[dd]->_textAlignH, _widgets[dd]->_textAlignV, deltax); + } +} + void ThemeEngine::drawSurface(const Common::Rect &r, const Graphics::Surface &surface, WidgetStateInfo state, int alpha, bool themeTrans) { if (!ready()) return; @@ -1210,6 +1233,29 @@ void ThemeEngine::drawWidgetBackground(const Common::Rect &r, uint16 hints, Widg } } +void ThemeEngine::drawWidgetBackgroundClip(const Common::Rect &r, const Common::Rect &clip, uint16 hints, WidgetBackground background, WidgetStateInfo state) { + if (!ready()) + return; + + switch (background) { + case kWidgetBackgroundBorderSmall: + queueDDClip(kDDWidgetBackgroundSmall, r, clip); + break; + + case kWidgetBackgroundEditText: + queueDDClip(kDDWidgetBackgroundEditText, r, clip); + break; + + case kWidgetBackgroundSlider: + queueDDClip(kDDWidgetBackgroundSlider, r, clip); + break; + + default: + queueDDClip(kDDWidgetBackgroundDefault, r, clip); + break; + } +} + void ThemeEngine::drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array &tabs, int active, uint16 hints, int titleVPad, WidgetStateInfo state) { if (!ready()) return; -- cgit v1.2.3 From 425d963bd3c927e529efdfed817960dec8de4552 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Wed, 22 Jun 2016 17:27:32 +0600 Subject: GUI: Fix ThemeItemTextData's dirty rectangle --- gui/ThemeEngine.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'gui/ThemeEngine.cpp') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 037940dfd4..a38e565f6c 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -276,15 +276,19 @@ void ThemeItemDrawDataClip::drawSelf(bool draw, bool restore) { } void ThemeItemTextData::drawSelf(bool draw, bool restore) { + Common::Rect dirty = _textDrawableArea; + if (dirty.isEmpty()) dirty = _area; + else dirty.clip(_area); + if (_restoreBg || restore) - _engine->restoreBackground(_area); + _engine->restoreBackground(dirty); if (draw) { _engine->renderer()->setFgColor(_color->r, _color->g, _color->b); _engine->renderer()->drawString(_data->_fontPtr, _text, _area, _alignH, _alignV, _deltax, _ellipsis, _textDrawableArea); } - _engine->addDirtyRect(_area); + _engine->addDirtyRect(dirty); } void ThemeItemBitmap::drawSelf(bool draw, bool restore) { @@ -1414,12 +1418,12 @@ void ThemeEngine::drawTextClip(const Common::Rect &r, const Common::Rect &clippi switch (inverted) { case kTextInversion: - queueDD(kDDTextSelectionBackground, r); + queueDDClip(kDDTextSelectionBackground, r, clippingArea); restore = false; break; case kTextInversionFocus: - queueDD(kDDTextSelectionFocusBackground, r); + queueDDClip(kDDTextSelectionFocusBackground, r, clippingArea); restore = false; break; -- cgit v1.2.3 From 559ca37dafea7fa07f2453ee9221df072c501b22 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Wed, 29 Jun 2016 15:40:37 +0600 Subject: GUI: Add VectorRendererSpec::drawTriangleClip() --- gui/ThemeEngine.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'gui/ThemeEngine.cpp') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index a38e565f6c..6d9f7d8a7d 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -1127,6 +1127,29 @@ void ThemeEngine::drawScrollbar(const Common::Rect &r, int sliderY, int sliderHe queueDD(scrollState == kScrollbarStateSlider ? kDDScrollbarHandleHover : kDDScrollbarHandleIdle, r2); } +void ThemeEngine::drawScrollbarClip(const Common::Rect &r, const Common::Rect &clippingRect, int sliderY, int sliderHeight, ScrollbarState scrollState, WidgetStateInfo state) { + if (!ready()) + return; + + queueDDClip(kDDScrollbarBase, r, clippingRect); + + Common::Rect r2 = r; + const int buttonExtra = (r.width() * 120) / 100; + + r2.bottom = r2.top + buttonExtra; + queueDDClip(scrollState == kScrollbarStateUp ? kDDScrollbarButtonHover : kDDScrollbarButtonIdle, r2, clippingRect, Graphics::VectorRenderer::kTriangleUp); + + r2.translate(0, r.height() - r2.height()); + queueDDClip(scrollState == kScrollbarStateDown ? kDDScrollbarButtonHover : kDDScrollbarButtonIdle, r2, clippingRect, Graphics::VectorRenderer::kTriangleDown); + + r2 = r; + r2.left += 1; + r2.right -= 1; + r2.top += sliderY; + r2.bottom = r2.top + sliderHeight; + queueDDClip(scrollState == kScrollbarStateSlider ? kDDScrollbarHandleHover : kDDScrollbarHandleIdle, r2, clippingRect); +} + void ThemeEngine::drawDialogBackground(const Common::Rect &r, DialogBackground bgtype, WidgetStateInfo state) { if (!ready()) return; @@ -1199,7 +1222,7 @@ void ThemeEngine::drawPopUpWidgetClip(const Common::Rect &r, const Common::Rect else if (state == kStateDisabled) dd = kDDPopUpDisabled; - queueDDClip(dd, r, clip); + queueDDClip(dd, r, clip); if (!sel.empty()) { Common::Rect text(r.left + 3, r.top + 1, r.right - 10, r.bottom); -- cgit v1.2.3 From f22d11953d355f8b56d504301997eb4643c299bc Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Wed, 29 Jun 2016 18:38:08 +0600 Subject: GUI: Add drawSquareClip() --- gui/ThemeEngine.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'gui/ThemeEngine.cpp') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 6d9f7d8a7d..13bf8133ef 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -1177,6 +1177,35 @@ void ThemeEngine::drawDialogBackground(const Common::Rect &r, DialogBackground b } } +void ThemeEngine::drawDialogBackgroundClip(const Common::Rect &r, const Common::Rect &clip, DialogBackground bgtype, WidgetStateInfo state) { + if (!ready()) + return; + + switch (bgtype) { + case kDialogBackgroundMain: + queueDDClip(kDDMainDialogBackground, r, clip); + break; + + case kDialogBackgroundSpecial: + queueDDClip(kDDSpecialColorBackground, r, clip); + break; + + case kDialogBackgroundPlain: + queueDDClip(kDDPlainColorBackground, r, clip); + break; + + case kDialogBackgroundTooltip: + queueDDClip(kDDTooltipBackground, r, clip); + break; + + case kDialogBackgroundDefault: + queueDDClip(kDDDefaultBackground, r, clip); + break; + case kDialogBackgroundNone: + break; + } +} + void ThemeEngine::drawCaret(const Common::Rect &r, bool erase, WidgetStateInfo state) { if (!ready()) return; @@ -1188,6 +1217,17 @@ void ThemeEngine::drawCaret(const Common::Rect &r, bool erase, WidgetStateInfo s queueDD(kDDCaret, r); } +void ThemeEngine::drawCaretClip(const Common::Rect &r, const Common::Rect &clip, bool erase, WidgetStateInfo state) { + if (!ready()) + return; + + if (erase) { + restoreBackground(r); + addDirtyRect(r); + } else + queueDDClip(kDDCaret, r, clip); +} + void ThemeEngine::drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, WidgetStateInfo state, Graphics::TextAlign align) { if (!ready()) return; -- cgit v1.2.3 From 80412a4139d19024a9ef941004380e6bbb8d4da9 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Wed, 29 Jun 2016 21:07:12 +0600 Subject: GUI: Add drawTabClip() --- gui/ThemeEngine.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'gui/ThemeEngine.cpp') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 13bf8133ef..08245380a8 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -1351,6 +1351,34 @@ void ThemeEngine::drawTab(const Common::Rect &r, int tabHeight, int tabWidth, co } } +void ThemeEngine::drawTabClip(const Common::Rect &r, const Common::Rect &clip, int tabHeight, int tabWidth, const Common::Array &tabs, int active, uint16 hints, int titleVPad, WidgetStateInfo state) { + if (!ready()) + return; + + queueDDClip(kDDTabBackground, Common::Rect(r.left, r.top, r.right, r.top + tabHeight), clip); + + for (int i = 0; i < (int)tabs.size(); ++i) { + if (i == active) + continue; + + if (r.left + i * tabWidth > r.right || r.left + (i + 1) * tabWidth > r.right) + continue; + + Common::Rect tabRect(r.left + i * tabWidth, r.top, r.left + (i + 1) * tabWidth, r.top + tabHeight); + queueDDClip(kDDTabInactive, tabRect, clip); + queueDDTextClip(getTextData(kDDTabInactive), getTextColor(kDDTabInactive), tabRect, clip, tabs[i], false, false, _widgets[kDDTabInactive]->_textAlignH, _widgets[kDDTabInactive]->_textAlignV); + } + + if (active >= 0 && + (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); + const uint16 tabLeft = active * tabWidth; + const uint16 tabRight = MAX(r.right - tabRect.right, 0); + queueDDClip(kDDTabActive, tabRect, clip, (tabLeft << 16) | (tabRight & 0xFFFF)); + queueDDTextClip(getTextData(kDDTabActive), getTextColor(kDDTabActive), tabRect, clip, tabs[active], false, false, _widgets[kDDTabActive]->_textAlignH, _widgets[kDDTabActive]->_textAlignV); + } +} + void ThemeEngine::drawText(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, Graphics::TextAlign align, TextInversionState inverted, int deltax, bool useEllipsis, FontStyle font, FontColor color, bool restore, const Common::Rect &drawableTextArea) { if (!ready()) return; -- cgit v1.2.3 From 4b87563792163d5fd538092b340500bccd20aa7b Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Thu, 30 Jun 2016 23:34:25 +0600 Subject: GUI: Add blipClip() --- gui/ThemeEngine.cpp | 7 ------- 1 file changed, 7 deletions(-) (limited to 'gui/ThemeEngine.cpp') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 08245380a8..b16a42806c 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -168,8 +168,6 @@ protected: bool _alpha; }; - - /********************************************************** * Data definitions for theme engine elements *********************************************************/ @@ -306,7 +304,6 @@ void ThemeItemBitmap::drawSelf(bool draw, bool restore) { } - /********************************************************** * ThemeEngine class *********************************************************/ @@ -979,8 +976,6 @@ void ThemeEngine::queueBitmap(const Graphics::Surface *bitmap, const Common::Rec } } - - /********************************************************** * Widget drawing functions *********************************************************/ @@ -1201,8 +1196,6 @@ void ThemeEngine::drawDialogBackgroundClip(const Common::Rect &r, const Common:: case kDialogBackgroundDefault: queueDDClip(kDDDefaultBackground, r, clip); break; - case kDialogBackgroundNone: - break; } } -- cgit v1.2.3 From 6fd6043391d7faef569612797fb1c181c45a91dc Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Fri, 1 Jul 2016 13:04:25 +0600 Subject: GUI: Fix blitAlphaBitmapClip() --- gui/ThemeEngine.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'gui/ThemeEngine.cpp') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index b16a42806c..6174d41ddd 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -168,6 +168,19 @@ protected: bool _alpha; }; +class ThemeItemBitmapClip : public ThemeItem { +public: + ThemeItemBitmapClip(ThemeEngine *engine, const Common::Rect &area, const Common::Rect &clip, const Graphics::Surface *bitmap, bool alpha) : + ThemeItem(engine, area), _bitmap(bitmap), _alpha(alpha), _clip(clip) {} + + void drawSelf(bool draw, bool restore); + +protected: + const Graphics::Surface *_bitmap; + bool _alpha; + const Common::Rect _clip; +}; + /********************************************************** * Data definitions for theme engine elements *********************************************************/ @@ -303,6 +316,21 @@ void ThemeItemBitmap::drawSelf(bool draw, bool restore) { _engine->addDirtyRect(_area); } +void ThemeItemBitmapClip::drawSelf(bool draw, bool restore) { + if (restore) + _engine->restoreBackground(_area); + + if (draw) { + if (_alpha) + _engine->renderer()->blitAlphaBitmapClip(_bitmap, _area, _clip); + else + _engine->renderer()->blitSubSurfaceClip(_bitmap, _area, _clip); + } + + Common::Rect dirtyRect = _area; + dirtyRect.clip(_clip); + _engine->addDirtyRect(dirtyRect); +} /********************************************************** * ThemeEngine class @@ -976,6 +1004,21 @@ void ThemeEngine::queueBitmap(const Graphics::Surface *bitmap, const Common::Rec } } +void ThemeEngine::queueBitmapClip(const Graphics::Surface *bitmap, const Common::Rect &r, const Common::Rect &clip, bool alpha) { + + Common::Rect area = r; + area.clip(_screen.w, _screen.h); + + ThemeItemBitmapClip *q = new ThemeItemBitmapClip(this, area, clip, bitmap, alpha); + + if (_buffering) { + _screenQueue.push_back(q); + } else { + q->drawSelf(true, false); + delete q; + } +} + /********************************************************** * Widget drawing functions *********************************************************/ @@ -1270,6 +1313,13 @@ void ThemeEngine::drawSurface(const Common::Rect &r, const Graphics::Surface &su queueBitmap(&surface, r, themeTrans); } +void ThemeEngine::drawSurfaceClip(const Common::Rect &r, const Common::Rect &clip, const Graphics::Surface &surface, WidgetStateInfo state, int alpha, bool themeTrans) { + if (!ready()) + return; + + queueBitmapClip(&surface, r, clip, themeTrans); +} + void ThemeEngine::drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background, WidgetStateInfo state) { if (!ready()) return; -- cgit v1.2.3 From 3d636617d0781bdd477551a87f6b9fc60e0a4a1f Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Fri, 1 Jul 2016 14:25:05 +0600 Subject: GUI: Use clipping everywhere --- gui/ThemeEngine.cpp | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) (limited to 'gui/ThemeEngine.cpp') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 6174d41ddd..b1decb1b74 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -1067,6 +1067,13 @@ void ThemeEngine::drawLineSeparator(const Common::Rect &r, WidgetStateInfo state queueDD(kDDSeparator, r); } +void ThemeEngine::drawLineSeparatorClip(const Common::Rect &r, const Common::Rect &clippingRect, WidgetStateInfo state) { + if (!ready()) + return; + + queueDDClip(kDDSeparator, r, clippingRect); +} + void ThemeEngine::drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state) { if (!ready()) return; @@ -1093,6 +1100,32 @@ void ThemeEngine::drawCheckbox(const Common::Rect &r, const Common::String &str, queueDDText(getTextData(dd), getTextColor(dd), r2, str, true, false, _widgets[kDDCheckboxDefault]->_textAlignH, _widgets[dd]->_textAlignV); } +void ThemeEngine::drawCheckboxClip(const Common::Rect &r, const Common::Rect &clip, const Common::String &str, bool checked, WidgetStateInfo state) { + if (!ready()) + return; + + Common::Rect r2 = r; + DrawData dd = kDDCheckboxDefault; + + if (checked) + dd = kDDCheckboxSelected; + + if (state == kStateDisabled) + dd = kDDCheckboxDisabled; + + const int checkBoxSize = MIN((int)r.height(), getFontHeight()); + + r2.bottom = r2.top + checkBoxSize; + r2.right = r2.left + checkBoxSize; + + queueDDClip(dd, r2, clip); + + r2.left = r2.right + checkBoxSize; + r2.right = r.right; + + queueDDTextClip(getTextData(dd), getTextColor(dd), r2, clip, str, true, false, _widgets[kDDCheckboxDefault]->_textAlignH, _widgets[dd]->_textAlignV); +} + void ThemeEngine::drawRadiobutton(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state) { if (!ready()) return; @@ -1119,6 +1152,32 @@ void ThemeEngine::drawRadiobutton(const Common::Rect &r, const Common::String &s queueDDText(getTextData(dd), getTextColor(dd), r2, str, true, false, _widgets[kDDRadiobuttonDefault]->_textAlignH, _widgets[dd]->_textAlignV); } +void ThemeEngine::drawRadiobuttonClip(const Common::Rect &r, const Common::Rect &clippingRect, const Common::String &str, bool checked, WidgetStateInfo state) { + if (!ready()) + return; + + Common::Rect r2 = r; + DrawData dd = kDDRadiobuttonDefault; + + if (checked) + dd = kDDRadiobuttonSelected; + + if (state == kStateDisabled) + dd = kDDRadiobuttonDisabled; + + const int checkBoxSize = MIN((int)r.height(), getFontHeight()); + + r2.bottom = r2.top + checkBoxSize; + r2.right = r2.left + checkBoxSize; + + queueDDClip(dd, r2, clippingRect); + + r2.left = r2.right + checkBoxSize; + r2.right = r.right; + + queueDDTextClip(getTextData(dd), getTextColor(dd), r2, clippingRect, str, true, false, _widgets[kDDRadiobuttonDefault]->_textAlignH, _widgets[dd]->_textAlignV); +} + void ThemeEngine::drawSlider(const Common::Rect &r, int width, WidgetStateInfo state) { if (!ready()) return; @@ -1139,6 +1198,26 @@ void ThemeEngine::drawSlider(const Common::Rect &r, int width, WidgetStateInfo s queueDD(dd, r2); } +void ThemeEngine::drawSliderClip(const Common::Rect &r, const Common::Rect &clip, int width, WidgetStateInfo state) { + if (!ready()) + return; + + DrawData dd = kDDSliderFull; + + if (state == kStateHighlight) + dd = kDDSliderHover; + else if (state == kStateDisabled) + dd = kDDSliderDisabled; + + Common::Rect r2 = r; + r2.setWidth(MIN((int16)width, r.width())); + // r2.top++; r2.bottom--; r2.left++; r2.right--; + + drawWidgetBackgroundClip(r, clip, 0, kWidgetBackgroundSlider, kStateEnabled); + + queueDDClip(dd, r2, clip); +} + void ThemeEngine::drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState scrollState, WidgetStateInfo state) { if (!ready()) return; @@ -1582,6 +1661,21 @@ void ThemeEngine::drawChar(const Common::Rect &r, byte ch, const Graphics::Font addDirtyRect(charArea); } +void ThemeEngine::drawCharClip(const Common::Rect &r, const Common::Rect &clip, byte ch, const Graphics::Font *font, WidgetStateInfo state, FontColor color) { + if (!ready()) + return; + + Common::Rect charArea = r; + charArea.clip(_screen.w, _screen.h); + if (!clip.isEmpty()) charArea.clip(clip); + + uint32 rgbColor = _overlayFormat.RGBToColor(_textColors[color]->r, _textColors[color]->g, _textColors[color]->b); + + restoreBackground(charArea); + font->drawChar(&_screen, ch, charArea.left, charArea.top, rgbColor); + addDirtyRect(charArea); +} + void ThemeEngine::debugWidgetPosition(const char *name, const Common::Rect &r) { _font->drawString(&_screen, name, r.left, r.top, r.width(), 0xFFFF, Graphics::kTextAlignRight, 0, true); _screen.hLine(r.left, r.top, r.right, 0xFFFF); -- cgit v1.2.3 From cea58cc61c12206f41b64ba0094655dcd84b57af Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Sat, 2 Jul 2016 13:26:05 +0600 Subject: JANITORIAL: Remove trailing spaces --- gui/ThemeEngine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gui/ThemeEngine.cpp') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index b1decb1b74..c850a6a02e 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -1377,7 +1377,7 @@ void ThemeEngine::drawPopUpWidgetClip(const Common::Rect &r, const Common::Rect else if (state == kStateDisabled) dd = kDDPopUpDisabled; - queueDDClip(dd, r, clip); + queueDDClip(dd, r, clip); if (!sel.empty()) { Common::Rect text(r.left + 3, r.top + 1, r.right - 10, r.bottom); -- cgit v1.2.3