diff options
author | Neil <nyamatongwe@gmail.com> | 2025-04-10 09:48:21 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2025-04-10 09:48:21 +1000 |
commit | b188e800b7bb0ad2c4f305e3f10f645c504f4e90 (patch) | |
tree | 4ce6ed5ad1771e73372def40f4cad6f7786f5ae6 | |
parent | 4e19675d86a4e9102b1aef5d16df3977d4ef2b61 (diff) | |
download | scintilla-mirror-b188e800b7bb0ad2c4f305e3f10f645c504f4e90.tar.gz |
Avoid 'magic' number with constexpr and add comments.
-rw-r--r-- | src/LineMarker.cxx | 20 |
1 files 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<XYPOSITION>(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: |