Creating tabs in Lua.

Forums: Creating tabs in Lua.
Forum for OctaneRender Lua scripting examples, discussion and support.

Creating tabs in Lua.

Postby stratified » Thu Jan 16, 2014 9:39 pm

stratified Thu Jan 16, 2014 9:39 pm
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
User avatar
stratified
OctaneRender Team
OctaneRender Team
 
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Re: Creating tabs in Lua.

Postby grimm » Thu Jan 16, 2014 9:48 pm

grimm Thu Jan 16, 2014 9:48 pm
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
Linux Mint 20 x64 | Nvidia GTX 980 4GB (displays) RTX 2070 8GB| Intel I7 5820K 3.8 Ghz | 32Gb Memory | Nvidia Driver 460.56
User avatar
grimm
Licensed Customer
Licensed Customer
 
Posts: 1321
Joined: Wed Jan 27, 2010 8:11 pm
Location: Spokane, Washington, USA

Re: Creating tabs in Lua.

Postby stratified » Thu Jan 16, 2014 9:52 pm

stratified Thu Jan 16, 2014 9:52 pm
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
User avatar
stratified
OctaneRender Team
OctaneRender Team
 
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Re: Creating tabs in Lua.

Postby Tugpsx » Fri Jan 17, 2014 6:36 am

Tugpsx Fri Jan 17, 2014 6:36 am
Sweet, it only gets better.
Dell Win Vista 32 | NVIDIA Quadro NVS135M | Core2 Duo T7500 2.20GHz | 4GB
CyberPowerPC Win 7 64| NVIDIA GTX660Ti (3G) GTX480(1.5G) | 16GB
Tugpsx
Licensed Customer
Licensed Customer
 
Posts: 1145
Joined: Thu Feb 04, 2010 8:04 pm
Location: Chicago, IL

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 5 guests

Tue Apr 16, 2024 9:17 am [ UTC ]