Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stetre/moonnuklear
Lua bindings for Nuklear
https://github.com/stetre/moonnuklear
gui lua lua-bindings nuklear
Last synced: about 2 months ago
JSON representation
Lua bindings for Nuklear
- Host: GitHub
- URL: https://github.com/stetre/moonnuklear
- Owner: stetre
- License: other
- Created: 2018-04-10T08:52:49.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-04-24T15:46:51.000Z (8 months ago)
- Last Synced: 2024-08-01T15:29:39.279Z (5 months ago)
- Topics: gui, lua, lua-bindings, nuklear
- Language: C
- Size: 1.91 MB
- Stars: 106
- Watchers: 9
- Forks: 10
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## MoonNuklear: Lua bindings for Nuklear
MoonNuklear is a Lua binding library for Mitcha Mettke's [Nuklear](https://github.com/Immediate-Mode-UI/nuklear) immediate mode GUI toolkit.
It runs on GNU/Linux, on MacOS, and on Windows (MSYS2/MinGW) and requires [Lua](http://www.lua.org/) (>=5.3).
_Author:_ _[Stefano Trettel](https://www.linkedin.com/in/stetre)_
[![Lua logo](./doc/powered-by-lua.gif)](http://www.lua.org/)
#### License
MIT/X11 license (same as Lua). See [LICENSE](./LICENSE).
#### Documentation
See the [Reference Manual](https://stetre.github.io/moonnuklear/doc/index.html).
#### Getting and installing
Setup the build environment as described [here](https://github.com/stetre/moonlibs), then:
```sh
$ git clone https://github.com/stetre/moonnuklear
$ cd moonnuklear
moonnuklear$ make
moonnuklear$ make install # or 'sudo make install' (Ubuntu and MacOS)
```#### Example
The example below shows the front-end implementation of a simple GUI.
The backend and other examples can be found in the **examples/** directory contained in the release package.
```lua
local nk = require("moonnuklear")
local backend = require("backend")local op = 'easy'
local value = 0.6
local window_flags = nk.WINDOW_BORDER|nk.WINDOW_MOVABLE|nk.WINDOW_CLOSABLElocal function hellogui(ctx)
if nk.window_begin(ctx, "Show", {50, 50, 220, 220}, window_flags) then
-- fixed widget pixel width
nk.layout_row_static(ctx, 30, 80, 1)if nk.button(ctx, nil, "button") then
-- ... event handling ...
print("button pressed")
end-- fixed widget window ratio width
nk.layout_row_dynamic(ctx, 30, 2)
if nk.option(ctx, 'easy', op == 'easy') then op = 'easy' end
if nk.option(ctx, 'hard', op == 'hard') then op = 'hard' end-- custom widget pixel width
nk.layout_row_begin(ctx, 'static', 30, 2)
nk.layout_row_push(ctx, 50)
nk.label(ctx, "Volume:", nk.TEXT_LEFT)
nk.layout_row_push(ctx, 110)
value = nk.slider(ctx, 0, value, 1.0, 0.1)
nk.layout_row_end(ctx)
end
nk.window_end(ctx)
end-- Init the backend and enter the event loop:
backend.init(640, 380, "Hello", true, nil)
backend.loop(hellogui, {.13, .29, .53, 1}, 30)```
The script can be executed at the shell prompt with the standard Lua interpreter:```shell
$ lua hello.lua
```#### See also
* [MoonLibs - Graphics and Audio Lua Libraries](https://github.com/stetre/moonlibs).