From b188e800b7bb0ad2c4f305e3f10f645c504f4e90 Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 10 Apr 2025 09:48:21 +1000 Subject: Avoid 'magic' number with constexpr and add comments. --- src/LineMarker.cxx | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/LineMarker.cxx b/src/LineMarker.cxx index faa32d9aa..85d8a7b59 100644 --- a/src/LineMarker.cxx +++ b/src/LineMarker.cxx @@ -464,11 +464,13 @@ void LineMarker::Draw(Surface *surface, const PRectangle &rcWhole, const Font *f break; case MarkerSymbol::DotDotDot: { - XYPOSITION right = static_cast(centreX - 6); + // 3 2x2 dots with 3 pixels between, margin must be 12 wide to show all + constexpr XYPOSITION pitchDots = 5.0; + XYPOSITION xBlob = std::floor(centreX - (pitchDots + 1)); for (int b = 0; b < 3; b++) { - const PRectangle rcBlob(right, rc.bottom - 4, right + 2, rc.bottom - 2); + const PRectangle rcBlob(xBlob, rc.bottom - 4, xBlob + 2, rc.bottom - 2); surface->FillRectangle(rcBlob, fore); - right += 5.0f; + xBlob += pitchDots; } } break; @@ -516,26 +518,28 @@ void LineMarker::Draw(Surface *surface, const PRectangle &rcWhole, const Font *f break; case MarkerSymbol::Bar: { + // Hide cap by continuing a bit. + constexpr XYPOSITION continueLength = 5.0; PRectangle rcBar = rcWhole; const XYPOSITION widthBar = std::floor(rcWhole.Width() / 3.0); rcBar.left = centreX - std::floor(widthBar / 2.0); rcBar.right = rcBar.left + widthBar; - surface->SetClip(rcWhole); + surface->SetClip(rcWhole); // Hide continued caps switch (part) { case LineMarker::FoldPart::headWithTail: surface->RectangleDraw(rcBar, FillStroke(back, fore, strokeWidth)); break; case LineMarker::FoldPart::head: - rcBar.bottom += 5; + rcBar.bottom += continueLength; surface->RectangleDraw(rcBar, FillStroke(back, fore, strokeWidth)); break; case LineMarker::FoldPart::tail: - rcBar.top -= 5; + rcBar.top -= continueLength; surface->RectangleDraw(rcBar, FillStroke(back, fore, strokeWidth)); break; case LineMarker::FoldPart::body: - rcBar.top -= 5; - rcBar.bottom += 5; + rcBar.top -= continueLength; + rcBar.bottom += continueLength; surface->RectangleDraw(rcBar, FillStroke(back, fore, strokeWidth)); break; default: -- cgit v1.2.3