Turning a GUI component's class on and off

I want to do something similar to what was suggested at https://forum.foleysfinest.com/t/making-components-leave-the-layout-when-invisible/132

That is, I have some classes defined in magic.xml. I want to be able to turn a component’s class on and off at run-time, in response to someone clicking a button on the interface.

What would be the line(s) of code in the PluginProcessor.cpp to add or remove a named GUI class from a GUI element?


I tried this quickly.
The flex grow set to 0 does not always work, because of the order the class is applied. If the node already sets a grow, the class has no chance to change that.
However, I used max-height sucessfully.

  • First I added a ToggleButton and added a new value, here “UI:hideKeyboard”
  • Then I created a class called “hidden”. Connect the class: active property to the “UI:hideKeyboard”.
  • For good measure I set max-width, max-height and flex-grow to 0.
  • applied the class to the component I wanted to hide

Unfortunately the change to the class didn’t work immediately, so I had to force a rebuild of the GUI in the menu: File → Refresh.

Now the checkbox can switch the keyboard on and off

Let me know if that works for you

That worked! I hadn’t noticed the active property of a class before.
I’ve now extended this so that there are two Views, with the second View hidden (and not taking up blank space on the interface). If the user clicks a button, the first View gets hidden and the second View is revealed.
This is a precursor to getting the JUCE tutorial JUCE: Tutorial: Unlock your plugins through online registration working with PGM. Hopefully, the next step, getting JUCE’s OnlineUnlockForm as a custom GUI component, won’t be too difficult. If you’ve got any ideas there, though, that would be great.
Thanks again.