Skip to content

2.00 Tabs

Lokasenna edited this page Jun 24, 2018 · 1 revision

Provides a set of tabs that swap between different sets of z-layers, allowing for a tabbed view.

Tabs

Parameters

z, x, y, tab_w, tab_h, opts[, pad]

Required

z               Element depth, used for hiding and disabling layers. 1 is the highest.
x, y            Coordinates of top-left corner
tab_w, tab_h    Size of individual tabs
opts            Comma-separated string, or a table, of tab names

Optional

pad             Padding between tabs. Defaults to 8.

Additional parameters

w, h            Overall width and height of the tab strip. These are determined
                automatically based on the number of tabs and their size.
                
bg              Color to be drawn underneath the tabs. Defaults to "elm_bg".
col_txt         Text color. Defaults to "txt".
col_tab_a       Active tab color. Defaults to "wnd_bg"
col_tab_b       Inactive tab color. Defaults to "tab_bg"
font_a          Active tab font. Defaults to 3.
font_b          Inactive tab font. Defaults to 4.
fullwidth       Boolean. Extends the tab background to the right edge of the script window.
                Defaults to true.    

state           The current tab. Numbered from left to right, starting at 1.

Methods

GUI.Val("my_tabs")

Returns the active tab. Numbered from 1.

GUI.Val("my_tabs", 2)

Sets the active tab. Numbered from 1.

:update_sets(init)

Assigns the z layers that are shown for each tab. Sets are defined thusly:
(Only needs to be done once, at startup)

			GUI.elms.my_tabs:update_sets(
				{
                z-layers shown on that tab
				   tab     /
				  /       |
				 |        |
				 v        v 
				[1] = {2, 3, 4}, 
				[2] = {2, 5, 6}, 
				[3] = {2, 7, 8},
				}
			)

update_sets() will be called automatically when a tab is clicked, or if a new tab is set using GUI.Val.

  • z-layers not included in any set (1, in the example above) will always be active unless frozen/hidden manually
  • z-layers in multiple sets (2, above) will be active on all of those tabs
  • Elements can have their z changed at any time - handy if you want to hide specific bits rather than the whole layer. Make sure to redraw any appropriate layers afterward
  • Likewise, the sets can be changed atany time by calling update_sets() with a new layer table

Notes