Crystal-lang bindings for libui
Crystal-lang bindings for libui, a GUI library for Linux, OS X and Windows.
(well, forget about Windows for now, this is Crystal)
04/15/17
08/13/16
07/24/16
06/19/16
Add these package to your dependencies in shard.yml:
dependencies:
libui:
github: fusion/libui.cr
Have a look at examples/controlgallery, which is a direct port of a C example.
(see examples/crgallery)
This is a feature I am introducing in addition to the library bindings.
It allows devs to specify a UI without hard coding it and maintain it using
fragments described in simple .yml files.
Some advantages:
Obvious drawback:
Note that inflating fragments and pure coding can be mixed.
CUI.menubar "path_to_yml_file"
CUI.inflate "path_to_yml_file"
CUI.get/CUI.get!
CUI.get_as_menuitem/CUI.get_as_menuitem!
CUI.get_mainwindow/CUI.get_mainwindow!
The ‘!’ forms will throw an exception if component is not found.
Recent versions of Crystal now require you to include the current path explicitly to find libraries:
crystal build --link-flags "-L$(pwd)" examples/controlgallery/main.cr
crystal build --link-flags "-L$(pwd)" examples/crgallery/crgallery.cr
If you omit this flag, libui.A.dylib or libui.so (system-specific) will not be found.
Note: in this example, I used the current directory but it could be -L/usr/local/includes
or any
other location depending on your setup.
To run the generated binaries:
LD_LIBRARY_PATH=. ./main
LD_LIBRARY_PATH=. ./crgallery