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 | 6516d81f0ad2574e49732c0def87d19c5a23ddeb (patch) | |
| tree | 1d23559c9e0d2d237eb29413c8d44cef14af6efd /src | |
| parent | 1cdba1d42d7cdec5bad6071f297ca1ce60fb6119 (diff) | |
| download | scintilla-mirror-6516d81f0ad2574e49732c0def87d19c5a23ddeb.tar.gz | |
Convert enum to enum class. Add noexcept and const.
Diffstat (limited to 'src')
| -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 14ccec908..597d20b47 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -1090,7 +1090,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, +	const LineLayout *ll, int xStart, PRectangle rcLine, Sci::Position secondCharacter, int subLine, Indicator::State state,  	int value, bool bidiEnabled, int tabWidthMinimumPixels) {  	const XYPOSITION subLineStart = ll->positions[ll->LineStart(subLine)]; @@ -1130,7 +1130,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, rc, rcLine, rcFirstCharacter, drawState, value); +		vsDraw.indicators[indicNum].Draw(surface, rc, rcLine, rcFirstCharacter, state, value);  	}  } @@ -1153,10 +1153,10 @@ static void DrawIndicators(Surface *surface, const EditModel &model, const ViewS  				const bool hover = vsDraw.indicators[deco->Indicator()].IsDynamic() &&  					rangeRun.ContainsCharacter(model.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, +					surface, vsDraw, ll, xStart, rcLine, posSecond - posLineStart, subLine, state,  					value, model.BidirectionalEnabled(), tabWidthMinimumPixels);  				startPos = endPos;  				if (!deco->ValueAt(startPos)) { @@ -1177,7 +1177,7 @@ static void DrawIndicators(Surface *surface, const EditModel &model, const ViewS  				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, model.BidirectionalEnabled(), tabWidthMinimumPixels); +						subLine, Indicator::State::normal, 1, model.BidirectionalEnabled(), tabWidthMinimumPixels);  				}  			}  			if (rangeLine.ContainsCharacter(model.braces[1])) { @@ -1185,7 +1185,7 @@ static void DrawIndicators(Surface *surface, const EditModel &model, const ViewS  				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, model.BidirectionalEnabled(), tabWidthMinimumPixels); +						subLine, Indicator::State::normal, 1, model.BidirectionalEnabled(), tabWidthMinimumPixels);  				}  			}  		} diff --git a/src/Indicator.cxx b/src/Indicator.cxx index 4ebf57b38..a09a64321 100644 --- a/src/Indicator.cxx +++ b/src/Indicator.cxx @@ -29,12 +29,12 @@ static PRectangle PixelGridAlign(const PRectangle &rc) noexcept {  		std::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); @@ -194,7 +194,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); @@ -269,6 +269,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;  };  } | 
