Hoping for TABS in Designer

Post Reply
creart
Posts: 31
Joined: Sat Dec 19, 2020 12:13 pm
Location: Netherlands
Contact:

Hoping for TABS in Designer

Post by creart » Mon Feb 01, 2021 8:27 pm

I really like Designer, but creating layouts could become a lot easier if there was some sort of a TAB object, with in-editor option to show/hide...
When designing modules at some point it can come in handy to divide knobs etc. over several TABS...
And while it's perfectly possible to create those kind of things in Java, there is know way to hide objects in the editor which makes it real hard to design multi-TAB screens...

I hope Cherry Audio at some point will create an option for that...

Are others having the same difficulties?

cheers Hans

User avatar
honki-bobo
Posts: 111
Joined: Sat Nov 09, 2019 1:18 pm

Re: Hoping for TABS in Designer

Post by honki-bobo » Mon Feb 01, 2021 11:01 pm

You can use the SetVisible(boolean isVisible) method to switch visibility of GUI elements, i.e. create two toggle buttons in one toggle group (your tab selectors), which turn visibility of certain elements on or off, depending on what you want to see on each tab.
Image
Monkey Business Audio
Modules - Forum

creart
Posts: 31
Joined: Sat Dec 19, 2020 12:13 pm
Location: Netherlands
Contact:

Re: Hoping for TABS in Designer

Post by creart » Mon Feb 01, 2021 11:35 pm

Ya I know and use that Martin... and that’s good for ‘runtime’ but when editing I end up with multiple elements in the same spot that are on top of each other that I can not hide IN the editor window....
Or do I miss something?

terrymcg
Posts: 61
Joined: Mon Apr 08, 2019 12:35 am

Re: Hoping for TABS in Designer

Post by terrymcg » Tue Feb 02, 2021 5:09 am

creart wrote:
Mon Feb 01, 2021 11:35 pm
Ya I know and use that Martin... and that’s good for ‘runtime’ but when editing I end up with multiple elements in the same spot that are on top of each other that I can not hide IN the editor window....
Or do I miss something?
You can (with a bit of work behind the scenes, and some limitations), create the 'duplicate' components on the fly, using the existing ones as references. For example, I use code like this to create arrays of LEDs on the fly:

Code: Select all

/*
 * dynamic gui control creation helpers
 *
 * AddComponent() is native to VoltageModule, and isn't visible from our external jar
 * but it seems likely (from the code generated by VMD) that calling AddComponent()
 * immediatly after creating the gui element is important.  So before adding them to an
 * instance of our 'LedRack' class(es) we'll create the leds, and AddComponent() them 
 * as we go.  then we'll return the batch of new leds as an array (for use with 
 * the LedRack constructor)
 *
 */
// create a bunch of leds using the specified skin
public VoltageLED[] LedFactory (int n, String skin, String name_root) {
   VoltageLED[] leds = new VoltageLED[n];
   
   for (int i=0; i < leds.length; i++) {
      String lname = name_root + " " + (i+1);
      
      leds[i] = new VoltageLED (lname, lname, this);
      AddComponent (leds[i]);
      leds[i].SetSkin (skin);
      leds[i].SetVisible (false);
   }
   
   return leds;
}
The skin you use needs to already exist in the module (ie, you need to have a manually created component using the skin), but otherwise, dynamically created GUI elements can be used and abused just like the manual ones. :) The 'name_root' parameter above is used to generate sequential names for the new LEDs (only for VM's benefit, since you've now got an array of LEDs to work with, vs. having to use individual variable names).

And you're not limited to LEDs either of course - just look at the un-editable section of the module, and copy the matching initialization sequence for the component(s) you want to create on the fly.

To clone the location etc. of existing components, try something like this:

Code: Select all

// build a toggle button from a source toggle button and string
public VoltageToggle ButtonFactory (VoltageToggle src, String name) {
   VoltageToggle button = new VoltageToggle (name, name, this, false, 0);
   AddComponent(button);
   button.SetWantsMouseNotifications( false );
   button.SetRect(src.GetRect());
   button.SetSkin( "Blue Square" );
   button.ShowOverlay( false );
   button.SetOverlayText( "" );
   button.SetVisible( false );
   
   return button;
}
By combining the two, you can create arrays of cloned (position, etc) components. :D

Hope that helps!

Cheers,
--
Terry McG

creart
Posts: 31
Joined: Sat Dec 19, 2020 12:13 pm
Location: Netherlands
Contact:

Re: Hoping for TABS in Designer

Post by creart » Tue Feb 02, 2021 9:44 am

Very cool trick, Terry!
I must confess that coming from (the last 15 years or so) PHP I missed the option of creating 'variable variables' that can in PHP be easily used to create objects on the fly...
I didn't really get how in Java (actually just started with it) something like that could be done - so very cool - thanks a lot!!!

This is at least a way of creating some repeating elements on the fly while having the tabs-images or rects in between and not clutter the editor...

I still think it would be very useful if the editor had a 'tab container' that could hold objects and the tab container could be set to hide/visible within the editor as well, like form editors in for instance VBA have...
But again thanks for this great advice!

cheers Hans

terrymcg
Posts: 61
Joined: Mon Apr 08, 2019 12:35 am

Re: Hoping for TABS in Designer

Post by terrymcg » Wed Feb 03, 2021 12:13 am

Hi Hans...
creart wrote:
Tue Feb 02, 2021 9:44 am
I still think it would be very useful if the editor had a 'tab container' that could hold objects and the tab container could be set to hide/visible within the editor as well, like form editors in for instance VBA have...
Sounds good to me too! :)

Have fun with the clones ;)

Cheers,
--
Terry McG

creart
Posts: 31
Joined: Sat Dec 19, 2020 12:13 pm
Location: Netherlands
Contact:

Re: Hoping for TABS in Designer

Post by creart » Fri Feb 05, 2021 9:05 am

Hey Terry... certainly having fun with the clones...
I tried using the same kind of thing using an array of AnalogOscillators but have not succeeded to get sound yet...

My syntax seems to ok - no errors there, but no sound..

Have you ever tried that?

cheers Hans

creart
Posts: 31
Joined: Sat Dec 19, 2020 12:13 pm
Location: Netherlands
Contact:

Re: Hoping for TABS in Designer

Post by creart » Fri Feb 05, 2021 9:17 am

forget about it... just worked it out....
a variable was not properly initialized, so the value was incorrect... doh..

terrymcg
Posts: 61
Joined: Mon Apr 08, 2019 12:35 am

Re: Hoping for TABS in Designer

Post by terrymcg » Sat Feb 06, 2021 4:30 am

Glad it's working out!

I always seem to be missing a variable somewhere too ;)

Cheers,
--
Terry McG

creart
Posts: 31
Joined: Sat Dec 19, 2020 12:13 pm
Location: Netherlands
Contact:

Re: Hoping for TABS in Designer

Post by creart » Mon Feb 15, 2021 7:55 am

Ya right?
I can be so sloppy in typing... missing brackets..missing semicolons or mistyping ..orforgetting...
And you really almost start to rely on the checks that the editor does when building...
Like..do I have enough closing brackets?.. and instead of counting.. just wait for the error :D

Post Reply