Browse Source

Viewport scrollbar fix.

tags/2021-05-28
Julian Storer 15 years ago
parent
commit
87175e988b
5 changed files with 39 additions and 20 deletions
  1. +14
    -9
      juce_amalgamated.cpp
  2. +3
    -1
      juce_amalgamated.h
  3. +8
    -3
      src/gui/components/layout/juce_ScrollBar.cpp
  4. +8
    -1
      src/gui/components/layout/juce_ScrollBar.h
  5. +6
    -6
      src/gui/components/layout/juce_Viewport.cpp

+ 14
- 9
juce_amalgamated.cpp View File

@@ -61102,7 +61102,7 @@ ScrollBar::ScrollBar (const bool vertical_,
minimumDelayInMillisecs (10), minimumDelayInMillisecs (10),
vertical (vertical_), vertical (vertical_),
isDraggingThumb (false), isDraggingThumb (false),
alwaysVisible (false),
autohides (true),
upButton (0), upButton (0),
downButton (0) downButton (0)
{ {
@@ -61229,7 +61229,7 @@ void ScrollBar::updateThumbPosition()
newThumbStart += roundToInt (((visibleRange.getStart() - totalRange.getStart()) * (thumbAreaSize - newThumbSize)) newThumbStart += roundToInt (((visibleRange.getStart() - totalRange.getStart()) * (thumbAreaSize - newThumbSize))
/ (totalRange.getLength() - visibleRange.getLength())); / (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) if (thumbStart != newThumbStart || thumbSize != newThumbSize)
{ {
@@ -61282,10 +61282,15 @@ void ScrollBar::setButtonVisibility (const bool buttonsAreVisible)


void ScrollBar::setAutoHide (const bool shouldHideWhenFullRange) void ScrollBar::setAutoHide (const bool shouldHideWhenFullRange)
{ {
alwaysVisible = ! shouldHideWhenFullRange;
autohides = shouldHideWhenFullRange;
updateThumbPosition(); updateThumbPosition();
} }


bool ScrollBar::autoHides() const throw()
{
return autohides;
}

void ScrollBar::paint (Graphics& g) void ScrollBar::paint (Graphics& g)
{ {
if (thumbAreaSize > 0) if (thumbAreaSize > 0)
@@ -62935,8 +62940,8 @@ void Viewport::updateVisibleRegion()
&& contentComp->getWidth() <= getWidth() && contentComp->getWidth() <= getWidth()
&& contentComp->getHeight() <= getHeight()) && contentComp->getHeight() <= getHeight())
{ {
horizontalScrollBar->setVisible (false);
verticalScrollBar->setVisible (false);
horizontalScrollBar->setVisible (! horizontalScrollBar->autoHides());
verticalScrollBar->setVisible (! verticalScrollBar->autoHides());
} }


horizontalScrollBar->setRangeLimits (0.0, contentComp->getWidth()); horizontalScrollBar->setRangeLimits (0.0, contentComp->getWidth());
@@ -62944,14 +62949,14 @@ void Viewport::updateVisibleRegion()
horizontalScrollBar->setSingleStepSize (singleStepX); horizontalScrollBar->setSingleStepSize (singleStepX);


if (! (contentComp->getWidth() > 0 && showHScrollbar && getHeight() > getScrollBarThickness())) if (! (contentComp->getWidth() > 0 && showHScrollbar && getHeight() > getScrollBarThickness()))
horizontalScrollBar->setVisible (false);
horizontalScrollBar->setVisible (! horizontalScrollBar->autoHides());


verticalScrollBar->setRangeLimits (0.0, contentComp->getHeight()); verticalScrollBar->setRangeLimits (0.0, contentComp->getHeight());
verticalScrollBar->setCurrentRange (newVY, getMaximumVisibleHeight()); verticalScrollBar->setCurrentRange (newVY, getMaximumVisibleHeight());
verticalScrollBar->setSingleStepSize (singleStepY); verticalScrollBar->setSingleStepSize (singleStepY);


if (! (contentComp->getHeight() > 0 && showVScrollbar && getWidth() > getScrollBarThickness())) if (! (contentComp->getHeight() > 0 && showVScrollbar && getWidth() > getScrollBarThickness()))
verticalScrollBar->setVisible (false);
verticalScrollBar->setVisible (! verticalScrollBar->autoHides());


if (verticalScrollBar->isVisible()) if (verticalScrollBar->isVisible())
{ {
@@ -62996,8 +63001,8 @@ void Viewport::updateVisibleRegion()
} }
else else
{ {
horizontalScrollBar->setVisible (false);
verticalScrollBar->setVisible (false);
horizontalScrollBar->setVisible (! horizontalScrollBar->autoHides());
verticalScrollBar->setVisible (! verticalScrollBar->autoHides());
} }
} }




+ 3
- 1
juce_amalgamated.h View File

@@ -16208,6 +16208,8 @@ public:


void setAutoHide (bool shouldHideWhenFullRange); void setAutoHide (bool shouldHideWhenFullRange);


bool autoHides() const throw();

void setRangeLimits (const Range<double>& newRangeLimit); void setRangeLimits (const Range<double>& newRangeLimit);


void setRangeLimits (double minimum, double maximum); void setRangeLimits (double minimum, double maximum);
@@ -16274,7 +16276,7 @@ private:
int thumbAreaStart, thumbAreaSize, thumbStart, thumbSize; int thumbAreaStart, thumbAreaSize, thumbStart, thumbSize;
int dragStartMousePos, lastMousePos; int dragStartMousePos, lastMousePos;
int initialDelayInMillisecs, repeatDelayInMillisecs, minimumDelayInMillisecs; int initialDelayInMillisecs, repeatDelayInMillisecs, minimumDelayInMillisecs;
bool vertical, isDraggingThumb, alwaysVisible;
bool vertical, isDraggingThumb, autohides;
class ScrollbarButton; class ScrollbarButton;
ScrollbarButton* upButton; ScrollbarButton* upButton;
ScrollbarButton* downButton; ScrollbarButton* downButton;


+ 8
- 3
src/gui/components/layout/juce_ScrollBar.cpp View File

@@ -91,7 +91,7 @@ ScrollBar::ScrollBar (const bool vertical_,
minimumDelayInMillisecs (10), minimumDelayInMillisecs (10),
vertical (vertical_), vertical (vertical_),
isDraggingThumb (false), isDraggingThumb (false),
alwaysVisible (false),
autohides (true),
upButton (0), upButton (0),
downButton (0) downButton (0)
{ {
@@ -221,7 +221,7 @@ void ScrollBar::updateThumbPosition()
newThumbStart += roundToInt (((visibleRange.getStart() - totalRange.getStart()) * (thumbAreaSize - newThumbSize)) newThumbStart += roundToInt (((visibleRange.getStart() - totalRange.getStart()) * (thumbAreaSize - newThumbSize))
/ (totalRange.getLength() - visibleRange.getLength())); / (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) if (thumbStart != newThumbStart || thumbSize != newThumbSize)
{ {
@@ -274,10 +274,15 @@ void ScrollBar::setButtonVisibility (const bool buttonsAreVisible)
void ScrollBar::setAutoHide (const bool shouldHideWhenFullRange) void ScrollBar::setAutoHide (const bool shouldHideWhenFullRange)
{ {
alwaysVisible = ! shouldHideWhenFullRange;
autohides = shouldHideWhenFullRange;
updateThumbPosition(); updateThumbPosition();
} }
bool ScrollBar::autoHides() const throw()
{
return autohides;
}
//============================================================================== //==============================================================================
void ScrollBar::paint (Graphics& g) void ScrollBar::paint (Graphics& g)
{ {


+ 8
- 1
src/gui/components/layout/juce_ScrollBar.h View File

@@ -116,9 +116,16 @@ public:
The default behaviour is for a scrollbar to become invisible when the thumb 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 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. value to false forces the bar to always be visible.
@see autoHides()
*/ */
void setAutoHide (bool shouldHideWhenFullRange); 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. /** Sets the minimum and maximum values that the bar will move between.
@@ -315,7 +322,7 @@ private:
int thumbAreaStart, thumbAreaSize, thumbStart, thumbSize; int thumbAreaStart, thumbAreaSize, thumbStart, thumbSize;
int dragStartMousePos, lastMousePos; int dragStartMousePos, lastMousePos;
int initialDelayInMillisecs, repeatDelayInMillisecs, minimumDelayInMillisecs; int initialDelayInMillisecs, repeatDelayInMillisecs, minimumDelayInMillisecs;
bool vertical, isDraggingThumb, alwaysVisible;
bool vertical, isDraggingThumb, autohides;
class ScrollbarButton; class ScrollbarButton;
ScrollbarButton* upButton; ScrollbarButton* upButton;
ScrollbarButton* downButton; ScrollbarButton* downButton;


+ 6
- 6
src/gui/components/layout/juce_Viewport.cpp View File

@@ -183,8 +183,8 @@ void Viewport::updateVisibleRegion()
&& contentComp->getWidth() <= getWidth() && contentComp->getWidth() <= getWidth()
&& contentComp->getHeight() <= getHeight()) && contentComp->getHeight() <= getHeight())
{ {
horizontalScrollBar->setVisible (false);
verticalScrollBar->setVisible (false);
horizontalScrollBar->setVisible (! horizontalScrollBar->autoHides());
verticalScrollBar->setVisible (! verticalScrollBar->autoHides());
} }
horizontalScrollBar->setRangeLimits (0.0, contentComp->getWidth()); horizontalScrollBar->setRangeLimits (0.0, contentComp->getWidth());
@@ -192,14 +192,14 @@ void Viewport::updateVisibleRegion()
horizontalScrollBar->setSingleStepSize (singleStepX); horizontalScrollBar->setSingleStepSize (singleStepX);
if (! (contentComp->getWidth() > 0 && showHScrollbar && getHeight() > getScrollBarThickness())) if (! (contentComp->getWidth() > 0 && showHScrollbar && getHeight() > getScrollBarThickness()))
horizontalScrollBar->setVisible (false);
horizontalScrollBar->setVisible (! horizontalScrollBar->autoHides());
verticalScrollBar->setRangeLimits (0.0, contentComp->getHeight()); verticalScrollBar->setRangeLimits (0.0, contentComp->getHeight());
verticalScrollBar->setCurrentRange (newVY, getMaximumVisibleHeight()); verticalScrollBar->setCurrentRange (newVY, getMaximumVisibleHeight());
verticalScrollBar->setSingleStepSize (singleStepY); verticalScrollBar->setSingleStepSize (singleStepY);
if (! (contentComp->getHeight() > 0 && showVScrollbar && getWidth() > getScrollBarThickness())) if (! (contentComp->getHeight() > 0 && showVScrollbar && getWidth() > getScrollBarThickness()))
verticalScrollBar->setVisible (false);
verticalScrollBar->setVisible (! verticalScrollBar->autoHides());
if (verticalScrollBar->isVisible()) if (verticalScrollBar->isVisible())
{ {
@@ -244,8 +244,8 @@ void Viewport::updateVisibleRegion()
} }
else else
{ {
horizontalScrollBar->setVisible (false);
verticalScrollBar->setVisible (false);
horizontalScrollBar->setVisible (! horizontalScrollBar->autoHides());
verticalScrollBar->setVisible (! verticalScrollBar->autoHides());
} }
} }


Loading…
Cancel
Save