Lokasenna GUI uses layers designated by "z".
Elements are assigned to a layer by setting the element's "z" value.
Lower "z" values are in front of (drawn later) than elements with higher "z" values.
A layer can have more than one element. Note: an element
that requires frequent redrawing should be on its own layer since all of
the elements sharing that layer are redrawn.
GUI.elms = { } -- holds all GUI elements
GUI.elms_list = { } -- holds list of element names sorted by z layer. keys are z layers; values are list of elements on each layer.
GUI.update_elms_list = function(init)
This function updates GUI.elm_list.
If init is true then it calls each element's init function (but it doesn't redraw them).
GUI.Init( ) calls:
gfx.init(GUI.name, GUI.w, GUI.h, GUI.dock or 0, GUI.x, GUI.y)
GUI.update_elms_list(true)
Iterates GUI.elms. When true calls GUI.elms[key]:init()
GUI.Main( ) calls: (see note1)
GUI.Main_Update_State( ) checks if script window w or h changed:
Yes: updates GUI.cur_w and GUI.cur_h, sets GUI.resized = true, and calls GUI.onresize().
No: sets GUI.resized = false
GUI.Main_Update_Elms( )
Iterates GUI.elms_list in reverse z-order and updates each non-hidden, non-frozen element.
Runs user function if defined (see Note 2).
GUI.update_elms_list( )
Rebuilds GUI.elms_list, but it doesn't initialize elements.
GUI.Main_Draw( )
if need_redraw or global_redraw then:
iterates GUI.elms_list from highest z to lowest
calls GUI.elms[elm]:draw( ) for elements on non-hidden layers.
Note 1:
GUI.Main is run on every update loop of the GUI script.
GUI.Main calls GUI.Main_Update_State( ) which calls reaper.defer(GUI.Main)
<Line 372 of core.lua>.
Note 2:
If defining a user function you can name it however you want.
dh_Toolkit scripts call the user function "dhMain". It is called by:
Anything you would put inside a reaper.defer( ) loop should go here.