LMMS
Loading...
Searching...
No Matches
juce::ScrollBar Class Reference

#include <juce_ScrollBar.h>

Inheritance diagram for juce::ScrollBar:
juce::Component juce::AsyncUpdater juce::Timer juce::MouseListener

Classes

class  Listener
struct  LookAndFeelMethods
class  ScrollbarButton

Public Types

enum  ColourIds { backgroundColourId = 0x1000300 , thumbColourId = 0x1000400 , trackColourId = 0x1000401 }
Public Types inherited from juce::Component
enum class  FocusContainerType { none , focusContainer , keyboardFocusContainer }
enum  FocusChangeType { focusChangedByMouseClick , focusChangedByTabKey , focusChangedDirectly }

Public Member Functions

 ScrollBar (bool isVertical)
 ~ScrollBar () override
bool isVertical () const noexcept
void setOrientation (bool shouldBeVertical)
void setAutoHide (bool shouldHideWhenFullRange)
bool autoHides () const noexcept
void setRangeLimits (Range< double > newRangeLimit, NotificationType notification=sendNotificationAsync)
void setRangeLimits (double minimum, double maximum, NotificationType notification=sendNotificationAsync)
Range< double > getRangeLimit () const noexcept
double getMinimumRangeLimit () const noexcept
double getMaximumRangeLimit () const noexcept
bool setCurrentRange (Range< double > newRange, NotificationType notification=sendNotificationAsync)
void setCurrentRange (double newStart, double newSize, NotificationType notification=sendNotificationAsync)
void setCurrentRangeStart (double newStart, NotificationType notification=sendNotificationAsync)
Range< double > getCurrentRange () const noexcept
double getCurrentRangeStart () const noexcept
double getCurrentRangeSize () const noexcept
void setSingleStepSize (double newSingleStepSize) noexcept
double getSingleStepSize () const noexcept
bool moveScrollbarInSteps (int howManySteps, NotificationType notification=sendNotificationAsync)
bool moveScrollbarInPages (int howManyPages, NotificationType notification=sendNotificationAsync)
bool scrollToTop (NotificationType notification=sendNotificationAsync)
bool scrollToBottom (NotificationType notification=sendNotificationAsync)
void setButtonRepeatSpeed (int initialDelayInMillisecs, int repeatDelayInMillisecs, int minimumDelayInMillisecs=-1)
void addListener (Listener *listener)
void removeListener (Listener *listener)
bool keyPressed (const KeyPress &) override
void mouseWheelMove (const MouseEvent &, const MouseWheelDetails &) override
void lookAndFeelChanged () override
void mouseDown (const MouseEvent &) override
void mouseDrag (const MouseEvent &) override
void mouseUp (const MouseEvent &) override
void paint (Graphics &) override
void resized () override
void parentHierarchyChanged () override
void setVisible (bool) override
Public Member Functions inherited from juce::Component
 Component () noexcept
 ~Component () override
 Component (const String &componentName) noexcept
