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
//! Multi-surface example demonstrating multiple layer shell surfaces.
//!
//! This example shows how to create multiple surfaces at startup:
//! - A top status bar
//! - A bottom dock
//!
//! Both surfaces share the same reactive signals.
use guido::prelude::*;
fn main() {
App::new().run(|app| {
// Shared signal that can be updated from any surface
let count = create_signal(0);
app.add_surface(
// Top status bar
SurfaceConfig::new()
.height(32)
.anchor(Anchor::TOP | Anchor::LEFT | Anchor::RIGHT)
.layer(Layer::Top)
.namespace("status-bar")
.background_color(Color::rgb(0.1, 0.1, 0.15)),
move || {
container()
.height(fill())
.layout(
Flex::row()
.spacing(8.0)
.main_alignment(MainAlignment::SpaceBetween)
.cross_alignment(CrossAlignment::Center),
)
.padding([0.0, 16.0])
.child(
container().child(
text("Multi-Surface Demo")
.font_size(14.0)
.color(Color::WHITE),
),
)
.child(
container().child(
text(move || format!("Count: {}", count.get()))
.font_size(14.0)
.color(Color::WHITE),
),
)
},
);
// Bottom dock
app.add_surface(
SurfaceConfig::new()
.height(48)
.anchor(Anchor::BOTTOM | Anchor::LEFT | Anchor::RIGHT)
.layer(Layer::Top)
.namespace("dock")
.background_color(Color::rgb(0.15, 0.15, 0.2)),
move || {
container()
.height(fill())
.layout(Flex::row().spacing(16.0).center())
.children([
container()
.background(Color::rgb(0.3, 0.3, 0.4))
.padding([8.0, 16.0])
.corners(8.0)
.when_hovered(|s| s.lighter(0.1))
.when_pressed(|s| s.ripple())
.on_click(move || count.update(|c| *c += 1))
.child(text("+").font_size(16.0).color(Color::WHITE)),
container()
.background(Color::rgb(0.3, 0.3, 0.4))
.padding([8.0, 16.0])
.corners(8.0)
.when_hovered(|s| s.lighter(0.1))
.when_pressed(|s| s.ripple())
.on_click(move || count.update(|c| *c -= 1))
.child(text("-").font_size(16.0).color(Color::WHITE)),
container()
.background(Color::rgb(0.4, 0.2, 0.2))
.padding([8.0, 16.0])
.corners(8.0)
.when_hovered(|s| s.lighter(0.1))
.when_pressed(|s| s.ripple())
.on_click(move || count.set(0))
.child(text("Reset").font_size(16.0).color(Color::WHITE)),
])
},
);
});
}