JUCE v8.0.9
JUCE API
 
Loading...
Searching...
No Matches
juce::VBlankAttachment Class Referencefinal

Helper class to synchronise Component updates to the vertical blank event of the display that the Component is presented on. More...

#include <juce_VBlankAttachment.h>

Inheritance diagram for juce::VBlankAttachment:
Collaboration diagram for juce::VBlankAttachment:

Public Member Functions

 VBlankAttachment ()=default
 Default constructor for creating an empty object.
 
 VBlankAttachment (Component *c, std::function< void()> callbackIn)
 Constructor.
 
 VBlankAttachment (Component *c, std::function< void(double)> callbackIn)
 Constructor.
 
 VBlankAttachment (VBlankAttachment &&other)
 
 ~VBlankAttachment () override
 Destructor.
 
bool isEmpty () const
 Returns true for a default constructed object.
 
VBlankAttachmentoperator= (VBlankAttachment &&other)
 

Private Member Functions

void cleanup ()
 
virtual void componentBeingDeleted (Component &component)
 Called when the component is in the process of being deleted.
 
virtual void componentBroughtToFront (Component &component)
 Called when the component is brought to the top of the z-order.
 
virtual void componentChildrenChanged (Component &component)
 Called when the component has children added or removed, or their z-order changes.
 
virtual void componentEnablementChanged (Component &component)
 
virtual void componentMovedOrResized (Component &component, bool wasMoved, bool wasResized)
 Called when the component's position or size changes.
 
virtual void componentNameChanged (Component &component)
 Called when the component's name is changed.
 
void componentParentHierarchyChanged (Component &) override
 Called to indicate that the component's parents have changed.
 
virtual void componentVisibilityChanged (Component &component)
 Called when the component is made visible or invisible.
 
void onVBlank (double timestampSec) override
 Called on every vertical blank of the display to which the peer is associated.
 
void updateOwner ()
 
void updatePeer ()
 

Private Attributes

std::function< void(double)> callback
 
ComponentlastOwner = nullptr
 
ComponentPeerlastPeer = nullptr
 
Componentowner = nullptr
 

Detailed Description

Helper class to synchronise Component updates to the vertical blank event of the display that the Component is presented on.

This is useful when animating the Component's contents.

@tags{Animations}

Constructor & Destructor Documentation

◆ VBlankAttachment() [1/4]

juce::VBlankAttachment::VBlankAttachment ( )
default

Default constructor for creating an empty object.

◆ VBlankAttachment() [2/4]

juce::VBlankAttachment::VBlankAttachment ( Component c,
std::function< void()>  callbackIn 
)

Constructor.

Creates an attachment that will call the passed in function at every vertical blank event of the display that the passed in Component is currently visible on.

The Component must be valid for the entire lifetime of the VBlankAttachment.

You should prefer the other constructor, where the callback also receives a timestamp parameter. This constructor is only provided for compatibility with the earlier JUCE implementation.

◆ VBlankAttachment() [3/4]

juce::VBlankAttachment::VBlankAttachment ( Component c,
std::function< void(double)>  callbackIn 
)

Constructor.

Creates an attachment that will call the passed in function at every vertical blank event of the display that the passed in Component is currently visible on.

The Component must be valid for the entire lifetime of the VBlankAttachment.

The provided callback is called with a monotonically increasing value expressed in seconds that corresponds to the time of the next frame to be presented. Use this value to synchronise drawing across all classes using a VBlankAttachment.

◆ VBlankAttachment() [4/4]

juce::VBlankAttachment::VBlankAttachment ( VBlankAttachment &&  other)

◆ ~VBlankAttachment()

juce::VBlankAttachment::~VBlankAttachment ( )
override

Destructor.

Member Function Documentation

◆ cleanup()

void juce::VBlankAttachment::cleanup ( )
private

◆ componentBeingDeleted()

virtual void juce::ComponentListener::componentBeingDeleted ( Component component)
virtualinherited

Called when the component is in the process of being deleted.

