Trying to smoothly animate window resize in audio plugin

gui

#1

Hello there,
I have an audio plugin that has a button that when clicked will expand the window size and show a component will extra controls on it. Calling setsize in the editor does this perfectly but it would be nice if I could animate the resizing so the window grows/shrinks when the button is clicked.
I’ve attempting this using the timerCallback function (shown below) to gradually resize the window however the window turns white until the animation is complete. I’ve timed the resized function and it’s only taking 1 millisecond to repaint the GUI and the timerCallback is being called every 20 milliseconds so there should be enough time to repaint the GUI.

Could anyone tell me why my GUI can’t keep up? Or maybe know a better way of animating a plugin window size altogether?

void UIHolder::timerCallback()
{
        int currentWidth = getWidth();
        //animate window getting larger
        if (currentWidth < PLUGIN_WIDTH_EXPANDED)
        {
            m_pluginEditor->setSize(currentWidth + m_animationStep, PLUGIN_HEIGHT);
            resized();
        }
        //animate window getting smaller
        else if (currentWidth > PLUGIN_WIDTH_NORMAL)
        {
            m_pluginEditor->setSize(currentWidth - m_animationStep, PLUGIN_HEIGHT);
            resized();
        }
        else 
        {
            stopTimer();
        }
}

#2

Have you seen any other plugin in your host successfully doing that?


#3

I’m using Reaper and now that I think about it no, I have not seen another plugin do that.


#4

The plugins resizing their windows needs some cooperation from the host. One shouldn’t expect even a sudden non animated resizing to always work in every host. (Every decent host should have at least some support for plugins resizing, though.)


#5

then I should probably drop the animation and check it will resize alright in some other hosts! Thank you for taking the time to reply to my post.


#6

they don’t animate, but Metric Halo plugins do have a couple different sizes you can use for their GUIs. Kontakt is resizable via the lower right corner thingie.