35 : processor (
proc), parameter (param), isLegacyParam (LegacyAudioParameter::isLegacy (¶m))
58 virtual void handleNewParameterValue() = 0;
62 void parameterValueChanged (
int,
float)
override
64 parameterValueHasChanged = 1;
67 void parameterGestureChanged (
int,
bool)
override {}
70 void audioProcessorParameterChanged (
AudioProcessor*,
int index,
float)
override
73 parameterValueHasChanged = 1;
79 void timerCallback()
override
83 handleNewParameterValue();
95 const bool isLegacyParam;
104 using ParameterListener::ParameterListener;
117 handleNewParameterValue();
119 button.
onClick = [
this] { buttonClicked(); };
129 area.removeFromLeft (8);
133 void handleNewParameterValue()
override
149 bool isParameterOn()
const {
return getParameter().
getValue() >= 0.5f; }
163 for (
auto& button : buttons)
165 button.setRadioGroupId (293847);
166 button.setClickingTogglesState (
true);
177 handleNewParameterValue();
181 for (
auto& button : buttons)
192 for (
auto& button : buttons)
193 button.setBounds (area.removeFromLeft (80));
196 void handleNewParameterValue()
override
200 if (buttons[1].getToggleState() !=
newState)
208 void rightButtonChanged()
212 if (isParameterOn() != buttonState)
216 if (getParameter().getAllValueStrings().isEmpty())
235 bool isParameterOn()
const
237 if (getParameter().getAllValueStrings().isEmpty())
238 return getParameter().
getValue() > 0.5f;
241 .
indexOf (getParameter().getCurrentValueAsText());
247 index =
roundToInt (getParameter().getValue());
253 TextButton buttons[2];
264 parameterValues (getParameter().getAllValueStrings())
269 handleNewParameterValue();
271 box.
onChange = [
this] { boxChanged(); };
280 area.removeFromLeft (8);
285 void handleNewParameterValue()
override
287 auto index = parameterValues.
indexOf (getParameter().getCurrentValueAsText());
293 index =
roundToInt (getParameter().getValue() * (
float) (parameterValues.
size() - 1));
301 if (getParameter().getCurrentValueAsText() != box.
getText())
315 const StringArray parameterValues;
328 slider.
setRange (0.0, 1.0, 1.0 / (getParameter().getNumSteps() - 1.0));
343 handleNewParameterValue();
346 slider.
onDragStart = [
this] { sliderStartedDragging(); };
347 slider.
onDragEnd = [
this] { sliderStoppedDragging(); };
356 valueLabel.
setBounds (area.removeFromRight (80));
358 area.removeFromLeft (6);
362 void handleNewParameterValue()
override
372 void updateTextDisplay()
377 void sliderValueChanged()
394 void sliderStartedDragging()
400 void sliderStoppedDragging()
408 bool isDragging =
false;
420 : editor (
editorIn), parameter (param)
448 parameterName.
setBounds (area.removeFromLeft (100));
449 parameterLabel.
setBounds (area.removeFromRight (50));
450 parameterComp->setBounds (area);
457 if (
auto menu = context->getContextMenuForParameter (¶meter))
459 .withMousePosition());
465 Label parameterName, parameterLabel;
475 return std::make_unique<BooleanParameterComponent> (processor, parameter);
479 return std::make_unique<SwitchParameterComponent> (processor, parameter);
486 return std::make_unique<ChoiceParameterComponent> (processor, parameter);
489 return std::make_unique<SliderParameterComponent> (processor, parameter);
492 void audioProcessorParameterChanged (AudioProcessor*,
int,
float)
override {}
494 void audioProcessorChanged (AudioProcessor*,
const ChangeDetails&
details)
override
496 if (!
details.parameterInfoChanged)
505 void handleAsyncUpdate()
override
510 if (
auto* p = parameterComp.
get())
511 p->handleNewParameterValue();
527 return std::make_unique<ParameterDisplayComponent> (editor, param);
539 : name (group.getName())
541 for (
auto* node : group)
543 if (
auto* param = node->getParameter())
547 if (
auto* inner = node->getGroup())
549 auto groupItem = std::make_unique<ParameterGroupItem> (editor, *inner);
551 if (groupItem->getNumSubItems() != 0)
561 return std::make_unique<Label> (name, name);
571 : legacyParameters (editor.
processor,
false),
572 groupItem (editor, legacyParameters.getGroup())
574 const auto numIndents = getNumIndents (groupItem);
599GenericAudioProcessorEditor::GenericAudioProcessorEditor (
AudioProcessor& p)
602 auto* viewport = pimpl->view.getViewport();
608 setSize (viewport->getViewedComponent()->getWidth() + viewport->getVerticalScrollBar().getWidth(),
609 jlimit (125, 400, viewport->getViewedComponent()->getHeight()));
612GenericAudioProcessorEditor::~GenericAudioProcessorEditor() =
default;
Has a callback method that is triggered asynchronously.
void triggerAsyncUpdate()
Causes the callback to be triggered at a later time.
void cancelPendingUpdate() noexcept
This will stop any pending updates from happening.
Base class for the component that acts as the GUI for an AudioProcessor.
void setResizable(bool allowHostToResize, bool useBottomRightCornerResizer)
Sets whether the editor is resizable by the host and/or user.
AudioProcessor & processor
The AudioProcessor that this editor represents.
AudioProcessorEditorHostContext * getHostContext() const noexcept
Gets a context object, if one is available.
Base class for listeners that want to know about changes to an AudioProcessor.
A class encapsulating a group of AudioProcessorParameters and nested AudioProcessorParameterGroups.
A base class for listeners that want to know about changes to an AudioProcessorParameter.
An abstract base class for parameter objects that can be added to an AudioProcessor.
virtual float getValue() const =0
Called by the host to find out the value of this parameter.
virtual String getLabel() const =0
Some parameters may be able to return a label string for their units.
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.
virtual int getNumSteps() const
Returns the number of steps that this parameter's range should be quantised into.
virtual bool isAutomatable() const
Returns true if the host can automate this parameter.
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.
virtual StringArray getAllValueStrings() const
Returns the set of strings which represent the possible states a parameter can be in.
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.
int getParameterIndex() const noexcept
Returns the index of this parameter in its parent processor's parameter list.
virtual bool isBoolean() const
Returns whether the parameter represents a boolean switch, typically with "On" and "Off" states.
virtual String getName(int maximumStringLength) const =0
Returns the name to display for this parameter, which should be made to fit within the given string l...
Base class for audio processing classes or plugins.
virtual void removeListener(AudioProcessorListener *listenerToRemove)
Removes a previously added listener.
virtual void addListener(AudioProcessorListener *newListener)
Adds a listener that will be called when an aspect of this processor changes.
static int getDefaultNumParameterSteps() noexcept
Returns the default number of steps for a parameter.
void resized() override
Called when this component's size has been changed.
void paint(Graphics &) override
Components can override this method to draw their content.
void resized() override
Called when this component's size has been changed.
void paint(Graphics &) override
Components can override this method to draw their content.
void addItemList(const StringArray &items, int firstItemIdOffset)
Adds an array of items to the drop-down list.
void setSelectedItemIndex(int newItemIndex, NotificationType notification=sendNotificationAsync)
Sets one of the items to be the current selection.
std::function< void()> onChange
You can assign a lambda to this callback object to have it called when the selected ID is changed.
String getText() const
Returns the text that is currently shown in the combo-box's text field.
The base class for all JUCE user-interface objects.
void setInterceptsMouseClicks(bool allowClicksOnThisComponent, bool allowClicksOnChildComponents) noexcept
Changes the default return value for the hitTest() method.
void addAndMakeVisible(Component *child, int zOrder=-1)
Adds a child component to this one, and also makes the child visible if it isn't already.
void setOpaque(bool shouldBeOpaque)
Indicates whether any parts of the component might be transparent.
void setBounds(int x, int y, int width, int height)
Changes the component's position and size.
void setSize(int newWidth, int newHeight)
Changes the size of the component.
void setColour(int colourID, Colour newColour)
Registers a colour to be used for a particular purpose.
Colour findColour(int colourID, bool inheritFromParent=false) const
Looks for a colour that has been registered with the given colour ID number.
LookAndFeel & getLookAndFeel() const noexcept
Finds the appropriate look-and-feel to use for this component.
Rectangle< int > getLocalBounds() const noexcept
Returns the component's bounds, relative to its own origin.
void paint(Graphics &) override
Components can override this method to draw their content.
void resized() override
Called when this component's size has been changed.
A graphics context, used for drawing a component or image.
void fillAll() const
Fills the context's entire clip region with the current colour or brush.
@ centredRight
Indicates that the item should be centred vertically but placed on the right hand side.
@ centred
Indicates that the item should be centred vertically and horizontally.
A component that displays a text string, and can optionally become a text editor when clicked.
@ outlineColourId
An optional colour to use to draw a border around the label.
void setJustificationType(Justification justification)
Sets the style of justification to be used for positioning the text.
void setBorderSize(BorderSize< int > newBorderSize)
Changes the border that is left between the edge of the component and the text.
void setText(const String &newText, NotificationType notification)
Changes the label text.
static MessageManager * getInstance()
Returns the global instance of the MessageManager.
bool isRightButtonDown() const noexcept
Checks whether the flag is set for the right mouse-button.
Contains position and status information about a mouse event.
const ModifierKeys mods
The key modifiers associated with the event.
void resized() override
Called when this component's size has been changed.
void mouseDown(const MouseEvent &e) override
Called when a mouse button is pressed.
Rectangle reduced(ValueType deltaX, ValueType deltaY) const noexcept
Returns a rectangle that is smaller than this one by a given amount.
Rectangle removeFromLeft(ValueType amountToRemove) noexcept
Removes a strip from the left-hand edge of this rectangle, reducing this rectangle by the specified a...
@ backgroundColourId
A colour to use to fill the window's background.
void paint(Graphics &) override
Components can override this method to draw their content.
void resized() override
Called when this component's size has been changed.
std::function< void()> onDragStart
You can assign a lambda to this callback object to have it called when the slider's drag begins.
void setDoubleClickReturnValue(bool shouldDoubleClickBeEnabled, double valueToSetOnDoubleClick, ModifierKeys singleClickModifiers=ModifierKeys::altModifier)
This lets you choose whether double-clicking or single-clicking with a specified key modifier moves t...
std::function< void()> onValueChange
You can assign a lambda to this callback object to have it called when the slider value is changed.
void setScrollWheelEnabled(bool enabled)
This can be used to stop the mouse scroll-wheel from moving the slider.
std::function< void()> onDragEnd
You can assign a lambda to this callback object to have it called when the slider's drag ends.
double getValue() const
Returns the slider's current value.
@ LinearHorizontal
A traditional horizontal slider.
@ textBoxOutlineColourId
The colour to use for a border around the text-editor box.
void setValue(double newValue, NotificationType notification=sendNotificationAsync)
Changes the slider's current value.
@ NoTextBox
Doesn't display a text box.
void setRange(double newMinimum, double newMaximum, double newInterval=0)
Sets the limits that the slider's value can take.
int indexOf(StringRef stringToLookFor, bool ignoreCase=false, int startIndex=0) const
Searches for a string in the array.
int size() const noexcept
Returns the number of strings in the array.
bool isEmpty() const noexcept
Returns true if the array is empty, false otherwise.
void paint(Graphics &) override
Components can override this method to draw their content.
void resized() override
Called when this component's size has been changed.
Makes repeated callbacks to a virtual method at a specified time interval.
int getTimerInterval() const noexcept
Returns the timer's interval.
void startTimerHz(int timerFrequencyHz) noexcept
Starts the timer with an interval specified in Hertz.
void startTimer(int intervalInMilliseconds) noexcept
Starts the timer and sets the length of interval required.
int getNumSubItems() const noexcept
Returns the number of sub-items that have been added to this item.
void addSubItem(TreeViewItem *newItem, int insertPosition=-1)
Adds a sub-item.
TreeViewItem * getSubItem(int index) const noexcept
Returns one of the item's sub-items.
void setDefaultOpenness(bool isOpenByDefault)
Sets whether items are open or closed by default.
int getIndentSize() noexcept
Returns the number of pixels by which each nested level of the tree is indented.
void setRootItem(TreeViewItem *newRootItem)
Sets the item that is displayed in the TreeView.
void setRootItemVisible(bool shouldBeVisible)
Changes whether the tree's root item is shown or not.
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.
constexpr Type jmin(Type a, Type b)
Returns the smaller of two values.
constexpr Type jmax(Type a, Type b)
Returns the larger of two values.
Type jlimit(Type lowerLimit, Type upperLimit, Type valueToConstrain) noexcept
Constrains a value to keep it within a given range.
@ dontSendNotification
No notification message should be sent.
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.
A simple wrapper around std::atomic.
bool compareAndSetBool(Type newValue, Type valueToCompare) noexcept
Atomically compares this value with a target value, and if it is equal, sets this to be equal to a ne...
Provides details about aspects of an AudioProcessor which have changed.
bool mightContainSubItems() override
Tells the tree whether this item can potentially be opened.
std::unique_ptr< Component > createItemComponent() override
Creates a component that will be used to represent this item.
int getItemHeight() const override
Must return the height required by this item.
std::unique_ptr< Component > createItemComponent() override
Creates a component that will be used to represent this item.
bool mightContainSubItems() override
Tells the tree whether this item can potentially be opened.