String getName () const noexcept
virtual void setName (const String &newName)
String getComponentID () const noexcept
void setComponentID (const String &newID)
bool isVisible () const noexcept
virtual void visibilityChanged ()
bool isShowing () const
virtual void addToDesktop (int windowStyleFlags, void *nativeWindowToAttachTo=nullptr)
void removeFromDesktop ()
bool isOnDesktop () const noexcept
ComponentPeergetPeer () const
virtual void userTriedToCloseWindow ()
virtual void minimisationStateChanged (bool isNowMinimised)
virtual float getDesktopScaleFactor () const
void toFront (bool shouldAlsoGainKeyboardFocus)
void toBack ()
void toBehind (Component *other)
void setAlwaysOnTop (bool shouldStayOnTop)
bool isAlwaysOnTop () const noexcept
int getX () const noexcept
int getY () const noexcept
int getWidth () const noexcept
int getHeight () const noexcept
int getRight () const noexcept
Point< intgetPosition () const noexcept
int getBottom () const noexcept
Rectangle< intgetBounds () const noexcept
Rectangle< intgetLocalBounds () const noexcept
Rectangle< intgetBoundsInParent () const noexcept
int getScreenX () const
int getScreenY () const
Point< intgetScreenPosition () const
Rectangle< intgetScreenBounds () const
Point< intgetLocalPoint (const Component *sourceComponent, Point< int > pointRelativeToSourceComponent) const
Point< float > getLocalPoint (const Component *sourceComponent, Point< float > pointRelativeToSourceComponent) const
Rectangle< intgetLocalArea (const Component *sourceComponent, Rectangle< int > areaRelativeToSourceComponent) const
Rectangle< float > getLocalArea (const Component *sourceComponent, Rectangle< float > areaRelativeToSourceComponent) const
Point< intlocalPointToGlobal (Point< int > localPoint) const
Point< float > localPointToGlobal (Point< float > localPoint) const
Rectangle< intlocalAreaToGlobal (Rectangle< int > localArea) const
Rectangle< float > localAreaToGlobal (Rectangle< float > localArea) const
void setTopLeftPosition (int x, int y)
void setTopLeftPosition (Point< int > newTopLeftPosition)
void setTopRightPosition (int x, int y)
void setSize (int newWidth, int newHeight)
void setBounds (int x, int y, int width, int height)
void setBounds (Rectangle< int > newBounds)
void setBoundsRelative (float proportionalX, float proportionalY, float proportionalWidth, float proportionalHeight)
void setBoundsRelative (Rectangle< float > proportionalArea)
void setBoundsInset (BorderSize< int > borders)
void setBoundsToFit (Rectangle< int > targetArea, Justification justification, bool onlyReduceInSize)
void setCentrePosition (int x, int y)
void setCentrePosition (Point< int > newCentrePosition)
void setCentreRelative (float x, float y)
void centreWithSize (int width, int height)
void setTransform (const AffineTransform &transform)
AffineTransform getTransform () const
bool isTransformed () const noexcept
int proportionOfWidth (float proportion) const noexcept
int proportionOfHeight (float proportion) const noexcept
int getParentWidth () const noexcept
int getParentHeight () const noexcept
Rectangle< intgetParentMonitorArea () const
int getNumChildComponents () const noexcept
ComponentgetChildComponent (int index) const noexcept
int getIndexOfChildComponent (const Component *child) const noexcept
const Array< Component * > & getChildren () const noexcept
ComponentfindChildWithID (StringRef componentID) const noexcept
void addChildComponent (Component *child, int zOrder=-1)
void addChildComponent (Component &child, int zOrder=-1)
void addAndMakeVisible (Component *child, int zOrder=-1)
void addAndMakeVisible (Component &child, int zOrder=-1)
void addChildAndSetID (Component *child, const String &componentID)
void removeChildComponent (Component *childToRemove)
ComponentremoveChildComponent (int childIndexToRemove)
void removeAllChildren ()
void deleteAllChildren ()
ComponentgetParentComponent () const noexcept
template<class TargetClass>
TargetClass * findParentComponentOfClass () const
ComponentgetTopLevelComponent () const noexcept
bool isParentOf (const Component *possibleChild) const noexcept
virtual void childrenChanged ()
virtual bool hitTest (int x, int y)
void setInterceptsMouseClicks (bool allowClicksOnThisComponent, bool allowClicksOnChildComponents) noexcept
void getInterceptsMouseClicks (bool &allowsClicksOnThisComponent, bool &allowsClicksOnChildComponents) const noexcept
bool contains (Point< int > localPoint)
bool contains (Point< float > localPoint)
bool reallyContains (Point< int > localPoint, bool returnTrueIfWithinAChild)
bool reallyContains (Point< float > localPoint, bool returnTrueIfWithinAChild)
ComponentgetComponentAt (int x, int y)
ComponentgetComponentAt (Point< int > position)
ComponentgetComponentAt (Point< float > position)
void repaint ()
void repaint (int x, int y, int width, int height)
void repaint (Rectangle< int > area)
void setBufferedToImage (bool shouldBeBuffered)
Image createComponentSnapshot (Rectangle< int > areaToGrab, bool clipImageToComponentBounds=true, float scaleFactor=1.0f)
void paintEntireComponent (Graphics &context, bool ignoreAlphaLevel)
void setPaintingIsUnclipped (bool shouldPaintWithoutClipping) noexcept
bool isPaintingUnclipped () const noexcept
void setComponentEffect (ImageEffectFilter *newEffect)
ImageEffectFiltergetComponentEffect () const noexcept
LookAndFeelgetLookAndFeel () const noexcept
void setLookAndFeel (LookAndFeel *newLookAndFeel)
void sendLookAndFeelChange ()
void setOpaque (bool shouldBeOpaque)
bool isOpaque () const noexcept
void setBroughtToFrontOnMouseClick (bool shouldBeBroughtToFront) noexcept
bool isBroughtToFrontOnMouseClick () const noexcept
void setExplicitFocusOrder (int newFocusOrderIndex)
int getExplicitFocusOrder () const
void setFocusContainerType (FocusContainerType containerType) noexcept
bool isFocusContainer () const noexcept
bool isKeyboardFocusContainer () const noexcept
ComponentfindFocusContainer () const
ComponentfindKeyboardFocusContainer () const
void setWantsKeyboardFocus (bool wantsFocus) noexcept
bool getWantsKeyboardFocus () const noexcept
void setMouseClickGrabsKeyboardFocus (bool shouldGrabFocus)
bool getMouseClickGrabsKeyboardFocus () const noexcept
void grabKeyboardFocus ()
void giveAwayKeyboardFocus ()
bool hasKeyboardFocus (bool trueIfChildIsFocused) const
void moveKeyboardFocusToSibling (bool moveToNext)
virtual std::unique_ptr< ComponentTraversercreateFocusTraverser ()
virtual std::unique_ptr< ComponentTraversercreateKeyboardFocusTraverser ()
void setHasFocusOutline (bool hasFocusOutline) noexcept
bool hasFocusOutline () const noexcept
bool isEnabled () const noexcept
void setEnabled (bool shouldBeEnabled)
virtual void enablementChanged ()
float getAlpha () const noexcept
void setAlpha (float newAlpha)
virtual void alphaChanged ()
void setMouseCursor (const MouseCursor &cursorType)
virtual MouseCursor getMouseCursor ()
void updateMouseCursor () const
virtual void paintOverChildren (Graphics &g)
void mouseMove (const MouseEvent &event) override
void mouseEnter (const MouseEvent &event) override
void mouseExit (const MouseEvent &event) override
void mouseDoubleClick (const MouseEvent &event) override
void mouseMagnify (const MouseEvent &event, float scaleFactor) override
void setRepaintsOnMouseActivity (bool shouldRepaint) noexcept
void addMouseListener (MouseListener *newListener, bool wantsEventsForAllNestedChildComponents)
void removeMouseListener (MouseListener *listenerToRemove)
void addKeyListener (KeyListener *newListener)
void removeKeyListener (KeyListener *listenerToRemove)
virtual bool keyStateChanged (bool isKeyDown)
virtual void modifierKeysChanged (const ModifierKeys &modifiers)
virtual void focusGained (FocusChangeType cause)
virtual void focusLost (FocusChangeType cause)
virtual void focusOfChildComponentChanged (FocusChangeType cause)
bool isMouseOver (bool includeChildren=false) const
bool isMouseButtonDown (bool includeChildren=false) const
bool isMouseOverOrDragging (bool includeChildren=false) const
Point< intgetMouseXYRelative () const
virtual void moved ()
virtual void childBoundsChanged (Component *child)
virtual void parentSizeChanged ()
virtual void broughtToFront ()
void addComponentListener (ComponentListener *newListener)
void removeComponentListener (ComponentListener *listenerToRemove)
void postCommandMessage (int commandId)
virtual void handleCommandMessage (int commandId)
void enterModalState (bool takeKeyboardFocus=true, ModalComponentManager::Callback *callback=nullptr, bool deleteWhenDismissed=false)
void exitModalState (int returnValue)
bool isCurrentlyModal (bool onlyConsiderForemostModalComponent=true) const noexcept
bool isCurrentlyBlockedByAnotherModalComponent () const
virtual bool canModalEventBeSentToComponent (const Component *targetComponent)
virtual void inputAttemptWhenModal ()
NamedValueSetgetProperties () noexcept
const NamedValueSetgetProperties () const noexcept
Colour findColour (int colourID, bool inheritFromParent=false) const
void setColour (int colourID, Colour newColour)
void removeColour (int colourID)
bool isColourSpecified (int colourID) const
void copyAllExplicitColoursTo (Component &target) const
virtual void colourChanged ()
voidgetWindowHandle () const
PositionergetPositioner () const noexcept
void setPositioner (Positioner *newPositioner)
void setCachedComponentImage (CachedComponentImage *newCachedImage)
CachedComponentImagegetCachedComponentImage () const noexcept
void setViewportIgnoreDragFlag (bool ignoreDrag) noexcept
bool getViewportIgnoreDragFlag () const noexcept
String getTitle () const noexcept
void setTitle (const String &newTitle)
String getDescription () const noexcept
void setDescription (const String &newDescription)
String getHelpText () const noexcept
void setHelpText (const String &newHelpText)
void setAccessible (bool shouldBeAccessible)
bool isAccessible () const noexcept
AccessibilityHandlergetAccessibilityHandler ()
void invalidateAccessibilityHandler ()
void setFocusContainer (bool shouldBeFocusContainer) noexcept
void contains (int, int)=delete
Public Member Functions inherited from juce::MouseListener
virtual ~MouseListener ()=default
Public Member Functions inherited from juce::AsyncUpdater
 AsyncUpdater ()
