diff --git a/extras/Projucer/Source/ComponentEditor/paintelements/jucer_FillType.h b/extras/Projucer/Source/ComponentEditor/paintelements/jucer_FillType.h index fb72c98ced..d1f935c28c 100644 --- a/extras/Projucer/Source/ComponentEditor/paintelements/jucer_FillType.h +++ b/extras/Projucer/Source/ComponentEditor/paintelements/jucer_FillType.h @@ -283,7 +283,7 @@ public: return gradCol1.isTransparent() && gradCol2.isTransparent(); case imageBrush: - return imageOpacity == 0; + return imageOpacity == 0.0; default: jassertfalse; diff --git a/extras/Projucer/Source/ComponentEditor/properties/jucer_FontPropertyComponent.h b/extras/Projucer/Source/ComponentEditor/properties/jucer_FontPropertyComponent.h index 180cbc392b..221472ef9d 100644 --- a/extras/Projucer/Source/ComponentEditor/properties/jucer_FontPropertyComponent.h +++ b/extras/Projucer/Source/ComponentEditor/properties/jucer_FontPropertyComponent.h @@ -128,7 +128,7 @@ public: s << getFontStyleCode (font) << ")"; - if (font.getExtraKerningFactor() != 0) + if (font.getExtraKerningFactor() != 0.0f) s << ".withExtraKerningFactor (" << CodeHelpers::floatLiteral (font.getExtraKerningFactor(), 3) << ")"; diff --git a/modules/juce_core/containers/juce_Variant.cpp b/modules/juce_core/containers/juce_Variant.cpp index a20b20df45..21d66dec5c 100644 --- a/modules/juce_core/containers/juce_Variant.cpp +++ b/modules/juce_core/containers/juce_Variant.cpp @@ -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 diff --git a/modules/juce_core/javascript/juce_Javascript.cpp b/modules/juce_core/javascript/juce_Javascript.cpp index f94e02ac0d..8b73e152cb 100644 --- a/modules/juce_core/javascript/juce_Javascript.cpp +++ b/modules/juce_core/javascript/juce_Javascript.cpp @@ -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::infinity(); } - var getWithInts (int64 a, int64 b) const override { return b != 0 ? var (a / (double) b) : var (std::numeric_limits::infinity()); } + var getWithDoubles (double a, double b) const override { return b != 0.0 ? a / b : std::numeric_limits::infinity(); } + var getWithInts (int64 a, int64 b) const override { return b != 0 ? var (a / (double) b) : var (std::numeric_limits::infinity()); } }; struct ModuloOp : public BinaryOperator diff --git a/modules/juce_core/text/juce_CharacterFunctions.cpp b/modules/juce_core/text/juce_CharacterFunctions.cpp index 7a0152adce..cf2231a49d 100644 --- a/modules/juce_core/text/juce_CharacterFunctions.cpp +++ b/modules/juce_core/text/juce_CharacterFunctions.cpp @@ -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); diff --git a/modules/juce_graphics/colour/juce_ColourGradient.cpp b/modules/juce_graphics/colour/juce_ColourGradient.cpp index e06e9970bf..360d0008c2 100644 --- a/modules/juce_graphics/colour/juce_ColourGradient.cpp +++ b/modules/juce_graphics/colour/juce_ColourGradient.cpp @@ -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; diff --git a/modules/juce_graphics/fonts/juce_CustomTypeface.cpp b/modules/juce_graphics/fonts/juce_CustomTypeface.cpp index 801a9e31a3..35e27d0d83 100644 --- a/modules/juce_graphics/fonts/juce_CustomTypeface.cpp +++ b/modules/juce_graphics/fonts/juce_CustomTypeface.cpp @@ -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! diff --git a/modules/juce_graphics/fonts/juce_Font.cpp b/modules/juce_graphics/fonts/juce_Font.cpp index 07fdde0cc9..b92d519a5d 100644 --- a/modules/juce_graphics/fonts/juce_Font.cpp +++ b/modules/juce_graphics/fonts/juce_Font.cpp @@ -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::max(); + auto bestLastUsageCount = std::numeric_limits::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 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 (""), - serif (""), - mono (""), - regular ("") - { - } - - String sans, serif, mono, regular; + String sans { "" }, + serif { "" }, + mono { "" }, + 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& glyphs, ArraygetGlyphPositions (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& glyphs, Array& 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)); } } diff --git a/modules/juce_graphics/geometry/juce_AffineTransform.cpp b/modules/juce_graphics/geometry/juce_AffineTransform.cpp index f58fe31562..1e61a19b4b 100644 --- a/modules/juce_graphics/geometry/juce_AffineTransform.cpp +++ b/modules/juce_graphics/geometry/juce_AffineTransform.cpp @@ -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); } diff --git a/modules/juce_graphics/geometry/juce_Path.cpp b/modules/juce_graphics/geometry/juce_Path.cpp index d6efabee3d..abefd0b234 100644 --- a/modules/juce_graphics/geometry/juce_Path.cpp +++ b/modules/juce_graphics/geometry/juce_Path.cpp @@ -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 Path::PathBounds::getRectangle() const noexcept { - return Rectangle (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; } @@ -271,9 +273,9 @@ void Path::startNewSubPath (const float x, const float y) preallocateSpace (3); - data.elements [numElements++] = moveMarker; - data.elements [numElements++] = x; - data.elements [numElements++] = y; + data.elements[numElements++] = moveMarker; + data.elements[numElements++] = x; + data.elements[numElements++] = y; } void Path::startNewSubPath (const Point start) @@ -290,9 +292,9 @@ void Path::lineTo (const float x, const float y) preallocateSpace (3); - data.elements [numElements++] = lineMarker; - data.elements [numElements++] = x; - data.elements [numElements++] = y; + data.elements[numElements++] = lineMarker; + data.elements[numElements++] = x; + data.elements[numElements++] = y; bounds.extend (x, y); } @@ -313,11 +315,11 @@ void Path::quadraticTo (const float x1, const float y1, preallocateSpace (5); - data.elements [numElements++] = quadMarker; - data.elements [numElements++] = x1; - data.elements [numElements++] = y1; - data.elements [numElements++] = x2; - data.elements [numElements++] = y2; + data.elements[numElements++] = quadMarker; + data.elements[numElements++] = x1; + data.elements[numElements++] = y1; + data.elements[numElements++] = x2; + data.elements[numElements++] = y2; bounds.extend (x1, y1, x2, y2); } @@ -342,13 +344,13 @@ void Path::cubicTo (const float x1, const float y1, preallocateSpace (7); - data.elements [numElements++] = cubicMarker; - data.elements [numElements++] = x1; - data.elements [numElements++] = y1; - data.elements [numElements++] = x2; - data.elements [numElements++] = y2; - data.elements [numElements++] = x3; - data.elements [numElements++] = y3; + data.elements[numElements++] = cubicMarker; + data.elements[numElements++] = x1; + data.elements[numElements++] = y1; + data.elements[numElements++] = x2; + data.elements[numElements++] = y2; + data.elements[numElements++] = x3; + data.elements[numElements++] = y3; bounds.extend (x1, y1, x2, y2); bounds.extend (x3, y3); @@ -365,11 +367,10 @@ void Path::cubicTo (const Point 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; + data.elements[numElements++] = closeSubPathMarker; } } @@ -377,11 +378,11 @@ Point 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 Path::getCurrentPosition() const } if (i > 0) - return Point (data.elements [i - 1], data.elements [i]); + return { data.elements[i - 1], data.elements[i] }; - return Point(); + return {}; } void Path::addRectangle (const float x, const float y, @@ -422,19 +423,19 @@ void Path::addRectangle (const float x, const float y, bounds.pathYMax = jmax (bounds.pathYMax, y2); } - data.elements [numElements++] = moveMarker; - data.elements [numElements++] = x1; - data.elements [numElements++] = y2; - data.elements [numElements++] = lineMarker; - data.elements [numElements++] = x1; - data.elements [numElements++] = y1; - data.elements [numElements++] = lineMarker; - data.elements [numElements++] = x2; - data.elements [numElements++] = y1; - data.elements [numElements++] = lineMarker; - data.elements [numElements++] = x2; - data.elements [numElements++] = y2; - data.elements [numElements++] = closeSubPathMarker; + data.elements[numElements++] = moveMarker; + data.elements[numElements++] = x1; + data.elements[numElements++] = y2; + data.elements[numElements++] = lineMarker; + data.elements[numElements++] = x1; + data.elements[numElements++] = y1; + data.elements[numElements++] = lineMarker; + data.elements[numElements++] = x2; + data.elements[numElements++] = y1; + data.elements[numElements++] = lineMarker; + data.elements[numElements++] = x2; + data.elements[numElements++] = y2; + data.elements[numElements++] = closeSubPathMarker; } void Path::addRoundedRectangle (float x, float y, float w, float h, float csx, float csy) @@ -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 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 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 segmentBounds, //============================================================================== void Path::addLineSegment (const Line& line, float lineThickness) { - const Line reversed (line.reversed()); + auto reversed = line.reversed(); lineThickness *= 0.5f; startNewSubPath (line.getPointAlongLine (0, lineThickness)); @@ -687,7 +688,7 @@ void Path::addLineSegment (const Line& line, float lineThickness) void Path::addArrow (const Line& line, float lineThickness, float arrowheadWidth, float arrowheadLength) { - const Line 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 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 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 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 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& 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& 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 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 Path::getClippedLine (Line line, const bool keepSectionOutsid while (i.next()) { - if (line.intersects (Line (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 Path::getPointAlongPath (float distanceFromStart, while (i.next()) { const Line 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 Path::getPointAlongPath (float distanceFromStart, distanceFromStart -= lineLength; } - return Point (i.x2, i.y2); + return { i.x2, i.y2 }; } float Path::getNearestPoint (const Point targetPoint, Point& pointOnPath, @@ -1147,7 +1148,7 @@ float Path::getNearestPoint (const Point targetPoint, Point& point while (i.next()) { const Line 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,73 +1169,73 @@ 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++]; + endX = data.elements[n++]; + endY = data.elements[n++]; if (n > 8) { - startX = data.elements [n - 8]; - startY = data.elements [n - 7]; - joinX = data.elements [n - 5]; - joinY = data.elements [n - 4]; + startX = data.elements[n - 8]; + startY = data.elements[n - 7]; + joinX = data.elements[n - 5]; + joinY = data.elements[n - 4]; } } else { - endX = data.elements [indexOfPathStartThis + 1]; - endY = data.elements [indexOfPathStartThis + 2]; + endX = data.elements[indexOfPathStartThis + 1]; + endY = data.elements[indexOfPathStartThis + 2]; if (n > 6) { - startX = data.elements [n - 6]; - startY = data.elements [n - 5]; - joinX = data.elements [n - 3]; - joinY = data.elements [n - 2]; + startX = data.elements[n - 6]; + startY = data.elements[n - 5]; + joinX = data.elements[n - 3]; + joinY = data.elements[n - 2]; } } 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); + 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,70 +1244,70 @@ 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) { - startX = data.elements [n - 3]; - startY = data.elements [n - 2]; + startX = data.elements[n - 3]; + startY = data.elements[n - 2]; joinX = endX; joinY = endY; - endX = data.elements [indexOfPathStartThis + 4]; - endY = data.elements [indexOfPathStartThis + 5]; + 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); + 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); p.quadraticTo (joinX, joinY, endX, endY); - p.data.elements [indexOfPathStart + 1] = endX; - p.data.elements [indexOfPathStart + 2] = endY; + p.data.elements[indexOfPathStart + 1] = endX; + p.data.elements[indexOfPathStart + 2] = endY; } } 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,42 +1392,41 @@ 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++]); + 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++]); + 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++]); - dest.writeFloat (data.elements [i++]); - dest.writeFloat (data.elements [i++]); - dest.writeFloat (data.elements [i++]); + dest.writeFloat (data.elements[i++]); + dest.writeFloat (data.elements[i++]); + 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++]); - dest.writeFloat (data.elements [i++]); - dest.writeFloat (data.elements [i++]); - dest.writeFloat (data.elements [i++]); - dest.writeFloat (data.elements [i++]); - dest.writeFloat (data.elements [i++]); + dest.writeFloat (data.elements[i++]); + dest.writeFloat (data.elements[i++]); + dest.writeFloat (data.elements[i++]); + dest.writeFloat (data.elements[i++]); + dest.writeFloat (data.elements[i++]); + dest.writeFloat (data.elements[i++]); } - else if (type == closeSubPathMarker) + else if (isMarker (type, closeSubPathMarker)) { dest.writeByte ('c'); } @@ -1446,48 +1446,48 @@ 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) { - String coord (data.elements [i++], 3); + String coord (data.elements[i++], 3); while (coord.endsWithChar ('0') && coord != "0") coord = coord.dropLastCharacters (1); @@ -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]; + 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,43 +1582,43 @@ 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++]; + x1 = elements[index++]; + y1 = elements[index++]; } - else if (type == lineMarker) + else if (isMarker (type, lineMarker)) { elementType = lineTo; - x1 = elements [index++]; - y1 = elements [index++]; + x1 = elements[index++]; + y1 = elements[index++]; } - else if (type == quadMarker) + else if (isMarker (type, quadMarker)) { elementType = quadraticTo; - x1 = elements [index++]; - y1 = elements [index++]; - x2 = elements [index++]; - y2 = elements [index++]; + x1 = elements[index++]; + y1 = elements[index++]; + x2 = elements[index++]; + y2 = elements[index++]; } - else if (type == cubicMarker) + else if (isMarker (type, cubicMarker)) { elementType = cubicTo; - x1 = elements [index++]; - y1 = elements [index++]; - x2 = elements [index++]; - y2 = elements [index++]; - x3 = elements [index++]; - y3 = elements [index++]; + x1 = elements[index++]; + y1 = elements[index++]; + x2 = elements[index++]; + y2 = elements[index++]; + x3 = elements[index++]; + y3 = elements[index++]; } - else if (type == closeSubPathMarker) + else if (isMarker (type, closeSubPathMarker)) { elementType = closePath; } diff --git a/modules/juce_graphics/geometry/juce_Path.h b/modules/juce_graphics/geometry/juce_Path.h index 46f5876cd0..19811a628f 100644 --- a/modules/juce_graphics/geometry/juce_Path.h +++ b/modules/juce_graphics/geometry/juce_Path.h @@ -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 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; diff --git a/modules/juce_graphics/geometry/juce_PathIterator.cpp b/modules/juce_graphics/geometry/juce_PathIterator.cpp index 76663ace05..ca237ff4ba 100644 --- a/modules/juce_graphics/geometry/juce_PathIterator.cpp +++ b/modules/juce_graphics/geometry/juce_PathIterator.cpp @@ -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; diff --git a/modules/juce_graphics/geometry/juce_PathIterator.h b/modules/juce_graphics/geometry/juce_PathIterator.h index e636bff14c..a10a489c5f 100644 --- a/modules/juce_graphics/geometry/juce_PathIterator.h +++ b/modules/juce_graphics/geometry/juce_PathIterator.h @@ -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 stackBase; + HeapBlock stackBase { 32 }; float* stackPos; - size_t index, stackSize; + size_t index = 0, stackSize = 32; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PathFlatteningIterator) }; diff --git a/modules/juce_graphics/geometry/juce_PathStrokeType.cpp b/modules/juce_graphics/geometry/juce_PathStrokeType.cpp index f9a7fbc892..837195d536 100644 --- a/modules/juce_graphics/geometry/juce_PathStrokeType.cpp +++ b/modules/juce_graphics/geometry/juce_PathStrokeType.cpp @@ -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 subPath; + Array 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; diff --git a/modules/juce_graphics/image_formats/pnglib/png.c b/modules/juce_graphics/image_formats/pnglib/png.c index 67e7e2ef6a..75e610521f 100644 --- a/modules/juce_graphics/image_formats/pnglib/png.c +++ b/modules/juce_graphics/image_formats/pnglib/png.c @@ -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; diff --git a/modules/juce_graphics/native/juce_RenderingHelpers.h b/modules/juce_graphics/native/juce_RenderingHelpers.h index 61026306fd..d048d2db7e 100644 --- a/modules/juce_graphics/native/juce_RenderingHelpers.h +++ b/modules/juce_graphics/native/juce_RenderingHelpers.h @@ -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); } diff --git a/modules/juce_graphics/placement/juce_RectanglePlacement.cpp b/modules/juce_graphics/placement/juce_RectanglePlacement.cpp index 1cfed08f68..573e5f4e77 100644 --- a/modules/juce_graphics/placement/juce_RectanglePlacement.cpp +++ b/modules/juce_graphics/placement/juce_RectanglePlacement.cpp @@ -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) diff --git a/modules/juce_gui_basics/drawables/juce_SVGParser.cpp b/modules/juce_gui_basics/drawables/juce_SVGParser.cpp index ba546b9f35..b66176eb36 100644 --- a/modules/juce_gui_basics/drawables/juce_SVGParser.cpp +++ b/modules/juce_gui_basics/drawables/juce_SVGParser.cpp @@ -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); diff --git a/modules/juce_gui_basics/layout/juce_AnimatedPositionBehaviours.h b/modules/juce_gui_basics/layout/juce_AnimatedPositionBehaviours.h index eb4efc44da..20167ddc2e 100644 --- a/modules/juce_gui_basics/layout/juce_AnimatedPositionBehaviours.h +++ b/modules/juce_gui_basics/layout/juce_AnimatedPositionBehaviours.h @@ -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; }; //============================================================================== diff --git a/modules/juce_gui_basics/layout/juce_FlexBox.cpp b/modules/juce_gui_basics/layout/juce_FlexBox.cpp index 5c89190238..4e99ed175c 100644 --- a/modules/juce_gui_basics/layout/juce_FlexBox.cpp +++ b/modules/juce_gui_basics/layout/juce_FlexBox.cpp @@ -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; } diff --git a/modules/juce_gui_basics/layout/juce_Viewport.cpp b/modules/juce_gui_basics/layout/juce_Viewport.cpp index ad9d1ea7e4..c95e1f49ff 100644 --- a/modules/juce_gui_basics/layout/juce_Viewport.cpp +++ b/modules/juce_gui_basics/layout/juce_Viewport.cpp @@ -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; diff --git a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index def3aaf3ba..2d9e08f258 100644 --- a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -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]; diff --git a/modules/juce_gui_basics/widgets/juce_ComboBox.cpp b/modules/juce_gui_basics/widgets/juce_ComboBox.cpp index 49102b0dc8..638ec2157a 100644 --- a/modules/juce_gui_basics/widgets/juce_ComboBox.cpp +++ b/modules/juce_gui_basics/widgets/juce_ComboBox.cpp @@ -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 diff --git a/modules/juce_gui_basics/widgets/juce_ListBox.cpp b/modules/juce_gui_basics/widgets/juce_ListBox.cpp index e8da2c2fb1..f2c4af4ce4 100644 --- a/modules/juce_gui_basics/widgets/juce_ListBox.cpp +++ b/modules/juce_gui_basics/widgets/juce_ListBox.cpp @@ -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); diff --git a/modules/juce_gui_basics/widgets/juce_Slider.cpp b/modules/juce_gui_basics/widgets/juce_Slider.cpp index 685b9b474b..2a8955eede 100644 --- a/modules/juce_gui_basics/widgets/juce_Slider.cpp +++ b/modules/juce_gui_basics/widgets/juce_Slider.cpp @@ -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 (valueMin.getValue()) <= static_cast (valueMax.getValue())); - newValue = jlimit ((double) valueMin.getValue(), - (double) valueMax.getValue(), + newValue = jlimit (static_cast (valueMin.getValue()), + static_cast (valueMax.getValue()), newValue); } @@ -217,10 +217,10 @@ public: if (style == TwoValueHorizontal || style == TwoValueVertical) { - if (allowNudgingOfOtherValues && newValue > (double) valueMax.getValue()) + if (allowNudgingOfOtherValues && newValue > static_cast (valueMax.getValue())) setMaxValue (newValue, notification, false); - newValue = jmin ((double) valueMax.getValue(), newValue); + newValue = jmin (static_cast (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 (valueMin.getValue())) setMinValue (newValue, notification, false); - newValue = jmax ((double) valueMin.getValue(), newValue); + newValue = jmax (static_cast (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 (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 (valueMax.getValue()) - static_cast (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 (valueMax.getValue()) - static_cast (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 (valueMax.getValue()) - static_cast (valueMin.getValue()); } mousePosWhenLastDragged = e.position; @@ -946,7 +946,7 @@ public: { restoreMouseIfHidden(); - if (sendChangeOnlyOnRelease && valueOnMouseDown != (double) currentValue.getValue()) + if (sendChangeOnlyOnRelease && valueOnMouseDown != static_cast (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 (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 (currentValue.getValue())); Point mousePos; if (isRotary()) diff --git a/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp b/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp index d3b0d2cdf3..acfa7db5ee 100644 --- a/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp +++ b/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp @@ -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);