aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorThierry Crozat2017-06-05 13:24:34 +0100
committerThierry Crozat2017-06-20 19:36:56 +0100
commit3213c426a5ffdabb944a5e1a8e137e2d6a6b88d6 (patch)
treea4fa446f29a8eeaaaab4a1b7367f427503290ded /gui
parent9f055d4ba12e809abab41ab1b7af1794eb75a1f6 (diff)
downloadscummvm-rg350-3213c426a5ffdabb944a5e1a8e137e2d6a6b88d6.tar.gz
scummvm-rg350-3213c426a5ffdabb944a5e1a8e137e2d6a6b88d6.tar.bz2
scummvm-rg350-3213c426a5ffdabb944a5e1a8e137e2d6a6b88d6.zip
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.
Diffstat (limited to 'gui')
-rw-r--r--gui/ThemeEngine.cpp18
1 files changed, 14 insertions, 4 deletions
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<Graphics::DrawStep>::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) {