openshot-audio  0.1.7
Public Member Functions | Static Public Member Functions | List of all members
Viewport Class Reference

#include <juce_Viewport.h>

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

Public Member Functions

 Viewport (const String &componentName=String::empty)
 
 ~Viewport ()
 
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< int > getViewPosition () const noexcept
 
Rectangle< int > getViewArea () 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)
 
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 resized () override
 
void scrollBarMoved (ScrollBar *, double newRangeStart) override
 
void mouseWheelMove (const MouseEvent &, const MouseWheelDetails &) 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 Component
 Component () noexcept
 
virtual ~Component ()
 
 Component (const String &componentName) noexcept
 
const StringgetName () const noexcept
 
virtual void setName (const String &newName)
 
const StringgetComponentID () 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 shouldAlsoGainFocus)
 
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< int > getPosition () const noexcept
 
int getBottom () const noexcept
 
const Rectangle< int > & getBounds () const noexcept
 
Rectangle< int > getLocalBounds () const noexcept
 
Rectangle< int > getBoundsInParent () const noexcept
 
int getScreenX () const
 
int getScreenY () const
 
Point< int > getScreenPosition () const
 
Rectangle< int > getScreenBounds () const
 
Point< int > getLocalPoint (const Component *sourceComponent, Point< int > pointRelativeToSourceComponent) const
 
Point< float > getLocalPoint (const Component *sourceComponent, Point< float > pointRelativeToSourceComponent) const
 
Rectangle< int > getLocalArea (const Component *sourceComponent, const Rectangle< int > &areaRelativeToSourceComponent) const
 
Point< int > localPointToGlobal (Point< int > localPoint) const
 
Point< float > localPointToGlobal (Point< float > localPoint) const
 
Rectangle< int > localAreaToGlobal (const Rectangle< int > &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 (const Rectangle< int > &newBounds)
 
void setBounds (const RelativeRectangle &newBounds)
 
void setBounds (const String &newBoundsExpression)
 
void setBoundsRelative (float proportionalX, float proportionalY, float proportionalWidth, float proportionalHeight)
 
void setBoundsInset (const BorderSize< int > &borders)
 
void setBoundsToFit (int x, int y, int width, int height, Justification justification, bool onlyReduceInSize)
 
void setCentrePosition (int x, int y)
 
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< int > getParentMonitorArea () const
 
int getNumChildComponents () const noexcept
 
ComponentgetChildComponent (int index) const noexcept
 
int getIndexOfChildComponent (const Component *child) 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 reallyContains (Point< int > localPoint, bool returnTrueIfWithinAChild)
 
ComponentgetComponentAt (int x, int y)
 
ComponentgetComponentAt (Point< int > position)
 
void repaint ()
 
void repaint (int x, int y, int width, int height)
 
void repaint (const Rectangle< int > &area)
 
void setBufferedToImage (bool shouldBeBuffered)
 
Image createComponentSnapshot (const Rectangle< int > &areaToGrab, bool clipImageToComponentBounds=true, float scaleFactor=1.0f)
 
void paintEntireComponent (Graphics &context, bool ignoreAlphaLevel)
 
void setPaintingIsUnclipped (bool shouldPaintWithoutClipping) 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 setWantsKeyboardFocus (bool wantsFocus) noexcept
 
bool getWantsKeyboardFocus () const noexcept
 
void setMouseClickGrabsKeyboardFocus (bool shouldGrabFocus)
 
bool getMouseClickGrabsKeyboardFocus () const noexcept
 
void grabKeyboardFocus ()
 
bool hasKeyboardFocus (bool trueIfChildIsFocused) const
 
void moveKeyboardFocusToSibling (bool moveToNext)
 
virtual KeyboardFocusTraversercreateFocusTraverser ()
 
int getExplicitFocusOrder () const
 
void setExplicitFocusOrder (int newFocusOrderIndex)
 
void setFocusContainer (bool shouldBeFocusContainer) noexcept
 
bool isFocusContainer () const noexcept
 
bool isEnabled () const noexcept
 
void setEnabled (bool shouldBeEnabled)
 
virtual void enablementChanged ()
 
void setAlpha (float newAlpha)
 
float getAlpha () const
 
void setMouseCursor (const MouseCursor &cursorType)
 
virtual MouseCursor getMouseCursor ()
 
void updateMouseCursor () const
 
virtual void paint (Graphics &g)
 
virtual void paintOverChildren (Graphics &g)
 
virtual void mouseMove (const MouseEvent &event) override
 
virtual void mouseEnter (const MouseEvent &event) override
 
virtual void mouseExit (const MouseEvent &event) override
 
virtual void mouseDown (const MouseEvent &event) override
 
virtual void mouseDrag (const MouseEvent &event) override
 
virtual void mouseUp (const MouseEvent &event) override
 
virtual void mouseDoubleClick (const MouseEvent &event) override
 
virtual void mouseMagnify (const MouseEvent &event, float scaleFactor)
 
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 () const
 
bool isMouseOverOrDragging () const
 
Point< int > getMouseXYRelative () 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 () 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 ()
 
virtual MarkerListgetMarkers (bool xAxis)
 
void * getWindowHandle () const
 
PositionergetPositioner () const noexcept
 
void setPositioner (Positioner *newPositioner)
 
void setCachedComponentImage (CachedComponentImage *newCachedImage)
 
CachedComponentImagegetCachedComponentImage () const noexcept
 
 JUCE_DEPRECATED (Point< int > relativePositionToGlobal(Point< int >) const)
 
 JUCE_DEPRECATED (Point< int > globalPositionToRelative(Point< int >) const)
 
 JUCE_DEPRECATED (Point< int > relativePositionToOtherComponent(const Component *, Point< int >) const)
 
- Public Member Functions inherited from MouseListener
virtual ~MouseListener ()
 

Static Public Member Functions

static bool respondsToKey (const KeyPress &)
 
- Static Public Member Functions inherited from Component
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
 

Additional Inherited Members

- Public Types inherited from Component
enum  FocusChangeType { focusChangedByMouseClick, focusChangedByTabKey, focusChangedDirectly }
 
- Protected Member Functions inherited from Component
virtual ComponentPeercreateNewPeer (int styleFlags, void *nativeWindowToAttachTo)
 

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.

Constructor & Destructor Documentation

◆ Viewport()

Viewport::Viewport ( const String componentName = String::empty)
explicit

Creates a Viewport.

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

◆ ~Viewport()

Viewport::~Viewport ( )

Destructor.

Member Function Documentation

◆ autoScroll()

bool 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

◆ componentMovedOrResized()

void 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 ComponentListener.

◆ getHorizontalScrollBar()

ScrollBar* Viewport::getHorizontalScrollBar ( )
inlinenoexcept

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

◆ getMaximumVisibleHeight()

int 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 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 Viewport::getScrollBarThickness ( ) const

Returns the thickness of the scrollbars.

See also
setScrollBarThickness

◆ getVerticalScrollBar()

ScrollBar* Viewport::getVerticalScrollBar ( )
inlinenoexcept

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

◆ getViewArea()

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

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

◆ getViewedComponent()

Component* Viewport::getViewedComponent ( ) const
inlinenoexcept

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

See also
setViewedComponent

◆ getViewHeight()

int 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> Viewport::getViewPosition ( ) const
inlinenoexcept

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

◆ getViewPositionX()

int 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 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 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.

◆ isHorizontalScrollBarShown()

bool Viewport::isHorizontalScrollBarShown ( ) const
inlinenoexcept

True if the horizontal scrollbar is enabled.

See also
setScrollBarsShown

◆ isVerticalScrollBarShown()

bool Viewport::isVerticalScrollBarShown ( ) const
inlinenoexcept

True if the vertical scrollbar is enabled.

See also
setScrollBarsShown

◆ keyPressed()

bool 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 Component.

Reimplemented in TreeView::TreeViewport, and ListBox::ListViewport.

◆ lookAndFeelChanged()

void 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 Component.

◆ mouseWheelMove()

void 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 Component.

◆ resized()

void 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 Component.

◆ respondsToKey()

bool Viewport::respondsToKey ( const KeyPress key)
static

◆ scrollBarMoved()

void 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 ScrollBar::Listener.

◆ setScrollBarsShown()

void 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 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

◆ setSingleStepSizes()

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

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

◆ setViewedComponent()

void 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 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 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 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.

◆ useMouseWheelMoveIfNeeded()

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

◆ viewedComponentChanged()

void Viewport::viewedComponentChanged ( Component newComponent)
virtual

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

◆ visibleAreaChanged()

void 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 TextEditorViewport, TreeView::TreeViewport, and ListBox::ListViewport.


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