Expand description
libui
is a simple, small and easy to distribute GUI library. It provides a native UI for your platform by utilising your systems API instead of implementing yet another mismatched looking renderer.
Technically, libui
is a “rustification” wrapper over the C library libui-ng
, which actually abstracts the native GUI framework. That is the Win32 API on Windows, Cocoa on Mac OS X, and GTK3 for Linux and others.
Add libui
to your dependency list with:
libui = { git = "https://github.com/libui-rs/libui" }
Next we suggest to have a look at the example applications or start with the minimal example printed here:
#![cfg_attr(not(test), windows_subsystem = "windows")]
#![cfg_attr(test, windows_subsystem = "console")]
extern crate libui;
use libui::controls::*;
use libui::prelude::*;
fn main() {
let ui = UI::init()
.expect("Couldn't initialize UI library");
let mut win = Window::new(&ui, "Example", 300, 200,
WindowType::NoMenubar);
let layout = VerticalBox::new();
// add controls to your layout here
win.set_child(layout);
win.show();
ui.main();
}
Modules§
- controls
- Available user interface controls and related functionality.
- draw
- Functions and types related to 2D vector graphics.
- menus
- Menus that appear at the top of windows, and the items that go in them.
- prelude
- Common imports are packaged into this module. It’s meant to be glob-imported:
use libui::prelude::*
. - str_
tools - Tools for making platform-independent string handling work properly.
Macros§
- layout
- Creates layout code from a compact, declarative and hierarchical UI description.
- menu
- Creates menu entries for the applications main menu from a hierarchical description.
Structs§
- Event
Loop - Provides fine-grained control over the user interface event loop, exposing the
on_tick
event which allows integration with other event loops, custom logic on event ticks, etc. Be aware the Cocoa (GUI toolkit on Mac OS) requires that the first thread spawned controls the UI, so do not spin off your UI interactions into an alternative thread. You’re likely to have problems on Mac OS. - Event
Queue - The struct to enqueue a closure from another thread
- Event
Queue With Data - The struct to enqueue a closure from another thread,
with holding data that is
!Send
. - UI
- A handle to user interface functionality.
Enums§
- UIError
- The error type returned by functions in this crate which might fail.