virtual ~AsyncUpdater ()
void triggerAsyncUpdate ()
void cancelPendingUpdate () noexcept
void handleUpdateNowIfNeeded ()
bool isUpdatePending () const noexcept

Private Member Functions

std::unique_ptr< AccessibilityHandlercreateAccessibilityHandler () override
void handleAsyncUpdate () override
void updateThumbPosition ()
void timerCallback () override
bool getVisibility () const noexcept
Private Member Functions inherited from juce::Timer
virtual ~Timer ()
void startTimer (int intervalInMilliseconds) noexcept
void startTimerHz (int timerFrequencyHz) noexcept
void stopTimer () noexcept
bool isTimerRunning () const noexcept
int getTimerInterval () const noexcept
 Timer () noexcept
 Timer (const Timer &) noexcept

Private Attributes

Range< double > totalRange { 0.0, 1.0 }
Range< double > visibleRange { 0.0, 1.0 }
double singleStepSize = 0.1
double dragStartRange = 0
int thumbAreaStart = 0
int thumbAreaSize = 0
int thumbStart = 0
int thumbSize = 0
int dragStartMousePos = 0
int lastMousePos = 0
int initialDelayInMillisecs = 100
int repeatDelayInMillisecs = 50
int minimumDelayInMillisecs = 10
bool vertical
bool isDraggingThumb = false
bool autohides = true
bool userVisibilityFlag = false
std::unique_ptr< ScrollbarButtonupButton
std::unique_ptr< ScrollbarButtondownButton
ListenerList< Listenerlisteners

