aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2021-03-27 09:40:14 +1100
committerNeil <nyamatongwe@gmail.com>2021-03-27 09:40:14 +1100
commite056a167c96e226dc7487f5df2263d17a4dec399 (patch)
tree279cd95e5fc1ad075a4b07cd39166a6c887ed913 /src
parentc02f75227ef151af1b283e4436d06149e69679a7 (diff)
downloadscintilla-mirror-e056a167c96e226dc7487f5df2263d17a4dec399.tar.gz
Add APIs for setting translucency and stroke width of markers.
Diffstat (limited to 'src')
-rw-r--r--src/Editor.cxx32
-rw-r--r--src/LineMarker.cxx26
-rw-r--r--src/LineMarker.h7
3 files changed, 45 insertions, 20 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 7ad889c23..ad56a8eb8 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -6946,22 +6946,46 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
InvalidateStyleData();
RedrawSelMargin();
break;
+ case SCI_MARKERSETBACK:
+ if (wParam <= MARKER_MAX)
+ vs.markers[wParam].back = ColourDesired(static_cast<int>(lParam));
+ InvalidateStyleData();
+ RedrawSelMargin();
+ break;
case SCI_MARKERSETBACKSELECTED:
if (wParam <= MARKER_MAX)
vs.markers[wParam].backSelected = ColourDesired(static_cast<int>(lParam));
InvalidateStyleData();
RedrawSelMargin();
break;
- case SCI_MARKERENABLEHIGHLIGHT:
- marginView.highlightDelimiter.isEnabled = wParam == 1;
+ case SCI_MARKERSETFORETRANSLUCENT:
+ if (wParam <= MARKER_MAX)
+ vs.markers[wParam].fore = ColourAlpha(static_cast<int>(lParam));
+ InvalidateStyleData();
RedrawSelMargin();
break;
- case SCI_MARKERSETBACK:
+ case SCI_MARKERSETBACKTRANSLUCENT:
if (wParam <= MARKER_MAX)
- vs.markers[wParam].back = ColourDesired(static_cast<int>(lParam));
+ vs.markers[wParam].back = ColourAlpha(static_cast<int>(lParam));
InvalidateStyleData();
RedrawSelMargin();
break;
+ case SCI_MARKERSETBACKSELECTEDTRANSLUCENT:
+ if (wParam <= MARKER_MAX)
+ vs.markers[wParam].backSelected = ColourAlpha(static_cast<int>(lParam));
+ InvalidateStyleData();
+ RedrawSelMargin();
+ break;
+ case SCI_MARKERSETSTROKEWIDTH:
+ if (wParam <= MARKER_MAX)
+ vs.markers[wParam].strokeWidth = lParam / 100.0f;
+ InvalidateStyleData();
+ RedrawSelMargin();
+ break;
+ case SCI_MARKERENABLEHIGHLIGHT:
+ marginView.highlightDelimiter.isEnabled = wParam == 1;
+ RedrawSelMargin();
+ break;
case SCI_MARKERSETALPHA:
if (wParam <= MARKER_MAX)
vs.markers[wParam].alpha = static_cast<int>(lParam);
diff --git a/src/LineMarker.cxx b/src/LineMarker.cxx
index 5acfb7cb3..35cf0ab4c 100644
--- a/src/LineMarker.cxx
+++ b/src/LineMarker.cxx
@@ -34,6 +34,7 @@ LineMarker::LineMarker(const LineMarker &other) {
fore = other.fore;
back = other.back;
backSelected = other.backSelected;
+ strokeWidth = other.strokeWidth;
alpha = other.alpha;
if (other.pxpm)
pxpm = std::make_unique<XPM>(*other.pxpm);
@@ -53,6 +54,7 @@ LineMarker &LineMarker::operator=(const LineMarker &other) {
fore = other.fore;
back = other.back;
backSelected = other.backSelected;
+ strokeWidth = other.strokeWidth;
alpha = other.alpha;
if (other.pxpm)
pxpm = std::make_unique<XPM>(*other.pxpm);
@@ -88,7 +90,7 @@ enum class Expansion { Minus, Plus };
enum class Shape { Square, Circle };
void DrawSymbol(Surface *surface, Shape shape, Expansion expansion, PRectangle rcSymbol, XYPOSITION widthStroke,
- ColourDesired colourFill, ColourDesired colourFrame, ColourDesired colourFrameRight, ColourDesired colourExpansion) {
+ ColourAlpha colourFill, ColourAlpha colourFrame, ColourAlpha colourFrameRight, ColourAlpha colourExpansion) {
const FillStroke fillStroke(colourFill, colourFrame, widthStroke);
const PRectangle rcSymbolLeft = Side(rcSymbol, Edge::left, (rcSymbol.Width() + widthStroke) / 2.0f);
@@ -127,7 +129,7 @@ void DrawSymbol(Surface *surface, Shape shape, Expansion expansion, PRectangle r
}
}
-void DrawTail(Surface *surface, XYPOSITION leftLine, XYPOSITION rightTail, XYPOSITION centreY, XYPOSITION widthSymbolStroke, ColourDesired fill) {
+void DrawTail(Surface *surface, XYPOSITION leftLine, XYPOSITION rightTail, XYPOSITION centreY, XYPOSITION widthSymbolStroke, ColourAlpha fill) {
const XYPOSITION slopeLength = 2.0f + widthSymbolStroke;
const XYPOSITION strokeTop = centreY + slopeLength;
const XYPOSITION halfWidth = widthSymbolStroke / 2.0f;
@@ -147,11 +149,10 @@ void DrawTail(Surface *surface, XYPOSITION leftLine, XYPOSITION rightTail, XYPOS
void LineMarker::DrawFoldingMark(Surface *surface, const PRectangle &rcWhole, FoldPart part) const {
// Assume: edges of rcWhole are integers.
// Code can only really handle integer strokeWidth.
- constexpr XYPOSITION strokeWidth = 1.0f;
- ColourDesired colourHead = back;
- ColourDesired colourBody = back;
- ColourDesired colourTail = back;
+ ColourAlpha colourHead = back;
+ ColourAlpha colourBody = back;
+ ColourAlpha colourTail = back;
switch (part) {
case FoldPart::head:
@@ -249,11 +250,11 @@ void LineMarker::DrawFoldingMark(Surface *surface, const PRectangle &rcWhole, Fo
break;
case SC_MARK_BOXPLUSCONNECTED: {
- const ColourDesired colourBelow = (part == FoldPart::headWithTail) ? colourTail : colourBody;
+ const ColourAlpha colourBelow = (part == FoldPart::headWithTail) ? colourTail : colourBody;
surface->FillRectangle(rcBelowSymbol, colourBelow);
surface->FillRectangle(rcAboveSymbol, colourBody);
- const ColourDesired colourRight = (part == FoldPart::body) ? colourTail : colourHead;
+ const ColourAlpha colourRight = (part == FoldPart::body) ? colourTail : colourHead;
DrawSymbol(surface, Shape::Square, Expansion::Plus, rcSymbol, widthStroke,
fore, colourHead, colourRight, colourTail);
}
@@ -269,7 +270,7 @@ void LineMarker::DrawFoldingMark(Surface *surface, const PRectangle &rcWhole, Fo
surface->FillRectangle(rcBelowSymbol, colourHead);
surface->FillRectangle(rcAboveSymbol, colourBody);
- const ColourDesired colourRight = (part == FoldPart::body) ? colourTail : colourHead;
+ const ColourAlpha colourRight = (part == FoldPart::body) ? colourTail : colourHead;
DrawSymbol(surface, Shape::Square, Expansion::Minus, rcSymbol, widthStroke,
fore, colourHead, colourRight, colourTail);
}
@@ -281,11 +282,11 @@ void LineMarker::DrawFoldingMark(Surface *surface, const PRectangle &rcWhole, Fo
break;
case SC_MARK_CIRCLEPLUSCONNECTED: {
- const ColourDesired colourBelow = (part == FoldPart::headWithTail) ? colourTail : colourBody;
+ const ColourAlpha colourBelow = (part == FoldPart::headWithTail) ? colourTail : colourBody;
surface->FillRectangle(rcBelowSymbol, colourBelow);
surface->FillRectangle(rcAboveSymbol, colourBody);
- const ColourDesired colourRight = (part == FoldPart::body) ? colourTail : colourHead;
+ const ColourAlpha colourRight = (part == FoldPart::body) ? colourTail : colourHead;
DrawSymbol(surface, Shape::Circle, Expansion::Plus, rcSymbol, widthStroke,
fore, colourHead, colourRight, colourTail);
}
@@ -300,7 +301,7 @@ void LineMarker::DrawFoldingMark(Surface *surface, const PRectangle &rcWhole, Fo
case SC_MARK_CIRCLEMINUSCONNECTED: {
surface->FillRectangle(rcBelowSymbol, colourHead);
surface->FillRectangle(rcAboveSymbol, colourBody);
- const ColourDesired colourRight = (part == FoldPart::body) ? colourTail : colourHead;
+ const ColourAlpha colourRight = (part == FoldPart::body) ? colourTail : colourHead;
DrawSymbol(surface, Shape::Circle, Expansion::Minus, rcSymbol, widthStroke,
fore, colourHead, colourRight, colourTail);
}
@@ -311,7 +312,6 @@ void LineMarker::DrawFoldingMark(Surface *surface, const PRectangle &rcWhole, Fo
void LineMarker::Draw(Surface *surface, const PRectangle &rcWhole, const Font *fontForCharacter, FoldPart part, int marginStyle) const {
// This is to satisfy the changed API - eventually the stroke width will be exposed to clients
- constexpr float strokeWidth = 1.0f;
if (customDraw) {
customDraw(surface, rcWhole, fontForCharacter, static_cast<int>(part), marginStyle, this);
diff --git a/src/LineMarker.h b/src/LineMarker.h
index 232a29dbb..b417ec34d 100644
--- a/src/LineMarker.h
+++ b/src/LineMarker.h
@@ -22,10 +22,11 @@ public:
enum class FoldPart { undefined, head, body, tail, headWithTail };
int markType = SC_MARK_CIRCLE;
- ColourDesired fore = ColourDesired(0, 0, 0);
- ColourDesired back = ColourDesired(0xff, 0xff, 0xff);
- ColourDesired backSelected = ColourDesired(0xff, 0x00, 0x00);
+ ColourAlpha fore = ColourAlpha(0, 0, 0);
+ ColourAlpha back = ColourAlpha(0xff, 0xff, 0xff);
+ ColourAlpha backSelected = ColourAlpha(0xff, 0x00, 0x00);
int alpha = SC_ALPHA_NOALPHA;
+ XYPOSITION strokeWidth = 1.0f;
std::unique_ptr<XPM> pxpm;
std::unique_ptr<RGBAImage> image;
/** Some platforms, notably PLAT_CURSES, do not support Scintilla's native