1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//! cpux is a retained-mode GUI framework.
//! It is meant to be simple to use and lightweight,
//! using very little CPU when idle.
//!
//! # Example
//! _It might seem a bit complex, but the crate is quite
//! well documented_
//! ```no_run
//! use cpux::app::{App, AppContext};
//! use cpux::button::Button;
//! use cpux::layouts::Column;
//! use cpux::text::Text;
//! use cpux::load_font;
//!
//! fn main() {
//! let font = load_font("assets/arial.ttf");
//!
//! let mut app = App::new("cpux counter example", 600, 400);
//! let mut counter = 0;
//!
//! let text1 = Text::new("Hello, GUI!", font.clone()).with_size(32.0);
//! let text2 = Text::new("Count: 0", font.clone())
//! .with_id("counter_text");
//! let button = Button::new("Click Me", font.clone())
//! .with_id("add_button");
//!
//!
//! let column = Column::new()
//! .at(50, 50)
//! .with_spacing(25)
//! .add(text1)
//! .add(text2)
//! .add(button);
//!
//! app.set_root(column);
//!
//! app.run(move |ui: &mut AppContext| {
//! if ui.was_clicked("add_button") {
//! counter += 1;
//! if let Some(text_widget) = ui.find_widget_mut::<Text>("counter_text") {
//! text_widget.content = format!("Count: {}", counter);
//! }
//! }
//! });
//! }
//! ```
//!
/// Helper utility to load raw TrueType Font (`.ttf`) files into vector memory.
///
/// # Example
/// ```no_run
/// use cpux::load_font;
/// let font = load_font("assets/arial.ttf");
/// ```