Additional Inherited Members

Static Public Member Functions inherited from juce::Component
static float JUCE_CALLTYPE getApproximateScaleFactorForComponent (const Component *targetComponent)
static Component *JUCE_CALLTYPE getCurrentlyFocusedComponent () noexcept
static void JUCE_CALLTYPE unfocusAllComponents ()
static void JUCE_CALLTYPE beginDragAutoRepeat (int millisecondsBetweenCallbacks)
static bool JUCE_CALLTYPE isMouseButtonDownAnywhere () noexcept
static int JUCE_CALLTYPE getNumCurrentlyModalComponents () noexcept
static Component *JUCE_CALLTYPE getCurrentlyModalComponent (int index=0) noexcept
Protected Member Functions inherited from juce::Component
virtual ComponentPeercreateNewPeer (int styleFlags, void *nativeWindowToAttachTo)
Static Protected Member Functions inherited from juce::Component
static std::unique_ptr< AccessibilityHandlercreateIgnoredAccessibilityHandler (Component &)
Static Private Member Functions inherited from juce::Timer
static void JUCE_CALLTYPE callAfterDelay (int milliseconds, std::function< void()> functionToCall)
static void JUCE_CALLTYPE callPendingTimersSynchronously ()

Detailed Description

A scrollbar component.

To use a scrollbar, set up its total range using the setRangeLimits() method - this sets the range of values it can represent. Then you can use setCurrentRange() to change the position and size of the scrollbar's 'thumb'.

Registering a ScrollBar::Listener with the scrollbar will allow you to find out when the user moves it, and you can use the getCurrentRangeStart() to find out where they moved it to.

The scrollbar will adjust its own visibility according to whether its thumb size allows it to actually be scrolled.

For most purposes, it's probably easier to use a Viewport or ListBox instead of handling a scrollbar directly.

See also
ScrollBar::Listener

@tags{GUI}

Member Enumeration Documentation

◆ ColourIds

enum juce::ScrollBar::ColourIds

A set of colour IDs to use to change the colour of various aspects of the component.

These constants can be used either via the Component::setColour(), or LookAndFeel::setColour() methods.

See also
Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
Enumerator
backgroundColourId 

The background colour of the scrollbar.

thumbColourId 

A base colour to use for the thumb. The look and feel will probably use variations on this colour.

trackColourId 

A base colour to use for the slot area of the bar. The look and feel will probably use variations on this colour.

Constructor & Destructor Documentation

◆ ScrollBar()

