mirror of
https://github.com/keharriso/love-nuklear.git
synced 2025-09-10 16:17:47 -04:00
Add closure alternatives to begin/end pairs
This commit is contained in:
parent
bb3ffeb957
commit
976ff9f63b
3 changed files with 413 additions and 52 deletions
51
example/closure.lua
Normal file
51
example/closure.lua
Normal file
|
@ -0,0 +1,51 @@
|
|||
-- Show off the optional closure-oriented versions of basic functions
|
||||
|
||||
local function menu(ui)
|
||||
ui:layoutRow('dynamic', 30, 2)
|
||||
ui:menu('Menu A', nil, 100, 200, function ()
|
||||
ui:layoutRow('dynamic', 30, 1)
|
||||
if ui:menuItem('Item 1') then
|
||||
print 'Closure: Item 1'
|
||||
end
|
||||
if ui:menuItem('Item 2') then
|
||||
print 'Closure: Item 2'
|
||||
end
|
||||
end)
|
||||
ui:menu('Menu B', nil, 100, 200, function ()
|
||||
ui:layoutRow('dynamic', 30, 1)
|
||||
if ui:menuItem('Item 3') then
|
||||
print 'Closure: Item 3'
|
||||
end
|
||||
if ui:menuItem('Item 4') then
|
||||
print 'Closure: Item 4'
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
local comboText = 'Combo 1'
|
||||
|
||||
function combo(ui)
|
||||
ui:layoutRow('dynamic', 30, 1)
|
||||
if ui:comboboxItem('Combo 1') then
|
||||
print 'Closure: Combo 1'
|
||||
comboText = 'Combo 1'
|
||||
end
|
||||
if ui:comboboxItem('Combo 2') then
|
||||
print 'Closure: Combo 2'
|
||||
comboText = 'Combo 2'
|
||||
end
|
||||
if ui:comboboxItem('Combo 3') then
|
||||
print 'Closure: Combo 3'
|
||||
comboText = 'Combo 3'
|
||||
end
|
||||
end
|
||||
|
||||
local function window(ui)
|
||||
ui:menubar(menu)
|
||||
ui:layoutRow('dynamic', 30, 1)
|
||||
ui:combobox(comboText, combo)
|
||||
end
|
||||
|
||||
return function (ui)
|
||||
ui:window('Closure', 200, 200, 150, 120, {'title', 'movable', 'border'}, window)
|
||||
end
|
|
@ -3,6 +3,7 @@
|
|||
local nuklear = require 'nuklear'
|
||||
|
||||
local calculator = require 'calculator'
|
||||
local closure = require 'closure'
|
||||
local draw = require 'draw'
|
||||
local overview = require 'overview'
|
||||
local style = require 'style'
|
||||
|
@ -20,6 +21,7 @@ function love.update(dt)
|
|||
ui1:frameBegin()
|
||||
calculator(ui1)
|
||||
style(ui1)
|
||||
closure(ui1)
|
||||
overview(ui1)
|
||||
draw(ui1)
|
||||
template(ui1)
|
||||
|
@ -33,7 +35,7 @@ end
|
|||
function love.draw()
|
||||
ui1:draw()
|
||||
ui2:draw()
|
||||
love.graphics.print("Current FPS: "..tostring(love.timer.getFPS( )), 10, 10)
|
||||
love.graphics.print('Current FPS: '..tostring(love.timer.getFPS( )), 10, 10)
|
||||
end
|
||||
|
||||
local function input(name, ...)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue