bevy_basic_ui/
components.rs1use bevy::prelude::*;
2
3use super::styles::{get_button_text_styles, BASIC_BUTTON_STYLE, NORMAL_BUTTON_COLOR};
4
5#[derive(Component)]
6pub struct UiMainRootNode;
7
8#[derive(Component)]
9pub struct UiFooterRootNode;
10
11#[derive(Component)]
12pub struct UiCamera;
13
14#[derive(Component)]
15pub struct Screen;
16
17#[derive(Component)]
18pub struct RespawnButton;
19
20#[derive(Component)]
21pub struct QuitButton;
22
23#[derive(Component)]
24pub struct SettingsButton;
25
26#[derive(Bundle)]
27pub struct BasicButtonBundle {
28 button: ButtonBundle,
29}
30
31#[derive(Bundle)]
32pub struct ButtonTextBundle {
33 button_text: TextBundle,
34}
35
36impl BasicButtonBundle {
37 pub fn new() -> Self {
38 Self {
39 button: ButtonBundle {
40 style: BASIC_BUTTON_STYLE,
41 background_color: NORMAL_BUTTON_COLOR.into(),
42 ..default()
43 },
44 }
45 }
46}
47
48impl ButtonTextBundle {
49 pub fn new(text: String, asset_server: &Res<AssetServer>) -> Self {
50 Self {
51 button_text: TextBundle {
52 text: Text {
53 sections: vec![TextSection::new(
54 text,
55 get_button_text_styles(&asset_server),
56 )],
57 justify: JustifyText::Center,
58 ..default()
59 },
60 ..default()
61 },
62 }
63 }
64}