47 parameterValueChanged ({}, parameter.
getValue());
62 if (undoManager !=
nullptr)
81template <
typename Callback>
91void ParameterAttachment::parameterValueChanged (
int,
float newValue)
106void ParameterAttachment::handleAsyncUpdate()
108 NullCheckedInvocation::invoke (setValue, parameter.
convertFrom0to1 (lastValue));
116 attachment (param, [
this] (
float f) { setValue (f); },
um)
119 slider.textFromValueFunction = [¶m] (
double value) {
return param.
getText (param.
convertTo0to1 ((
float) value), 0); };
126 double normalisedValue)
mutable
130 return (
double) range.convertFrom0to1 ((
float) normalisedValue);
139 return (
double) range.convertTo0to1 ((
float)
mappedValue);
148 return (
double) range.snapToLegalValue ((
float)
mappedValue);
153 std::move (convertFrom0To1Function),
154 std::move (convertTo0To1Function),
155 std::move (snapToLegalValueFunction) };
158 newRange.symmetricSkew = range.symmetricSkew;
160 slider.setNormalisableRange (
newRange);
163 slider.valueChanged();
164 slider.addListener (
this);
174void SliderParameterAttachment::setValue (
float newValue)
180void SliderParameterAttachment::sliderValueChanged (Slider*)
182 if (! ignoreCallbacks)
191 storedParameter (param),
192 attachment (param, [
this] (
float f) { setValue (f); },
um)
195 comboBox.addListener (
this);
208void ComboBoxParameterAttachment::setValue (
float newValue)
220void ComboBoxParameterAttachment::comboBoxChanged (ComboBox*)
227 const auto newValue = numItems > 1 ? selected / (
float) (numItems - 1)
238 attachment (param, [
this] (
float f) { setValue (f); },
um)
241 button.addListener (
this);
254void ButtonParameterAttachment::setValue (
float newValue)
260void ButtonParameterAttachment::buttonClicked (Button*)
void triggerAsyncUpdate()
Causes the callback to be triggered at a later time.
void cancelPendingUpdate() noexcept
This will stop any pending updates from happening.
virtual float getValue() const =0
Called by the host to find out the value of this parameter.
virtual float getDefaultValue() const =0
This should return the default value for this parameter.
virtual String getText(float normalisedValue, int) const
Returns a textual version of the supplied normalised parameter value.
void beginChangeGesture()
Sends a signal to the host to tell it that the user is about to start changing this parameter.
void removeListener(Listener *listener)
Removes a previously registered parameter listener.
void setValueNotifyingHost(float newValue)
A processor should call this when it needs to change one of its parameters.
void endChangeGesture()
Tells the host that the user has finished changing this parameter.
void addListener(Listener *newListener)
Registers a listener to receive events when the parameter's state changes.
virtual float getValueForText(const String &text) const =0
Should parse a string and return the appropriate value for it.
~ComboBoxParameterAttachment() override
Destructor.
void sendInitialUpdate()
Call this after setting up your combo box in the case where you need to do extra setup after construc...
ComboBoxParameterAttachment(RangedAudioParameter ¶meter, ComboBox &combo, UndoManager *undoManager=nullptr)
Creates a connection between a plug-in parameter and a ComboBox.
A component that lets the user choose from a drop-down list of choices.
void setSelectedItemIndex(int newItemIndex, NotificationType notification=sendNotificationAsync)
Sets one of the items to be the current selection.
int getNumItems() const noexcept
Returns the number of items that have been added to the list.
int getSelectedItemIndex() const
Returns the index of the item that's currently shown in the box.
void removeListener(Listener *listener)
Deregisters a previously-registered listener.
static MessageManager * getInstance()
Returns the global instance of the MessageManager.
ValueType start
The minimum value of the non-normalised range.
void endGesture()
Ends a gesture on the managed parameter.
void setValueAsCompleteGesture(float newDenormalisedValue)
Triggers a full gesture message on the managed parameter.
void sendInitialUpdate()
Calls the parameterChangedCallback function that was registered in the constructor,...
void beginGesture()
Begins a gesture on the managed parameter.
void setValueAsPartOfGesture(float newDenormalisedValue)
Updates the parameter value during a gesture.
~ParameterAttachment() override
Destructor.
ParameterAttachment(RangedAudioParameter ¶meter, std::function< void(float)> parameterChangedCallback, UndoManager *undoManager=nullptr)
Listens to a parameter and calls the the provided function in response to parameter changes.
This abstract base class is used by some AudioProcessorParameter helper classes.
float convertTo0to1(float v) const noexcept
Normalises and snaps a value based on the normalisable range.
virtual const NormalisableRange< float > & getNormalisableRange() const =0
Returns the range of values that the parameter can take.
float convertFrom0to1(float v) const noexcept
Denormalises and snaps a value based on the normalisable range.
Helper class providing an RAII-based mechanism for temporarily setting and then re-setting a value.
void sendInitialUpdate()
Call this after setting up your slider in the case where you need to do extra setup after constructin...
~SliderParameterAttachment() override
Destructor.
SliderParameterAttachment(RangedAudioParameter ¶meter, Slider &slider, UndoManager *undoManager=nullptr)
Creates a connection between a plug-in parameter and a Slider.
A slider control for changing a value.
double getValue() const
Returns the slider's current value.
void removeListener(Listener *listener)
Removes a previously-registered listener.
void setValue(double newValue, NotificationType notification=sendNotificationAsync)
Changes the slider's current value.
Manages a list of undo/redo commands.
void beginNewTransaction()
Starts a new group of actions that together will be treated as a single transaction.
constexpr bool approximatelyEqual(Type a, Type b, Tolerance< Type > tolerance=Tolerance< Type >{} .withAbsolute(std::numeric_limits< Type >::min()) .withRelative(std::numeric_limits< Type >::epsilon()))
Returns true if the two floating-point numbers are approximately equal.
@ sendNotificationSync
Requests a synchronous notification.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
int roundToInt(const FloatType value) noexcept
Fast floating-point-to-integer conversion.