juce::ScrollBar::ScrollBar ( bool isVertical)

Creates a Scrollbar.

Parameters
isVerticalspecifies whether the bar should be a vertical or horizontal

◆ ~ScrollBar()

juce::ScrollBar::~ScrollBar ( )
override

Destructor.

Member Function Documentation

◆ addListener()

void juce::ScrollBar::addListener ( Listener * listener)

Registers a listener that will be called when the scrollbar is moved.

◆ autoHides()

bool juce::ScrollBar::autoHides ( ) const
noexcept

Returns true if this scrollbar is set to auto-hide when its thumb is as big as its maximum range.

See also
setAutoHide

◆ createAccessibilityHandler()

std::unique_ptr< AccessibilityHandler > juce::ScrollBar::createAccessibilityHandler ( )
overrideprivatevirtual

Override this method to return a custom AccessibilityHandler for this component.

The default implementation creates and returns a AccessibilityHandler object with an unspecified role, meaning that it will be visible to accessibility clients but without a specific role, action callbacks or interfaces. To control how accessibility clients see and interact with your component subclass AccessibilityHandler, implement the desired behaviours, and return an instance of it from this method in your component subclass.

The accessibility handler you return here is guaranteed to be destroyed before its Component, so it's safe to store and use a reference back to the Component inside the AccessibilityHandler if necessary.

See also
getAccessibilityHandler

Reimplemented from juce::Component.

◆ getCurrentRange()

Range< double > juce::ScrollBar::getCurrentRange ( ) const
inlinenoexcept

Returns the current thumb range.

See also
getCurrentRange, setCurrentRange

◆ getCurrentRangeSize()

double juce::ScrollBar::getCurrentRangeSize ( ) const
inlinenoexcept

Returns the current size of the thumb.

See also
getCurrentRange, setCurrentRange

◆ getCurrentRangeStart()

double juce::ScrollBar::getCurrentRangeStart ( ) const
inlinenoexcept

Returns the position of the top of the thumb.

See also
getCurrentRange, setCurrentRangeStart

◆ getMaximumRangeLimit()

double juce::ScrollBar::getMaximumRangeLimit ( ) const
inlinenoexcept

Returns the upper value that the thumb can be set to.

This is the value set by setRangeLimits().

◆ getMinimumRangeLimit()

double juce::ScrollBar::getMinimumRangeLimit ( ) const
inlinenoexcept

Returns the lower value that the thumb can be set to.

This is the value set by setRangeLimits().

◆ getRangeLimit()

Range< double > juce::ScrollBar::getRangeLimit ( ) const
inlinenoexcept

Returns the current limits on the thumb position.

See also
setRangeLimits

◆ getSingleStepSize()

double juce::ScrollBar::getSingleStepSize ( ) const
inlinenoexcept

Returns the current step size.

See also
setSingleStepSize

◆ getVisibility()

bool juce::ScrollBar::getVisibility ( ) const
privatenoexcept

◆ handleAsyncUpdate()

void juce::ScrollBar::handleAsyncUpdate ( )
overrideprivatevirtual

Called back to do whatever your class needs to do.

This method is called by the message thread at the next convenient time after the triggerAsyncUpdate() method has been called.

Implements juce::AsyncUpdater.

◆ isVertical()

bool juce::ScrollBar::isVertical ( ) const
inlinenoexcept

Returns true if the scrollbar is vertical, false if it's horizontal.

◆ keyPressed()

bool juce::ScrollBar::keyPressed ( const KeyPress & key)
overridevirtual

Called when a key is pressed.

When a key is pressed, the component that has the keyboard focus will have this method called. Remember that a component will only be given the focus if its setWantsKeyboardFocus() method has been used to enable this.

If your implementation returns true, the event will be consumed and not passed on to any other listeners. If it returns false, the key will be passed to any KeyListeners that have been registered with this component. As soon as one of these returns true, the process will stop, but if they all return false, the event will be passed upwards to this component's parent, and so on.

The default implementation of this method does nothing and returns false.

See also
keyStateChanged, getCurrentlyFocusedComponent, addKeyListener

Reimplemented from juce::Component.

◆ lookAndFeelChanged()

void juce::ScrollBar::lookAndFeelChanged ( )
overridevirtual

Called to let the component react to a change in the look-and-feel setting.

When the look-and-feel is changed for a component, this will be called in all its child components, recursively.

It can also be triggered manually by the sendLookAndFeelChange() method, in case an application uses a LookAndFeel class that might have changed internally.

