From c7b624d91eaa0444fdc454dfb5c5dd7beaa56bcc Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Mon, 21 Jul 2008 19:42:35 +0000 Subject: Bugfix: Rounded squares at low resolutions were not drawn. Cleanup. svn-id: r33179 --- graphics/VectorRenderer.cpp | 86 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) (limited to 'graphics/VectorRenderer.cpp') diff --git a/graphics/VectorRenderer.cpp b/graphics/VectorRenderer.cpp index 190bbbb40a..9b460e1ac0 100644 --- a/graphics/VectorRenderer.cpp +++ b/graphics/VectorRenderer.cpp @@ -84,6 +84,87 @@ void VectorRenderer::textStep(const Common::String &text, const Common::Rect &ar !step.hasAlign ? GUI::Theme::kTextAlignVTop : step.alignVertical); } +int VectorRenderer::stepGetRadius(const DrawStep &step, const Common::Rect &area) { + int radius = 0; + + if (step.radius == 0xFF) + radius = MIN(area.width(), area.height()) / 2; + else + radius = step.radius; + + if (step.scale != (1 << 16) && step.scale != 0) + radius = (radius * step.scale) >> 16; + + return radius; +} + +void VectorRenderer::stepGetPositions(const DrawStep &step, const Common::Rect &area, uint16 &in_x, uint16 &in_y, uint16 &in_w, uint16 &in_h) { + if (!step.autoWidth) { + in_w = step.w == -1 ? area.height() : step.w; + + switch(step.xAlign) { + case Graphics::DrawStep::kVectorAlignManual: + if (step.x >= 0) in_x = area.left + step.x; + else in_x = area.left + area.width() + step.x; // value relative to the opposite corner. + break; + + case Graphics::DrawStep::kVectorAlignCenter: + in_x = area.left + (area.width() / 2) - (in_w / 2); + break; + + case Graphics::DrawStep::kVectorAlignLeft: + in_x = area.left; + break; + + case Graphics::DrawStep::kVectorAlignRight: + in_x = area.left + area.width() - in_w; + break; + + default: + error("Vertical alignment in horizontal data."); + } + } else { + in_x = area.left; + in_w = area.width(); + } + + if (!step.autoHeight) { + in_h = step.h == -1 ? area.width() : step.h; + + switch(step.yAlign) { + case Graphics::DrawStep::kVectorAlignManual: + if (step.y >= 0) in_y = area.top + step.y; + else in_y = area.top + area.height() + step.y; // relative + break; + + case Graphics::DrawStep::kVectorAlignCenter: + in_y = area.top + (area.height() / 2) - (in_h / 2); + break; + + case Graphics::DrawStep::kVectorAlignTop: + in_y = area.top; + break; + + case Graphics::DrawStep::kVectorAlignBottom: + in_y = area.top + area.height() - in_h; + break; + + default: + error("Horizontal alignment in vertical data."); + } + } else { + in_y = area.top; + in_h = area.height(); + } + + if (step.scale != (1 << 16) && step.scale != 0) { + in_x = (in_x * step.scale) >> 16; + in_y = (in_y * step.scale) >> 16; + in_w = (in_w * step.scale) >> 16; + in_h = (in_h * step.scale) >> 16; + } +} + /******************************************************************** * MISCELANEOUS functions ********************************************************************/ @@ -356,8 +437,11 @@ template void VectorRendererSpec:: drawRoundedSquare(int x, int y, int r, int w, int h) { if (x + w > Base::_activeSurface->w || y + h > Base::_activeSurface->h || - w <= 0 || h <= 0 || x < 0 || y < 0 || (r << 1) > w || (r << 1) > h) + w <= 0 || h <= 0 || x < 0 || y < 0) return; + + while ((r << 1) > w || (r << 1) > h) + r <<= 1; if (Base::_fillMode != kFillDisabled && Base::_shadowOffset && x + w + Base::_shadowOffset < Base::_activeSurface->w -- cgit v1.2.3