Crate boing

source ·
Expand description

A safe wrapper over libui-ng-sys.

Background

libui is a C library that provides a neutral interface to native GUI technologies (e.g., windows, widgets) on major OSes. libui-ng is the “next generation” of libui, developed and maintained separately. libui-ng-sys provides Rust bindings to libui-ng, and boing is a safe yet fairly unopinionated layer on top of libui-ng-sys.

Usage

To get started with boing, see the Ui struct.

Examples

let ui = Ui::new()?;

// Append a drop-down menu labeled "File" to the menubar of all windows created with
// `has_menubar` set to `true`; see [`Ui::create_window`] for more information.
let file_menu = ui.create_menu("File")?;
// Append a menu item labeled "Quit" (in English) to the previously-created file menu. This
// "Quit" item will exit the application when clicked.
file_menu.push_quit_item()?;

// Create a 200x200 pixel window titled "Hello World!" with a menubar that exits the application
// when closed.
let window = ui.create_window("Hello World!", 200u16, 200u16, true, true)?;
// Create a button labeled "Press Me!" and set it as the main child control of the
// previously-created window.
window.set_child(ui.create_pushbutton("Press Me!")?);
// Present the window to the user. Calling this method is necessary for the window to appear at
// all.
window.show();

// Enter the UI event loop. As [`Ui::run`] borrows immutably, this can be called again.
ui.run();

For more examples, including a control gallery, see the [boing-examples] crate.

Re-exports

pub use area::Area;
pub use color::Color;
pub use color::Picker as ColorPicker;
pub use font::Font;
pub use font::Picker as FontPicker;
pub use form::Form;
pub use crate::image::Image;
pub use menu::Menu;

Modules

Colors and color pickers.
Fonts and font pickers.
A user input form.
An RGBA image.
An application-wide drop-down menu within a menubar that may contain additional
Re-exported items from dependencies.

Structs

A series of controls aligned to a common line.
A togglable button with adjacent customizable text.
A drop-down menu of mutually-exclusive selectable items.
A type-erased control.
A tabular collection of controls.
A labeled container around a child control.
A text label.
An item within a Menu.
A box in which multiple lines of text are displayed.
The primary non-negative integer type used by libui-ng.
A horizontal bar that continuously fills as an action progresses.
A clickable button containing customizable text.
A set of mutually-exclusive selectable items.
A horizontal or vertical bar for separating content.
A box in which a single line of text is displayed.
A graphical user interface provided by libui-ng.
An application window.

Enums

The error type returned by fallible boing functions.

Traits

A control that contains other controls.
A graphical element.