mirror of
https://github.com/keharriso/love-nuklear.git
synced 2025-09-10 16:17:47 -04:00
Change from snake_case to camelCase for consistency with LOVE
This commit is contained in:
parent
c676186163
commit
6f9a955946
7 changed files with 540 additions and 558 deletions
15
README.md
15
README.md
|
@ -17,17 +17,17 @@ end
|
|||
local combo = {value = 1, items = {'A', 'B', 'C'}}
|
||||
|
||||
function love.update(dt)
|
||||
nk.frame_begin()
|
||||
if nk.window_begin('Simple Example', 100, 100, 200, 160,
|
||||
nk.frameBegin()
|
||||
if nk.windowBegin('Simple Example', 100, 100, 200, 160,
|
||||
'border', 'title', 'movable') then
|
||||
nk.layout_row('dynamic', 30, 1)
|
||||
nk.layoutRow('dynamic', 30, 1)
|
||||
nk.label('Hello, world!')
|
||||
nk.layout_row('dynamic', 30, 2)
|
||||
nk.layoutRow('dynamic', 30, 2)
|
||||
nk.label('Combo box:')
|
||||
if nk.combobox(combo, combo.items) then
|
||||
print('Combo!', combo.items[combo.value])
|
||||
end
|
||||
nk.layout_row('dynamic', 30, 3)
|
||||
nk.layoutRow('dynamic', 30, 3)
|
||||
nk.label('Buttons:')
|
||||
if nk.button('Sample') then
|
||||
print('Sample!')
|
||||
|
@ -36,8 +36,8 @@ function love.update(dt)
|
|||
print('Button!')
|
||||
end
|
||||
end
|
||||
nk.window_end()
|
||||
nk.frame_end()
|
||||
nk.windowEnd()
|
||||
nk.frameEnd()
|
||||
end
|
||||
|
||||
function love.draw()
|
||||
|
@ -91,4 +91,3 @@ A complete description of all functions and style properties, alongside addition
|
|||
## License
|
||||
|
||||
Copyright (c) 2016 Kevin Harrison, released under the MIT License (see LICENSE for details).
|
||||
|
||||
|
|
|
@ -61,10 +61,10 @@ local function display()
|
|||
end
|
||||
|
||||
return function ()
|
||||
if nk.window_begin('Calculator', 50, 50, 180, 250, 'border', 'movable', 'title') then
|
||||
nk.layout_row('dynamic', 35, 1)
|
||||
if nk.windowBegin('Calculator', 50, 50, 180, 250, 'border', 'movable', 'title') then
|
||||
nk.layoutRow('dynamic', 35, 1)
|
||||
nk.label(display(), 'right')
|
||||
nk.layout_row('dynamic', 35, 4)
|
||||
nk.layoutRow('dynamic', 35, 4)
|
||||
for i=1,16 do
|
||||
if i >= 13 and i < 16 then
|
||||
if i == 13 then
|
||||
|
@ -91,5 +91,5 @@ return function ()
|
|||
end
|
||||
end
|
||||
end
|
||||
nk.window_end()
|
||||
nk.windowEnd()
|
||||
end
|
||||
|
|
|
@ -12,12 +12,12 @@ function love.load()
|
|||
end
|
||||
|
||||
function love.update(dt)
|
||||
nk.frame_begin()
|
||||
nk.frameBegin()
|
||||
calculator()
|
||||
style()
|
||||
overview()
|
||||
skin()
|
||||
nk.frame_end()
|
||||
nk.frameEnd()
|
||||
end
|
||||
|
||||
function love.draw()
|
||||
|
|
|
@ -15,34 +15,34 @@ local edit = {value = 'Edit text'}
|
|||
local comboA = {value = 1, items = {'A', 'B', 'C'}}
|
||||
|
||||
return function ()
|
||||
if nk.window_begin('Overview', 100, 100, 600, 450, 'border', 'movable', 'title') then
|
||||
nk.menubar_begin()
|
||||
nk.layout_row('dynamic', 30, 1)
|
||||
if nk.menu_begin('Menu', nil, 120, 90) then
|
||||
nk.layout_row('dynamic', 40, 1)
|
||||
nk.menu_item('Item A')
|
||||
nk.menu_item('Item B')
|
||||
nk.menu_item('Item C')
|
||||
nk.menu_end()
|
||||
if nk.windowBegin('Overview', 100, 100, 600, 450, 'border', 'movable', 'title') then
|
||||
nk.menubarBegin()
|
||||
nk.layoutRow('dynamic', 30, 1)
|
||||
if nk.menuBegin('Menu', nil, 120, 90) then
|
||||
nk.layoutRow('dynamic', 40, 1)
|
||||
nk.menuItem('Item A')
|
||||
nk.menuItem('Item B')
|
||||
nk.menuItem('Item C')
|
||||
nk.menuEnd()
|
||||
end
|
||||
nk.menubar_end()
|
||||
nk.layout_row('dynamic', 400, 3)
|
||||
nk.group_begin('Group 1', 'border')
|
||||
nk.layout_row('dynamic', 30, 1)
|
||||
nk.menubarEnd()
|
||||
nk.layoutRow('dynamic', 400, 3)
|
||||
nk.groupBegin('Group 1', 'border')
|
||||
nk.layoutRow('dynamic', 30, 1)
|
||||
nk.label('Left label')
|
||||
nk.label('Centered label', 'centered')
|
||||
nk.label('Right label', 'right')
|
||||
nk.label('Colored label', 'left', '#ff0000')
|
||||
if nk.tree_push('tab', 'Tree Tab') then
|
||||
if nk.tree_push('node', 'Tree Node 1') then
|
||||
if nk.treePush('tab', 'Tree Tab') then
|
||||
if nk.treePush('node', 'Tree Node 1') then
|
||||
nk.label('Label 1')
|
||||
nk.tree_pop()
|
||||
nk.treePop()
|
||||
end
|
||||
if nk.tree_push('node', 'Tree Node 2') then
|
||||
if nk.treePush('node', 'Tree Node 2') then
|
||||
nk.label('Label 2')
|
||||
nk.tree_pop()
|
||||
nk.treePop()
|
||||
end
|
||||
nk.tree_pop()
|
||||
nk.treePop()
|
||||
end
|
||||
nk.spacing(1)
|
||||
if nk.button('Button') then
|
||||
|
@ -51,56 +51,56 @@ return function ()
|
|||
nk.spacing(1)
|
||||
nk.checkbox('Checkbox A', checkA)
|
||||
nk.checkbox('Checkbox B', checkB)
|
||||
nk.group_end()
|
||||
nk.group_begin('Group 2', 'border')
|
||||
nk.layout_row('dynamic', 30, 1)
|
||||
nk.groupEnd()
|
||||
nk.groupBegin('Group 2', 'border')
|
||||
nk.layoutRow('dynamic', 30, 1)
|
||||
nk.label('Radio buttons:')
|
||||
nk.layout_row('dynamic', 30, 3)
|
||||
nk.layoutRow('dynamic', 30, 3)
|
||||
nk.radio('A', radio)
|
||||
nk.radio('B', radio)
|
||||
nk.radio('C', radio)
|
||||
nk.layout_row('dynamic', 30, 1)
|
||||
nk.layoutRow('dynamic', 30, 1)
|
||||
nk.selectable('Selectable A', selectA)
|
||||
nk.selectable('Selectable B', selectB)
|
||||
nk.layout_row('dynamic', 30, {.35, .65})
|
||||
nk.layoutRow('dynamic', 30, {.35, .65})
|
||||
nk.label('Slider:')
|
||||
nk.slider(0, slider, 1, 0.05)
|
||||
nk.label('Progress:')
|
||||
nk.progress(progress, 10, true)
|
||||
nk.layout_row('dynamic', 30, 2)
|
||||
nk.layoutRow('dynamic', 30, 2)
|
||||
nk.spacing(2)
|
||||
nk.label('Color picker:')
|
||||
nk.button(nil, colorPicker.value)
|
||||
nk.layout_row('dynamic', 90, 1)
|
||||
nk.color_picker(colorPicker)
|
||||
nk.group_end()
|
||||
nk.group_begin('Group 3', 'border')
|
||||
nk.layout_row('dynamic', 30, 1)
|
||||
nk.layoutRow('dynamic', 90, 1)
|
||||
nk.colorPicker(colorPicker)
|
||||
nk.groupEnd()
|
||||
nk.groupBegin('Group 3', 'border')
|
||||
nk.layoutRow('dynamic', 30, 1)
|
||||
nk.property('Property', 0, property, 10, 0.25, 0.05)
|
||||
nk.spacing(1)
|
||||
nk.label('Edit:')
|
||||
nk.layout_row('dynamic', 90, 1)
|
||||
nk.layoutRow('dynamic', 90, 1)
|
||||
nk.edit('box', edit)
|
||||
nk.layout_row('dynamic', 5, 1)
|
||||
nk.layoutRow('dynamic', 5, 1)
|
||||
nk.spacing(1)
|
||||
nk.layout_row('dynamic', 30, 1)
|
||||
nk.layoutRow('dynamic', 30, 1)
|
||||
nk.label('Combobox:')
|
||||
nk.combobox(comboA, comboA.items)
|
||||
nk.layout_row('dynamic', 5, 1)
|
||||
nk.layoutRow('dynamic', 5, 1)
|
||||
nk.spacing(1)
|
||||
nk.layout_row('dynamic', 30, 1)
|
||||
if nk.widget_is_hovered() then
|
||||
nk.layoutRow('dynamic', 30, 1)
|
||||
if nk.widgetIsHovered() then
|
||||
nk.tooltip('Test tooltip')
|
||||
end
|
||||
local x, y, w, h = nk.widget_bounds()
|
||||
if nk.contextual_begin(100, 100, x, y, w, h) then
|
||||
nk.layout_row('dynamic', 30, 1)
|
||||
nk.contextual_item('Item A')
|
||||
nk.contextual_item('Item B')
|
||||
nk.contextual_end()
|
||||
local x, y, w, h = nk.widgetBounds()
|
||||
if nk.contextualBegin(100, 100, x, y, w, h) then
|
||||
nk.layoutRow('dynamic', 30, 1)
|
||||
nk.contextualItem('Item A')
|
||||
nk.contextualItem('Item B')
|
||||
nk.contextualEnd()
|
||||
end
|
||||
nk.label('Contextual (Right click me)')
|
||||
nk.group_end()
|
||||
nk.groupEnd()
|
||||
end
|
||||
nk.window_end()
|
||||
nk.windowEnd()
|
||||
end
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
local nk = require 'nuklear'
|
||||
|
||||
local window_header = love.graphics.newImage 'skin/window_header.png'
|
||||
local checkbox_skin = love.graphics.newImage 'skin/checkbox_false.png'
|
||||
local checkbox_check = love.graphics.newImage 'skin/checkbox_true.png'
|
||||
local windowHeader = love.graphics.newImage 'skin/window_header.png'
|
||||
local checkboxSkin = love.graphics.newImage 'skin/checkbox_false.png'
|
||||
local checkboxCheck = love.graphics.newImage 'skin/checkbox_true.png'
|
||||
|
||||
local style = {
|
||||
['text'] = {
|
||||
|
@ -18,11 +18,11 @@ local style = {
|
|||
['text active'] = '#ffffff'
|
||||
},
|
||||
['checkbox'] = {
|
||||
['normal'] = checkbox_skin,
|
||||
['hover'] = checkbox_skin,
|
||||
['active'] = checkbox_skin,
|
||||
['cursor normal'] = checkbox_check,
|
||||
['cursor hover'] = checkbox_check,
|
||||
['normal'] = checkboxSkin,
|
||||
['hover'] = checkboxSkin,
|
||||
['active'] = checkboxSkin,
|
||||
['cursor normal'] = checkboxCheck,
|
||||
['cursor hover'] = checkboxCheck,
|
||||
['text normal'] = '#000000',
|
||||
['text hover'] = '#000000',
|
||||
['text active'] = '#000000',
|
||||
|
@ -30,9 +30,9 @@ local style = {
|
|||
},
|
||||
['window'] = {
|
||||
['header'] = {
|
||||
['normal'] = window_header,
|
||||
['hover'] = window_header,
|
||||
['active'] = window_header,
|
||||
['normal'] = windowHeader,
|
||||
['hover'] = windowHeader,
|
||||
['active'] = windowHeader,
|
||||
['label normal'] = '#000000',
|
||||
['label hover'] = '#000000',
|
||||
['label active'] = '#000000',
|
||||
|
@ -46,17 +46,17 @@ local style = {
|
|||
local check = {value = false}
|
||||
|
||||
return function ()
|
||||
nk.style_push(style)
|
||||
if nk.window_begin('Skin Example', 200, 200, 350, 200, 'title', 'movable') then
|
||||
nk.layout_space_begin('dynamic', 150, 3)
|
||||
nk.layout_space_push(0.14, 0.15, 0.72, 0.3)
|
||||
nk.stylePush(style)
|
||||
if nk.windowBegin('Skin Example', 200, 200, 350, 200, 'title', 'movable') then
|
||||
nk.layoutSpaceBegin('dynamic', 150, 3)
|
||||
nk.layoutSpacePush(0.14, 0.15, 0.72, 0.3)
|
||||
nk.label('Skin example! Styles can change skins, colors, padding, font, and more.', 'wrap')
|
||||
nk.layout_space_push(0.2, 0.55, 0.2, 0.2)
|
||||
nk.layoutSpacePush(0.2, 0.55, 0.2, 0.2)
|
||||
nk.button('Button')
|
||||
nk.layout_space_push(0.55, 0.55, 0.3, 0.2)
|
||||
nk.layoutSpacePush(0.55, 0.55, 0.3, 0.2)
|
||||
nk.checkbox('Checkbox', check)
|
||||
nk.layout_space_end()
|
||||
nk.layoutSpaceEnd()
|
||||
end
|
||||
nk.window_end()
|
||||
nk.style_pop()
|
||||
nk.windowEnd()
|
||||
nk.stylePop()
|
||||
end
|
||||
|
|
|
@ -33,36 +33,36 @@ local colors = {
|
|||
['tab header'] = '#282828'
|
||||
}
|
||||
|
||||
local color_names = {}
|
||||
local colorNames = {}
|
||||
|
||||
for name,_ in pairs(colors) do
|
||||
color_names[#color_names + 1] = name
|
||||
colorNames[#colorNames + 1] = name
|
||||
end
|
||||
|
||||
table.sort(color_names)
|
||||
table.sort(colorNames)
|
||||
|
||||
return function ()
|
||||
nk.style_load_colors(colors)
|
||||
nk.window_begin('Style', 400, 50, 350, 450, 'border', 'movable', 'title', 'scrollbar')
|
||||
nk.layout_row('dynamic', 25, 2)
|
||||
for _,name in ipairs(color_names) do
|
||||
nk.styleLoadColors(colors)
|
||||
nk.windowBegin('Style', 400, 50, 350, 450, 'border', 'movable', 'title', 'scrollbar')
|
||||
nk.layoutRow('dynamic', 25, 2)
|
||||
for _,name in ipairs(colorNames) do
|
||||
nk.label(name..':')
|
||||
local color = colors[name]
|
||||
if nk.combobox_begin(nil, color, 200, 200) then
|
||||
nk.layout_row('dynamic', 90, 1)
|
||||
color = nk.color_picker(color)
|
||||
if nk.comboboxBegin(nil, color, 200, 200) then
|
||||
nk.layoutRow('dynamic', 90, 1)
|
||||
color = nk.colorPicker(color)
|
||||
colors[name] = color
|
||||
local r, g, b = nk.color_parse_rgba(color)
|
||||
nk.layout_row('dynamic', 25, {.25, .75})
|
||||
local r, g, b = nk.colorParseRGBA(color)
|
||||
nk.layoutRow('dynamic', 25, {.25, .75})
|
||||
nk.label('R: '..r)
|
||||
r = nk.slider(0, r, 255, 1)
|
||||
nk.label('G: '..g)
|
||||
g = nk.slider(0, g, 255, 1)
|
||||
nk.label('B: '..b)
|
||||
b = nk.slider(0, b, 255, 1)
|
||||
colors[name] = nk.color_rgba(r, g, b)
|
||||
nk.combobox_end()
|
||||
colors[name] = nk.colorRGBA(r, g, b)
|
||||
nk.comboboxEnd()
|
||||
end
|
||||
end
|
||||
nk.window_end()
|
||||
nk.windowEnd()
|
||||
end
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue