Most optimal way of managing panels with repeat controls?

Reid115
Reid115 Member Posts: 47 Member
edited July 2022 in Scripting Workshop

I'm working on a project that has tabs in the GUI that flip between different tables. On each tab is a table, along with a bunch of controls of various ui types. Each tab is the exact same with everything in the exact same position -- just different iterations of the controls. There are roughly 50 ui elements on each tab that are tied to the respective table. My question is this: does it make more sense to actually re-declare these 50 elements for every single tab, or should I make integer arrays to store the values, and then reload them into the elements on a tab change? If I have, say, 8 tabs, thats 8*50 = 400 ui elements to declare, which really bloats the GUI. So instead, I was thinking something like this:

declare const NUM_TABS := 8
declare pers ui_value_edit ve1
declare pers %ve1_vals[NUM_TABS]
declare pers ui_value_edit ve2
declare pers %ve2_vals[NUM_TABS]

function tab_change
    ve1 := ve1_vals[selected_tab]
    ve2 := ve2_vals[selected_tab]
end function

on ui_control (ve1)
    ve1_vals[selected_tab] := ve1
end on

on ui_control (ve2)
    ve2_vals[selected_tab] := ve2
end on

This is just a basic example showing 2 value edits shared by 8 tabs. Is this the most optimal way of handling this on a large scale? I just want to make sure I'm not overthinking this before commiting to writing the code this way. Thanks.

Just to be clear, I'm talking about custom tabs in the GUI -- not tabs from multiple scripts.

Comments

  • Lovechld2000
    Lovechld2000 Member Posts: 29 Member

    when i did something on a large scale i opted for storing values in an array and recalled the settings when viewing the tabs. the downside is you can't automate the ui because the control alters values in the context of what tab is viewed

  • EvilDragon
    EvilDragon Moderator Posts: 1,022 mod

    In your particular case, I would use one widget and use an array to store the data, then update the widget value depending on which tab you're on. Much more compact. This works for pretty much anything, but if you need the parameter to be host automatable/MIDI learnable, this is where you need separate widget instances. For value edits and tables, though, you don't need that since those aren't automatable anyways.

Back To Top