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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//! Crabshell's widgets, styles, layout, text layout, hit testing and
//! invalidation.
//!
//! A bar is described with widgets and turned into a live [`Window`]:
//!
//! ```
//! use crabshell_reactive::Runtime;
//! use crabshell_ui::prelude::*;
//!
//! const BAR: Style = Style::new()
//! .background(Color::rgb(0x1e, 0x1e, 0x2e))
//! .color(Color::rgb(0xcd, 0xd6, 0xf4));
//!
//! let runtime = Runtime::current();
//! let cx = Cx::new(runtime.new_owner());
//! let count = cx.signal(0);
//!
//! let bar = PanelWindow::new(&Output::new("DP-1"))
//! .anchors(Edge::Top | Edge::Left | Edge::Right)
//! .height(30)
//! .style(BAR)
//! .child(
//! Row::new().gap(8).padding(4, 8).child(
//! Button::new(Text::new(move || format!("clicked {} times", count.get())))
//! .on_click(move |_cx| count.update(|n| *n += 1)),
//! ),
//! );
//!
//! // The platform does the rest once per event-loop iteration.
//! let window = Window::new(&cx, bar);
//! let mut text = TextSystem::new();
//! window.set_size(Size::new(1920.0, 30.0));
//! runtime.flush(); // bindings run
//! window.layout(&mut text);
//! let _damage = window.take_damage(); // what the renderer repaints
//! ```
//!
//! # How it fits together
//!
//! - Widgets are descriptions. [`Window::new`] turns them into a tree of
//! nodes, each with its own reactive owner. A property given a closure
//! becomes an effect that writes the node when a signal it read changes.
//! - Each property is a layout property (text, font, padding, gap, size,
//! children) or a paint property (colors, background, border, opacity,
//! radius). A paint change records the widget's area as damage. A layout
//! change marks the window for [`Window::layout`], which records the old
//! and new area of every widget that moved or changed.
//! - [`TextSystem`] loads only the fonts fontconfig matches for the families
//! styles name, plus fallbacks for missing characters. Each `Text` keeps
//! one cosmic-text buffer that layout measures and the renderer draws.
//! - Pointer events go to [`Window::pointer_motion`] and friends. Hit testing
//! finds the deepest [`Button`] under the pointer, and its handlers run
//! with no borrow held, inside `catch_unwind`.
//! - Dropping a [`Window`] disposes its owner, freeing every node, binding
//! and handler it made.
pub use Cx;
pub use ;
pub use ;
pub use ;
pub use PopupWindow;
pub use ;
pub use ;
pub use TextSystem;
pub use ;
pub use ;
pub use ;
/// What a bar's code needs, in one `use`.