See also
sendLookAndFeelChange, getLookAndFeel

Reimplemented from juce::Component.

◆ mouseDown()

void juce::ScrollBar::mouseDown ( const MouseEvent & event)
overridevirtual

Called when a mouse button is pressed.

The MouseEvent object passed in contains lots of methods for finding out which button was pressed, as well as which modifier keys (e.g. shift, ctrl) were held down at the time.

Once a button is held down, the mouseDrag method will be called when the mouse moves, until the button is released.

Parameters
Eventdetails about the position and status of the mouse event, including the source component in which it occurred
See also
mouseUp, mouseDrag, mouseDoubleClick, contains

Reimplemented from juce::Component.

◆ mouseDrag()

void juce::ScrollBar::mouseDrag ( const MouseEvent & event)
overridevirtual

Called when the mouse is moved while a button is held down.

When a mouse button is pressed inside a component, that component receives mouseDrag callbacks each time the mouse moves, even if the mouse strays outside the component's bounds.

Parameters
Eventdetails about the position and status of the mouse event, including the source component in which it occurred
See also
mouseDown, mouseUp, mouseMove, contains, setDragRepeatInterval

Reimplemented from juce::Component.

◆ mouseUp()

void juce::ScrollBar::mouseUp ( const MouseEvent & event)
overridevirtual

Called when a mouse button is released.

A mouseUp callback is sent to the component in which a button was pressed even if the mouse is actually over a different component when the button is released.

The MouseEvent object passed in contains lots of methods for finding out which buttons were down just before they were released.

Parameters
Eventdetails about the position and status of the mouse event, including the source component in which it occurred
See also
mouseDown, mouseDrag, mouseDoubleClick, contains

Reimplemented from juce::Component.

◆ mouseWheelMove()

void juce::ScrollBar::mouseWheelMove ( const MouseEvent & event,
const MouseWheelDetails & wheel )
overridevirtual

Called when the mouse-wheel is moved.

This callback is sent to the component that the mouse is over when the wheel is moved.

If not overridden, a component will forward this message to its parent, so that parent components can collect mouse-wheel messages that happen to child components which aren't interested in them. (Bear in mind that if you attach a component as a mouse-listener to other components, then those wheel moves will also end up calling this method and being passed up to the parents, which may not be what you intended to happen).

Parameters
Eventdetails about the mouse event
wheeldetails about the mouse wheel movement

Reimplemented from juce::Component.

◆ moveScrollbarInPages()

bool juce::ScrollBar::moveScrollbarInPages ( int howManyPages,
NotificationType notification = sendNotificationAsync )

Moves the scroll bar up or down in pages.

This will move the bar by a multiple of its current thumb size, effectively doing a page-up or down.

A positive value here will move the bar down or to the right, a negative value moves it up or to the left.

Parameters
howManyPagesthe number of pages to move the scrollbar
notificationwhether to send a notification of the change to listeners. A notification will only be sent if the position has changed.
Returns
true if the scrollbar's position actually changed.

◆ moveScrollbarInSteps()

bool juce::ScrollBar::moveScrollbarInSteps ( int howManySteps,
NotificationType notification = sendNotificationAsync )

Moves the scrollbar by a number of single-steps.

This will move the bar by a multiple of its single-step interval (as specified using the setSingleStepSize() method).

A positive value here will move the bar down or to the right, a negative value moves it up or to the left.

Parameters
howManyStepsthe number of steps to move the scrollbar
notificationwhether to send a notification of the change to listeners. A notification will only be sent if the position has changed.
Returns
true if the scrollbar's position actually changed.

◆ paint()

void juce::ScrollBar::paint ( Graphics & g)
overridevirtual

Components can override this method to draw their content.

The paint() method gets called when a region of a component needs redrawing, either because the component's repaint() method has been called, or because something has happened on the screen that means a section of a window needs to be redrawn.

Any child components will draw themselves over whatever this method draws. If you need to paint over the top of your child components, you can also implement the paintOverChildren() method to do this.

If you want to cause a component to redraw itself, this is done asynchronously - calling the repaint() method marks a region of the component as "dirty", and the paint() method will automatically be called sometime later, by the message thread, to paint any bits that need refreshing. In JUCE (and almost all modern UI frameworks), you never redraw something synchronously.

You should never need to call this method directly - to take a snapshot of the component you could use createComponentSnapshot() or paintEntireComponent().

Parameters
gthe graphics context that must be used to do the drawing operations.
See also
repaint, paintOverChildren, Graphics

Reimplemented from juce::Component.

◆ parentHierarchyChanged()

void juce::ScrollBar::parentHierarchyChanged ( )
overridevirtual

Called to indicate that the component's parents have changed.

When a component is added or removed from its parent, this method will be called on all of its children (recursively - so all children of its children will also be called as well).

Subclasses can override this if they need to react to this in some way.

See also
getParentComponent, isShowing, ComponentListener::componentParentHierarchyChanged

Reimplemented from juce::Component.

◆ removeListener()

void juce::ScrollBar::removeListener ( Listener * listener)

Deregisters a previously-registered listener.

◆ resized()

void juce::ScrollBar::resized ( )
overridevirtual

Called when this component's size has been changed.

A component can implement this method to do things such as laying out its child components when its width or height changes.

The method is called synchronously as a result of the setBounds or setSize methods, so repeatedly changing a components size will repeatedly call its resized method (unlike things like repainting, where multiple calls to repaint are coalesced together).

If the component is a top-level window on the desktop, its size could also be changed by operating-system factors beyond the application's control.

See also
moved, setSize

Reimplemented from juce::Component.

◆ scrollToBottom()

bool juce::ScrollBar::scrollToBottom ( NotificationType notification = sendNotificationAsync)

Scrolls to the bottom (or right). This is the same as calling setCurrentRangeStart (getMaximumRangeLimit() - getCurrentRangeSize());

Parameters
notificationwhether to send a notification of the change to listeners. A notification will only be sent if the position has changed.
Returns
true if the scrollbar's position actually changed.

◆ scrollToTop()

bool juce::ScrollBar::scrollToTop ( NotificationType notification = sendNotificationAsync)

Scrolls to the top (or left). This is the same as calling setCurrentRangeStart (getMinimumRangeLimit());

Parameters
notificationwhether to send a notification of the change to listeners. A notification will only be sent if the position has changed.
Returns
true if the scrollbar's position actually changed.

◆ setAutoHide()

void juce::ScrollBar::setAutoHide ( bool shouldHideWhenFullRange)

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.

See also
autoHides()

◆ setButtonRepeatSpeed()

void juce::ScrollBar::setButtonRepeatSpeed ( int initialDelayInMillisecs,
int repeatDelayInMillisecs,
int minimumDelayInMillisecs = -1 )

Changes the delay before the up and down buttons autorepeat when they are held down.

For an explanation of what the parameters are for, see Button::setRepeatSpeed().

See also
Button::setRepeatSpeed

◆ setCurrentRange() [1/2]

void juce::ScrollBar::setCurrentRange ( double newStart,
double newSize,
NotificationType notification = sendNotificationAsync )

Changes the position of the scrollbar's 'thumb'.

This sets both the position and size of the thumb - to just set the position without changing the size, you can use setCurrentRangeStart().

Parameters
newStartthe top (or left) of the thumb, in the range getMinimumRangeLimit() <= newStart <= getMaximumRangeLimit(). If the value is beyond these limits, it will be clipped.
newSizethe size of the thumb, such that getMinimumRangeLimit() <= newStart + newSize <= getMaximumRangeLimit(). If the size is beyond these limits, it will be clipped.
notificationspecifies if and how a callback should be made to any listeners if the range actually changes
See also
setCurrentRangeStart, getCurrentRangeStart, getCurrentRangeSize

◆ setCurrentRange() [2/2]

bool juce::ScrollBar::setCurrentRange ( Range< double > newRange,
NotificationType notification = sendNotificationAsync )

Changes the position of the scrollbar's 'thumb'.

This sets both the position and size of the thumb - to just set the position without changing the size, you can use setCurrentRangeStart().

If this method call actually changes the scrollbar's position, it will trigger an asynchronous call to ScrollBar::Listener::scrollBarMoved() for all the listeners that are registered.

The notification parameter can be used to optionally send or inhibit a callback to any scrollbar listeners.

Returns
true if the range was changed, or false if nothing was changed.
See also
getCurrentRange. setCurrentRangeStart

◆ setCurrentRangeStart()

void juce::ScrollBar::setCurrentRangeStart ( double newStart,
NotificationType notification = sendNotificationAsync )

Moves the bar's thumb position.

This will move the thumb position without changing the thumb size. Note that the maximum thumb start position is (getMaximumRangeLimit() - getCurrentRangeSize()).

If this method call actually changes the scrollbar's position, it will trigger an asynchronous call to ScrollBar::Listener::scrollBarMoved() for all the listeners that are registered.

See also
setCurrentRange

◆ setOrientation()

void juce::ScrollBar::setOrientation ( bool shouldBeVertical)

Changes the scrollbar's direction.

You'll also need to resize the bar appropriately - this just changes its internal layout.

Parameters
shouldBeVerticaltrue makes it vertical; false makes it horizontal.

◆ setRangeLimits() [1/2]

void juce::ScrollBar::setRangeLimits ( double minimum,
double maximum,
NotificationType notification = sendNotificationAsync )

Sets the minimum and maximum values that the bar will move between.

The bar's thumb will always be constrained so that the entire thumb lies within this range.

Parameters
minimumthe new range minimum.
maximumthe new range maximum.
notificationwhether to send a notification of the change to listeners. A notification will only be sent if the range has changed.
See also
setCurrentRange

◆ setRangeLimits() [2/2]

void juce::ScrollBar::setRangeLimits ( Range< double > newRangeLimit,
NotificationType notification = sendNotificationAsync )

Sets the minimum and maximum values that the bar will move between.

The bar's thumb will always be constrained so that the entire thumb lies within this range.

Parameters
newRangeLimitthe new range.
notificationwhether to send a notification of the change to listeners. A notification will only be sent if the range has changed.
See also
setCurrentRange

◆ setSingleStepSize()

void juce::ScrollBar::setSingleStepSize ( double newSingleStepSize)
noexcept

Sets the amount by which the up and down buttons will move the bar.

The value here is in terms of the total range, and is added or subtracted from the thumb position when the user clicks an up/down (or left/right) button.

◆ setVisible()

void juce::ScrollBar::setVisible ( bool shouldBeVisible)
overridevirtual

Makes the component visible or invisible.

This method will show or hide the component. Note that components default to being non-visible when first created. Also note that visible components won't be seen unless all their parent components are also visible.

This method will call visibilityChanged() and also componentVisibilityChanged() for any component listeners that are interested in this component.

Parameters
shouldBeVisiblewhether to show or hide the component
See also
isVisible, isShowing, visibilityChanged, ComponentListener::componentVisibilityChanged

Reimplemented from juce::Component.

◆ timerCallback()

void juce::ScrollBar::timerCallback ( )
overrideprivatevirtual

The user-defined callback routine that actually gets called periodically.

It's perfectly ok to call startTimer() or stopTimer() from within this callback to change the subsequent intervals.

Implements juce::Timer.

◆ updateThumbPosition()

void juce::ScrollBar::updateThumbPosition ( )
private

Member Data Documentation

◆ autohides

bool juce::ScrollBar::autohides = true
private

◆ downButton

std::unique_ptr<ScrollbarButton> juce::ScrollBar::downButton
private

◆ dragStartMousePos

int juce::ScrollBar::dragStartMousePos = 0
private

◆ dragStartRange

double juce::ScrollBar::dragStartRange = 0
private

◆ initialDelayInMillisecs

int juce::ScrollBar::initialDelayInMillisecs = 100
private

◆ isDraggingThumb

bool juce::ScrollBar::isDraggingThumb = false
private

◆ lastMousePos

int juce::ScrollBar::lastMousePos = 0
private

◆ listeners

ListenerList<Listener> juce::ScrollBar::listeners
private

◆ minimumDelayInMillisecs

int juce::ScrollBar::minimumDelayInMillisecs = 10
private

◆ repeatDelayInMillisecs

int juce::ScrollBar::repeatDelayInMillisecs = 50
private

◆ singleStepSize

double juce::ScrollBar::singleStepSize = 0.1
private

◆ thumbAreaSize

int juce::ScrollBar::thumbAreaSize = 0
private

◆ thumbAreaStart

int juce::ScrollBar::thumbAreaStart = 0
private

◆ thumbSize

int juce::ScrollBar::thumbSize = 0
private

◆ thumbStart

int juce::ScrollBar::thumbStart = 0
private

◆ totalRange

Range<double> juce::ScrollBar::totalRange { 0.0, 1.0 }
private

◆ upButton

std::unique_ptr<ScrollbarButton> juce::ScrollBar::upButton
private

◆ userVisibilityFlag

bool juce::ScrollBar::userVisibilityFlag = false
private

◆ vertical

bool juce::ScrollBar::vertical
private

◆ visibleRange

Range<double> juce::ScrollBar::visibleRange { 0.0, 1.0 }
private

The documentation for this class was generated from the following files: