diff --git a/modules/juce_gui_basics/layout/juce_ScrollBar.cpp b/modules/juce_gui_basics/layout/juce_ScrollBar.cpp index 30182c8c88..f7777de47a 100644 --- a/modules/juce_gui_basics/layout/juce_ScrollBar.cpp +++ b/modules/juce_gui_basics/layout/juce_ScrollBar.cpp @@ -25,8 +25,8 @@ class ScrollBar::ScrollbarButton : public Button { public: - ScrollbarButton (const int direction_, ScrollBar& owner_) - : Button (String::empty), direction (direction_), owner (owner_) + ScrollbarButton (int direc, ScrollBar& s) + : Button (String()), direction (direc), owner (s) { setWantsKeyboardFocus (false); } @@ -52,7 +52,7 @@ private: //============================================================================== -ScrollBar::ScrollBar (const bool vertical_) +ScrollBar::ScrollBar (const bool shouldBeVertical) : totalRange (0.0, 1.0), visibleRange (0.0, 0.1), singleStepSize (0.1), @@ -60,16 +60,13 @@ ScrollBar::ScrollBar (const bool vertical_) thumbAreaSize (0), thumbStart (0), thumbSize (0), - minimumScrollBarThumbSize (0), initialDelayInMillisecs (100), repeatDelayInMillisecs (50), minimumDelayInMillisecs (10), - vertical (vertical_), + vertical (shouldBeVertical), isDraggingThumb (false), autohides (true) { - minimumScrollBarThumbSize = getLookAndFeel().getMinimumScrollbarThumbSize (*this); - setRepaintsOnMouseActivity (true); setFocusContainer (true); } @@ -97,8 +94,7 @@ void ScrollBar::setRangeLimits (const double newMinimum, const double newMaximum setRangeLimits (Range (newMinimum, newMaximum), notification); } -bool ScrollBar::setCurrentRange (Range newRange, - const NotificationType notification) +bool ScrollBar::setCurrentRange (Range newRange, const NotificationType notification) { const Range constrainedRange (totalRange.constrainRange (newRange)); @@ -155,18 +151,18 @@ bool ScrollBar::scrollToBottom (NotificationType notification) return setCurrentRange (visibleRange.movedToEndAt (getMaximumRangeLimit()), notification); } -void ScrollBar::setButtonRepeatSpeed (const int initialDelayInMillisecs_, - const int repeatDelayInMillisecs_, - const int minimumDelayInMillisecs_) +void ScrollBar::setButtonRepeatSpeed (const int newInitialDelay, + const int newRepeatDelay, + const int newMinimumDelay) { - initialDelayInMillisecs = initialDelayInMillisecs_; - repeatDelayInMillisecs = repeatDelayInMillisecs_; - minimumDelayInMillisecs = minimumDelayInMillisecs_; + initialDelayInMillisecs = newInitialDelay; + repeatDelayInMillisecs = newRepeatDelay; + minimumDelayInMillisecs = newMinimumDelay; if (upButton != nullptr) { - upButton ->setRepeatSpeed (initialDelayInMillisecs, repeatDelayInMillisecs, minimumDelayInMillisecs); - downButton->setRepeatSpeed (initialDelayInMillisecs, repeatDelayInMillisecs, minimumDelayInMillisecs); + upButton ->setRepeatSpeed (newInitialDelay, newRepeatDelay, newMinimumDelay); + downButton->setRepeatSpeed (newInitialDelay, newRepeatDelay, newMinimumDelay); } } @@ -190,6 +186,8 @@ void ScrollBar::handleAsyncUpdate() //============================================================================== void ScrollBar::updateThumbPosition() { + const int minimumScrollBarThumbSize = getLookAndFeel().getMinimumScrollbarThumbSize (*this); + int newThumbSize = roundToInt (totalRange.getLength() > 0 ? (visibleRange.getLength() * thumbAreaSize) / totalRange.getLength() : thumbAreaSize); @@ -205,7 +203,8 @@ void ScrollBar::updateThumbPosition() newThumbStart += roundToInt (((visibleRange.getStart() - totalRange.getStart()) * (thumbAreaSize - newThumbSize)) / (totalRange.getLength() - visibleRange.getLength())); - setVisible ((! autohides) || (totalRange.getLength() > visibleRange.getLength() && visibleRange.getLength() > 0.0)); + setVisible ((! autohides) || (totalRange.getLength() > visibleRange.getLength() + && visibleRange.getLength() > 0.0)); if (thumbStart != newThumbStart || thumbSize != newThumbSize) { @@ -281,7 +280,6 @@ void ScrollBar::resized() const int length = vertical ? getHeight() : getWidth(); LookAndFeel& lf = getLookAndFeel(); - minimumScrollBarThumbSize = lf.getMinimumScrollbarThumbSize (*this); const bool buttonsVisible = lf.areScrollbarButtonsVisible(); int buttonSize = 0; @@ -311,20 +309,22 @@ void ScrollBar::resized() else { thumbAreaStart = buttonSize; - thumbAreaSize = length - (buttonSize << 1); + thumbAreaSize = length - 2 * buttonSize; } if (upButton != nullptr) { + Rectangle r (getLocalBounds()); + if (vertical) { - upButton->setBounds (0, 0, getWidth(), buttonSize); - downButton->setBounds (0, thumbAreaStart + thumbAreaSize, getWidth(), buttonSize); + upButton->setBounds (r.removeFromTop (buttonSize)); + downButton->setBounds (r.removeFromBottom (buttonSize)); } else { - upButton->setBounds (0, 0, buttonSize, getHeight()); - downButton->setBounds (thumbAreaStart + thumbAreaSize, 0, buttonSize, getHeight()); + upButton->setBounds (r.removeFromLeft (buttonSize)); + downButton->setBounds (r.removeFromRight (buttonSize)); } } diff --git a/modules/juce_gui_basics/layout/juce_ScrollBar.h b/modules/juce_gui_basics/layout/juce_ScrollBar.h index b59fed2d8d..c663bfdba0 100644 --- a/modules/juce_gui_basics/layout/juce_ScrollBar.h +++ b/modules/juce_gui_basics/layout/juce_ScrollBar.h @@ -381,10 +381,9 @@ public: private: //============================================================================== - Range totalRange, visibleRange; + Range totalRange, visibleRange; double singleStepSize, dragStartRange; int thumbAreaStart, thumbAreaSize, thumbStart, thumbSize; - int minimumScrollBarThumbSize; int dragStartMousePos, lastMousePos; int initialDelayInMillisecs, repeatDelayInMillisecs, minimumDelayInMillisecs; bool vertical, isDraggingThumb, autohides; diff --git a/modules/juce_gui_basics/mouse/juce_TooltipClient.h b/modules/juce_gui_basics/mouse/juce_TooltipClient.h index 06cd315b66..c449f9a151 100644 --- a/modules/juce_gui_basics/mouse/juce_TooltipClient.h +++ b/modules/juce_gui_basics/mouse/juce_TooltipClient.h @@ -65,14 +65,14 @@ class JUCE_API SettableTooltipClient : public TooltipClient public: //============================================================================== /** Destructor. */ - virtual ~SettableTooltipClient() {} + ~SettableTooltipClient() {} //============================================================================== /** Assigns a new tooltip to this object. */ virtual void setTooltip (const String& newTooltip) { tooltipString = newTooltip; } /** Returns the tooltip assigned to this object. */ - virtual String getTooltip() { return tooltipString; } + String getTooltip() override { return tooltipString; } protected: SettableTooltipClient() {}