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?

Cheers, 

Vincent

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);
1 Like

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?

cheers

oli

look here:  http://www.juce.com/forum/topic/audioprocessoreditor-drawing-openglrenderer-flickers-resizing

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.

2 Likes

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

Bumping: Does anyone know how to do all of the above, where the resizable plugin will also resize when changing aupresets? Apparently the aupreset format stores a plugin window size, which will resize the outer boundaries of the plugin container, but not my actual plugin GUI.

1 Like

Hello,

Maybe this is obvious, but it is important to call setSize after setResizable and setResizeLimits.
For example, this would not make editor resizeable:

	setSize(800, 400);
	setResizable(true, true);
	setResizeLimits(800, 100, 1000, 1000);

but this will work:

	setResizable(true, true);
	setResizeLimits(800, 100, 1000, 1000);
	setSize(800, 400);

Or setSize can be omitted.

Kindly regards,
Mateusz

1 Like

If you don’t need to change the aspect ratio of the plugin, the easiest way is to use an AffineTransform in your PluginEditor.
This way you can just use pixels with all component’s setBounds()

1 Like