Change from snake_case to camelCase for consistency with LOVE

This commit is contained in:
Kevin Harrison 2016-12-03 13:58:58 -05:00
parent c676186163
commit 6f9a955946
7 changed files with 540 additions and 558 deletions

View file

@ -17,17 +17,17 @@ end
local combo = {value = 1, items = {'A', 'B', 'C'}} local combo = {value = 1, items = {'A', 'B', 'C'}}
function love.update(dt) function love.update(dt)
nk.frame_begin() nk.frameBegin()
if nk.window_begin('Simple Example', 100, 100, 200, 160, if nk.windowBegin('Simple Example', 100, 100, 200, 160,
'border', 'title', 'movable') then 'border', 'title', 'movable') then
nk.layout_row('dynamic', 30, 1) nk.layoutRow('dynamic', 30, 1)
nk.label('Hello, world!') nk.label('Hello, world!')
nk.layout_row('dynamic', 30, 2) nk.layoutRow('dynamic', 30, 2)
nk.label('Combo box:') nk.label('Combo box:')
if nk.combobox(combo, combo.items) then if nk.combobox(combo, combo.items) then
print('Combo!', combo.items[combo.value]) print('Combo!', combo.items[combo.value])
end end
nk.layout_row('dynamic', 30, 3) nk.layoutRow('dynamic', 30, 3)
nk.label('Buttons:') nk.label('Buttons:')
if nk.button('Sample') then if nk.button('Sample') then
print('Sample!') print('Sample!')
@ -36,8 +36,8 @@ function love.update(dt)
print('Button!') print('Button!')
end end
end end
nk.window_end() nk.windowEnd()
nk.frame_end() nk.frameEnd()
end end
function love.draw() function love.draw()
@ -91,4 +91,3 @@ A complete description of all functions and style properties, alongside addition
## License ## License
Copyright (c) 2016 Kevin Harrison, released under the MIT License (see LICENSE for details). Copyright (c) 2016 Kevin Harrison, released under the MIT License (see LICENSE for details).

View file

@ -61,10 +61,10 @@ local function display()
end end
return function () return function ()
if nk.window_begin('Calculator', 50, 50, 180, 250, 'border', 'movable', 'title') then if nk.windowBegin('Calculator', 50, 50, 180, 250, 'border', 'movable', 'title') then
nk.layout_row('dynamic', 35, 1) nk.layoutRow('dynamic', 35, 1)
nk.label(display(), 'right') nk.label(display(), 'right')
nk.layout_row('dynamic', 35, 4) nk.layoutRow('dynamic', 35, 4)
for i=1,16 do for i=1,16 do
if i >= 13 and i < 16 then if i >= 13 and i < 16 then
if i == 13 then if i == 13 then
@ -91,5 +91,5 @@ return function ()
end end
end end
end end
nk.window_end() nk.windowEnd()
end end

View file

@ -12,12 +12,12 @@ function love.load()
end end
function love.update(dt) function love.update(dt)
nk.frame_begin() nk.frameBegin()
calculator() calculator()
style() style()
overview() overview()
skin() skin()
nk.frame_end() nk.frameEnd()
end end
function love.draw() function love.draw()

View file

