diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 38f574497e..c5179d4df5 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -61102,7 +61102,7 @@ ScrollBar::ScrollBar (const bool vertical_, minimumDelayInMillisecs (10), vertical (vertical_), isDraggingThumb (false), - alwaysVisible (false), + autohides (true), upButton (0), downButton (0) { @@ -61229,7 +61229,7 @@ void ScrollBar::updateThumbPosition() newThumbStart += roundToInt (((visibleRange.getStart() - totalRange.getStart()) * (thumbAreaSize - newThumbSize)) / (totalRange.getLength() - visibleRange.getLength())); - setVisible (alwaysVisible || (totalRange.getLength() > visibleRange.getLength() && visibleRange.getLength() > 0.0)); + setVisible ((! autohides) || (totalRange.getLength() > visibleRange.getLength() && visibleRange.getLength() > 0.0)); if (thumbStart != newThumbStart || thumbSize != newThumbSize) { @@ -61282,10 +61282,15 @@ void ScrollBar::setButtonVisibility (const bool buttonsAreVisible) void ScrollBar::setAutoHide (const bool shouldHideWhenFullRange) { - alwaysVisible = ! shouldHideWhenFullRange; + autohides = shouldHideWhenFullRange; updateThumbPosition(); } +bool ScrollBar::autoHides() const throw() +{ + return autohides; +} + void ScrollBar::paint (Graphics& g) { if (thumbAreaSize > 0) @@ -62935,8 +62940,8 @@ void Viewport::updateVisibleRegion() && contentComp->getWidth() <= getWidth() && contentComp->getHeight() <= getHeight()) { - horizontalScrollBar->setVisible (false); - verticalScrollBar->setVisible (false); + horizontalScrollBar->setVisible (! horizontalScrollBar->autoHides()); + verticalScrollBar->setVisible (! verticalScrollBar->autoHides()); } horizontalScrollBar->setRangeLimits (0.0, contentComp->getWidth()); @@ -62944,14 +62949,14 @@ void Viewport::updateVisibleRegion() horizontalScrollBar->setSingleStepSize (singleStepX); if (! (contentComp->getWidth() > 0 && showHScrollbar && getHeight() > getScrollBarThickness())) - horizontalScrollBar->setVisible (false); + horizontalScrollBar->setVisible (! horizontalScrollBar->autoHides()); verticalScrollBar->setRangeLimits (0.0, contentComp->getHeight()); verticalScrollBar->setCurrentRange (newVY, getMaximumVisibleHeight()); verticalScrollBar->setSingleStepSize (singleStepY); if (! (contentComp->getHeight() > 0 && showVScrollbar && getWidth() > getScrollBarThickness())) - verticalScrollBar->setVisible (false); + verticalScrollBar->setVisible (! verticalScrollBar->autoHides()); if (verticalScrollBar->isVisible()) { @@ -62996,8 +63001,8 @@ void Viewport::updateVisibleRegion() } else { - horizontalScrollBar->setVisible (false); - verticalScrollBar->setVisible (false); + horizontalScrollBar->setVisible (! horizontalScrollBar->autoHides()); + verticalScrollBar->setVisible (! verticalScrollBar->autoHides()); } } diff --git a/juce_amalgamated.h b/juce_amalgamated.h index d8d86f59cf..da42eb2cce 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -16208,6 +16208,8 @@ public: void setAutoHide (bool shouldHideWhenFullRange); + bool autoHides() const throw(); + void setRangeLimits (const Range& newRangeLimit); void setRangeLimits (double minimum, double maximum); @@ -16274,7 +16276,7 @@ private: int thumbAreaStart, thumbAreaSize, thumbStart, thumbSize; int dragStartMousePos, lastMousePos; int initialDelayInMillisecs, repeatDelayInMillisecs, minimumDelayInMillisecs; - bool vertical, isDraggingThumb, alwaysVisible; + bool vertical, isDraggingThumb, autohides; class ScrollbarButton; ScrollbarButton* upButton; ScrollbarButton* downButton; diff --git a/src/gui/components/layout/juce_ScrollBar.cpp b/src/gui/components/layout/juce_ScrollBar.cpp index 5c6ab6075b..394079dda7 100644 --- a/src/gui/components/layout/juce_ScrollBar.cpp +++ b/src/gui/components/layout/juce_ScrollBar.cpp @@ -91,7 +91,7 @@ ScrollBar::ScrollBar (const bool vertical_, minimumDelayInMillisecs (10), vertical (vertical_), isDraggingThumb (false), - alwaysVisible (false), + autohides (true), upButton (0), downButton (0) { @@ -221,7 +221,7 @@ void ScrollBar::updateThumbPosition() newThumbStart += roundToInt (((visibleRange.getStart() - totalRange.getStart()) * (thumbAreaSize - newThumbSize)) / (totalRange.getLength() - visibleRange.getLength())); - setVisible (alwaysVisible || (totalRange.getLength() > visibleRange.getLength() && visibleRange.getLength() > 0.0)); + setVisible ((! autohides) || (totalRange.getLength() > visibleRange.getLength() && visibleRange.getLength() > 0.0)); if (thumbStart != newThumbStart || thumbSize != newThumbSize) { @@ -274,10 +274,15 @@ void ScrollBar::setButtonVisibility (const bool buttonsAreVisible) void ScrollBar::setAutoHide (const bool shouldHideWhenFullRange) { - alwaysVisible = ! shouldHideWhenFullRange; + autohides = shouldHideWhenFullRange; updateThumbPosition(); } +bool ScrollBar::autoHides() const throw() +{ + return autohides; +} + //============================================================================== void ScrollBar::paint (Graphics& g) { diff --git a/src/gui/components/layout/juce_ScrollBar.h b/src/gui/components/layout/juce_ScrollBar.h index 3121743840..32a2982ec0 100644 --- a/src/gui/components/layout/juce_ScrollBar.h +++ b/src/gui/components/layout/juce_ScrollBar.h @@ -116,9 +116,16 @@ public: The default behaviour is for a scrollbar to become invisible when the thumb fills the whole of its range (i.e. when it can't be moved). Setting this value to false forces the bar to always be visible. + @see autoHides() */ void setAutoHide (bool shouldHideWhenFullRange); + /** Returns true if this scrollbar is set to auto-hide when its thumb is as big + as its maximum range. + @see setAutoHide + */ + bool autoHides() const throw(); + //============================================================================== /** Sets the minimum and maximum values that the bar will move between. @@ -315,7 +322,7 @@ private: int thumbAreaStart, thumbAreaSize, thumbStart, thumbSize; int dragStartMousePos, lastMousePos; int initialDelayInMillisecs, repeatDelayInMillisecs, minimumDelayInMillisecs; - bool vertical, isDraggingThumb, alwaysVisible; + bool vertical, isDraggingThumb, autohides; class ScrollbarButton; ScrollbarButton* upButton; ScrollbarButton* downButton; diff --git a/src/gui/components/layout/juce_Viewport.cpp b/src/gui/components/layout/juce_Viewport.cpp index 00e670bc3a..7ae5e60d72 100644 --- a/src/gui/components/layout/juce_Viewport.cpp +++ b/src/gui/components/layout/juce_Viewport.cpp @@ -183,8 +183,8 @@ void Viewport::updateVisibleRegion() && contentComp->getWidth() <= getWidth() && contentComp->getHeight() <= getHeight()) { - horizontalScrollBar->setVisible (false); - verticalScrollBar->setVisible (false); + horizontalScrollBar->setVisible (! horizontalScrollBar->autoHides()); + verticalScrollBar->setVisible (! verticalScrollBar->autoHides()); } horizontalScrollBar->setRangeLimits (0.0, contentComp->getWidth()); @@ -192,14 +192,14 @@ void Viewport::updateVisibleRegion() horizontalScrollBar->setSingleStepSize (singleStepX); if (! (contentComp->getWidth() > 0 && showHScrollbar && getHeight() > getScrollBarThickness())) - horizontalScrollBar->setVisible (false); + horizontalScrollBar->setVisible (! horizontalScrollBar->autoHides()); verticalScrollBar->setRangeLimits (0.0, contentComp->getHeight()); verticalScrollBar->setCurrentRange (newVY, getMaximumVisibleHeight()); verticalScrollBar->setSingleStepSize (singleStepY); if (! (contentComp->getHeight() > 0 && showVScrollbar && getWidth() > getScrollBarThickness())) - verticalScrollBar->setVisible (false); + verticalScrollBar->setVisible (! verticalScrollBar->autoHides()); if (verticalScrollBar->isVisible()) { @@ -244,8 +244,8 @@ void Viewport::updateVisibleRegion() } else { - horizontalScrollBar->setVisible (false); - verticalScrollBar->setVisible (false); + horizontalScrollBar->setVisible (! horizontalScrollBar->autoHides()); + verticalScrollBar->setVisible (! verticalScrollBar->autoHides()); } }