From fb9e8bb503efc6c2b760b05bf2c1f67fa37fa7b5 Mon Sep 17 00:00:00 2001 From: Erik Angelin Date: Fri, 14 Nov 2014 10:41:27 +0100 Subject: Feature [feature-requests:#1086]. Annotation display style ANNOTATION_INDENTED; like _BOXED but no border. --- src/EditView.cxx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/EditView.cxx') diff --git a/src/EditView.cxx b/src/EditView.cxx index f1d201f15..845d38dc5 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -992,6 +992,10 @@ static void DrawIndicators(Surface *surface, const EditModel &model, const ViewS } } +static bool AnnotationBoxedOrIndented(int annotationVisible) { + return annotationVisible == ANNOTATION_BOXED || annotationVisible == ANNOTATION_INDENTED; +} + void EditView::DrawAnnotation(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, int line, int xStart, PRectangle rcLine, int subLine, DrawPhase phase) { int indent = static_cast(model.pdoc->GetLineIndentation(line) * vsDraw.spaceWidth); @@ -1003,18 +1007,16 @@ void EditView::DrawAnnotation(Surface *surface, const EditModel &model, const Vi surface->FillRectangle(rcSegment, vsDraw.styles[0].back); } rcSegment.left = static_cast(xStart); - if (model.trackLineWidth || (vsDraw.annotationVisible == ANNOTATION_BOXED)) { - // Only care about calculating width if tracking or need to draw box + if (model.trackLineWidth || AnnotationBoxedOrIndented(vsDraw.annotationVisible)) { + // Only care about calculating width if tracking or need to draw indented box int widthAnnotation = WidestLineWidth(surface, vsDraw, vsDraw.annotationStyleOffset, stAnnotation); - if (vsDraw.annotationVisible == ANNOTATION_BOXED) { + if (AnnotationBoxedOrIndented(vsDraw.annotationVisible)) { widthAnnotation += static_cast(vsDraw.spaceWidth * 2); // Margins - } - if (widthAnnotation > lineWidthMaxSeen) - lineWidthMaxSeen = widthAnnotation; - if (vsDraw.annotationVisible == ANNOTATION_BOXED) { rcSegment.left = static_cast(xStart + indent); rcSegment.right = rcSegment.left + widthAnnotation; } + if (widthAnnotation > lineWidthMaxSeen) + lineWidthMaxSeen = widthAnnotation; } const int annotationLines = model.pdoc->AnnotationLines(line); size_t start = 0; @@ -1026,7 +1028,7 @@ void EditView::DrawAnnotation(Surface *surface, const EditModel &model, const Vi lineInAnnotation++; } PRectangle rcText = rcSegment; - if ((phase & drawBack) && (vsDraw.annotationVisible == ANNOTATION_BOXED)) { + if ((phase & drawBack) && AnnotationBoxedOrIndented(vsDraw.annotationVisible)) { surface->FillRectangle(rcText, vsDraw.styles[stAnnotation.StyleAt(start) + vsDraw.annotationStyleOffset].back); rcText.left += vsDraw.spaceWidth; -- cgit v1.2.3