diff options
author | Bastien Bouclet | 2019-11-13 21:09:21 +0100 |
---|---|---|
committer | Bastien Bouclet | 2019-11-24 14:06:25 +0100 |
commit | 2c812a6b7a0b24b9012379118867fb4f64f32c14 (patch) | |
tree | 6f4225127305dbdae8f3a0dc7dfe61e51af51b1a /graphics | |
parent | 3db6aed4e474d5b16639ee4958d1cd13504d12fb (diff) | |
download | scummvm-rg350-2c812a6b7a0b24b9012379118867fb4f64f32c14.tar.gz scummvm-rg350-2c812a6b7a0b24b9012379118867fb4f64f32c14.tar.bz2 scummvm-rg350-2c812a6b7a0b24b9012379118867fb4f64f32c14.zip |
GUI: Add DropdownButtonWidget and use it in the launcher for mass add
DropdownButtonWidget is a button split in two parts vertically. Clicking
the left part triggers a default action. Clicking the right part shows a
list of other actions the user can choose from.
Using this widget on the launcher lets 'Mass add' be a secondary action
of the 'Add' button, removing the necessity of pressing the shift key to
access the feature.
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/VectorRenderer.cpp | 41 | ||||
-rw-r--r-- | graphics/VectorRenderer.h | 8 | ||||
-rw-r--r-- | graphics/VectorRendererSpec.cpp | 4 |
3 files changed, 47 insertions, 6 deletions
diff --git a/graphics/VectorRenderer.cpp b/graphics/VectorRenderer.cpp index e226e45475..bcab4bf5a2 100644 --- a/graphics/VectorRenderer.cpp +++ b/graphics/VectorRenderer.cpp @@ -52,13 +52,48 @@ void VectorRenderer::drawStep(const Common::Rect &area, const Common::Rect &clip setGradientFactor(step.factor); setStrokeWidth(step.stroke); setFillMode((FillMode)step.fillMode); - setClippingRect(clip); + setClippingRect(applyStepClippingRect(area, clip, step)); _dynamicData = extra; (this->*(step.drawingCall))(area, step); } +Common::Rect VectorRenderer::applyStepClippingRect(const Common::Rect &area, const Common::Rect &clip, const DrawStep &step) { + if (step.clip == Common::Rect()) { + return clip; + } + + Common::Rect finalClip = clip; + if (step.clip.left > 0) { + finalClip.left = area.left + step.clip.left; + } else if (step.clip.left < 0) { + finalClip.left = area.right + step.clip.left; + } + + if (step.clip.top > 0) { + finalClip.top = area.top + step.clip.top; + } else if (step.clip.top < 0) { + finalClip.top = area.bottom + step.clip.top; + } + + if (step.clip.right > 0) { + finalClip.right = area.left + step.clip.right; + } else if (step.clip.right < 0) { + finalClip.right = area.right + step.clip.right; + } + + if (step.clip.bottom > 0) { + finalClip.bottom = area.top + step.clip.bottom; + } else if (step.clip.bottom < 0) { + finalClip.bottom = area.bottom + step.clip.bottom; + } + + finalClip.clip(clip); + + return finalClip; +} + int VectorRenderer::stepGetRadius(const DrawStep &step, const Common::Rect &area) { int radius = 0; @@ -102,7 +137,7 @@ void VectorRenderer::stepGetPositions(const DrawStep &step, const Common::Rect & } } else { in_x = area.left + step.padding.left; - in_w = area.width(); + in_w = area.width() - step.padding.left - step.padding.right; } if (!step.autoHeight) { @@ -133,7 +168,7 @@ void VectorRenderer::stepGetPositions(const DrawStep &step, const Common::Rect & } } else { in_y = area.top + step.padding.top; - in_h = area.height(); + in_h = area.height() - step.padding.top - step.padding.bottom; } if (step.scale != (1 << 16) && step.scale != 0) { diff --git a/graphics/VectorRenderer.h b/graphics/VectorRenderer.h index 9be55460c2..28a987a927 100644 --- a/graphics/VectorRenderer.h +++ b/graphics/VectorRenderer.h @@ -64,6 +64,7 @@ struct DrawStep { negative values mean counting from the opposite direction */ Common::Rect padding; + Common::Rect clip; /**< Clipping rect restriction */ enum VectorAlignment { kVectorAlignManual, @@ -392,6 +393,11 @@ public: int stepGetRadius(const DrawStep &step, const Common::Rect &area); /** + * Restrict a draw call clipping rect with a step specific clipping rect + */ + Common::Rect applyStepClippingRect(const Common::Rect &area, const Common::Rect &clip, const DrawStep &step); + + /** * DrawStep callback functions for each drawing feature */ void drawCallback_CIRCLE(const Common::Rect &area, const DrawStep &step) { @@ -412,7 +418,7 @@ public: void drawCallback_LINE(const Common::Rect &area, const DrawStep &step) { uint16 x, y, w, h; stepGetPositions(step, area, x, y, w, h); - drawLine(x, y, x + w, y + w); + drawLine(x, y, x + w, y + h); } void drawCallback_ROUNDSQ(const Common::Rect &area, const DrawStep &step) { diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp index 457e9ff149..a1d8ba3599 100644 --- a/graphics/VectorRendererSpec.cpp +++ b/graphics/VectorRendererSpec.cpp @@ -670,9 +670,9 @@ gradientFillClip(PixelType *ptr, int width, int x, int y, int realX, int realY) if (grad == 0 || _gradCache[curGrad] == _gradCache[curGrad + 1] || // no color change stripSize < 2) { // the stip is small - colorFill<PixelType>(ptr, ptr + width, _gradCache[curGrad]); + colorFillClip<PixelType>(ptr, ptr + width, _gradCache[curGrad], realX, realY, _clippingArea); } else if (grad == 3 && ox) { - colorFill<PixelType>(ptr, ptr + width, _gradCache[curGrad + 1]); + colorFillClip<PixelType>(ptr, ptr + width, _gradCache[curGrad + 1], realX, realY, _clippingArea); } else { for (int j = x; j < x + width; j++, ptr++) { if (realX + j - x < _clippingArea.left || realX + j - x >= _clippingArea.right) continue; |