libui README

The project's README from github.com/andlabs/libui. As one markdown file: README.md.

libui: a portable GUI library for C

This README is being written.
Build Status, Azure Pipelines
Build Status, AppVeyor

Status

It has come to my attention that I have not been particularly clear about how usable or feature-complete libui is, and that this has fooled many people into expecting more from libui right this moment than I have explicitly promised to make available. I apologize for not doing this sooner.

libui is currently mid-alpha software. Much of what is currently present runs stabily enough for the examples and perhaps some small programs to work, but the stability is still a work-in-progress, much of what is already there is not feature-complete, some of it will be buggy on certain platforms, and there's a lot of stuff missing. In short, here's a list of features that I would like to add to libui, but that aren't in yet:

In addition, here is a list of issues generalizing existing problems.

Furthermore, libui is not properly fully documented yet. This is mainly due to the fact that the API was initially unstable enough so as to result in rewriting documentation multiple times, in addition to me not being happy with really any existing C code documentation tool. That being said, I have started to pin down my ideal code documentation style in parts of ui.h, most notably in the uiAttributedString APIs. Over time, I plan on extending this to the rest of the headers. You can also use the documentation for libui's Go bindings as a reference, though it is somewhat stale and not optimally written.

But libui is not dead; I am working on it whenever I can, and I hope to get it to a point of real quality soon!

News

Note that today's entry (Eastern Time) may be updated later today.

Old announcements can be found in the NEWS.md file.

Runtime Requirements

Build Requirements

Building

libui uses only the standard Meson build options, so a libui build can be set up just like any other:

$ # you must be in the top-level libui directory, otherwise this won't work
$ meson setup build [options]
$ ninja -C build

Once this completes, everything will be under build/meson-out/. (Note that unlike the previous build processes, everything is built by default, including tests and examples.)

The most important options are:

Most other built-in options will work, though keep in mind there are a handful of options that cannot be overridden because libui depends on them holding a specific value; if you do override these, though, libui will warn you when you run meson.

The Meson website and documentation has more in-depth usage instructions.

For the sake of completeness, I should note that the default value of --layout is flat, not the usual mirror. This is done both to make creating the release archives easier as well as to reduce the chance that shared library builds will fail to start on Windows because the DLL is in another directory. You can always specify this manually if you want.

Backends other than ninja should work, but are untested by me.

Installation

Meson also supports installing from source; if you use Ninja, just do

$ ninja -C build install

When running meson, the --prefix option will set the installation prefix. The Meson documentation has more information, and even lists more fine-grained options that you can use to control the installation.

Arch Linux

Can be built from AUR: https://aur.archlinux.org/packages/libui-git/

Documentation

Needs to be written. Consult ui.h and the examples for details for now.

Language Bindings

libui was originally written as part of my package ui for Go. Now that libui is separate, package ui has become a binding to libui. As such, package ui is the only official binding.

Other people have made bindings to other languages:

Language Bindings
C++ libui-cpp, cpp-libui-qtlike
C# / .NET Framework LibUI.Binding
C# / .NET Core DevZH.UI, SharpUI, TCD.UI
CHICKEN Scheme wasamasa/libui
Common Lisp jinwoo/cl-ui
Crystal libui.cr, hedron
D DerelictLibui (flat API), libuid (object-oriented)
Euphoria libui-euphoria
Harbour hbui
Haskell haskell-libui
JavaScript/Node.js libui-node, libui.js (merged into libui-node?), proton-native, vuido
Julia Libui.jl
Kotlin kotlin-libui
Lua libuilua, libui-lua, lui, lui
Nim ui
Perl6 perl6-libui
PHP ui
Python pylibui
Ruby libui-ruby, libui
Rust libui-rs
Scala scalaui
Swift libui-swift

Frequently Asked Questions

Why does my program start in the background on OS X if I run from the command line?

OS X normally does not start program executables directly; instead, it uses Launch Services to coordinate the launching of the program between the various parts of the system and the loading of info from an .app bundle. One of these coordination tasks is responsible for bringing a newly launched app into the foreground. This is called "activation".

When you run a binary directly from the Terminal, however, you are running it directly, not through Launch Services. Therefore, the program starts in the background, because no one told it to activate! Now, it turns out there is an API that we can use to force our app to be activated. But if we use it, then we'd be trampling over Launch Services, which already knows whether it should activate or not. Therefore, libui does not step over Launch Services, at the cost of requiring an extra user step if running directly from the command line.

See also this and this.

Contributing

See CONTRIBUTING.md.

Screenshots

From examples/controlgallery:

Windows

Unix

OS X

libui (andlabs/libui)

Searching Database…

10.9K ·GitHub
What is this?libui is a portable GUI library written in C that uses each platform's native GUI toolkit (Win32 on Windows, GTK+ on Unix/Linux, Cocoa on Mac OS X) so apps look and feel native everywhere.
Is this a ready-made app, or a library I build GUIs with?It is a C library you link into your own program to build windows, buttons, and other native controls; it is not a standalone application.
How do I build and install libui?libui uses the Meson build system: run the standard Meson setup and build it with a backend like Ninja, then optionally install from source with Meson's install support; on Arch Linux it's also available via the AUR.
What do I need installed before building it?You need Meson 0.48.0+ with a backend (Ninja recommended); on Windows, Visual Studio 2013+ or MinGW-w64; on Unix, GTK+ 3.10+; on Mac OS X, the ability to build Cocoa programs (OS X 10.8+).
How finished and stable is libui right now?The author describes it as mid-alpha software: examples and small programs run reasonably well, but many features like trees, clipboard/drag-and-drop, printing, accessibility, and document-based programs are missing, documentation is incomplete, and some things are buggy on certain platforms.
Which operating systems does it run on?Windows (Vista SP2 with Platform Update or newer), Unix/Linux with GTK+ 3.10+, and Mac OS X 10.8 or newer.
Can I use libui from languages other than C?Yes, libui originated as the backend for a Go binding called package ui, and the community maintains many third-party bindings for languages like C++, C#, Python, Rust, Node.js, Swift, Kotlin, and more.
Can I build a shared or a static library?Both are supported via the Meson --default-library option (shared or static), though you must pick one at build time since the build process differs by target type.
Why does a libui app launch in the background on macOS when run from the Terminal?Because running the binary directly bypasses macOS Launch Services, which normally handles app activation; launching through Launch Services (e.g. via a bundled .app) avoids this.
What are similar projects?flatbuffers, hello-algo, quicktype, antlr4, iced, qt, supertonic, gpui-kit
Which topics is it in?gui-framework, kotlin, csharp, golang, swift, c, cpp, ui, desktop, rust, gui, library
Creator
andlabs
Size
6.2 MB
Stars
10.9K
Updated
CommitJan 02
Age
11y
Commits · 90 Days