Skip to content

Commit 96cb829

Browse files
committed
0.1.0 release!
1 parent 74182bf commit 96cb829

File tree

2 files changed

+108
-10
lines changed

2 files changed

+108
-10
lines changed

README.md

Lines changed: 68 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,76 @@
1-
# libUI
1+
# The Improved User Interface Crate
22
[![libui-rs build status](https://api.travis-ci.org/LeoTindall/libui-rs.svg?branch=master)](https://travis-ci.org/LeoTindall/libui-rs/)
33

4-
A Rusty user interface library that binds to platform native APIs.
5-
These are work-in-progress Rust bindings to the minimalistic native UI library [libui][libui].
4+
`iui` is a simple, small, easy to distribute GUI library, a Rusty user interface library that binds to platform native APIs.
5+
These are work-in-progress bindings to the minimalistic native UI library [libui][libui].
66

7-
## Building
8-
`libui` is included as a submodule. You will need CMake to build `libui` itself;
9-
after that, Cargo should be able to take care of the build process.
7+
Add this to your crate with:
108

11-
Based on work by @pcwalton
9+
```
10+
iui = "0.1.0"
11+
```
1212

13-
[libui]: https://github.com/andlabs/libui
13+
## Example
14+
15+
```
16+
extern crate iui;
17+
use iui::prelude::*;
18+
use iui::controls::{VerticalBox, MultilineEntry, Button};
19+
use std::io::prelude::*;
20+
use std::error::Error;
21+
use std::fs::File;
22+
23+
fn main() {
24+
// Initialize the UI
25+
let ui = UI::init().unwrap();
26+
27+
// Create the input controls
28+
let entry = MultilineEntry::new(&ui);
29+
let button = Button::new(&ui, "Save Buffer");
30+
31+
// Set up the application's layout
32+
let window = Window::new(&ui, "Save Buffer to File", 640, 480, WindowType::NoMenubar);
33+
let vbox = VerticalBox::new(&ui);
34+
vbox.append(&ui, entry.clone(), LayoutStrategy::Stretchy);
35+
vbox.append(&ui, button.clone(), LayoutStrategy::Compact);
36+
window.set_child(&ui, vbox);
37+
window.show(&ui);
38+
39+
// When the button is clicked, get the name of a file and then write the entry's contents to it.
40+
// Note the in real code you should spin off a thread to do the actual writing, do it between UI events,
41+
// or use Tokio. Even with minmal content, this method shows noticable lag.
42+
button.on_clicked(&ui, {
43+
let ui = ui.clone();
44+
move |_| {
45+
if let Some(path) = window.save_file(&ui) {
46+
let mut file = match File::create(&path) {
47+
Err(why) => { window.modal_err(&ui, "I/O Error", &format!("Could not open file {}: {}", path.display(), why.description())); return; }
48+
Ok(f) => f
49+
};
50+
match file.write_all(entry.value(&ui).as_bytes()) {
51+
Err(why) => { window.modal_err(&ui, "I/O Error", &format!("Could not write to file {}: {}", path.display(), why.description())); return; }
52+
Ok(_) => ()
53+
};
54+
}
55+
}
56+
});
1457
15-
# Testing Note
58+
ui.main();
59+
}
60+
```
1661

62+
## Organization
63+
64+
`iui` is the safe Rust wrapper, to be used by most users.
65+
`ui` is the old version of the safe wrapper. Don't use this.
66+
`ui-sys` is the raw unsafe bindings to the `libui` C code. Requires `cmake` so it can build `libui`.
67+
68+
## Building
69+
`libui` is included as a submodule. You will need CMake to build `libui` itself.
70+
71+
Based on work by @pcwalton. Licensed MIT.
72+
73+
## Testing Note
1774
Travis does not connect video devices to their testing environments, so the tests cannot be run. Therefore, the "tests" only check compilation.
75+
76+
[libui]: https://github.com/andlabs/libui

iui/Cargo.toml

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,48 @@ name = "iui"
33
version = "0.1.0"
44
authors = ["Leo Tindall <[email protected]>"]
55

6+
# A short blurb about the package. This is not rendered in any format when
7+
# uploaded to crates.io (aka this is not markdown).
8+
description = "Simple, small, easy to distribute GUI bindings."
9+
10+
# These URLs point to more information about the package. These are
11+
# intended to be webviews of the relevant data, not necessarily compatible
12+
# with VCS tools and the like.
13+
documentation = "https://docs.rs/iui/"
14+
repository = "https://github.com/LeoTindall/libui-rs"
15+
16+
# This points to a file under the package root (relative to this `Cargo.toml`).
17+
# The contents of this file are stored and indexed in the registry.
18+
# crates.io will render this file and place the result on the crate's page.
19+
readme = "../README.md"
20+
21+
# This is a list of up to five keywords that describe this crate. Keywords
22+
# are searchable on crates.io, and you may choose any words that would
23+
# help someone find this crate.
24+
keywords = ["windows", "gtk", "gui", "user interface", "macos"]
25+
26+
# This is a list of up to five categories where this crate would fit.
27+
# Categories are a fixed list available at crates.io/category_slugs, and
28+
# they must match exactly.
29+
categories = ["gui", "os::macos-apis", "os::unix-apis", "os::windows-apis"]
30+
license = "MIT"
31+
32+
[badges]
33+
# Travis CI: `repository` in format "<user>/<project>" is required.
34+
# `branch` is optional; default is `master`
35+
travis-ci = { repository = "LeoTindall/libui-rs", branch = "master" }
36+
37+
# Is it maintained resolution time: `repository` is required.
38+
is-it-maintained-issue-resolution = { repository = "LeoTindall/libui-rs" }
39+
40+
# Is it maintained percentage of open issues: `repository` is required.
41+
is-it-maintained-open-issues = { repository = "LeoTindall/libui-rs" }
42+
43+
maintenance = { status = "actively-developed" }
44+
645
[dependencies]
746
bitflags = "0.7"
8-
libc = "*"
47+
libc = "0.2"
948
failure = "0.1.1"
1049

1150
[dependencies.ui-sys]

0 commit comments

Comments
 (0)