diff --git a/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp b/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp index dc9c3747ff..d599407d72 100644 --- a/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp @@ -353,7 +353,10 @@ struct AAXClasses addAndMakeVisible (pluginEditor = plugin.createEditorIfNeeded()); if (pluginEditor != nullptr) + { setBounds (pluginEditor->getLocalBounds()); + pluginEditor->addMouseListener (this, true); + } } ~ContentWrapperComponent() @@ -361,6 +364,7 @@ struct AAXClasses if (pluginEditor != nullptr) { PopupMenu::dismissAllActiveMenus(); + pluginEditor->removeMouseListener (this); pluginEditor->processor.editorBeingDeleted (pluginEditor); } } @@ -370,6 +374,26 @@ struct AAXClasses g.fillAll (Colours::black); } + template + void callMouseMethod (const MouseEvent& e, MethodType method) + { + if (AAX_IViewContainer* vc = owner.GetViewContainer()) + { + const int parameterIndex = pluginEditor->getControlParameterIndex (*e.eventComponent); + + if (parameterIndex >= 0) + { + uint32_t mods = 0; + vc->GetModifiers (&mods); + (vc->*method) (IndexAsParamID (parameterIndex), mods); + } + } + } + + void mouseDown (const MouseEvent& e) override { callMouseMethod (e, &AAX_IViewContainer::HandleParameterMouseDown); } + void mouseUp (const MouseEvent& e) override { callMouseMethod (e, &AAX_IViewContainer::HandleParameterMouseUp); } + void mouseDrag (const MouseEvent& e) override { callMouseMethod (e, &AAX_IViewContainer::HandleParameterMouseDrag); } + void childBoundsChanged (Component*) override { if (pluginEditor != nullptr) @@ -737,35 +761,6 @@ struct AAXClasses } private: - struct IndexAsParamID - { - inline explicit IndexAsParamID (int i) noexcept : index (i) {} - - operator AAX_CParamID() noexcept - { - jassert (index >= 0); - - char* t = name + sizeof (name); - *--t = 0; - int v = index; - - do - { - *--t = (char) ('0' + (v % 10)); - v /= 10; - - } while (v > 0); - - return static_cast (t); - } - - private: - int index; - char name[32]; - - JUCE_DECLARE_NON_COPYABLE (IndexAsParamID) - }; - void process (float* const* channels, const int numChans, const int bufferSize, const bool bypass, AAX_IMIDINode* midiNodeIn, AAX_IMIDINode* midiNodesOut) { @@ -920,6 +915,36 @@ struct AAXClasses JUCE_DECLARE_NON_COPYABLE (JuceAAX_Processor) }; + //============================================================================== + struct IndexAsParamID + { + inline explicit IndexAsParamID (int i) noexcept : index (i) {} + + operator AAX_CParamID() noexcept + { + jassert (index >= 0); + + char* t = name + sizeof (name); + *--t = 0; + int v = index; + + do + { + *--t = (char) ('0' + (v % 10)); + v /= 10; + + } while (v > 0); + + return static_cast (t); + } + + private: + int index; + char name[32]; + + JUCE_DECLARE_NON_COPYABLE (IndexAsParamID) + }; + //============================================================================== static void AAX_CALLBACK algorithmProcessCallback (JUCEAlgorithmContext* const instancesBegin[], const void* const instancesEnd) diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp b/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp index 72f4c41e46..a625411117 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp @@ -40,3 +40,4 @@ AudioProcessorEditor::~AudioProcessorEditor() } void AudioProcessorEditor::setControlHighlight (ParameterControlHighlightInfo) {} +int AudioProcessorEditor::getControlParameterIndex (Component&) { return -1; } diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.h b/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.h index 8926ae9e9c..1755497c33 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.h +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.h @@ -75,6 +75,15 @@ public: */ virtual void setControlHighlight (ParameterControlHighlightInfo); + /** Called by certain plug-in wrappers to find out whether a component is used + to control a parameter. + + If the given component represents a particular plugin parameter, then this + method should return the index of that parameter. If not, it should return -1. + Currently only AAX plugins will call this, and implementing it is optional. + */ + virtual int getControlParameterIndex (Component&); + private: JUCE_DECLARE_NON_COPYABLE (AudioProcessorEditor) };