Minimal plugin bounds

I like resizable vector based plugins.

To set a minimal plugin size I added

void MyPluginProcessorEditor::resized()
{
    const int minWidth = 360;
    const int minHeight = 320;
    if (getWidth() < minWidth || getHeight() < minHeight)
    {
        setSize (jmax (minWidth, getWidth()), jmax (minHeight, getHeight()));
    }
    
    ...
}

to my editor.

Would you also do it like this? Or are there other approaches to set a minimal bound?

You mustn't attempt to set the size in the resized() callback - that could obviously get into all kinds of recursive loops.

If it's the host that's resizing your component, then your plugin will just have to accept whatever it gets. If the resizing is being done by your own GUI (e.g. by a ResizableCornerComponent, etc) then you should apply your constraints to the size before setBounds gets called.

If it's the host that's resizing your component, then your plugin will just have to accept whatever it gets.

I wasn't aware of that. Host triggered size change was the main reason to put it into resize() - fully aware of the recursion taking place (multiple times).

Will move it to a derived class of ResizableCornerComponent as you have suggested.

Thank you for the clarification!

Will move it to a derived class of ResizableCornerComponent as you have suggested.

That sounds weird to me. I'm doing it just this way :

in your editor.h :
    ScopedPointer <ResizableCornerComponent> resizer;
    ComponentBoundsConstrainer resizeLimits;
    
in the constructor :
    addAndMakeVisible (resizer = new ResizableCornerComponent (this, &resizeLimits));
    resizeLimits.setSizeLimits (minW, minH, maxW, maxH);


in resized() :
    resizer->setBounds (getWidth() - 20, getHeight() - 20, 20, 20);
 

 

Thank you lalala for the hint and your code snippet!
I wasn't aware of the ComponentBoundsConstrainer. Quite handy!