initial commit
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
[submodule "src/nuklear"]
|
||||
path = src/nuklear
|
||||
url = https://github.com/vurtun/nuklear.git
|
27
CMakeLists.txt
Normal file
|
@ -0,0 +1,27 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
PROJECT("love-nuklear" C)
|
||||
|
||||
SET(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
|
||||
FIND_PACKAGE(LuaJIT REQUIRED)
|
||||
|
||||
SET(LIB_NAME "nuklear")
|
||||
|
||||
ADD_LIBRARY(
|
||||
"${LIB_NAME}"
|
||||
MODULE
|
||||
src/nuklear/nuklear.h
|
||||
src/nuklear_love.c
|
||||
)
|
||||
|
||||
TARGET_INCLUDE_DIRECTORIES(
|
||||
"${LIB_NAME}"
|
||||
PUBLIC
|
||||
"${LUA_INCLUDE_DIR}"
|
||||
)
|
||||
|
||||
TARGET_LINK_LIBRARIES(
|
||||
"${LIB_NAME}"
|
||||
${LUA_LIBRARIES}
|
||||
)
|
||||
|
||||
SET_TARGET_PROPERTIES("${LIB_NAME}" PROPERTIES PREFIX "")
|
9
LICENSE
Normal file
|
@ -0,0 +1,9 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Kevin Harrison
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
94
README.md
Normal file
|
@ -0,0 +1,94 @@
|
|||
# LÖVE-Nuklear
|
||||
|
||||
[Nuklear](https://github.com/vurtun/nuklear) module for the [LÖVE](https://love2d.org/) game engine.
|
||||
|
||||
Provides a lightweight immediate mode GUI for LÖVE games.
|
||||
|
||||
## Example
|
||||
```lua
|
||||
-- Simple UI example.
|
||||
|
||||
local nk = require 'nuklear'
|
||||
|
||||
function love.load()
|
||||
nk.init()
|
||||
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,
|
||||
'border', 'title', 'movable') then
|
||||
nk.layout_row('dynamic', 30, 1)
|
||||
nk.label('Hello, world!')
|
||||
nk.layout_row('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.label('Buttons:')
|
||||
if nk.button('Sample') then
|
||||
print('Sample!')
|
||||
end
|
||||
if nk.button('Button') then
|
||||
print('Button!')
|
||||
end
|
||||
end
|
||||
nk.window_end()
|
||||
nk.frame_end()
|
||||
end
|
||||
|
||||
function love.draw()
|
||||
nk.draw()
|
||||
end
|
||||
|
||||
function love.keypressed(key, scancode, isrepeat)
|
||||
nk.keypressed(key, scancode, isrepeat)
|
||||
end
|
||||
|
||||
function love.keyreleased(key, scancode)
|
||||
nk.keyreleased(key, scancode)
|
||||
end
|
||||
|
||||
function love.mousepressed(x, y, button, istouch)
|
||||
nk.mousepressed(x, y, button, istouch)
|
||||
end
|
||||
|
||||
function love.mousereleased(x, y, button, istouch)
|
||||
nk.mousereleased(x, y, button, istouch)
|
||||
end
|
||||
|
||||
function love.mousemoved(x, y, dx, dy, istouch)
|
||||
nk.mousemoved(x, y, dx, dy, istouch)
|
||||
end
|
||||
|
||||
function love.textinput(text)
|
||||
nk.textinput(text)
|
||||
end
|
||||
|
||||
function love.wheelmoved(x, y)
|
||||
nk.wheelmoved(x, y)
|
||||
end
|
||||
```
|
||||
|
||||
## Building
|
||||
|
||||
Grab the code with:
|
||||
```sh
|
||||
$ git clone --recursive git@github.com:keharriso/love-nuklear.git
|
||||
```
|
||||
|
||||
Compile with CMake (I recommend using the MinGW generator on Windows). You'll need to tell CMake where to find the LuaJIT headers and binaries. The end result is a native Lua module.
|
||||
|
||||
|
||||
|
||||
## Documentation
|
||||
|
||||
A complete description of all functions and style properties, alongside additional examples, is available at the [LÖVE-Nuklear wiki](https://github.com/keharriso/love-nuklear/wiki).
|
||||
|
||||
## License
|
||||
|
||||
Copyright (c) 2016 Kevin Harrison, released under the MIT License (see LICENSE for details).
|
||||
|
63
cmake/FindLuaJIT.cmake
Normal file
|
@ -0,0 +1,63 @@
|
|||
# Locate LuaJIT library
|
||||
# This module defines
|
||||
# LUAJIT_FOUND, if false, do not try to link to Lua
|
||||
# LUA_LIBRARIES
|
||||
# LUA_INCLUDE_DIR, where to find lua.h
|
||||
# LUAJIT_VERSION_STRING, the version of Lua found (since CMake 2.8.8)
|
||||
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
find_path(LUA_INCLUDE_DIR luajit.h
|
||||
HINTS
|
||||
ENV LUA_DIR
|
||||
PATH_SUFFIXES include/luajit-2.0 include
|
||||
PATHS
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/sw # Fink
|
||||
/opt/local # DarwinPorts
|
||||
/opt/csw # Blastwave
|
||||
/opt
|
||||
)
|
||||
|
||||
find_library(LUA_LIBRARY
|
||||
NAMES luajit-5.1
|
||||
HINTS
|
||||
ENV LUA_DIR
|
||||
PATH_SUFFIXES lib
|
||||
PATHS
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/sw
|
||||
/opt/local
|
||||
/opt/csw
|
||||
/opt
|
||||
)
|
||||
|
||||
if(LUA_LIBRARY)
|
||||
# include the math library for Unix
|
||||
if(UNIX AND NOT APPLE AND NOT BEOS AND NOT HAIKU)
|
||||
find_library(LUA_MATH_LIBRARY m)
|
||||
set( LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}" CACHE STRING "Lua Libraries")
|
||||
# For Windows and Mac, don't need to explicitly include the math library
|
||||
else()
|
||||
set( LUA_LIBRARIES "${LUA_LIBRARY}" CACHE STRING "Lua Libraries")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/luajit.h")
|
||||
file(STRINGS "${LUA_INCLUDE_DIR}/luajit.h" luajit_version_str REGEX "^#define[ \t]+LUAJIT_VERSION[ \t]+\"LuaJIT .+\"")
|
||||
|
||||
string(REGEX REPLACE "^#define[ \t]+LUAJIT_VERSION[ \t]+\"LuaJIT ([^\"]+)\".*" "\\1" LUAJIT_VERSION_STRING "${luajit_version_str}")
|
||||
unset(luajit_version_str)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
# handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LuaJIT
|
||||
REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR
|
||||
VERSION_VAR LUAJIT_VERSION_STRING)
|
||||
|
||||
mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY)
|
95
example/calculator.lua
Normal file
|
@ -0,0 +1,95 @@
|
|||
-- Simple calculator example, adapted from the original nuklear demo.
|
||||
|
||||
local nk = require 'nuklear'
|
||||
|
||||
local ops = {'+', '-', '*', '/'}
|
||||
local a, b, op = '0'
|
||||
|
||||
local function clear()
|
||||
a, b, op = '0'
|
||||
end
|
||||
|
||||
local function digit(d)
|
||||
if op then
|
||||
if b == nil or b == '0' then
|
||||
b = d
|
||||
else
|
||||
b = b..d
|
||||
end
|
||||
else
|
||||
if a == '0' then
|
||||
a = d
|
||||
else
|
||||
a = a..d
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function decimal()
|
||||
if op then
|
||||
b = b or '0'
|
||||
b = b:find('.') and b or b..'.'
|
||||
else
|
||||
a = a:find('.') and a or a..'.'
|
||||
end
|
||||
end
|
||||
|
||||
local function equals()
|
||||
if not tonumber(b) then
|
||||
return
|
||||
end
|
||||
if op == '+' then
|
||||
a, b, op = tostring(tonumber(a) + tonumber(b))
|
||||
elseif op == '-' then
|
||||
a, b, op = tostring(tonumber(a) - tonumber(b))
|
||||
elseif op == '*' then
|
||||
a, b, op = tostring(tonumber(a) * tonumber(b))
|
||||
elseif op == '/' then
|
||||
a, b, op = tostring(tonumber(a) / tonumber(b))
|
||||
end
|
||||
end
|
||||
|
||||
local function operator(o)
|
||||
if op then
|
||||
equals()
|
||||
end
|
||||
op = o
|
||||
end
|
||||
|
||||
local function display()
|
||||
return b or a
|
||||
end
|
||||
|
||||
return function ()
|
||||
if nk.window_begin('Calculator', 50, 50, 180, 250, 'border', 'movable', 'title') then
|
||||
nk.layout_row('dynamic', 35, 1)
|
||||
nk.label(display(), 'right')
|
||||
nk.layout_row('dynamic', 35, 4)
|
||||
for i=1,16 do
|
||||
if i >= 13 and i < 16 then
|
||||
if i == 13 then
|
||||
if nk.button('C') then
|
||||
clear()
|
||||
end
|
||||
if nk.button('0') then
|
||||
digit('0')
|
||||
end
|
||||
if nk.button('=') then
|
||||
equals()
|
||||
end
|
||||
end
|
||||
elseif i % 4 ~= 0 then
|
||||
local d = tostring(math.floor(i / 4) * 3 + (i % 4))
|
||||
if nk.button(d) then
|
||||
digit(d)
|
||||
end
|
||||
else
|
||||
local o = ops[math.floor(i / 4)]
|
||||
if nk.button(o) then
|
||||
operator(o)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
nk.window_end()
|
||||
end
|
53
example/main.lua
Normal file
|
@ -0,0 +1,53 @@
|
|||
-- Several simple examples.
|
||||
|
||||
local nk = require 'nuklear'
|
||||
|
||||
local calculator = require 'calculator'
|
||||
local overview = require 'overview'
|
||||
local style = require 'style'
|
||||
local skin = require 'skin'
|
||||
|
||||
function love.load()
|
||||
nk.init()
|
||||
end
|
||||
|
||||
function love.update(dt)
|
||||
nk.frame_begin()
|
||||
calculator()
|
||||
style()
|
||||
overview()
|
||||
skin()
|
||||
nk.frame_end()
|
||||
end
|
||||
|
||||
function love.draw()
|
||||
nk.draw()
|
||||
end
|
||||
|
||||
function love.keypressed(key, scancode, isrepeat)
|
||||
nk.keypressed(key, scancode, isrepeat)
|
||||
end
|
||||
|
||||
function love.keyreleased(key, scancode)
|
||||
nk.keyreleased(key, scancode)
|
||||
end
|
||||
|
||||
function love.mousepressed(x, y, button, istouch)
|
||||
nk.mousepressed(x, y, button, istouch)
|
||||
end
|
||||
|
||||
function love.mousereleased(x, y, button, istouch)
|
||||
nk.mousereleased(x, y, button, istouch)
|
||||
end
|
||||
|
||||
function love.mousemoved(x, y, dx, dy, istouch)
|
||||
nk.mousemoved(x, y, dx, dy, istouch)
|
||||
end
|
||||
|
||||
function love.textinput(text)
|
||||
nk.textinput(text)
|
||||
end
|
||||
|
||||
function love.wheelmoved(x, y)
|
||||
nk.wheelmoved(x, y)
|
||||
end
|
106
example/overview.lua
Normal file
|
@ -0,0 +1,106 @@
|
|||
-- An overview of most of the supported widgets.
|
||||
|
||||
local nk = require 'nuklear'
|
||||
|
||||
local checkA = {value = false}
|
||||
local checkB = {value = true}
|
||||
local radio = {value = 'A'}
|
||||
local selectA = {value = false}
|
||||
local selectB = {value = true}
|
||||
local slider = {value = 0.2}
|
||||
local progress = {value = 1}
|
||||
local colorPicker = {value = '#ff0000'}
|
||||
local property = {value = 6}
|
||||
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()
|
||||
end
|
||||
nk.menubar_end()
|
||||
nk.layout_row('dynamic', 400, 3)
|
||||
nk.group_begin('Group 1', 'border')
|
||||
nk.layout_row('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
|
||||
nk.label('Label 1')
|
||||
nk.tree_pop()
|
||||
end
|
||||
if nk.tree_push('node', 'Tree Node 2') then
|
||||
nk.label('Label 2')
|
||||
nk.tree_pop()
|
||||
end
|
||||
nk.tree_pop()
|
||||
end
|
||||
nk.spacing(1)
|
||||
if nk.button('Button') then
|
||||
print('button pressed!')
|
||||
end
|
||||
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.label('Radio buttons:')
|
||||
nk.layout_row('dynamic', 30, 3)
|
||||
nk.radio('A', radio)
|
||||
nk.radio('B', radio)
|
||||
nk.radio('C', radio)
|
||||
nk.layout_row('dynamic', 30, 1)
|
||||
nk.selectable('Selectable A', selectA)
|
||||
nk.selectable('Selectable B', selectB)
|
||||
nk.layout_row('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.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.property('Property', 0, property, 10, 0.25, 0.05)
|
||||
nk.spacing(1)
|
||||
nk.label('Edit:')
|
||||
nk.layout_row('dynamic', 90, 1)
|
||||
nk.edit('box', edit)
|
||||
nk.layout_row('dynamic', 5, 1)
|
||||
nk.spacing(1)
|
||||
nk.layout_row('dynamic', 30, 1)
|
||||
nk.label('Combobox:')
|
||||
nk.combobox(comboA, comboA.items)
|
||||
nk.layout_row('dynamic', 5, 1)
|
||||
nk.spacing(1)
|
||||
nk.layout_row('dynamic', 30, 1)
|
||||
if nk.widget_is_hovered() 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()
|
||||
end
|
||||
nk.label('Contextual (Right click me)')
|
||||
nk.group_end()
|
||||
end
|
||||
nk.window_end()
|
||||
end
|
62
example/skin.lua
Normal file
|
@ -0,0 +1,62 @@
|
|||
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 style = {
|
||||
['text'] = {
|
||||
['color'] = '#000000'
|
||||
},
|
||||
['button'] = {
|
||||
['normal'] = love.graphics.newImage 'skin/button.png',
|
||||
['hover'] = love.graphics.newImage 'skin/button_hover.png',
|
||||
['active'] = love.graphics.newImage 'skin/button_active.png',
|
||||
['text background'] = '#00000000',
|
||||
['text normal'] = '#000000',
|
||||
['text hover'] = '#000000',
|
||||
['text active'] = '#ffffff'
|
||||
},
|
||||
['checkbox'] = {
|
||||
['normal'] = checkbox_skin,
|
||||
['hover'] = checkbox_skin,
|
||||
['active'] = checkbox_skin,
|
||||
['cursor normal'] = checkbox_check,
|
||||
['cursor hover'] = checkbox_check,
|
||||
['text normal'] = '#000000',
|
||||
['text hover'] = '#000000',
|
||||
['text active'] = '#000000',
|
||||
['text background'] = '#d3ceaa'
|
||||
},
|
||||
['window'] = {
|
||||
['header'] = {
|
||||
['normal'] = window_header,
|
||||
['hover'] = window_header,
|
||||
['active'] = window_header,
|
||||
['label normal'] = '#000000',
|
||||
['label hover'] = '#000000',
|
||||
['label active'] = '#000000',
|
||||
['label padding'] = {x = 10, y = 8}
|
||||
},
|
||||
['fixed background'] = love.graphics.newImage 'skin/window.png',
|
||||
['background'] = '#d3ceaa'
|
||||
}
|
||||
}
|
||||
|
||||
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.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.button('Button')
|
||||
nk.layout_space_push(0.55, 0.55, 0.3, 0.2)
|
||||
nk.checkbox('Checkbox', check)
|
||||
nk.layout_space_end()
|
||||
end
|
||||
nk.window_end()
|
||||
nk.style_pop()
|
||||
end
|
BIN
example/skin/button.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
example/skin/button_active.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
example/skin/button_hover.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
example/skin/checkbox_false.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
example/skin/checkbox_true.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
example/skin/window.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
example/skin/window_header.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
69
example/style.lua
Normal file
|
@ -0,0 +1,69 @@
|
|||
-- Show off some of the styling options.
|
||||
|
||||
local nk = require 'nuklear'
|
||||
|
||||
local colors = {
|
||||
['text'] = '#afafaf',
|
||||
['window'] = '#2d2d2d',
|
||||
['header'] = '#282828',
|
||||
['border'] = '#414141',
|
||||
['button'] = '#323232',
|
||||
['button hover'] = '#282828',
|
||||
['button active'] = '#232323',
|
||||
['toggle'] = '#646464',
|
||||
['toggle hover'] = '#787878',
|
||||
['toggle cursor'] = '#2d2d2d',
|
||||
['select'] = '#2d2d2d',
|
||||
['select active'] = '#232323',
|
||||
['slider'] = '#262626',
|
||||
['slider cursor'] = '#646464',
|
||||
['slider cursor hover'] = '#787878',
|
||||
['slider cursor active'] = '#969696',
|
||||
['property'] = '#262626',
|
||||
['edit'] = '#262626',
|
||||
['edit cursor'] = '#afafaf',
|
||||
['combo'] = '#2d2d2d',
|
||||
['chart'] = '#787878',
|
||||
['chart color'] = '#2d2d2d',
|
||||
['chart color highlight'] = '#ff0000',
|
||||
['scrollbar'] = '#282828',
|
||||
['scrollbar cursor'] = '#646464',
|
||||
['scrollbar cursor hover'] = '#787878',
|
||||
['scrollbar cursor active'] = '#969696',
|
||||
['tab header'] = '#282828'
|
||||
}
|
||||
|
||||
local color_names = {}
|
||||
|
||||
for name,_ in pairs(colors) do
|
||||
color_names[#color_names + 1] = name
|
||||
end
|
||||
|
||||
table.sort(color_names)
|
||||
|
||||
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.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)
|
||||
colors[name] = color
|
||||
local r, g, b = nk.color_parse_rgba(color)
|
||||
nk.layout_row('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.layout_row('dynamic', 0, 0) -- Work-around for nuklear issue #282
|
||||
nk.combobox_end()
|
||||
end
|
||||
end
|
||||
nk.window_end()
|
||||
end
|
1
src/nuklear
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 8e603282a4531bf9826698a7687f1e18b1364b94
|