@ -15,34 +15,34 @@ local edit = {value = 'Edit text'}
local comboA = {value = 1, items = {'A', 'B', 'C'}} local comboA = {value = 1, items = {'A', 'B', 'C'}}
return function () return function ()
if nk.window_begin('Overview', 100, 100, 600, 450, 'border', 'movable', 'title') then if nk.windowBegin('Overview', 100, 100, 600, 450, 'border', 'movable', 'title') then
nk.menubar_begin() nk.menubarBegin()
nk.layout_row('dynamic', 30, 1) nk.layoutRow('dynamic', 30, 1)
if nk.menu_begin('Menu', nil, 120, 90) then if nk.menuBegin('Menu', nil, 120, 90) then
nk.layout_row('dynamic', 40, 1) nk.layoutRow('dynamic', 40, 1)
nk.menu_item('Item A') nk.menuItem('Item A')
nk.menu_item('Item B') nk.menuItem('Item B')
nk.menu_item('Item C') nk.menuItem('Item C')
nk.menu_end() nk.menuEnd()
end end
nk.menubar_end() nk.menubarEnd()
nk.layout_row('dynamic', 400, 3) nk.layoutRow('dynamic', 400, 3)
nk.group_begin('Group 1', 'border') nk.groupBegin('Group 1', 'border')
nk.layout_row('dynamic', 30, 1) nk.layoutRow('dynamic', 30, 1)
nk.label('Left label') nk.label('Left label')
nk.label('Centered label', 'centered') nk.label('Centered label', 'centered')
nk.label('Right label', 'right') nk.label('Right label', 'right')
nk.label('Colored label', 'left', '#ff0000') nk.label('Colored label', 'left', '#ff0000')
if nk.tree_push('tab', 'Tree Tab') then if nk.treePush('tab', 'Tree Tab') then
if nk.tree_push('node', 'Tree Node 1') then if nk.treePush('node', 'Tree Node 1') then
nk.label('Label 1') nk.label('Label 1')
nk.tree_pop() nk.treePop()
end end
if nk.tree_push('node', 'Tree Node 2') then if nk.treePush('node', 'Tree Node 2') then
nk.label('Label 2') nk.label('Label 2')
nk.tree_pop() nk.treePop()
end end
nk.tree_pop() nk.treePop()
end end
nk.spacing(1) nk.spacing(1)
if nk.button('Button') then if nk.button('Button') then
@ -51,56 +51,56 @@ return function ()
nk.spacing(1) nk.spacing(1)
nk.checkbox('Checkbox A', checkA) nk.checkbox('Checkbox A', checkA)
nk.checkbox('Checkbox B', checkB) nk.checkbox('Checkbox B', checkB)
nk.group_end() nk.groupEnd()
nk.group_begin('Group 2', 'border') nk.groupBegin('Group 2', 'border')
nk.layout_row('dynamic', 30, 1) nk.layoutRow('dynamic', 30, 1)
nk.label('Radio buttons:') nk.label('Radio buttons:')
nk.layout_row('dynamic', 30, 3) nk.layoutRow('dynamic', 30, 3)
nk.radio('A', radio) nk.radio('A', radio)
nk.radio('B', radio) nk.radio('B', radio)
nk.radio('C', radio) nk.radio('C', radio)
nk.layout_row('dynamic', 30, 1) nk.layoutRow('dynamic', 30, 1)
nk.selectable('Selectable A', selectA) nk.selectable('Selectable A', selectA)
nk.selectable('Selectable B', selectB) nk.selectable('Selectable B', selectB)
nk.layout_row('dynamic', 30, {.35, .65}) nk.layoutRow('dynamic', 30, {.35, .65})
nk.label('Slider:') nk.label('Slider:')
nk.slider(0, slider, 1, 0.05) nk.slider(0, slider, 1, 0.05)
nk.label('Progress:') nk.label('Progress:')
nk.progress(progress, 10, true) nk.progress(progress, 10, true)
nk.layout_row('dynamic', 30, 2) nk.layoutRow('dynamic', 30, 2)
nk.spacing(2) nk.spacing(2)
nk.label('Color picker:') nk.label('Color picker:')
nk.button(nil, colorPicker.value) nk.button(nil, colorPicker.value)
nk.layout_row('dynamic', 90, 1) nk.layoutRow('dynamic', 90, 1)
nk.color_picker(colorPicker) nk.colorPicker(colorPicker)
nk.group_end() nk.groupEnd()
nk.group_begin('Group 3', 'border') nk.groupBegin('Group 3', 'border')
nk.layout_row('dynamic', 30, 1) nk.layoutRow('dynamic', 30, 1)
nk.property('Property', 0, property, 10, 0.25, 0.05) nk.property('Property', 0, property, 10, 0.25, 0.05)
nk.spacing(1) nk.spacing(1)
nk.label('Edit:') nk.label('Edit:')
nk.layout_row('dynamic', 90, 1) nk.layoutRow('dynamic', 90, 1)
nk.edit('box', edit) nk.edit('box', edit)
nk.layout_row('dynamic', 5, 1) nk.layoutRow('dynamic', 5, 1)
nk.spacing(1) nk.spacing(1)
nk.layout_row('dynamic', 30, 1) nk.layoutRow('dynamic', 30, 1)
nk.label('Combobox:') nk.label('Combobox:')
nk.combobox(comboA, comboA.items) nk.combobox(comboA, comboA.items)
nk.layout_row('dynamic', 5, 1) nk.layoutRow('dynamic', 5, 1)
nk.spacing(1) nk.spacing(1)
nk.layout_row('dynamic', 30, 1) nk.layoutRow('dynamic', 30, 1)
if nk.widget_is_hovered() then if nk.widgetIsHovered() then
nk.tooltip('Test tooltip') nk.tooltip('Test tooltip')
end end
local x, y, w, h = nk.widget_bounds() local x, y, w, h = nk.widgetBounds()
if nk.contextual_begin(100, 100, x, y, w, h) then if nk.contextualBegin(100, 100, x, y, w, h) then
nk.layout_row('dynamic', 30, 1) nk.layoutRow('dynamic', 30, 1)
nk.contextual_item('Item A') nk.contextualItem('Item A')
nk.contextual_item('Item B') nk.contextualItem('Item B')
nk.contextual_end() nk.contextualEnd()
end end
nk.label('Contextual (Right click me)') nk.label('Contextual (Right click me)')
nk.group_end() nk.groupEnd()
end end
nk.window_end() nk.windowEnd()
end end

View file