This callback is made from inside the destructor, so be very, very cautious about what you do in here.

In particular, bear in mind that it's the Component base class's destructor that calls this - so if the object that's being deleted is a subclass of Component, then the subclass layers of the object will already have been destructed when it gets to this point!

Parameters
componentthe component that was deleted

Reimplemented in juce::ComponentMovementWatcher, and juce::RelativeCoordinatePositionerBase.

◆ componentBroughtToFront()

virtual void juce::ComponentListener::componentBroughtToFront ( Component component)
virtualinherited

Called when the component is brought to the top of the z-order.

Parameters
componentthe component that was moved
See also
Component::toFront, Component::broughtToFront

Reimplemented in juce::DropShadower, and juce::FocusOutline.

◆ componentChildrenChanged()

virtual void juce::ComponentListener::componentChildrenChanged ( Component component)
virtualinherited

Called when the component has children added or removed, or their z-order changes.

Parameters
componentthe component whose children have changed
See also
Component::childrenChanged, Component::addChildComponent, Component::removeChildComponent

Reimplemented in juce::DropShadower, and juce::RelativeCoordinatePositionerBase.

◆ componentEnablementChanged()

virtual void juce::ComponentListener::componentEnablementChanged ( Component component)
virtualinherited

◆ componentMovedOrResized()

virtual void juce::ComponentListener::componentMovedOrResized ( Component component,
bool  wasMoved,
bool  wasResized 
)
virtualinherited

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 in juce::ComponentMovementWatcher, juce::SidePanel, juce::Viewport, juce::Label, juce::NativeScaleFactorNotifier, juce::PeerListener, juce::AudioProcessorEditor::AudioProcessorEditorListener, juce::StandaloneFilterWindow::MainContentComponent, juce::DropShadower, juce::FocusOutline, and juce::RelativeCoordinatePositionerBase.

◆ componentNameChanged()

virtual void juce::ComponentListener::componentNameChanged ( Component component)
virtualinherited

Called when the component's name is changed.

Parameters
componentthe component that had its name changed
See also
Component::setName, Component::getName

Reimplemented in juce::MultiDocumentPanel.

◆ componentParentHierarchyChanged()

void juce::VBlankAttachment::componentParentHierarchyChanged ( Component component)
overrideprivatevirtual

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

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

Parameters
componentthe component that this listener is registered with
See also
Component::parentHierarchyChanged

Reimplemented from juce::ComponentListener.

◆ componentVisibilityChanged()

virtual void juce::ComponentListener::componentVisibilityChanged ( Component component)
virtualinherited

Called when the component is made visible or invisible.

Parameters
componentthe component that changed
See also
Component::setVisible

Reimplemented in juce::ComponentMovementWatcher, juce::DropShadower, juce::FocusOutline, juce::Label, juce::NativeScaleFactorNotifier, and juce::PeerListener.

◆ isEmpty()

bool juce::VBlankAttachment::isEmpty ( ) const
inline

Returns true for a default constructed object.

◆ onVBlank()

void juce::VBlankAttachment::onVBlank ( double  timestampSec)
overrideprivatevirtual

Called on every vertical blank of the display to which the peer is associated.

The timestampSec parameter is a monotonically increasing value expressed in seconds that corresponds to the time at which the next frame will be displayed.

Implements juce::ComponentPeer::VBlankListener.

◆ operator=()

VBlankAttachment & juce::VBlankAttachment::operator= ( VBlankAttachment &&  other)

◆ updateOwner()

void juce::VBlankAttachment::updateOwner ( )
private

◆ updatePeer()

void juce::VBlankAttachment::updatePeer ( )
private

Member Data Documentation

◆ callback

std::function<void (double)> juce::VBlankAttachment::callback
private

◆ lastOwner

Component* juce::VBlankAttachment::lastOwner = nullptr
private

◆ lastPeer

ComponentPeer* juce::VBlankAttachment::lastPeer = nullptr
private

◆ owner

Component* juce::VBlankAttachment::owner = nullptr
private

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