Initial version
This commit is contained in:
commit
325ef7a8d4
6 changed files with 163 additions and 0 deletions
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
nimui
|
||||||
|
nimcache
|
||||||
|
*.exe
|
||||||
|
*.swp
|
||||||
|
tui*
|
||||||
21
LICENSE
Normal file
21
LICENSE
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2018 Ganesh Viswanathan
|
||||||
|
|
||||||
|
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.
|
||||||
39
README.md
Normal file
39
README.md
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
Nimui is a [Nim](https://nim-lang.org/) wrapper for the [libui](https://github.com/andlabs/libui) library.
|
||||||
|
|
||||||
|
Nimui is distributed as a [Nimble](https://github.com/nim-lang/nimble) package and depends on [nimgen](https://github.com/genotrance/nimgen) and [c2nim](https://github.com/nim-lang/c2nim/) to generate the wrappers. The libui source code is downloaded using Git so having ```git``` in the path is required.
|
||||||
|
|
||||||
|
__Installation__
|
||||||
|
|
||||||
|
Nimui is currently a work in progress. It can be installed via [Nimble](https://github.com/nim-lang/nimble):
|
||||||
|
|
||||||
|
```
|
||||||
|
> nimble install nimgen
|
||||||
|
|
||||||
|
> git clone https://github.com/genotrance/nimui
|
||||||
|
> cd nimui
|
||||||
|
> nimble install -y
|
||||||
|
```
|
||||||
|
|
||||||
|
This will download, wrap and install nimui in the standard Nimble package location, typically ~/.nimble. Once installed, it can be imported into any Nim program.
|
||||||
|
|
||||||
|
__Usage__
|
||||||
|
|
||||||
|
TBD
|
||||||
|
|
||||||
|
```nim
|
||||||
|
import nimui/ui
|
||||||
|
|
||||||
|
var opts: UiInitOptions
|
||||||
|
if uiInit(addr opts) != nil:
|
||||||
|
quit(1)
|
||||||
|
```
|
||||||
|
|
||||||
|
__Credits__
|
||||||
|
|
||||||
|
Nimui wraps the [libui](https://github.com/andlabs/libui) library and all its licensing terms apply to the usage of this package.
|
||||||
|
|
||||||
|
Credits go out to [c2nim](https://github.com/nim-lang/c2nim/) as well without which this package would be greatly limited in its abilities.
|
||||||
|
|
||||||
|
__Feedback__
|
||||||
|
|
||||||
|
Nimui is a work in progress and any feedback or suggestions are welcome. It is hosted on [GitHub](https://github.com/genotrance/nimui) with an MIT license so issues, forks and PRs are most appreciated.
|
||||||
55
nimui.cfg
Normal file
55
nimui.cfg
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
[n.global]
|
||||||
|
output = nimui
|
||||||
|
|
||||||
|
[n.include]
|
||||||
|
nimui
|
||||||
|
nimui/common
|
||||||
|
|
||||||
|
[n.prepare]
|
||||||
|
git = "https://github.com/andlabs/libui"
|
||||||
|
execute-win = "windres nimui/examples/resources.rc nimui/examples/resources.o"
|
||||||
|
|
||||||
|
[ui.h]
|
||||||
|
preprocess = true
|
||||||
|
defines = true
|
||||||
|
|
||||||
|
recurse = true
|
||||||
|
|
||||||
|
compile = "nimui/common/*.c"
|
||||||
|
compile-win = "nimui/windows/*.cpp"
|
||||||
|
compile-lin = "nimui/unix/*.c"
|
||||||
|
|
||||||
|
pragma.passC = "passC: \"--std=c++11\""
|
||||||
|
pragma-win.passL = "passL: \"-luser32 -lkernel32 -lgdi32 -lcomctl32 -luxtheme -lmsimg32 -lcomdlg32 -ld2d1 -ldwrite -lole32 -loleaut32 -loleacc -luuid -lwindowscodecs -lstdc++\""
|
||||||
|
pragma-win.rc = "link: \"nimui/examples/resources.o\""
|
||||||
|
|
||||||
|
flags = "--cdecl --nep1"
|
||||||
|
|
||||||
|
[ui.nim]
|
||||||
|
regex.1 = """([u]int[\d]+)T"""
|
||||||
|
replace.1 = "$1"
|
||||||
|
|
||||||
|
regex.2 = """([u]int)ptrT"""
|
||||||
|
replace.2 = "ptr $1"
|
||||||
|
|
||||||
|
regex.3 = """U(.*?)\* = [a-zA-Z]+\n"""
|
||||||
|
replace.3 = """U$1* = object
|
||||||
|
"""
|
||||||
|
|
||||||
|
regex.4 = """ (?:UiInitOptions|UiControl|UiAreaDrawParams|UiAreaMouseEvent|UiAreaKeyEvent|UiAreaHandler|UiDrawMatrix)+\* = object"""
|
||||||
|
replace.4 = ""
|
||||||
|
|
||||||
|
regex.5 = """ (?:UiDrawBrushGradientStop|UiDrawBrush|UiDrawStrokeParams|UiFontDescriptor|UiDrawTextLayoutParams)+\* = object"""
|
||||||
|
replace.5 = ""
|
||||||
|
|
||||||
|
regex.6 = """ (?:UiTableModelHandler|UiTableTextColumnOptionalParams|UiTableParams)+\* = object"""
|
||||||
|
replace.6 = ""
|
||||||
|
|
||||||
|
regex.7 = """((?s: (?:UiAreaDrawParams|UiAreaMouseEvent|UiModifiers|UiAreaKeyEvent|UiExtKey)+\* .*?\n\n))"""
|
||||||
|
move.7 = "UiArea* = object\n"
|
||||||
|
|
||||||
|
search.8 = "type\nconst\n"
|
||||||
|
replace.8 = "const\n"
|
||||||
|
|
||||||
|
search.9 = "{.compile: \"nimui/common/OLD_table.c\".}"
|
||||||
|
comment.9 = 1
|
||||||
30
nimui.nimble
Normal file
30
nimui.nimble
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
# Package
|
||||||
|
|
||||||
|
version = "0.1.0"
|
||||||
|
author = "genotrance"
|
||||||
|
description = "libui wrapper for Nim"
|
||||||
|
license = "MIT"
|
||||||
|
|
||||||
|
skipDirs = @["tests"]
|
||||||
|
|
||||||
|
# Dependencies
|
||||||
|
|
||||||
|
requires "nimgen >= 0.4.0"
|
||||||
|
|
||||||
|
import distros
|
||||||
|
|
||||||
|
var cmd = ""
|
||||||
|
var ldpath = ""
|
||||||
|
var ext = ""
|
||||||
|
if detectOs(Windows):
|
||||||
|
cmd = "cmd /c "
|
||||||
|
ext = ".exe"
|
||||||
|
|
||||||
|
task setup, "Download and generate":
|
||||||
|
exec cmd & "nimgen nimui.cfg"
|
||||||
|
|
||||||
|
before install:
|
||||||
|
setupTask()
|
||||||
|
|
||||||
|
task test, "Test nimui":
|
||||||
|
exec "nim cpp --app:gui tests/tui.nim"
|
||||||
13
tests/tui.nim
Normal file
13
tests/tui.nim
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
import nimui/ui
|
||||||
|
|
||||||
|
var opts: UiInitOptions
|
||||||
|
if uiInit(addr opts) != nil:
|
||||||
|
quit(1)
|
||||||
|
|
||||||
|
# var
|
||||||
|
# mainwin: ptr UiWindow = uiNewWindow("libui Control Gallery", 640, 480, 1)
|
||||||
|
|
||||||
|
# uiWindowSetMargined(mainwin, 1)
|
||||||
|
|
||||||
|
# uiControlShow(cast[ptr UiControl](mainwin))
|
||||||
|
# uiMain()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue