diff options
author | Neil <nyamatongwe@gmail.com> | 2018-04-20 11:23:25 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2018-04-20 11:23:25 +1000 |
commit | 8592922d49030738a4bbd3b025cdc7a5e0d79f11 (patch) | |
tree | b040e0c810512b9c8dc2ed937ce216bbc6df0ac8 /src | |
parent | a95e8fdc0958585f10e6142058ad8273269ec904 (diff) | |
download | scintilla-mirror-8592922d49030738a4bbd3b025cdc7a5e0d79f11.tar.gz |
Use standard lround function and remove some casts.
Diffstat (limited to 'src')
-rw-r--r-- | src/Indicator.cxx | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/Indicator.cxx b/src/Indicator.cxx index 5e229039e..eff9b558e 100644 --- a/src/Indicator.cxx +++ b/src/Indicator.cxx @@ -5,6 +5,8 @@ // Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org> // The License.txt file describes the conditions under which this software may be distributed. +#include <cmath> + #include <stdexcept> #include <vector> #include <map> @@ -21,8 +23,8 @@ using namespace Scintilla; static PRectangle PixelGridAlign(const PRectangle &rc) { // Move left and right side to nearest pixel to avoid blurry visuals - return PRectangle::FromInts(static_cast<int>(rc.left + 0.5), static_cast<int>(rc.top), - static_cast<int>(rc.right + 0.5), static_cast<int>(rc.bottom)); + return PRectangle::FromInts(lround(rc.left), static_cast<int>(rc.top), + lround(rc.right), static_cast<int>(rc.bottom)); } void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine, const PRectangle &rcCharacter, DrawState drawState, int value) const { @@ -36,8 +38,8 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r surface->PenColour(sacDraw.fore); const int ymid = static_cast<int>(rc.bottom + rc.top) / 2; if (sacDraw.style == INDIC_SQUIGGLE) { - int x = static_cast<int>(rc.left+0.5); - const int xLast = static_cast<int>(rc.right+0.5); + int x = lround(rc.left); + const int xLast = lround(rc.right); int y = 0; surface->MoveTo(x, static_cast<int>(rc.top) + y); while (x < xLast) { @@ -175,7 +177,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r if (rcCharacter.Width() >= 0.1) { const int pixelHeight = static_cast<int>(rc.Height() - 1.0f); // 1 pixel onto next line if multiphase const XYPOSITION x = (sacDraw.style == INDIC_POINT) ? (rcCharacter.left) : ((rcCharacter.right + rcCharacter.left) / 2); - const int ix = static_cast<int>(x + 0.5f); + const int ix = lround(x); const int iy = static_cast<int>(rc.top + 1.0f); Point pts[] = { Point::FromInts(ix - pixelHeight, iy + pixelHeight), // Left |