Skip to content

3.1 What are UI Families

Davide Magni edited this page May 31, 2017 · 5 revisions

We wanted to be able to handle Scripts with a large amount of UI Controls. To do so, we introduced the concept of Families.

An UI Family is an ID assigned to each UI Control you create. This ID will be used to access to all the UI Controls assigned to a Family in order to perform mass actions on those UI Controls. For instance, you can hide and move all the UI Controls belonging to a specific Family.

It’s extremely important to organise UI Controls in proper Families. This will make much easier to access each Family the way you expect to, with no “surprises”.

As of Koala v2.1.4, it is possible to assign multiple Families to a single UI Control by using Tags. We will discuss this matter further.

The organization of UI Controls and Families, obviously, is up to you.

Usage of Families: an example

An example of Family can be, for instance, all the controls of a Mixer. When you define each single UI Control, you are asked to specify the Family they belong to. Then you can show, hide, move, process each single UI Control belonging to that Family in an extremely advanced manner.

on init 
	{...}
	create_family(MIXER_FAMILY, 0) 
	create_button(mute_btn, MIXER_FAMILY, ...)
	create_button(solo_btn, MIXER_FAMILY, ...)
	create_slider(volume, MIXER_FAMILY, ...)
	create_slider(panpot, MIXER_FAMILY, ...)
	{...}
end on

This script creates a Family called MIXER_FAMILY with ID 0. Then, it creates four UI Controls assigned to MIXER_FAMILY.

Now you can perform various actions over this Family. We are going to check out all of them in this section.

Additional notes on UI Controls management

Everytime a function regarding the GUI is called in on init callback, the values passed to the function override the default values.

For example:

on init
	create_family(FAMILY, 1)
	create_knob(knob, FAMILY, ...)
	shift_family(FAMILY, 60, 70)
end on

In this case, shift_family overrides the default values set in create_knob (10 and 15). If you call reset_pos or reset_family_pos, the knob position will be set at X=60 and Y=70. If you call set_pos or reset_family_pos from a different callback, obviously, the default value is not overriden.

Clone this wiki locally