Gin
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
AsyncLambdaValueTreeListener Class Reference

Asynchronous ValueTree listener using lambda functions. More...

#include <gin_valuetreeutilities.h>

Inherits juce::ValueTree::Listener.

Public Member Functions

 AsyncLambdaValueTreeListener (juce::ValueTree &v_)
 Creates an async listener for the specified ValueTree.
 
 ~AsyncLambdaValueTreeListener () override
 Destructor.
 

Public Attributes

std::function< void(const juce::ValueTree &, const juce::Identifier &)> onValueTreePropertyChanged
 Called asynchronously when a property value changes.
 
std::function< void(const juce::ValueTree &, const juce::ValueTree &)> onValueTreeChildAdded
 Called asynchronously when a child is added.
 
std::function< void(const juce::ValueTree &, const juce::ValueTree &, int)> onValueTreeChildRemoved
 Called asynchronously when a child is removed.
 
std::function< void(const juce::ValueTree &, int, int)> onValueTreeChildOrderChanged
 Called asynchronously when children are reordered.
 
std::function< void(const juce::ValueTree &)> onValueTreeParentChanged
 Called asynchronously when the parent changes.
 
std::function< void(const juce::ValueTree &)> onValueTreeRedirected
 Called asynchronously when the tree is redirected to a different shared state.
 

Detailed Description

Asynchronous ValueTree listener using lambda functions.

Similar to LambdaValueTreeListener, but all callbacks are executed asynchronously on the message thread using juce::MessageManager::callAsync(). This makes it safe to update UI components from the callbacks without worrying about thread safety.

The callbacks receive const references to prevent accidental modification of the ValueTree from the async callbacks.

Example usage:

listener.onValueTreePropertyChanged = [this] (const juce::ValueTree& v, const juce::Identifier& prop) {
// This runs on the message thread, safe to update UI
someComponent.repaint();
};
Asynchronous ValueTree listener using lambda functions.
Definition gin_valuetreeutilities.h:167
A lightweight 2D point class for projects that don't use juce_graphics.
Definition gin_point.h:25
See also
LambdaValueTreeListener

Constructor & Destructor Documentation

◆ AsyncLambdaValueTreeListener()

AsyncLambdaValueTreeListener::AsyncLambdaValueTreeListener ( juce::ValueTree &  v_)

Creates an async listener for the specified ValueTree.

Parameters
v_The ValueTree to listen to

◆ ~AsyncLambdaValueTreeListener()

AsyncLambdaValueTreeListener::~AsyncLambdaValueTreeListener ( )
override

Destructor.

Removes this listener from the ValueTree.

Member Data Documentation

◆ onValueTreePropertyChanged

std::function<void (const juce::ValueTree&, const juce::Identifier&)> AsyncLambdaValueTreeListener::onValueTreePropertyChanged

Called asynchronously when a property value changes.

Parameters: (tree, property identifier)

◆ onValueTreeChildAdded

std::function<void (const juce::ValueTree&, const juce::ValueTree&)> AsyncLambdaValueTreeListener::onValueTreeChildAdded

Called asynchronously when a child is added.

Parameters: (parent tree, child that was added)

◆ onValueTreeChildRemoved

std::function<void (const juce::ValueTree&, const juce::ValueTree&, int)> AsyncLambdaValueTreeListener::onValueTreeChildRemoved

Called asynchronously when a child is removed.

Parameters: (parent tree, child that was removed, index)

◆ onValueTreeChildOrderChanged

std::function<void (const juce::ValueTree&, int, int)> AsyncLambdaValueTreeListener::onValueTreeChildOrderChanged

Called asynchronously when children are reordered.

Parameters: (tree, old index, new index)

◆ onValueTreeParentChanged

std::function<void (const juce::ValueTree&)> AsyncLambdaValueTreeListener::onValueTreeParentChanged

Called asynchronously when the parent changes.

Parameters: (tree whose parent changed)

◆ onValueTreeRedirected

std::function<void (const juce::ValueTree&)> AsyncLambdaValueTreeListener::onValueTreeRedirected

Called asynchronously when the tree is redirected to a different shared state.

Parameters: (tree)


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