Changes between Version 3 and Version 4 of UI


Ignore:
Timestamp:
05/31/13 18:21:40 (12 years ago)
Author:
epyon
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • UI

    v3 v4  
    22
    33UI elements can be both loaded from Lua definitions or created on the fly.
     4
     5{{{#!lua
     6-- some_name.ui.lua
     7
     8register_ui "mywindow"
     9{
     10  element "window" { -- id will be mywindow.window
     11    position  = { 10, 10 },
     12    dimension = { 400, 100 },
     13    class     = "mywindow", -- style class
     14    element { -- unnamed element (mywindow.window.1)
     15      position = { 10, 10 }, -- relative, dimension auto
     16      text = "Hello world! Fine day?",
     17    },
     18    button "yes" { -- subelement, will be mywindow.window.yes
     19      rposition  = { 0.1, 0.8 }, -- relative positioning
     20      rdimension = { 0.3, nil }, -- just one value, other is nil
     21      dimension  = { nil, 20 }, -- other value not relative
     22      text       = "Yes!",
     23    },
     24    button "no" { --
     25      rposition  = { 0.1, 0.8 }, -- relative positioning
     26      rdimension = { 0.3 }, -- just one value, other is nil hence can be ommited
     27      dimension  = { nil, 20 }, -- other value not relative
     28      text       = "No :(",
     29    },
     30  },
     31}
     32
     33}}}
     34
     35{{{
     36-- some_script.lua
     37
     38ui_element = ui.create( "mywindow" );
     39local result
     40ui_element:find("yes").on_click = function(self) result = true;  self:destroy() end
     41ui_element:find("no").on_click  = function(self) result = false; self:destroy() end
     42ui:run_modal( ui_element )
     43
     44}}}
     45
    446
    547== UI styles ==