@ -1,8 +1,8 @@
local nk = require 'nuklear' local nk = require 'nuklear'
local window_header = love.graphics.newImage 'skin/window_header.png' local windowHeader = love.graphics.newImage 'skin/window_header.png'
local checkbox_skin = love.graphics.newImage 'skin/checkbox_false.png' local checkboxSkin = love.graphics.newImage 'skin/checkbox_false.png'
local checkbox_check = love.graphics.newImage 'skin/checkbox_true.png' local checkboxCheck = love.graphics.newImage 'skin/checkbox_true.png'
local style = { local style = {
['text'] = { ['text'] = {
@ -18,11 +18,11 @@ local style = {
['text active'] = '#ffffff' ['text active'] = '#ffffff'
}, },
['checkbox'] = { ['checkbox'] = {
['normal'] = checkbox_skin, ['normal'] = checkboxSkin,
['hover'] = checkbox_skin, ['hover'] = checkboxSkin,
['active'] = checkbox_skin, ['active'] = checkboxSkin,
['cursor normal'] = checkbox_check, ['cursor normal'] = checkboxCheck,
['cursor hover'] = checkbox_check, ['cursor hover'] = checkboxCheck,
['text normal'] = '#000000', ['text normal'] = '#000000',
['text hover'] = '#000000', ['text hover'] = '#000000',
['text active'] = '#000000', ['text active'] = '#000000',
@ -30,9 +30,9 @@ local style = {
}, },
['window'] = { ['window'] = {
['header'] = { ['header'] = {
['normal'] = window_header, ['normal'] = windowHeader,
['hover'] = window_header, ['hover'] = windowHeader,
['active'] = window_header, ['active'] = windowHeader,
['label normal'] = '#000000', ['label normal'] = '#000000',
['label hover'] = '#000000', ['label hover'] = '#000000',
['label active'] = '#000000', ['label active'] = '#000000',
@ -46,17 +46,17 @@ local style = {
local check = {value = false} local check = {value = false}
return function () return function ()
nk.style_push(style) nk.stylePush(style)
if nk.window_begin('Skin Example', 200, 200, 350, 200, 'title', 'movable') then if nk.windowBegin('Skin Example', 200, 200, 350, 200, 'title', 'movable') then
nk.layout_space_begin('dynamic', 150, 3) nk.layoutSpaceBegin('dynamic', 150, 3)
nk.layout_space_push(0.14, 0.15, 0.72, 0.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.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.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.checkbox('Checkbox', check)
nk.layout_space_end() nk.layoutSpaceEnd()
end end
nk.window_end() nk.windowEnd()
nk.style_pop() nk.stylePop()
end end

View file

@ -33,36 +33,36 @@ local colors = {
['tab header'] = '#282828' ['tab header'] = '#282828'
} }
local color_names = {} local colorNames = {}
for name,_ in pairs(colors) do for name,_ in pairs(colors) do
color_names[#color_names + 1] = name colorNames[#colorNames + 1] = name
end end
table.sort(color_names) table.sort(colorNames)
return function () return function ()
nk.style_load_colors(colors) nk.styleLoadColors(colors)
nk.window_begin('Style', 400, 50, 350, 450, 'border', 'movable', 'title', 'scrollbar') nk.windowBegin('Style', 400, 50, 350, 450, 'border', 'movable', 'title', 'scrollbar')
nk.layout_row('dynamic', 25, 2) nk.layoutRow('dynamic', 25, 2)
for _,name in ipairs(color_names) do for _,name in ipairs(colorNames) do
nk.label(name..':') nk.label(name..':')
local color = colors[name] local color = colors[name]
if nk.combobox_begin(nil, color, 200, 200) then if nk.comboboxBegin(nil, color, 200, 200) then
nk.layout_row('dynamic', 90, 1) nk.layoutRow('dynamic', 90, 1)
color = nk.color_picker(color) color = nk.colorPicker(color)
colors[name] = color colors[name] = color
local r, g, b = nk.color_parse_rgba(color) local r, g, b = nk.colorParseRGBA(color)
nk.layout_row('dynamic', 25, {.25, .75}) nk.layoutRow('dynamic', 25, {.25, .75})
nk.label('R: '..r) nk.label('R: '..r)
r = nk.slider(0, r, 255, 1) r = nk.slider(0, r, 255, 1)
nk.label('G: '..g) nk.label('G: '..g)
g = nk.slider(0, g, 255, 1) g = nk.slider(0, g, 255, 1)
nk.label('B: '..b) nk.label('B: '..b)
b = nk.slider(0, b, 255, 1) b = nk.slider(0, b, 255, 1)
colors[name] = nk.color_rgba(r, g, b) colors[name] = nk.colorRGBA(r, g, b)
nk.combobox_end() nk.comboboxEnd()
end end
end end
nk.window_end() nk.windowEnd()
end end

File diff suppressed because it is too large Load diff