mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Removed the Scrollbar's setButtonVisibility method, and instead added LookAndFeel::areScrollbarButtonsVisible()
This commit is contained in:
parent
65f147b241
commit
cd5893d6e8
8 changed files with 33 additions and 52 deletions
|
|
@ -59,8 +59,7 @@ private:
|
|||
|
||||
|
||||
//==============================================================================
|
||||
ScrollBar::ScrollBar (const bool vertical_,
|
||||
const bool buttonsAreVisible)
|
||||
ScrollBar::ScrollBar (const bool vertical_)
|
||||
: totalRange (0.0, 1.0),
|
||||
visibleRange (0.0, 0.1),
|
||||
singleStepSize (0.1),
|
||||
|
|
@ -75,8 +74,6 @@ ScrollBar::ScrollBar (const bool vertical_,
|
|||
isDraggingThumb (false),
|
||||
autohides (true)
|
||||
{
|
||||
setButtonVisibility (buttonsAreVisible);
|
||||
|
||||
setRepaintsOnMouseActivity (true);
|
||||
setFocusContainer (true);
|
||||
}
|
||||
|
|
@ -235,22 +232,6 @@ void ScrollBar::setOrientation (const bool shouldBeVertical)
|
|||
}
|
||||
}
|
||||
|
||||
void ScrollBar::setButtonVisibility (const bool buttonsAreVisible)
|
||||
{
|
||||
upButton = nullptr;
|
||||
downButton = nullptr;
|
||||
|
||||
if (buttonsAreVisible)
|
||||
{
|
||||
addAndMakeVisible (upButton = new ScrollbarButton (vertical ? 0 : 3, *this));
|
||||
addAndMakeVisible (downButton = new ScrollbarButton (vertical ? 2 : 1, *this));
|
||||
|
||||
setButtonRepeatSpeed (initialDelayInMillisecs, repeatDelayInMillisecs, minimumDelayInMillisecs);
|
||||
}
|
||||
|
||||
updateThumbPosition();
|
||||
}
|
||||
|
||||
void ScrollBar::setAutoHide (const bool shouldHideWhenFullRange)
|
||||
{
|
||||
autohides = shouldHideWhenFullRange;
|
||||
|
|
@ -296,12 +277,31 @@ void ScrollBar::paint (Graphics& g)
|
|||
void ScrollBar::lookAndFeelChanged()
|
||||
{
|
||||
setComponentEffect (getLookAndFeel().getScrollbarEffect());
|
||||
resized();
|
||||
}
|
||||
|
||||
void ScrollBar::resized()
|
||||
{
|
||||
const int length = vertical ? getHeight() : getWidth();
|
||||
|
||||
const bool buttonsVisible = getLookAndFeel().areScrollbarButtonsVisible();
|
||||
|
||||
if (buttonsVisible)
|
||||
{
|
||||
if (upButton == nullptr)
|
||||
{
|
||||
addAndMakeVisible (upButton = new ScrollbarButton (vertical ? 0 : 3, *this));
|
||||
addAndMakeVisible (downButton = new ScrollbarButton (vertical ? 2 : 1, *this));
|
||||
|
||||
setButtonRepeatSpeed (initialDelayInMillisecs, repeatDelayInMillisecs, minimumDelayInMillisecs);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
upButton = nullptr;
|
||||
downButton = nullptr;
|
||||
}
|
||||
|
||||
const int buttonSize = upButton != nullptr ? jmin (getLookAndFeel().getScrollbarButtonSize (*this), length / 2)
|
||||
: 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
#define __JUCE_SCROLLBAR_JUCEHEADER__
|
||||
|
||||
#include "../buttons/juce_Button.h"
|
||||
|
||||
class Viewport;
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
|
|
@ -50,7 +50,7 @@
|
|||
@see ScrollBar::Listener
|
||||
*/
|
||||
class JUCE_API ScrollBar : public Component,
|
||||
public AsyncUpdater,
|
||||
private AsyncUpdater,
|
||||
private Timer
|
||||
{
|
||||
public:
|
||||
|
|
@ -60,8 +60,7 @@ public:
|
|||
@param isVertical whether it should be a vertical or horizontal bar
|
||||
@param buttonsAreVisible whether to show the up/down or left/right buttons
|
||||
*/
|
||||
ScrollBar (bool isVertical,
|
||||
bool buttonsAreVisible = true);
|
||||
ScrollBar (bool isVertical);
|
||||
|
||||
/** Destructor. */
|
||||
~ScrollBar();
|
||||
|
|
@ -79,9 +78,6 @@ public:
|
|||
*/
|
||||
void setOrientation (bool shouldBeVertical);
|
||||
|
||||
/** Shows or hides the scrollbar's buttons. */
|
||||
void setButtonVisibility (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
|
||||
|
|
@ -295,8 +291,6 @@ public:
|
|||
/** @internal */
|
||||
void lookAndFeelChanged();
|
||||
/** @internal */
|
||||
void handleAsyncUpdate();
|
||||
/** @internal */
|
||||
void mouseDown (const MouseEvent&);
|
||||
/** @internal */
|
||||
void mouseDrag (const MouseEvent&);
|
||||
|
|
@ -320,9 +314,12 @@ private:
|
|||
ScopedPointer<ScrollbarButton> upButton, downButton;
|
||||
ListenerList <Listener> listeners;
|
||||
|
||||
void handleAsyncUpdate();
|
||||
void updateThumbPosition();
|
||||
void timerCallback();
|
||||
|
||||
friend class Viewport;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ScrollBar);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -328,12 +328,6 @@ int Viewport::getScrollBarThickness() const
|
|||
: getLookAndFeel().getDefaultScrollbarWidth();
|
||||
}
|
||||
|
||||
void Viewport::setScrollBarButtonVisibility (const bool buttonsVisible)
|
||||
{
|
||||
verticalScrollBar.setButtonVisibility (buttonsVisible);
|
||||
horizontalScrollBar.setButtonVisibility (buttonsVisible);
|
||||
}
|
||||
|
||||
void Viewport::scrollBarMoved (ScrollBar* scrollBarThatHasMoved, double newRangeStart)
|
||||
{
|
||||
const int newRangeStartInt = roundToInt (newRangeStart);
|
||||
|
|
|
|||
|
|
@ -225,12 +225,6 @@ public:
|
|||
*/
|
||||
void setSingleStepSizes (int stepX, int stepY);
|
||||
|
||||
/** Shows or hides the buttons on any scrollbars that are used.
|
||||
|
||||
@see ScrollBar::setButtonVisibility
|
||||
*/
|
||||
void setScrollBarButtonVisibility (bool buttonsVisible);
|
||||
|
||||
/** Returns a pointer to the scrollbar component being used.
|
||||
Handy if you need to customise the bar somehow.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -713,6 +713,11 @@ void LookAndFeel::drawSpinningWaitAnimation (Graphics& g, const Colour& colour,
|
|||
}
|
||||
}
|
||||
|
||||
bool LookAndFeel::areScrollbarButtonsVisible()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void LookAndFeel::drawScrollbarButton (Graphics& g,
|
||||
ScrollBar& scrollbar,
|
||||
int width, int height,
|
||||
|
|
|
|||
|
|
@ -229,6 +229,8 @@ public:
|
|||
int x, int y, int w, int h);
|
||||
|
||||
//==============================================================================
|
||||
virtual bool areScrollbarButtonsVisible();
|
||||
|
||||
/** Draws one of the buttons on a scrollbar.
|
||||
|
||||
@param g the context to draw into
|
||||
|
|
|
|||
|
|
@ -1200,11 +1200,6 @@ void TextEditor::setScrollBarThickness (const int newThicknessPixels)
|
|||
viewport->setScrollBarThickness (newThicknessPixels);
|
||||
}
|
||||
|
||||
void TextEditor::setScrollBarButtonVisibility (const bool buttonsVisible)
|
||||
{
|
||||
viewport->setScrollBarButtonVisibility (buttonsVisible);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void TextEditor::clear()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -287,12 +287,6 @@ public:
|
|||
*/
|
||||
void setScrollBarThickness (int newThicknessPixels);
|
||||
|
||||
/** Shows or hides the buttons on any scrollbars that are used.
|
||||
|
||||
@see ScrollBar::setButtonVisibility
|
||||
*/
|
||||
void setScrollBarButtonVisibility (bool buttonsVisible);
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
Receives callbacks from a TextEditor component when it changes.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue