So I have a PluginWindow derived from DocumentWindow and if I add a AudioProcessorEditor to the PluginWindow using:
setContentOwned (editor, true);
Where editor is a AudioProcessorEditor*
The plug-in editor shows up fine at all times… but if I create a simple PluginComponent class:
class PluginComponent : public Component,
public ComponentListener
{
public:
PluginComponent (AudioProcessorEditor* pEditor) : m_pEditor (pEditor)
{
int iWidth = m_pEditor->getWidth();
int iHeight = m_pEditor->getHeight();
setSize (iWidth, iHeight);
m_pEditor->setTopLeftPosition (0, 0);
addAndMakeVisible (m_pEditor);
m_pEditor->addComponentListener (this);
}
~PluginComponent()
{
m_pEditor->removeComponentListener (this);
}
void componentMovedOrResized (Component& component, bool wasMoved, bool wasResized) override
{
if (wasResized && m_pEditor == &component)
{
int iWidth = m_pEditor->getWidth();
int iHeight = m_pEditor->getHeight();
setSize (iWidth, iHeight);
m_pEditor->setTopLeftPosition (0, 0);
}
}
void paint (Graphics& g) override
{
g.fillAll (Colours::red);
}
private:
AudioProcessorEditor* m_pEditor = nullptr;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PluginComponent);
};
and add the PluginComponent like this:
setContentOwned (new PluginComponent (editor), true);
It works fine for almost all plug-in manufacturers except one that I’ve tested… in that case the first time the Window is displayed it draws the VST2 AudioProcessorEditor, but if I close and re-open the Window the plug-in area is black.
Stepping though the code I don’t see anything wrong… and if I load a VST3 version of the plug-in it always draws correctly.
Any thoughts on why the VST2 when embedded in a “parent” Component will not repaint (for a particular plug-in)… but when not embedded in another Component paints fine?
Thanks,
Rail