Browse Source

Made a few minor tweaks to reduce the number of pedantic -Wfloat-equals warnings

tags/2021-05-28
jules 8 years ago
parent
commit
bf94ab0e4c
26 changed files with 412 additions and 433 deletions
  1. +1
    -1
      extras/Projucer/Source/ComponentEditor/paintelements/jucer_FillType.h
  2. +1
    -1
      extras/Projucer/Source/ComponentEditor/properties/jucer_FontPropertyComponent.h
  3. +1
    -1
      modules/juce_core/containers/juce_Variant.cpp
  4. +2
    -2
      modules/juce_core/javascript/juce_Javascript.cpp
  5. +1
    -1
      modules/juce_core/text/juce_CharacterFunctions.cpp
  6. +2
    -2
      modules/juce_graphics/colour/juce_ColourGradient.cpp
  7. +2
    -2
      modules/juce_graphics/fonts/juce_CustomTypeface.cpp
  8. +31
    -43
      modules/juce_graphics/fonts/juce_Font.cpp
  9. +7
    -7
      modules/juce_graphics/geometry/juce_AffineTransform.cpp
  10. +238
    -240
      modules/juce_graphics/geometry/juce_Path.cpp
  11. +5
    -5
      modules/juce_graphics/geometry/juce_Path.h
  12. +36
    -41
      modules/juce_graphics/geometry/juce_PathIterator.cpp
  13. +3
    -3
      modules/juce_graphics/geometry/juce_PathIterator.h
  14. +47
    -47
      modules/juce_graphics/geometry/juce_PathStrokeType.cpp
  15. +1
    -1
      modules/juce_graphics/image_formats/pnglib/png.c
  16. +1
    -1
      modules/juce_graphics/native/juce_RenderingHelpers.h
  17. +1
    -1
      modules/juce_graphics/placement/juce_RectanglePlacement.cpp
  18. +2
    -2
      modules/juce_gui_basics/drawables/juce_SVGParser.cpp
  19. +2
    -3
      modules/juce_gui_basics/layout/juce_AnimatedPositionBehaviours.h
  20. +2
    -2
      modules/juce_gui_basics/layout/juce_FlexBox.cpp
  21. +1
    -1
      modules/juce_gui_basics/layout/juce_Viewport.cpp
  22. +1
    -1
      modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm
  23. +3
    -4
      modules/juce_gui_basics/widgets/juce_ComboBox.cpp
  24. +2
    -2
      modules/juce_gui_basics/widgets/juce_ListBox.cpp
  25. +17
    -17
      modules/juce_gui_basics/widgets/juce_Slider.cpp
  26. +2
    -2
      modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp

+ 1
- 1
extras/Projucer/Source/ComponentEditor/paintelements/jucer_FillType.h View File

@@ -283,7 +283,7 @@ public:
return gradCol1.isTransparent() && gradCol2.isTransparent();
case imageBrush:
return imageOpacity == 0;
return imageOpacity == 0.0;
default:
jassertfalse;


+ 1
- 1
extras/Projucer/Source/ComponentEditor/properties/jucer_FontPropertyComponent.h View File

@@ -128,7 +128,7 @@ public:
s << getFontStyleCode (font)
<< ")";
if (font.getExtraKerningFactor() != 0)
if (font.getExtraKerningFactor() != 0.0f)
s << ".withExtraKerningFactor ("
<< CodeHelpers::floatLiteral (font.getExtraKerningFactor(), 3)
<< ")";


+ 1
- 1
modules/juce_core/containers/juce_Variant.cpp View File

@@ -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


+ 2
- 2
modules/juce_core/javascript/juce_Javascript.cpp View File

@@ -597,8 +597,8 @@ 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 getWithInts (int64 a, int64 b) const override { return b != 0 ? var (a / (double) b) : var (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()); }
};
struct ModuloOp : public BinaryOperator


+ 1
- 1
modules/juce_core/text/juce_CharacterFunctions.cpp View File

@@ -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);


+ 2
- 2
modules/juce_graphics/colour/juce_ColourGradient.cpp View File

@@ -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;


+ 2
- 2
modules/juce_graphics/fonts/juce_CustomTypeface.cpp View File

@@ -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!


+ 31
- 43
modules/juce_graphics/fonts/juce_Font.cpp View File

@@ -38,14 +38,14 @@ namespace FontValues
typedef Typeface::Ptr (*GetTypefaceForFont) (const Font&);
GetTypefaceForFont juce_getTypefaceForFont = nullptr;
float Font::getDefaultMinimumHorizontalScaleFactor() noexcept { return FontValues::minimumHorizontalScale; }
float Font::getDefaultMinimumHorizontalScaleFactor() noexcept { return FontValues::minimumHorizontalScale; }
void Font::setDefaultMinimumHorizontalScaleFactor (float newValue) noexcept { FontValues::minimumHorizontalScale = newValue; }
//==============================================================================
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));
}
}


+ 7
- 7
modules/juce_graphics/geometry/juce_AffineTransform.cpp View File

@@ -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);
}


+ 238
- 240
modules/juce_graphics/geometry/juce_Path.cpp
File diff suppressed because it is too large
View File


+ 5
- 5
modules/juce_graphics/geometry/juce_Path.h View File

@@ -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;


+ 36
- 41
modules/juce_graphics/geometry/juce_PathIterator.cpp View File

@@ -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;
const float error1X = m4x - x2;
const float error1Y = m4y - y2;
const float error2X = m5x - x3;
const float error2Y = m5y - y3;
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;
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;


+ 3
- 3
modules/juce_graphics/geometry/juce_PathIterator.h View File

@@ -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)
};

+ 47
- 47
modules/juce_graphics/geometry/juce_PathStrokeType.cpp View File

@@ -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,
@@ -572,7 +572,7 @@ namespace PathStrokeHelpers
// left/right-hand lines along either side of it...
PathFlatteningIterator it (*sourcePath, transform, Path::defaultToleranceForMeasurement / extraAccuracy);
Array <LineSection> subPath;
Array<LineSection> subPath;
subPath.ensureStorageAllocated (512);
LineSection l;
l.x1 = 0;
@@ -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;


+ 1
- 1
modules/juce_graphics/image_formats/pnglib/png.c View File

@@ -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;


+ 1
- 1
modules/juce_graphics/native/juce_RenderingHelpers.h View File

@@ -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);
}


+ 1
- 1
modules/juce_graphics/placement/juce_RectanglePlacement.cpp View File

@@ -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)


+ 2
- 2
modules/juce_gui_basics/drawables/juce_SVGParser.cpp View File

@@ -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);


+ 2
- 3
modules/juce_gui_basics/layout/juce_AnimatedPositionBehaviours.h View File

@@ -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;
};
//==============================================================================


+ 2
- 2
modules/juce_gui_basics/layout/juce_FlexBox.cpp View File

@@ -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;
}


+ 1
- 1
modules/juce_gui_basics/layout/juce_Viewport.cpp View File

@@ -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;


+ 1
- 1
modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm View File

@@ -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];


+ 3
- 4
modules/juce_gui_basics/widgets/juce_ComboBox.cpp View File

@@ -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


+ 2
- 2
modules/juce_gui_basics/widgets/juce_ListBox.cpp View File

@@ -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);


+ 17
- 17
modules/juce_gui_basics/widgets/juce_Slider.cpp View File

@@ -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())


+ 2
- 2
modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp View File

@@ -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…
Cancel
Save