diff options
author | nyamatongwe <devnull@localhost> | 2006-05-21 02:53:47 +0000 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2006-05-21 02:53:47 +0000 |
commit | 8bc63ca16fc5b97d3c8bd384f32a2d279cf0d77b (patch) | |
tree | 15abb4e7ae94e7d22cb4fd18e1fced5683c14c65 /src | |
parent | d36b56fea83ecfefb4e7bdeefed3829afd27bd05 (diff) | |
download | scintilla-mirror-8bc63ca16fc5b97d3c8bd384f32a2d279cf0d77b.tar.gz |
Added translucency for selection and markers.
Diffstat (limited to 'src')
-rw-r--r-- | src/Editor.cxx | 76 | ||||
-rw-r--r-- | src/LineMarker.h | 4 | ||||
-rw-r--r-- | src/ViewStyle.cxx | 2 | ||||
-rw-r--r-- | src/ViewStyle.h | 1 |
4 files changed, 70 insertions, 13 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx index 9b20bfa2d..54a461eff 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -2153,7 +2153,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou ColourAllocated Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackground, ColourAllocated background, bool inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) { if (inSelection) { - if (vsDraw.selbackset) { + if (vsDraw.selbackset && (vsDraw.selAlpha == SC_ALPHA_NOALPHA)) { if (primarySelection) return vsDraw.selbackground.allocated; else @@ -2241,7 +2241,7 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin bool eolInSelection = (subLine == (ll->lines - 1)) && (posLineEnd > ll->selStart) && (posLineEnd <= ll->selEnd) && (ll->selStart != ll->selEnd); - if (eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1)) { + if (eolInSelection && vsDraw.selbackset && (vsDraw.selAlpha == SC_ALPHA_NOALPHA) && (line < pdoc->LinesTotal() - 1)) { if (primarySelection) surface->FillRectangle(rcSegment, vsDraw.selbackground.allocated); else @@ -2277,6 +2277,12 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin } } +static void SimpleAlphaRectangle(Surface *surface, PRectangle rc, ColourAllocated fill, int alpha) { + if (alpha != SC_ALPHA_NOALPHA) { + surface->AlphaRectangle(rc, 0, fill, alpha, fill, alpha, 0); + } +} + void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart, PRectangle rcLine, LineLayout *ll, int subLine) { @@ -2302,7 +2308,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis if (!overrideBackground) { int marks = pdoc->GetMark(line); for (int markBit = 0; (markBit < 32) && marks; markBit++) { - if ((marks & 1) && vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND) { + if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND) && + (vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA)) { background = vsDraw.markers[markBit].back.allocated; overrideBackground = true; } @@ -2311,14 +2318,15 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis } if (!overrideBackground) { if (vsDraw.maskInLine) { - int marks = pdoc->GetMark(line) & vsDraw.maskInLine; - if (marks) { - for (int markBit = 0; (markBit < 32) && marks; markBit++) { - if ((marks & 1) && (vsDraw.markers[markBit].markType != SC_MARK_EMPTY)) { + int marksMasked = pdoc->GetMark(line) & vsDraw.maskInLine; + if (marksMasked) { + for (int markBit = 0; (markBit < 32) && marksMasked; markBit++) { + if ((marksMasked & 1) && (vsDraw.markers[markBit].markType != SC_MARK_EMPTY) && + (vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA)) { overrideBackground = true; background = vsDraw.markers[markBit].back.allocated; } - marks >>= 1; + marksMasked >>= 1; } } } @@ -2646,6 +2654,16 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis xStart, subLine, subLineStart, overrideBackground, background, drawWrapMarkEnd, vsDraw.whitespaceForeground.allocated); } + if ((vsDraw.selAlpha != SC_ALPHA_NOALPHA) && (ll->selStart >= 0) && (ll->selEnd >= 0)) { + int startPosSel = (ll->selStart < posLineStart) ? posLineStart : ll->selStart; + int endPosSel = (ll->selEnd < (lineEnd + posLineStart)) ? ll->selEnd : (lineEnd + posLineStart); + if (startPosSel < endPosSel) { + rcSegment.left = xStart + ll->positions[startPosSel - posLineStart] - subLineStart; + rcSegment.right = xStart + ll->positions[endPosSel - posLineStart] - subLineStart; + SimpleAlphaRectangle(surface, rcSegment, + primarySelection ? vsDraw.selbackground.allocated : vsDraw.selbackground2.allocated, vsDraw.selAlpha); + } + } if (vsDraw.edgeState == EDGE_LINE) { int edgeX = theEdge * vsDraw.spaceWidth; @@ -2654,11 +2672,29 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis surface->FillRectangle(rcSegment, vsDraw.edgecolour.allocated); } - if (caret.active && vsDraw.showCaretLineBackground && (vsDraw.caretLineAlpha != SC_ALPHA_NOALPHA) && ll->containsCaret) { - rcSegment.left = xStart; - rcSegment.right = rcLine.right - 1; - surface->AlphaRectangle(rcSegment, 0, vsDraw.caretLineBackground.allocated, vsDraw.caretLineAlpha, - vsDraw.caretLineBackground.allocated, vsDraw.caretLineAlpha, 0); + // Draw any translucent whole line states + rcSegment.left = xStart; + rcSegment.right = rcLine.right - 1; + if (caret.active && vsDraw.showCaretLineBackground && ll->containsCaret) { + SimpleAlphaRectangle(surface, rcSegment, vsDraw.caretLineBackground.allocated, vsDraw.caretLineAlpha); + } + int marks = pdoc->GetMark(line); + for (int markBit = 0; (markBit < 32) && marks; markBit++) { + if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND)) { + SimpleAlphaRectangle(surface, rcSegment, vsDraw.markers[markBit].back.allocated, vsDraw.markers[markBit].alpha); + } + marks >>= 1; + } + if (vsDraw.maskInLine) { + int marksMasked = pdoc->GetMark(line) & vsDraw.maskInLine; + if (marksMasked) { + for (int markBit = 0; (markBit < 32) && marksMasked; markBit++) { + if ((marksMasked & 1) && (vsDraw.markers[markBit].markType != SC_MARK_EMPTY)) { + SimpleAlphaRectangle(surface, rcSegment, vsDraw.markers[markBit].back.allocated, vsDraw.markers[markBit].alpha); + } + marksMasked >>= 1; + } + } } } @@ -3089,6 +3125,7 @@ long Editor::FormatRange(bool draw, RangeToFormat *pfr) { // Don't show the selection when printing vsPrint.selbackset = false; vsPrint.selforeset = false; + vsPrint.selAlpha = SC_ALPHA_NOALPHA; vsPrint.whitespaceBackgroundSet = false; vsPrint.whitespaceForegroundSet = false; vsPrint.showCaretLineBackground = false; @@ -6512,6 +6549,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { InvalidateStyleData(); RedrawSelMargin(); break; + case SCI_MARKERSETALPHA: + if (wParam <= MARKER_MAX) + vs.markers[wParam].alpha = lParam; + InvalidateStyleRedraw(); + break; case SCI_MARKERADD: { int markerID = pdoc->AddMark(wParam, lParam); return markerID; @@ -6850,6 +6892,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { InvalidateStyleRedraw(); break; + case SCI_SETSELALPHA: + vs.selAlpha = wParam; + InvalidateStyleRedraw(); + break; + + case SCI_GETSELALPHA: + return vs.selAlpha; + case SCI_SETWHITESPACEFORE: vs.whitespaceForegroundSet = wParam != 0; vs.whitespaceForeground.desired = ColourDesired(lParam); diff --git a/src/LineMarker.h b/src/LineMarker.h index ef5924f75..8ebdce491 100644 --- a/src/LineMarker.h +++ b/src/LineMarker.h @@ -15,11 +15,13 @@ public: int markType; ColourPair fore; ColourPair back; + int alpha; XPM *pxpm; LineMarker() { markType = SC_MARK_CIRCLE; fore = ColourDesired(0,0,0); back = ColourDesired(0xff,0xff,0xff); + alpha = SC_ALPHA_NOALPHA; pxpm = NULL; } LineMarker(const LineMarker &) { @@ -27,6 +29,7 @@ public: markType = SC_MARK_CIRCLE; fore = ColourDesired(0,0,0); back = ColourDesired(0xff,0xff,0xff); + alpha = SC_ALPHA_NOALPHA; pxpm = NULL; } ~LineMarker() { @@ -37,6 +40,7 @@ public: markType = SC_MARK_CIRCLE; fore = ColourDesired(0,0,0); back = ColourDesired(0xff,0xff,0xff); + alpha = SC_ALPHA_NOALPHA; delete pxpm; pxpm = NULL; return *this; diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index f221af193..930427bb8 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -73,6 +73,7 @@ ViewStyle::ViewStyle(const ViewStyle &source) { selbackset = source.selbackset; selbackground.desired = source.selbackground.desired; selbackground2.desired = source.selbackground2.desired; + selAlpha = source.selAlpha; foldmarginColourSet = source.foldmarginColourSet; foldmarginColour.desired = source.foldmarginColour.desired; @@ -141,6 +142,7 @@ void ViewStyle::Init() { selbackset = true; selbackground.desired = ColourDesired(0xc0, 0xc0, 0xc0); selbackground2.desired = ColourDesired(0xb0, 0xb0, 0xb0); + selAlpha = SC_ALPHA_NOALPHA; foldmarginColourSet = false; foldmarginColour.desired = ColourDesired(0xff, 0, 0); diff --git a/src/ViewStyle.h b/src/ViewStyle.h index 90d50b1fb..d0cb87f21 100644 --- a/src/ViewStyle.h +++ b/src/ViewStyle.h @@ -53,6 +53,7 @@ public: bool selbackset; ColourPair selbackground; ColourPair selbackground2; + int selAlpha; bool whitespaceForegroundSet; ColourPair whitespaceForeground; bool whitespaceBackgroundSet; |