diff options
author | Neil <nyamatongwe@gmail.com> | 2022-07-31 22:21:57 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2022-07-31 22:21:57 +1000 |
commit | d38429108f2035d9fab0919271f6715cd1b7eda6 (patch) | |
tree | 014b3bf217785e26e4c8db514fedf380d3bb007a /src | |
parent | 926cb6f7d228b347db16a45e1f2632da475da1f0 (diff) | |
download | scintilla-mirror-d38429108f2035d9fab0919271f6715cd1b7eda6.tar.gz |
Add SC_MARK_BAR marker and INDIC_POINT_TOP indicator which are useful for change
history. Tweak size of INDIC_POINT and INDIC_POINTCHARACTER. Let translucency of
INDIC_COMPOSITIONTHICK be adjusted.
Diffstat (limited to 'src')
-rw-r--r-- | src/Indicator.cxx | 20 | ||||
-rw-r--r-- | src/LineMarker.cxx | 31 | ||||
-rw-r--r-- | src/MarginView.cxx | 24 | ||||
-rw-r--r-- | src/ViewStyle.cxx | 15 | ||||
-rw-r--r-- | src/ViewStyle.h | 1 |
5 files changed, 88 insertions, 3 deletions
diff --git a/src/Indicator.cxx b/src/Indicator.cxx index bd02a01d1..cb7d5deba 100644 --- a/src/Indicator.cxx +++ b/src/Indicator.cxx @@ -252,7 +252,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r case IndicatorStyle::CompositionThick: { const PRectangle rcComposition(rc.left+1, rcLine.bottom-2, rc.right-1, rcLine.bottom); - surface->FillRectangle(rcComposition, sacDraw.fore); + surface->FillRectangle(rcComposition, ColourRGBA(sacDraw.fore, outlineAlpha)); } break; @@ -269,7 +269,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r const XYPOSITION x = (sacDraw.style == IndicatorStyle::Point) ? (rcCharacter.left) : ((rcCharacter.right + rcCharacter.left) / 2); // 0.5f is to hit midpoint of pixels: const XYPOSITION ix = std::round(x) + 0.5f; - const XYPOSITION iy = std::floor(rc.top + 1.0f) + 0.5f; + const XYPOSITION iy = std::floor(rc.top) + 0.5f; const Point pts[] = { Point(ix - pixelHeight, iy + pixelHeight), // Left Point(ix + pixelHeight, iy + pixelHeight), // Right @@ -279,6 +279,22 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r } break; + case IndicatorStyle::PointTop: + if (rcCharacter.Width() >= 0.1) { + const XYPOSITION pixelHeight = std::floor(rc.Height() - 1.0f); // 1 pixel onto previous line if multiphase + const XYPOSITION x = rcCharacter.left; + // 0.5f is to hit midpoint of pixels: + const XYPOSITION ix = std::round(x) + 0.5f; + const XYPOSITION iy = std::floor(rcLine.top) + 0.5f; + const Point pts[] = { + Point(ix - pixelHeight, iy), // Left + Point(ix + pixelHeight, iy), // Right + Point(ix, iy + pixelHeight) // Bottom + }; + surface->Polygon(pts, std::size(pts), FillStroke(sacDraw.fore)); + } + break; + default: // Either IndicatorStyle::Plain or unknown surface->FillRectangle(PRectangle(rcAligned.left, ymid, diff --git a/src/LineMarker.cxx b/src/LineMarker.cxx index df8c3d55a..9794f523c 100644 --- a/src/LineMarker.cxx +++ b/src/LineMarker.cxx @@ -514,6 +514,37 @@ void LineMarker::Draw(Surface *surface, const PRectangle &rcWhole, const Font *f } break; + case MarkerSymbol::Bar: { + 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); + switch (part) { + case LineMarker::FoldPart::headWithTail: + surface->RectangleDraw(rcBar, FillStroke(back, fore, strokeWidth)); + break; + case LineMarker::FoldPart::head: + rcBar.bottom += 5; + surface->RectangleDraw(rcBar, FillStroke(back, fore, strokeWidth)); + break; + case LineMarker::FoldPart::tail: + rcBar.top -= 5; + surface->RectangleDraw(rcBar, FillStroke(back, fore, strokeWidth)); + break; + case LineMarker::FoldPart::body: + rcBar.top -= 5; + rcBar.bottom += 5; + surface->RectangleDraw(rcBar, FillStroke(back, fore, strokeWidth)); + break; + default: + break; + } + surface->PopClip(); + } + break; + + case MarkerSymbol::Bookmark: { const XYPOSITION halfHeight = std::floor(minDim / 3); Point pts[] = { diff --git a/src/MarginView.cxx b/src/MarginView.cxx index 7d2f4a8cd..6e43c0f0c 100644 --- a/src/MarginView.cxx +++ b/src/MarginView.cxx @@ -283,7 +283,11 @@ void MarginView::PaintOneMargin(Surface *surface, PRectangle rc, PRectangle rcOn const bool firstSubLine = visibleLine == firstVisibleLine; const bool lastSubLine = visibleLine == lastVisibleLine; - int marks = firstSubLine ? model.GetMark(lineDoc) : 0; + int marks = model.GetMark(lineDoc); + if (!firstSubLine) { + // Mask off non-continuing marks + marks = marks & vs.maskDrawWrapped; + } bool headWithTail = false; @@ -413,6 +417,24 @@ void MarginView::PaintOneMargin(Surface *surface, PRectangle rc, PRectangle rcOn part = LineMarker::FoldPart::tail; } } + if (vs.markers[markBit].markType == MarkerSymbol::Bar) { + const int mask = 1 << markBit; + const bool markBefore = firstSubLine ? (model.GetMark(lineDoc-1) & mask) : true; + const bool markAfter = lastSubLine ? (model.GetMark(lineDoc+1) & mask) : true; + if (markBefore) { + if (markAfter) { + part = LineMarker::FoldPart::body; + } else { + part = LineMarker::FoldPart::tail; + } + } else { + if (markAfter) { + part = LineMarker::FoldPart::head; + } else { + part = LineMarker::FoldPart::headWithTail; + } + } + } vs.markers[markBit].Draw(surface, rcMarker, vs.styles[StyleLineNumber].font.get(), part, marginStyle.style); } marks >>= 1; diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index 01b94cca1..5160cfc54 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -284,6 +284,7 @@ ViewStyle::ViewStyle(const ViewStyle &source) : ViewStyle(source.styles.size()) ms = source.ms; maskInLine = source.maskInLine; maskDrawInText = source.maskDrawInText; + maskDrawWrapped = source.maskDrawWrapped; fixedColumnWidth = source.fixedColumnWidth; marginInside = source.marginInside; textStart = source.textStart; @@ -347,6 +348,17 @@ void ViewStyle::CalculateMarginWidthAndMask() noexcept { break; } } + maskDrawWrapped = 0; + for (int markBit = 0; markBit < 32; markBit++) { + const int maskBit = 1U << markBit; + switch (markers[markBit].markType) { + case MarkerSymbol::Bar: + maskDrawWrapped |= maskBit; + break; + default: // Other marker types do not affect the masks + break; + } + } } void ViewStyle::Refresh(Surface &surface, int tabInChars) { @@ -493,6 +505,9 @@ void ViewStyle::CalcLargestMarkerHeight() noexcept { if (marker.image && marker.image->GetHeight() > largestMarkerHeight) largestMarkerHeight = marker.image->GetHeight(); break; + case MarkerSymbol::Bar: + largestMarkerHeight = lineHeight + 2; + break; default: // Only images have their own natural heights break; } diff --git a/src/ViewStyle.h b/src/ViewStyle.h index c5ee232c3..a91aea501 100644 --- a/src/ViewStyle.h +++ b/src/ViewStyle.h @@ -141,6 +141,7 @@ public: int rightMarginWidth; ///< Spacing margin on right of text int maskInLine = 0; ///< Mask for markers to be put into text because there is nowhere for them to go in margin int maskDrawInText = 0; ///< Mask for markers that always draw in text + int maskDrawWrapped = 0; ///< Mask for markers that draw on wrapped lines std::vector<MarginStyle> ms; int fixedColumnWidth = 0; ///< Total width of margins bool marginInside; ///< true: margin included in text view, false: separate views |