From c02f75227ef151af1b283e4436d06149e69679a7 Mon Sep 17 00:00:00 2001 From: Neil Date: Sat, 27 Mar 2021 08:48:56 +1100 Subject: Add API for setting stroke width of indicators. --- doc/ScintillaDoc.html | 23 ++++++++++++++++++++++- doc/ScintillaHistory.html | 3 +++ include/Scintilla.h | 2 ++ include/Scintilla.iface | 6 ++++++ src/Editor.cxx | 13 +++++++++++++ src/Indicator.cxx | 1 - src/Indicator.h | 1 + 7 files changed, 47 insertions(+), 2 deletions(-) diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index e869d069e..ea1484501 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -119,7 +119,7 @@

Scintilla Documentation

-

Last edited 22 March 2021 NH

+

Last edited 27 March 2021 NH

Scintilla 5 has moved the lexers from Scintilla into a new Lexilla project.
@@ -4657,6 +4657,8 @@ struct Sci_TextToFind { SCI_INDICSETFORE(int indicator, colour fore)
SCI_INDICGETFORE(int indicator) → colour
+ SCI_INDICSETSTROKEWIDTH(int indicator, int hundredths)
+ SCI_INDICGETSTROKEWIDTH(int indicator) → int
SCI_INDICSETALPHA(int indicator, alpha alpha)
SCI_INDICGETALPHA(int indicator) → int
SCI_INDICSETOUTLINEALPHA(int indicator, alpha alpha)
@@ -4926,6 +4928,25 @@ struct Sci_TextToFind { SCI_INDICSETFORE(1, 0xff0000); (light blue)
SCI_INDICSETFORE(2, 0x0000ff); (light red)

+ SCI_INDICSETSTROKEWIDTH(int indicator, int hundredths)
+ SCI_INDICGETSTROKEWIDTH(int indicator) → int
+

SCI_INDICSETSTROKEWIDTH(int indicator, int hundredths)
+ SCI_INDICGETSTROKEWIDTH(int indicator) → int
+ These two messages set and get the stroke width used to draw an indicator in hundredths of a pixel. + The default value is 100 indicating a width of one pixel. + Some indicator styles do not support setting stroke width, generally where it makes no sense (INDIC_POINT) or + wasn't simple (INDIC_SQUIGGLEPIXMAP). + The indicators supporting stroke width are: + INDIC_PLAIN, INDIC_SQUIGGLE, INDIC_TT, INDIC_DIAGONAL, + INDIC_STRIKE, INDIC_BOX, INDIC_ROUNDBOX, INDIC_STRAIGHTBOX, + INDIC_FULLBOX, INDIC_DASH, INDIC_DOTS, INDIC_SQUIGGLELOW. +

+

Fractional pixel widths are possible such as 50 for half a pixel wide. + On many systems a half pixel value will appear as a fainter line but it allows drawing very thin lines on systems with multiple physical pixels + per logical pixel. + Half (logical) pixel lines are available on macOS with 'retina' displays, + see SC_SUPPORTS_PIXEL_DIVISIONS.

+

SCI_INDICSETALPHA(int indicator, alpha alpha)
SCI_INDICGETALPHA(int indicator) → int
These two messages set and get the alpha transparency used for drawing the diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index b63a6c69a..47f16e0ce 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -597,6 +597,9 @@ Add colouralpha type to Scintilla.iface for APIs that set both colour and transparency together as an RGBA value.

  • + Add SCI_INDICSETSTROKEWIDTH to set stroke width of indicators. +
  • +
  • Change graphics coordinates from float (32-bit) to double (64-bit). Fixes uneven line heights in large documents on Cocoa. Increases memory use. diff --git a/include/Scintilla.h b/include/Scintilla.h index 81869efec..69dc2d057 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -328,6 +328,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_INDICFLAG_VALUEFORE 1 #define SCI_INDICSETFLAGS 2684 #define SCI_INDICGETFLAGS 2685 +#define SCI_INDICSETSTROKEWIDTH 2751 +#define SCI_INDICGETSTROKEWIDTH 2752 #define SCI_SETWHITESPACEFORE 2084 #define SCI_SETWHITESPACEBACK 2085 #define SCI_SETWHITESPACESIZE 2086 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index d11bbc79a..23938bfd9 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -813,6 +813,12 @@ set void IndicSetFlags=2684(int indicator, IndicFlag flags) # Retrieve the attributes of an indicator. get IndicFlag IndicGetFlags=2685(int indicator,) +# Set the stroke width of an indicator in hundredths of a pixel. +set void IndicSetStrokeWidth=2751(int indicator, int hundredths) + +# Retrieve the stroke width of an indicator. +get int IndicGetStrokeWidth=2752(int indicator,) + # Set the foreground colour of all whitespace and whether to use this setting. fun void SetWhitespaceFore=2084(bool useSetting, colour fore) diff --git a/src/Editor.cxx b/src/Editor.cxx index 44c80451b..7ad889c23 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -7518,6 +7518,19 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_INDICGETOUTLINEALPHA: return (wParam <= INDICATOR_MAX) ? vs.indicators[wParam].outlineAlpha : 0; + case SCI_INDICSETSTROKEWIDTH: + if (wParam <= INDICATOR_MAX && lParam >= 0 && lParam <= 1000) { + vs.indicators[wParam].strokeWidth = lParam / 100.0f; + InvalidateStyleRedraw(); + } + break; + + case SCI_INDICGETSTROKEWIDTH: + if (wParam <= INDICATOR_MAX) { + return std::lround(vs.indicators[wParam].strokeWidth * 100); + } + break; + case SCI_SETINDICATORCURRENT: pdoc->DecorationSetCurrentIndicator(static_cast(wParam)); break; diff --git a/src/Indicator.cxx b/src/Indicator.cxx index 93bf68ed0..1ebc18b7f 100644 --- a/src/Indicator.cxx +++ b/src/Indicator.cxx @@ -36,7 +36,6 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r const int pixelDivisions = surface->PixelDivisions(); - const XYPOSITION strokeWidth = 1.0f; const XYPOSITION halfWidth = strokeWidth / 2.0f; const PRectangle rcAligned(PixelAlignOutside(rc, pixelDivisions)); diff --git a/src/Indicator.h b/src/Indicator.h index 669d9a2d8..89cf1cdc5 100644 --- a/src/Indicator.h +++ b/src/Indicator.h @@ -33,6 +33,7 @@ public: int fillAlpha; int outlineAlpha; int attributes; + XYPOSITION strokeWidth = 1.0f; Indicator() noexcept : under(false), fillAlpha(30), outlineAlpha(50), attributes(0) { } Indicator(int style_, ColourDesired fore_=ColourDesired(0,0,0), bool under_=false, int fillAlpha_=30, int outlineAlpha_=50) noexcept : -- cgit v1.2.3