mirror of
https://github.com/keharriso/love-nuklear.git
synced 2025-09-11 00:27:48 -04:00
Compare commits
41 commits
Author | SHA1 | Date | |
---|---|---|---|
|
5336818494 | ||
|
8d092eefa4 | ||
|
1b8058071e | ||
|
829dc151c0 | ||
|
e9be4aa952 | ||
|
018aaf60a0 | ||
|
0347818eca | ||
|
640a50532b | ||
|
9ba37e4e4a | ||
|
7491ab58b2 | ||
|
d1cfcf2a47 | ||
|
d41e9d1875 | ||
|
efc53612bf | ||
|
09cdd09716 | ||
|
fef4e00a60 | ||
|
f33c94db66 | ||
|
213be47f91 | ||
|
f7ab5085f1 | ||
|
0cca218ac7 | ||
|
ccfb6ec005 | ||
|
b3af181896 | ||
|
05dfdb5c34 | ||
|
bf89bf9f08 | ||
|
be9b57393a | ||
|
d463002a97 | ||
|
0d14e1c2cf | ||
|
2fd70e6062 | ||
|
de05b2595c | ||
|
8d081e50e6 | ||
|
3254a42992 | ||
|
901c47fe2c | ||
|
f652c1936f | ||
|
206f937e6e | ||
|
5255830af4 | ||
|
75da1af2b6 | ||
|
08abd141ce | ||
|
a7991c524e | ||
|
42ca8ed3c0 | ||
|
976ff9f63b | ||
|
bb3ffeb957 | ||
|
752eacec7c |
12 changed files with 1379 additions and 675 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
build/
|
2
.gitmodules
vendored
2
.gitmodules
vendored
|
@ -1,3 +1,3 @@
|
||||||
[submodule "src/nuklear"]
|
[submodule "src/nuklear"]
|
||||||
path = src/nuklear
|
path = src/nuklear
|
||||||
url = https://github.com/vurtun/nuklear.git
|
url = https://github.com/Immediate-Mode-UI/Nuklear.git
|
||||||
|
|
|
@ -24,4 +24,14 @@ TARGET_LINK_LIBRARIES(
|
||||||
${LUA_LIBRARIES}
|
${LUA_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
IF(MSVC)
|
||||||
|
TARGET_COMPILE_DEFINITIONS(${LIB_NAME} PRIVATE LUA_BUILD_AS_DLL)
|
||||||
|
endif(MSVC)
|
||||||
|
|
||||||
SET_TARGET_PROPERTIES("${LIB_NAME}" PROPERTIES PREFIX "")
|
SET_TARGET_PROPERTIES("${LIB_NAME}" PROPERTIES PREFIX "")
|
||||||
|
|
||||||
|
IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
||||||
|
SET(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}" CACHE PATH "..." FORCE)
|
||||||
|
ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
||||||
|
|
||||||
|
INSTALL(TARGETS "${LIB_NAME}" DESTINATION .)
|
||||||
|
|
41
README.md
41
README.md
|
@ -1,6 +1,6 @@
|
||||||
# LÖVE-Nuklear
|
# LÖVE-Nuklear
|
||||||
|
|
||||||
[Nuklear](https://github.com/vurtun/nuklear) module for the [LÖVE](https://love2d.org/) game engine.
|
[Nuklear](https://github.com/Immediate-Mode-UI/Nuklear) module for the [LÖVE](https://love2d.org/) game engine.
|
||||||
|
|
||||||
Provides a lightweight immediate mode GUI for LÖVE games.
|
Provides a lightweight immediate mode GUI for LÖVE games.
|
||||||
|
|
||||||
|
@ -54,12 +54,12 @@ function love.keyreleased(key, scancode)
|
||||||
ui:keyreleased(key, scancode)
|
ui:keyreleased(key, scancode)
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.mousepressed(x, y, button, istouch)
|
function love.mousepressed(x, y, button, istouch, presses)
|
||||||
ui:mousepressed(x, y, button, istouch)
|
ui:mousepressed(x, y, button, istouch, presses)
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.mousereleased(x, y, button, istouch)
|
function love.mousereleased(x, y, button, istouch, presses)
|
||||||
ui:mousereleased(x, y, button, istouch)
|
ui:mousereleased(x, y, button, istouch, presses)
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.mousemoved(x, y, dx, dy, istouch)
|
function love.mousemoved(x, y, dx, dy, istouch)
|
||||||
|
@ -81,23 +81,30 @@ Windows binaries are available for each [release](https://github.com/keharriso/l
|
||||||
|
|
||||||
To build the library yourself, grab the code with:
|
To build the library yourself, grab the code with:
|
||||||
```sh
|
```sh
|
||||||
$ git clone --recursive git@github.com:keharriso/love-nuklear.git
|
$ git clone --recursive https://github.com/keharriso/love-nuklear.git
|
||||||
```
|
```
|
||||||
|
|
||||||
Next, you need to compile the code to a native Lua module.
|
Next, you need to compile the code to a native Lua module.
|
||||||
|
|
||||||
### Compiling with CMake on Linux
|
### Compiling with CMake on Linux
|
||||||
|
|
||||||
1. First, ensure you have the `cmake` and `luajit` packages installed.
|
1. First, ensure you have a C compiler and the `cmake` and `luajit` or `lua51-luajit` (for openSUSE) packages installed, as well as `libluajit-5.1-dev` (for Ubuntu/Debian), `luajit-devel` (for Fedora), or `lua51-luajit-devel` (for openSUSE) if your distro has one of these packages.
|
||||||
2. Create a new folder next to `love-nuklear` called `love-nuklear-build`.
|
2. Create a new folder next to `love-nuklear` called `love-nuklear-build`.
|
||||||
3. Open a terminal inside `love-nuklear-build`.
|
3. Open a terminal inside `love-nuklear-build`.
|
||||||
4. Compile with
|
4. Compile the library with
|
||||||
```sh
|
```sh
|
||||||
$ cmake ../love-nuklear
|
$ cmake -DCMAKE_BUILD_TYPE=Release ../love-nuklear
|
||||||
$ make
|
$ make
|
||||||
```
|
```
|
||||||
5. Locate `nuklear.so` in the build folder.
|
5. Locate `nuklear.so` in the build folder.
|
||||||
|
|
||||||
|
#### Via GNU Guix
|
||||||
|
|
||||||
|
LÖVE-Nuklear is also available as a [Guix](http://guix.gnu.org/) package, and can thus be directly downloaded and built via:
|
||||||
|
```
|
||||||
|
$ guix package --install love-nuklear
|
||||||
|
```
|
||||||
|
|
||||||
### Compiling with CMake and MinGW on Windows
|
### Compiling with CMake and MinGW on Windows
|
||||||
|
|
||||||
1. Install [CMake](https://cmake.org/download/) and [MinGW](http://mingw.org/) or [MinGW-w64](https://mingw-w64.org/doku.php).
|
1. Install [CMake](https://cmake.org/download/) and [MinGW](http://mingw.org/) or [MinGW-w64](https://mingw-w64.org/doku.php).
|
||||||
|
@ -125,6 +132,22 @@ $ mingw32-make
|
||||||
```
|
```
|
||||||
18. Locate `nuklear.dll` inside the build folder.
|
18. Locate `nuklear.dll` inside the build folder.
|
||||||
|
|
||||||
|
### Compiling with CMake and MSVC on Windows
|
||||||
|
|
||||||
|
1. Install [CMake](https://cmake.org/download/) and [Visual Studio](https://visualstudio.microsoft.com/).
|
||||||
|
Community or Express edition is sufficient.
|
||||||
|
2. Download the source code for [LuaJIT](http://luajit.org/download.html).
|
||||||
|
3. Open a Visual Studio Command Prompt (x86 or x64 depending on what architecture you need)
|
||||||
|
and set the current directory to the LuaJIT folder (the one that contains "README"). Also
|
||||||
|
remember this path.
|
||||||
|
4. At the VS Command Prompt, set your current directory to `src` then
|
||||||
|
execute `msvcbuild.bat`. This will create lua51.dll, lua51.lib, and luajit.exe
|
||||||
|
5. Now open new command prompt window inside the `love-nuklear` folder.
|
||||||
|
6. Type `set "LUA_DIR=<path to directory at step 3>"`
|
||||||
|
7. Then type `cmake -Bbuild -H. -A Win32 -DLUA_INCLUDE_DIR=%LUA_DIR%\src -DLUA_LIBRARY=%LUA_DIR%\src\lua51.lib -DCMAKE_INSTALL_PREFIX=%CD%\install`.
|
||||||
|
If you previously compile LuaJIT using x64 VS command prompt, replace `Win32` with `x64` at above command.
|
||||||
|
8. Then type `cmake --build build --config Release --target install` and you'll found `nuklear.dll` inside "install" folder.
|
||||||
|
|
||||||
## Documentation
|
## 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).
|
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).
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
find_path(LUA_INCLUDE_DIR luajit.h
|
find_path(LUA_INCLUDE_DIR luajit.h
|
||||||
HINTS
|
HINTS
|
||||||
ENV LUA_DIR
|
ENV LUA_DIR
|
||||||
PATH_SUFFIXES include/luajit-2.0 include
|
PATH_SUFFIXES include/luajit-2.0 include/luajit-2.1 include/luajit-5_1-2.1 include
|
||||||
PATHS
|
PATHS
|
||||||
~/Library/Frameworks
|
~/Library/Frameworks
|
||||||
/Library/Frameworks
|
/Library/Frameworks
|
||||||
|
|
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
|
|
@ -5,7 +5,7 @@ local img = love.graphics.newImage 'skin/button.png'
|
||||||
return function (ui)
|
return function (ui)
|
||||||
if ui:windowBegin('Draw Example', 300, 300, 200, 200, 'title', 'movable', 'border') then
|
if ui:windowBegin('Draw Example', 300, 300, 200, 200, 'title', 'movable', 'border') then
|
||||||
local x, y, w, h = ui:windowGetBounds()
|
local x, y, w, h = ui:windowGetBounds()
|
||||||
love.graphics.setColor(255, 0, 0)
|
love.graphics.setColor(1, 0, 0)
|
||||||
ui:line(x + 10, y + 40, x + 50, y + 40, x + 50, y + 80)
|
ui:line(x + 10, y + 40, x + 50, y + 40, x + 50, y + 80)
|
||||||
ui:curve(x + 50, y + 80, x + 80, y + 40, x + 100, y + 80, x + 80, y + 80)
|
ui:curve(x + 50, y + 80, x + 80, y + 40, x + 100, y + 80, x + 80, y + 80)
|
||||||
ui:polygon('line', x + 100, y + 150, x + 60, y + 140, x + 70, y + 70)
|
ui:polygon('line', x + 100, y + 150, x + 60, y + 140, x + 70, y + 70)
|
||||||
|
@ -13,7 +13,7 @@ return function (ui)
|
||||||
ui:ellipse('fill', x + 30, y + 150, 20, 40)
|
ui:ellipse('fill', x + 30, y + 150, 20, 40)
|
||||||
ui:arc('fill', x + 150, y + 80, 40, 3 * math.pi / 2, 2 * math.pi);
|
ui:arc('fill', x + 150, y + 80, 40, 3 * math.pi / 2, 2 * math.pi);
|
||||||
ui:rectMultiColor(x + 95, y + 50, 50, 50, '#ff0000', '#00ff00', '#0000ff', '#000000')
|
ui:rectMultiColor(x + 95, y + 50, 50, 50, '#ff0000', '#00ff00', '#0000ff', '#000000')
|
||||||
love.graphics.setColor(255, 255, 255)
|
love.graphics.setColor(1, 1, 1)
|
||||||
ui:image(img, x + 120, y + 120, 70, 50)
|
ui:image(img, x + 120, y + 120, 70, 50)
|
||||||
ui:text('DRAW TEXT', x + 15, y + 75, 100, 100)
|
ui:text('DRAW TEXT', x + 15, y + 75, 100, 100)
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,15 +3,18 @@
|
||||||
local nuklear = require 'nuklear'
|
local nuklear = require 'nuklear'
|
||||||
|
|
||||||
local calculator = require 'calculator'
|
local calculator = require 'calculator'
|
||||||
|
local closure = require 'closure'
|
||||||
local draw = require 'draw'
|
local draw = require 'draw'
|
||||||
local overview = require 'overview'
|
local overview = require 'overview'
|
||||||
local style = require 'style'
|
local style = require 'style'
|
||||||
local skin = require 'skin'
|
local skin = require 'skin'
|
||||||
|
local template = require 'template'
|
||||||
local transform = require 'transform'
|
local transform = require 'transform'
|
||||||
|
|
||||||
local ui1, ui2
|
local ui1, ui2
|
||||||
|
|
||||||
function love.load()
|
function love.load()
|
||||||
|
love.keyboard.setKeyRepeat(true)
|
||||||
ui1, ui2 = nuklear.newUI(), nuklear.newUI()
|
ui1, ui2 = nuklear.newUI(), nuklear.newUI()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -19,8 +22,10 @@ function love.update(dt)
|
||||||
ui1:frameBegin()
|
ui1:frameBegin()
|
||||||
calculator(ui1)
|
calculator(ui1)
|
||||||
style(ui1)
|
style(ui1)
|
||||||
|
closure(ui1)
|
||||||
overview(ui1)
|
overview(ui1)
|
||||||
draw(ui1)
|
draw(ui1)
|
||||||
|
template(ui1)
|
||||||
skin(ui1)
|
skin(ui1)
|
||||||
ui1:frameEnd()
|
ui1:frameEnd()
|
||||||
ui2:frameBegin()
|
ui2:frameBegin()
|
||||||
|
@ -31,7 +36,7 @@ end
|
||||||
function love.draw()
|
function love.draw()
|
||||||
ui1:draw()
|
ui1:draw()
|
||||||
ui2: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
|
end
|
||||||
|
|
||||||
local function input(name, ...)
|
local function input(name, ...)
|
||||||
|
@ -46,12 +51,12 @@ function love.keyreleased(key, scancode)
|
||||||
input('keyreleased', key, scancode)
|
input('keyreleased', key, scancode)
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.mousepressed(x, y, button, istouch)
|
function love.mousepressed(x, y, button, istouch, presses)
|
||||||
input('mousepressed', x, y, button, istouch)
|
input('mousepressed', x, y, button, istouch, presses)
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.mousereleased(x, y, button, istouch)
|
function love.mousereleased(x, y, button, istouch, presses)
|
||||||
input('mousereleased', x, y, button, istouch)
|
input('mousereleased', x, y, button, istouch, presses)
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.mousemoved(x, y, dx, dy, istouch)
|
function love.mousemoved(x, y, dx, dy, istouch)
|
||||||
|
|
|
@ -11,6 +11,7 @@ local colorPicker = {value = '#ff0000'}
|
||||||
local property = {value = 6}
|
local property = {value = 6}
|
||||||
local edit = {value = 'Edit text'}
|
local edit = {value = 'Edit text'}
|
||||||
local comboA = {value = 1, items = {'A', 'B', 'C'}}
|
local comboA = {value = 1, items = {'A', 'B', 'C'}}
|
||||||
|
local scissorActive = false
|
||||||
|
|
||||||
return function (ui)
|
return function (ui)
|
||||||
if ui:windowBegin('Overview', 100, 100, 600, 450, 'border', 'movable', 'title') then
|
if ui:windowBegin('Overview', 100, 100, 600, 450, 'border', 'movable', 'title') then
|
||||||
|
@ -49,6 +50,9 @@ return function (ui)
|
||||||
ui:spacing(1)
|
ui:spacing(1)
|
||||||
ui:checkbox('Checkbox A', checkA)
|
ui:checkbox('Checkbox A', checkA)
|
||||||
ui:checkbox('Checkbox B', checkB)
|
ui:checkbox('Checkbox B', checkB)
|
||||||
|
if ui:button('Scissor') then
|
||||||
|
scissorActive = not scissorActive
|
||||||
|
end
|
||||||
ui:groupEnd()
|
ui:groupEnd()
|
||||||
end
|
end
|
||||||
if ui:groupBegin('Group 2', 'border') then
|
if ui:groupBegin('Group 2', 'border') then
|
||||||
|
@ -104,4 +108,11 @@ return function (ui)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
ui:windowEnd()
|
ui:windowEnd()
|
||||||
|
if(scissorActive) then
|
||||||
|
love.graphics.setScissor()
|
||||||
|
love.graphics.clear()
|
||||||
|
love.graphics.setScissor(130, 130, 500, 400)
|
||||||
|
else
|
||||||
|
love.graphics.setScissor()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
19
example/template.lua
Normal file
19
example/template.lua
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
-- Show off the template row layout
|
||||||
|
|
||||||
|
return function(ui)
|
||||||
|
if ui:windowBegin('Template Layout', 200, 100, 300, 200,
|
||||||
|
'title', 'border', 'movable', 'scalable') then
|
||||||
|
x, y, width, height = ui:windowGetContentRegion()
|
||||||
|
ui:layoutRow('dynamic', 40, 1)
|
||||||
|
ui:label('Scale me!');
|
||||||
|
ui:layoutTemplateBegin(height - 40)
|
||||||
|
ui:layoutTemplatePush('static', 75)
|
||||||
|
ui:layoutTemplatePush('dynamic')
|
||||||
|
ui:layoutTemplatePush('variable', 75)
|
||||||
|
ui:layoutTemplateEnd()
|
||||||
|
ui:button(nil, '#ff0000')
|
||||||
|
ui:button(nil, '#00ff00')
|
||||||
|
ui:button(nil, '#0000ff')
|
||||||
|
end
|
||||||
|
ui:windowEnd()
|
||||||
|
end
|
|
@ -1 +1 @@
|
||||||
Subproject commit 181cfd86c47ae83eceabaf4e640587b844e613b6
|
Subproject commit 614abce05b9455849bbf1519b7f86e53c78b04ab
|
1896
src/nuklear_love.c
1896
src/nuklear_love.c
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue