From 2b18ef23926aad433abb838b47c2daad731bced9 Mon Sep 17 00:00:00 2001 From: jules Date: Thu, 28 Feb 2008 20:00:50 +0000 Subject: [PATCH] --- .../gui/components/controls/juce_ListBox.cpp | 6 +++++- .../gui/components/controls/juce_ListBox.h | 9 ++++++++- .../gui/components/layout/juce_ScrollBar.cpp | 9 ++++++++- .../gui/components/layout/juce_ScrollBar.h | 10 +++++++++- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/juce_appframework/gui/components/controls/juce_ListBox.cpp b/src/juce_appframework/gui/components/controls/juce_ListBox.cpp index 251c6e0dd8..e44ab8a720 100644 --- a/src/juce_appframework/gui/components/controls/juce_ListBox.cpp +++ b/src/juce_appframework/gui/components/controls/juce_ListBox.cpp @@ -350,7 +350,6 @@ ListBox::ListBox (const String& name, ListBoxModel* const model_) totalItems (0), rowHeight (22), minimumRowWidth (0), - scrollBarSize (18), outlineThickness (0), lastRowSelected (-1), mouseMoveSelects (false), @@ -424,6 +423,11 @@ void ListBox::visibilityChanged() viewport->updateVisibleArea (true); } +Viewport* ListBox::getViewPort() const throw() +{ + return viewport; +} + //============================================================================== void ListBox::updateContent() { diff --git a/src/juce_appframework/gui/components/controls/juce_ListBox.h b/src/juce_appframework/gui/components/controls/juce_ListBox.h index 1eb684d0a4..bbf3182d46 100644 --- a/src/juce_appframework/gui/components/controls/juce_ListBox.h +++ b/src/juce_appframework/gui/components/controls/juce_ListBox.h @@ -527,6 +527,13 @@ public: */ Image* createSnapshotOfSelectedRows(); + /** Returns the viewport that this ListBox uses. + + You may need to use this to change parameters such as whether scrollbars + are shown, etc. + */ + Viewport* getViewPort() const throw(); + //============================================================================== /** @internal */ @@ -562,7 +569,7 @@ private: ListViewport* viewport; Component* headerComponent; int totalItems, rowHeight, minimumRowWidth; - int scrollBarSize, outlineThickness; + int outlineThickness; int lastMouseX, lastMouseY, lastRowSelected; bool mouseMoveSelects, multipleSelection, hasDoneInitialUpdate; SparseSet selected; diff --git a/src/juce_appframework/gui/components/layout/juce_ScrollBar.cpp b/src/juce_appframework/gui/components/layout/juce_ScrollBar.cpp index 9a328ab02b..2bbf7b2039 100644 --- a/src/juce_appframework/gui/components/layout/juce_ScrollBar.cpp +++ b/src/juce_appframework/gui/components/layout/juce_ScrollBar.cpp @@ -102,6 +102,7 @@ ScrollBar::ScrollBar (const bool vertical_, minimumDelayInMillisecs (10), vertical (vertical_), isDraggingThumb (false), + alwaysVisible (false), upButton (0), downButton (0), listeners (2) @@ -234,7 +235,7 @@ void ScrollBar::updateThumbPosition() throw() newThumbStart += roundDoubleToInt (((rangeStart - minimum) * (thumbAreaSize - newThumbSize)) / ((maximum - minimum) - rangeSize)); - setVisible (maximum - minimum > rangeSize && rangeSize > 0.0); + setVisible (alwaysVisible || (maximum - minimum > rangeSize && rangeSize > 0.0)); if (thumbStart != newThumbStart || thumbSize != newThumbSize) { @@ -283,6 +284,12 @@ void ScrollBar::setButtonVisibility (const bool buttonsAreVisible) updateThumbPosition(); } +void ScrollBar::setAutoHide (const bool shouldHideWhenFullRange) +{ + alwaysVisible = ! shouldHideWhenFullRange; + updateThumbPosition(); +} + //============================================================================== void ScrollBar::paint (Graphics& g) { diff --git a/src/juce_appframework/gui/components/layout/juce_ScrollBar.h b/src/juce_appframework/gui/components/layout/juce_ScrollBar.h index 6316d2f06f..0357c205cf 100644 --- a/src/juce_appframework/gui/components/layout/juce_ScrollBar.h +++ b/src/juce_appframework/gui/components/layout/juce_ScrollBar.h @@ -116,6 +116,14 @@ public: /** Shows or hides the scrollbar's buttons. */ void setButtonVisibility (const bool buttonsAreVisible); + /** Tells the scrollbar whether to make itself invisible when not needed. + + 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. + */ + void setAutoHide (const bool shouldHideWhenFullRange); + //============================================================================== /** Sets the minimum and maximum values that the bar will move between. @@ -287,7 +295,7 @@ private: int thumbAreaStart, thumbAreaSize, thumbStart, thumbSize; int dragStartMousePos, lastMousePos; int initialDelayInMillisecs, repeatDelayInMillisecs, minimumDelayInMillisecs; - bool vertical, isDraggingThumb; + bool vertical, isDraggingThumb, alwaysVisible; Button* upButton; Button* downButton; SortedSet listeners;