• Stars
    star
    176
  • Rank 209,711 (Top 5 %)
  • Language
    Crystal
  • License
    MIT License
  • Created almost 8 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Crystal-lang bindings for libui

libui.cr

Crystal-lang bindings for libui, a GUI library for Linux, OS X and Windows.

(well, forget about Windows for now, this is Crystal)

OS X

What's New

04/15/17

  • Sync'd to upstream #5fa7ba4
  • Updated for Crystal 0.21.1

08/13/16

  • Sync'd to upstream #6e45859
  • Control Gallery not updated, but yml examples were
  • Proper component stretching and margins
  • Waiting for tables definition to materialize

07/24/16

  • Now with YAML builder

06/19/16

  • Sync'd to upstream #9656a81
  • Control Gallery example not updated but library is.

Installation

Add these package to your dependencies in shard.yml:

dependencies:
  libui:
    github: fusion/libui.cr

Usage

Standard (C-like) usage

Have a look at examples/controlgallery, which is a direct port of a C example.

Crystal-only YAML builder

(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:

  • No need to recompile your code to test a UI change
  • Team collaboration now easier
  • Descriptive UI
  • Separation of concerns

Obvious drawback:

  • No compile-time checks

Note that inflating fragments and pure coding can be mixed.

API

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.

Development

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

Contributing

  1. Fork it ( https://github.com/fusion/libui.cr/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • [fusion] Chris F Ravenscroft - creator, maintainer

More Repositories

1

kittendns

Go
144
star
2

pngsource

Embed Embed source code in png files
HTML
105
star
3

pywhistle

Unofficial Whistle 3 API consumer
Python
20
star
4

RootTools

Root Tools
Java
19
star
5

krew-plugins-for-m1

Kubectl Krew plugins built for Mac M1 processors
Shell
12
star
6

extphp

This is the ExtPHP wrapper I wrote before ExtJS changed license.
11
star
7

CActor

The Actor Model for Plain Old C
C
11
star
8

crystalvault

A zero-knowledge server to store and share secrets: credentials, keys, etc.
HTML
9
star
9

Twitterified

The Twitterified Client, fully open-sourced
ActionScript
9
star
10

s2ajax

The awesome Sajax for Python/PHP, but for Python, including 3.0, and PHP5, with objects support.
PHP
7
star
11

SuperBomberGame

This is not a complete game, but small demo of how one could write a game loop in ReasonML.
Reason
6
star
12

sbase-for-android

Shell tools that suck less!
C
5
star
13

data.cr

A bumbling foray in immutable data structures land. In Crystal!
Crystal
5
star
14

ztncli

A companion CLI for Key Network's ztncui ZeroTier controller interface
Shell
5
star
15

crafty-things

A CraftX Extension
TypeScript
5
star
16

applekeyboarddriver

A laptop/PS2 keyboard driver for recalcitrant laptops/desktops running Leopard...er Darwin
C++
4
star
17

modernfbv

Go
4
star
18

mailbiter

Go
3
star
19

n2

n2: More ketchup.
PHP
3
star
20

NativeTools

C++
3
star
21

wekanapi

A standalone API for Wekan
Crystal
2
star
22

BambooGarden

Using RootTools' new Java interfaces, handle multiple notebooks in Wacom's Bamboo Paper
Java
2
star
23

U-Must-Sync

Currently, non-functional code to synchronize Toodledo and The Hit List
2
star
24

crystal-pack

A partial implementation of pack() and unpack() for the Crystal language
Crystal
2
star
25

reasonable-fidelity

Replay recorded web sessions, check for fidelity
Python
2
star
26

lenses

PHP Framework
PHP
2
star
27

shl

Execute from shell some commands that query online services
Go
1
star
28

php-error-reporter

Display stack traces, variables states, and will try to notify you
1
star
29

CFRAnimated

A "compressed time" animation library for Android (currently Canvas)
Java
1
star
30

ezedit

Edit any web page. Easily. Very very easily.
PHP
1
star
31

glauth-qr-code-rust

Rust
1
star
32

mezzanine-mollom

Mollom SPAM filter for Mezzanine CMS
Python
1
star
33

awesome-supervisor

A curated list of supervisor(d) configurations, etc
Shell
1
star
34

cfr_minimal_shell

This is my minimal shell tarball. Use it if you must, but it's not an actual project.
Vim Script
1
star
35

slotmachine

Find a free slot in a slice, quick, in Go
Go
1
star
36

php-migrate

A migration tool, relying on YAML syntax, for your PHP projects
1
star
37

crystal-block

Highlight matching Crystal block in Atom editor
CoffeeScript
1
star