diff options
| -rw-r--r-- | doc/ScintillaDoc.html | 64 | ||||
| -rw-r--r-- | doc/ScintillaHistory.html | 4 | ||||
| -rw-r--r-- | include/Scintilla.h | 3 | ||||
| -rw-r--r-- | include/Scintilla.iface | 3 | ||||
| -rw-r--r-- | src/EditView.cxx | 38 | ||||
| -rw-r--r-- | src/LineMarker.h | 2 | ||||
| -rw-r--r-- | test/simpleTests.py | 8 | 
7 files changed, 92 insertions, 30 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 789e06c84..d28b8f859 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -3586,11 +3586,21 @@ struct Sci_TextToFind {          </tr>          <tr> +          <th align="left"><code>SC_LAYER_UNDER_TEXT</code>.</th> + +          <td>1</td> + +          <td>Draw the selection background translucently under the text.<br /> +	  This will not work in single phase drawing mode (<code class="deprecated">SC_PHASES_ONE</code>) +	  as there is no under-text phase.</td> +        </tr> + +        <tr>            <th align="left"><code>SC_LAYER_OVER_TEXT</code></th> -          <td>10</td> +          <td>2</td> -          <td>Draw the selection background translucently over the text</td> +          <td>Draw the selection background translucently over the text.</td>          </tr>        </tbody> @@ -3654,15 +3664,25 @@ struct Sci_TextToFind {            <td>0</td> -          <td>Draw the caret line background opaquely on the base layer</td> +          <td>Draw the selection background opaquely on the base layer</td> +        </tr> + +        <tr> +          <th align="left"><code>SC_LAYER_UNDER_TEXT</code>.</th> + +          <td>1</td> + +          <td>Draw the selection background translucently under the text.<br /> +	  This will not work in single phase drawing mode (<code class="deprecated">SC_PHASES_ONE</code>) +	  as there is no under-text phase.</td>          </tr>          <tr>            <th align="left"><code>SC_LAYER_OVER_TEXT</code></th> -          <td>10</td> +          <td>2</td> -          <td>Draw the caret line background translucently over the text</td> +          <td>Draw the selection background translucently over the text.</td>          </tr>        </tbody> @@ -5050,7 +5070,39 @@ struct Sci_TextToFind {       The layer to draw on is defined by <code>SCI_MARKERSETLAYER</code>.       The degree of translucency can be chosen by setting an alpha value.       This is only for the content area - in margins, translucency is achieved through the <code>SCI_MARKERSET…TRANSLUCENT</code> -     methods.</p> +     methods. +     The <code class="parameter">layer</code> argument can be one of:</p> + +    <table class="standard" summary="Layer"> +      <tbody valign="top"> +        <tr> +          <th align="left"><code>SC_LAYER_BASE</code></th> + +          <td>0</td> + +          <td>Draw the selection background opaquely on the base layer</td> +        </tr> + +        <tr> +          <th align="left"><code>SC_LAYER_UNDER_TEXT</code>.</th> + +          <td>1</td> + +          <td>Draw the selection background translucently under the text.<br /> +	  This will not work in single phase drawing mode (<code class="deprecated">SC_PHASES_ONE</code>) +	  as there is no under-text phase.</td> +        </tr> + +        <tr> +          <th align="left"><code>SC_LAYER_OVER_TEXT</code></th> + +          <td>2</td> + +          <td>Draw the selection background translucently over the text.</td> +        </tr> + +      </tbody> +    </table>      <p><b id="SCI_MARKERADD">SCI_MARKERADD(line line, int markerNumber) → int</b><br />       This message adds marker number <code class="parameter">markerNumber</code> to a line. The message returns -1 if diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 6d64439c7..d9154f97c 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -584,7 +584,7 @@  	The selection background colour may default to use platform APIs to discover global  	or user settings and may change in response to those settings changing.  	The SCI_SETSELECTIONLAYER method defines whether the selection background is drawn -	translucently over text or opaquely underneath other drawing. +	translucently over or under text or opaquely underneath other drawing.  	</li>  	<li>  	Change caret line drawing to use SC_ELEMENT_CARET_LINE_BACK element and @@ -593,7 +593,7 @@  	SCI_SETCARETLINEBACKALPHA now discouraged.  	</li>  	<li> -	Add SCI_MARKERSETLAYER to define layer on which to draw conetent area markers. +	Add SCI_MARKERSETLAYER to define layer on which to draw content area markers.  	This replaces the use of SC_ALPHA_NOALPHA for markers.  	</li>  	<li> diff --git a/include/Scintilla.h b/include/Scintilla.h index 3a5738bde..babb7e89c 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -304,7 +304,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,  #define SCI_GETSELEOLFILLED 2479  #define SCI_SETSELEOLFILLED 2480  #define SC_LAYER_BASE 0 -#define SC_LAYER_OVER_TEXT 10 +#define SC_LAYER_UNDER_TEXT 1 +#define SC_LAYER_OVER_TEXT 2  #define SCI_GETSELECTIONLAYER 2762  #define SCI_SETSELECTIONLAYER 2763  #define SCI_GETCARETLINELAYER 2764 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index dfe555168..24c7e830d 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -739,7 +739,8 @@ set void SetSelEOLFilled=2480(bool filled,)  enu Layer=SC_LAYER_  val SC_LAYER_BASE=0 -val SC_LAYER_OVER_TEXT=10 +val SC_LAYER_UNDER_TEXT=1 +val SC_LAYER_OVER_TEXT=2  # Get the layer for drawing selections  get Layer GetSelectionLayer=2762(,) diff --git a/src/EditView.cxx b/src/EditView.cxx index e76921139..a8dffa792 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -927,7 +927,7 @@ static void DrawCaretLineFramed(Surface *surface, const ViewStyle &vsDraw, const  	// Avoid double drawing the corners by removing the left and right sides when drawing top and bottom borders  	const PRectangle rcWithoutLeftRight = rcLine.Inset(Point(width, 0.0)); -	if (subLine == 0 || ll->wrapIndent == 0 || vsDraw.caretLine.layer == Layer::over) { +	if (subLine == 0 || ll->wrapIndent == 0 || vsDraw.caretLine.layer != Layer::base) {  		// Left  		surface->FillRectangleAligned(Side(rcLine, Edge::left, width), colourFrame);  	} @@ -935,7 +935,7 @@ static void DrawCaretLineFramed(Surface *surface, const ViewStyle &vsDraw, const  		// Top  		surface->FillRectangleAligned(Side(rcWithoutLeftRight, Edge::top, width), colourFrame);  	} -	if (subLine == ll->lines - 1 || vsDraw.caretLine.layer == Layer::over) { +	if (subLine == ll->lines - 1 || vsDraw.caretLine.layer != Layer::base) {  		// Right  		surface->FillRectangleAligned(Side(rcLine, Edge::right, width), colourFrame);  	} @@ -1029,8 +1029,14 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle  			} else {  				surface->FillRectangleAligned(rcSegment, Fill(textBack));  			} -			DrawTextBlob(surface, vsDraw, rcSegment, ctrlChar, textBack, textFore, phasesDraw == PhasesDraw::one); -			if (eolInSelection && (line < model.pdoc->LinesTotal() - 1) && (vsDraw.selection.layer == Layer::over)) { +			const bool drawEOLSelection = eolInSelection && (line < model.pdoc->LinesTotal() - 1); +			ColourAlpha blobText = textBack; +			if (drawEOLSelection && (vsDraw.selection.layer == Layer::under)) { +				surface->FillRectangleAligned(rcSegment, selectionBack); +				blobText = textBack.MixedWith(selectionBack, selectionBack.GetAlphaComponent()); +			} +			DrawTextBlob(surface, vsDraw, rcSegment, ctrlChar, blobText, textFore, phasesDraw == PhasesDraw::one); +			if (drawEOLSelection && (vsDraw.selection.layer == Layer::over)) {  				surface->FillRectangleAligned(rcSegment, selectionBack);  			}  		} @@ -1052,7 +1058,7 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle  		} else {  			surface->FillRectangleAligned(rcSegment, Fill(vsDraw.styles[STYLE_DEFAULT].back));  		} -		if (eolInSelection && (line < model.pdoc->LinesTotal() - 1) && (vsDraw.selection.layer == Layer::over)) { +		if (eolInSelection && (line < model.pdoc->LinesTotal() - 1) && (vsDraw.selection.layer != Layer::base)) {  			surface->FillRectangleAligned(rcSegment, selectionBack);  		}  	} @@ -1277,7 +1283,7 @@ void EditView::DrawFoldDisplayText(Surface *surface, const EditModel &model, con  	}  	if (FlagSet(phase, DrawPhase::selectionTranslucent)) { -		if (eolInSelection && (line < model.pdoc->LinesTotal() - 1) && (vsDraw.selection.layer == Layer::over)) { +		if (eolInSelection && (line < model.pdoc->LinesTotal() - 1) && (vsDraw.selection.layer != Layer::base)) {  			surface->FillRectangleAligned(rcSegment, SelectionBackground(model, vsDraw, eolInSelection));  		}  	} @@ -1802,8 +1808,8 @@ static void DrawMarkUnderline(Surface *surface, const EditModel &model, const Vi  }  static void DrawTranslucentSelection(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, -	Sci::Line line, PRectangle rcLine, int subLine, Range lineRange, int xStart, int tabWidthMinimumPixels) { -	if (vsDraw.selection.layer == Layer::over) { +	Sci::Line line, PRectangle rcLine, int subLine, Range lineRange, int xStart, int tabWidthMinimumPixels, Layer layer) { +	if (vsDraw.selection.layer == layer) {  		const Sci::Position posLineStart = model.pdoc->LineStart(line);  		const XYACCUMULATOR subLineStart = ll->positions[lineRange.start];  		// For each selection draw @@ -1865,9 +1871,9 @@ static void DrawTranslucentSelection(Surface *surface, const EditModel &model, c  // Draw any translucent whole line states  static void DrawTranslucentLineState(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, -	Sci::Line line, PRectangle rcLine, int subLine) { +	Sci::Line line, PRectangle rcLine, int subLine, Layer layer) {  	if ((model.caret.active || vsDraw.caretLine.alwaysShow) && vsDraw.ElementColour(SC_ELEMENT_CARET_LINE_BACK) && ll->containsCaret && -		vsDraw.caretLine.layer == Layer::over) { +		vsDraw.caretLine.layer == layer) {  		if (vsDraw.caretLine.frame) {  			DrawCaretLineFramed(surface, vsDraw, ll, rcLine, subLine);  		} else { @@ -1877,7 +1883,7 @@ static void DrawTranslucentLineState(Surface *surface, const EditModel &model, c  	const int marksOfLine = model.pdoc->GetMark(line);  	int marksDrawnInText = marksOfLine & vsDraw.maskDrawInText;  	for (int markBit = 0; (markBit < 32) && marksDrawnInText; markBit++) { -		if (marksDrawnInText & 1) { +		if ((marksDrawnInText & 1) && (vsDraw.markers[markBit].layer == layer)) {  			if (vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND) {  				surface->FillRectangleAligned(rcLine, vsDraw.markers[markBit].BackWithAlpha());  			} else if (vsDraw.markers[markBit].markType == SC_MARK_UNDERLINE) { @@ -1890,7 +1896,7 @@ static void DrawTranslucentLineState(Surface *surface, const EditModel &model, c  	}  	int marksDrawnInLine = marksOfLine & vsDraw.maskInLine;  	for (int markBit = 0; (markBit < 32) && marksDrawnInLine; markBit++) { -		if (marksDrawnInLine & 1) { +		if ((marksDrawnInLine & 1) && (vsDraw.markers[markBit].layer == layer)) {  			surface->FillRectangleAligned(rcLine, vsDraw.markers[markBit].BackWithAlpha());  		}  		marksDrawnInLine >>= 1; @@ -2191,6 +2197,8 @@ void EditView::DrawLine(Surface *surface, const EditModel &model, const ViewStyl  	}  	if (FlagSet(phase, DrawPhase::text)) { +		DrawTranslucentSelection(surface, model, vsDraw, ll, line, rcLine, subLine, lineRange, xStart, tabWidthMinimumPixels, Layer::under); +		DrawTranslucentLineState(surface, model, vsDraw, ll, line, rcLine, subLine, Layer::under);  		DrawForeground(surface, model, vsDraw, ll, lineVisible, rcLine, lineRange, posLineStart, xStart,  			subLine, background);  	} @@ -2217,11 +2225,11 @@ void EditView::DrawLine(Surface *surface, const EditModel &model, const ViewStyl  	}  	if (!hideSelection && FlagSet(phase, DrawPhase::selectionTranslucent)) { -		DrawTranslucentSelection(surface, model, vsDraw, ll, line, rcLine, subLine, lineRange, xStart, tabWidthMinimumPixels); +		DrawTranslucentSelection(surface, model, vsDraw, ll, line, rcLine, subLine, lineRange, xStart, tabWidthMinimumPixels, Layer::over);  	}  	if (FlagSet(phase, DrawPhase::lineTranslucent)) { -		DrawTranslucentLineState(surface, model, vsDraw, ll, line, rcLine, subLine); +		DrawTranslucentLineState(surface, model, vsDraw, ll, line, rcLine, subLine, Layer::over);  	}  } @@ -2467,7 +2475,7 @@ void EditView::FillLineRemainder(Surface *surface, const EditModel &model, const  		} else {  			surface->FillRectangleAligned(rcArea, Fill(vsDraw.styles[STYLE_DEFAULT].back));  		} -		if (eolInSelection && vsDraw.selection.eolFilled && (line < model.pdoc->LinesTotal() - 1) && (vsDraw.selection.layer == Layer::over)) { +		if (eolInSelection && vsDraw.selection.eolFilled && (line < model.pdoc->LinesTotal() - 1) && (vsDraw.selection.layer != Layer::base)) {  			surface->FillRectangleAligned(rcArea, SelectionBackground(model, vsDraw, eolInSelection));  		}  	} diff --git a/src/LineMarker.h b/src/LineMarker.h index 1047d34e9..e0921b2b3 100644 --- a/src/LineMarker.h +++ b/src/LineMarker.h @@ -15,7 +15,7 @@ class RGBAImage;  typedef void (*DrawLineMarkerFn)(Surface *surface, const PRectangle &rcWhole, const Font *fontForCharacter, int tFold, int marginStyle, const void *lineMarker); -enum class Layer { base = 0, over = 10 }; +enum class Layer { base = 0, under = 1, over = 2 };  /**   */ diff --git a/test/simpleTests.py b/test/simpleTests.py index c28c31593..1a619a656 100644 --- a/test/simpleTests.py +++ b/test/simpleTests.py @@ -1995,8 +1995,8 @@ class TestElements(unittest.TestCase):  		self.assertEquals(self.ed.CaretLineFrame, 0)  		self.assertFalse(self.ed.CaretLineVisibleAlways) -		self.ed.CaretLineLayer = 10 -		self.assertEquals(self.ed.CaretLineLayer, 10) +		self.ed.CaretLineLayer = 2 +		self.assertEquals(self.ed.CaretLineLayer, 2)  		self.ed.CaretLineFrame = 2  		self.assertEquals(self.ed.CaretLineFrame, 2)  		self.ed.CaretLineVisibleAlways = True @@ -2028,7 +2028,7 @@ class TestElements(unittest.TestCase):  		self.assertEquals(self.ed.CaretLineBackAlpha, alpha)  		backColourTranslucent = backColour | (alpha << 24)  		self.assertEquals(self.ElementColour(self.ed.SC_ELEMENT_CARET_LINE_BACK), backColourTranslucent) -		self.assertEquals(self.ed.CaretLineLayer, 10) +		self.assertEquals(self.ed.CaretLineLayer, 2)  		self.ed.CaretLineBackAlpha = 0x100  		self.assertEquals(self.ed.CaretLineBackAlpha, 0x100) @@ -2050,7 +2050,7 @@ class TestElements(unittest.TestCase):  	def testMarkerLayer(self):  		self.assertEquals(self.ed.MarkerGetLayer(1), 0)  		self.ed.MarkerSetAlpha(1, 23) -		self.assertEquals(self.ed.MarkerGetLayer(1), 10) +		self.assertEquals(self.ed.MarkerGetLayer(1), 2)  		self.ed.MarkerSetAlpha(1, 0x100)  		self.assertEquals(self.ed.MarkerGetLayer(1), 0)  | 
