When you resize a plugin created with JUCE > 6.1.2 in Logic, the resizing is jerky, see this video.
Although you enlarge the GUI size by dragging the resizer triangle, the current values for width and height in PluginEditor::resized()
are occasionally smaller(!) than the ones in the previous call. This leads to unsightly jumps in the editor size during resizing.
I checked this with both JUCE 7.0.5 and the current develop branch.
The problem occurs for example in Logic 10.7.7 on Ventura/M1 and in Logic 10.6.3 on Catalina (Intel).
To reproduce this, I created a basic plugin “ResizablePlugin” (https://github.com/CppClown/ResizablePlugin.git) with the Projucer and did the following modifications:
- PluginEditor.h: Add private members
mWidth
andmHeight
and a text editor:
...
private:
// This reference is provided as a quick way for your editor to
// access the processor object that created it.
ResizablePluginAudioProcessor& audioProcessor;
int mWidth { 0 };
int mHeight { 0 };
juce::TextEditor mTextEditor;
...
- PluginEditor.cpp: The text editor is added in the constructor. Likewise, the code to allow resizing is added:
...
ResizablePluginAudioProcessorEditor::ResizablePluginAudioProcessorEditor (ResizablePluginAudioProcessor& p)
: AudioProcessorEditor (&p), audioProcessor (p)
{
//-------- Text editor.
mTextEditor.setReadOnly(true);
mTextEditor.setFont(Font("Consolas", 16.f, Font::FontStyleFlags::plain));
mTextEditor.setMultiLine(true);
addAndMakeVisible(mTextEditor);
//-------- Set size and limits.
const auto minWidth = 500.f;
const auto minHeight = 375.f;
const auto maxWidth = 1240.f;
const auto maxHeight = 930.f;
setResizable(false, true);
if (auto componentBoundsConstrainer = getConstrainer())
{
componentBoundsConstrainer->setSizeLimits(
roundToInt(minWidth), roundToInt(minHeight),
roundToInt(maxWidth), roundToInt(maxHeight));
componentBoundsConstrainer->setFixedAspectRatio(4.f / 3.f);
}
setSize(minWidth, minHeight);
}
...
- PluginEditor.cpp: Add code to
resized()
to display the current width and height. Each time the size is smaller than the previous size, a message is issued.
...
void ResizablePluginAudioProcessorEditor::resized()
{
// This is generally where you'll want to lay out the positions of any
// subcomponents in your editor..
mTextEditor.setBounds(getLocalBounds());
const auto w = getWidth();
const auto h = getHeight();
mTextEditor.insertTextAtCaret("w = " + String(w) + ", h = " + String(h));
if (w < mWidth || h < mHeight)
{
mTextEditor.insertTextAtCaret(" Smaller than previous size!");
}
mTextEditor.insertTextAtCaret("\n");
mWidth = w;
mHeight = h;
}
...
Now when you run the plugin in Logic and enlarge its GUI by dragging the resizer triangle, the message “Smaller than previous size!” is occasionally output. It is especially annoying when you move the mouse quickly, because then the jumps are large. This should not happen.
Obviously the problem was introduced in commit https://github.com/juce-framework/JUCE/commit/4ca923a34b3cec79b50c3f1cb794f8327d7530a0.
Could you please take a look and possibly offer a solution? Thank you very much.