From 3213c426a5ffdabb944a5e1a8e137e2d6a6b88d6 Mon Sep 17 00:00:00 2001 From: Thierry Crozat Date: Mon, 5 Jun 2017 13:24:34 +0100 Subject: GUI: Separate bevel and shadow effect when extending widget rect When widget::draw() is called it asks the ThemeEngine to redraw the background first and then the widget gets redrawn in drawWidget(). The ThemeEngine uses an extended rect to restore the background to include bevel and shadow effects. However if this extended rect overlaps with other widgets, since those other widgets are not redrawn, a part of those will be missing. See for example bug #6394: GUI: List View save page drawns over font. In case we get overlap we might need to change the way widgets are drawn so that all widgets intersecting the area where the backgroud is restored are redrawn. This commit simply seperate the bevel and shadow effects, and uses the shadow offset only to extend the bottom and right sides of the rectangle (while the bevel offset is still used to extend all four sides). This results in a smaller extended rectangle (if the shadow offset is bigger than the bevel offset, which is the case of the list view) and thus decrease the risk of the issue happening. The particular cases described in bug #6394 are all fixed with this change. --- gui/ThemeEngine.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'gui') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index ecea94524c..d340047b1c 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -87,6 +87,7 @@ struct WidgetDrawData { E.g. when taking into account rounded corners, drop shadows, etc Used when restoring the widget background */ uint16 _backgroundOffset; + uint16 _shadowOffset; bool _buffer; @@ -271,6 +272,10 @@ void ThemeItemDrawData::drawSelf(bool draw, bool restore) { Common::Rect extendedRect = _area; extendedRect.grow(_engine->kDirtyRectangleThreshold + _data->_backgroundOffset); + if (_data->_shadowOffset > _data->_backgroundOffset) { + extendedRect.right += _data->_shadowOffset - _data->_backgroundOffset; + extendedRect.bottom += _data->_shadowOffset - _data->_backgroundOffset; + } if (restore) _engine->restoreBackground(extendedRect); @@ -288,6 +293,10 @@ void ThemeItemDrawDataClip::drawSelf(bool draw, bool restore) { Common::Rect extendedRect = _area; extendedRect.grow(_engine->kDirtyRectangleThreshold + _data->_backgroundOffset); + if (_data->_shadowOffset > _data->_backgroundOffset) { + extendedRect.right += _data->_shadowOffset - _data->_backgroundOffset; + extendedRect.bottom += _data->_shadowOffset - _data->_backgroundOffset; + } if (restore) _engine->restoreBackground(extendedRect); @@ -646,17 +655,18 @@ void ThemeEngine::setGraphicsMode(GraphicsMode mode) { } void WidgetDrawData::calcBackgroundOffset() { - uint maxShadow = 0; + uint maxShadow = 0, maxBevel = 0; for (Common::List::const_iterator step = _steps.begin(); step != _steps.end(); ++step) { if ((step->autoWidth || step->autoHeight) && step->shadow > maxShadow) maxShadow = step->shadow; - if (step->drawingCall == &Graphics::VectorRenderer::drawCallback_BEVELSQ && step->bevel > maxShadow) - maxShadow = step->bevel; + if (step->drawingCall == &Graphics::VectorRenderer::drawCallback_BEVELSQ && step->bevel > maxBevel) + maxBevel = step->bevel; } - _backgroundOffset = maxShadow; + _backgroundOffset = maxBevel; + _shadowOffset = maxShadow; } void ThemeEngine::restoreBackground(Common::Rect r) { -- cgit v1.2.3