Best way to implement resizable plugin


Hi all, 

Quite the noob question I'm sure, but what is the best way to implement a resizable plugin? Since the AudioProcessorEditor inherits from Component, it doesn't make sense for it to also inherit from ResizableWindow, right? 

Or is the way to do this to use GenericAudioProcessorEditor instead of AudioProcessorEditor, and then use its resized() method?




ResizeableWindow is no good for this - it's for use on the desktop. The demo plugin is resizable, using a ResizeableCornerComponent, so have a look at how that works.


thank you! Here's how I did it, in case it might be useful for others that want to implement the resizableCorner in their plugin: 

    1. In editor
        a. In constructor (AT THE END since components added last are shown on top of previous ones), Add resizableCorner and resize limits, like this:

addAndMakeVisible (resizer = new ResizableCornerComponent (this, &resizeLimits));
resizeLimits.setSizeLimits (150, 150, 800, 300);
setSize (ownerFilter->lastUIWidth, ownerFilter->lastUIHeight);

        b. Add resized() method:

void AudioProcessorEditor::resized() {
  resizer->setBounds (getWidth() - 16, getHeight() - 16, 16, 16);
  getProcessor()->lastUIWidth = getWidth();
  getProcessor()->lastUIHeight = getHeight();

    2. In processor
        a. Add memory for width and height in .h

int lastUIWidth, lastUIHeight;

        b. Set up their default values in the constructor, e.g.

lastUIWidth = 400;
lastUIHeight = 200;

        c. Add them to getStateInformation()

xml.setAttribute ("uiWidth", lastUIWidth);
xml.setAttribute ("uiHeight", lastUIHeight);

        d. add them to setStateInformation()

lastUIWidth  = xmlState->getIntAttribute ("uiWidth", lastUIWidth);
lastUIHeight = xmlState->getIntAttribute ("uiHeight", lastUIHeight);


could I extend this question and ask what the best/easiest way to rescale the UI is? I'm interested in the scalable vector GUIs as used by ValhallaDSP and Madronna Labs?




look here:


It looks like since this thread started, the AudioProcessorEditor class has been updated to include a ResizeableCornerComponent. Just use the methods:

AudioProcessorEditor::setResizable(true, true) and
AudioProcessorEditor::setResizeLimits(minWidth, minHeight, maxWidth, maxHeight)
and it just magically happens.

Of course, if you wish to save size state as part of the plugin state saving then there is more to do. The audio plugin example code does this I think.


Also, make sure you initialise all your GUI components before you call setResizeLimits() otherwise there’ll be trouble.