1use bevy::{prelude::*, text::FontSourceTemplate};
3
4fn main() {
5 App::new()
6 .add_plugins(DefaultPlugins)
7 .add_systems(Startup, scene.spawn())
8 .run();
9}
10
11fn scene() -> impl SceneList {
12 bsn_list![Camera2d, ui()]
13}
14
15fn ui() -> impl Scene {
16 bsn! {
17 Node {
18 width: percent(100),
19 height: percent(100),
20 align_items: AlignItems::Center,
21 justify_content: JustifyContent::Center,
22 column_gap: px(5),
23 }
24 Children [
25 (
26 button("Ok")
27 on(|_event: On<Pointer<Press>>| println!("Ok pressed!"))
28 ),
29 (
30 button("Cancel")
31 on(|_event: On<Pointer<Press>>| println!("Cancel pressed!"))
32 BackgroundColor(Color::srgb(0.4, 0.15, 0.15))
33 ),
34 ]
35 }
36}
37
38fn button(label: &str) -> impl Scene {
39 bsn! {
40 Button
41 Node {
42 width: px(150),
43 height: px(65),
44 border: px(5),
45 border_radius: BorderRadius::MAX,
46 justify_content: JustifyContent::Center,
47 align_items: AlignItems::Center,
48 }
49 BorderColor::from(Color::BLACK)
50 BackgroundColor(Color::srgb(0.15, 0.15, 0.15))
51 Children [(
52 Text(label)
53 TextFont {
54 font: FontSourceTemplate::Handle("fonts/FiraSans-Bold.ttf"),
55 font_size: px(33.0),
56 }
57 TextColor(Color::srgb(0.9, 0.9, 0.9))
58 TextShadow
59 )]
60 }
61}