I’d like to make my plugin window resizable, but always conform to a given aspect ratio, and I’m a little confused about the best way to do this.
I have a
ComponentBoundsConstrainer member variable on my PluginEditor class, and it seems like I should be able to do this:
m_constrainer.setSizeLimits(512, 512 / ratio, 4096, 4096 / ratio); m_constrainer.setFixedAspectRatio(ratio); setResizable(true, true); setConstrainer(&m_constrainer);
But this doesn’t seem to work. So my second approach was to use my own
addAndMakeVisible(m_resizableCorner = new ResizableCornerComponent(this, &m_constrainer));
This seems to have done the trick, but I’m not sure exactly how it differs from what I was trying to do beforehand. What is the PluginEditor’s
attachConstrainer method supposed to do?
It also feels wasteful to me to define my own
ResizableCornerComponent when the
AudioProcessorEditor class has it’s own public
ScopedPointer<ResizableCornerComponent> member. That makes me think the
ResizableCornerComponent should have a public method which allows me to set a constrainer?
Lastly, and this is a bit of a tangent, why does the
AudioProcessorEditor class define its resizable corner member with a
ScopedPointer<ResizableCornerComponent> m_corner; where in most other places it seems like the suggestion would be to just use a stack allocated member variable: