Page 1 of 1

Creating tabs in Lua.

PostPosted: Thu Jan 16, 2014 9:39 pm
by stratified
Hi All,

From release 1.27, you can have tabs in your lua user interface. Tabs are similar to groups or panel stacks. They take a list of children, one for each tab. The tab component is resized to fit it's largest child component. Here's an example script:

Code: Select all
--
-- Tabbed component creation example
--


local button = octane.gui.create
{
    type   = octane.gui.componentType.BUTTON,
    width  = 100,
    height = 24,
    x      = 20,
    y      = 20,
    text   = "Button",
}

local table = octane.gui.create
{
    type   = octane.gui.componentType.TABLE,
    header = { "animal", "friendly" },
    items  =
    {
        "cat"     , "no" ,
        "dog"     , "yes",
        "dolphin" , "yes",
        "shark"   , "no" ,
        "tiger"   , "no" ,
        "bear"    , "no" ,
        "seal"    , "yes",
        "horse"   , "yes",
        "eagle"   , "no" ,
        "zebra"   , "no" ,
        "elephant", "no" ,
        "hippo"   , "no" ,
    }
    ,
    widths      = { 200, 200},
    height      = 400,
    selectedRow = 2,
}

local tabs = octane.gui.create
{
    type       = octane.gui.componentType.TABS,
    children   = { table, button },         -- components, 1 for each tab
    header     = { "Animals", "Button" },   -- text to appear on each tab
    currentTab = 1,                         -- the initially selected tab
    callback   = function(comp, evt) print("Current tab: ", comp:getProperties().currentTab) end
}


local window = octane.gui.create
{
    type     = octane.gui.componentType.WINDOW,
    width    = tabs:getProperties().width,
    height   = tabs:getProperties().height,
    children = { tabs },
    text     = "Tabs Example",
}

window:showWindow()


Here's how it looks:

tabs-example.png
tab component example


cheers,
Thomas

Re: Creating tabs in Lua.

PostPosted: Thu Jan 16, 2014 9:48 pm
by grimm
Awesome Thomas! :D I was going to ask you about these but I didn't want to put too much on you plate, and there you go and beat me to it. :twisted:

Jason

Re: Creating tabs in Lua.

PostPosted: Thu Jan 16, 2014 9:52 pm
by stratified
grimm wrote:Awesome Thomas! :D I was going to ask you about these but I didn't want to put too much on you plate, and there you go and beat me to it. :twisted:

Jason


They come in very handy when trying to structure more complex UIs. Having a single huge window doesn't scale.

cheers,
Thomas

Re: Creating tabs in Lua.

PostPosted: Fri Jan 17, 2014 6:36 am
by Tugpsx
Sweet, it only gets better.