From 9a06be6d61827f675601f7f6b0bc9571b3b1130a Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 17 Jun 2019 13:58:07 +0100 Subject: [PATCH] Some minor cleanups --- .../juce_core/maths/juce_NormalisableRange.h | 23 +++--- .../layout/juce_ConcertinaPanel.cpp | 81 ++++++++++--------- .../layout/juce_GroupComponent.h | 7 +- .../layout/juce_ResizableBorderComponent.cpp | 20 ++--- .../layout/juce_ResizableBorderComponent.h | 2 +- .../layout/juce_ResizableCornerComponent.cpp | 35 +++----- .../layout/juce_ResizableEdgeComponent.cpp | 14 ++-- .../juce_gui_basics/layout/juce_ScrollBar.cpp | 44 +++++----- .../widgets/juce_TextEditor.cpp | 2 +- .../juce_gui_basics/widgets/juce_TextEditor.h | 2 +- 10 files changed, 106 insertions(+), 124 deletions(-) diff --git a/modules/juce_core/maths/juce_NormalisableRange.h b/modules/juce_core/maths/juce_NormalisableRange.h index 08472c8e58..e18537d11a 100644 --- a/modules/juce_core/maths/juce_NormalisableRange.h +++ b/modules/juce_core/maths/juce_NormalisableRange.h @@ -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; + /** Creates a NormalisableRange with a given range and an injective mapping function. @param rangeStart The minimum value in the range. @@ -125,14 +130,14 @@ public: */ NormalisableRange (ValueType rangeStart, ValueType rangeEnd, - std::function convertFrom0To1Func, - std::function convertTo0To1Func, - std::function snapToLegalValueFunc = nullptr) noexcept + ValueRemapFunction convertFrom0To1Func, + ValueRemapFunction convertTo0To1Func, + ValueRemapFunction snapToLegalValueFunc = {}) noexcept : start (rangeStart), end (rangeEnd), - convertFrom0To1Function (convertFrom0To1Func), - convertTo0To1Function (convertTo0To1Func), - snapToLegalValueFunction (snapToLegalValueFunc) + convertFrom0To1Function (std::move (convertFrom0To1Func)), + convertTo0To1Function (std::move (convertTo0To1Func)), + snapToLegalValueFunction (std::move (snapToLegalValueFunc)) { checkInvariants(); } @@ -274,11 +279,7 @@ private: return clampedValue; } - using ConversionFunction = std::function; - - ConversionFunction convertFrom0To1Function = {}, - convertTo0To1Function = {}, - snapToLegalValueFunction = {}; + ValueRemapFunction convertFrom0To1Function, convertTo0To1Function, snapToLegalValueFunction; }; } // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ConcertinaPanel.cpp b/modules/juce_gui_basics/layout/juce_ConcertinaPanel.cpp index 292cf32097..685c79fef9 100644 --- a/modules/juce_gui_basics/layout/juce_ConcertinaPanel.cpp +++ b/modules/juce_gui_basics/layout/juce_ConcertinaPanel.cpp @@ -31,15 +31,15 @@ struct ConcertinaPanel::PanelSizes { 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) {} - int setSize (const int newSize) noexcept + int setSize (int newSize) noexcept { jassert (minSize <= maxSize); - const int oldSize = size; + auto oldSize = size; size = jlimit (minSize, maxSize, newSize); return size - oldSize; } @@ -66,12 +66,12 @@ struct ConcertinaPanel::PanelSizes Array 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)); targetPosition = jmax (targetPosition, totalSpace - getMaximumSize (index, num)); @@ -83,14 +83,14 @@ struct ConcertinaPanel::PanelSizes 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)); newSizes.stretchRange (0, num, totalSpace - newSizes.getTotalSize (0, num), stretchAll); return newSizes; } - PanelSizes withResizedPanel (const int index, int panelHeight, int totalSpace) const + PanelSizes withResizedPanel (int index, int panelHeight, int totalSpace) const { PanelSizes newSizes (*this); @@ -100,8 +100,8 @@ struct ConcertinaPanel::PanelSizes } 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); newSizes.get(index).setSize (panelHeight); @@ -121,21 +121,21 @@ private: 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 i = start; i < end && spaceDiff > 0; ++i) 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 i = end; --i >= start && spaceDiff > 0;) 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 expandableItems; @@ -150,20 +150,19 @@ private: 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) 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;) 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) { @@ -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; while (start < end) tot += get (start++).size; return tot; } - int getMinimumSize (int start, const int end) const noexcept + int getMinimumSize (int start, int end) const noexcept { int tot = 0; while (start < end) tot += get (start++).minSize; return tot; } - int getMaximumSize (int start, const int end) const noexcept + int getMaximumSize (int start, int end) const noexcept { int tot = 0; + while (start < end) { - const int mx = get (start++).maxSize; + auto mx = get (start++).maxSize; + if (mx > 0x100000) return mx; @@ -215,7 +216,7 @@ private: class ConcertinaPanel::PanelHolder : public Component { public: - PanelHolder (Component* const comp, bool takeOwnership) + PanelHolder (Component* comp, bool takeOwnership) : component (comp, takeOwnership) { setRepaintsOnMouseActivity (true); @@ -286,13 +287,13 @@ private: int getHeaderSize() const noexcept { ConcertinaPanel& panel = getPanel(); - const int ourIndex = panel.holders.indexOf (this); + auto ourIndex = panel.holders.indexOf (this); return panel.currentSizes->get(ourIndex).minSize; } ConcertinaPanel& getPanel() const { - ConcertinaPanel* const panel = dynamic_cast (getParentComponent()); + auto panel = dynamic_cast (getParentComponent()); jassert (panel != nullptr); 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 (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); currentSizes->sizes.insert (insertIndex, PanelSizes::Panel (headerHeight, headerHeight, std::numeric_limits::max())); addAndMakeVisible (holder); @@ -336,7 +337,7 @@ void ConcertinaPanel::addPanel (int insertIndex, Component* component, bool take void ConcertinaPanel::removePanel (Component* component) { - const int index = indexOfComp (component); + auto index = indexOfComp (component); 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! 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); 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); } 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! if (index >= 0) @@ -376,7 +377,7 @@ void ConcertinaPanel::setMaximumPanelSize (Component* component, int maximumSize 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! if (index >= 0) @@ -393,7 +394,7 @@ void ConcertinaPanel::setCustomPanelHeader (Component* component, Component* cus { OptionalScopedPointer 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! if (index >= 0) @@ -419,20 +420,20 @@ ConcertinaPanel::PanelSizes ConcertinaPanel::getFittedSizes() const return currentSizes->fittedInto (getHeight()); } -void ConcertinaPanel::applyLayout (const PanelSizes& sizes, const bool animate) +void ConcertinaPanel::applyLayout (const PanelSizes& sizes, bool animate) { if (! animate) animator.cancelAllAnimations (false); const int animationDuration = 150; - const int w = getWidth(); + auto w = getWidth(); int y = 0; for (int i = 0; i < holders.size(); ++i) { PanelHolder& p = *holders.getUnchecked (i); - const int h = sizes.get (i).size; + auto h = sizes.get (i).size; const Rectangle pos (0, y, w, h); 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; applyLayout (getFittedSizes(), animate); diff --git a/modules/juce_gui_basics/layout/juce_GroupComponent.h b/modules/juce_gui_basics/layout/juce_GroupComponent.h index 0854e84e1e..2b00badd83 100644 --- a/modules/juce_gui_basics/layout/juce_GroupComponent.h +++ b/modules/juce_gui_basics/layout/juce_GroupComponent.h @@ -44,8 +44,8 @@ public: @param componentName the name to give the component @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. */ ~GroupComponent() override; @@ -58,15 +58,12 @@ public: String getText() const; /** Sets the positioning of the text label. - (The default is Justification::left) - @see getTextLabelPosition */ void setTextLabelPosition (Justification justification); /** Returns the current text label position. - @see setTextLabelPosition */ Justification getTextLabelPosition() const noexcept { return justification; } diff --git a/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.cpp b/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.cpp index 7ee552f6a9..4e346b414d 100644 --- a/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.cpp +++ b/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.cpp @@ -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), - constrainer (constrainer_), - borderSize (5), - mouseZone (0) + constrainer (boundsConstrainer), + borderSize (5) { } -ResizableBorderComponent::~ResizableBorderComponent() -{ -} +ResizableBorderComponent::~ResizableBorderComponent() = default; //============================================================================== void ResizableBorderComponent::paint (Graphics& g) @@ -168,13 +165,10 @@ void ResizableBorderComponent::mouseUp (const MouseEvent&) 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& newBorderSize) +void ResizableBorderComponent::setBorderThickness (BorderSize newBorderSize) { if (borderSize != newBorderSize) { diff --git a/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.h b/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.h index 9e9c456d33..4939336dc1 100644 --- a/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.h +++ b/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.h @@ -78,7 +78,7 @@ public: @see getBorderThickness */ - void setBorderThickness (const BorderSize& newBorderSize); + void setBorderThickness (BorderSize newBorderSize); /** Returns the number of pixels wide that the draggable edges of this component are. diff --git a/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.cpp b/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.cpp index 7b3735cf06..e9350bf4c6 100644 --- a/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.cpp +++ b/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.cpp @@ -27,26 +27,23 @@ namespace juce { -ResizableCornerComponent::ResizableCornerComponent (Component* const componentToResize, - ComponentBoundsConstrainer* const constrainer_) +ResizableCornerComponent::ResizableCornerComponent (Component* componentToResize, + ComponentBoundsConstrainer* boundsConstrainer) : component (componentToResize), - constrainer (constrainer_) + constrainer (boundsConstrainer) { setRepaintsOnMouseActivity (true); setMouseCursor (MouseCursor::BottomRightCornerResizeCursor); } -ResizableCornerComponent::~ResizableCornerComponent() -{ -} +ResizableCornerComponent::~ResizableCornerComponent() = default; //============================================================================== void ResizableCornerComponent::paint (Graphics& g) { - getLookAndFeel() - .drawCornerResizer (g, getWidth(), getHeight(), - isMouseOverOrDragging(), - isMouseButtonDown()); + getLookAndFeel().drawCornerResizer (g, getWidth(), getHeight(), + isMouseOverOrDragging(), + isMouseButtonDown()); } void ResizableCornerComponent::mouseDown (const MouseEvent&) @@ -71,20 +68,15 @@ void ResizableCornerComponent::mouseDrag (const MouseEvent& e) return; } - Rectangle 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) - { constrainer->setBoundsForComponent (component, r, false, false, true, true); - } + else if (auto pos = component->getPositioner()) + pos->applyNewBounds (r); else - { - if (Component::Positioner* const pos = component->getPositioner()) - pos->applyNewBounds (r); - else - component->setBounds (r); - } + component->setBounds (r); } void ResizableCornerComponent::mouseUp (const MouseEvent&) @@ -98,8 +90,7 @@ bool ResizableCornerComponent::hitTest (int x, int y) if (getWidth() <= 0) return false; - const int yAtX = getHeight() - (getHeight() * x / getWidth()); - + auto yAtX = getHeight() - (getHeight() * x / getWidth()); return y >= yAtX - getHeight() / 4; } diff --git a/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.cpp b/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.cpp index 2fac0f042a..a62fbc3b66 100644 --- a/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.cpp +++ b/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.cpp @@ -27,21 +27,19 @@ namespace juce { -ResizableEdgeComponent::ResizableEdgeComponent (Component* const componentToResize, - ComponentBoundsConstrainer* const constrainer_, - Edge edge_) +ResizableEdgeComponent::ResizableEdgeComponent (Component* componentToResize, + ComponentBoundsConstrainer* boundsConstrainer, + Edge e) : component (componentToResize), - constrainer (constrainer_), - edge (edge_) + constrainer (boundsConstrainer), + edge (e) { setRepaintsOnMouseActivity (true); setMouseCursor (isVertical() ? MouseCursor::LeftRightResizeCursor : MouseCursor::UpDownResizeCursor); } -ResizableEdgeComponent::~ResizableEdgeComponent() -{ -} +ResizableEdgeComponent::~ResizableEdgeComponent() = default; //============================================================================== bool ResizableEdgeComponent::isVertical() const noexcept diff --git a/modules/juce_gui_basics/layout/juce_ScrollBar.cpp b/modules/juce_gui_basics/layout/juce_ScrollBar.cpp index 5f10fa8f98..62602d96ee 100644 --- a/modules/juce_gui_basics/layout/juce_ScrollBar.cpp +++ b/modules/juce_gui_basics/layout/juce_ScrollBar.cpp @@ -82,15 +82,15 @@ void ScrollBar::setRangeLimits (Range 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! setRangeLimits (Range (newMinimum, newMaximum), notification); } -bool ScrollBar::setCurrentRange (Range newRange, const NotificationType notification) +bool ScrollBar::setCurrentRange (Range newRange, NotificationType notification) { - const Range constrainedRange (totalRange.constrainRange (newRange)); + auto constrainedRange = totalRange.constrainRange (newRange); if (visibleRange != constrainedRange) { @@ -110,27 +110,27 @@ bool ScrollBar::setCurrentRange (Range newRange, const NotificationType return false; } -void ScrollBar::setCurrentRange (const double newStart, const double newSize, NotificationType notification) +void ScrollBar::setCurrentRange (double newStart, double newSize, NotificationType notification) { setCurrentRange (Range (newStart, newStart + newSize), notification); } -void ScrollBar::setCurrentRangeStart (const double newStart, NotificationType notification) +void ScrollBar::setCurrentRangeStart (double newStart, NotificationType notification) { setCurrentRange (visibleRange.movedToStartAt (newStart), notification); } -void ScrollBar::setSingleStepSize (const double newSingleStepSize) noexcept +void ScrollBar::setSingleStepSize (double newSingleStepSize) noexcept { singleStepSize = newSingleStepSize; } -bool ScrollBar::moveScrollbarInSteps (const int howManySteps, NotificationType notification) +bool ScrollBar::moveScrollbarInSteps (int howManySteps, NotificationType 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); } @@ -145,9 +145,9 @@ bool ScrollBar::scrollToBottom (NotificationType 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; 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); } -void ScrollBar::removeListener (Listener* const listener) +void ScrollBar::removeListener (Listener* listener) { listeners.remove (listener); } @@ -201,8 +201,8 @@ void ScrollBar::updateThumbPosition() 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) 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) { @@ -230,7 +230,7 @@ void ScrollBar::setOrientation (const bool shouldBeVertical) } } -void ScrollBar::setAutoHide (const bool shouldHideWhenFullRange) +void ScrollBar::setAutoHide (bool shouldHideWhenFullRange) { autohides = shouldHideWhenFullRange; updateThumbPosition(); @@ -248,8 +248,8 @@ void ScrollBar::paint (Graphics& g) { auto& lf = getLookAndFeel(); - const int thumb = (thumbAreaSize > lf.getMinimumScrollbarThumbSize (*this)) - ? thumbSize : 0; + auto thumb = (thumbAreaSize > lf.getMinimumScrollbarThumbSize (*this)) + ? thumbSize : 0; if (vertical) lf.drawScrollbar (g, *this, 0, thumbAreaStart, getWidth(), thumbAreaSize, @@ -273,7 +273,7 @@ void ScrollBar::resized() auto length = vertical ? getHeight() : getWidth(); auto& lf = getLookAndFeel(); - const bool buttonsVisible = lf.areScrollbarButtonsVisible(); + bool buttonsVisible = lf.areScrollbarButtonsVisible(); int buttonSize = 0; if (buttonsVisible) @@ -358,11 +358,11 @@ void ScrollBar::mouseDown (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) { - const int deltaPixels = mousePos - dragStartMousePos; + auto deltaPixels = mousePos - dragStartMousePos; setCurrentRangeStart (dragStartRange + deltaPixels * (totalRange.getLength() - visibleRange.getLength()) diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp index fee48f15e2..2099a9bc70 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp @@ -1412,7 +1412,7 @@ void TextEditor::setIndents (int newLeftIndent, int newTopIndent) topIndent = newTopIndent; } -void TextEditor::setBorder (const BorderSize& border) +void TextEditor::setBorder (BorderSize border) { borderSize = border; resized(); diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.h b/modules/juce_gui_basics/widgets/juce_TextEditor.h index 4dfe378630..be44cc4763 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.h +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.h @@ -482,7 +482,7 @@ public: /** Changes the size of border left around the edge of the component. @see getBorder */ - void setBorder (const BorderSize& border); + void setBorder (BorderSize border); /** Returns the size of border around the edge of the component. @see setBorder