1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Extensions to AudioProcessorEditor to help clicking on AAX controls.

This commit is contained in:
jules 2014-08-19 17:03:09 +01:00
parent a323d4d797
commit 4604767220
3 changed files with 64 additions and 29 deletions

View file

@ -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 <typename MethodType>
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<AAX_CParamID> (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<AAX_CParamID> (t);
}
private:
int index;
char name[32];
JUCE_DECLARE_NON_COPYABLE (IndexAsParamID)
};
//==============================================================================
static void AAX_CALLBACK algorithmProcessCallback (JUCEAlgorithmContext* const instancesBegin[],
const void* const instancesEnd)

View file

@ -40,3 +40,4 @@ AudioProcessorEditor::~AudioProcessorEditor()
}
void AudioProcessorEditor::setControlHighlight (ParameterControlHighlightInfo) {}
int AudioProcessorEditor::getControlParameterIndex (Component&) { return -1; }

View file

@ -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)
};