I’m using a custom ComponentBoundsConstrainer
subclass to handle my resizable plugin. It makes sure that the main component always has a fixed aspect ratio and then adds some extra constant height for a preset menu placed above the content. My checkBounds
implementation looks like that.
void MyConstrainer::checkBounds (juce::Rectangle<int>& bounds, const juce::Rectangle<int>&, const juce::Rectangle<int>&, bool, bool, bool, bool)
{
auto contentHeight = juce::jmax (contentMinHeight, bounds.getHeight() - presetManagerComponentHeight);
auto contentWidth = juce::jmax (contentMinWitdh, juce::roundToInt (contentHeight * contentAspectRatio));
bounds.setSize (contentWidth, contentHeight + presetManagerComponentHeight);
}
I set it all up like
setResizable (true, true);
setConstrainer (&myConstrainer);
In the editor constructor. This works as expected when using the resizer. However, it’s still possible to resize the plugin window in width/heigtht individually and override the constraints this way, which leads to ugly looking misplaced sub components etc. This can be reproduced under e.g. Cubase or Reaper.
I see that the first argument passed to the setResizable
call is allowHostToResize
. Setting this to false does not help either, I’m still able to resize the window in any direction and override the constrainer, but it makes the resizer disappear
I get the feeling that I’m misunderstanding something here. Is there anything totally wrong with my approach?