Hi everyone!
I created a fork of ui that wraps libui-ng instead of the old and unmaintained libui library. I made this fork because libui seems to be abandoned (ATOW, most recent update to libui was 2 years ago), and ui hasn't been updated in a long time aswell (coincidentally, the most recent change also happens to be 2 years ago).
The source code can can be found here: https://github.com/neroist/uing
You can install via Nimble: nimble install uing
UIng's documentation is hosted here: https://neroist.github.io/uing/uing.html
You can find examples here.
For rawui I suggest you look at libui-ng's official docs, which can be found here.
Heres the datetime example written with uing: (original C code here)
import std/times
import uing
proc main =
let window = newWindow("Date / Time", 320, 240)
window.margined = true
let grid = newGrid(true)
window.child = grid
let
dateTimeLabel = newLabel()
dateLabel = newLabel()
timeLabel = newLabel()
dateTimePicker = newDateTimePicker() do (dt: DateTimePicker):
dateTimeLabel.text = dt.time.format("ddd MMM d HH:mm:ss UUUU")
datePicker = newDatePicker() do (dt: DateTimePicker):
dateLabel.text = dt.time.format("yyyy-MM-dd")
timePicker = newTimePicker() do (dt: DateTimePicker):
timeLabel.text = dt.time.format("hh:mm:ss")
nowButton = newButton("Now") do (_: Button):
timePicker.time = now()
datePicker.time = now()
epochButton = newButton("Unix epoch") do (_: Button):
dateTimePicker.time = dateTime(1969, mDec, 31, 19)
grid.add(dateTimePicker, 0, 0, 2, 1, true, AlignFill, false, AlignFill)
grid.add(datePicker, 0, 1, 1, 1, true, AlignFill, false, AlignFill)
grid.add(timePicker, 1, 1, 1, 1, true, AlignFill, false, AlignFill)
grid.add(dateTimeLabel, 0, 2, 2, 1, true, AlignCenter, false, AlignFill)
grid.add(dateLabel, 0, 3, 1, 1, true, AlignCenter, false, AlignFill)
grid.add(timeLabel, 1, 3, 1, 1, true, AlignCenter, false, AlignFill)
grid.add(nowButton, 0, 4, 1, 1, true, AlignFill, true, AlignEnd)
grid.add(epochButton, 1, 4, 1, 1, true, AlignFill, true, AlignEnd)
show window
mainLoop()
init()
main()
This results in this application on Windows:
How dare you fork my work! I have not allowed you to fork it! This is not how open source works!
Just kidding. It's awesome. :-)
Does it support custom Widgets?
Checking the libui-ng Class documentation I couldn't see it.