diff --git a/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp b/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp index 3c0d447e98..a2ff14f7da 100644 --- a/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp +++ b/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp @@ -195,7 +195,7 @@ void PluginListComponent::setNumberOfThreadsForScanning (int num) void PluginListComponent::resized() { - Rectangle r (getLocalBounds().reduced (2)); + auto r = getLocalBounds().reduced (2); optionsButton.setBounds (r.removeFromBottom (24)); optionsButton.changeWidthToFitText (24); diff --git a/modules/juce_audio_utils/gui/juce_AudioVisualiserComponent.cpp b/modules/juce_audio_utils/gui/juce_AudioVisualiserComponent.cpp index 21b0fad66a..e1ca37b3d2 100644 --- a/modules/juce_audio_utils/gui/juce_AudioVisualiserComponent.cpp +++ b/modules/juce_audio_utils/gui/juce_AudioVisualiserComponent.cpp @@ -29,8 +29,7 @@ namespace juce struct AudioVisualiserComponent::ChannelInfo { - ChannelInfo (AudioVisualiserComponent& o, int bufferSize) - : owner (o), nextSample (0), subSample (0) + ChannelInfo (AudioVisualiserComponent& o, int bufferSize) : owner (o) { setBufferSize (bufferSize); clear(); @@ -38,20 +37,20 @@ struct AudioVisualiserComponent::ChannelInfo void clear() noexcept { - for (int i = 0; i < levels.size(); ++i) - levels.getReference(i) = Range(); + for (auto& l : levels) + l = {}; - value = Range(); + value = {}; subSample = 0; } - void pushSamples (const float* inputSamples, const int num) noexcept + void pushSamples (const float* inputSamples, int num) noexcept { for (int i = 0; i < num; ++i) pushSample (inputSamples[i]); } - void pushSample (const float newSample) noexcept + void pushSample (float newSample) noexcept { if (--subSample <= 0) { @@ -69,7 +68,7 @@ struct AudioVisualiserComponent::ChannelInfo void setBufferSize (int newSize) { levels.removeRange (newSize, levels.size()); - levels.insertMultiple (-1, Range(), newSize - levels.size()); + levels.insertMultiple (-1, {}, newSize - levels.size()); if (nextSample >= newSize) nextSample = 0; @@ -78,13 +77,13 @@ struct AudioVisualiserComponent::ChannelInfo AudioVisualiserComponent& owner; Array> levels; Range value; - int nextSample, subSample; + int nextSample = 0, subSample = 0; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ChannelInfo) }; //============================================================================== -AudioVisualiserComponent::AudioVisualiserComponent (const int initialNumChannels) +AudioVisualiserComponent::AudioVisualiserComponent (int initialNumChannels) : numSamples (1024), inputSamplesPerBlock (256), backgroundColour (Colours::black), @@ -99,7 +98,7 @@ AudioVisualiserComponent::~AudioVisualiserComponent() { } -void AudioVisualiserComponent::setNumChannels (const int numChannels) +void AudioVisualiserComponent::setNumChannels (int numChannels) { channels.clear(); @@ -111,14 +110,14 @@ void AudioVisualiserComponent::setBufferSize (int newNumSamples) { numSamples = newNumSamples; - for (int i = 0; i < channels.size(); ++i) - channels.getUnchecked(i)->setBufferSize (newNumSamples); + for (auto* c : channels) + c->setBufferSize (newNumSamples); } void AudioVisualiserComponent::clear() { - for (int i = 0; i < channels.size(); ++i) - channels.getUnchecked(i)->clear(); + for (auto* c : channels) + c->clear(); } void AudioVisualiserComponent::pushBuffer (const float** d, int numChannels, int num) @@ -138,7 +137,7 @@ void AudioVisualiserComponent::pushBuffer (const AudioBuffer& buffer) void AudioVisualiserComponent::pushBuffer (const AudioSourceChannelInfo& buffer) { - const int numChannels = jmin (buffer.buffer->getNumChannels(), channels.size()); + auto numChannels = jmin (buffer.buffer->getNumChannels(), channels.size()); for (int i = 0; i < numChannels; ++i) channels.getUnchecked(i)->pushSamples (buffer.buffer->getReadPointer (i, buffer.startSample), @@ -179,27 +178,24 @@ void AudioVisualiserComponent::paint (Graphics& g) { g.fillAll (backgroundColour); - Rectangle r (getLocalBounds().toFloat()); - const float channelHeight = r.getHeight() / channels.size(); + auto r = getLocalBounds().toFloat(); + auto channelHeight = r.getHeight() / channels.size(); g.setColour (waveformColour); - for (int i = 0; i < channels.size(); ++i) - { - const ChannelInfo& c = *channels.getUnchecked(i); - + for (auto* c : channels) paintChannel (g, r.removeFromTop (channelHeight), - c.levels.begin(), c.levels.size(), c.nextSample); - } + c->levels.begin(), c->levels.size(), c->nextSample); } -void AudioVisualiserComponent::getChannelAsPath (Path& path, const Range* levels, int numLevels, int nextSample) +void AudioVisualiserComponent::getChannelAsPath (Path& path, const Range* levels, + int numLevels, int nextSample) { path.preallocateSpace (4 * numLevels + 8); for (int i = 0; i < numLevels; ++i) { - const float level = -(levels[(nextSample + i) % numLevels].getEnd()); + auto level = -(levels[(nextSample + i) % numLevels].getEnd()); if (i == 0) path.startNewSubPath (0.0f, level); diff --git a/modules/juce_events/broadcasters/juce_ActionBroadcaster.cpp b/modules/juce_events/broadcasters/juce_ActionBroadcaster.cpp index 9efb3a9e1d..d495ebedef 100644 --- a/modules/juce_events/broadcasters/juce_ActionBroadcaster.cpp +++ b/modules/juce_events/broadcasters/juce_ActionBroadcaster.cpp @@ -35,7 +35,7 @@ public: void messageCallback() override { - if (const ActionBroadcaster* const b = broadcaster) + if (auto b = broadcaster.get()) if (b->actionListeners.contains (listener)) listener->actionListenerCallback (message); } diff --git a/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp b/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp index 868ccf7355..cf8506787b 100644 --- a/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp +++ b/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp @@ -351,8 +351,8 @@ void LowLevelGraphicsPostScriptRenderer::fillRect (const Rectangle& r) writeClip(); writeColour (stateStack.getLast()->fillType.colour); - Rectangle r2 (r.translated ((float) stateStack.getLast()->xOffset, - (float) stateStack.getLast()->yOffset)); + auto r2 = r.translated ((float) stateStack.getLast()->xOffset, + (float) stateStack.getLast()->yOffset); out << r2.getX() << ' ' << -r2.getBottom() << ' ' << r2.getWidth() << ' ' << r2.getHeight() << " rectfill\n"; } @@ -401,7 +401,7 @@ void LowLevelGraphicsPostScriptRenderer::fillPath (const Path& path, const Affin out << "clip\n"; } - const Rectangle bounds (stateStack.getLast()->clip.getBounds()); + auto bounds = stateStack.getLast()->clip.getBounds(); // ideally this would draw lots of lines or ellipses to approximate the gradient, but for the // time-being, this just fills it with the average colour.. diff --git a/modules/juce_graphics/effects/juce_DropShadowEffect.cpp b/modules/juce_graphics/effects/juce_DropShadowEffect.cpp index 6557c9dd85..8e2bf23060 100644 --- a/modules/juce_graphics/effects/juce_DropShadowEffect.cpp +++ b/modules/juce_graphics/effects/juce_DropShadowEffect.cpp @@ -99,9 +99,9 @@ void DropShadow::drawForPath (Graphics& g, const Path& path) const { jassert (radius > 0); - const Rectangle area ((path.getBounds().getSmallestIntegerContainer() + offset) - .expanded (radius + 1) - .getIntersection (g.getClipBounds().expanded (radius + 1))); + auto area = (path.getBounds().getSmallestIntegerContainer() + offset) + .expanded (radius + 1) + .getIntersection (g.getClipBounds().expanded (radius + 1)); if (area.getWidth() > 2 && area.getHeight() > 2) { @@ -142,11 +142,11 @@ void DropShadow::drawForRectangle (Graphics& g, const Rectangle& targetArea const float radiusInset = (radius + 1) / 2.0f; const float expandedRadius = radius + radiusInset; - const Rectangle area (targetArea.toFloat().reduced (radiusInset) + offset.toFloat()); + auto area = targetArea.toFloat().reduced (radiusInset) + offset.toFloat(); - Rectangle r (area.expanded (expandedRadius)); - Rectangle top (r.removeFromTop (expandedRadius)); - Rectangle bottom (r.removeFromBottom (expandedRadius)); + auto r = area.expanded (expandedRadius); + auto top = r.removeFromTop (expandedRadius); + auto bottom = r.removeFromBottom (expandedRadius); drawShadowSection (g, cg, top.removeFromLeft (expandedRadius), true, 1.0f, 1.0f, 0, 1.0f); drawShadowSection (g, cg, top.removeFromRight (expandedRadius), true, 0, 1.0f, 1.0f, 1.0f); diff --git a/modules/juce_graphics/geometry/juce_Path.cpp b/modules/juce_graphics/geometry/juce_Path.cpp index c0aef9ec26..42e2a6a550 100644 --- a/modules/juce_graphics/geometry/juce_Path.cpp +++ b/modules/juce_graphics/geometry/juce_Path.cpp @@ -674,8 +674,8 @@ void Path::addBubble (Rectangle bodyArea, startNewSubPath (bodyArea.getX() + cornerSizeW, bodyArea.getY()); - const Rectangle targetLimit (bodyArea.reduced (jmin (halfW - 1.0f, cornerSizeW + arrowBaseWidth), - jmin (halfH - 1.0f, cornerSizeH + arrowBaseWidth))); + auto targetLimit = bodyArea.reduced (jmin (halfW - 1.0f, cornerSizeW + arrowBaseWidth), + jmin (halfH - 1.0f, cornerSizeH + arrowBaseWidth)); if (Rectangle (targetLimit.getX(), maximumArea.getY(), targetLimit.getWidth(), bodyArea.getY() - maximumArea.getY()).contains (arrowTip)) diff --git a/modules/juce_gui_basics/buttons/juce_ShapeButton.cpp b/modules/juce_gui_basics/buttons/juce_ShapeButton.cpp index 3e7f91a59d..d49ae2b111 100644 --- a/modules/juce_gui_basics/buttons/juce_ShapeButton.cpp +++ b/modules/juce_gui_basics/buttons/juce_ShapeButton.cpp @@ -82,7 +82,7 @@ void ShapeButton::setShape (const Path& newShape, if (resizeNowToFitThisShape) { - Rectangle newBounds (shape.getBounds()); + auto newBounds = shape.getBounds(); if (hasShadow) newBounds = newBounds.expanded (4.0f); @@ -105,7 +105,9 @@ void ShapeButton::paintButton (Graphics& g, bool isMouseOverButton, bool isButto isButtonDown = false; } - Rectangle r (border.subtractedFrom (getLocalBounds()).toFloat().reduced (outlineWidth * 0.5f)); + auto r = border.subtractedFrom (getLocalBounds()) + .toFloat() + .reduced (outlineWidth * 0.5f); if (getComponentEffect() != nullptr) r = r.reduced (2.0f); @@ -118,7 +120,7 @@ void ShapeButton::paintButton (Graphics& g, bool isMouseOverButton, bool isButto sizeReductionWhenPressed * r.getHeight()); } - const AffineTransform trans (shape.getTransformToScaleToFit (r, maintainShapeProportions)); + auto trans = shape.getTransformToScaleToFit (r, maintainShapeProportions); if (isButtonDown) g.setColour (getToggleState() && useOnColours ? downColourOn : downColour); else if (isMouseOverButton) g.setColour (getToggleState() && useOnColours ? overColourOn : overColour); diff --git a/modules/juce_gui_basics/buttons/juce_TextButton.cpp b/modules/juce_gui_basics/buttons/juce_TextButton.cpp index d7d4fb46cd..9ca594f9ed 100644 --- a/modules/juce_gui_basics/buttons/juce_TextButton.cpp +++ b/modules/juce_gui_basics/buttons/juce_TextButton.cpp @@ -46,7 +46,7 @@ TextButton::~TextButton() void TextButton::paintButton (Graphics& g, bool isMouseOverButton, bool isButtonDown) { - LookAndFeel& lf = getLookAndFeel(); + auto& lf = getLookAndFeel(); lf.drawButtonBackground (g, *this, findColour (getToggleState() ? buttonOnColourId : buttonColourId), diff --git a/modules/juce_gui_basics/components/juce_Component.cpp b/modules/juce_gui_basics/components/juce_Component.cpp index 501ec4dbbf..a1edb9041e 100644 --- a/modules/juce_gui_basics/components/juce_Component.cpp +++ b/modules/juce_gui_basics/components/juce_Component.cpp @@ -2013,8 +2013,8 @@ void Component::setComponentEffect (ImageEffectFilter* newEffect) LookAndFeel& Component::getLookAndFeel() const noexcept { for (auto* c = this; c != nullptr; c = c->parentComponent) - if (c->lookAndFeel != nullptr) - return *(c->lookAndFeel); + if (auto lf = c->lookAndFeel.get()) + return *lf; return LookAndFeel::getDefaultLookAndFeel(); } diff --git a/modules/juce_gui_basics/components/juce_Desktop.cpp b/modules/juce_gui_basics/components/juce_Desktop.cpp index bfa3564200..5388c0f898 100644 --- a/modules/juce_gui_basics/components/juce_Desktop.cpp +++ b/modules/juce_gui_basics/components/juce_Desktop.cpp @@ -91,15 +91,16 @@ Component* Desktop::findComponentAt (Point screenPosition) const //============================================================================== LookAndFeel& Desktop::getDefaultLookAndFeel() noexcept { - if (currentLookAndFeel == nullptr) - { - if (defaultLookAndFeel == nullptr) - defaultLookAndFeel.reset (new LookAndFeel_V4()); + if (auto lf = currentLookAndFeel.get()) + return *lf; - currentLookAndFeel = defaultLookAndFeel.get(); - } + if (defaultLookAndFeel == nullptr) + defaultLookAndFeel.reset (new LookAndFeel_V4()); - return *currentLookAndFeel; + auto lf = defaultLookAndFeel.get(); + jassert (lf != nullptr); + currentLookAndFeel = lf; + return *lf; } void Desktop::setDefaultLookAndFeel (LookAndFeel* newDefaultLookAndFeel) @@ -193,7 +194,7 @@ void Desktop::handleAsyncUpdate() // The component may be deleted during this operation, but we'll use a SafePointer rather than a // BailOutChecker so that any remaining listeners will still get a callback (with a null pointer). WeakReference currentFocus (Component::getCurrentlyFocusedComponent()); - focusListeners.call ([&] (FocusChangeListener& l) { l.globalFocusChanged (currentFocus); }); + focusListeners.call ([&] (FocusChangeListener& l) { l.globalFocusChanged (currentFocus.get()); }); } //============================================================================== diff --git a/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.h b/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.h index 8f4bbb1515..daa1f7fb54 100644 --- a/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.h +++ b/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.h @@ -49,7 +49,7 @@ class JUCE_API ComponentMovementWatcher : public ComponentListener public: //============================================================================== /** Creates a ComponentMovementWatcher to watch a given target component. */ - ComponentMovementWatcher (Component* component); + ComponentMovementWatcher (Component* componentToWatch); /** Destructor. */ ~ComponentMovementWatcher(); @@ -68,7 +68,7 @@ public: virtual void componentVisibilityChanged() = 0; /** Returns the component that's being watched. */ - Component* getComponent() const noexcept { return component; } + Component* getComponent() const noexcept { return component.get(); } //============================================================================== /** @internal */ diff --git a/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.cpp b/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.cpp index 163295d7a4..789ee3525f 100644 --- a/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.cpp +++ b/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.cpp @@ -27,10 +27,8 @@ namespace juce { -ResizableBorderComponent::Zone::Zone() noexcept : zone (0) {} - -ResizableBorderComponent::Zone::Zone (const int zoneFlags) noexcept : zone (zoneFlags) {} - +ResizableBorderComponent::Zone::Zone() noexcept {} +ResizableBorderComponent::Zone::Zone (int zoneFlags) noexcept : zone (zoneFlags) {} ResizableBorderComponent::Zone::Zone (const ResizableBorderComponent::Zone& other) noexcept : zone (other.zone) {} ResizableBorderComponent::Zone& ResizableBorderComponent::Zone::operator= (const ResizableBorderComponent::Zone& other) noexcept @@ -42,8 +40,8 @@ ResizableBorderComponent::Zone& ResizableBorderComponent::Zone::operator= (const bool ResizableBorderComponent::Zone::operator== (const ResizableBorderComponent::Zone& other) const noexcept { return zone == other.zone; } bool ResizableBorderComponent::Zone::operator!= (const ResizableBorderComponent::Zone& other) const noexcept { return zone != other.zone; } -ResizableBorderComponent::Zone ResizableBorderComponent::Zone::fromPositionOnBorder (const Rectangle& totalSize, - const BorderSize& border, +ResizableBorderComponent::Zone ResizableBorderComponent::Zone::fromPositionOnBorder (Rectangle totalSize, + BorderSize border, Point position) { int z = 0; @@ -51,13 +49,15 @@ ResizableBorderComponent::Zone ResizableBorderComponent::Zone::fromPositionOnBor if (totalSize.contains (position) && ! border.subtractedFrom (totalSize).contains (position)) { - const int minW = jmax (totalSize.getWidth() / 10, jmin (10, totalSize.getWidth() / 3)); + auto minW = jmax (totalSize.getWidth() / 10, jmin (10, totalSize.getWidth() / 3)); + if (position.x < jmax (border.getLeft(), minW) && border.getLeft() > 0) z |= left; else if (position.x >= totalSize.getWidth() - jmax (border.getRight(), minW) && border.getRight() > 0) z |= right; - const int minH = jmax (totalSize.getHeight() / 10, jmin (10, totalSize.getHeight() / 3)); + auto minH = jmax (totalSize.getHeight() / 10, jmin (10, totalSize.getHeight() / 3)); + if (position.y < jmax (border.getTop(), minH) && border.getTop() > 0) z |= top; else if (position.y >= totalSize.getHeight() - jmax (border.getBottom(), minH) && border.getBottom() > 0) @@ -69,7 +69,7 @@ ResizableBorderComponent::Zone ResizableBorderComponent::Zone::fromPositionOnBor MouseCursor ResizableBorderComponent::Zone::getMouseCursor() const noexcept { - MouseCursor::StandardCursorType mc = MouseCursor::NormalCursor; + auto mc = MouseCursor::NormalCursor; switch (zone) { @@ -141,7 +141,7 @@ void ResizableBorderComponent::mouseDrag (const MouseEvent& e) return; } - const Rectangle newBounds (mouseZone.resizeRectangleBy (originalBounds, e.getOffsetFromDragStart())); + auto newBounds = mouseZone.resizeRectangleBy (originalBounds, e.getOffsetFromDragStart()); if (constrainer != nullptr) { @@ -153,8 +153,8 @@ void ResizableBorderComponent::mouseDrag (const MouseEvent& e) } else { - if (Component::Positioner* const pos = component->getPositioner()) - pos->applyNewBounds (newBounds); + if (auto positioner = component->getPositioner()) + positioner->applyNewBounds (newBounds); else component->setBounds (newBounds); } @@ -190,7 +190,7 @@ BorderSize ResizableBorderComponent::getBorderThickness() const void ResizableBorderComponent::updateMouseZone (const MouseEvent& e) { - Zone newZone (Zone::fromPositionOnBorder (getLocalBounds(), borderSize, e.getPosition())); + auto newZone = Zone::fromPositionOnBorder (getLocalBounds(), borderSize, e.getPosition()); if (mouseZone != newZone) { diff --git a/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.h b/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.h index 507dd17718..5a86c4f5bd 100644 --- a/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.h +++ b/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.h @@ -119,8 +119,8 @@ public: /** Given a point within a rectangle with a resizable border, this returns the zone that the point lies within. */ - static Zone fromPositionOnBorder (const Rectangle& totalSize, - const BorderSize& border, + static Zone fromPositionOnBorder (Rectangle totalSize, + BorderSize border, Point position); /** Returns an appropriate mouse-cursor for this resize zone. */ @@ -160,7 +160,7 @@ public: private: //============================================================================== - int zone; + int zone = centre; }; /** Returns the zone in which the mouse was last seen. */ diff --git a/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.cpp b/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.cpp index a4c8441be2..5fb835adc1 100644 --- a/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.cpp +++ b/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.cpp @@ -77,7 +77,7 @@ void ResizableEdgeComponent::mouseDrag (const MouseEvent& e) return; } - Rectangle newBounds (originalBounds); + auto newBounds = originalBounds; switch (edge) { @@ -98,8 +98,8 @@ void ResizableEdgeComponent::mouseDrag (const MouseEvent& e) } else { - if (Component::Positioner* const pos = component->getPositioner()) - pos->applyNewBounds (newBounds); + if (auto positioner = component->getPositioner()) + positioner->applyNewBounds (newBounds); else component->setBounds (newBounds); } diff --git a/modules/juce_gui_basics/layout/juce_ScrollBar.cpp b/modules/juce_gui_basics/layout/juce_ScrollBar.cpp index c441cbc454..e13565e616 100644 --- a/modules/juce_gui_basics/layout/juce_ScrollBar.cpp +++ b/modules/juce_gui_basics/layout/juce_ScrollBar.cpp @@ -308,7 +308,7 @@ void ScrollBar::resized() if (upButton != nullptr) { - Rectangle r (getLocalBounds()); + auto r = getLocalBounds(); if (vertical) { diff --git a/modules/juce_gui_basics/layout/juce_TabbedComponent.cpp b/modules/juce_gui_basics/layout/juce_TabbedComponent.cpp index eed3622a39..437c497dfa 100644 --- a/modules/juce_gui_basics/layout/juce_TabbedComponent.cpp +++ b/modules/juce_gui_basics/layout/juce_TabbedComponent.cpp @@ -31,14 +31,14 @@ namespace TabbedComponentHelpers { const Identifier deleteComponentId ("deleteByTabComp_"); - static void deleteIfNecessary (Component* const comp) + static void deleteIfNecessary (Component* comp) { if (comp != nullptr && (bool) comp->getProperties() [deleteComponentId]) delete comp; } static Rectangle getTabArea (Rectangle& content, BorderSize& outline, - const TabbedButtonBar::Orientation orientation, const int tabDepth) + TabbedButtonBar::Orientation orientation, int tabDepth) { switch (orientation) { @@ -71,7 +71,7 @@ struct TabbedComponent::ButtonBar : public TabbedButtonBar owner.popupMenuClickOnTab (tabIndex, tabName); } - Colour getTabBackgroundColour (const int tabIndex) + Colour getTabBackgroundColour (int tabIndex) { return owner.tabs->getTabBackgroundColour (tabIndex); } @@ -88,7 +88,7 @@ struct TabbedComponent::ButtonBar : public TabbedButtonBar //============================================================================== -TabbedComponent::TabbedComponent (const TabbedButtonBar::Orientation orientation) +TabbedComponent::TabbedComponent (TabbedButtonBar::Orientation orientation) { tabs.reset (new ButtonBar (*this, orientation)); addAndMakeVisible (tabs.get()); @@ -101,7 +101,7 @@ TabbedComponent::~TabbedComponent() } //============================================================================== -void TabbedComponent::setOrientation (const TabbedButtonBar::Orientation orientation) +void TabbedComponent::setOrientation (TabbedButtonBar::Orientation orientation) { tabs->setOrientation (orientation); resized(); @@ -112,7 +112,7 @@ TabbedButtonBar::Orientation TabbedComponent::getOrientation() const noexcept return tabs->getOrientation(); } -void TabbedComponent::setTabBarDepth (const int newDepth) +void TabbedComponent::setTabBarDepth (int newDepth) { if (tabDepth != newDepth) { @@ -121,7 +121,7 @@ void TabbedComponent::setTabBarDepth (const int newDepth) } } -TabBarButton* TabbedComponent::createTabButton (const String& tabName, const int /*tabIndex*/) +TabBarButton* TabbedComponent::createTabButton (const String& tabName, int /*tabIndex*/) { return new TabBarButton (tabName, *tabs); } @@ -132,7 +132,7 @@ void TabbedComponent::clearTabs() if (panelComponent != nullptr) { panelComponent->setVisible (false); - removeChildComponent (panelComponent); + removeChildComponent (panelComponent.get()); panelComponent = nullptr; } @@ -146,9 +146,9 @@ void TabbedComponent::clearTabs() void TabbedComponent::addTab (const String& tabName, Colour tabBackgroundColour, - Component* const contentComponent, - const bool deleteComponentWhenNotNeeded, - const int insertIndex) + Component* contentComponent, + bool deleteComponentWhenNotNeeded, + int insertIndex) { contentComponents.insert (insertIndex, WeakReference (contentComponent)); @@ -159,22 +159,22 @@ void TabbedComponent::addTab (const String& tabName, resized(); } -void TabbedComponent::setTabName (const int tabIndex, const String& newName) +void TabbedComponent::setTabName (int tabIndex, const String& newName) { tabs->setTabName (tabIndex, newName); } -void TabbedComponent::removeTab (const int tabIndex) +void TabbedComponent::removeTab (int tabIndex) { if (isPositiveAndBelow (tabIndex, contentComponents.size())) { - TabbedComponentHelpers::deleteIfNecessary (contentComponents.getReference (tabIndex)); + TabbedComponentHelpers::deleteIfNecessary (contentComponents.getReference (tabIndex).get()); contentComponents.remove (tabIndex); tabs->removeTab (tabIndex); } } -void TabbedComponent::moveTab (const int currentIndex, const int newIndex, const bool animate) +void TabbedComponent::moveTab (int currentIndex, int newIndex, bool animate) { contentComponents.move (currentIndex, newIndex); tabs->moveTab (currentIndex, newIndex, animate); @@ -190,17 +190,17 @@ StringArray TabbedComponent::getTabNames() const return tabs->getTabNames(); } -Component* TabbedComponent::getTabContentComponent (const int tabIndex) const noexcept +Component* TabbedComponent::getTabContentComponent (int tabIndex) const noexcept { - return contentComponents [tabIndex]; + return contentComponents[tabIndex].get(); } -Colour TabbedComponent::getTabBackgroundColour (const int tabIndex) const noexcept +Colour TabbedComponent::getTabBackgroundColour (int tabIndex) const noexcept { return tabs->getTabBackgroundColour (tabIndex); } -void TabbedComponent::setTabBackgroundColour (const int tabIndex, Colour newColour) +void TabbedComponent::setTabBackgroundColour (int tabIndex, Colour newColour) { tabs->setTabBackgroundColour (tabIndex, newColour); @@ -208,7 +208,7 @@ void TabbedComponent::setTabBackgroundColour (const int tabIndex, Colour newColo repaint(); } -void TabbedComponent::setCurrentTabIndex (const int newTabIndex, const bool sendChangeMessage) +void TabbedComponent::setCurrentTabIndex (int newTabIndex, bool sendChangeMessage) { tabs->setCurrentTabIndex (newTabIndex, sendChangeMessage); } @@ -223,14 +223,14 @@ String TabbedComponent::getCurrentTabName() const return tabs->getCurrentTabName(); } -void TabbedComponent::setOutline (const int thickness) +void TabbedComponent::setOutline (int thickness) { outlineThickness = thickness; resized(); repaint(); } -void TabbedComponent::setIndent (const int indentThickness) +void TabbedComponent::setIndent (int indentThickness) { edgeIndent = indentThickness; resized(); @@ -266,19 +266,19 @@ void TabbedComponent::resized() tabs->setBounds (TabbedComponentHelpers::getTabArea (content, outline, getOrientation(), tabDepth)); content = BorderSize (edgeIndent).subtractedFrom (outline.subtractedFrom (content)); - for (int i = contentComponents.size(); --i >= 0;) - if (Component* c = contentComponents.getReference(i)) - c->setBounds (content); + for (auto& c : contentComponents) + if (auto comp = c.get()) + comp->setBounds (content); } void TabbedComponent::lookAndFeelChanged() { - for (int i = contentComponents.size(); --i >= 0;) - if (Component* c = contentComponents.getReference(i)) - c->lookAndFeelChanged(); + for (auto& c : contentComponents) + if (auto comp = c.get()) + comp->lookAndFeelChanged(); } -void TabbedComponent::changeCallback (const int newCurrentTabIndex, const String& newTabName) +void TabbedComponent::changeCallback (int newCurrentTabIndex, const String& newTabName) { auto* newPanelComp = getTabContentComponent (getCurrentTabIndex()); diff --git a/modules/juce_gui_basics/layout/juce_TabbedComponent.h b/modules/juce_gui_basics/layout/juce_TabbedComponent.h index 383ab34037..78e6e01be6 100644 --- a/modules/juce_gui_basics/layout/juce_TabbedComponent.h +++ b/modules/juce_gui_basics/layout/juce_TabbedComponent.h @@ -162,7 +162,7 @@ public: /** Returns the current component that's filling the panel. This will return nullptr if there isn't one. */ - Component* getCurrentContentComponent() const noexcept { return panelComponent; } + Component* getCurrentContentComponent() const noexcept { return panelComponent.get(); } //============================================================================== /** Callback method to indicate the selected tab has been changed. diff --git a/modules/juce_gui_basics/layout/juce_Viewport.cpp b/modules/juce_gui_basics/layout/juce_Viewport.cpp index 67ee38e27d..d43f6ede46 100644 --- a/modules/juce_gui_basics/layout/juce_Viewport.cpp +++ b/modules/juce_gui_basics/layout/juce_Viewport.cpp @@ -66,7 +66,7 @@ void Viewport::deleteOrRemoveContentComp() { // This sets the content comp to a null pointer before deleting the old one, in case // anything tries to use the old one while it's in mid-deletion.. - std::unique_ptr oldCompDeleter (contentComp); + std::unique_ptr oldCompDeleter (contentComp.get()); contentComp = nullptr; } else @@ -124,7 +124,7 @@ Point Viewport::viewportPosToCompPos (Point pos) const { jassert (contentComp != nullptr); - auto contentBounds = contentHolder.getLocalArea (contentComp, contentComp->getLocalBounds()); + auto contentBounds = contentHolder.getLocalArea (contentComp.get(), contentComp->getLocalBounds()); Point p (jmax (jmin (0, contentHolder.getWidth() - contentBounds.getWidth()), jmin (0, -(pos.x))), jmax (jmin (0, contentHolder.getHeight() - contentBounds.getHeight()), jmin (0, -(pos.y)))); @@ -398,8 +398,9 @@ void Viewport::updateVisibleArea() } Rectangle contentBounds; - if (contentComp != nullptr) - contentBounds = contentHolder.getLocalArea (contentComp, contentComp->getLocalBounds()); + + if (auto cc = contentComp.get()) + contentBounds = contentHolder.getLocalArea (cc, cc->getLocalBounds()); auto visibleOrigin = -contentBounds.getPosition(); diff --git a/modules/juce_gui_basics/layout/juce_Viewport.h b/modules/juce_gui_basics/layout/juce_Viewport.h index 0bb108e903..6c493b4aa4 100644 --- a/modules/juce_gui_basics/layout/juce_Viewport.h +++ b/modules/juce_gui_basics/layout/juce_Viewport.h @@ -81,7 +81,7 @@ public: @see setViewedComponent */ - Component* getViewedComponent() const noexcept { return contentComp; } + Component* getViewedComponent() const noexcept { return contentComp.get(); } //============================================================================== /** Changes the position of the viewed component. diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp index e09466fa43..aa937abd3a 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp @@ -1226,7 +1226,7 @@ void LookAndFeel_V2::drawLabel (Graphics& g, Label& label) g.setColour (label.findColour (Label::textColourId).withMultipliedAlpha (alpha)); g.setFont (font); - Rectangle textArea (label.getBorderSize().subtractedFrom (label.getLocalBounds())); + auto textArea = label.getBorderSize().subtractedFrom (label.getLocalBounds()); g.drawFittedText (label.getText(), textArea, label.getJustificationType(), jmax (1, (int) (textArea.getHeight() / font.getHeight())), diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.cpp b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.cpp index df7feb784d..4f4148ffb2 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.cpp +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.cpp @@ -158,7 +158,7 @@ void LookAndFeel_V3::drawButtonBackground (Graphics& g, Button& button, const Co void LookAndFeel_V3::drawTableHeaderBackground (Graphics& g, TableHeaderComponent& header) { - Rectangle r (header.getLocalBounds()); + auto r = header.getLocalBounds(); auto outlineColour = header.findColour (TableHeaderComponent::outlineColourId); g.setColour (outlineColour); diff --git a/modules/juce_gui_basics/misc/juce_BubbleComponent.cpp b/modules/juce_gui_basics/misc/juce_BubbleComponent.cpp index 9e05e9821b..833e35463a 100644 --- a/modules/juce_gui_basics/misc/juce_BubbleComponent.cpp +++ b/modules/juce_gui_basics/misc/juce_BubbleComponent.cpp @@ -86,8 +86,8 @@ void BubbleComponent::setPosition (Rectangle rectangleToPointTo, const int totalW = content.getWidth() + distanceFromTarget * 2; const int totalH = content.getHeight() + distanceFromTarget * 2; - const Rectangle availableSpace (getParentComponent() != nullptr ? getParentComponent()->getLocalBounds() - : getParentMonitorArea().transformedBy (getTransform().inverted())); + auto availableSpace = (getParentComponent() != nullptr ? getParentComponent()->getLocalBounds() + : getParentMonitorArea().transformedBy (getTransform().inverted())); int spaceAbove = ((allowablePlacements & above) != 0) ? jmax (0, rectangleToPointTo.getY() - availableSpace.getY()) : -1; int spaceBelow = ((allowablePlacements & below) != 0) ? jmax (0, availableSpace.getBottom() - rectangleToPointTo.getBottom()) : -1; diff --git a/modules/juce_gui_basics/mouse/juce_ComponentDragger.cpp b/modules/juce_gui_basics/mouse/juce_ComponentDragger.cpp index 5f01eb8c98..8814b32783 100644 --- a/modules/juce_gui_basics/mouse/juce_ComponentDragger.cpp +++ b/modules/juce_gui_basics/mouse/juce_ComponentDragger.cpp @@ -48,7 +48,7 @@ void ComponentDragger::dragComponent (Component* const componentToDrag, const Mo if (componentToDrag != nullptr) { - Rectangle bounds (componentToDrag->getBounds()); + auto bounds = componentToDrag->getBounds(); // If the component is a window, multiple mouse events can get queued while it's in the same position, // so their coordinates become wrong after the first one moves the window, so in that case, we'll use diff --git a/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp b/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp index efe7654ce0..d028d2a166 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp +++ b/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp @@ -149,7 +149,7 @@ public: comp.internalMouseDrag (MouseInputSource (this), screenPosToLocalPos (comp, screenPos), time, pressure, orientation, rotation, tiltX, tiltY); } - void sendMouseUp (Component& comp, Point screenPos, Time time, const ModifierKeys oldMods) + void sendMouseUp (Component& comp, Point screenPos, Time time, ModifierKeys oldMods) { JUCE_MOUSE_EVENT_DBG ("up") comp.internalMouseUp (MouseInputSource (this), screenPosToLocalPos (comp, screenPos), time, oldMods, pressure, orientation, rotation, tiltX, tiltY); @@ -161,7 +161,7 @@ public: comp.internalMouseWheel (MouseInputSource (this), screenPosToLocalPos (comp, screenPos), time, wheel); } - void sendMagnifyGesture (Component& comp, Point screenPos, Time time, const float amount) + void sendMagnifyGesture (Component& comp, Point screenPos, Time time, float amount) { JUCE_MOUSE_EVENT_DBG ("magnify") comp.internalMagnifyGesture (MouseInputSource (this), screenPosToLocalPos (comp, screenPos), time, amount); @@ -169,7 +169,7 @@ public: //============================================================================== // (returns true if the button change caused a modal event loop) - bool setButtons (Point screenPos, Time time, const ModifierKeys newButtonState) + bool setButtons (Point screenPos, Time time, ModifierKeys newButtonState) { if (buttonState == newButtonState) return false; @@ -220,7 +220,7 @@ public: return lastCounter != mouseEventCounter; } - void setComponentUnderMouse (Component* const newComponent, Point screenPos, Time time) + void setComponentUnderMouse (Component* newComponent, Point screenPos, Time time) { auto* current = getComponentUnderMouse(); @@ -234,16 +234,17 @@ public: WeakReference safeOldComp (current); setButtons (screenPos, time, ModifierKeys()); - if (safeOldComp != nullptr) + if (auto oldComp = safeOldComp.get()) { componentUnderMouse = safeNewComp; - sendMouseExit (*safeOldComp, screenPos, time); + sendMouseExit (*oldComp, screenPos, time); } buttonState = originalButtonState; } - current = componentUnderMouse = safeNewComp; + componentUnderMouse = safeNewComp.get(); + current = safeNewComp.get(); if (current != nullptr) sendMouseEnter (*current, screenPos, time); @@ -263,7 +264,7 @@ public: } } - void setScreenPos (Point newScreenPos, Time time, const bool forceUpdate) + void setScreenPos (Point newScreenPos, Time time, bool forceUpdate) { if (! isDragging()) setComponentUnderMouse (findComponentAt (newScreenPos), newScreenPos, time); @@ -368,7 +369,7 @@ public: else screenPos = peer.localToGlobal (positionWithinPeer); - if (Component* target = lastNonInertialWheelTarget) + if (auto target = lastNonInertialWheelTarget.get()) sendMouseWheel (*target, screenPos, time, wheel); } @@ -737,7 +738,7 @@ struct MouseInputSource::SourceList : public Timer return nullptr; } - void beginDragAutoRepeat (const int interval) + void beginDragAutoRepeat (int interval) { if (interval > 0) { diff --git a/modules/juce_gui_basics/properties/juce_PropertyComponent.cpp b/modules/juce_gui_basics/properties/juce_PropertyComponent.cpp index 19136a5e76..54419a95e3 100644 --- a/modules/juce_gui_basics/properties/juce_PropertyComponent.cpp +++ b/modules/juce_gui_basics/properties/juce_PropertyComponent.cpp @@ -27,8 +27,8 @@ namespace juce { -PropertyComponent::PropertyComponent (const String& name, const int preferredHeight_) - : Component (name), preferredHeight (preferredHeight_) +PropertyComponent::PropertyComponent (const String& name, int height) + : Component (name), preferredHeight (height) { jassert (name.isNotEmpty()); } @@ -37,7 +37,7 @@ PropertyComponent::~PropertyComponent() {} void PropertyComponent::paint (Graphics& g) { - LookAndFeel& lf = getLookAndFeel(); + auto& lf = getLookAndFeel(); lf.drawPropertyComponentBackground (g, getWidth(), getHeight(), *this); lf.drawPropertyComponentLabel (g, getWidth(), getHeight(), *this); @@ -45,7 +45,7 @@ void PropertyComponent::paint (Graphics& g) void PropertyComponent::resized() { - if (Component* const c = getChildComponent(0)) + if (auto c = getChildComponent(0)) c->setBounds (getLookAndFeel().getPropertyComponentContentPosition (*this)); } diff --git a/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp b/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp index fdf3c7f699..3c57bd9c34 100644 --- a/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp +++ b/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp @@ -499,11 +499,11 @@ void TableHeaderComponent::reactToMenuItem (const int menuReturnId, const int /* void TableHeaderComponent::paint (Graphics& g) { - LookAndFeel& lf = getLookAndFeel(); + auto& lf = getLookAndFeel(); lf.drawTableHeaderBackground (g, *this); - const Rectangle clip (g.getClipBounds()); + auto clip = g.getClipBounds(); int x = 0; diff --git a/modules/juce_gui_extra/misc/juce_LiveConstantEditor.cpp b/modules/juce_gui_extra/misc/juce_LiveConstantEditor.cpp index 0be9335678..5a4ec36745 100644 --- a/modules/juce_gui_extra/misc/juce_LiveConstantEditor.cpp +++ b/modules/juce_gui_extra/misc/juce_LiveConstantEditor.cpp @@ -280,7 +280,7 @@ public: void resized() override { - Rectangle r (getLocalBounds().reduced (2, 0)); + auto r = getLocalBounds().reduced (2, 0); for (int i = 0; i < editors.size(); ++i) editors.getUnchecked(i)->setBounds (r.removeFromTop (itemHeight)); diff --git a/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockForm.cpp b/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockForm.cpp index 4e02a1d09c..2ba9c6f7f5 100644 --- a/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockForm.cpp +++ b/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockForm.cpp @@ -219,9 +219,9 @@ void OnlineUnlockForm::resized() const int buttonHeight = 22; - Rectangle r (getLocalBounds().reduced (10, 20)); + auto r = getLocalBounds().reduced (10, 20); - Rectangle buttonArea (r.removeFromBottom (buttonHeight)); + auto buttonArea = r.removeFromBottom (buttonHeight); registerButton.changeWidthToFitText (buttonHeight); cancelButton.changeWidthToFitText (buttonHeight);