diff options
| author | Neil <nyamatongwe@gmail.com> | 2020-06-10 10:51:46 +1000 |
|---|---|---|
| committer | Neil <nyamatongwe@gmail.com> | 2020-06-10 10:51:46 +1000 |
| commit | c6f1f1c7c7f486fd19c394a7e33df9f0980b55c8 (patch) | |
| tree | 7e9ef4edb5853eccbcb2665a47657ec23584a2c5 | |
| parent | 4b4de8537bdc20fc858e8a6258e80181ac417fe8 (diff) | |
| download | scintilla-mirror-c6f1f1c7c7f486fd19c394a7e33df9f0980b55c8.tar.gz | |
Backport: Convert enum to enum class. Add noexcept and const.
Backport of changeset 8296:d8dc184c713c.
| -rw-r--r-- | src/EditView.cxx | 12 | ||||
| -rw-r--r-- | src/Indicator.cxx | 8 | ||||
| -rw-r--r-- | src/Indicator.h | 6 |
3 files changed, 13 insertions, 13 deletions
diff --git a/src/EditView.cxx b/src/EditView.cxx index f5e7a1325..edb1e0a05 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -1026,7 +1026,7 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle } static void DrawIndicator(int indicNum, Sci::Position startPos, Sci::Position endPos, Surface *surface, const ViewStyle &vsDraw, - const LineLayout *ll, int xStart, PRectangle rcLine, Sci::Position secondCharacter, int subLine, Indicator::DrawState drawState, int value) { + const LineLayout *ll, int xStart, PRectangle rcLine, Sci::Position secondCharacter, int subLine, Indicator::State state, int value) { const XYPOSITION subLineStart = ll->positions[ll->LineStart(subLine)]; const PRectangle rcIndic( ll->positions[startPos] + xStart - subLineStart, @@ -1042,7 +1042,7 @@ static void DrawIndicator(int indicNum, Sci::Position startPos, Sci::Position en // Indicator continued from earlier line so make an empty box and don't draw rcFirstCharacter.right = rcFirstCharacter.left; } - vsDraw.indicators[indicNum].Draw(surface, rcIndic, rcLine, rcFirstCharacter, drawState, value); + vsDraw.indicators[indicNum].Draw(surface, rcIndic, rcLine, rcFirstCharacter, state, value); } static void DrawIndicators(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, @@ -1064,10 +1064,10 @@ static void DrawIndicators(Surface *surface, const EditModel &model, const ViewS const bool hover = vsDraw.indicators[deco->Indicator()].IsDynamic() && rangeRun.ContainsCharacter(hoverIndicatorPos); const int value = deco->ValueAt(startPos); - const Indicator::DrawState drawState = hover ? Indicator::drawHover : Indicator::drawNormal; + const Indicator::State state = hover ? Indicator::State::hover : Indicator::State::normal; const Sci::Position posSecond = model.pdoc->MovePositionOutsideChar(rangeRun.First() + 1, 1); DrawIndicator(deco->Indicator(), startPos - posLineStart, endPos - posLineStart, - surface, vsDraw, ll, xStart, rcLine, posSecond - posLineStart, subLine, drawState, value); + surface, vsDraw, ll, xStart, rcLine, posSecond - posLineStart, subLine, state, value); startPos = endPos; if (!deco->ValueAt(startPos)) { startPos = deco->EndRun(startPos); @@ -1086,14 +1086,14 @@ static void DrawIndicators(Surface *surface, const EditModel &model, const ViewS const Sci::Position braceOffset = model.braces[0] - posLineStart; if (braceOffset < ll->numCharsInLine) { const Sci::Position secondOffset = model.pdoc->MovePositionOutsideChar(model.braces[0] + 1, 1) - posLineStart; - DrawIndicator(braceIndicator, braceOffset, braceOffset + 1, surface, vsDraw, ll, xStart, rcLine, secondOffset, subLine, Indicator::drawNormal, 1); + DrawIndicator(braceIndicator, braceOffset, braceOffset + 1, surface, vsDraw, ll, xStart, rcLine, secondOffset, subLine, Indicator::State::normal, 1); } } if (rangeLine.ContainsCharacter(model.braces[1])) { const Sci::Position braceOffset = model.braces[1] - posLineStart; if (braceOffset < ll->numCharsInLine) { const Sci::Position secondOffset = model.pdoc->MovePositionOutsideChar(model.braces[1] + 1, 1) - posLineStart; - DrawIndicator(braceIndicator, braceOffset, braceOffset + 1, surface, vsDraw, ll, xStart, rcLine, secondOffset, subLine, Indicator::drawNormal, 1); + DrawIndicator(braceIndicator, braceOffset, braceOffset + 1, surface, vsDraw, ll, xStart, rcLine, secondOffset, subLine, Indicator::State::normal, 1); } } } diff --git a/src/Indicator.cxx b/src/Indicator.cxx index fea9f4011..c08b87965 100644 --- a/src/Indicator.cxx +++ b/src/Indicator.cxx @@ -28,12 +28,12 @@ static PRectangle PixelGridAlign(const PRectangle &rc) noexcept { Sci::round(rc.right), std::floor(rc.bottom)); } -void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine, const PRectangle &rcCharacter, DrawState drawState, int value) const { +void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine, const PRectangle &rcCharacter, State state, int value) const { StyleAndColour sacDraw = sacNormal; if (Flags() & SC_INDICFLAG_VALUEFORE) { sacDraw.fore = ColourDesired(value & SC_INDICVALUEMASK); } - if (drawState == drawHover) { + if (state == State::hover) { sacDraw = sacHover; } const IntegerRectangle irc(rc); @@ -193,7 +193,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r PRectangle rcBox = PixelGridAlign(rc); rcBox.top = rcLine.top + 1; rcBox.bottom = rcLine.bottom; - IntegerRectangle ircBox(rcBox); + const IntegerRectangle ircBox(rcBox); // Cap width at 4000 to avoid large allocations when mistakes made const int width = std::min(ircBox.Width(), 4000); RGBAImage image(width, ircBox.Height(), 1.0, nullptr); @@ -268,6 +268,6 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r } } -void Indicator::SetFlags(int attributes_) { +void Indicator::SetFlags(int attributes_) noexcept { attributes = attributes_; } diff --git a/src/Indicator.h b/src/Indicator.h index 24319df99..669d9a2d8 100644 --- a/src/Indicator.h +++ b/src/Indicator.h @@ -26,7 +26,7 @@ struct StyleAndColour { */ class Indicator { public: - enum DrawState { drawNormal, drawHover }; + enum class State { normal, hover }; StyleAndColour sacNormal; StyleAndColour sacHover; bool under; @@ -38,7 +38,7 @@ public: Indicator(int style_, ColourDesired fore_=ColourDesired(0,0,0), bool under_=false, int fillAlpha_=30, int outlineAlpha_=50) noexcept : sacNormal(style_, fore_), sacHover(style_, fore_), under(under_), fillAlpha(fillAlpha_), outlineAlpha(outlineAlpha_), attributes(0) { } - void Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine, const PRectangle &rcCharacter, DrawState drawState, int value) const; + void Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine, const PRectangle &rcCharacter, State drawState, int value) const; bool IsDynamic() const noexcept { return !(sacNormal == sacHover); } @@ -48,7 +48,7 @@ public: int Flags() const noexcept { return attributes; } - void SetFlags(int attributes_); + void SetFlags(int attributes_) noexcept; }; } |
