diff options
author | Neil <nyamatongwe@gmail.com> | 2023-01-15 13:15:03 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2023-01-15 13:15:03 +1100 |
commit | 75b9e2e143d73d0399ea3a9a8ae5c973fadc4b42 (patch) | |
tree | f973fa5f046e6a90556e05d2185000d8fda95cfb | |
parent | b0b1287f399bc033708ef82a8e799759f14adb29 (diff) | |
download | scintilla-mirror-75b9e2e143d73d0399ea3a9a8ae5c973fadc4b42.tar.gz |
Simplify DrawIndentGuide and move decision to offset out of loop.
-rw-r--r-- | src/EditView.cxx | 17 | ||||
-rw-r--r-- | src/EditView.h | 2 |
2 files changed, 10 insertions, 9 deletions
diff --git a/src/EditView.cxx b/src/EditView.cxx index 487623865..61d0e53cb 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -2199,8 +2199,8 @@ ColourRGBA InvertedLight(ColourRGBA orig) noexcept { } -void EditView::DrawIndentGuide(Surface *surface, Sci::Line lineVisible, int lineHeight, XYPOSITION start, PRectangle rcSegment, bool highlight) { - const Point from = Point::FromInts(0, ((lineVisible & 1) && (lineHeight & 1)) ? 1 : 0); +void EditView::DrawIndentGuide(Surface *surface, XYPOSITION start, PRectangle rcSegment, bool highlight, bool offset) { + const Point from = Point::FromInts(0, offset ? 1 : 0); const PRectangle rcCopyArea(start + 1, rcSegment.top, start + 2, rcSegment.bottom); surface->Copy(rcCopyArea, from, @@ -2221,6 +2221,9 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi // Does not take margin into account but not significant const XYPOSITION xStartVisible = static_cast<XYPOSITION>(subLineStart-xStart); + // When lineHeight is odd, dotted indent guides are drawn offset by 1 on odd lines to join together. + const bool offsetGuide = (lineVisible & 1) && (vsDraw.lineHeight & 1); + // Same baseline used for all text const XYPOSITION ybase = rcLine.top + vsDraw.maxAscent; @@ -2299,8 +2302,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi indentCount++) { if (indentCount > 0) { const XYPOSITION xIndent = std::floor(indentCount * indentWidth); - DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment, - (ll->xHighlightGuide == xIndent)); + DrawIndentGuide(surface, xIndent + xStart, rcSegment, ll->xHighlightGuide == xIndent, offsetGuide); } } } @@ -2391,8 +2393,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi indentCount++) { if (indentCount > 0) { const XYPOSITION xIndent = std::floor(indentCount * indentWidth); - DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment, - (ll->xHighlightGuide == xIndent)); + DrawIndentGuide(surface, xIndent + xStart, rcSegment, ll->xHighlightGuide == xIndent, offsetGuide); } } } @@ -2464,11 +2465,11 @@ void EditView::DrawIndentGuidesOverEmpty(Surface *surface, const EditModel &mode model.pdoc->GetLineIndentation(lineNextWithText)); } + const bool offsetGuide = (lineVisible & 1) && (vsDraw.lineHeight & 1); for (int indentPos = model.pdoc->IndentSize(); indentPos < indentSpace; indentPos += model.pdoc->IndentSize()) { const XYPOSITION xIndent = std::floor(indentPos * vsDraw.spaceWidth); if (xIndent < xStartText) { - DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcLine, - (ll->xHighlightGuide == xIndent)); + DrawIndentGuide(surface, xIndent + xStart, rcLine, ll->xHighlightGuide == xIndent, offsetGuide); } } } diff --git a/src/EditView.h b/src/EditView.h index c05703710..e6de369bc 100644 --- a/src/EditView.h +++ b/src/EditView.h @@ -144,7 +144,7 @@ private: Sci::Line line, int xStart, PRectangle rcLine, int subLine, DrawPhase phase); void DrawCarets(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, Sci::Line lineDoc, int xStart, PRectangle rcLine, int subLine) const; - void DrawIndentGuide(Surface *surface, Sci::Line lineVisible, int lineHeight, XYPOSITION start, PRectangle rcSegment, bool highlight); + void DrawIndentGuide(Surface *surface, XYPOSITION start, PRectangle rcSegment, bool highlight, bool offset); void DrawForeground(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, int xStart, PRectangle rcLine, int subLine, Sci::Line lineVisible, Range lineRange, Sci::Position posLineStart, ColourOptional background); |