mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Made a few minor tweaks to reduce the number of pedantic -Wfloat-equals warnings
This commit is contained in:
parent
6bb3d9b1db
commit
bf94ab0e4c
26 changed files with 411 additions and 432 deletions
|
|
@ -283,7 +283,7 @@ public:
|
|||
return gradCol1.isTransparent() && gradCol2.isTransparent();
|
||||
|
||||
case imageBrush:
|
||||
return imageOpacity == 0;
|
||||
return imageOpacity == 0.0;
|
||||
|
||||
default:
|
||||
jassertfalse;
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ public:
|
|||
s << getFontStyleCode (font)
|
||||
<< ")";
|
||||
|
||||
if (font.getExtraKerningFactor() != 0)
|
||||
if (font.getExtraKerningFactor() != 0.0f)
|
||||
s << ".withExtraKerningFactor ("
|
||||
<< CodeHelpers::floatLiteral (font.getExtraKerningFactor(), 3)
|
||||
<< ")";
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ public:
|
|||
int64 toInt64 (const ValueUnion& data) const noexcept override { return (int64) data.doubleValue; }
|
||||
double toDouble (const ValueUnion& data) const noexcept override { return data.doubleValue; }
|
||||
String toString (const ValueUnion& data) const override { return String (data.doubleValue, 20); }
|
||||
bool toBool (const ValueUnion& data) const noexcept override { return data.doubleValue != 0; }
|
||||
bool toBool (const ValueUnion& data) const noexcept override { return data.doubleValue != 0.0; }
|
||||
bool isDouble() const noexcept override { return true; }
|
||||
|
||||
bool equals (const ValueUnion& data, const ValueUnion& otherData, const VariantType& otherType) const noexcept override
|
||||
|
|
|
|||
|
|
@ -597,7 +597,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
|
|||
struct DivideOp : public BinaryOperator
|
||||
{
|
||||
DivideOp (const CodeLocation& l, ExpPtr& a, ExpPtr& b) noexcept : BinaryOperator (l, a, b, TokenTypes::divide) {}
|
||||
var getWithDoubles (double a, double b) const override { return b != 0 ? a / b : std::numeric_limits<double>::infinity(); }
|
||||
var getWithDoubles (double a, double b) const override { return b != 0.0 ? a / b : std::numeric_limits<double>::infinity(); }
|
||||
var getWithInts (int64 a, int64 b) const override { return b != 0 ? var (a / (double) b) : var (std::numeric_limits<double>::infinity()); }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ double CharacterFunctions::mulexp10 (const double value, int exponent) noexcept
|
|||
if (exponent == 0)
|
||||
return value;
|
||||
|
||||
if (value == 0)
|
||||
if (value == 0.0)
|
||||
return 0;
|
||||
|
||||
const bool negative = (exponent < 0);
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ void ColourGradient::setColour (int index, Colour newColour) noexcept
|
|||
|
||||
Colour ColourGradient::getColourAtPosition (const double position) const noexcept
|
||||
{
|
||||
jassert (colours.getReference(0).position == 0); // the first colour specified has to go at position 0
|
||||
jassert (colours.getReference(0).position == 0.0); // the first colour specified has to go at position 0
|
||||
|
||||
if (position <= 0 || colours.size() <= 1)
|
||||
return colours.getReference(0).colour;
|
||||
|
|
@ -157,7 +157,7 @@ void ColourGradient::createLookupTable (PixelARGB* const lookupTable, const int
|
|||
JUCE_COLOURGRADIENT_CHECK_COORDS_INITIALISED // Trying to use this object without setting its coordinates?
|
||||
jassert (colours.size() >= 2);
|
||||
jassert (numEntries > 0);
|
||||
jassert (colours.getReference(0).position == 0); // The first colour specified has to go at position 0
|
||||
jassert (colours.getReference(0).position == 0.0); // The first colour specified has to go at position 0
|
||||
|
||||
PixelARGB pix1 (colours.getReference (0).colour.getPixelARGB());
|
||||
int index = 0;
|
||||
|
|
|
|||
|
|
@ -189,9 +189,9 @@ void CustomTypeface::addGlyph (const juce_wchar character, const Path& path, con
|
|||
|
||||
void CustomTypeface::addKerningPair (const juce_wchar char1, const juce_wchar char2, const float extraAmount) noexcept
|
||||
{
|
||||
if (extraAmount != 0)
|
||||
if (extraAmount != 0.0f)
|
||||
{
|
||||
if (GlyphInfo* const g = findGlyph (char1, true))
|
||||
if (auto* g = findGlyph (char1, true))
|
||||
g->addKerningPair (char2, extraAmount);
|
||||
else
|
||||
jassertfalse; // can only add kerning pairs for characters that exist!
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ void Font::setDefaultMinimumHorizontalScaleFactor (float newValue) noexcept { F
|
|||
class TypefaceCache : private DeletedAtShutdown
|
||||
{
|
||||
public:
|
||||
TypefaceCache() : counter (0)
|
||||
TypefaceCache()
|
||||
{
|
||||
setSize (10);
|
||||
}
|
||||
|
|
@ -77,8 +77,8 @@ public:
|
|||
{
|
||||
const ScopedReadLock slr (lock);
|
||||
|
||||
const String faceName (font.getTypefaceName());
|
||||
const String faceStyle (font.getTypefaceStyle());
|
||||
auto faceName = font.getTypefaceName();
|
||||
auto faceStyle = font.getTypefaceStyle();
|
||||
|
||||
jassert (faceName.isNotEmpty());
|
||||
|
||||
|
|
@ -98,11 +98,11 @@ public:
|
|||
|
||||
const ScopedWriteLock slw (lock);
|
||||
int replaceIndex = 0;
|
||||
size_t bestLastUsageCount = std::numeric_limits<size_t>::max();
|
||||
auto bestLastUsageCount = std::numeric_limits<size_t>::max();
|
||||
|
||||
for (int i = faces.size(); --i >= 0;)
|
||||
{
|
||||
const size_t lu = faces.getReference(i).lastUsageCount;
|
||||
auto lu = faces.getReference(i).lastUsageCount;
|
||||
|
||||
if (bestLastUsageCount > lu)
|
||||
{
|
||||
|
|
@ -111,7 +111,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
CachedFace& face = faces.getReference (replaceIndex);
|
||||
auto& face = faces.getReference (replaceIndex);
|
||||
face.typefaceName = faceName;
|
||||
face.typefaceStyle = faceStyle;
|
||||
face.lastUsageCount = ++counter;
|
||||
|
|
@ -147,7 +147,7 @@ private:
|
|||
|
||||
ReadWriteLock lock;
|
||||
Array<CachedFace> faces;
|
||||
size_t counter;
|
||||
size_t counter = 0;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TypefaceCache)
|
||||
};
|
||||
|
|
@ -179,8 +179,7 @@ public:
|
|||
: typeface (TypefaceCache::getInstance()->defaultFace),
|
||||
typefaceName (Font::getDefaultSansSerifFontName()),
|
||||
typefaceStyle (Font::getDefaultStyle()),
|
||||
height (FontValues::defaultFontHeight),
|
||||
horizontalScale (1.0f), kerning (0), ascent (0), underline (false)
|
||||
height (FontValues::defaultFontHeight)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -188,7 +187,7 @@ public:
|
|||
: typefaceName (Font::getDefaultSansSerifFontName()),
|
||||
typefaceStyle (FontStyleHelpers::getStyleName (styleFlags)),
|
||||
height (fontHeight),
|
||||
horizontalScale (1.0f), kerning (0), ascent (0), underline ((styleFlags & underlined) != 0)
|
||||
underline ((styleFlags & underlined) != 0)
|
||||
{
|
||||
if (styleFlags == plain)
|
||||
typeface = TypefaceCache::getInstance()->defaultFace;
|
||||
|
|
@ -198,15 +197,14 @@ public:
|
|||
: typefaceName (name),
|
||||
typefaceStyle (FontStyleHelpers::getStyleName (styleFlags)),
|
||||
height (fontHeight),
|
||||
horizontalScale (1.0f), kerning (0), ascent (0), underline ((styleFlags & underlined) != 0)
|
||||
underline ((styleFlags & underlined) != 0)
|
||||
{
|
||||
if (styleFlags == plain && typefaceName.isEmpty())
|
||||
typeface = TypefaceCache::getInstance()->defaultFace;
|
||||
}
|
||||
|
||||
SharedFontInternal (const String& name, const String& style, float fontHeight) noexcept
|
||||
: typefaceName (name), typefaceStyle (style), height (fontHeight),
|
||||
horizontalScale (1.0f), kerning (0), ascent (0), underline (false)
|
||||
: typefaceName (name), typefaceStyle (style), height (fontHeight)
|
||||
{
|
||||
if (typefaceName.isEmpty())
|
||||
typefaceName = Font::getDefaultSansSerifFontName();
|
||||
|
|
@ -216,8 +214,7 @@ public:
|
|||
: typeface (face),
|
||||
typefaceName (face->getName()),
|
||||
typefaceStyle (face->getStyle()),
|
||||
height (FontValues::defaultFontHeight),
|
||||
horizontalScale (1.0f), kerning (0), ascent (0), underline (false)
|
||||
height (FontValues::defaultFontHeight)
|
||||
{
|
||||
jassert (typefaceName.isNotEmpty());
|
||||
}
|
||||
|
|
@ -247,8 +244,8 @@ public:
|
|||
|
||||
Typeface::Ptr typeface;
|
||||
String typefaceName, typefaceStyle;
|
||||
float height, horizontalScale, kerning, ascent;
|
||||
bool underline;
|
||||
float height, horizontalScale = 1.0f, kerning = 0, ascent = 0;
|
||||
bool underline = false;
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -318,15 +315,10 @@ void Font::checkTypefaceSuitability()
|
|||
//==============================================================================
|
||||
struct FontPlaceholderNames
|
||||
{
|
||||
FontPlaceholderNames()
|
||||
: sans ("<Sans-Serif>"),
|
||||
serif ("<Serif>"),
|
||||
mono ("<Monospaced>"),
|
||||
regular ("<Regular>")
|
||||
{
|
||||
}
|
||||
|
||||
String sans, serif, mono, regular;
|
||||
String sans { "<Sans-Serif>" },
|
||||
serif { "<Serif>" },
|
||||
mono { "<Monospaced>" },
|
||||
regular { "<Regular>" };
|
||||
};
|
||||
|
||||
const FontPlaceholderNames& getFontPlaceholderNames()
|
||||
|
|
@ -590,14 +582,14 @@ bool Font::isUnderlined() const noexcept { return font->underline; }
|
|||
|
||||
void Font::setBold (const bool shouldBeBold)
|
||||
{
|
||||
const int flags = getStyleFlags();
|
||||
auto flags = getStyleFlags();
|
||||
setStyleFlags (shouldBeBold ? (flags | bold)
|
||||
: (flags & ~bold));
|
||||
}
|
||||
|
||||
void Font::setItalic (const bool shouldBeItalic)
|
||||
{
|
||||
const int flags = getStyleFlags();
|
||||
auto flags = getStyleFlags();
|
||||
setStyleFlags (shouldBeItalic ? (flags | italic)
|
||||
: (flags & ~italic));
|
||||
}
|
||||
|
|
@ -611,7 +603,7 @@ void Font::setUnderline (const bool shouldBeUnderlined)
|
|||
|
||||
float Font::getAscent() const
|
||||
{
|
||||
if (font->ascent == 0)
|
||||
if (font->ascent == 0.0f)
|
||||
font->ascent = getTypeface()->getAscent();
|
||||
|
||||
return font->height * font->ascent;
|
||||
|
|
@ -631,9 +623,9 @@ int Font::getStringWidth (const String& text) const
|
|||
|
||||
float Font::getStringWidthFloat (const String& text) const
|
||||
{
|
||||
float w = getTypeface()->getStringWidth (text);
|
||||
auto w = getTypeface()->getStringWidth (text);
|
||||
|
||||
if (font->kerning != 0)
|
||||
if (font->kerning != 0.0f)
|
||||
w += font->kerning * text.length();
|
||||
|
||||
return w * font->height * font->horizontalScale;
|
||||
|
|
@ -643,14 +635,12 @@ void Font::getGlyphPositions (const String& text, Array<int>& glyphs, Array<floa
|
|||
{
|
||||
getTypeface()->getGlyphPositions (text, glyphs, xOffsets);
|
||||
|
||||
const int num = xOffsets.size();
|
||||
|
||||
if (num > 0)
|
||||
if (auto num = xOffsets.size())
|
||||
{
|
||||
const float scale = font->height * font->horizontalScale;
|
||||
float* const x = xOffsets.getRawDataPointer();
|
||||
auto scale = font->height * font->horizontalScale;
|
||||
auto* x = xOffsets.getRawDataPointer();
|
||||
|
||||
if (font->kerning != 0)
|
||||
if (font->kerning != 0.0f)
|
||||
{
|
||||
for (int i = 0; i < num; ++i)
|
||||
x[i] = (x[i] + i * font->kerning) * scale;
|
||||
|
|
@ -665,18 +655,16 @@ void Font::getGlyphPositions (const String& text, Array<int>& glyphs, Array<floa
|
|||
|
||||
void Font::findFonts (Array<Font>& destArray)
|
||||
{
|
||||
const StringArray names (findAllTypefaceNames());
|
||||
|
||||
for (int i = 0; i < names.size(); ++i)
|
||||
for (auto& name : findAllTypefaceNames())
|
||||
{
|
||||
const StringArray styles (findAllTypefaceStyles (names[i]));
|
||||
auto styles = findAllTypefaceStyles (name);
|
||||
|
||||
String style ("Regular");
|
||||
|
||||
if (! styles.contains (style, true))
|
||||
style = styles[0];
|
||||
|
||||
destArray.add (Font (names[i], style, FontValues::defaultFontHeight));
|
||||
destArray.add (Font (name, style, FontValues::defaultFontHeight));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,10 +71,10 @@ bool AffineTransform::operator!= (const AffineTransform& other) const noexcept
|
|||
//==============================================================================
|
||||
bool AffineTransform::isIdentity() const noexcept
|
||||
{
|
||||
return (mat01 == 0)
|
||||
&& (mat02 == 0)
|
||||
&& (mat10 == 0)
|
||||
&& (mat12 == 0)
|
||||
return (mat01 == 0.0f)
|
||||
&& (mat02 == 0.0f)
|
||||
&& (mat10 == 0.0f)
|
||||
&& (mat12 == 0.0f)
|
||||
&& (mat00 == 1.0f)
|
||||
&& (mat11 == 1.0f);
|
||||
}
|
||||
|
|
@ -228,7 +228,7 @@ AffineTransform AffineTransform::inverted() const noexcept
|
|||
|
||||
bool AffineTransform::isSingularity() const noexcept
|
||||
{
|
||||
return (mat00 * mat11 - mat10 * mat01) == 0;
|
||||
return (mat00 * mat11 - mat10 * mat01) == 0.0f;
|
||||
}
|
||||
|
||||
AffineTransform AffineTransform::fromTargetPoints (const float x00, const float y00,
|
||||
|
|
@ -250,8 +250,8 @@ AffineTransform AffineTransform::fromTargetPoints (const float sx1, const float
|
|||
|
||||
bool AffineTransform::isOnlyTranslation() const noexcept
|
||||
{
|
||||
return (mat01 == 0)
|
||||
&& (mat10 == 0)
|
||||
return (mat01 == 0.0f)
|
||||
&& (mat10 == 0.0f)
|
||||
&& (mat00 == 1.0f)
|
||||
&& (mat11 == 1.0f);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ namespace PathHelpers
|
|||
{
|
||||
t = t.findEndOfWhitespace();
|
||||
|
||||
String::CharPointerType start (t);
|
||||
auto start = t;
|
||||
size_t numChars = 0;
|
||||
|
||||
while (! (t.isEmpty() || t.isWhitespace()))
|
||||
|
|
@ -44,7 +44,7 @@ namespace PathHelpers
|
|||
++numChars;
|
||||
}
|
||||
|
||||
return String (start, numChars);
|
||||
return { start, numChars };
|
||||
}
|
||||
|
||||
inline double lengthOf (float x1, float y1, float x2, float y2) noexcept
|
||||
|
|
@ -63,15 +63,19 @@ const float Path::closeSubPathMarker = 100005.0f;
|
|||
const float Path::defaultToleranceForTesting = 1.0f;
|
||||
const float Path::defaultToleranceForMeasurement = 0.6f;
|
||||
|
||||
static inline bool isMarker (float value, float marker) noexcept
|
||||
{
|
||||
return value == marker;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
Path::PathBounds::PathBounds() noexcept
|
||||
: pathXMin (0), pathXMax (0), pathYMin (0), pathYMax (0)
|
||||
{
|
||||
}
|
||||
|
||||
Rectangle<float> Path::PathBounds::getRectangle() const noexcept
|
||||
{
|
||||
return Rectangle<float> (pathXMin, pathYMin, pathXMax - pathXMin, pathYMax - pathYMin);
|
||||
return { pathXMin, pathYMin, pathXMax - pathXMin, pathYMax - pathYMin };
|
||||
}
|
||||
|
||||
void Path::PathBounds::reset() noexcept
|
||||
|
|
@ -120,7 +124,6 @@ void Path::PathBounds::extend (const float x1, const float y1, const float x2, c
|
|||
|
||||
//==============================================================================
|
||||
Path::Path()
|
||||
: numElements (0), useNonZeroWinding (true)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -214,8 +217,7 @@ void Path::setUsingNonZeroWinding (const bool isNonZero) noexcept
|
|||
useNonZeroWinding = isNonZero;
|
||||
}
|
||||
|
||||
void Path::scaleToFit (const float x, const float y, const float w, const float h,
|
||||
const bool preserveProportions) noexcept
|
||||
void Path::scaleToFit (float x, float y, float w, float h, bool preserveProportions) noexcept
|
||||
{
|
||||
applyTransform (getTransformToScaleToFit (x, y, w, h, preserveProportions));
|
||||
}
|
||||
|
|
@ -227,15 +229,15 @@ bool Path::isEmpty() const noexcept
|
|||
|
||||
while (i < numElements)
|
||||
{
|
||||
const float type = data.elements [i++];
|
||||
auto type = data.elements[i++];
|
||||
|
||||
if (type == moveMarker)
|
||||
if (isMarker (type, moveMarker))
|
||||
{
|
||||
i += 2;
|
||||
}
|
||||
else if (type == lineMarker
|
||||
|| type == quadMarker
|
||||
|| type == cubicMarker)
|
||||
else if (isMarker (type, lineMarker)
|
||||
|| isMarker (type, quadMarker)
|
||||
|| isMarker (type, cubicMarker))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -365,8 +367,7 @@ void Path::cubicTo (const Point<float> controlPoint1,
|
|||
|
||||
void Path::closeSubPath()
|
||||
{
|
||||
if (numElements > 0
|
||||
&& data.elements [numElements - 1] != closeSubPathMarker)
|
||||
if (numElements > 0 && ! isMarker (data.elements[numElements - 1], closeSubPathMarker))
|
||||
{
|
||||
preallocateSpace (1);
|
||||
data.elements[numElements++] = closeSubPathMarker;
|
||||
|
|
@ -377,11 +378,11 @@ Point<float> Path::getCurrentPosition() const
|
|||
{
|
||||
int i = (int) numElements - 1;
|
||||
|
||||
if (i > 0 && data.elements[i] == closeSubPathMarker)
|
||||
if (i > 0 && isMarker (data.elements[i], closeSubPathMarker))
|
||||
{
|
||||
while (i >= 0)
|
||||
{
|
||||
if (data.elements[i] == moveMarker)
|
||||
if (isMarker (data.elements[i], moveMarker))
|
||||
{
|
||||
i += 2;
|
||||
break;
|
||||
|
|
@ -392,9 +393,9 @@ Point<float> Path::getCurrentPosition() const
|
|||
}
|
||||
|
||||
if (i > 0)
|
||||
return Point<float> (data.elements [i - 1], data.elements [i]);
|
||||
return { data.elements[i - 1], data.elements[i] };
|
||||
|
||||
return Point<float>();
|
||||
return {};
|
||||
}
|
||||
|
||||
void Path::addRectangle (const float x, const float y,
|
||||
|
|
@ -449,10 +450,10 @@ void Path::addRoundedRectangle (const float x, const float y, const float w, con
|
|||
{
|
||||
csx = jmin (csx, w * 0.5f);
|
||||
csy = jmin (csy, h * 0.5f);
|
||||
const float cs45x = csx * 0.45f;
|
||||
const float cs45y = csy * 0.45f;
|
||||
const float x2 = x + w;
|
||||
const float y2 = y + h;
|
||||
auto cs45x = csx * 0.45f;
|
||||
auto cs45y = csy * 0.45f;
|
||||
auto x2 = x + w;
|
||||
auto y2 = y + h;
|
||||
|
||||
if (curveTopLeft)
|
||||
{
|
||||
|
|
@ -538,12 +539,12 @@ void Path::addEllipse (float x, float y, float w, float h)
|
|||
|
||||
void Path::addEllipse (Rectangle<float> area)
|
||||
{
|
||||
const float hw = area.getWidth() * 0.5f;
|
||||
const float hw55 = hw * 0.55f;
|
||||
const float hh = area.getHeight() * 0.5f;
|
||||
const float hh55 = hh * 0.55f;
|
||||
const float cx = area.getX() + hw;
|
||||
const float cy = area.getY() + hh;
|
||||
auto hw = area.getWidth() * 0.5f;
|
||||
auto hw55 = hw * 0.55f;
|
||||
auto hh = area.getHeight() * 0.5f;
|
||||
auto hh55 = hh * 0.55f;
|
||||
auto cx = area.getX() + hw;
|
||||
auto cy = area.getY() + hh;
|
||||
|
||||
startNewSubPath (cx, cy - hh);
|
||||
cubicTo (cx + hw55, cy - hh, cx + hw, cy - hh55, cx + hw, cy);
|
||||
|
|
@ -559,8 +560,8 @@ void Path::addArc (const float x, const float y,
|
|||
const float toRadians,
|
||||
const bool startAsNewSubPath)
|
||||
{
|
||||
const float radiusX = w / 2.0f;
|
||||
const float radiusY = h / 2.0f;
|
||||
auto radiusX = w / 2.0f;
|
||||
auto radiusY = h / 2.0f;
|
||||
|
||||
addCentredArc (x + radiusX,
|
||||
y + radiusY,
|
||||
|
|
@ -580,8 +581,8 @@ void Path::addCentredArc (const float centreX, const float centreY,
|
|||
if (radiusX > 0.0f && radiusY > 0.0f)
|
||||
{
|
||||
const Point<float> centre (centreX, centreY);
|
||||
const AffineTransform rotation (AffineTransform::rotation (rotationOfEllipse, centreX, centreY));
|
||||
float angle = fromRadians;
|
||||
auto rotation = AffineTransform::rotation (rotationOfEllipse, centreX, centreY);
|
||||
auto angle = fromRadians;
|
||||
|
||||
if (startAsNewSubPath)
|
||||
startNewSubPath (centre.getPointOnCircumference (radiusX, radiusY, angle).transformedBy (rotation));
|
||||
|
|
@ -674,7 +675,7 @@ void Path::addPieSegment (Rectangle<float> segmentBounds,
|
|||
//==============================================================================
|
||||
void Path::addLineSegment (const Line<float>& line, float lineThickness)
|
||||
{
|
||||
const Line<float> reversed (line.reversed());
|
||||
auto reversed = line.reversed();
|
||||
lineThickness *= 0.5f;
|
||||
|
||||
startNewSubPath (line.getPointAlongLine (0, lineThickness));
|
||||
|
|
@ -687,7 +688,7 @@ void Path::addLineSegment (const Line<float>& line, float lineThickness)
|
|||
void Path::addArrow (const Line<float>& line, float lineThickness,
|
||||
float arrowheadWidth, float arrowheadLength)
|
||||
{
|
||||
const Line<float> reversed (line.reversed());
|
||||
auto reversed = line.reversed();
|
||||
lineThickness *= 0.5f;
|
||||
arrowheadWidth *= 0.5f;
|
||||
arrowheadLength = jmin (arrowheadLength, 0.8f * line.getLength());
|
||||
|
|
@ -709,12 +710,12 @@ void Path::addPolygon (const Point<float> centre, const int numberOfSides,
|
|||
|
||||
if (numberOfSides > 1)
|
||||
{
|
||||
const float angleBetweenPoints = float_Pi * 2.0f / numberOfSides;
|
||||
auto angleBetweenPoints = float_Pi * 2.0f / numberOfSides;
|
||||
|
||||
for (int i = 0; i < numberOfSides; ++i)
|
||||
{
|
||||
const float angle = startAngle + i * angleBetweenPoints;
|
||||
const Point<float> p (centre.getPointOnCircumference (radius, angle));
|
||||
auto angle = startAngle + i * angleBetweenPoints;
|
||||
auto p = centre.getPointOnCircumference (radius, angle);
|
||||
|
||||
if (i == 0)
|
||||
startNewSubPath (p);
|
||||
|
|
@ -733,12 +734,12 @@ void Path::addStar (const Point<float> centre, const int numberOfPoints,
|
|||
|
||||
if (numberOfPoints > 1)
|
||||
{
|
||||
const float angleBetweenPoints = float_Pi * 2.0f / numberOfPoints;
|
||||
auto angleBetweenPoints = float_Pi * 2.0f / numberOfPoints;
|
||||
|
||||
for (int i = 0; i < numberOfPoints; ++i)
|
||||
{
|
||||
const float angle = startAngle + i * angleBetweenPoints;
|
||||
const Point<float> p (centre.getPointOnCircumference (outerRadius, angle));
|
||||
auto angle = startAngle + i * angleBetweenPoints;
|
||||
auto p = centre.getPointOnCircumference (outerRadius, angle);
|
||||
|
||||
if (i == 0)
|
||||
startNewSubPath (p);
|
||||
|
|
@ -758,12 +759,12 @@ void Path::addBubble (const Rectangle<float>& bodyArea,
|
|||
const float cornerSize,
|
||||
const float arrowBaseWidth)
|
||||
{
|
||||
const float halfW = bodyArea.getWidth() / 2.0f;
|
||||
const float halfH = bodyArea.getHeight() / 2.0f;
|
||||
const float cornerSizeW = jmin (cornerSize, halfW);
|
||||
const float cornerSizeH = jmin (cornerSize, halfH);
|
||||
const float cornerSizeW2 = 2.0f * cornerSizeW;
|
||||
const float cornerSizeH2 = 2.0f * cornerSizeH;
|
||||
auto halfW = bodyArea.getWidth() / 2.0f;
|
||||
auto halfH = bodyArea.getHeight() / 2.0f;
|
||||
auto cornerSizeW = jmin (cornerSize, halfW);
|
||||
auto cornerSizeH = jmin (cornerSize, halfH);
|
||||
auto cornerSizeW2 = 2.0f * cornerSizeW;
|
||||
auto cornerSizeH2 = 2.0f * cornerSizeH;
|
||||
|
||||
startNewSubPath (bodyArea.getX() + cornerSizeW, bodyArea.getY());
|
||||
|
||||
|
|
@ -820,33 +821,33 @@ void Path::addBubble (const Rectangle<float>& bodyArea,
|
|||
void Path::addPath (const Path& other)
|
||||
{
|
||||
size_t i = 0;
|
||||
const float* const d = other.data.elements;
|
||||
const float* d = other.data.elements;
|
||||
|
||||
while (i < other.numElements)
|
||||
{
|
||||
const float type = d[i++];
|
||||
auto type = d[i++];
|
||||
|
||||
if (type == moveMarker)
|
||||
if (isMarker (type, moveMarker))
|
||||
{
|
||||
startNewSubPath (d[i], d[i + 1]);
|
||||
i += 2;
|
||||
}
|
||||
else if (type == lineMarker)
|
||||
else if (isMarker (type, lineMarker))
|
||||
{
|
||||
lineTo (d[i], d[i + 1]);
|
||||
i += 2;
|
||||
}
|
||||
else if (type == quadMarker)
|
||||
else if (isMarker (type, quadMarker))
|
||||
{
|
||||
quadraticTo (d[i], d[i + 1], d[i + 2], d[i + 3]);
|
||||
i += 4;
|
||||
}
|
||||
else if (type == cubicMarker)
|
||||
else if (isMarker (type, cubicMarker))
|
||||
{
|
||||
cubicTo (d[i], d[i + 1], d[i + 2], d[i + 3], d[i + 4], d[i + 5]);
|
||||
i += 6;
|
||||
}
|
||||
else if (type == closeSubPathMarker)
|
||||
else if (isMarker (type, closeSubPathMarker))
|
||||
{
|
||||
closeSubPath();
|
||||
}
|
||||
|
|
@ -862,44 +863,44 @@ void Path::addPath (const Path& other,
|
|||
const AffineTransform& transformToApply)
|
||||
{
|
||||
size_t i = 0;
|
||||
const float* const d = other.data.elements;
|
||||
const float* d = other.data.elements;
|
||||
|
||||
while (i < other.numElements)
|
||||
{
|
||||
const float type = d [i++];
|
||||
auto type = d[i++];
|
||||
|
||||
if (type == closeSubPathMarker)
|
||||
if (isMarker (type, closeSubPathMarker))
|
||||
{
|
||||
closeSubPath();
|
||||
}
|
||||
else
|
||||
{
|
||||
float x = d[i++];
|
||||
float y = d[i++];
|
||||
auto x = d[i++];
|
||||
auto y = d[i++];
|
||||
transformToApply.transformPoint (x, y);
|
||||
|
||||
if (type == moveMarker)
|
||||
if (isMarker (type, moveMarker))
|
||||
{
|
||||
startNewSubPath (x, y);
|
||||
}
|
||||
else if (type == lineMarker)
|
||||
else if (isMarker (type, lineMarker))
|
||||
{
|
||||
lineTo (x, y);
|
||||
}
|
||||
else if (type == quadMarker)
|
||||
else if (isMarker (type, quadMarker))
|
||||
{
|
||||
float x2 = d [i++];
|
||||
float y2 = d [i++];
|
||||
auto x2 = d[i++];
|
||||
auto y2 = d[i++];
|
||||
transformToApply.transformPoint (x2, y2);
|
||||
|
||||
quadraticTo (x, y, x2, y2);
|
||||
}
|
||||
else if (type == cubicMarker)
|
||||
else if (isMarker (type, cubicMarker))
|
||||
{
|
||||
float x2 = d [i++];
|
||||
float y2 = d [i++];
|
||||
float x3 = d [i++];
|
||||
float y3 = d [i++];
|
||||
auto x2 = d[i++];
|
||||
auto y2 = d[i++];
|
||||
auto x3 = d[i++];
|
||||
auto y3 = d[i++];
|
||||
transformToApply.transformPoints (x2, y2, x3, y3);
|
||||
|
||||
cubicTo (x, y, x2, y2, x3, y3);
|
||||
|
|
@ -919,13 +920,13 @@ void Path::applyTransform (const AffineTransform& transform) noexcept
|
|||
bounds.reset();
|
||||
bool firstPoint = true;
|
||||
float* d = data.elements;
|
||||
float* const end = d + numElements;
|
||||
auto* end = d + numElements;
|
||||
|
||||
while (d < end)
|
||||
{
|
||||
const float type = *d++;
|
||||
auto type = *d++;
|
||||
|
||||
if (type == moveMarker)
|
||||
if (isMarker (type, moveMarker))
|
||||
{
|
||||
transform.transformPoint (d[0], d[1]);
|
||||
|
||||
|
|
@ -941,19 +942,19 @@ void Path::applyTransform (const AffineTransform& transform) noexcept
|
|||
|
||||
d += 2;
|
||||
}
|
||||
else if (type == lineMarker)
|
||||
else if (isMarker (type, lineMarker))
|
||||
{
|
||||
transform.transformPoint (d[0], d[1]);
|
||||
bounds.extend (d[0], d[1]);
|
||||
d += 2;
|
||||
}
|
||||
else if (type == quadMarker)
|
||||
else if (isMarker (type, quadMarker))
|
||||
{
|
||||
transform.transformPoints (d[0], d[1], d[2], d[3]);
|
||||
bounds.extend (d[0], d[1], d[2], d[3]);
|
||||
d += 4;
|
||||
}
|
||||
else if (type == cubicMarker)
|
||||
else if (isMarker (type, cubicMarker))
|
||||
{
|
||||
transform.transformPoints (d[0], d[1], d[2], d[3], d[4], d[5]);
|
||||
bounds.extend (d[0], d[1], d[2], d[3]);
|
||||
|
|
@ -977,7 +978,7 @@ AffineTransform Path::getTransformToScaleToFit (const float x, const float y,
|
|||
const bool preserveProportions,
|
||||
Justification justification) const
|
||||
{
|
||||
Rectangle<float> boundsRect (getBounds());
|
||||
auto boundsRect = getBounds();
|
||||
|
||||
if (preserveProportions)
|
||||
{
|
||||
|
|
@ -985,7 +986,7 @@ AffineTransform Path::getTransformToScaleToFit (const float x, const float y,
|
|||
return AffineTransform();
|
||||
|
||||
float newW, newH;
|
||||
const float srcRatio = boundsRect.getHeight() / boundsRect.getWidth();
|
||||
auto srcRatio = boundsRect.getHeight() / boundsRect.getWidth();
|
||||
|
||||
if (srcRatio > h / w)
|
||||
{
|
||||
|
|
@ -998,8 +999,8 @@ AffineTransform Path::getTransformToScaleToFit (const float x, const float y,
|
|||
newH = w * srcRatio;
|
||||
}
|
||||
|
||||
float newXCentre = x;
|
||||
float newYCentre = y;
|
||||
auto newXCentre = x;
|
||||
auto newYCentre = y;
|
||||
|
||||
if (justification.testFlags (Justification::left)) newXCentre += newW * 0.5f;
|
||||
else if (justification.testFlags (Justification::right)) newXCentre += w - newW * 0.5f;
|
||||
|
|
@ -1040,7 +1041,7 @@ bool Path::contains (const float x, const float y, const float tolerance) const
|
|||
{
|
||||
if ((i.y1 <= y && i.y2 > y) || (i.y2 <= y && i.y1 > y))
|
||||
{
|
||||
const float intersectX = i.x1 + (i.x2 - i.x1) * (y - i.y1) / (i.y2 - i.y1);
|
||||
auto intersectX = i.x1 + (i.x2 - i.x1) * (y - i.y1) / (i.y2 - i.y1);
|
||||
|
||||
if (intersectX <= x)
|
||||
{
|
||||
|
|
@ -1091,7 +1092,7 @@ Line<float> Path::getClippedLine (Line<float> line, const bool keepSectionOutsid
|
|||
|
||||
while (i.next())
|
||||
{
|
||||
if (line.intersects (Line<float> (i.x1, i.y1, i.x2, i.y2), intersection))
|
||||
if (line.intersects ({ i.x1, i.y1, i.x2, i.y2 }, intersection))
|
||||
{
|
||||
if ((startInside && keepSectionOutsidePath) || (endInside && ! keepSectionOutsidePath))
|
||||
result.setStart (intersection);
|
||||
|
|
@ -1124,7 +1125,7 @@ Point<float> Path::getPointAlongPath (float distanceFromStart,
|
|||
while (i.next())
|
||||
{
|
||||
const Line<float> line (i.x1, i.y1, i.x2, i.y2);
|
||||
const float lineLength = line.getLength();
|
||||
auto lineLength = line.getLength();
|
||||
|
||||
if (distanceFromStart <= lineLength)
|
||||
return line.getPointAlongLine (distanceFromStart);
|
||||
|
|
@ -1132,7 +1133,7 @@ Point<float> Path::getPointAlongPath (float distanceFromStart,
|
|||
distanceFromStart -= lineLength;
|
||||
}
|
||||
|
||||
return Point<float> (i.x2, i.y2);
|
||||
return { i.x2, i.y2 };
|
||||
}
|
||||
|
||||
float Path::getNearestPoint (const Point<float> targetPoint, Point<float>& pointOnPath,
|
||||
|
|
@ -1147,7 +1148,7 @@ float Path::getNearestPoint (const Point<float> targetPoint, Point<float>& point
|
|||
while (i.next())
|
||||
{
|
||||
const Line<float> line (i.x1, i.y1, i.x2, i.y2);
|
||||
const float distance = line.getDistanceFromPoint (targetPoint, pointOnLine);
|
||||
auto distance = line.getDistanceFromPoint (targetPoint, pointOnLine);
|
||||
|
||||
if (distance < bestDistance)
|
||||
{
|
||||
|
|
@ -1168,30 +1169,30 @@ Path Path::createPathWithRoundedCorners (const float cornerRadius) const
|
|||
if (cornerRadius <= 0.01f)
|
||||
return *this;
|
||||
|
||||
Path p;
|
||||
size_t indexOfPathStart = 0, indexOfPathStartThis = 0;
|
||||
size_t n = 0;
|
||||
bool lastWasLine = false, firstWasLine = false;
|
||||
Path p;
|
||||
|
||||
while (n < numElements)
|
||||
{
|
||||
const float type = data.elements [n++];
|
||||
auto type = data.elements[n++];
|
||||
|
||||
if (type == moveMarker)
|
||||
if (isMarker (type, moveMarker))
|
||||
{
|
||||
indexOfPathStart = p.numElements;
|
||||
indexOfPathStartThis = n - 1;
|
||||
const float x = data.elements [n++];
|
||||
const float y = data.elements [n++];
|
||||
auto x = data.elements[n++];
|
||||
auto y = data.elements[n++];
|
||||
p.startNewSubPath (x, y);
|
||||
lastWasLine = false;
|
||||
firstWasLine = (data.elements [n] == lineMarker);
|
||||
firstWasLine = (isMarker (data.elements[n], lineMarker));
|
||||
}
|
||||
else if (type == lineMarker || type == closeSubPathMarker)
|
||||
else if (isMarker (type, lineMarker) || isMarker (type, closeSubPathMarker))
|
||||
{
|
||||
float startX = 0, startY = 0, joinX = 0, joinY = 0, endX, endY;
|
||||
|
||||
if (type == lineMarker)
|
||||
if (isMarker (type, lineMarker))
|
||||
{
|
||||
endX = data.elements[n++];
|
||||
endY = data.elements[n++];
|
||||
|
|
@ -1220,21 +1221,21 @@ Path Path::createPathWithRoundedCorners (const float cornerRadius) const
|
|||
|
||||
if (lastWasLine)
|
||||
{
|
||||
const double len1 = PathHelpers::lengthOf (startX, startY, joinX, joinY);
|
||||
auto len1 = PathHelpers::lengthOf (startX, startY, joinX, joinY);
|
||||
|
||||
if (len1 > 0)
|
||||
{
|
||||
const double propNeeded = jmin (0.5, cornerRadius / len1);
|
||||
auto propNeeded = jmin (0.5, cornerRadius / len1);
|
||||
|
||||
p.data.elements[p.numElements - 2] = (float) (joinX - (joinX - startX) * propNeeded);
|
||||
p.data.elements[p.numElements - 1] = (float) (joinY - (joinY - startY) * propNeeded);
|
||||
}
|
||||
|
||||
const double len2 = PathHelpers::lengthOf (endX, endY, joinX, joinY);
|
||||
auto len2 = PathHelpers::lengthOf (endX, endY, joinX, joinY);
|
||||
|
||||
if (len2 > 0)
|
||||
{
|
||||
const double propNeeded = jmin (0.5, cornerRadius / len2);
|
||||
auto propNeeded = jmin (0.5, cornerRadius / len2);
|
||||
|
||||
p.quadraticTo (joinX, joinY,
|
||||
(float) (joinX + (endX - joinX) * propNeeded),
|
||||
|
|
@ -1243,13 +1244,13 @@ Path Path::createPathWithRoundedCorners (const float cornerRadius) const
|
|||
|
||||
p.lineTo (endX, endY);
|
||||
}
|
||||
else if (type == lineMarker)
|
||||
else if (isMarker (type, lineMarker))
|
||||
{
|
||||
p.lineTo (endX, endY);
|
||||
lastWasLine = true;
|
||||
}
|
||||
|
||||
if (type == closeSubPathMarker)
|
||||
if (isMarker (type, closeSubPathMarker))
|
||||
{
|
||||
if (firstWasLine)
|
||||
{
|
||||
|
|
@ -1260,21 +1261,21 @@ Path Path::createPathWithRoundedCorners (const float cornerRadius) const
|
|||
endX = data.elements[indexOfPathStartThis + 4];
|
||||
endY = data.elements[indexOfPathStartThis + 5];
|
||||
|
||||
const double len1 = PathHelpers::lengthOf (startX, startY, joinX, joinY);
|
||||
auto len1 = PathHelpers::lengthOf (startX, startY, joinX, joinY);
|
||||
|
||||
if (len1 > 0)
|
||||
{
|
||||
const double propNeeded = jmin (0.5, cornerRadius / len1);
|
||||
auto propNeeded = jmin (0.5, cornerRadius / len1);
|
||||
|
||||
p.data.elements[p.numElements - 2] = (float) (joinX - (joinX - startX) * propNeeded);
|
||||
p.data.elements[p.numElements - 1] = (float) (joinY - (joinY - startY) * propNeeded);
|
||||
}
|
||||
|
||||
const double len2 = PathHelpers::lengthOf (endX, endY, joinX, joinY);
|
||||
auto len2 = PathHelpers::lengthOf (endX, endY, joinX, joinY);
|
||||
|
||||
if (len2 > 0)
|
||||
{
|
||||
const double propNeeded = jmin (0.5, cornerRadius / len2);
|
||||
auto propNeeded = jmin (0.5, cornerRadius / len2);
|
||||
|
||||
endX = (float) (joinX + (endX - joinX) * propNeeded);
|
||||
endY = (float) (joinY + (endY - joinY) * propNeeded);
|
||||
|
|
@ -1289,24 +1290,24 @@ Path Path::createPathWithRoundedCorners (const float cornerRadius) const
|
|||
p.closeSubPath();
|
||||
}
|
||||
}
|
||||
else if (type == quadMarker)
|
||||
else if (isMarker (type, quadMarker))
|
||||
{
|
||||
lastWasLine = false;
|
||||
const float x1 = data.elements [n++];
|
||||
const float y1 = data.elements [n++];
|
||||
const float x2 = data.elements [n++];
|
||||
const float y2 = data.elements [n++];
|
||||
auto x1 = data.elements[n++];
|
||||
auto y1 = data.elements[n++];
|
||||
auto x2 = data.elements[n++];
|
||||
auto y2 = data.elements[n++];
|
||||
p.quadraticTo (x1, y1, x2, y2);
|
||||
}
|
||||
else if (type == cubicMarker)
|
||||
else if (isMarker (type, cubicMarker))
|
||||
{
|
||||
lastWasLine = false;
|
||||
const float x1 = data.elements [n++];
|
||||
const float y1 = data.elements [n++];
|
||||
const float x2 = data.elements [n++];
|
||||
const float y2 = data.elements [n++];
|
||||
const float x3 = data.elements [n++];
|
||||
const float y3 = data.elements [n++];
|
||||
auto x1 = data.elements[n++];
|
||||
auto y1 = data.elements[n++];
|
||||
auto x2 = data.elements[n++];
|
||||
auto y2 = data.elements[n++];
|
||||
auto x3 = data.elements[n++];
|
||||
auto y3 = data.elements[n++];
|
||||
p.cubicTo (x1, y1, x2, y2, x3, y3);
|
||||
}
|
||||
}
|
||||
|
|
@ -1323,38 +1324,38 @@ void Path::loadPathFromStream (InputStream& source)
|
|||
{
|
||||
case 'm':
|
||||
{
|
||||
const float x = source.readFloat();
|
||||
const float y = source.readFloat();
|
||||
auto x = source.readFloat();
|
||||
auto y = source.readFloat();
|
||||
startNewSubPath (x, y);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'l':
|
||||
{
|
||||
const float x = source.readFloat();
|
||||
const float y = source.readFloat();
|
||||
auto x = source.readFloat();
|
||||
auto y = source.readFloat();
|
||||
lineTo (x, y);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'q':
|
||||
{
|
||||
const float x1 = source.readFloat();
|
||||
const float y1 = source.readFloat();
|
||||
const float x2 = source.readFloat();
|
||||
const float y2 = source.readFloat();
|
||||
auto x1 = source.readFloat();
|
||||
auto y1 = source.readFloat();
|
||||
auto x2 = source.readFloat();
|
||||
auto y2 = source.readFloat();
|
||||
quadraticTo (x1, y1, x2, y2);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'b':
|
||||
{
|
||||
const float x1 = source.readFloat();
|
||||
const float y1 = source.readFloat();
|
||||
const float x2 = source.readFloat();
|
||||
const float y2 = source.readFloat();
|
||||
const float x3 = source.readFloat();
|
||||
const float y3 = source.readFloat();
|
||||
auto x1 = source.readFloat();
|
||||
auto y1 = source.readFloat();
|
||||
auto x2 = source.readFloat();
|
||||
auto y2 = source.readFloat();
|
||||
auto x3 = source.readFloat();
|
||||
auto y3 = source.readFloat();
|
||||
cubicTo (x1, y1, x2, y2, x3, y3);
|
||||
break;
|
||||
}
|
||||
|
|
@ -1391,24 +1392,23 @@ void Path::writePathToStream (OutputStream& dest) const
|
|||
{
|
||||
dest.writeByte (useNonZeroWinding ? 'n' : 'z');
|
||||
|
||||
size_t i = 0;
|
||||
while (i < numElements)
|
||||
for (size_t i = 0; i < numElements;)
|
||||
{
|
||||
const float type = data.elements [i++];
|
||||
auto type = data.elements[i++];
|
||||
|
||||
if (type == moveMarker)
|
||||
if (isMarker (type, moveMarker))
|
||||
{
|
||||
dest.writeByte ('m');
|
||||
dest.writeFloat (data.elements[i++]);
|
||||
dest.writeFloat (data.elements[i++]);
|
||||
}
|
||||
else if (type == lineMarker)
|
||||
else if (isMarker (type, lineMarker))
|
||||
{
|
||||
dest.writeByte ('l');
|
||||
dest.writeFloat (data.elements[i++]);
|
||||
dest.writeFloat (data.elements[i++]);
|
||||
}
|
||||
else if (type == quadMarker)
|
||||
else if (isMarker (type, quadMarker))
|
||||
{
|
||||
dest.writeByte ('q');
|
||||
dest.writeFloat (data.elements[i++]);
|
||||
|
|
@ -1416,7 +1416,7 @@ void Path::writePathToStream (OutputStream& dest) const
|
|||
dest.writeFloat (data.elements[i++]);
|
||||
dest.writeFloat (data.elements[i++]);
|
||||
}
|
||||
else if (type == cubicMarker)
|
||||
else if (isMarker (type, cubicMarker))
|
||||
{
|
||||
dest.writeByte ('b');
|
||||
dest.writeFloat (data.elements[i++]);
|
||||
|
|
@ -1426,7 +1426,7 @@ void Path::writePathToStream (OutputStream& dest) const
|
|||
dest.writeFloat (data.elements[i++]);
|
||||
dest.writeFloat (data.elements[i++]);
|
||||
}
|
||||
else if (type == closeSubPathMarker)
|
||||
else if (isMarker (type, closeSubPathMarker))
|
||||
{
|
||||
dest.writeByte ('c');
|
||||
}
|
||||
|
|
@ -1446,43 +1446,43 @@ String Path::toString() const
|
|||
|
||||
while (i < numElements)
|
||||
{
|
||||
const float marker = data.elements [i++];
|
||||
auto type = data.elements[i++];
|
||||
char markerChar = 0;
|
||||
int numCoords = 0;
|
||||
|
||||
if (marker == moveMarker)
|
||||
if (isMarker (type, moveMarker))
|
||||
{
|
||||
markerChar = 'm';
|
||||
numCoords = 2;
|
||||
}
|
||||
else if (marker == lineMarker)
|
||||
else if (isMarker (type, lineMarker))
|
||||
{
|
||||
markerChar = 'l';
|
||||
numCoords = 2;
|
||||
}
|
||||
else if (marker == quadMarker)
|
||||
else if (isMarker (type, quadMarker))
|
||||
{
|
||||
markerChar = 'q';
|
||||
numCoords = 4;
|
||||
}
|
||||
else if (marker == cubicMarker)
|
||||
else if (isMarker (type, cubicMarker))
|
||||
{
|
||||
markerChar = 'c';
|
||||
numCoords = 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
jassert (marker == closeSubPathMarker);
|
||||
jassert (isMarker (type, closeSubPathMarker));
|
||||
markerChar = 'z';
|
||||
}
|
||||
|
||||
if (marker != lastMarker)
|
||||
if (! isMarker (type, lastMarker))
|
||||
{
|
||||
if (s.getDataSize() != 0)
|
||||
s << ' ';
|
||||
|
||||
s << markerChar;
|
||||
lastMarker = marker;
|
||||
lastMarker = type;
|
||||
}
|
||||
|
||||
while (--numCoords >= 0 && i < numElements)
|
||||
|
|
@ -1510,15 +1510,15 @@ void Path::restoreFromString (StringRef stringVersion)
|
|||
clear();
|
||||
setUsingNonZeroWinding (true);
|
||||
|
||||
String::CharPointerType t (stringVersion.text);
|
||||
auto t = stringVersion.text;
|
||||
juce_wchar marker = 'm';
|
||||
int numValues = 2;
|
||||
float values[6];
|
||||
|
||||
for (;;)
|
||||
{
|
||||
const String token (PathHelpers::nextToken (t));
|
||||
const juce_wchar firstChar = token[0];
|
||||
auto token = PathHelpers::nextToken (t);
|
||||
auto firstChar = token[0];
|
||||
int startNum = 0;
|
||||
|
||||
if (firstChar == 0)
|
||||
|
|
@ -1572,9 +1572,7 @@ void Path::restoreFromString (StringRef stringVersion)
|
|||
|
||||
//==============================================================================
|
||||
Path::Iterator::Iterator (const Path& p) noexcept
|
||||
: elementType (startNewSubPath),
|
||||
x1 (0), y1 (0), x2 (0), y2 (0), x3 (0), y3 (0),
|
||||
path (p), index (0)
|
||||
: elementType (startNewSubPath), path (p)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -1584,25 +1582,25 @@ Path::Iterator::~Iterator() noexcept
|
|||
|
||||
bool Path::Iterator::next() noexcept
|
||||
{
|
||||
const float* const elements = path.data.elements;
|
||||
const float* elements = path.data.elements;
|
||||
|
||||
if (index < path.numElements)
|
||||
{
|
||||
const float type = elements [index++];
|
||||
auto type = elements[index++];
|
||||
|
||||
if (type == moveMarker)
|
||||
if (isMarker (type, moveMarker))
|
||||
{
|
||||
elementType = startNewSubPath;
|
||||
x1 = elements[index++];
|
||||
y1 = elements[index++];
|
||||
}
|
||||
else if (type == lineMarker)
|
||||
else if (isMarker (type, lineMarker))
|
||||
{
|
||||
elementType = lineTo;
|
||||
x1 = elements[index++];
|
||||
y1 = elements[index++];
|
||||
}
|
||||
else if (type == quadMarker)
|
||||
else if (isMarker (type, quadMarker))
|
||||
{
|
||||
elementType = quadraticTo;
|
||||
x1 = elements[index++];
|
||||
|
|
@ -1610,7 +1608,7 @@ bool Path::Iterator::next() noexcept
|
|||
x2 = elements[index++];
|
||||
y2 = elements[index++];
|
||||
}
|
||||
else if (type == cubicMarker)
|
||||
else if (isMarker (type, cubicMarker))
|
||||
{
|
||||
elementType = cubicTo;
|
||||
x1 = elements[index++];
|
||||
|
|
@ -1620,7 +1618,7 @@ bool Path::Iterator::next() noexcept
|
|||
x3 = elements[index++];
|
||||
y3 = elements[index++];
|
||||
}
|
||||
else if (type == closeSubPathMarker)
|
||||
else if (isMarker (type, closeSubPathMarker))
|
||||
{
|
||||
elementType = closePath;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -746,12 +746,12 @@ public:
|
|||
|
||||
PathElementType elementType;
|
||||
|
||||
float x1, y1, x2, y2, x3, y3;
|
||||
float x1 = 0, y1 = 0, x2 = 0, y2 = 0, x3 = 0, y3 = 0;
|
||||
|
||||
//==============================================================================
|
||||
private:
|
||||
const Path& path;
|
||||
size_t index;
|
||||
size_t index = 0;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE (Iterator)
|
||||
};
|
||||
|
|
@ -802,7 +802,7 @@ private:
|
|||
friend class PathFlatteningIterator;
|
||||
friend class Path::Iterator;
|
||||
ArrayAllocationBase<float, DummyCriticalSection> data;
|
||||
size_t numElements;
|
||||
size_t numElements = 0;
|
||||
|
||||
struct PathBounds
|
||||
{
|
||||
|
|
@ -813,11 +813,11 @@ private:
|
|||
void extend (float, float) noexcept;
|
||||
void extend (float, float, float, float) noexcept;
|
||||
|
||||
float pathXMin, pathXMax, pathYMin, pathYMax;
|
||||
float pathXMin = 0, pathXMax = 0, pathYMin = 0, pathYMax = 0;
|
||||
};
|
||||
|
||||
PathBounds bounds;
|
||||
bool useNonZeroWinding;
|
||||
bool useNonZeroWinding = true;
|
||||
|
||||
static const float lineMarker;
|
||||
static const float moveMarker;
|
||||
|
|
|
|||
|
|
@ -38,12 +38,7 @@ PathFlatteningIterator::PathFlatteningIterator (const Path& path_,
|
|||
transform (transform_),
|
||||
points (path_.data.elements),
|
||||
toleranceSquared (tolerance * tolerance),
|
||||
subPathCloseX (0),
|
||||
subPathCloseY (0),
|
||||
isIdentityTransform (transform_.isIdentity()),
|
||||
stackBase (32),
|
||||
index (0),
|
||||
stackSize (32)
|
||||
isIdentityTransform (transform_.isIdentity())
|
||||
{
|
||||
stackPos = stackBase;
|
||||
}
|
||||
|
|
@ -55,7 +50,7 @@ PathFlatteningIterator::~PathFlatteningIterator()
|
|||
bool PathFlatteningIterator::isLastInSubpath() const noexcept
|
||||
{
|
||||
return stackPos == stackBase.getData()
|
||||
&& (index >= path.numElements || points [index] == Path::moveMarker);
|
||||
&& (index >= path.numElements || isMarker (points[index], Path::moveMarker));
|
||||
}
|
||||
|
||||
bool PathFlatteningIterator::next()
|
||||
|
|
@ -79,12 +74,12 @@ bool PathFlatteningIterator::next()
|
|||
|
||||
type = points [index++];
|
||||
|
||||
if (type != Path::closeSubPathMarker)
|
||||
if (! isMarker (type, Path::closeSubPathMarker))
|
||||
{
|
||||
x2 = points [index++];
|
||||
y2 = points [index++];
|
||||
|
||||
if (type == Path::quadMarker)
|
||||
if (isMarker (type, Path::quadMarker))
|
||||
{
|
||||
x3 = points [index++];
|
||||
y3 = points [index++];
|
||||
|
|
@ -92,7 +87,7 @@ bool PathFlatteningIterator::next()
|
|||
if (! isIdentityTransform)
|
||||
transform.transformPoints (x2, y2, x3, y3);
|
||||
}
|
||||
else if (type == Path::cubicMarker)
|
||||
else if (isMarker (type, Path::cubicMarker))
|
||||
{
|
||||
x3 = points [index++];
|
||||
y3 = points [index++];
|
||||
|
|
@ -113,17 +108,17 @@ bool PathFlatteningIterator::next()
|
|||
{
|
||||
type = *--stackPos;
|
||||
|
||||
if (type != Path::closeSubPathMarker)
|
||||
if (! isMarker (type, Path::closeSubPathMarker))
|
||||
{
|
||||
x2 = *--stackPos;
|
||||
y2 = *--stackPos;
|
||||
|
||||
if (type == Path::quadMarker)
|
||||
if (isMarker (type, Path::quadMarker))
|
||||
{
|
||||
x3 = *--stackPos;
|
||||
y3 = *--stackPos;
|
||||
}
|
||||
else if (type == Path::cubicMarker)
|
||||
else if (isMarker (type, Path::cubicMarker))
|
||||
{
|
||||
x3 = *--stackPos;
|
||||
y3 = *--stackPos;
|
||||
|
|
@ -133,7 +128,7 @@ bool PathFlatteningIterator::next()
|
|||
}
|
||||
}
|
||||
|
||||
if (type == Path::lineMarker)
|
||||
if (isMarker (type, Path::lineMarker))
|
||||
{
|
||||
++subPathIndex;
|
||||
|
||||
|
|
@ -146,7 +141,7 @@ bool PathFlatteningIterator::next()
|
|||
return true;
|
||||
}
|
||||
|
||||
if (type == Path::quadMarker)
|
||||
if (isMarker (type, Path::quadMarker))
|
||||
{
|
||||
const size_t offset = (size_t) (stackPos - stackBase);
|
||||
|
||||
|
|
@ -157,15 +152,15 @@ bool PathFlatteningIterator::next()
|
|||
stackPos = stackBase + offset;
|
||||
}
|
||||
|
||||
const float m1x = (x1 + x2) * 0.5f;
|
||||
const float m1y = (y1 + y2) * 0.5f;
|
||||
const float m2x = (x2 + x3) * 0.5f;
|
||||
const float m2y = (y2 + y3) * 0.5f;
|
||||
const float m3x = (m1x + m2x) * 0.5f;
|
||||
const float m3y = (m1y + m2y) * 0.5f;
|
||||
auto m1x = (x1 + x2) * 0.5f;
|
||||
auto m1y = (y1 + y2) * 0.5f;
|
||||
auto m2x = (x2 + x3) * 0.5f;
|
||||
auto m2y = (y2 + y3) * 0.5f;
|
||||
auto m3x = (m1x + m2x) * 0.5f;
|
||||
auto m3y = (m1y + m2y) * 0.5f;
|
||||
|
||||
const float errorX = m3x - x2;
|
||||
const float errorY = m3y - y2;
|
||||
auto errorX = m3x - x2;
|
||||
auto errorY = m3y - y2;
|
||||
|
||||
if (errorX * errorX + errorY * errorY > toleranceSquared)
|
||||
{
|
||||
|
|
@ -194,7 +189,7 @@ bool PathFlatteningIterator::next()
|
|||
|
||||
jassert (stackPos < stackBase + stackSize);
|
||||
}
|
||||
else if (type == Path::cubicMarker)
|
||||
else if (isMarker (type, Path::cubicMarker))
|
||||
{
|
||||
const size_t offset = (size_t) (stackPos - stackBase);
|
||||
|
||||
|
|
@ -205,21 +200,21 @@ bool PathFlatteningIterator::next()
|
|||
stackPos = stackBase + offset;
|
||||
}
|
||||
|
||||
const float m1x = (x1 + x2) * 0.5f;
|
||||
const float m1y = (y1 + y2) * 0.5f;
|
||||
const float m2x = (x3 + x2) * 0.5f;
|
||||
const float m2y = (y3 + y2) * 0.5f;
|
||||
const float m3x = (x3 + x4) * 0.5f;
|
||||
const float m3y = (y3 + y4) * 0.5f;
|
||||
const float m4x = (m1x + m2x) * 0.5f;
|
||||
const float m4y = (m1y + m2y) * 0.5f;
|
||||
const float m5x = (m3x + m2x) * 0.5f;
|
||||
const float m5y = (m3y + m2y) * 0.5f;
|
||||
auto m1x = (x1 + x2) * 0.5f;
|
||||
auto m1y = (y1 + y2) * 0.5f;
|
||||
auto m2x = (x3 + x2) * 0.5f;
|
||||
auto m2y = (y3 + y2) * 0.5f;
|
||||
auto m3x = (x3 + x4) * 0.5f;
|
||||
auto m3y = (y3 + y4) * 0.5f;
|
||||
auto m4x = (m1x + m2x) * 0.5f;
|
||||
auto m4y = (m1y + m2y) * 0.5f;
|
||||
auto m5x = (m3x + m2x) * 0.5f;
|
||||
auto m5y = (m3y + m2y) * 0.5f;
|
||||
|
||||
const float error1X = m4x - x2;
|
||||
const float error1Y = m4y - y2;
|
||||
const float error2X = m5x - x3;
|
||||
const float error2Y = m5y - y3;
|
||||
auto error1X = m4x - x2;
|
||||
auto error1Y = m4y - y2;
|
||||
auto error2X = m5x - x3;
|
||||
auto error2Y = m5y - y3;
|
||||
|
||||
if (error1X * error1X + error1Y * error1Y > toleranceSquared
|
||||
|| error2X * error2X + error2Y * error2Y > toleranceSquared)
|
||||
|
|
@ -255,7 +250,7 @@ bool PathFlatteningIterator::next()
|
|||
*stackPos++ = Path::lineMarker;
|
||||
}
|
||||
}
|
||||
else if (type == Path::closeSubPathMarker)
|
||||
else if (isMarker (type, Path::closeSubPathMarker))
|
||||
{
|
||||
if (x2 != subPathCloseX || y2 != subPathCloseY)
|
||||
{
|
||||
|
|
@ -270,7 +265,7 @@ bool PathFlatteningIterator::next()
|
|||
}
|
||||
else
|
||||
{
|
||||
jassert (type == Path::moveMarker);
|
||||
jassert (isMarker (type, Path::moveMarker));
|
||||
|
||||
subPathIndex = -1;
|
||||
subPathCloseX = x1 = x2;
|
||||
|
|
|
|||
|
|
@ -95,12 +95,12 @@ private:
|
|||
const AffineTransform transform;
|
||||
float* points;
|
||||
const float toleranceSquared;
|
||||
float subPathCloseX, subPathCloseY;
|
||||
float subPathCloseX = 0, subPathCloseY = 0;
|
||||
const bool isIdentityTransform;
|
||||
|
||||
HeapBlock<float> stackBase;
|
||||
HeapBlock<float> stackBase { 32 };
|
||||
float* stackPos;
|
||||
size_t index, stackSize;
|
||||
size_t index = 0, stackSize = 32;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PathFlatteningIterator)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -76,19 +76,19 @@ namespace PathStrokeHelpers
|
|||
{
|
||||
if (x2 != x3 || y2 != y3)
|
||||
{
|
||||
const float dx1 = x2 - x1;
|
||||
const float dy1 = y2 - y1;
|
||||
const float dx2 = x4 - x3;
|
||||
const float dy2 = y4 - y3;
|
||||
const float divisor = dx1 * dy2 - dx2 * dy1;
|
||||
auto dx1 = x2 - x1;
|
||||
auto dy1 = y2 - y1;
|
||||
auto dx2 = x4 - x3;
|
||||
auto dy2 = y4 - y3;
|
||||
auto divisor = dx1 * dy2 - dx2 * dy1;
|
||||
|
||||
if (divisor == 0)
|
||||
if (divisor == 0.0f)
|
||||
{
|
||||
if (! ((dx1 == 0 && dy1 == 0) || (dx2 == 0 && dy2 == 0)))
|
||||
if (! ((dx1 == 0.0f && dy1 == 0.0f) || (dx2 == 0.0f && dy2 == 0.0f)))
|
||||
{
|
||||
if (dy1 == 0 && dy2 != 0)
|
||||
if (dy1 == 0.0f && dy2 != 0.0f)
|
||||
{
|
||||
const float along = (y1 - y3) / dy2;
|
||||
auto along = (y1 - y3) / dy2;
|
||||
intersectionX = x3 + along * dx2;
|
||||
intersectionY = y1;
|
||||
|
||||
|
|
@ -100,9 +100,9 @@ namespace PathStrokeHelpers
|
|||
return along >= 0 && along <= 1.0f;
|
||||
}
|
||||
|
||||
if (dy2 == 0 && dy1 != 0)
|
||||
if (dy2 == 0.0f && dy1 != 0.0f)
|
||||
{
|
||||
const float along = (y3 - y1) / dy1;
|
||||
auto along = (y3 - y1) / dy1;
|
||||
intersectionX = x1 + along * dx1;
|
||||
intersectionY = y3;
|
||||
|
||||
|
|
@ -114,9 +114,9 @@ namespace PathStrokeHelpers
|
|||
return along >= 0 && along <= 1.0f;
|
||||
}
|
||||
|
||||
if (dx1 == 0 && dx2 != 0)
|
||||
if (dx1 == 0.0f && dx2 != 0.0f)
|
||||
{
|
||||
const float along = (x1 - x3) / dx2;
|
||||
auto along = (x1 - x3) / dx2;
|
||||
intersectionX = x1;
|
||||
intersectionY = y3 + along * dy2;
|
||||
|
||||
|
|
@ -129,9 +129,9 @@ namespace PathStrokeHelpers
|
|||
return along >= 0 && along <= 1.0f;
|
||||
}
|
||||
|
||||
if (dx2 == 0 && dx1 != 0)
|
||||
if (dx2 == 0.0f && dx1 != 0.0f)
|
||||
{
|
||||
const float along = (x3 - x1) / dx1;
|
||||
auto along = (x3 - x1) / dx1;
|
||||
intersectionX = x3;
|
||||
intersectionY = y1 + along * dy1;
|
||||
|
||||
|
|
@ -151,14 +151,14 @@ namespace PathStrokeHelpers
|
|||
return false;
|
||||
}
|
||||
|
||||
const float along1 = ((y1 - y3) * dx2 - (x1 - x3) * dy2) / divisor;
|
||||
auto along1 = ((y1 - y3) * dx2 - (x1 - x3) * dy2) / divisor;
|
||||
|
||||
intersectionX = x1 + along1 * dx1;
|
||||
intersectionY = y1 + along1 * dy1;
|
||||
|
||||
if (along1 >= 0 && along1 <= 1.0f)
|
||||
{
|
||||
const float along2 = ((y1 - y3) * dx1 - (x1 - x3) * dy1) / divisor;
|
||||
auto along2 = ((y1 - y3) * dx1 - (x1 - x3) * dy1) / divisor;
|
||||
|
||||
if (along2 >= 0 && along2 <= 1.0f)
|
||||
{
|
||||
|
|
@ -293,18 +293,18 @@ namespace PathStrokeHelpers
|
|||
{
|
||||
float offx1, offy1, offx2, offy2;
|
||||
|
||||
float dx = x2 - x1;
|
||||
float dy = y2 - y1;
|
||||
const float len = juce_hypot (dx, dy);
|
||||
auto dx = x2 - x1;
|
||||
auto dy = y2 - y1;
|
||||
auto len = juce_hypot (dx, dy);
|
||||
|
||||
if (len == 0)
|
||||
if (len == 0.0f)
|
||||
{
|
||||
offx1 = offx2 = x1;
|
||||
offy1 = offy2 = y1;
|
||||
}
|
||||
else
|
||||
{
|
||||
const float offset = width / len;
|
||||
auto offset = width / len;
|
||||
dx *= offset;
|
||||
dy *= offset;
|
||||
|
||||
|
|
@ -324,8 +324,8 @@ namespace PathStrokeHelpers
|
|||
else
|
||||
{
|
||||
// rounded ends
|
||||
const float midx = (offx1 + offx2) * 0.5f;
|
||||
const float midy = (offy1 + offy2) * 0.5f;
|
||||
auto midx = (offx1 + offx2) * 0.5f;
|
||||
auto midy = (offy1 + offy2) * 0.5f;
|
||||
|
||||
destPath.cubicTo (x1 + (offx1 - x1) * 0.55f, y1 + (offy1 - y1) * 0.55f,
|
||||
offx1 + (midx - offx1) * 0.45f, offy1 + (midy - offy1) * 0.45f,
|
||||
|
|
@ -369,10 +369,10 @@ namespace PathStrokeHelpers
|
|||
{
|
||||
while (amountAtEnd > 0 && subPath.size() > 0)
|
||||
{
|
||||
LineSection& l = subPath.getReference (subPath.size() - 1);
|
||||
float dx = l.rx2 - l.rx1;
|
||||
float dy = l.ry2 - l.ry1;
|
||||
const float len = juce_hypot (dx, dy);
|
||||
auto& l = subPath.getReference (subPath.size() - 1);
|
||||
auto dx = l.rx2 - l.rx1;
|
||||
auto dy = l.ry2 - l.ry1;
|
||||
auto len = juce_hypot (dx, dy);
|
||||
|
||||
if (len <= amountAtEnd && subPath.size() > 1)
|
||||
{
|
||||
|
|
@ -384,7 +384,7 @@ namespace PathStrokeHelpers
|
|||
}
|
||||
else
|
||||
{
|
||||
const float prop = jmin (0.9999f, amountAtEnd / len);
|
||||
auto prop = jmin (0.9999f, amountAtEnd / len);
|
||||
dx *= prop;
|
||||
dy *= prop;
|
||||
l.rx1 += dx;
|
||||
|
|
@ -397,10 +397,10 @@ namespace PathStrokeHelpers
|
|||
|
||||
while (amountAtStart > 0 && subPath.size() > 0)
|
||||
{
|
||||
LineSection& l = subPath.getReference (0);
|
||||
float dx = l.rx2 - l.rx1;
|
||||
float dy = l.ry2 - l.ry1;
|
||||
const float len = juce_hypot (dx, dy);
|
||||
auto& l = subPath.getReference (0);
|
||||
auto dx = l.rx2 - l.rx1;
|
||||
auto dy = l.ry2 - l.ry1;
|
||||
auto len = juce_hypot (dx, dy);
|
||||
|
||||
if (len <= amountAtStart && subPath.size() > 1)
|
||||
{
|
||||
|
|
@ -412,7 +412,7 @@ namespace PathStrokeHelpers
|
|||
}
|
||||
else
|
||||
{
|
||||
const float prop = jmin (0.9999f, amountAtStart / len);
|
||||
auto prop = jmin (0.9999f, amountAtStart / len);
|
||||
dx *= prop;
|
||||
dy *= prop;
|
||||
l.rx2 -= dx;
|
||||
|
|
@ -434,12 +434,12 @@ namespace PathStrokeHelpers
|
|||
if (arrowhead != nullptr)
|
||||
shortenSubPath (subPath, arrowhead->startLength, arrowhead->endLength);
|
||||
|
||||
const LineSection& firstLine = subPath.getReference (0);
|
||||
auto& firstLine = subPath.getReference (0);
|
||||
|
||||
float lastX1 = firstLine.lx1;
|
||||
float lastY1 = firstLine.ly1;
|
||||
float lastX2 = firstLine.lx2;
|
||||
float lastY2 = firstLine.ly2;
|
||||
auto lastX1 = firstLine.lx1;
|
||||
auto lastY1 = firstLine.ly1;
|
||||
auto lastX2 = firstLine.lx2;
|
||||
auto lastY2 = firstLine.ly2;
|
||||
|
||||
if (isClosed)
|
||||
{
|
||||
|
|
@ -472,11 +472,11 @@ namespace PathStrokeHelpers
|
|||
lastY2 = l.ly2;
|
||||
}
|
||||
|
||||
const LineSection& lastLine = subPath.getReference (subPath.size() - 1);
|
||||
auto& lastLine = subPath.getReference (subPath.size() - 1);
|
||||
|
||||
if (isClosed)
|
||||
{
|
||||
const LineSection& l = subPath.getReference (0);
|
||||
auto& l = subPath.getReference (0);
|
||||
|
||||
addEdgeAndJoint (destPath, jointStyle,
|
||||
maxMiterExtensionSquared, width,
|
||||
|
|
@ -505,7 +505,7 @@ namespace PathStrokeHelpers
|
|||
|
||||
for (int i = subPath.size() - 1; --i >= 0;)
|
||||
{
|
||||
const LineSection& l = subPath.getReference (i);
|
||||
auto& l = subPath.getReference (i);
|
||||
|
||||
addEdgeAndJoint (destPath, jointStyle,
|
||||
maxMiterExtensionSquared, width,
|
||||
|
|
@ -600,20 +600,20 @@ namespace PathStrokeHelpers
|
|||
float dx = l.x2 - l.x1;
|
||||
float dy = l.y2 - l.y1;
|
||||
|
||||
const float hypotSquared = dx*dx + dy*dy;
|
||||
auto hypotSquared = dx * dx + dy * dy;
|
||||
|
||||
if (it.closesSubPath || hypotSquared > minSegmentLength || it.isLastInSubpath())
|
||||
{
|
||||
const float len = std::sqrt (hypotSquared);
|
||||
auto len = std::sqrt (hypotSquared);
|
||||
|
||||
if (len == 0)
|
||||
if (len == 0.0f)
|
||||
{
|
||||
l.rx1 = l.rx2 = l.lx1 = l.lx2 = l.x1;
|
||||
l.ry1 = l.ry2 = l.ly1 = l.ly2 = l.y1;
|
||||
}
|
||||
else
|
||||
{
|
||||
const float offset = width / len;
|
||||
auto offset = width / len;
|
||||
dx *= offset;
|
||||
dy *= offset;
|
||||
|
||||
|
|
|
|||
|
|
@ -2863,7 +2863,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
|
|||
fp = 0; /* Guarantees termination below. */
|
||||
}
|
||||
|
||||
if (d == 0)
|
||||
if (d == 0.0)
|
||||
{
|
||||
++czero;
|
||||
if (cdigits == 0) ++clead;
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ public:
|
|||
|
||||
complexTransform = getTransformWith (t);
|
||||
isOnlyTranslated = false;
|
||||
isRotated = (complexTransform.mat01 != 0 || complexTransform.mat10 != 0
|
||||
isRotated = (complexTransform.mat01 != 0.0f || complexTransform.mat10 != 0.0f
|
||||
|| complexTransform.mat00 < 0 || complexTransform.mat11 < 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ bool RectanglePlacement::operator!= (const RectanglePlacement& other) const noex
|
|||
void RectanglePlacement::applyTo (double& x, double& y, double& w, double& h,
|
||||
const double dx, const double dy, const double dw, const double dh) const noexcept
|
||||
{
|
||||
if (w == 0 || h == 0)
|
||||
if (w == 0.0 || h == 0.0)
|
||||
return;
|
||||
|
||||
if ((flags & stretchToFit) != 0)
|
||||
|
|
|
|||
|
|
@ -155,8 +155,8 @@ public:
|
|||
}
|
||||
else
|
||||
{
|
||||
if (viewBoxW == 0) newState.viewBoxW = newState.width;
|
||||
if (viewBoxH == 0) newState.viewBoxH = newState.height;
|
||||
if (viewBoxW == 0.0f) newState.viewBoxW = newState.width;
|
||||
if (viewBoxH == 0.0f) newState.viewBoxH = newState.height;
|
||||
}
|
||||
|
||||
newState.parseSubElements (xml, *drawable);
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ namespace AnimatedPositionBehaviours
|
|||
struct ContinuousWithMomentum
|
||||
{
|
||||
ContinuousWithMomentum() noexcept
|
||||
: velocity (0), damping (0.92)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -82,11 +81,11 @@ namespace AnimatedPositionBehaviours
|
|||
*/
|
||||
bool isStopped (double /*position*/) const noexcept
|
||||
{
|
||||
return velocity == 0;
|
||||
return velocity == 0.0;
|
||||
}
|
||||
|
||||
private:
|
||||
double velocity, damping;
|
||||
double velocity = 0, damping = 0.92;
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -588,12 +588,12 @@ private:
|
|||
|
||||
if (positiveFlexibility)
|
||||
{
|
||||
if (totalFlexGrow != 0)
|
||||
if (totalFlexGrow != 0.0)
|
||||
changeUnit = difference / totalFlexGrow;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (totalFlexShrink != 0)
|
||||
if (totalFlexShrink != 0.0)
|
||||
changeUnit = difference / totalFlexShrink;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -489,7 +489,7 @@ void Viewport::mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& whe
|
|||
|
||||
static int rescaleMouseWheelDistance (float distance, int singleStepSize) noexcept
|
||||
{
|
||||
if (distance == 0)
|
||||
if (distance == 0.0f)
|
||||
return 0;
|
||||
|
||||
distance *= 14.0f * singleStepSize;
|
||||
|
|
|
|||
|
|
@ -651,7 +651,7 @@ public:
|
|||
@catch (...)
|
||||
{}
|
||||
|
||||
if (wheel.deltaX == 0 && wheel.deltaY == 0)
|
||||
if (wheel.deltaX == 0.0f && wheel.deltaY == 0.0f)
|
||||
{
|
||||
const float scale = 10.0f / 256.0f;
|
||||
wheel.deltaX = scale * (float) [ev deltaX];
|
||||
|
|
|
|||
|
|
@ -599,13 +599,12 @@ void ComboBox::mouseUp (const MouseEvent& e2)
|
|||
|
||||
void ComboBox::mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& wheel)
|
||||
{
|
||||
if (! menuActive && scrollWheelEnabled && e.eventComponent == this && wheel.deltaY != 0)
|
||||
if (! menuActive && scrollWheelEnabled && e.eventComponent == this && wheel.deltaY != 0.0f)
|
||||
{
|
||||
const int oldPos = (int) mouseWheelAccumulator;
|
||||
auto oldPos = (int) mouseWheelAccumulator;
|
||||
mouseWheelAccumulator += wheel.deltaY * 5.0f;
|
||||
const int delta = oldPos - (int) mouseWheelAccumulator;
|
||||
|
||||
if (delta != 0)
|
||||
if (auto delta = oldPos - (int) mouseWheelAccumulator)
|
||||
nudgeSelectedItem (delta);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -786,13 +786,13 @@ void ListBox::mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& whee
|
|||
{
|
||||
bool eventWasUsed = false;
|
||||
|
||||
if (wheel.deltaX != 0 && viewport->getHorizontalScrollBar()->isVisible())
|
||||
if (wheel.deltaX != 0.0f && viewport->getHorizontalScrollBar()->isVisible())
|
||||
{
|
||||
eventWasUsed = true;
|
||||
viewport->getHorizontalScrollBar()->mouseWheelMove (e, wheel);
|
||||
}
|
||||
|
||||
if (wheel.deltaY != 0 && viewport->getVerticalScrollBar()->isVisible())
|
||||
if (wheel.deltaY != 0.0f && viewport->getVerticalScrollBar()->isVisible())
|
||||
{
|
||||
eventWasUsed = true;
|
||||
viewport->getVerticalScrollBar()->mouseWheelMove (e, wheel);
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ public:
|
|||
// interval setting.
|
||||
numDecimalPlaces = 7;
|
||||
|
||||
if (newInt != 0)
|
||||
if (newInt != 0.0)
|
||||
{
|
||||
int v = std::abs (roundToInt (newInt * 10000000));
|
||||
|
||||
|
|
@ -177,10 +177,10 @@ public:
|
|||
|
||||
if (style == ThreeValueHorizontal || style == ThreeValueVertical)
|
||||
{
|
||||
jassert ((double) valueMin.getValue() <= (double) valueMax.getValue());
|
||||
jassert (static_cast<double> (valueMin.getValue()) <= static_cast<double> (valueMax.getValue()));
|
||||
|
||||
newValue = jlimit ((double) valueMin.getValue(),
|
||||
(double) valueMax.getValue(),
|
||||
newValue = jlimit (static_cast<double> (valueMin.getValue()),
|
||||
static_cast<double> (valueMax.getValue()),
|
||||
newValue);
|
||||
}
|
||||
|
||||
|
|
@ -217,10 +217,10 @@ public:
|
|||
|
||||
if (style == TwoValueHorizontal || style == TwoValueVertical)
|
||||
{
|
||||
if (allowNudgingOfOtherValues && newValue > (double) valueMax.getValue())
|
||||
if (allowNudgingOfOtherValues && newValue > static_cast<double> (valueMax.getValue()))
|
||||
setMaxValue (newValue, notification, false);
|
||||
|
||||
newValue = jmin ((double) valueMax.getValue(), newValue);
|
||||
newValue = jmin (static_cast<double> (valueMax.getValue()), newValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -254,10 +254,10 @@ public:
|
|||
|
||||
if (style == TwoValueHorizontal || style == TwoValueVertical)
|
||||
{
|
||||
if (allowNudgingOfOtherValues && newValue < (double) valueMin.getValue())
|
||||
if (allowNudgingOfOtherValues && newValue < static_cast<double> (valueMin.getValue()))
|
||||
setMinValue (newValue, notification, false);
|
||||
|
||||
newValue = jmax ((double) valueMin.getValue(), newValue);
|
||||
newValue = jmax (static_cast<double> (valueMin.getValue()), newValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -402,7 +402,7 @@ public:
|
|||
{
|
||||
const double newValue = owner.snapValue (owner.getValueFromText (label->getText()), notDragging);
|
||||
|
||||
if (newValue != (double) currentValue.getValue())
|
||||
if (newValue != static_cast<double> (currentValue.getValue()))
|
||||
{
|
||||
DragInProgress drag (*this);
|
||||
setValue (newValue, sendNotificationSync);
|
||||
|
|
@ -791,7 +791,7 @@ public:
|
|||
const double maxSpeed = jmax (200, sliderRegionSize);
|
||||
double speed = jlimit (0.0, maxSpeed, (double) std::abs (mouseDiff));
|
||||
|
||||
if (speed != 0)
|
||||
if (speed != 0.0)
|
||||
{
|
||||
speed = 0.2 * velocityModeSensitivity
|
||||
* (1.0 + std::sin (double_Pi * (1.5 + jmin (0.5, velocityModeOffset
|
||||
|
|
@ -840,7 +840,7 @@ public:
|
|||
|
||||
sliderBeingDragged = getThumbIndexAt (e);
|
||||
|
||||
minMaxDiff = (double) valueMax.getValue() - (double) valueMin.getValue();
|
||||
minMaxDiff = static_cast<double> (valueMax.getValue()) - static_cast<double> (valueMin.getValue());
|
||||
|
||||
lastAngle = rotaryParams.startAngleRadians
|
||||
+ (rotaryParams.endAngleRadians - rotaryParams.startAngleRadians)
|
||||
|
|
@ -920,7 +920,7 @@ public:
|
|||
if (e.mods.isShiftDown())
|
||||
setMaxValue (getMinValue() + minMaxDiff, dontSendNotification, true);
|
||||
else
|
||||
minMaxDiff = (double) valueMax.getValue() - (double) valueMin.getValue();
|
||||
minMaxDiff = static_cast<double> (valueMax.getValue()) - static_cast<double> (valueMin.getValue());
|
||||
}
|
||||
else if (sliderBeingDragged == 2)
|
||||
{
|
||||
|
|
@ -930,7 +930,7 @@ public:
|
|||
if (e.mods.isShiftDown())
|
||||
setMinValue (getMaxValue() - minMaxDiff, dontSendNotification, true);
|
||||
else
|
||||
minMaxDiff = (double) valueMax.getValue() - (double) valueMin.getValue();
|
||||
minMaxDiff = static_cast<double> (valueMax.getValue()) - static_cast<double> (valueMin.getValue());
|
||||
}
|
||||
|
||||
mousePosWhenLastDragged = e.position;
|
||||
|
|
@ -946,7 +946,7 @@ public:
|
|||
{
|
||||
restoreMouseIfHidden();
|
||||
|
||||
if (sendChangeOnlyOnRelease && valueOnMouseDown != (double) currentValue.getValue())
|
||||
if (sendChangeOnlyOnRelease && valueOnMouseDown != static_cast<double> (currentValue.getValue()))
|
||||
triggerChangeMessage (sendNotificationAsync);
|
||||
|
||||
currentDrag = nullptr;
|
||||
|
|
@ -1010,11 +1010,11 @@ public:
|
|||
if (valueBox != nullptr)
|
||||
valueBox->hideEditor (false);
|
||||
|
||||
const double value = (double) currentValue.getValue();
|
||||
const double value = static_cast<double> (currentValue.getValue());
|
||||
const double delta = getMouseWheelDelta (value, (std::abs (wheel.deltaX) > std::abs (wheel.deltaY)
|
||||
? -wheel.deltaX : wheel.deltaY)
|
||||
* (wheel.isReversed ? -1.0f : 1.0f));
|
||||
if (delta != 0)
|
||||
if (delta != 0.0)
|
||||
{
|
||||
const double newValue = value + jmax (interval, std::abs (delta)) * (delta < 0 ? -1.0 : 1.0);
|
||||
|
||||
|
|
@ -1052,7 +1052,7 @@ public:
|
|||
|
||||
const double pos = sliderBeingDragged == 2 ? getMaxValue()
|
||||
: (sliderBeingDragged == 1 ? getMinValue()
|
||||
: (double) currentValue.getValue());
|
||||
: static_cast<double> (currentValue.getValue()));
|
||||
Point<float> mousePos;
|
||||
|
||||
if (isRotary())
|
||||
|
|
|
|||
|
|
@ -1415,8 +1415,8 @@ void CodeEditorComponent::mouseDoubleClick (const MouseEvent& e)
|
|||
|
||||
void CodeEditorComponent::mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& wheel)
|
||||
{
|
||||
if ((verticalScrollBar.isVisible() && wheel.deltaY != 0)
|
||||
|| (horizontalScrollBar.isVisible() && wheel.deltaX != 0))
|
||||
if ((verticalScrollBar.isVisible() && wheel.deltaY != 0.0f)
|
||||
|| (horizontalScrollBar.isVisible() && wheel.deltaX != 0.0f))
|
||||
{
|
||||
{
|
||||
MouseWheelDetails w (wheel);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue