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

#include <juce_Viewport.h>

Inheritance diagram for juce::Viewport:
juce::Component juce::ComponentListener juce::ScrollBar::Listener juce::MouseListener juce::ListBox::ListViewport juce::TextEditor::TextEditorViewport juce::TreeView::TreeViewport

Classes

class  AccessibilityIgnoredComponent
struct  DragToScrollListener

Public Types

enum class  ScrollOnDragMode { never , nonHover , all }
Public Types inherited from juce::Component
enum class  FocusContainerType { none , focusContainer , keyboardFocusContainer }
enum  FocusChangeType { focusChangedByMouseClick , focusChangedByTabKey , focusChangedDirectly }

Public Member Functions

 Viewport (const String &componentName=String())
 ~Viewport () override
void setViewedComponent (Component *newViewedComponent, bool deleteComponentWhenNoLongerNeeded=true)
ComponentgetViewedComponent () const noexcept
void setViewPosition (int xPixelsOffset, int yPixelsOffset)
void setViewPosition (Point< int > newPosition)
void setViewPositionProportionately (double proportionX, double proportionY)
bool autoScroll (int mouseX, int mouseY, int distanceFromEdge, int maximumSpeed)
Point< intgetViewPosition () const noexcept
Rectangle< intgetViewArea () const noexcept
int getViewPositionX () const noexcept
int getViewPositionY () const noexcept
int getViewWidth () const noexcept
int getViewHeight () const noexcept
int getMaximumVisibleWidth () const
int getMaximumVisibleHeight () const
virtual void visibleAreaChanged (const Rectangle< int > &newVisibleArea)
virtual void viewedComponentChanged (Component *newComponent)
void setScrollBarsShown (bool showVerticalScrollbarIfNeeded, bool showHorizontalScrollbarIfNeeded, bool allowVerticalScrollingWithoutScrollbar=false, bool allowHorizontalScrollingWithoutScrollbar=false)
void setScrollBarPosition (bool verticalScrollbarOnRight, bool horizontalScrollbarAtBottom)
bool isVerticalScrollbarOnTheRight () const noexcept
bool isHorizontalScrollbarAtBottom () const noexcept
bool isVerticalScrollBarShown () const noexcept
bool isHorizontalScrollBarShown () const noexcept
void setScrollBarThickness (int thickness)
int getScrollBarThickness () const
void setSingleStepSizes (int stepX, int stepY)
ScrollBargetVerticalScrollBar () noexcept
ScrollBargetHorizontalScrollBar () noexcept
void recreateScrollbars ()
bool canScrollVertically () const noexcept
bool canScrollHorizontally () const noexcept
void setScrollOnDragEnabled (bool shouldScrollOnDrag)
bool isScrollOnDragEnabled () const noexcept
void setScrollOnDragMode (ScrollOnDragMode scrollOnDragMode)
ScrollOnDragMode getScrollOnDragMode () const
bool isCurrentlyScrollingOnDrag () const noexcept
void resized () override
void scrollBarMoved (ScrollBar *, double newRangeStart) override
void mouseWheelMove (const MouseEvent &, const MouseWheelDetails &) override
void mouseDown (const MouseEvent &e) override
bool keyPressed (const KeyPress &) override
void componentMovedOrResized (Component &, bool wasMoved, bool wasResized) override
void lookAndFeelChanged () override
bool useMouseWheelMoveIfNeeded (const MouseEvent &, const MouseWheelDetails &)
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)
virtual void setVisible (bool shouldBeVisible)
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 parentHierarchyChanged ()
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 paint (Graphics &g)
virtual void paintOverChildren (Graphics &g)
void mouseMove (const MouseEvent &event) override
void mouseEnter (const MouseEvent &event) override
void mouseExit (const MouseEvent &event) override
void mouseDrag (const MouseEvent &event) override
void mouseUp (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

Static Public Member Functions

static bool respondsToKey (const KeyPress &)
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

virtual ScrollBarcreateScrollBarComponent (bool isVertical)
Protected Member Functions inherited from juce::Component
virtual ComponentPeercreateNewPeer (int styleFlags, void *nativeWindowToAttachTo)

Private Member Functions

Point< intviewportPosToCompPos (Point< int >) const
void updateVisibleArea ()
void deleteOrRemoveContentComp ()
Private Member Functions inherited from juce::ComponentListener
virtual ~ComponentListener ()=default
virtual void componentBroughtToFront (Component &component)
virtual void componentVisibilityChanged (Component &component)
virtual void componentChildrenChanged (Component &component)
virtual void componentParentHierarchyChanged (Component &component)
virtual void componentNameChanged (Component &component)
virtual void componentBeingDeleted (Component &component)
virtual void componentEnablementChanged (Component &component)
Private Member Functions inherited from juce::ScrollBar::Listener
virtual ~Listener ()=default

Private Attributes

std::unique_ptr< ScrollBarverticalScrollBar
std::unique_ptr< ScrollBarhorizontalScrollBar
AccessibilityIgnoredComponent contentHolder
WeakReference< ComponentcontentComp
Rectangle< intlastVisibleArea
int scrollBarThickness = 0
int singleStepX = 16
int singleStepY = 16
ScrollOnDragMode scrollOnDragMode = ScrollOnDragMode::nonHover
bool showHScrollbar = true
bool showVScrollbar = true
bool deleteContent = true
bool customScrollBarThickness = false
bool allowScrollingWithoutScrollbarV = false
bool allowScrollingWithoutScrollbarH = false
bool vScrollbarRight = true
bool hScrollbarBottom = true
std::unique_ptr< DragToScrollListenerdragToScrollListener

Additional Inherited Members

Static Protected Member Functions inherited from juce::Component
static std::unique_ptr< AccessibilityHandlercreateIgnoredAccessibilityHandler (Component &)

Detailed Description

A Viewport is used to contain a larger child component, and allows the child to be automatically scrolled around.

To use a Viewport, just create one and set the component that goes inside it using the setViewedComponent() method. When the child component changes size, the Viewport will adjust its scrollbars accordingly.

A subclass of the viewport can be created which will receive calls to its visibleAreaChanged() method when the subcomponent changes position or size.

@tags{GUI}

Member Enumeration Documentation

◆ ScrollOnDragMode

enum class juce::Viewport::ScrollOnDragMode
strong
Enumerator
never 

Dragging will never scroll the viewport.

nonHover 

Dragging will only scroll the viewport if the input source cannot hover.

all 

Dragging will always scroll the viewport.

Constructor & Destructor Documentation

◆ Viewport()

juce::Viewport::Viewport ( const String & componentName = String())
explicit

Creates a Viewport.

The viewport is initially empty - use the setViewedComponent() method to add a child component for it to manage.

◆ ~Viewport()

juce::Viewport::~Viewport ( )
override

Destructor.

Member Function Documentation

◆ autoScroll()

bool juce::Viewport::autoScroll ( int mouseX,
int mouseY,
int distanceFromEdge,
int maximumSpeed )

If the specified position is at the edges of the viewport, this method scrolls the viewport to bring that position nearer to the centre.

Call this if you're dragging an object inside a viewport and want to make it scroll when the user approaches an edge. You might also find Component::beginDragAutoRepeat() useful when auto-scrolling.

Parameters
mouseXthe x position, relative to the Viewport's top-left
mouseYthe y position, relative to the Viewport's top-left
distanceFromEdgespecifies how close to an edge the position needs to be before the viewport should scroll in that direction
maximumSpeedthe maximum number of pixels that the viewport is allowed to scroll by.
Returns
true if the viewport was scrolled

◆ canScrollHorizontally()

bool juce::Viewport::canScrollHorizontally ( ) const
noexcept

True if there's any off-screen content that could be scrolled horizontally, or false if everything is currently visible.

◆ canScrollVertically()

bool juce::Viewport::canScrollVertically ( ) const
noexcept

True if there's any off-screen content that could be scrolled vertically, or false if everything is currently visible.

◆ componentMovedOrResized()

void juce::Viewport::componentMovedOrResized ( Component & component,
bool wasMoved,
bool wasResized )
overridevirtual

Called when the component's position or size changes.

Parameters
componentthe component that was moved or resized
wasMovedtrue if the component's top-left corner has just moved
wasResizedtrue if the component's width or height has just changed
See also
Component::setBounds, Component::resized, Component::moved

Reimplemented from juce::ComponentListener.

◆ createScrollBarComponent()

ScrollBar * juce::Viewport::createScrollBarComponent ( bool isVertical)
protectedvirtual

Creates the Scrollbar components that will be added to the Viewport. Subclasses can override this if they need to customise the scrollbars in some way.

◆ deleteOrRemoveContentComp()

void juce::Viewport::deleteOrRemoveContentComp ( )
private

◆ getHorizontalScrollBar()

ScrollBar & juce::Viewport::getHorizontalScrollBar ( )
inlinenoexcept

Returns a reference to the scrollbar component being used. Handy if you need to customise the bar somehow.

◆ getMaximumVisibleHeight()

int juce::Viewport::getMaximumVisibleHeight ( ) const

Returns the height available within this component for the contents.

This will be the height of the viewport component minus the space taken up by a horizontal scrollbar (if visible).

◆ getMaximumVisibleWidth()

int juce::Viewport::getMaximumVisibleWidth ( ) const

Returns the width available within this component for the contents.

This will be the width of the viewport component minus the width of a vertical scrollbar (if visible).

◆ getScrollBarThickness()

int juce::Viewport::getScrollBarThickness ( ) const

Returns the thickness of the scrollbars.

See also
setScrollBarThickness

◆ getScrollOnDragMode()

ScrollOnDragMode juce::Viewport::getScrollOnDragMode ( ) const
inline

Returns the current scroll-on-drag mode.

◆ getVerticalScrollBar()

ScrollBar & juce::Viewport::getVerticalScrollBar ( )
inlinenoexcept

Returns a reference to the scrollbar component being used. Handy if you need to customise the bar somehow.

◆ getViewArea()

Rectangle< int > juce::Viewport::getViewArea ( ) const
inlinenoexcept

Returns the visible area of the child component, relative to its top-left

◆ getViewedComponent()

Component * juce::Viewport::getViewedComponent ( ) const
inlinenoexcept

Returns the component that's currently being used inside the Viewport.

See also
setViewedComponent

◆ getViewHeight()

int juce::Viewport::getViewHeight ( ) const
inlinenoexcept

Returns the height of the visible area of the child component.

This may be less than the height of this Viewport if there's a horizontal scrollbar or if the child component is itself smaller.

◆ getViewPosition()

Point< int > juce::Viewport::getViewPosition ( ) const
inlinenoexcept

Returns the position within the child component of the top-left of its visible area.

◆ getViewPositionX()

int juce::Viewport::getViewPositionX ( ) const
inlinenoexcept

Returns the position within the child component of the top-left of its visible area.

See also
getViewWidth, setViewPosition

◆ getViewPositionY()

int juce::Viewport::getViewPositionY ( ) const
inlinenoexcept

Returns the position within the child component of the top-left of its visible area.

See also
getViewHeight, setViewPosition

◆ getViewWidth()

int juce::Viewport::getViewWidth ( ) const
inlinenoexcept

Returns the width of the visible area of the child component.

This may be less than the width of this Viewport if there's a vertical scrollbar or if the child component is itself smaller.

◆ isCurrentlyScrollingOnDrag()

bool juce::Viewport::isCurrentlyScrollingOnDrag ( ) const
noexcept

Returns true if the user is currently dragging-to-scroll.

See also
setScrollOnDragEnabled

◆ isHorizontalScrollbarAtBottom()

bool juce::Viewport::isHorizontalScrollbarAtBottom ( ) const
inlinenoexcept

True if the horizontal scrollbar will appear at the bottom of the content

◆ isHorizontalScrollBarShown()

bool juce::Viewport::isHorizontalScrollBarShown ( ) const
inlinenoexcept

True if the horizontal scrollbar is enabled.

See also
setScrollBarsShown

◆ isScrollOnDragEnabled()

bool juce::Viewport::isScrollOnDragEnabled ( ) const
inlinenoexcept

Returns true if drag-to-scroll functionality is enabled for mouse input sources.

◆ isVerticalScrollbarOnTheRight()

bool juce::Viewport::isVerticalScrollbarOnTheRight ( ) const
inlinenoexcept

True if the vertical scrollbar will appear on the right side of the content

◆ isVerticalScrollBarShown()

bool juce::Viewport::isVerticalScrollBarShown ( ) const
inlinenoexcept

True if the vertical scrollbar is enabled.

See also
setScrollBarsShown

◆ keyPressed()

bool juce::Viewport::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::Viewport::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::Viewport::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.

◆ mouseWheelMove()

void juce::Viewport::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.

◆ recreateScrollbars()

void juce::Viewport::recreateScrollbars ( )

Re-instantiates the scrollbars, which is only really useful if you've overridden createScrollBarComponent().

◆ resized()

void juce::Viewport::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.

◆ respondsToKey()

bool juce::Viewport::respondsToKey ( const KeyPress & key)
static

◆ scrollBarMoved()

void juce::Viewport::scrollBarMoved ( ScrollBar * scrollBarThatHasMoved,
double newRangeStart )
overridevirtual

Called when a ScrollBar is moved.

Parameters
scrollBarThatHasMovedthe bar that has moved
newRangeStartthe new range start of this bar

Implements juce::ScrollBar::Listener.

◆ setScrollBarPosition()

void juce::Viewport::setScrollBarPosition ( bool verticalScrollbarOnRight,
bool horizontalScrollbarAtBottom )

Changes where the scroll bars are positioned

If verticalScrollbarOnRight is set to true, then the vertical scrollbar will appear on the right side of the view port's content (this is the default), otherwise it will be on the left side of the content.

If horizontalScrollbarAtBottom is set to true, then the horizontal scrollbar will appear at the bottom of the view port's content (this is the default), otherwise it will be at the top.

◆ setScrollBarsShown()

void juce::Viewport::setScrollBarsShown ( bool showVerticalScrollbarIfNeeded,
bool showHorizontalScrollbarIfNeeded,
bool allowVerticalScrollingWithoutScrollbar = false,
bool allowHorizontalScrollingWithoutScrollbar = false )

Turns scrollbars on or off.

If set to false, the scrollbars won't ever appear. When true (the default) they will appear only when needed.

The allowVerticalScrollingWithoutScrollbar parameters allow you to enable mouse-wheel scrolling even when there the scrollbars are hidden. When the scrollbars are visible, these parameters are ignored.

◆ setScrollBarThickness()

void juce::Viewport::setScrollBarThickness ( int thickness)

Changes the width of the scrollbars. If this isn't specified, the default width from the LookAndFeel class will be used.

See also
LookAndFeel::getDefaultScrollbarWidth

◆ setScrollOnDragEnabled()

void juce::Viewport::setScrollOnDragEnabled ( bool shouldScrollOnDrag)
inline

Enables or disables drag-to-scroll functionality for mouse sources in the viewport.

If your viewport contains a Component that you don't want to receive mouse events when the user is drag-scrolling, you can disable this with the Component::setViewportIgnoreDragFlag() method.

◆ setScrollOnDragMode()

void juce::Viewport::setScrollOnDragMode ( ScrollOnDragMode scrollOnDragMode)

Sets the current scroll-on-drag mode. The default is ScrollOnDragMode::nonHover.

If your viewport contains a Component that you don't want to receive mouse events when the user is drag-scrolling, you can disable this with the Component::setViewportIgnoreDragFlag() method.

◆ setSingleStepSizes()

void juce::Viewport::setSingleStepSizes ( int stepX,
int stepY )

Changes the distance that a single-step click on a scrollbar button will move the viewport.

◆ setViewedComponent()

void juce::Viewport::setViewedComponent ( Component * newViewedComponent,
bool deleteComponentWhenNoLongerNeeded = true )

Sets the component that this viewport will contain and scroll around.

This will add the given component to this Viewport and position it at (0, 0).

(Don't add or remove any child components directly using the normal Component::addChildComponent() methods).

Parameters
newViewedComponentthe component to add to this viewport, or null to remove the current component.
deleteComponentWhenNoLongerNeededif true, the component will be deleted automatically when the viewport is deleted or when a different component is added. If false, the caller must manage the lifetime of the component
See also
getViewedComponent

◆ setViewPosition() [1/2]

void juce::Viewport::setViewPosition ( int xPixelsOffset,
int yPixelsOffset )

Changes the position of the viewed component.

The inner component will be moved so that the pixel at the top left of the viewport will be the pixel at position (xPixelsOffset, yPixelsOffset) within the inner component.

This will update the scrollbars and might cause a call to visibleAreaChanged().

See also
getViewPositionX, getViewPositionY, setViewPositionProportionately

◆ setViewPosition() [2/2]

void juce::Viewport::setViewPosition ( Point< int > newPosition)

Changes the position of the viewed component.

The inner component will be moved so that the pixel at the top left of the viewport will be the pixel at the specified coordinates within the inner component.

This will update the scrollbars and might cause a call to visibleAreaChanged().

See also
getViewPositionX, getViewPositionY, setViewPositionProportionately

◆ setViewPositionProportionately()

void juce::Viewport::setViewPositionProportionately ( double proportionX,
double proportionY )

Changes the view position as a proportion of the distance it can move.

The values here are from 0.0 to 1.0 - where (0, 0) would put the visible area in the top-left, and (1, 1) would put it as far down and to the right as it's possible to go whilst keeping the child component on-screen.

◆ updateVisibleArea()

void juce::Viewport::updateVisibleArea ( )
private

◆ useMouseWheelMoveIfNeeded()

bool juce::Viewport::useMouseWheelMoveIfNeeded ( const MouseEvent & e,
const MouseWheelDetails & wheel )

◆ viewedComponentChanged()

void juce::Viewport::viewedComponentChanged ( Component * newComponent)
virtual

Callback method that is called when the viewed component is added, removed or swapped.

◆ viewportPosToCompPos()

Point< int > juce::Viewport::viewportPosToCompPos ( Point< int > pos) const
private

◆ visibleAreaChanged()

void juce::Viewport::visibleAreaChanged ( const Rectangle< int > & newVisibleArea)
virtual

Callback method that is called when the visible area changes.

This will be called when the visible area is moved either be scrolling or by calls to setViewPosition(), etc.

Reimplemented in juce::ListBox::ListViewport, juce::TextEditor::TextEditorViewport, and juce::TreeView::TreeViewport.

Member Data Documentation

◆ allowScrollingWithoutScrollbarH

bool juce::Viewport::allowScrollingWithoutScrollbarH = false
private

◆ allowScrollingWithoutScrollbarV

bool juce::Viewport::allowScrollingWithoutScrollbarV = false
private

◆ contentComp

WeakReference<Component> juce::Viewport::contentComp
private

◆ contentHolder

AccessibilityIgnoredComponent juce::Viewport::contentHolder
private

◆ customScrollBarThickness

bool juce::Viewport::customScrollBarThickness = false
private

◆ deleteContent

bool juce::Viewport::deleteContent = true
private

◆ dragToScrollListener

std::unique_ptr<DragToScrollListener> juce::Viewport::dragToScrollListener
private

◆ horizontalScrollBar

std::unique_ptr<ScrollBar> juce::Viewport::horizontalScrollBar
private

◆ hScrollbarBottom

bool juce::Viewport::hScrollbarBottom = true
private

◆ lastVisibleArea

Rectangle<int> juce::Viewport::lastVisibleArea
private

◆ scrollBarThickness

int juce::Viewport::scrollBarThickness = 0
private

◆ scrollOnDragMode

ScrollOnDragMode juce::Viewport::scrollOnDragMode = ScrollOnDragMode::nonHover
private

◆ showHScrollbar

bool juce::Viewport::showHScrollbar = true
private

◆ showVScrollbar

bool juce::Viewport::showVScrollbar = true
private

◆ singleStepX

int juce::Viewport::singleStepX = 16
private

◆ singleStepY

int juce::Viewport::singleStepY = 16
private

◆ verticalScrollBar

std::unique_ptr<ScrollBar> juce::Viewport::verticalScrollBar
private

◆ vScrollbarRight

bool juce::Viewport::vScrollbarRight = true
private

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