From 3d2730a0ddd1e1e33e6639775727beb954d7bfc0 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Tue, 21 Jun 2016 16:45:07 +0600 Subject: [PATCH] GUI: clippingRect propagated deeper --- graphics/VectorRenderer.h | 3 ++- graphics/VectorRendererSpec.cpp | 23 +++++++++++++++++++++++ graphics/VectorRendererSpec.h | 1 + gui/ThemeEngine.cpp | 3 +-- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/graphics/VectorRenderer.h b/graphics/VectorRenderer.h index e98dbc22cf9..2af91d3587b 100644 --- a/graphics/VectorRenderer.h +++ b/graphics/VectorRenderer.h @@ -173,6 +173,7 @@ public: * @param r Radius of the corners. */ virtual void drawRoundedSquare(int x, int y, int r, int w, int h) = 0; + virtual void drawRoundedSquareClip(int x, int y, int r, int w, int h, int cx, int cy, int cw, int ch) = 0; /** * Draws a triangle starting at (x,y) with the given base and height. @@ -379,7 +380,7 @@ public: void drawCallback_ROUNDSQ(const Common::Rect &area, const DrawStep &step, const Common::Rect &clip) { //TODO uint16 x, y, w, h; stepGetPositions(step, area, x, y, w, h); - drawRoundedSquare(x, y, stepGetRadius(step, area), w, h); + drawRoundedSquareClip(x, y, stepGetRadius(step, area), w, h, clip.left, clip.top, clip.right-clip.left, clip.bottom-clip.top); } void drawCallback_FILLSURFACE(const Common::Rect &area, const DrawStep &step, const Common::Rect &clip) { //TODO diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp index 258d935440b..6c559e0f701 100644 --- a/graphics/VectorRendererSpec.cpp +++ b/graphics/VectorRendererSpec.cpp @@ -918,6 +918,29 @@ drawRoundedSquare(int x, int y, int r, int w, int h) { drawRoundedSquareAlg(x, y, r, w, h, _fgColor, Base::_fillMode); } +template +void VectorRendererSpec:: +drawRoundedSquareClip(int x, int y, int r, int w, int h, int cx, int cy, int cw, int ch) { + if (x + w > Base::_activeSurface->w || y + h > Base::_activeSurface->h || + w <= 0 || h <= 0 || x < 0 || y < 0 || r <= 0) + return; + + if ((r * 2) > w || (r * 2) > h) + r = MIN(w / 2, h / 2); + + if (r <= 0) + return; + + if (Base::_fillMode != kFillDisabled && Base::_shadowOffset + && x + w + Base::_shadowOffset + 1 < Base::_activeSurface->w + && y + h + Base::_shadowOffset + 1 < Base::_activeSurface->h + && h > (Base::_shadowOffset + 1) * 2) { + drawRoundedSquareShadow(x, y, r, w, h, Base::_shadowOffset); + } + + drawRoundedSquareAlg(x, y, r, w, h, _fgColor, Base::_fillMode); +} + template void VectorRendererSpec:: drawTab(int x, int y, int r, int w, int h) { diff --git a/graphics/VectorRendererSpec.h b/graphics/VectorRendererSpec.h index 3e54608b8e6..13377d80e82 100644 --- a/graphics/VectorRendererSpec.h +++ b/graphics/VectorRendererSpec.h @@ -54,6 +54,7 @@ public: void drawCircle(int x, int y, int r); void drawSquare(int x, int y, int w, int h); void drawRoundedSquare(int x, int y, int r, int w, int h); + void drawRoundedSquareClip(int x, int y, int r, int w, int h, int cx, int cy, int cw, int ch); void drawTriangle(int x, int y, int base, int height, TriangleOrientation orient); void drawTab(int x, int y, int r, int w, int h); void drawBeveledSquare(int x, int y, int w, int h, int bevel) { diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 12788c22332..3c6f5956a8f 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) {