JUCE  v5.4.1-191-g0ab5e696f
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::ComponentMovementWatcher Class Referenceabstract

An object that watches for any movement of a component or any of its parent components. More...

#include <juce_ComponentMovementWatcher.h>

Inheritance diagram for juce::ComponentMovementWatcher:
Collaboration diagram for juce::ComponentMovementWatcher:

Public Member Functions

 ComponentMovementWatcher (Component *componentToWatch)
 Creates a ComponentMovementWatcher to watch a given target component. More...
 
 ~ComponentMovementWatcher () override
 Destructor. More...
 
void componentBeingDeleted (Component &) override
 
virtual void componentBroughtToFront (Component &component)
 Called when the component is brought to the top of the z-order. More...
 
virtual void componentChildrenChanged (Component &component)
 Called when the component has children added or removed, or their z-order changes. More...
 
virtual void componentEnablementChanged (Component &component)
 
virtual void componentMovedOrResized (bool wasMoved, bool wasResized)=0
 This callback happens when the component that is being watched is moved relative to its top-level peer window, or when it is resized. More...
 
void componentMovedOrResized (Component &, bool wasMoved, bool wasResized) override
 
virtual void componentNameChanged (Component &component)
 Called when the component's name is changed. More...
 
void componentParentHierarchyChanged (Component &) override
 
virtual void componentPeerChanged ()=0
 This callback happens when the component's top-level peer is changed. More...
 
virtual void componentVisibilityChanged ()=0
 This callback happens when the component's visibility state changes, possibly due to one of its parents being made visible or invisible. More...
 
void componentVisibilityChanged (Component &) override
 
ComponentgetComponent () const noexcept
 Returns the component that's being watched. More...
 

Private Member Functions

void registerWithParentComps ()
 
void unregister ()
 

Private Attributes

WeakReference< Componentcomponent
 
Rectangle< intlastBounds
 
uint32 lastPeerID = 0
 
bool reentrant = false
 
Array< Component * > registeredParentComps
 
bool wasShowing
 

Detailed Description

An object that watches for any movement of a component or any of its parent components.

This makes it easy to check when a component is moved relative to its top-level peer window. The normal Component::moved() method is only called when a component moves relative to its immediate parent, and sometimes you want to know if any of components higher up the tree have moved (which of course will affect the overall position of all their sub-components).

It also includes a callback that lets you know when the top-level peer is changed.

This class is used by specialised components like WebBrowserComponent because they need to keep their custom windows in the right place and respond to changes in the peer.

{GUI}

Constructor & Destructor Documentation

◆ ComponentMovementWatcher()

juce::ComponentMovementWatcher::ComponentMovementWatcher ( Component componentToWatch)

Creates a ComponentMovementWatcher to watch a given target component.

◆ ~ComponentMovementWatcher()

juce::ComponentMovementWatcher::~ComponentMovementWatcher ( )
override

Destructor.

Member Function Documentation

◆ componentBeingDeleted()

void juce::ComponentMovementWatcher::componentBeingDeleted ( Component )
overridevirtual

Reimplemented from juce::ComponentListener.

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

◆ 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() [1/2]

virtual void juce::ComponentMovementWatcher::componentMovedOrResized ( bool  wasMoved,
bool  wasResized 
)
pure virtual

This callback happens when the component that is being watched is moved relative to its top-level peer window, or when it is resized.

Implemented in juce::CarbonViewWrapperComponent.

Referenced by juce::CarbonViewWrapperComponent::componentMovedOrResized().

◆ componentMovedOrResized() [2/2]

void juce::ComponentMovementWatcher::componentMovedOrResized ( Component ,
bool  wasMoved,
bool  wasResized 
)
overridevirtual

Reimplemented from juce::ComponentListener.

Reimplemented in juce::CarbonViewWrapperComponent.

◆ 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::ComponentMovementWatcher::componentParentHierarchyChanged ( Component )
overridevirtual

Reimplemented from juce::ComponentListener.

◆ componentPeerChanged()

virtual void juce::ComponentMovementWatcher::componentPeerChanged ( )
pure virtual

This callback happens when the component's top-level peer is changed.

Implemented in juce::CarbonViewWrapperComponent.

◆ componentVisibilityChanged() [1/2]

virtual void juce::ComponentMovementWatcher::componentVisibilityChanged ( )
pure virtual

This callback happens when the component's visibility state changes, possibly due to one of its parents being made visible or invisible.

Implemented in juce::CarbonViewWrapperComponent.

◆ componentVisibilityChanged() [2/2]

void juce::ComponentMovementWatcher::componentVisibilityChanged ( Component )
overridevirtual

Reimplemented from juce::ComponentListener.

◆ getComponent()

Component* juce::ComponentMovementWatcher::getComponent ( ) const
inlinenoexcept

Returns the component that's being watched.

◆ registerWithParentComps()

void juce::ComponentMovementWatcher::registerWithParentComps ( )
private

◆ unregister()

void juce::ComponentMovementWatcher::unregister ( )
private

Member Data Documentation

◆ component

WeakReference<Component> juce::ComponentMovementWatcher::component
private

◆ lastBounds

Rectangle<int> juce::ComponentMovementWatcher::lastBounds
private

◆ lastPeerID

uint32 juce::ComponentMovementWatcher::lastPeerID = 0
private

◆ reentrant

bool juce::ComponentMovementWatcher::reentrant = false
private

◆ registeredParentComps

Array<Component*> juce::ComponentMovementWatcher::registeredParentComps
private

◆ wasShowing

bool juce::ComponentMovementWatcher::wasShowing
private

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