| @@ -596,9 +596,8 @@ private: | |||||
| void setAllLookAndFeels (LookAndFeel* laf) | void setAllLookAndFeels (LookAndFeel* laf) | ||||
| { | { | ||||
| for (int i = 0; i < demoComp.getNumChildComponents(); ++i) | |||||
| if (Component* c = demoComp.getChildComponent (i)) | |||||
| c->setLookAndFeel (laf); | |||||
| for (auto* child : demoComp.getChildren()) | |||||
| child->setLookAndFeel (laf); | |||||
| } | } | ||||
| void comboBoxChanged (ComboBox* comboBoxThatHasChanged) override | void comboBoxChanged (ComboBox* comboBoxThatHasChanged) override | ||||
| @@ -411,8 +411,8 @@ struct FilterComponent : public Component | |||||
| bool hitTest (int x, int y) override | bool hitTest (int x, int y) override | ||||
| { | { | ||||
| for (int i = getNumChildComponents(); --i >= 0;) | |||||
| if (getChildComponent(i)->getBounds().contains (x, y)) | |||||
| for (auto* child : getChildren()) | |||||
| if (child->getBounds().contains (x, y)) | |||||
| return true; | return true; | ||||
| return x >= 3 && x < getWidth() - 6 && y >= pinSize && y < getHeight() - pinSize; | return x >= 3 && x < getWidth() - 6 && y >= pinSize && y < getHeight() - pinSize; | ||||
| @@ -440,9 +440,9 @@ struct FilterComponent : public Component | |||||
| { | { | ||||
| if (auto* processor = f->getProcessor()) | if (auto* processor = f->getProcessor()) | ||||
| { | { | ||||
| for (int i = 0; i < getNumChildComponents(); ++i) | |||||
| for (auto* child : getChildren()) | |||||
| { | { | ||||
| if (auto* pin = dynamic_cast<PinComponent*> (getChildComponent(i))) | |||||
| if (auto* pin = dynamic_cast<PinComponent*> (child)) | |||||
| { | { | ||||
| const bool isInput = pin->isInput; | const bool isInput = pin->isInput; | ||||
| int busIdx = 0; | int busIdx = 0; | ||||
| @@ -465,8 +465,8 @@ struct FilterComponent : public Component | |||||
| Point<float> getPinPos (int index, bool isInput) const | Point<float> getPinPos (int index, bool isInput) const | ||||
| { | { | ||||
| for (int i = 0; i < getNumChildComponents(); ++i) | |||||
| if (auto* pin = dynamic_cast<PinComponent*> (getChildComponent(i))) | |||||
| for (auto* child : getChildren()) | |||||
| if (auto* pin = dynamic_cast<PinComponent*> (child)) | |||||
| if (pin->index == index && isInput == pin->isInput) | if (pin->index == index && isInput == pin->isInput) | ||||
| return getPosition().toFloat() + pin->getBounds().getCentre().toFloat(); | return getPosition().toFloat() + pin->getBounds().getCentre().toFloat(); | ||||
| @@ -804,21 +804,19 @@ void GraphEditorPanel::createNewPlugin (const PluginDescription& desc, Point<int | |||||
| FilterComponent* GraphEditorPanel::getComponentForFilter (const uint32 filterID) const | FilterComponent* GraphEditorPanel::getComponentForFilter (const uint32 filterID) const | ||||
| { | { | ||||
| for (int i = getNumChildComponents(); --i >= 0;) | |||||
| { | |||||
| if (auto* fc = dynamic_cast<FilterComponent*> (getChildComponent (i))) | |||||
| for (auto* child : getChildren()) | |||||
| if (auto* fc = dynamic_cast<FilterComponent*> (child)) | |||||
| if (fc->pluginID == filterID) | if (fc->pluginID == filterID) | ||||
| return fc; | return fc; | ||||
| } | |||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| ConnectorComponent* GraphEditorPanel::getComponentForConnection (const AudioProcessorGraph::Connection& conn) const | ConnectorComponent* GraphEditorPanel::getComponentForConnection (const AudioProcessorGraph::Connection& conn) const | ||||
| { | { | ||||
| for (int i = getNumChildComponents(); --i >= 0;) | |||||
| for (auto* child : getChildren()) | |||||
| { | { | ||||
| if (auto* c = dynamic_cast<ConnectorComponent*> (getChildComponent (i))) | |||||
| if (auto* c = dynamic_cast<ConnectorComponent*> (child)) | |||||
| if (c->sourceFilterID == conn.sourceNodeId | if (c->sourceFilterID == conn.sourceNodeId | ||||
| && c->destFilterID == conn.destNodeId | && c->destFilterID == conn.destNodeId | ||||
| && c->sourceFilterChannel == conn.sourceChannelIndex | && c->sourceFilterChannel == conn.sourceChannelIndex | ||||
| @@ -831,8 +829,8 @@ ConnectorComponent* GraphEditorPanel::getComponentForConnection (const AudioProc | |||||
| PinComponent* GraphEditorPanel::findPinAt (Point<float> pos) const | PinComponent* GraphEditorPanel::findPinAt (Point<float> pos) const | ||||
| { | { | ||||
| for (int i = getNumChildComponents(); --i >= 0;) | |||||
| if (auto* fc = dynamic_cast<FilterComponent*> (getChildComponent (i))) | |||||
| for (auto* child : getChildren()) | |||||
| if (auto* fc = dynamic_cast<FilterComponent*> (child)) | |||||
| if (auto* pin = dynamic_cast<PinComponent*> (fc->getComponentAt (pos.toInt() - fc->getPosition()))) | if (auto* pin = dynamic_cast<PinComponent*> (fc->getComponentAt (pos.toInt() - fc->getPosition()))) | ||||
| return pin; | return pin; | ||||
| @@ -851,11 +849,9 @@ void GraphEditorPanel::changeListenerCallback (ChangeBroadcaster*) | |||||
| void GraphEditorPanel::updateComponents() | void GraphEditorPanel::updateComponents() | ||||
| { | { | ||||
| for (int i = getNumChildComponents(); --i >= 0;) | |||||
| { | |||||
| if (auto* fc = dynamic_cast<FilterComponent*> (getChildComponent (i))) | |||||
| for (auto* child : getChildren()) | |||||
| if (auto* fc = dynamic_cast<FilterComponent*> (child)) | |||||
| fc->update(); | fc->update(); | ||||
| } | |||||
| for (int i = getNumChildComponents(); --i >= 0;) | for (int i = getNumChildComponents(); --i >= 0;) | ||||
| { | { | ||||
| @@ -563,8 +563,8 @@ private: | |||||
| { | { | ||||
| int y = 0; | int y = 0; | ||||
| for (int i = getNumChildComponents(); --i >= 0;) | |||||
| y = jmax (y, getChildComponent (i)->getBottom()); | |||||
| for (auto* c : getChildren()) | |||||
| y = jmax (y, c->getBottom()); | |||||
| return y; | return y; | ||||
| } | } | ||||
| @@ -242,19 +242,17 @@ void Button::setRadioGroupId (const int newGroupId, NotificationType notificatio | |||||
| void Button::turnOffOtherButtonsInGroup (const NotificationType notification) | void Button::turnOffOtherButtonsInGroup (const NotificationType notification) | ||||
| { | { | ||||
| if (Component* const p = getParentComponent()) | |||||
| if (auto* p = getParentComponent()) | |||||
| { | { | ||||
| if (radioGroupId != 0) | if (radioGroupId != 0) | ||||
| { | { | ||||
| WeakReference<Component> deletionWatcher (this); | WeakReference<Component> deletionWatcher (this); | ||||
| for (int i = p->getNumChildComponents(); --i >= 0;) | |||||
| for (auto* c : p->getChildren()) | |||||
| { | { | ||||
| Component* const c = p->getChildComponent (i); | |||||
| if (c != this) | if (c != this) | ||||
| { | { | ||||
| if (Button* const b = dynamic_cast<Button*> (c)) | |||||
| if (auto b = dynamic_cast<Button*> (c)) | |||||
| { | { | ||||
| if (b->getRadioGroupId() == radioGroupId) | if (b->getRadioGroupId() == radioGroupId) | ||||
| { | { | ||||
| @@ -406,7 +406,7 @@ struct Component::ComponentHelpers | |||||
| for (int i = comp.childComponentList.size(); --i >= 0;) | for (int i = comp.childComponentList.size(); --i >= 0;) | ||||
| { | { | ||||
| const Component& child = *comp.childComponentList.getUnchecked(i); | |||||
| auto& child = *comp.childComponentList.getUnchecked(i); | |||||
| if (child.isVisible() && ! child.isTransformed()) | if (child.isVisible() && ! child.isTransformed()) | ||||
| { | { | ||||
| @@ -421,7 +421,8 @@ struct Component::ComponentHelpers | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| const Point<int> childPos (child.getPosition()); | |||||
| auto childPos = child.getPosition(); | |||||
| if (clipObscuredRegions (child, g, newClip - childPos, childPos + delta)) | if (clipObscuredRegions (child, g, newClip - childPos, childPos + delta)) | ||||
| wasClipped = true; | wasClipped = true; | ||||
| } | } | ||||
| @@ -434,7 +435,7 @@ struct Component::ComponentHelpers | |||||
| static Rectangle<int> getParentOrMainMonitorBounds (const Component& comp) | static Rectangle<int> getParentOrMainMonitorBounds (const Component& comp) | ||||
| { | { | ||||
| if (Component* p = comp.getParentComponent()) | |||||
| if (auto* p = comp.getParentComponent()) | |||||
| return p->getLocalBounds(); | return p->getLocalBounds(); | ||||
| return Desktop::getInstance().getDisplays().getMainDisplay().userArea; | return Desktop::getInstance().getDisplays().getMainDisplay().userArea; | ||||
| @@ -442,31 +443,22 @@ struct Component::ComponentHelpers | |||||
| static void releaseAllCachedImageResources (Component& c) | static void releaseAllCachedImageResources (Component& c) | ||||
| { | { | ||||
| if (CachedComponentImage* cached = c.getCachedComponentImage()) | |||||
| if (auto* cached = c.getCachedComponentImage()) | |||||
| cached->releaseResources(); | cached->releaseResources(); | ||||
| for (int i = c.getNumChildComponents(); --i >= 0;) | |||||
| releaseAllCachedImageResources (*c.getChildComponent (i)); | |||||
| for (auto* child : c.childComponentList) | |||||
| releaseAllCachedImageResources (*child); | |||||
| } | } | ||||
| }; | }; | ||||
| //============================================================================== | //============================================================================== | ||||
| Component::Component() noexcept | Component::Component() noexcept | ||||
| : parentComponent (nullptr), | |||||
| lookAndFeel (nullptr), | |||||
| effect (nullptr), | |||||
| componentFlags (0), | |||||
| componentTransparency (0) | |||||
| : componentFlags (0) | |||||
| { | { | ||||
| } | } | ||||
| Component::Component (const String& name) noexcept | Component::Component (const String& name) noexcept | ||||
| : componentName (name), | |||||
| parentComponent (nullptr), | |||||
| lookAndFeel (nullptr), | |||||
| effect (nullptr), | |||||
| componentFlags (0), | |||||
| componentTransparency (0) | |||||
| : componentName (name), componentFlags (0) | |||||
| { | { | ||||
| } | } | ||||
| @@ -895,11 +887,11 @@ void Component::toFront (const bool setAsForeground) | |||||
| } | } | ||||
| else if (parentComponent != nullptr) | else if (parentComponent != nullptr) | ||||
| { | { | ||||
| const Array<Component*>& childList = parentComponent->childComponentList; | |||||
| auto& childList = parentComponent->childComponentList; | |||||
| if (childList.getLast() != this) | if (childList.getLast() != this) | ||||
| { | { | ||||
| const int index = childList.indexOf (this); | |||||
| auto index = childList.indexOf (this); | |||||
| if (index >= 0) | if (index >= 0) | ||||
| { | { | ||||
| @@ -936,8 +928,8 @@ void Component::toBehind (Component* const other) | |||||
| if (parentComponent != nullptr) | if (parentComponent != nullptr) | ||||
| { | { | ||||
| const Array<Component*>& childList = parentComponent->childComponentList; | |||||
| const int index = childList.indexOf (this); | |||||
| auto& childList = parentComponent->childComponentList; | |||||
| auto index = childList.indexOf (this); | |||||
| if (index >= 0 && childList [index + 1] != other) | if (index >= 0 && childList [index + 1] != other) | ||||
| { | { | ||||
| @@ -977,11 +969,11 @@ void Component::toBack() | |||||
| } | } | ||||
| else if (parentComponent != nullptr) | else if (parentComponent != nullptr) | ||||
| { | { | ||||
| const Array<Component*>& childList = parentComponent->childComponentList; | |||||
| auto& childList = parentComponent->childComponentList; | |||||
| if (childList.getFirst() != this) | if (childList.getFirst() != this) | ||||
| { | { | ||||
| const int index = childList.indexOf (this); | |||||
| auto index = childList.indexOf (this); | |||||
| if (index > 0) | if (index > 0) | ||||
| { | { | ||||
| @@ -1380,7 +1372,7 @@ bool Component::hitTest (int x, int y) | |||||
| { | { | ||||
| for (int i = childComponentList.size(); --i >= 0;) | for (int i = childComponentList.size(); --i >= 0;) | ||||
| { | { | ||||
| Component& child = *childComponentList.getUnchecked (i); | |||||
| auto& child = *childComponentList.getUnchecked (i); | |||||
| if (child.isVisible() | if (child.isVisible() | ||||
| && ComponentHelpers::hitTest (child, ComponentHelpers::convertFromParentSpace (child, Point<int> (x, y)))) | && ComponentHelpers::hitTest (child, ComponentHelpers::convertFromParentSpace (child, Point<int> (x, y)))) | ||||
| @@ -1437,7 +1429,8 @@ Component* Component::getComponentAt (Point<int> position) | |||||
| { | { | ||||
| for (int i = childComponentList.size(); --i >= 0;) | for (int i = childComponentList.size(); --i >= 0;) | ||||
| { | { | ||||
| Component* child = childComponentList.getUnchecked(i); | |||||
| auto* child = childComponentList.getUnchecked(i); | |||||
| child = child->getComponentAt (ComponentHelpers::convertFromParentSpace (*child, position)); | child = child->getComponentAt (ComponentHelpers::convertFromParentSpace (*child, position)); | ||||
| if (child != nullptr) | if (child != nullptr) | ||||
| @@ -1607,7 +1600,7 @@ int Component::getNumChildComponents() const noexcept | |||||
| Component* Component::getChildComponent (const int index) const noexcept | Component* Component::getChildComponent (const int index) const noexcept | ||||
| { | { | ||||
| return childComponentList [index]; | |||||
| return childComponentList[index]; | |||||
| } | } | ||||
| int Component::getIndexOfChildComponent (const Component* const child) const noexcept | int Component::getIndexOfChildComponent (const Component* const child) const noexcept | ||||
| @@ -1617,12 +1610,9 @@ int Component::getIndexOfChildComponent (const Component* const child) const noe | |||||
| Component* Component::findChildWithID (StringRef targetID) const noexcept | Component* Component::findChildWithID (StringRef targetID) const noexcept | ||||
| { | { | ||||
| for (int i = childComponentList.size(); --i >= 0;) | |||||
| { | |||||
| auto* c = childComponentList.getUnchecked(i); | |||||
| for (auto* c : childComponentList) | |||||
| if (c->componentID == targetID) | if (c->componentID == targetID) | ||||
| return c; | return c; | ||||
| } | |||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| @@ -1979,7 +1969,7 @@ void Component::paintComponentAndChildren (Graphics& g) | |||||
| for (int i = 0; i < childComponentList.size(); ++i) | for (int i = 0; i < childComponentList.size(); ++i) | ||||
| { | { | ||||
| Component& child = *childComponentList.getUnchecked (i); | |||||
| auto& child = *childComponentList.getUnchecked (i); | |||||
| if (child.isVisible()) | if (child.isVisible()) | ||||
| { | { | ||||
| @@ -2007,7 +1997,7 @@ void Component::paintComponentAndChildren (Graphics& g) | |||||
| for (int j = i + 1; j < childComponentList.size(); ++j) | for (int j = i + 1; j < childComponentList.size(); ++j) | ||||
| { | { | ||||
| const Component& sibling = *childComponentList.getUnchecked (j); | |||||
| auto& sibling = *childComponentList.getUnchecked (j); | |||||
| if (sibling.flags.opaqueFlag && sibling.isVisible() && sibling.affineTransform == nullptr) | if (sibling.flags.opaqueFlag && sibling.isVisible() && sibling.affineTransform == nullptr) | ||||
| { | { | ||||
| @@ -613,7 +613,7 @@ public: | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Returns the number of child components that this component contains. | /** Returns the number of child components that this component contains. | ||||
| @see getChildComponent, getIndexOfChildComponent | |||||
| @see getChildren, getChildComponent, getIndexOfChildComponent | |||||
| */ | */ | ||||
| int getNumChildComponents() const noexcept; | int getNumChildComponents() const noexcept; | ||||
| @@ -624,7 +624,7 @@ public: | |||||
| If the index is out-of-range, this will return a null pointer. | If the index is out-of-range, this will return a null pointer. | ||||
| @see getNumChildComponents, getIndexOfChildComponent | |||||
| @see getChildren, getNumChildComponents, getIndexOfChildComponent | |||||
| */ | */ | ||||
| Component* getChildComponent (int index) const noexcept; | Component* getChildComponent (int index) const noexcept; | ||||
| @@ -635,10 +635,15 @@ public: | |||||
| Returns -1 if the component passed-in is not a child of this component. | Returns -1 if the component passed-in is not a child of this component. | ||||
| @see getNumChildComponents, getChildComponent, addChildComponent, toFront, toBack, toBehind | |||||
| @see getChildren, getNumChildComponents, getChildComponent, addChildComponent, toFront, toBack, toBehind | |||||
| */ | */ | ||||
| int getIndexOfChildComponent (const Component* child) const noexcept; | int getIndexOfChildComponent (const Component* child) const noexcept; | ||||
| /** Provides access to the underlying array of child components. | |||||
| The most likely reason you may want to use this is for iteration in a range-based for loop. | |||||
| */ | |||||
| const Array<Component*>& getChildren() const noexcept { return childComponentList; } | |||||
| /** Looks for a child component with the specified ID. | /** Looks for a child component with the specified ID. | ||||
| @see setComponentID, getComponentID | @see setComponentID, getComponentID | ||||
| */ | */ | ||||
| @@ -2251,14 +2256,14 @@ private: | |||||
| //============================================================================== | //============================================================================== | ||||
| String componentName, componentID; | String componentName, componentID; | ||||
| Component* parentComponent; | |||||
| Component* parentComponent = nullptr; | |||||
| Rectangle<int> boundsRelativeToParent; | Rectangle<int> boundsRelativeToParent; | ||||
| ScopedPointer<Positioner> positioner; | ScopedPointer<Positioner> positioner; | ||||
| ScopedPointer<AffineTransform> affineTransform; | ScopedPointer<AffineTransform> affineTransform; | ||||
| Array<Component*> childComponentList; | Array<Component*> childComponentList; | ||||
| LookAndFeel* lookAndFeel; | |||||
| LookAndFeel* lookAndFeel = nullptr; | |||||
| MouseCursor cursor; | MouseCursor cursor; | ||||
| ImageEffectFilter* effect; | |||||
| ImageEffectFilter* effect = nullptr; | |||||
| ScopedPointer<CachedComponentImage> cachedImage; | ScopedPointer<CachedComponentImage> cachedImage; | ||||
| class MouseListenerList; | class MouseListenerList; | ||||
| @@ -2304,7 +2309,7 @@ private: | |||||
| ComponentFlags flags; | ComponentFlags flags; | ||||
| }; | }; | ||||
| uint8 componentTransparency; | |||||
| uint8 componentTransparency = 0; | |||||
| //============================================================================== | //============================================================================== | ||||
| void internalMouseEnter (MouseInputSource, Point<float>, Time); | void internalMouseEnter (MouseInputSource, Point<float>, Time); | ||||
| @@ -140,8 +140,8 @@ bool Drawable::replaceColour (Colour original, Colour replacement) | |||||
| { | { | ||||
| bool changed = false; | bool changed = false; | ||||
| for (int i = getNumChildComponents(); --i >= 0;) | |||||
| if (auto* d = dynamic_cast<Drawable*> (getChildComponent(i))) | |||||
| for (auto* c : getChildren()) | |||||
| if (auto* d = dynamic_cast<Drawable*> (c)) | |||||
| changed = d->replaceColour (original, replacement) || changed; | changed = d->replaceColour (original, replacement) || changed; | ||||
| return changed; | return changed; | ||||
| @@ -25,8 +25,7 @@ | |||||
| */ | */ | ||||
| DrawableComposite::DrawableComposite() | DrawableComposite::DrawableComposite() | ||||
| : bounds (Point<float>(), Point<float> (100.0f, 0.0f), Point<float> (0.0f, 100.0f)), | |||||
| updateBoundsReentrant (false) | |||||
| : bounds (Point<float>(), Point<float> (100.0f, 0.0f), Point<float> (0.0f, 100.0f)) | |||||
| { | { | ||||
| setContentArea (RelativeRectangle (Rectangle<float> (0.0f, 0.0f, 100.0f, 100.0f))); | setContentArea (RelativeRectangle (Rectangle<float> (0.0f, 0.0f, 100.0f, 100.0f))); | ||||
| } | } | ||||
| @@ -35,11 +34,10 @@ DrawableComposite::DrawableComposite (const DrawableComposite& other) | |||||
| : Drawable (other), | : Drawable (other), | ||||
| bounds (other.bounds), | bounds (other.bounds), | ||||
| markersX (other.markersX), | markersX (other.markersX), | ||||
| markersY (other.markersY), | |||||
| updateBoundsReentrant (false) | |||||
| markersY (other.markersY) | |||||
| { | { | ||||
| for (int i = 0; i < other.getNumChildComponents(); ++i) | |||||
| if (const Drawable* const d = dynamic_cast<const Drawable*> (other.getChildComponent(i))) | |||||
| for (auto* c : other.getChildren()) | |||||
| if (auto* d = dynamic_cast<const Drawable*> (c)) | |||||
| addAndMakeVisible (d->createCopy()); | addAndMakeVisible (d->createCopy()); | ||||
| } | } | ||||
| @@ -58,8 +56,8 @@ Rectangle<float> DrawableComposite::getDrawableBounds() const | |||||
| { | { | ||||
| Rectangle<float> r; | Rectangle<float> r; | ||||
| for (int i = getNumChildComponents(); --i >= 0;) | |||||
| if (const Drawable* const d = dynamic_cast<const Drawable*> (getChildComponent(i))) | |||||
| for (auto* c : getChildren()) | |||||
| if (auto* d = dynamic_cast<const Drawable*> (c)) | |||||
| r = r.getUnion (d->isTransformed() ? d->getDrawableBounds().transformedBy (d->getTransform()) | r = r.getUnion (d->isTransformed() ? d->getDrawableBounds().transformedBy (d->getTransform()) | ||||
| : d->getDrawableBounds()); | : d->getDrawableBounds()); | ||||
| @@ -96,7 +94,7 @@ void DrawableComposite::setBoundingBox (const RelativeParallelogram& newBounds) | |||||
| if (bounds.isDynamic()) | if (bounds.isDynamic()) | ||||
| { | { | ||||
| Drawable::Positioner<DrawableComposite>* const p = new Drawable::Positioner<DrawableComposite> (*this); | |||||
| auto p = new Drawable::Positioner<DrawableComposite> (*this); | |||||
| setPositioner (p); | setPositioner (p); | ||||
| p->apply(); | p->apply(); | ||||
| } | } | ||||
| @@ -135,11 +133,11 @@ void DrawableComposite::recalculateCoordinates (Expression::Scope* scope) | |||||
| Point<float> resolved[3]; | Point<float> resolved[3]; | ||||
| bounds.resolveThreePoints (resolved, scope); | bounds.resolveThreePoints (resolved, scope); | ||||
| const Rectangle<float> content (getContentArea().resolve (scope)); | |||||
| auto content = getContentArea().resolve (scope); | |||||
| AffineTransform t (AffineTransform::fromTargetPoints (content.getX(), content.getY(), resolved[0].x, resolved[0].y, | |||||
| content.getRight(), content.getY(), resolved[1].x, resolved[1].y, | |||||
| content.getX(), content.getBottom(), resolved[2].x, resolved[2].y)); | |||||
| auto t = AffineTransform::fromTargetPoints (content.getX(), content.getY(), resolved[0].x, resolved[0].y, | |||||
| content.getRight(), content.getY(), resolved[1].x, resolved[1].y, | |||||
| content.getX(), content.getBottom(), resolved[2].x, resolved[2].y); | |||||
| if (t.isSingularity()) | if (t.isSingularity()) | ||||
| t = AffineTransform(); | t = AffineTransform(); | ||||
| @@ -149,8 +147,7 @@ void DrawableComposite::recalculateCoordinates (Expression::Scope* scope) | |||||
| void DrawableComposite::parentHierarchyChanged() | void DrawableComposite::parentHierarchyChanged() | ||||
| { | { | ||||
| DrawableComposite* parent = getParent(); | |||||
| if (parent != nullptr) | |||||
| if (auto* parent = getParent()) | |||||
| originRelativeToComponent = parent->originRelativeToComponent - getPosition(); | originRelativeToComponent = parent->originRelativeToComponent - getPosition(); | ||||
| } | } | ||||
| @@ -172,10 +169,10 @@ void DrawableComposite::updateBoundsToFitChildren() | |||||
| Rectangle<int> childArea; | Rectangle<int> childArea; | ||||
| for (int i = getNumChildComponents(); --i >= 0;) | |||||
| childArea = childArea.getUnion (getChildComponent(i)->getBoundsInParent()); | |||||
| for (auto* c : getChildren()) | |||||
| childArea = childArea.getUnion (c->getBoundsInParent()); | |||||
| const Point<int> delta (childArea.getPosition()); | |||||
| auto delta = childArea.getPosition(); | |||||
| childArea += getPosition(); | childArea += getPosition(); | ||||
| if (childArea != getBounds()) | if (childArea != getBounds()) | ||||
| @@ -184,9 +181,8 @@ void DrawableComposite::updateBoundsToFitChildren() | |||||
| { | { | ||||
| originRelativeToComponent -= delta; | originRelativeToComponent -= delta; | ||||
| for (int i = getNumChildComponents(); --i >= 0;) | |||||
| if (Component* const c = getChildComponent(i)) | |||||
| c->setBounds (c->getBounds() - delta); | |||||
| for (auto* c : getChildren()) | |||||
| c->setBounds (c->getBounds() - delta); | |||||
| } | } | ||||
| setBounds (childArea); | setBounds (childArea); | ||||
| @@ -306,9 +302,9 @@ ValueTree DrawableComposite::createValueTree (ComponentBuilder::ImageProvider* i | |||||
| ValueTree childList (v.getChildListCreating (nullptr)); | ValueTree childList (v.getChildListCreating (nullptr)); | ||||
| for (int i = 0; i < getNumChildComponents(); ++i) | |||||
| for (auto* c : getChildren()) | |||||
| { | { | ||||
| const Drawable* const d = dynamic_cast<const Drawable*> (getChildComponent(i)); | |||||
| auto* d = dynamic_cast<const Drawable*> (c); | |||||
| jassert (d != nullptr); // You can't save a mix of Drawables and normal components! | jassert (d != nullptr); // You can't save a mix of Drawables and normal components! | ||||
| childList.addChild (d->createValueTree (imageProvider), -1, nullptr); | childList.addChild (d->createValueTree (imageProvider), -1, nullptr); | ||||
| @@ -324,11 +320,10 @@ Path DrawableComposite::getOutlineAsPath() const | |||||
| { | { | ||||
| Path p; | Path p; | ||||
| for (int i = 0; i < getNumChildComponents(); ++i) | |||||
| if (auto* childDrawable = dynamic_cast<Drawable*> (getChildComponent (i))) | |||||
| p.addPath (childDrawable->getOutlineAsPath()); | |||||
| for (auto* c : getChildren()) | |||||
| if (auto* d = dynamic_cast<Drawable*> (c)) | |||||
| p.addPath (d->getOutlineAsPath()); | |||||
| p.applyTransform (getTransform()); | p.applyTransform (getTransform()); | ||||
| return p; | return p; | ||||
| } | } | ||||
| @@ -148,7 +148,7 @@ private: | |||||
| //============================================================================== | //============================================================================== | ||||
| RelativeParallelogram bounds; | RelativeParallelogram bounds; | ||||
| MarkerList markersX, markersY; | MarkerList markersX, markersY; | ||||
| bool updateBoundsReentrant; | |||||
| bool updateBoundsReentrant = false; | |||||
| friend class Drawable::Positioner<DrawableComposite>; | friend class Drawable::Positioner<DrawableComposite>; | ||||
| bool registerCoordinates (RelativeCoordinatePositionerBase&); | bool registerCoordinates (RelativeCoordinatePositionerBase&); | ||||
| @@ -30,46 +30,40 @@ namespace KeyboardFocusHelpers | |||||
| // left-to-right and then top-to-bottom. | // left-to-right and then top-to-bottom. | ||||
| struct ScreenPositionComparator | struct ScreenPositionComparator | ||||
| { | { | ||||
| static int compareElements (const Component* const first, const Component* const second) | |||||
| static int compareElements (const Component* first, const Component* second) | |||||
| { | { | ||||
| const int explicitOrder1 = getOrder (first); | |||||
| const int explicitOrder2 = getOrder (second); | |||||
| auto explicitOrder1 = getOrder (first); | |||||
| auto explicitOrder2 = getOrder (second); | |||||
| if (explicitOrder1 != explicitOrder2) | if (explicitOrder1 != explicitOrder2) | ||||
| return explicitOrder1 - explicitOrder2; | return explicitOrder1 - explicitOrder2; | ||||
| const int yDiff = first->getY() - second->getY(); | |||||
| auto yDiff = first->getY() - second->getY(); | |||||
| return yDiff == 0 ? first->getX() - second->getX() | return yDiff == 0 ? first->getX() - second->getX() | ||||
| : yDiff; | : yDiff; | ||||
| } | } | ||||
| static int getOrder (const Component* const c) | |||||
| static int getOrder (const Component* c) | |||||
| { | { | ||||
| const int order = c->getExplicitFocusOrder(); | |||||
| auto order = c->getExplicitFocusOrder(); | |||||
| return order > 0 ? order : (std::numeric_limits<int>::max() / 2); | return order > 0 ? order : (std::numeric_limits<int>::max() / 2); | ||||
| } | } | ||||
| }; | }; | ||||
| static void findAllFocusableComponents (Component* const parent, Array <Component*>& comps) | |||||
| static void findAllFocusableComponents (Component* parent, Array<Component*>& comps) | |||||
| { | { | ||||
| if (parent->getNumChildComponents() > 0) | |||||
| if (parent->getNumChildComponents() != 0) | |||||
| { | { | ||||
| Array <Component*> localComps; | |||||
| Array<Component*> localComps; | |||||
| ScreenPositionComparator comparator; | ScreenPositionComparator comparator; | ||||
| for (int i = parent->getNumChildComponents(); --i >= 0;) | |||||
| { | |||||
| Component* const c = parent->getChildComponent (i); | |||||
| for (auto* c : parent->getChildren()) | |||||
| if (c->isVisible() && c->isEnabled()) | if (c->isVisible() && c->isEnabled()) | ||||
| localComps.addSorted (comparator, c); | localComps.addSorted (comparator, c); | ||||
| } | |||||
| for (int i = 0; i < localComps.size(); ++i) | |||||
| for (auto* c : localComps) | |||||
| { | { | ||||
| Component* const c = localComps.getUnchecked (i); | |||||
| if (c->getWantsKeyboardFocus()) | if (c->getWantsKeyboardFocus()) | ||||
| comps.add (c); | comps.add (c); | ||||
| @@ -90,18 +84,16 @@ namespace KeyboardFocusHelpers | |||||
| return c; | return c; | ||||
| } | } | ||||
| static Component* getIncrementedComponent (Component* const current, const int delta) | |||||
| static Component* getIncrementedComponent (Component* current, int delta) | |||||
| { | { | ||||
| Component* focusContainer = findFocusContainer (current); | |||||
| if (focusContainer != nullptr) | |||||
| if (auto* focusContainer = findFocusContainer (current)) | |||||
| { | { | ||||
| Array <Component*> comps; | |||||
| Array<Component*> comps; | |||||
| KeyboardFocusHelpers::findAllFocusableComponents (focusContainer, comps); | KeyboardFocusHelpers::findAllFocusableComponents (focusContainer, comps); | ||||
| if (comps.size() > 0) | |||||
| if (! comps.isEmpty()) | |||||
| { | { | ||||
| const int index = comps.indexOf (current); | |||||
| auto index = comps.indexOf (current); | |||||
| return comps [(index + comps.size() + delta) % comps.size()]; | return comps [(index + comps.size() + delta) % comps.size()]; | ||||
| } | } | ||||
| } | } | ||||
| @@ -128,7 +120,7 @@ Component* KeyboardFocusTraverser::getPreviousComponent (Component* current) | |||||
| Component* KeyboardFocusTraverser::getDefaultComponent (Component* parentComponent) | Component* KeyboardFocusTraverser::getDefaultComponent (Component* parentComponent) | ||||
| { | { | ||||
| Array <Component*> comps; | |||||
| Array<Component*> comps; | |||||
| if (parentComponent != nullptr) | if (parentComponent != nullptr) | ||||
| KeyboardFocusHelpers::findAllFocusableComponents (parentComponent, comps); | KeyboardFocusHelpers::findAllFocusableComponents (parentComponent, comps); | ||||
| @@ -52,9 +52,9 @@ namespace ComponentBuilderHelpers | |||||
| if (c.getComponentID() == compId) | if (c.getComponentID() == compId) | ||||
| return &c; | return &c; | ||||
| for (int i = c.getNumChildComponents(); --i >= 0;) | |||||
| if (Component* const child = findComponentWithID (*c.getChildComponent (i), compId)) | |||||
| return child; | |||||
| for (auto* child : c.getChildren()) | |||||
| if (auto* found = findComponentWithID (*child, compId)) | |||||
| return found; | |||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| @@ -238,7 +238,7 @@ void ComponentBuilder::updateChildComponents (Component& parent, const ValueTree | |||||
| { | { | ||||
| using namespace ComponentBuilderHelpers; | using namespace ComponentBuilderHelpers; | ||||
| const int numExistingChildComps = parent.getNumChildComponents(); | |||||
| auto numExistingChildComps = parent.getNumChildComponents(); | |||||
| Array<Component*> componentsInOrder; | Array<Component*> componentsInOrder; | ||||
| componentsInOrder.ensureStorageAllocated (numExistingChildComps); | componentsInOrder.ensureStorageAllocated (numExistingChildComps); | ||||
| @@ -250,15 +250,16 @@ void ComponentBuilder::updateChildComponents (Component& parent, const ValueTree | |||||
| for (int i = 0; i < numExistingChildComps; ++i) | for (int i = 0; i < numExistingChildComps; ++i) | ||||
| existingComponents.add (parent.getChildComponent (i)); | existingComponents.add (parent.getChildComponent (i)); | ||||
| const int newNumChildren = children.getNumChildren(); | |||||
| auto newNumChildren = children.getNumChildren(); | |||||
| for (int i = 0; i < newNumChildren; ++i) | for (int i = 0; i < newNumChildren; ++i) | ||||
| { | { | ||||
| const ValueTree childState (children.getChild (i)); | |||||
| Component* c = removeComponentWithID (existingComponents, getStateId (childState)); | |||||
| auto childState = children.getChild (i); | |||||
| auto* c = removeComponentWithID (existingComponents, getStateId (childState)); | |||||
| if (c == nullptr) | if (c == nullptr) | ||||
| { | { | ||||
| if (TypeHandler* const type = getHandlerForState (childState)) | |||||
| if (auto* type = getHandlerForState (childState)) | |||||
| c = ComponentBuilderHelpers::createNewComponent (*type, childState, &parent); | c = ComponentBuilderHelpers::createNewComponent (*type, childState, &parent); | ||||
| else | else | ||||
| jassertfalse; | jassertfalse; | ||||
| @@ -143,7 +143,7 @@ void MultiDocumentPanel::addWindow (Component* component) | |||||
| int x = 4; | int x = 4; | ||||
| if (Component* const topComp = getChildComponent (getNumChildComponents() - 1)) | |||||
| if (auto* topComp = getChildren().getLast()) | |||||
| if (topComp->getX() == x && topComp->getY() == x) | if (topComp->getX() == x && topComp->getY() == x) | ||||
| x += 16; | x += 16; | ||||
| @@ -200,7 +200,7 @@ bool MultiDocumentPanel::addDocument (Component* const component, | |||||
| { | { | ||||
| addAndMakeVisible (tabComponent = new TabbedComponentInternal()); | addAndMakeVisible (tabComponent = new TabbedComponentInternal()); | ||||
| Array <Component*> temp (components); | |||||
| Array<Component*> temp (components); | |||||
| for (int i = 0; i < temp.size(); ++i) | for (int i = 0; i < temp.size(); ++i) | ||||
| tabComponent->addTab (temp[i]->getName(), docColour, temp[i], false); | tabComponent->addTab (temp[i]->getName(), docColour, temp[i], false); | ||||
| @@ -239,9 +239,9 @@ bool MultiDocumentPanel::closeDocument (Component* component, | |||||
| if (mode == FloatingWindows) | if (mode == FloatingWindows) | ||||
| { | { | ||||
| for (int i = getNumChildComponents(); --i >= 0;) | |||||
| for (auto* child : getChildren()) | |||||
| { | { | ||||
| if (MultiDocumentPanelWindow* const dw = dynamic_cast<MultiDocumentPanelWindow*> (getChildComponent (i))) | |||||
| if (auto* dw = dynamic_cast<MultiDocumentPanelWindow*> (child)) | |||||
| { | { | ||||
| if (dw->getContentComponent() == component) | if (dw->getContentComponent() == component) | ||||
| { | { | ||||
| @@ -326,8 +326,8 @@ Component* MultiDocumentPanel::getActiveDocument() const noexcept | |||||
| { | { | ||||
| if (mode == FloatingWindows) | if (mode == FloatingWindows) | ||||
| { | { | ||||
| for (int i = getNumChildComponents(); --i >= 0;) | |||||
| if (MultiDocumentPanelWindow* const dw = dynamic_cast<MultiDocumentPanelWindow*> (getChildComponent (i))) | |||||
| for (auto* child : getChildren()) | |||||
| if (auto* dw = dynamic_cast<MultiDocumentPanelWindow*> (child)) | |||||
| if (dw->isActiveWindow()) | if (dw->isActiveWindow()) | ||||
| return dw->getContentComponent(); | return dw->getContentComponent(); | ||||
| } | } | ||||
| @@ -411,7 +411,7 @@ void MultiDocumentPanel::setLayoutMode (const LayoutMode newLayoutMode) | |||||
| resized(); | resized(); | ||||
| const Array <Component*> tempComps (components); | |||||
| const Array<Component*> tempComps (components); | |||||
| components.clear(); | components.clear(); | ||||
| for (int i = 0; i < tempComps.size(); ++i) | for (int i = 0; i < tempComps.size(); ++i) | ||||
| @@ -445,8 +445,8 @@ void MultiDocumentPanel::resized() | |||||
| { | { | ||||
| if (mode == MaximisedWindowsWithTabs || components.size() == numDocsBeforeTabsUsed) | if (mode == MaximisedWindowsWithTabs || components.size() == numDocsBeforeTabsUsed) | ||||
| { | { | ||||
| for (int i = getNumChildComponents(); --i >= 0;) | |||||
| getChildComponent (i)->setBounds (getLocalBounds()); | |||||
| for (auto* child : getChildren()) | |||||
| child->setBounds (getLocalBounds()); | |||||
| } | } | ||||
| setWantsKeyboardFocus (components.size() == 0); | setWantsKeyboardFocus (components.size() == 0); | ||||
| @@ -456,8 +456,8 @@ Component* MultiDocumentPanel::getContainerComp (Component* c) const | |||||
| { | { | ||||
| if (mode == FloatingWindows) | if (mode == FloatingWindows) | ||||
| { | { | ||||
| for (int i = 0; i < getNumChildComponents(); ++i) | |||||
| if (MultiDocumentPanelWindow* const dw = dynamic_cast<MultiDocumentPanelWindow*> (getChildComponent (i))) | |||||
| for (auto* child : getChildren()) | |||||
| if (auto* dw = dynamic_cast<MultiDocumentPanelWindow*> (child)) | |||||
| if (dw->getContentComponent() == c) | if (dw->getContentComponent() == c) | ||||
| return dw; | return dw; | ||||
| } | } | ||||
| @@ -469,8 +469,8 @@ void MultiDocumentPanel::componentNameChanged (Component&) | |||||
| { | { | ||||
| if (mode == FloatingWindows) | if (mode == FloatingWindows) | ||||
| { | { | ||||
| for (int i = 0; i < getNumChildComponents(); ++i) | |||||
| if (MultiDocumentPanelWindow* const dw = dynamic_cast<MultiDocumentPanelWindow*> (getChildComponent (i))) | |||||
| for (auto* child : getChildren()) | |||||
| if (auto* dw = dynamic_cast<MultiDocumentPanelWindow*> (child)) | |||||
| dw->setName (dw->getContentComponent()->getName()); | dw->setName (dw->getContentComponent()->getName()); | ||||
| } | } | ||||
| else if (tabComponent != nullptr) | else if (tabComponent != nullptr) | ||||
| @@ -482,21 +482,21 @@ void MultiDocumentPanel::componentNameChanged (Component&) | |||||
| void MultiDocumentPanel::updateOrder() | void MultiDocumentPanel::updateOrder() | ||||
| { | { | ||||
| const Array <Component*> oldList (components); | |||||
| auto oldList = components; | |||||
| if (mode == FloatingWindows) | if (mode == FloatingWindows) | ||||
| { | { | ||||
| components.clear(); | components.clear(); | ||||
| for (int i = 0; i < getNumChildComponents(); ++i) | |||||
| if (MultiDocumentPanelWindow* const dw = dynamic_cast<MultiDocumentPanelWindow*> (getChildComponent (i))) | |||||
| for (auto* child : getChildren()) | |||||
| if (auto* dw = dynamic_cast<MultiDocumentPanelWindow*> (child)) | |||||
| components.add (dw->getContentComponent()); | components.add (dw->getContentComponent()); | ||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| if (tabComponent != nullptr) | if (tabComponent != nullptr) | ||||
| { | { | ||||
| if (Component* const current = tabComponent->getCurrentContentComponent()) | |||||
| if (auto* current = tabComponent->getCurrentContentComponent()) | |||||
| { | { | ||||
| components.removeFirstMatchingValue (current); | components.removeFirstMatchingValue (current); | ||||
| components.add (current); | components.add (current); | ||||
| @@ -221,8 +221,8 @@ void TabbedButtonBar::setOrientation (const Orientation newOrientation) | |||||
| { | { | ||||
| orientation = newOrientation; | orientation = newOrientation; | ||||
| for (int i = getNumChildComponents(); --i >= 0;) | |||||
| getChildComponent (i)->resized(); | |||||
| for (auto* child : getChildren()) | |||||
| child->resized(); | |||||
| resized(); | resized(); | ||||
| } | } | ||||
| @@ -378,9 +378,9 @@ AlertWindow* LookAndFeel_V4::createAlertWindow (const String& title, const Strin | |||||
| bounds = bounds.withSizeKeepingCentre (bounds.getWidth() + boundsOffset, bounds.getHeight() + boundsOffset); | bounds = bounds.withSizeKeepingCentre (bounds.getWidth() + boundsOffset, bounds.getHeight() + boundsOffset); | ||||
| aw->setBounds (bounds); | aw->setBounds (bounds); | ||||
| for (int i = 0, maxI = aw->getNumChildComponents(); i < maxI; ++i) | |||||
| if (auto button = dynamic_cast<TextButton*> (aw->getChildComponent(i))) | |||||
| button->setBounds (button->getBounds().withPosition (button->getX() + 25, button->getY() + 40)); | |||||
| for (auto* child : aw->getChildren()) | |||||
| if (auto button = dynamic_cast<TextButton*> (child)) | |||||
| button->setBounds (button->getBounds() + Point<int> (25, 40)); | |||||
| return aw; | return aw; | ||||
| } | } | ||||
| @@ -61,7 +61,7 @@ static NSRect flippedScreenRect (NSRect r) noexcept | |||||
| } | } | ||||
| #if JUCE_MODULE_AVAILABLE_juce_opengl | #if JUCE_MODULE_AVAILABLE_juce_opengl | ||||
| void componentPeerAboutToChange (ComponentPeer&, bool); | |||||
| void componentPeerAboutToChange (Component&, bool); | |||||
| #endif | #endif | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -672,7 +672,7 @@ public: | |||||
| { | { | ||||
| #if JUCE_MODULE_AVAILABLE_juce_opengl | #if JUCE_MODULE_AVAILABLE_juce_opengl | ||||
| if ([view window] == window) | if ([view window] == window) | ||||
| componentPeerAboutToChange (*this, (newWindow == nullptr)); | |||||
| componentPeerAboutToChange (getComponent(), newWindow == nullptr); | |||||
| #else | #else | ||||
| ignoreUnused (newWindow); | ignoreUnused (newWindow); | ||||
| #endif | #endif | ||||
| @@ -177,7 +177,7 @@ public: | |||||
| { | { | ||||
| for (int i = 0; i < getNumChildComponents(); ++i) | for (int i = 0; i < getNumChildComponents(); ++i) | ||||
| { | { | ||||
| if (ToolbarItemComponent* const tc = dynamic_cast<ToolbarItemComponent*> (getChildComponent (i))) | |||||
| if (auto* tc = dynamic_cast<ToolbarItemComponent*> (getChildComponent (i))) | |||||
| { | { | ||||
| tc->setVisible (false); | tc->setVisible (false); | ||||
| const int index = oldIndexes.removeAndReturn (i); | const int index = oldIndexes.removeAndReturn (i); | ||||
| @@ -197,9 +197,9 @@ public: | |||||
| int y = indent; | int y = indent; | ||||
| int maxX = 0; | int maxX = 0; | ||||
| for (int i = 0; i < getNumChildComponents(); ++i) | |||||
| for (auto* c : getChildren()) | |||||
| { | { | ||||
| if (ToolbarItemComponent* const tc = dynamic_cast<ToolbarItemComponent*> (getChildComponent (i))) | |||||
| if (auto* tc = dynamic_cast<ToolbarItemComponent*> (c)) | |||||
| { | { | ||||
| int preferredSize = 1, minSize = 1, maxSize = 1; | int preferredSize = 1, minSize = 1, maxSize = 1; | ||||
| @@ -101,8 +101,8 @@ public: | |||||
| addButton (TRANS("Cancel"), 0); | addButton (TRANS("Cancel"), 0); | ||||
| // (avoid return + escape keys getting processed by the buttons..) | // (avoid return + escape keys getting processed by the buttons..) | ||||
| for (int i = getNumChildComponents(); --i >= 0;) | |||||
| getChildComponent (i)->setWantsKeyboardFocus (false); | |||||
| for (auto* child : getChildren()) | |||||
| child->setWantsKeyboardFocus (false); | |||||
| setWantsKeyboardFocus (true); | setWantsKeyboardFocus (true); | ||||
| grabKeyboardFocus(); | grabKeyboardFocus(); | ||||
| @@ -113,7 +113,7 @@ public: | |||||
| lastPress = key; | lastPress = key; | ||||
| String message (TRANS("Key") + ": " + owner.getDescriptionForKeyPress (key)); | String message (TRANS("Key") + ": " + owner.getDescriptionForKeyPress (key)); | ||||
| const CommandID previousCommand = owner.getMappings().findCommandForKeyPress (key); | |||||
| auto previousCommand = owner.getMappings().findCommandForKeyPress (key); | |||||
| if (previousCommand != 0) | if (previousCommand != 0) | ||||
| message << "\n\n(" | message << "\n\n(" | ||||
| @@ -148,7 +148,7 @@ public: | |||||
| { | { | ||||
| if (newKey.isValid()) | if (newKey.isValid()) | ||||
| { | { | ||||
| const CommandID previousCommand = owner.getMappings().findCommandForKeyPress (newKey); | |||||
| auto previousCommand = owner.getMappings().findCommandForKeyPress (newKey); | |||||
| if (previousCommand == 0 || dontAskUser) | if (previousCommand == 0 || dontAskUser) | ||||
| { | { | ||||
| @@ -209,14 +209,14 @@ private: | |||||
| class KeyMappingEditorComponent::ItemComponent : public Component | class KeyMappingEditorComponent::ItemComponent : public Component | ||||
| { | { | ||||
| public: | public: | ||||
| ItemComponent (KeyMappingEditorComponent& kec, const CommandID command) | |||||
| ItemComponent (KeyMappingEditorComponent& kec, CommandID command) | |||||
| : owner (kec), commandID (command) | : owner (kec), commandID (command) | ||||
| { | { | ||||
| setInterceptsMouseClicks (false, true); | setInterceptsMouseClicks (false, true); | ||||
| const bool isReadOnly = owner.isCommandReadOnly (commandID); | const bool isReadOnly = owner.isCommandReadOnly (commandID); | ||||
| const Array<KeyPress> keyPresses (owner.getMappings().getKeyPressesAssignedToCommand (commandID)); | |||||
| auto keyPresses = owner.getMappings().getKeyPressesAssignedToCommand (commandID); | |||||
| for (int i = 0; i < jmin ((int) maxNumAssignments, keyPresses.size()); ++i) | for (int i = 0; i < jmin ((int) maxNumAssignments, keyPresses.size()); ++i) | ||||
| addKeyPressButton (owner.getDescriptionForKeyPress (keyPresses.getReference (i)), i, isReadOnly); | addKeyPressButton (owner.getDescriptionForKeyPress (keyPresses.getReference (i)), i, isReadOnly); | ||||
| @@ -226,7 +226,7 @@ public: | |||||
| void addKeyPressButton (const String& desc, const int index, const bool isReadOnly) | void addKeyPressButton (const String& desc, const int index, const bool isReadOnly) | ||||
| { | { | ||||
| ChangeKeyButton* const b = new ChangeKeyButton (owner, commandID, desc, index); | |||||
| auto* b = new ChangeKeyButton (owner, commandID, desc, index); | |||||
| keyChangeButtons.add (b); | keyChangeButtons.add (b); | ||||
| b->setEnabled (! isReadOnly); | b->setEnabled (! isReadOnly); | ||||
| @@ -250,7 +250,7 @@ public: | |||||
| for (int i = keyChangeButtons.size(); --i >= 0;) | for (int i = keyChangeButtons.size(); --i >= 0;) | ||||
| { | { | ||||
| ChangeKeyButton* const b = keyChangeButtons.getUnchecked(i); | |||||
| auto* b = keyChangeButtons.getUnchecked(i); | |||||
| b->fitToContent (getHeight() - 2); | b->fitToContent (getHeight() - 2); | ||||
| b->setTopRightPosition (x, 1); | b->setTopRightPosition (x, 1); | ||||
| @@ -272,7 +272,7 @@ private: | |||||
| class KeyMappingEditorComponent::MappingItem : public TreeViewItem | class KeyMappingEditorComponent::MappingItem : public TreeViewItem | ||||
| { | { | ||||
| public: | public: | ||||
| MappingItem (KeyMappingEditorComponent& kec, const CommandID command) | |||||
| MappingItem (KeyMappingEditorComponent& kec, CommandID command) | |||||
| : owner (kec), commandID (command) | : owner (kec), commandID (command) | ||||
| {} | {} | ||||
| @@ -314,13 +314,9 @@ public: | |||||
| if (isNowOpen) | if (isNowOpen) | ||||
| { | { | ||||
| if (getNumSubItems() == 0) | if (getNumSubItems() == 0) | ||||
| { | |||||
| const Array<CommandID> commands (owner.getCommandManager().getCommandsInCategory (categoryName)); | |||||
| for (int i = 0; i < commands.size(); ++i) | |||||
| if (owner.shouldCommandBeIncluded (commands.getUnchecked(i))) | |||||
| addSubItem (new MappingItem (owner, commands.getUnchecked(i))); | |||||
| } | |||||
| for (auto command : owner.getCommandManager().getCommandsInCategory (categoryName)) | |||||
| if (owner.shouldCommandBeIncluded (command)) | |||||
| addSubItem (new MappingItem (owner, command)); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -360,19 +356,16 @@ public: | |||||
| const OpennessRestorer opennessRestorer (*this); | const OpennessRestorer opennessRestorer (*this); | ||||
| clearSubItems(); | clearSubItems(); | ||||
| const StringArray categories (owner.getCommandManager().getCommandCategories()); | |||||
| for (int i = 0; i < categories.size(); ++i) | |||||
| for (auto category : owner.getCommandManager().getCommandCategories()) | |||||
| { | { | ||||
| const Array<CommandID> commands (owner.getCommandManager().getCommandsInCategory (categories[i])); | |||||
| int count = 0; | int count = 0; | ||||
| for (int j = 0; j < commands.size(); ++j) | |||||
| if (owner.shouldCommandBeIncluded (commands.getUnchecked(j))) | |||||
| for (auto command : owner.getCommandManager().getCommandsInCategory (category)) | |||||
| if (owner.shouldCommandBeIncluded (command)) | |||||
| ++count; | ++count; | ||||
| if (count > 0) | if (count > 0) | ||||
| addSubItem (new CategoryItem (owner, categories[i])); | |||||
| addSubItem (new CategoryItem (owner, category)); | |||||
| } | } | ||||
| } | } | ||||
| @@ -459,14 +452,14 @@ void KeyMappingEditorComponent::resized() | |||||
| //============================================================================== | //============================================================================== | ||||
| bool KeyMappingEditorComponent::shouldCommandBeIncluded (const CommandID commandID) | bool KeyMappingEditorComponent::shouldCommandBeIncluded (const CommandID commandID) | ||||
| { | { | ||||
| const ApplicationCommandInfo* const ci = mappings.getCommandManager().getCommandForID (commandID); | |||||
| auto* ci = mappings.getCommandManager().getCommandForID (commandID); | |||||
| return ci != nullptr && (ci->flags & ApplicationCommandInfo::hiddenFromKeyEditor) == 0; | return ci != nullptr && (ci->flags & ApplicationCommandInfo::hiddenFromKeyEditor) == 0; | ||||
| } | } | ||||
| bool KeyMappingEditorComponent::isCommandReadOnly (const CommandID commandID) | bool KeyMappingEditorComponent::isCommandReadOnly (const CommandID commandID) | ||||
| { | { | ||||
| const ApplicationCommandInfo* const ci = mappings.getCommandManager().getCommandForID (commandID); | |||||
| auto* ci = mappings.getCommandManager().getCommandForID (commandID); | |||||
| return ci != nullptr && (ci->flags & ApplicationCommandInfo::readOnlyInKeyEditor) != 0; | return ci != nullptr && (ci->flags & ApplicationCommandInfo::readOnlyInKeyEditor) != 0; | ||||
| } | } | ||||
| @@ -53,13 +53,13 @@ private: | |||||
| Array<Component*> alreadyDone; | Array<Component*> alreadyDone; | ||||
| for (int i = TopLevelWindow::getNumTopLevelWindows(); --i >= 0;) | for (int i = TopLevelWindow::getNumTopLevelWindows(); --i >= 0;) | ||||
| if (Component* c = TopLevelWindow::getTopLevelWindow(i)) | |||||
| if (auto* c = TopLevelWindow::getTopLevelWindow(i)) | |||||
| repaintAndResizeAllComps (c, alreadyDone); | repaintAndResizeAllComps (c, alreadyDone); | ||||
| Desktop& desktop = Desktop::getInstance(); | |||||
| auto& desktop = Desktop::getInstance(); | |||||
| for (int i = desktop.getNumComponents(); --i >= 0;) | for (int i = desktop.getNumComponents(); --i >= 0;) | ||||
| if (Component* c = desktop.getComponent(i)) | |||||
| if (auto* c = desktop.getComponent(i)) | |||||
| repaintAndResizeAllComps (c, alreadyDone); | repaintAndResizeAllComps (c, alreadyDone); | ||||
| } | } | ||||
| @@ -73,7 +73,7 @@ private: | |||||
| for (int i = c->getNumChildComponents(); --i >= 0;) | for (int i = c->getNumChildComponents(); --i >= 0;) | ||||
| { | { | ||||
| if (Component* child = c->getChildComponent(i)) | |||||
| if (auto* child = c->getChildComponent(i)) | |||||
| { | { | ||||
| repaintAndResizeAllComps (child, alreadyDone); | repaintAndResizeAllComps (child, alreadyDone); | ||||
| alreadyDone.add (child); | alreadyDone.add (child); | ||||
| @@ -124,7 +124,7 @@ LiveValueBase::~LiveValueBase() | |||||
| //============================================================================== | //============================================================================== | ||||
| LivePropertyEditorBase::LivePropertyEditorBase (LiveValueBase& v, CodeDocument& d) | LivePropertyEditorBase::LivePropertyEditorBase (LiveValueBase& v, CodeDocument& d) | ||||
| : value (v), resetButton ("reset"), document (d), sourceEditor (document, &tokeniser), wasHex (false) | |||||
| : value (v), document (d), sourceEditor (document, &tokeniser) | |||||
| { | { | ||||
| setSize (600, 100); | setSize (600, 100); | ||||
| @@ -155,11 +155,11 @@ void LivePropertyEditorBase::paint (Graphics& g) | |||||
| void LivePropertyEditorBase::resized() | void LivePropertyEditorBase::resized() | ||||
| { | { | ||||
| Rectangle<int> r (getLocalBounds().reduced (0, 3).withTrimmedBottom (1)); | |||||
| auto r = getLocalBounds().reduced (0, 3).withTrimmedBottom (1); | |||||
| Rectangle<int> left (r.removeFromLeft (jmax (200, r.getWidth() / 3))); | |||||
| auto left = r.removeFromLeft (jmax (200, r.getWidth() / 3)); | |||||
| Rectangle<int> top (left.removeFromTop (25)); | |||||
| auto top = left.removeFromTop (25); | |||||
| resetButton.setBounds (top.removeFromRight (35).reduced (0, 3)); | resetButton.setBounds (top.removeFromRight (35).reduced (0, 3)); | ||||
| name.setBounds (top); | name.setBounds (top); | ||||
| @@ -208,8 +208,8 @@ void LivePropertyEditorBase::selectOriginalValue() | |||||
| void LivePropertyEditorBase::findOriginalValueInCode() | void LivePropertyEditorBase::findOriginalValueInCode() | ||||
| { | { | ||||
| CodeDocument::Position pos (document, value.sourceLine, 0); | CodeDocument::Position pos (document, value.sourceLine, 0); | ||||
| String line (pos.getLineText()); | |||||
| String::CharPointerType p (line.getCharPointer()); | |||||
| auto line = pos.getLineText(); | |||||
| auto p = line.getCharPointer(); | |||||
| p = CharacterFunctions::find (p, CharPointer_ASCII ("JUCE_LIVE_CONSTANT")); | p = CharacterFunctions::find (p, CharPointer_ASCII ("JUCE_LIVE_CONSTANT")); | ||||
| @@ -233,13 +233,13 @@ void LivePropertyEditorBase::findOriginalValueInCode() | |||||
| if (p.getAndAdvance() == '(') | if (p.getAndAdvance() == '(') | ||||
| { | { | ||||
| String::CharPointerType start (p), end (p); | |||||
| auto start = p, end = p; | |||||
| int depth = 1; | int depth = 1; | ||||
| while (! end.isEmpty()) | while (! end.isEmpty()) | ||||
| { | { | ||||
| const juce_wchar c = end.getAndAdvance(); | |||||
| auto c = end.getAndAdvance(); | |||||
| if (c == '(') ++depth; | if (c == '(') ++depth; | ||||
| if (c == ')') --depth; | if (c == ')') --depth; | ||||
| @@ -328,11 +328,11 @@ public: | |||||
| void updateItems (ValueList& list) | void updateItems (ValueList& list) | ||||
| { | { | ||||
| if (ValueListHolderComponent* l = dynamic_cast<ValueListHolderComponent*> (viewport.getViewedComponent())) | |||||
| if (auto* l = dynamic_cast<ValueListHolderComponent*> (viewport.getViewedComponent())) | |||||
| { | { | ||||
| while (l->getNumChildComponents() < list.values.size()) | while (l->getNumChildComponents() < list.values.size()) | ||||
| { | { | ||||
| if (LiveValueBase* v = list.values [l->getNumChildComponents()]) | |||||
| if (auto* v = list.values [l->getNumChildComponents()]) | |||||
| l->addItem (viewport.getMaximumVisibleWidth(), *v, list.getDocument (v->sourceFile)); | l->addItem (viewport.getMaximumVisibleWidth(), *v, list.getDocument (v->sourceFile)); | ||||
| else | else | ||||
| break; | break; | ||||
| @@ -346,7 +346,7 @@ public: | |||||
| { | { | ||||
| DocumentWindow::resized(); | DocumentWindow::resized(); | ||||
| if (ValueListHolderComponent* l = dynamic_cast<ValueListHolderComponent*> (viewport.getViewedComponent())) | |||||
| if (auto* l = dynamic_cast<ValueListHolderComponent*> (viewport.getViewedComponent())) | |||||
| l->layout (viewport.getMaximumVisibleWidth()); | l->layout (viewport.getMaximumVisibleWidth()); | ||||
| } | } | ||||
| @@ -379,7 +379,7 @@ CodeDocument& ValueList::getDocument (const File& file) | |||||
| if (index >= 0) | if (index >= 0) | ||||
| return *documents.getUnchecked (index); | return *documents.getUnchecked (index); | ||||
| CodeDocument* doc = documents.add (new CodeDocument()); | |||||
| auto* doc = documents.add (new CodeDocument()); | |||||
| documentFiles.add (file); | documentFiles.add (file); | ||||
| doc->replaceAllContent (file.loadFileAsString()); | doc->replaceAllContent (file.loadFileAsString()); | ||||
| doc->clearUndoHistory(); | doc->clearUndoHistory(); | ||||
| @@ -409,7 +409,7 @@ struct ColourEditorComp : public Component, | |||||
| void mouseDown (const MouseEvent&) override | void mouseDown (const MouseEvent&) override | ||||
| { | { | ||||
| ColourSelector* colourSelector = new ColourSelector(); | |||||
| auto* colourSelector = new ColourSelector(); | |||||
| colourSelector->setName ("Colour"); | colourSelector->setName ("Colour"); | ||||
| colourSelector->setCurrentColour (getColour()); | colourSelector->setCurrentColour (getColour()); | ||||
| colourSelector->addChangeListener (this); | colourSelector->addChangeListener (this); | ||||
| @@ -421,7 +421,7 @@ struct ColourEditorComp : public Component, | |||||
| void changeListenerCallback (ChangeBroadcaster* source) override | void changeListenerCallback (ChangeBroadcaster* source) override | ||||
| { | { | ||||
| if (ColourSelector* cs = dynamic_cast<ColourSelector*> (source)) | |||||
| if (auto* cs = dynamic_cast<ColourSelector*> (source)) | |||||
| editor.applyNewValue (getAsString (cs->getCurrentColour(), true)); | editor.applyNewValue (getAsString (cs->getCurrentColour(), true)); | ||||
| repaint(); | repaint(); | ||||
| @@ -493,9 +493,9 @@ struct BoolSliderComp : public SliderComp | |||||
| void sliderValueChanged (Slider*) override { editor.applyNewValue (slider.getValue() > 0.5 ? "true" : "false"); } | void sliderValueChanged (Slider*) override { editor.applyNewValue (slider.getValue() > 0.5 ? "true" : "false"); } | ||||
| }; | }; | ||||
| Component* createIntegerSlider (LivePropertyEditorBase& editor) { return new SliderComp (editor, false); } | |||||
| Component* createFloatSlider (LivePropertyEditorBase& editor) { return new SliderComp (editor, true); } | |||||
| Component* createBoolSlider (LivePropertyEditorBase& editor) { return new BoolSliderComp (editor); } | |||||
| Component* createIntegerSlider (LivePropertyEditorBase& editor) { return new SliderComp (editor, false); } | |||||
| Component* createFloatSlider (LivePropertyEditorBase& editor) { return new SliderComp (editor, true); } | |||||
| Component* createBoolSlider (LivePropertyEditorBase& editor) { return new BoolSliderComp (editor); } | |||||
| } | } | ||||
| @@ -123,13 +123,13 @@ namespace LiveConstantEditor | |||||
| LiveValueBase& value; | LiveValueBase& value; | ||||
| Label name; | Label name; | ||||
| TextEditor valueEditor; | TextEditor valueEditor; | ||||
| TextButton resetButton; | |||||
| TextButton resetButton { "reset" }; | |||||
| CodeDocument& document; | CodeDocument& document; | ||||
| CPlusPlusCodeTokeniser tokeniser; | CPlusPlusCodeTokeniser tokeniser; | ||||
| CodeEditorComponent sourceEditor; | CodeEditorComponent sourceEditor; | ||||
| CodeDocument::Position valueStart, valueEnd; | CodeDocument::Position valueStart, valueEnd; | ||||
| ScopedPointer<Component> customComp; | ScopedPointer<Component> customComp; | ||||
| bool wasHex; | |||||
| bool wasHex = false; | |||||
| JUCE_DECLARE_NON_COPYABLE (LivePropertyEditorBase) | JUCE_DECLARE_NON_COPYABLE (LivePropertyEditorBase) | ||||
| }; | }; | ||||
| @@ -247,21 +247,11 @@ bool OpenGLHelpers::isContextActive() | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| void componentPeerAboutToChange (ComponentPeer& peer, bool shouldSuspend) | |||||
| void componentPeerAboutToChange (Component& comp, bool shouldSuspend) | |||||
| { | { | ||||
| Array<Component*> stack; | |||||
| stack.add (&peer.getComponent()); | |||||
| if (auto* context = OpenGLContext::getContextAttachedTo (comp)) | |||||
| context->overrideCanBeAttached (shouldSuspend); | |||||
| while (stack.size() != 0) | |||||
| { | |||||
| Component& comp = *stack.removeAndReturn (0); | |||||
| const int n = comp.getNumChildComponents(); | |||||
| for (int i = 0; i < n; ++i) | |||||
| if (Component* child = comp.getChildComponent (i)) | |||||
| stack.add (child); | |||||
| if (OpenGLContext* context = OpenGLContext::getContextAttachedTo (comp)) | |||||
| context->overrideCanBeAttached (shouldSuspend); | |||||
| } | |||||
| for (auto* child : comp.getChildren()) | |||||
| componentPeerAboutToChange (*child, shouldSuspend); | |||||
| } | } | ||||
| @@ -322,14 +322,14 @@ private: | |||||
| struct AsyncWorkerFunctor : AsyncWorker | struct AsyncWorkerFunctor : AsyncWorker | ||||
| { | { | ||||
| AsyncWorkerFunctor (T functorToUse) : functor (functorToUse) {} | AsyncWorkerFunctor (T functorToUse) : functor (functorToUse) {} | ||||
| void operator() (OpenGLContext& callerContext) override { functor (callerContext); } | |||||
| void operator() (OpenGLContext& callerContext) override { functor (callerContext); } | |||||
| T functor; | T functor; | ||||
| JUCE_DECLARE_NON_COPYABLE(AsyncWorkerFunctor) | |||||
| JUCE_DECLARE_NON_COPYABLE (AsyncWorkerFunctor) | |||||
| }; | }; | ||||
| //============================================================================== | //============================================================================== | ||||
| friend void componentPeerAboutToChange (ComponentPeer&, bool); | |||||
| friend void componentPeerAboutToChange (Component&, bool); | |||||
| void overrideCanBeAttached (bool); | void overrideCanBeAttached (bool); | ||||
| //============================================================================== | //============================================================================== | ||||