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

Manages the system's stack of modal components. More...

#include <juce_ModalComponentManager.h>

Inheritance diagram for juce::ModalComponentManager:
Collaboration diagram for juce::ModalComponentManager:

Classes

class  Callback
 Receives callbacks when a modal component is dismissed. More...
 

Public Member Functions

void attachCallback (Component *component, Callback *callback)
 Adds a new callback that will be called when the specified modal component is dismissed. More...
 
void bringModalComponentsToFront (bool topOneShouldGrabFocus=true)
 Brings any modal components to the front. More...
 
bool cancelAllModalComponents ()
 Calls exitModalState (0) on any components that are currently modal. More...
 
ComponentgetModalComponent (int index) const
 Returns one of the components being shown modally. More...
 
int getNumModalComponents () const
 Returns the number of components currently being shown modally. More...
 
bool isFrontModalComponent (const Component *component) const
 Returns true if the specified component is currently the topmost modal component. More...
 
bool isModal (const Component *component) const
 Returns true if the specified component is in a modal state. More...
 
int runEventLoopForCurrentComponent ()
 Runs the event loop until the currently topmost modal component is dismissed, and returns the exit code for that component. More...
 

Protected Member Functions

 ModalComponentManager ()
 Creates a ModalComponentManager. More...
 
 ~ModalComponentManager () override
 Destructor. More...
 
void handleAsyncUpdate () override
 

Private Member Functions

void cancelPendingUpdate () noexcept
 This will stop any pending updates from happening. More...
 
void endModal (Component *, int returnValue)
 
void endModal (Component *)
 
void handleUpdateNowIfNeeded ()
 If an update has been triggered and is pending, this will invoke it synchronously. More...
 
bool isUpdatePending () const noexcept
 Returns true if there's an update callback in the pipeline. More...
 
void startModal (Component *, bool autoDelete)
 
void triggerAsyncUpdate ()
 Causes the callback to be triggered at a later time. More...
 

Static Private Member Functions

static void deleteAll ()
 Deletes all extant objects. More...
 

Private Attributes

OwnedArray< ModalItem > stack
 

Friends

class Component
 

Detailed Description

Manages the system's stack of modal components.

Normally you'll just use the Component methods to invoke modal states in components, and won't have to deal with this class directly, but this is the singleton object that's used internally to manage the stack.

See also
Component::enterModalState, Component::exitModalState, Component::isCurrentlyModal, Component::getCurrentlyModalComponent, Component::isCurrentlyBlockedByAnotherModalComponent

{GUI}

Constructor & Destructor Documentation

◆ ModalComponentManager()

juce::ModalComponentManager::ModalComponentManager ( )
protected

Creates a ModalComponentManager.

You shouldn't ever call the constructor - it's a singleton, so use ModalComponentManager::getInstance()

◆ ~ModalComponentManager()

juce::ModalComponentManager::~ModalComponentManager ( )
overrideprotected

Destructor.

Member Function Documentation

◆ attachCallback()

void juce::ModalComponentManager::attachCallback ( Component component,
Callback callback 
)

Adds a new callback that will be called when the specified modal component is dismissed.

If the component is modal, then when it is dismissed, either by being hidden, or by calling Component::exitModalState(), then the Callback::modalStateFinished() method will be called.

Each component can have any number of callbacks associated with it, and this one is added to that list.

The object that is passed in will be deleted by the manager when it's no longer needed. If the given component is not currently modal, the callback object is deleted immediately and no action is taken.

◆ bringModalComponentsToFront()

void juce::ModalComponentManager::bringModalComponentsToFront ( bool  topOneShouldGrabFocus = true)

Brings any modal components to the front.

◆ cancelAllModalComponents()

bool juce::ModalComponentManager::cancelAllModalComponents ( )

Calls exitModalState (0) on any components that are currently modal.

Returns
true if any components were modal; false if nothing needed cancelling

◆ cancelPendingUpdate()

void juce::AsyncUpdater::cancelPendingUpdate ( )
noexceptinherited

This will stop any pending updates from happening.

If called after triggerAsyncUpdate() and before the handleAsyncUpdate() callback happens, this will cancel the handleAsyncUpdate() callback.

Note that this method simply cancels the next callback - if a callback is already in progress on a different thread, this won't block until the callback finishes, so there's no guarantee that the callback isn't still running when the method returns.

◆ deleteAll()

static void juce::DeletedAtShutdown::deleteAll ( )
staticinherited

Deletes all extant objects.

This shouldn't be used by applications, as it's called automatically in the shutdown code of the JUCEApplicationBase class.

◆ endModal() [1/2]

void juce::ModalComponentManager::endModal ( Component ,
int  returnValue 
)
private

◆ endModal() [2/2]

void juce::ModalComponentManager::endModal ( Component )
private

◆ getModalComponent()

Component* juce::ModalComponentManager::getModalComponent ( int  index) const

Returns one of the components being shown modally.

An index of 0 is the most recently-shown, topmost component.

◆ getNumModalComponents()

int juce::ModalComponentManager::getNumModalComponents ( ) const

Returns the number of components currently being shown modally.

See also
getModalComponent

◆ handleAsyncUpdate()

void juce::ModalComponentManager::handleAsyncUpdate ( )
overrideprotectedvirtual

Implements juce::AsyncUpdater.

◆ handleUpdateNowIfNeeded()

void juce::AsyncUpdater::handleUpdateNowIfNeeded ( )
inherited

If an update has been triggered and is pending, this will invoke it synchronously.

Use this as a kind of "flush" operation - if an update is pending, the handleAsyncUpdate() method will be called immediately; if no update is pending, then nothing will be done.

Because this may invoke the callback, this method must only be called on the main event thread.

◆ isFrontModalComponent()

bool juce::ModalComponentManager::isFrontModalComponent ( const Component component) const

Returns true if the specified component is currently the topmost modal component.

◆ isModal()

bool juce::ModalComponentManager::isModal ( const Component component) const

Returns true if the specified component is in a modal state.

◆ isUpdatePending()

bool juce::AsyncUpdater::isUpdatePending ( ) const
noexceptinherited

Returns true if there's an update callback in the pipeline.

◆ runEventLoopForCurrentComponent()

int juce::ModalComponentManager::runEventLoopForCurrentComponent ( )

Runs the event loop until the currently topmost modal component is dismissed, and returns the exit code for that component.

◆ startModal()

void juce::ModalComponentManager::startModal ( Component ,
bool  autoDelete 
)
private

◆ triggerAsyncUpdate()

void juce::AsyncUpdater::triggerAsyncUpdate ( )
inherited

Causes the callback to be triggered at a later time.

This method returns immediately, after which a callback to the handleAsyncUpdate() method will be made by the message thread as soon as possible.

If an update callback is already pending but hasn't happened yet, calling this method will have no effect.

It's thread-safe to call this method from any thread, BUT beware of calling it from a real-time (e.g. audio) thread, because it involves posting a message to the system queue, which means it may block (and in general will do on most OSes).

Friends And Related Function Documentation

◆ Component

friend class Component
friend

Member Data Documentation

◆ stack

OwnedArray<ModalItem> juce::ModalComponentManager::stack
private

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