mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-17 00:44:19 +00:00
GenericAudioProcessorEditor: Update parameter names when AudioProcessor changes
This commit is contained in:
parent
cfec0b5356
commit
07ca7ae13b
1 changed files with 30 additions and 1 deletions
|
|
@ -406,12 +406,16 @@ private:
|
|||
};
|
||||
|
||||
//==============================================================================
|
||||
class ParameterDisplayComponent : public Component
|
||||
class ParameterDisplayComponent : public Component,
|
||||
private AudioProcessorListener,
|
||||
private AsyncUpdater
|
||||
{
|
||||
public:
|
||||
ParameterDisplayComponent (AudioProcessorEditor& editorIn, AudioProcessorParameter& param)
|
||||
: editor (editorIn), parameter (param)
|
||||
{
|
||||
editor.processor.addListener (this);
|
||||
|
||||
parameterName.setText (parameter.getName (128), dontSendNotification);
|
||||
parameterName.setJustificationType (Justification::centredRight);
|
||||
parameterName.setInterceptsMouseClicks (false, false);
|
||||
|
|
@ -426,6 +430,12 @@ public:
|
|||
setSize (400, 40);
|
||||
}
|
||||
|
||||
~ParameterDisplayComponent() override
|
||||
{
|
||||
cancelPendingUpdate();
|
||||
editor.processor.removeListener (this);
|
||||
}
|
||||
|
||||
void resized() override
|
||||
{
|
||||
auto area = getLocalBounds();
|
||||
|
|
@ -479,6 +489,25 @@ private:
|
|||
return std::make_unique<SliderParameterComponent> (processor, parameter);
|
||||
}
|
||||
|
||||
void audioProcessorParameterChanged (AudioProcessor*, int, float) override {}
|
||||
|
||||
void audioProcessorChanged (AudioProcessor*, const ChangeDetails& details) override
|
||||
{
|
||||
if (! details.parameterInfoChanged)
|
||||
return;
|
||||
|
||||
if (MessageManager::getInstance()->isThisTheMessageThread())
|
||||
handleAsyncUpdate();
|
||||
else
|
||||
triggerAsyncUpdate();
|
||||
}
|
||||
|
||||
void handleAsyncUpdate() override
|
||||
{
|
||||
parameterName .setText (parameter.getName (128), dontSendNotification);
|
||||
parameterLabel.setText (parameter.getLabel(), dontSendNotification);
|
||||
}
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ParameterDisplayComponent)
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue