- Notifications
You must be signed in to change notification settings - Fork74
Rust bindings to the minimalist, native, cross-platform UI toolkit `libui`
License
Apache-2.0, MIT licenses found
Licenses found
rust-native-ui/libui-rs
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
iui
is a simple, small, easy to distribute GUI library, a Rusty user interface library that binds to platform native APIs.These are work-in-progress bindings to the minimalistic native UI library [libui][libui] via theui-sys
bindings crate.
Addiui
to your project with:
iui ="0.3"
This repository contains multiple Rust crates. Also be sure to look at ourchangelog and learnhow to contribute.
iui
is the safe Rust wrapper, to be used by most users.ui-sys
is the raw unsafe bindings to thelibui
C code. Requirescmake
so it can buildlibui
.libui
is included as a submodule.
Based on work by@pcwalton. Licensed MIT.
externcrate iui;use iui::prelude::*;use iui::controls::{Label,Button,VerticalBox,Group};fnmain(){// Initialize the UI librarylet ui =UI::init().expect("Couldn't initialize UI library");// Create a window into which controls can be placedletmut win =Window::new(&ui,"Test App",200,200,WindowType::NoMenubar);// Create a vertical layout to hold the controlsletmut vbox =VerticalBox::new(&ui); vbox.set_padded(&ui,true);letmut group_vbox =VerticalBox::new(&ui);letmut group =Group::new(&ui,"Group");// Create two buttons to place in the windowletmut button =Button::new(&ui,"Button"); button.on_clicked(&ui,{let ui = ui.clone();move |btn|{ btn.set_text(&ui,"Clicked!");}});letmut quit_button =Button::new(&ui,"Quit"); quit_button.on_clicked(&ui,{let ui = ui.clone();move |_|{ ui.quit();}});// Create a new label. Note that labels don't auto-wrap!letmut label_text =String::new(); label_text.push_str("There is a ton of text in this label.\n"); label_text.push_str("Pretty much every unicode character is supported.\n"); label_text.push_str("🎉 用户界面 사용자 인터페이스");let label =Label::new(&ui,&label_text); vbox.append(&ui, label,LayoutStrategy::Stretchy); group_vbox.append(&ui, button,LayoutStrategy::Compact); group_vbox.append(&ui, quit_button,LayoutStrategy::Compact); group.set_child(&ui, group_vbox); vbox.append(&ui, group,LayoutStrategy::Compact);// Actually put the button in the window win.set_child(&ui, vbox);// Show the window win.show(&ui);// Run the application ui.main();}
ui-sys
includeslibui
as a sub-module and allows it to be built on-the-fly with thedefault featuresfetch
andbuild. With
fetch disabled, it will simply build theexisting sources without updating them, and withbuild
disabled it will build nothing,assuming either a system or local (in./lib/
) version oflibui
is available.
Note thatmost of the time, buildinglibui
on the fly is what you want. It does howeverrequire a copy of cmake, essential build tools, et cetera.
About
Rust bindings to the minimalist, native, cross-platform UI toolkit `libui`
Resources
License
Apache-2.0, MIT licenses found
Licenses found
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.