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
这是什么?libui 是一个用 C 语言编写的可移植图形界面(GUI)库,它在各平台上使用各自原生的 GUI 工具包(Windows 上为 Win32,Unix/Linux 上为 GTK+,Mac OS X 上为 Cocoa),让应用在所有平台上都具有原生的外观和操作体验。
这是一个现成的应用,还是我用来构建图形界面的库?它是一个 C 语言库,你可以将它链接到自己的程序中,用来构建窗口、按钮和其他原生控件;它本身不是独立的应用程序。
我该如何构建和安装 libui?libui 使用 Meson 构建系统:运行标准的 Meson 配置命令,再用 Ninja 等后端进行构建;之后也可以选择使用 Meson 的安装功能从源码安装。在 Arch Linux 上,也可以通过 AUR 安装。
构建之前需要先安装什么?你需要 Meson 0.48.0+ 以及一个后端(推荐 Ninja);在 Windows 上需要 Visual Studio 2013+ 或 MinGW-w64;在 Unix 上需要 GTK+ 3.10+;在 Mac OS X 上需要能够构建 Cocoa 程序的环境(OS X 10.8+)。
libui 目前的成熟度和稳定性如何?作者称其为 alpha 中期阶段的软件:示例和小型程序运行尚可,但许多功能仍然缺失,例如树形控件、剪贴板/拖放、打印、无障碍功能以及基于文档的程序;文档也不完整,部分功能在某些平台上存在 bug。
它可以在哪些操作系统上运行?Windows(Vista SP2 加 Platform Update 或更新版本)、带有 GTK+ 3.10+ 的 Unix/Linux,以及 Mac OS X 10.8 或更新版本。
除了 C 语言,我能在其他语言中使用 libui 吗?可以。libui 最初是 Go 语言绑定 package ui 的后端,社区还为 C++、C#、Python、Rust、Node.js、Swift、Kotlin 等语言维护了许多第三方绑定。
我可以构建动态库还是静态库?两者都支持,可通过 Meson 的 --default-library 选项进行选择(shared 或 static),但由于不同目标类型的构建过程不同,你需要在构建时就确定其中一种。
为什么在终端中运行 libui 应用时,它会在 macOS 上于后台启动?因为直接运行可执行文件会绕过 macOS 的 Launch Services,而 Launch Services 通常负责应用的激活;通过 Launch Services 启动(例如通过打包好的 .app)就可以避免这个问题。
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