| @@ -112,6 +112,11 @@ public: | |||||
| { | { | ||||
| } | } | ||||
| /** A function object which can remap a value in some way based on the start and end of a range. */ | |||||
| using ValueRemapFunction = std::function<ValueType(ValueType rangeStart, | |||||
| ValueType rangeEnd, | |||||
| ValueType valueToRemap)>; | |||||
| /** Creates a NormalisableRange with a given range and an injective mapping function. | /** Creates a NormalisableRange with a given range and an injective mapping function. | ||||
| @param rangeStart The minimum value in the range. | @param rangeStart The minimum value in the range. | ||||
| @@ -125,14 +130,14 @@ public: | |||||
| */ | */ | ||||
| NormalisableRange (ValueType rangeStart, | NormalisableRange (ValueType rangeStart, | ||||
| ValueType rangeEnd, | ValueType rangeEnd, | ||||
| std::function<ValueType(ValueType currentRangeStart, ValueType currentRangeEnd, ValueType normalisedValue)> convertFrom0To1Func, | |||||
| std::function<ValueType(ValueType currentRangeStart, ValueType currentRangeEnd, ValueType mappedValue)> convertTo0To1Func, | |||||
| std::function<ValueType(ValueType currentRangeStart, ValueType currentRangeEnd, ValueType valueToSnap)> snapToLegalValueFunc = nullptr) noexcept | |||||
| ValueRemapFunction convertFrom0To1Func, | |||||
| ValueRemapFunction convertTo0To1Func, | |||||
| ValueRemapFunction snapToLegalValueFunc = {}) noexcept | |||||
| : start (rangeStart), | : start (rangeStart), | ||||
| end (rangeEnd), | end (rangeEnd), | ||||
| convertFrom0To1Function (convertFrom0To1Func), | |||||
| convertTo0To1Function (convertTo0To1Func), | |||||
| snapToLegalValueFunction (snapToLegalValueFunc) | |||||
| convertFrom0To1Function (std::move (convertFrom0To1Func)), | |||||
| convertTo0To1Function (std::move (convertTo0To1Func)), | |||||
| snapToLegalValueFunction (std::move (snapToLegalValueFunc)) | |||||
| { | { | ||||
| checkInvariants(); | checkInvariants(); | ||||
| } | } | ||||
| @@ -274,11 +279,7 @@ private: | |||||
| return clampedValue; | return clampedValue; | ||||
| } | } | ||||
| using ConversionFunction = std::function<ValueType(ValueType, ValueType, ValueType)>; | |||||
| ConversionFunction convertFrom0To1Function = {}, | |||||
| convertTo0To1Function = {}, | |||||
| snapToLegalValueFunction = {}; | |||||
| ValueRemapFunction convertFrom0To1Function, convertTo0To1Function, snapToLegalValueFunction; | |||||
| }; | }; | ||||
| } // namespace juce | } // namespace juce | ||||
| @@ -31,15 +31,15 @@ struct ConcertinaPanel::PanelSizes | |||||
| { | { | ||||
| struct Panel | struct Panel | ||||
| { | { | ||||
| Panel() noexcept {} | |||||
| Panel() = default; | |||||
| Panel (const int sz, const int mn, const int mx) noexcept | |||||
| Panel (int sz, int mn, int mx) noexcept | |||||
| : size (sz), minSize (mn), maxSize (mx) {} | : size (sz), minSize (mn), maxSize (mx) {} | ||||
| int setSize (const int newSize) noexcept | |||||
| int setSize (int newSize) noexcept | |||||
| { | { | ||||
| jassert (minSize <= maxSize); | jassert (minSize <= maxSize); | ||||
| const int oldSize = size; | |||||
| auto oldSize = size; | |||||
| size = jlimit (minSize, maxSize, newSize); | size = jlimit (minSize, maxSize, newSize); | ||||
| return size - oldSize; | return size - oldSize; | ||||
| } | } | ||||
| @@ -66,12 +66,12 @@ struct ConcertinaPanel::PanelSizes | |||||
| Array<Panel> sizes; | Array<Panel> sizes; | ||||
| Panel& get (const int index) noexcept { return sizes.getReference (index); } | |||||
| const Panel& get (const int index) const noexcept { return sizes.getReference (index); } | |||||
| Panel& get (int index) noexcept { return sizes.getReference (index); } | |||||
| const Panel& get (int index) const noexcept { return sizes.getReference (index); } | |||||
| PanelSizes withMovedPanel (const int index, int targetPosition, int totalSpace) const | |||||
| PanelSizes withMovedPanel (int index, int targetPosition, int totalSpace) const | |||||
| { | { | ||||
| const int num = sizes.size(); | |||||
| auto num = sizes.size(); | |||||
| totalSpace = jmax (totalSpace, getMinimumSize (0, num)); | totalSpace = jmax (totalSpace, getMinimumSize (0, num)); | ||||
| targetPosition = jmax (targetPosition, totalSpace - getMaximumSize (index, num)); | targetPosition = jmax (targetPosition, totalSpace - getMaximumSize (index, num)); | ||||
| @@ -83,14 +83,14 @@ struct ConcertinaPanel::PanelSizes | |||||
| PanelSizes fittedInto (int totalSpace) const | PanelSizes fittedInto (int totalSpace) const | ||||
| { | { | ||||
| PanelSizes newSizes (*this); | |||||
| const int num = newSizes.sizes.size(); | |||||
| auto newSizes (*this); | |||||
| auto num = newSizes.sizes.size(); | |||||
| totalSpace = jmax (totalSpace, getMinimumSize (0, num)); | totalSpace = jmax (totalSpace, getMinimumSize (0, num)); | ||||
| newSizes.stretchRange (0, num, totalSpace - newSizes.getTotalSize (0, num), stretchAll); | newSizes.stretchRange (0, num, totalSpace - newSizes.getTotalSize (0, num), stretchAll); | ||||
| return newSizes; | return newSizes; | ||||
| } | } | ||||
| PanelSizes withResizedPanel (const int index, int panelHeight, int totalSpace) const | |||||
| PanelSizes withResizedPanel (int index, int panelHeight, int totalSpace) const | |||||
| { | { | ||||
| PanelSizes newSizes (*this); | PanelSizes newSizes (*this); | ||||
| @@ -100,8 +100,8 @@ struct ConcertinaPanel::PanelSizes | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| const int num = sizes.size(); | |||||
| const int minSize = getMinimumSize (0, num); | |||||
| auto num = sizes.size(); | |||||
| auto minSize = getMinimumSize (0, num); | |||||
| totalSpace = jmax (totalSpace, minSize); | totalSpace = jmax (totalSpace, minSize); | ||||
| newSizes.get(index).setSize (panelHeight); | newSizes.get(index).setSize (panelHeight); | ||||
| @@ -121,21 +121,21 @@ private: | |||||
| stretchLast | stretchLast | ||||
| }; | }; | ||||
| void growRangeFirst (const int start, const int end, int spaceDiff) noexcept | |||||
| void growRangeFirst (int start, int end, int spaceDiff) noexcept | |||||
| { | { | ||||
| for (int attempts = 4; --attempts >= 0 && spaceDiff > 0;) | for (int attempts = 4; --attempts >= 0 && spaceDiff > 0;) | ||||
| for (int i = start; i < end && spaceDiff > 0; ++i) | for (int i = start; i < end && spaceDiff > 0; ++i) | ||||
| spaceDiff -= get (i).expand (spaceDiff); | spaceDiff -= get (i).expand (spaceDiff); | ||||
| } | } | ||||
| void growRangeLast (const int start, const int end, int spaceDiff) noexcept | |||||
| void growRangeLast (int start, int end, int spaceDiff) noexcept | |||||
| { | { | ||||
| for (int attempts = 4; --attempts >= 0 && spaceDiff > 0;) | for (int attempts = 4; --attempts >= 0 && spaceDiff > 0;) | ||||
| for (int i = end; --i >= start && spaceDiff > 0;) | for (int i = end; --i >= start && spaceDiff > 0;) | ||||
| spaceDiff -= get (i).expand (spaceDiff); | spaceDiff -= get (i).expand (spaceDiff); | ||||
| } | } | ||||
| void growRangeAll (const int start, const int end, int spaceDiff) noexcept | |||||
| void growRangeAll (int start, int end, int spaceDiff) noexcept | |||||
| { | { | ||||
| Array<Panel*> expandableItems; | Array<Panel*> expandableItems; | ||||
| @@ -150,20 +150,19 @@ private: | |||||
| growRangeLast (start, end, spaceDiff); | growRangeLast (start, end, spaceDiff); | ||||
| } | } | ||||
| void shrinkRangeFirst (const int start, const int end, int spaceDiff) noexcept | |||||
| void shrinkRangeFirst (int start, int end, int spaceDiff) noexcept | |||||
| { | { | ||||
| for (int i = start; i < end && spaceDiff > 0; ++i) | for (int i = start; i < end && spaceDiff > 0; ++i) | ||||
| spaceDiff -= get(i).reduce (spaceDiff); | spaceDiff -= get(i).reduce (spaceDiff); | ||||
| } | } | ||||
| void shrinkRangeLast (const int start, const int end, int spaceDiff) noexcept | |||||
| void shrinkRangeLast (int start, int end, int spaceDiff) noexcept | |||||
| { | { | ||||
| for (int i = end; --i >= start && spaceDiff > 0;) | for (int i = end; --i >= start && spaceDiff > 0;) | ||||
| spaceDiff -= get(i).reduce (spaceDiff); | spaceDiff -= get(i).reduce (spaceDiff); | ||||
| } | } | ||||
| void stretchRange (const int start, const int end, const int amountToAdd, | |||||
| const ExpandMode expandMode) noexcept | |||||
| void stretchRange (int start, int end, int amountToAdd, ExpandMode expandMode) noexcept | |||||
| { | { | ||||
| if (end > start) | if (end > start) | ||||
| { | { | ||||
| @@ -181,26 +180,28 @@ private: | |||||
| } | } | ||||
| } | } | ||||
| int getTotalSize (int start, const int end) const noexcept | |||||
| int getTotalSize (int start, int end) const noexcept | |||||
| { | { | ||||
| int tot = 0; | int tot = 0; | ||||
| while (start < end) tot += get (start++).size; | while (start < end) tot += get (start++).size; | ||||
| return tot; | return tot; | ||||
| } | } | ||||
| int getMinimumSize (int start, const int end) const noexcept | |||||
| int getMinimumSize (int start, int end) const noexcept | |||||
| { | { | ||||
| int tot = 0; | int tot = 0; | ||||
| while (start < end) tot += get (start++).minSize; | while (start < end) tot += get (start++).minSize; | ||||
| return tot; | return tot; | ||||
| } | } | ||||
| int getMaximumSize (int start, const int end) const noexcept | |||||
| int getMaximumSize (int start, int end) const noexcept | |||||
| { | { | ||||
| int tot = 0; | int tot = 0; | ||||
| while (start < end) | while (start < end) | ||||
| { | { | ||||
| const int mx = get (start++).maxSize; | |||||
| auto mx = get (start++).maxSize; | |||||
| if (mx > 0x100000) | if (mx > 0x100000) | ||||
| return mx; | return mx; | ||||
| @@ -215,7 +216,7 @@ private: | |||||
| class ConcertinaPanel::PanelHolder : public Component | class ConcertinaPanel::PanelHolder : public Component | ||||
| { | { | ||||
| public: | public: | ||||
| PanelHolder (Component* const comp, bool takeOwnership) | |||||
| PanelHolder (Component* comp, bool takeOwnership) | |||||
| : component (comp, takeOwnership) | : component (comp, takeOwnership) | ||||
| { | { | ||||
| setRepaintsOnMouseActivity (true); | setRepaintsOnMouseActivity (true); | ||||
| @@ -286,13 +287,13 @@ private: | |||||
| int getHeaderSize() const noexcept | int getHeaderSize() const noexcept | ||||
| { | { | ||||
| ConcertinaPanel& panel = getPanel(); | ConcertinaPanel& panel = getPanel(); | ||||
| const int ourIndex = panel.holders.indexOf (this); | |||||
| auto ourIndex = panel.holders.indexOf (this); | |||||
| return panel.currentSizes->get(ourIndex).minSize; | return panel.currentSizes->get(ourIndex).minSize; | ||||
| } | } | ||||
| ConcertinaPanel& getPanel() const | ConcertinaPanel& getPanel() const | ||||
| { | { | ||||
| ConcertinaPanel* const panel = dynamic_cast<ConcertinaPanel*> (getParentComponent()); | |||||
| auto panel = dynamic_cast<ConcertinaPanel*> (getParentComponent()); | |||||
| jassert (panel != nullptr); | jassert (panel != nullptr); | ||||
| return *panel; | return *panel; | ||||
| } | } | ||||
| @@ -327,7 +328,7 @@ void ConcertinaPanel::addPanel (int insertIndex, Component* component, bool take | |||||
| jassert (component != nullptr); // can't use a null pointer here! | jassert (component != nullptr); // can't use a null pointer here! | ||||
| jassert (indexOfComp (component) < 0); // You can't add the same component more than once! | jassert (indexOfComp (component) < 0); // You can't add the same component more than once! | ||||
| PanelHolder* const holder = new PanelHolder (component, takeOwnership); | |||||
| auto holder = new PanelHolder (component, takeOwnership); | |||||
| holders.insert (insertIndex, holder); | holders.insert (insertIndex, holder); | ||||
| currentSizes->sizes.insert (insertIndex, PanelSizes::Panel (headerHeight, headerHeight, std::numeric_limits<int>::max())); | currentSizes->sizes.insert (insertIndex, PanelSizes::Panel (headerHeight, headerHeight, std::numeric_limits<int>::max())); | ||||
| addAndMakeVisible (holder); | addAndMakeVisible (holder); | ||||
| @@ -336,7 +337,7 @@ void ConcertinaPanel::addPanel (int insertIndex, Component* component, bool take | |||||
| void ConcertinaPanel::removePanel (Component* component) | void ConcertinaPanel::removePanel (Component* component) | ||||
| { | { | ||||
| const int index = indexOfComp (component); | |||||
| auto index = indexOfComp (component); | |||||
| if (index >= 0) | if (index >= 0) | ||||
| { | { | ||||
| @@ -346,25 +347,25 @@ void ConcertinaPanel::removePanel (Component* component) | |||||
| } | } | ||||
| } | } | ||||
| bool ConcertinaPanel::setPanelSize (Component* panelComponent, int height, const bool animate) | |||||
| bool ConcertinaPanel::setPanelSize (Component* panelComponent, int height, bool animate) | |||||
| { | { | ||||
| const int index = indexOfComp (panelComponent); | |||||
| auto index = indexOfComp (panelComponent); | |||||
| jassert (index >= 0); // The specified component doesn't seem to have been added! | jassert (index >= 0); // The specified component doesn't seem to have been added! | ||||
| height += currentSizes->get(index).minSize; | height += currentSizes->get(index).minSize; | ||||
| const int oldSize = currentSizes->get(index).size; | |||||
| auto oldSize = currentSizes->get(index).size; | |||||
| setLayout (currentSizes->withResizedPanel (index, height, getHeight()), animate); | setLayout (currentSizes->withResizedPanel (index, height, getHeight()), animate); | ||||
| return oldSize != currentSizes->get(index).size; | return oldSize != currentSizes->get(index).size; | ||||
| } | } | ||||
| bool ConcertinaPanel::expandPanelFully (Component* component, const bool animate) | |||||
| bool ConcertinaPanel::expandPanelFully (Component* component, bool animate) | |||||
| { | { | ||||
| return setPanelSize (component, getHeight(), animate); | return setPanelSize (component, getHeight(), animate); | ||||
| } | } | ||||
| void ConcertinaPanel::setMaximumPanelSize (Component* component, int maximumSize) | void ConcertinaPanel::setMaximumPanelSize (Component* component, int maximumSize) | ||||
| { | { | ||||
| const int index = indexOfComp (component); | |||||
| auto index = indexOfComp (component); | |||||
| jassert (index >= 0); // The specified component doesn't seem to have been added! | jassert (index >= 0); // The specified component doesn't seem to have been added! | ||||
| if (index >= 0) | if (index >= 0) | ||||
| @@ -376,7 +377,7 @@ void ConcertinaPanel::setMaximumPanelSize (Component* component, int maximumSize | |||||
| void ConcertinaPanel::setPanelHeaderSize (Component* component, int headerSize) | void ConcertinaPanel::setPanelHeaderSize (Component* component, int headerSize) | ||||
| { | { | ||||
| const auto index = indexOfComp (component); | |||||
| auto index = indexOfComp (component); | |||||
| jassert (index >= 0); // The specified component doesn't seem to have been added! | jassert (index >= 0); // The specified component doesn't seem to have been added! | ||||
| if (index >= 0) | if (index >= 0) | ||||
| @@ -393,7 +394,7 @@ void ConcertinaPanel::setCustomPanelHeader (Component* component, Component* cus | |||||
| { | { | ||||
| OptionalScopedPointer<Component> optional (customComponent, takeOwnership); | OptionalScopedPointer<Component> optional (customComponent, takeOwnership); | ||||
| const auto index = indexOfComp (component); | |||||
| auto index = indexOfComp (component); | |||||
| jassert (index >= 0); // The specified component doesn't seem to have been added! | jassert (index >= 0); // The specified component doesn't seem to have been added! | ||||
| if (index >= 0) | if (index >= 0) | ||||
| @@ -419,20 +420,20 @@ ConcertinaPanel::PanelSizes ConcertinaPanel::getFittedSizes() const | |||||
| return currentSizes->fittedInto (getHeight()); | return currentSizes->fittedInto (getHeight()); | ||||
| } | } | ||||
| void ConcertinaPanel::applyLayout (const PanelSizes& sizes, const bool animate) | |||||
| void ConcertinaPanel::applyLayout (const PanelSizes& sizes, bool animate) | |||||
| { | { | ||||
| if (! animate) | if (! animate) | ||||
| animator.cancelAllAnimations (false); | animator.cancelAllAnimations (false); | ||||
| const int animationDuration = 150; | const int animationDuration = 150; | ||||
| const int w = getWidth(); | |||||
| auto w = getWidth(); | |||||
| int y = 0; | int y = 0; | ||||
| for (int i = 0; i < holders.size(); ++i) | for (int i = 0; i < holders.size(); ++i) | ||||
| { | { | ||||
| PanelHolder& p = *holders.getUnchecked (i); | PanelHolder& p = *holders.getUnchecked (i); | ||||
| const int h = sizes.get (i).size; | |||||
| auto h = sizes.get (i).size; | |||||
| const Rectangle<int> pos (0, y, w, h); | const Rectangle<int> pos (0, y, w, h); | ||||
| if (animate) | if (animate) | ||||
| @@ -444,7 +445,7 @@ void ConcertinaPanel::applyLayout (const PanelSizes& sizes, const bool animate) | |||||
| } | } | ||||
| } | } | ||||
| void ConcertinaPanel::setLayout (const PanelSizes& sizes, const bool animate) | |||||
| void ConcertinaPanel::setLayout (const PanelSizes& sizes, bool animate) | |||||
| { | { | ||||
| *currentSizes = sizes; | *currentSizes = sizes; | ||||
| applyLayout (getFittedSizes(), animate); | applyLayout (getFittedSizes(), animate); | ||||
| @@ -44,8 +44,8 @@ public: | |||||
| @param componentName the name to give the component | @param componentName the name to give the component | ||||
| @param labelText the text to show at the top of the outline | @param labelText the text to show at the top of the outline | ||||
| */ | */ | ||||
| GroupComponent (const String& componentName = String(), | |||||
| const String& labelText = String()); | |||||
| GroupComponent (const String& componentName = {}, | |||||
| const String& labelText = {}); | |||||
| /** Destructor. */ | /** Destructor. */ | ||||
| ~GroupComponent() override; | ~GroupComponent() override; | ||||
| @@ -58,15 +58,12 @@ public: | |||||
| String getText() const; | String getText() const; | ||||
| /** Sets the positioning of the text label. | /** Sets the positioning of the text label. | ||||
| (The default is Justification::left) | (The default is Justification::left) | ||||
| @see getTextLabelPosition | @see getTextLabelPosition | ||||
| */ | */ | ||||
| void setTextLabelPosition (Justification justification); | void setTextLabelPosition (Justification justification); | ||||
| /** Returns the current text label position. | /** Returns the current text label position. | ||||
| @see setTextLabelPosition | @see setTextLabelPosition | ||||
| */ | */ | ||||
| Justification getTextLabelPosition() const noexcept { return justification; } | Justification getTextLabelPosition() const noexcept { return justification; } | ||||
| @@ -88,18 +88,15 @@ MouseCursor ResizableBorderComponent::Zone::getMouseCursor() const noexcept | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| ResizableBorderComponent::ResizableBorderComponent (Component* const componentToResize, | |||||
| ComponentBoundsConstrainer* const constrainer_) | |||||
| ResizableBorderComponent::ResizableBorderComponent (Component* componentToResize, | |||||
| ComponentBoundsConstrainer* boundsConstrainer) | |||||
| : component (componentToResize), | : component (componentToResize), | ||||
| constrainer (constrainer_), | |||||
| borderSize (5), | |||||
| mouseZone (0) | |||||
| constrainer (boundsConstrainer), | |||||
| borderSize (5) | |||||
| { | { | ||||
| } | } | ||||
| ResizableBorderComponent::~ResizableBorderComponent() | |||||
| { | |||||
| } | |||||
| ResizableBorderComponent::~ResizableBorderComponent() = default; | |||||
| //============================================================================== | //============================================================================== | ||||
| void ResizableBorderComponent::paint (Graphics& g) | void ResizableBorderComponent::paint (Graphics& g) | ||||
| @@ -168,13 +165,10 @@ void ResizableBorderComponent::mouseUp (const MouseEvent&) | |||||
| bool ResizableBorderComponent::hitTest (int x, int y) | bool ResizableBorderComponent::hitTest (int x, int y) | ||||
| { | { | ||||
| return x < borderSize.getLeft() | |||||
| || x >= getWidth() - borderSize.getRight() | |||||
| || y < borderSize.getTop() | |||||
| || y >= getHeight() - borderSize.getBottom(); | |||||
| return ! borderSize.subtractedFrom (getLocalBounds()).contains (x, y); | |||||
| } | } | ||||
| void ResizableBorderComponent::setBorderThickness (const BorderSize<int>& newBorderSize) | |||||
| void ResizableBorderComponent::setBorderThickness (BorderSize<int> newBorderSize) | |||||
| { | { | ||||
| if (borderSize != newBorderSize) | if (borderSize != newBorderSize) | ||||
| { | { | ||||
| @@ -78,7 +78,7 @@ public: | |||||
| @see getBorderThickness | @see getBorderThickness | ||||
| */ | */ | ||||
| void setBorderThickness (const BorderSize<int>& newBorderSize); | |||||
| void setBorderThickness (BorderSize<int> newBorderSize); | |||||
| /** Returns the number of pixels wide that the draggable edges of this component are. | /** Returns the number of pixels wide that the draggable edges of this component are. | ||||
| @@ -27,26 +27,23 @@ | |||||
| namespace juce | namespace juce | ||||
| { | { | ||||
| ResizableCornerComponent::ResizableCornerComponent (Component* const componentToResize, | |||||
| ComponentBoundsConstrainer* const constrainer_) | |||||
| ResizableCornerComponent::ResizableCornerComponent (Component* componentToResize, | |||||
| ComponentBoundsConstrainer* boundsConstrainer) | |||||
| : component (componentToResize), | : component (componentToResize), | ||||
| constrainer (constrainer_) | |||||
| constrainer (boundsConstrainer) | |||||
| { | { | ||||
| setRepaintsOnMouseActivity (true); | setRepaintsOnMouseActivity (true); | ||||
| setMouseCursor (MouseCursor::BottomRightCornerResizeCursor); | setMouseCursor (MouseCursor::BottomRightCornerResizeCursor); | ||||
| } | } | ||||
| ResizableCornerComponent::~ResizableCornerComponent() | |||||
| { | |||||
| } | |||||
| ResizableCornerComponent::~ResizableCornerComponent() = default; | |||||
| //============================================================================== | //============================================================================== | ||||
| void ResizableCornerComponent::paint (Graphics& g) | void ResizableCornerComponent::paint (Graphics& g) | ||||
| { | { | ||||
| getLookAndFeel() | |||||
| .drawCornerResizer (g, getWidth(), getHeight(), | |||||
| isMouseOverOrDragging(), | |||||
| isMouseButtonDown()); | |||||
| getLookAndFeel().drawCornerResizer (g, getWidth(), getHeight(), | |||||
| isMouseOverOrDragging(), | |||||
| isMouseButtonDown()); | |||||
| } | } | ||||
| void ResizableCornerComponent::mouseDown (const MouseEvent&) | void ResizableCornerComponent::mouseDown (const MouseEvent&) | ||||
| @@ -71,20 +68,15 @@ void ResizableCornerComponent::mouseDrag (const MouseEvent& e) | |||||
| return; | return; | ||||
| } | } | ||||
| Rectangle<int> r (originalBounds.withSize (originalBounds.getWidth() + e.getDistanceFromDragStartX(), | |||||
| originalBounds.getHeight() + e.getDistanceFromDragStartY())); | |||||
| auto r = originalBounds.withSize (originalBounds.getWidth() + e.getDistanceFromDragStartX(), | |||||
| originalBounds.getHeight() + e.getDistanceFromDragStartY()); | |||||
| if (constrainer != nullptr) | if (constrainer != nullptr) | ||||
| { | |||||
| constrainer->setBoundsForComponent (component, r, false, false, true, true); | constrainer->setBoundsForComponent (component, r, false, false, true, true); | ||||
| } | |||||
| else if (auto pos = component->getPositioner()) | |||||
| pos->applyNewBounds (r); | |||||
| else | else | ||||
| { | |||||
| if (Component::Positioner* const pos = component->getPositioner()) | |||||
| pos->applyNewBounds (r); | |||||
| else | |||||
| component->setBounds (r); | |||||
| } | |||||
| component->setBounds (r); | |||||
| } | } | ||||
| void ResizableCornerComponent::mouseUp (const MouseEvent&) | void ResizableCornerComponent::mouseUp (const MouseEvent&) | ||||
| @@ -98,8 +90,7 @@ bool ResizableCornerComponent::hitTest (int x, int y) | |||||
| if (getWidth() <= 0) | if (getWidth() <= 0) | ||||
| return false; | return false; | ||||
| const int yAtX = getHeight() - (getHeight() * x / getWidth()); | |||||
| auto yAtX = getHeight() - (getHeight() * x / getWidth()); | |||||
| return y >= yAtX - getHeight() / 4; | return y >= yAtX - getHeight() / 4; | ||||
| } | } | ||||
| @@ -27,21 +27,19 @@ | |||||
| namespace juce | namespace juce | ||||
| { | { | ||||
| ResizableEdgeComponent::ResizableEdgeComponent (Component* const componentToResize, | |||||
| ComponentBoundsConstrainer* const constrainer_, | |||||
| Edge edge_) | |||||
| ResizableEdgeComponent::ResizableEdgeComponent (Component* componentToResize, | |||||
| ComponentBoundsConstrainer* boundsConstrainer, | |||||
| Edge e) | |||||
| : component (componentToResize), | : component (componentToResize), | ||||
| constrainer (constrainer_), | |||||
| edge (edge_) | |||||
| constrainer (boundsConstrainer), | |||||
| edge (e) | |||||
| { | { | ||||
| setRepaintsOnMouseActivity (true); | setRepaintsOnMouseActivity (true); | ||||
| setMouseCursor (isVertical() ? MouseCursor::LeftRightResizeCursor | setMouseCursor (isVertical() ? MouseCursor::LeftRightResizeCursor | ||||
| : MouseCursor::UpDownResizeCursor); | : MouseCursor::UpDownResizeCursor); | ||||
| } | } | ||||
| ResizableEdgeComponent::~ResizableEdgeComponent() | |||||
| { | |||||
| } | |||||
| ResizableEdgeComponent::~ResizableEdgeComponent() = default; | |||||
| //============================================================================== | //============================================================================== | ||||
| bool ResizableEdgeComponent::isVertical() const noexcept | bool ResizableEdgeComponent::isVertical() const noexcept | ||||
| @@ -82,15 +82,15 @@ void ScrollBar::setRangeLimits (Range<double> newRangeLimit, NotificationType no | |||||
| } | } | ||||
| } | } | ||||
| void ScrollBar::setRangeLimits (const double newMinimum, const double newMaximum, NotificationType notification) | |||||
| void ScrollBar::setRangeLimits (double newMinimum, double newMaximum, NotificationType notification) | |||||
| { | { | ||||
| jassert (newMaximum >= newMinimum); // these can't be the wrong way round! | jassert (newMaximum >= newMinimum); // these can't be the wrong way round! | ||||
| setRangeLimits (Range<double> (newMinimum, newMaximum), notification); | setRangeLimits (Range<double> (newMinimum, newMaximum), notification); | ||||
| } | } | ||||
| bool ScrollBar::setCurrentRange (Range<double> newRange, const NotificationType notification) | |||||
| bool ScrollBar::setCurrentRange (Range<double> newRange, NotificationType notification) | |||||
| { | { | ||||
| const Range<double> constrainedRange (totalRange.constrainRange (newRange)); | |||||
| auto constrainedRange = totalRange.constrainRange (newRange); | |||||
| if (visibleRange != constrainedRange) | if (visibleRange != constrainedRange) | ||||
| { | { | ||||
| @@ -110,27 +110,27 @@ bool ScrollBar::setCurrentRange (Range<double> newRange, const NotificationType | |||||
| return false; | return false; | ||||
| } | } | ||||
| void ScrollBar::setCurrentRange (const double newStart, const double newSize, NotificationType notification) | |||||
| void ScrollBar::setCurrentRange (double newStart, double newSize, NotificationType notification) | |||||
| { | { | ||||
| setCurrentRange (Range<double> (newStart, newStart + newSize), notification); | setCurrentRange (Range<double> (newStart, newStart + newSize), notification); | ||||
| } | } | ||||
| void ScrollBar::setCurrentRangeStart (const double newStart, NotificationType notification) | |||||
| void ScrollBar::setCurrentRangeStart (double newStart, NotificationType notification) | |||||
| { | { | ||||
| setCurrentRange (visibleRange.movedToStartAt (newStart), notification); | setCurrentRange (visibleRange.movedToStartAt (newStart), notification); | ||||
| } | } | ||||
| void ScrollBar::setSingleStepSize (const double newSingleStepSize) noexcept | |||||
| void ScrollBar::setSingleStepSize (double newSingleStepSize) noexcept | |||||
| { | { | ||||
| singleStepSize = newSingleStepSize; | singleStepSize = newSingleStepSize; | ||||
| } | } | ||||
| bool ScrollBar::moveScrollbarInSteps (const int howManySteps, NotificationType notification) | |||||
| bool ScrollBar::moveScrollbarInSteps (int howManySteps, NotificationType notification) | |||||
| { | { | ||||
| return setCurrentRange (visibleRange + howManySteps * singleStepSize, notification); | return setCurrentRange (visibleRange + howManySteps * singleStepSize, notification); | ||||
| } | } | ||||
| bool ScrollBar::moveScrollbarInPages (const int howManyPages, NotificationType notification) | |||||
| bool ScrollBar::moveScrollbarInPages (int howManyPages, NotificationType notification) | |||||
| { | { | ||||
| return setCurrentRange (visibleRange + howManyPages * visibleRange.getLength(), notification); | return setCurrentRange (visibleRange + howManyPages * visibleRange.getLength(), notification); | ||||
| } | } | ||||
| @@ -145,9 +145,9 @@ bool ScrollBar::scrollToBottom (NotificationType notification) | |||||
| return setCurrentRange (visibleRange.movedToEndAt (getMaximumRangeLimit()), notification); | return setCurrentRange (visibleRange.movedToEndAt (getMaximumRangeLimit()), notification); | ||||
| } | } | ||||
| void ScrollBar::setButtonRepeatSpeed (const int newInitialDelay, | |||||
| const int newRepeatDelay, | |||||
| const int newMinimumDelay) | |||||
| void ScrollBar::setButtonRepeatSpeed (int newInitialDelay, | |||||
| int newRepeatDelay, | |||||
| int newMinimumDelay) | |||||
| { | { | ||||
| initialDelayInMillisecs = newInitialDelay; | initialDelayInMillisecs = newInitialDelay; | ||||
| repeatDelayInMillisecs = newRepeatDelay; | repeatDelayInMillisecs = newRepeatDelay; | ||||
| @@ -161,12 +161,12 @@ void ScrollBar::setButtonRepeatSpeed (const int newInitialDelay, | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| void ScrollBar::addListener (Listener* const listener) | |||||
| void ScrollBar::addListener (Listener* listener) | |||||
| { | { | ||||
| listeners.add (listener); | listeners.add (listener); | ||||
| } | } | ||||
| void ScrollBar::removeListener (Listener* const listener) | |||||
| void ScrollBar::removeListener (Listener* listener) | |||||
| { | { | ||||
| listeners.remove (listener); | listeners.remove (listener); | ||||
| } | } | ||||
| @@ -201,8 +201,8 @@ void ScrollBar::updateThumbPosition() | |||||
| if (thumbStart != newThumbStart || thumbSize != newThumbSize) | if (thumbStart != newThumbStart || thumbSize != newThumbSize) | ||||
| { | { | ||||
| const int repaintStart = jmin (thumbStart, newThumbStart) - 4; | |||||
| const int repaintSize = jmax (thumbStart + thumbSize, newThumbStart + newThumbSize) + 8 - repaintStart; | |||||
| auto repaintStart = jmin (thumbStart, newThumbStart) - 4; | |||||
| auto repaintSize = jmax (thumbStart + thumbSize, newThumbStart + newThumbSize) + 8 - repaintStart; | |||||
| if (vertical) | if (vertical) | ||||
| repaint (0, repaintStart, getWidth(), repaintSize); | repaint (0, repaintStart, getWidth(), repaintSize); | ||||
| @@ -214,7 +214,7 @@ void ScrollBar::updateThumbPosition() | |||||
| } | } | ||||
| } | } | ||||
| void ScrollBar::setOrientation (const bool shouldBeVertical) | |||||
| void ScrollBar::setOrientation (bool shouldBeVertical) | |||||
| { | { | ||||
| if (vertical != shouldBeVertical) | if (vertical != shouldBeVertical) | ||||
| { | { | ||||
| @@ -230,7 +230,7 @@ void ScrollBar::setOrientation (const bool shouldBeVertical) | |||||
| } | } | ||||
| } | } | ||||
| void ScrollBar::setAutoHide (const bool shouldHideWhenFullRange) | |||||
| void ScrollBar::setAutoHide (bool shouldHideWhenFullRange) | |||||
| { | { | ||||
| autohides = shouldHideWhenFullRange; | autohides = shouldHideWhenFullRange; | ||||
| updateThumbPosition(); | updateThumbPosition(); | ||||
| @@ -248,8 +248,8 @@ void ScrollBar::paint (Graphics& g) | |||||
| { | { | ||||
| auto& lf = getLookAndFeel(); | auto& lf = getLookAndFeel(); | ||||
| const int thumb = (thumbAreaSize > lf.getMinimumScrollbarThumbSize (*this)) | |||||
| ? thumbSize : 0; | |||||
| auto thumb = (thumbAreaSize > lf.getMinimumScrollbarThumbSize (*this)) | |||||
| ? thumbSize : 0; | |||||
| if (vertical) | if (vertical) | ||||
| lf.drawScrollbar (g, *this, 0, thumbAreaStart, getWidth(), thumbAreaSize, | lf.drawScrollbar (g, *this, 0, thumbAreaStart, getWidth(), thumbAreaSize, | ||||
| @@ -273,7 +273,7 @@ void ScrollBar::resized() | |||||
| auto length = vertical ? getHeight() : getWidth(); | auto length = vertical ? getHeight() : getWidth(); | ||||
| auto& lf = getLookAndFeel(); | auto& lf = getLookAndFeel(); | ||||
| const bool buttonsVisible = lf.areScrollbarButtonsVisible(); | |||||
| bool buttonsVisible = lf.areScrollbarButtonsVisible(); | |||||
| int buttonSize = 0; | int buttonSize = 0; | ||||
| if (buttonsVisible) | if (buttonsVisible) | ||||
| @@ -358,11 +358,11 @@ void ScrollBar::mouseDown (const MouseEvent& e) | |||||
| void ScrollBar::mouseDrag (const MouseEvent& e) | void ScrollBar::mouseDrag (const MouseEvent& e) | ||||
| { | { | ||||
| const int mousePos = vertical ? e.y : e.x; | |||||
| auto mousePos = vertical ? e.y : e.x; | |||||
| if (isDraggingThumb && lastMousePos != mousePos && thumbAreaSize > thumbSize) | if (isDraggingThumb && lastMousePos != mousePos && thumbAreaSize > thumbSize) | ||||
| { | { | ||||
| const int deltaPixels = mousePos - dragStartMousePos; | |||||
| auto deltaPixels = mousePos - dragStartMousePos; | |||||
| setCurrentRangeStart (dragStartRange | setCurrentRangeStart (dragStartRange | ||||
| + deltaPixels * (totalRange.getLength() - visibleRange.getLength()) | + deltaPixels * (totalRange.getLength() - visibleRange.getLength()) | ||||
| @@ -1412,7 +1412,7 @@ void TextEditor::setIndents (int newLeftIndent, int newTopIndent) | |||||
| topIndent = newTopIndent; | topIndent = newTopIndent; | ||||
| } | } | ||||
| void TextEditor::setBorder (const BorderSize<int>& border) | |||||
| void TextEditor::setBorder (BorderSize<int> border) | |||||
| { | { | ||||
| borderSize = border; | borderSize = border; | ||||
| resized(); | resized(); | ||||
| @@ -482,7 +482,7 @@ public: | |||||
| /** Changes the size of border left around the edge of the component. | /** Changes the size of border left around the edge of the component. | ||||
| @see getBorder | @see getBorder | ||||
| */ | */ | ||||
| void setBorder (const BorderSize<int>& border); | |||||
| void setBorder (BorderSize<int> border); | |||||
| /** Returns the size of border around the edge of the component. | /** Returns the size of border around the edge of the component. | ||||
| @see setBorder | @see setBorder | ||||