JUCE v8.0.9
JUCE API
 
Loading...
Searching...
No Matches
juce::NativeScaleFactorNotifier Class Reference

Calls a function every time the native scale factor of a component's peer changes. More...

#include <juce_NativeScaleFactorNotifier.h>

Inheritance diagram for juce::NativeScaleFactorNotifier:
Collaboration diagram for juce::NativeScaleFactorNotifier:

Public Member Functions

 NativeScaleFactorNotifier (Component *comp, std::function< void(float)> onScaleChanged)
 Constructs an instance.
 
 ~NativeScaleFactorNotifier () override
 

Private Member Functions

void componentBeingDeleted (Component &) override
 
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 (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.
 
void componentMovedOrResized (bool, bool) override
 This callback happens when the component that is being watched is moved relative to its top-level peer window, or when it is resized.
 
void componentMovedOrResized (Component &, bool wasMoved, bool wasResized) override
 
virtual void componentNameChanged (Component &component)
 Called when the component's name is changed.
 
void componentParentHierarchyChanged (Component &) override
 
void componentPeerChanged () override
 This callback happens when the component's top-level peer is changed.
 
void componentVisibilityChanged () override
 This callback happens when the component's visibility state changes, possibly due to one of its parents being made visible or invisible.
 
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.
 
void componentVisibilityChanged (Component &) override
 
ComponentgetComponent () const noexcept
 Returns the component that's being watched.
 
void nativeScaleFactorChanged (double newScaleFactor) override
 Called when the scale factor changes.
 
void registerWithParentComps ()
 
void unregister ()
 

Private Attributes

WeakReference< Componentcomponent
 
Rectangle< int > lastBounds
 
uint32 lastPeerID = 0
 
ComponentPeerpeer = nullptr
 
bool reentrant = false
 
Array< Component * > registeredParentComps
 
std::function< void(float)> scaleChanged
 
bool wasShowing
 

Detailed Description

Calls a function every time the native scale factor of a component's peer changes.

This is used in the VST and VST3 wrappers to ensure that the editor's scale is kept in sync with the scale of its containing component.

@tags{GUI}

Constructor & Destructor Documentation

◆ NativeScaleFactorNotifier()

juce::NativeScaleFactorNotifier::NativeScaleFactorNotifier ( Component comp,
std::function< void(float)>  onScaleChanged 
)

Constructs an instance.

While the instance is alive, it will listen for changes to the scale factor of the comp's peer, and will call onScaleChanged whenever this scale factor changes.

Parameters
compThe component to observe
onScaleChangedA function that will be called when the backing scale factor changes

◆ ~NativeScaleFactorNotifier()

juce::NativeScaleFactorNotifier::~NativeScaleFactorNotifier ( )
override

Member Function Documentation

◆ componentBeingDeleted()

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

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, 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() [1/3]

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

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

Implements juce::ComponentMovementWatcher.

◆ componentMovedOrResized() [2/3]

void juce::NativeScaleFactorNotifier::componentMovedOrResized ( bool  wasMoved,
bool  wasResized 
)
inlineoverrideprivatevirtual

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

Implements juce::ComponentMovementWatcher.

◆ componentMovedOrResized() [3/3]

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

Reimplemented from juce::ComponentMovementWatcher.

◆ 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 )
overridevirtualinherited

Reimplemented from juce::ComponentListener.

◆ componentPeerChanged()

void juce::NativeScaleFactorNotifier::componentPeerChanged ( )
overrideprivatevirtual

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

Implements juce::ComponentMovementWatcher.

◆ componentVisibilityChanged() [1/3]

void juce::NativeScaleFactorNotifier::componentVisibilityChanged ( )
inlineoverrideprivatevirtual

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

Implements juce::ComponentMovementWatcher.

◆ componentVisibilityChanged() [2/3]

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

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

Implements juce::ComponentMovementWatcher.

◆ componentVisibilityChanged() [3/3]

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

Reimplemented from juce::ComponentMovementWatcher.

◆ getComponent()

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

Returns the component that's being watched.

Referenced by juce::PeerListener::componentPeerChanged().

◆ nativeScaleFactorChanged()

void juce::NativeScaleFactorNotifier::nativeScaleFactorChanged ( double  newScaleFactor)
overrideprivatevirtual

Called when the scale factor changes.

Implements juce::ComponentPeer::ScaleFactorListener.

◆ registerWithParentComps()

void juce::ComponentMovementWatcher::registerWithParentComps ( )
privateinherited

◆ unregister()

void juce::ComponentMovementWatcher::unregister ( )
privateinherited

Member Data Documentation

◆ component

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

◆ lastBounds

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

◆ lastPeerID

uint32 juce::ComponentMovementWatcher::lastPeerID = 0
privateinherited

◆ peer

ComponentPeer* juce::NativeScaleFactorNotifier::peer = nullptr
private

◆ reentrant

bool juce::ComponentMovementWatcher::reentrant = false
privateinherited

◆ registeredParentComps

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

◆ scaleChanged

std::function<void (float)> juce::NativeScaleFactorNotifier::scaleChanged
private

◆ wasShowing

bool juce::ComponentMovementWatcher::wasShowing
privateinherited

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