swoop_ui/button/
v_button.rs

1use bevy_ecs::prelude::*;
2use bevy_ui::prelude::*;
3
4use crate::View;
5use crate::border::{BorderStyle, BorderView};
6use crate::prelude::{BackgroundStyle, BackgroundView, StackView};
7use crate::shadow::ShadowView;
8
9#[derive(Bundle, Debug, Clone)]
10pub struct VButton {
11    name: Name,
12    node: Node,
13    botton: Button,
14    border: BorderStyle,
15    background: BackgroundStyle,
16    shadow: BoxShadow,
17}
18
19impl Default for VButton {
20    fn default() -> Self {
21        Self {
22            name: Name::new("SwoopButton"),
23            node: Node {
24                display: Display::Flex,
25                flex_direction: FlexDirection::Column,
26                justify_content: JustifyContent::Center,
27                align_items: AlignItems::Center,
28                row_gap: Val::Px(0.0),
29                ..Default::default()
30            },
31            botton: Button,
32            border: BorderStyle::button(),
33            background: BackgroundStyle::button(),
34            shadow: BoxShadow::default(),
35        }
36    }
37}
38
39impl View for VButton {
40    fn name_node(&mut self) -> &mut Name {
41        &mut self.name
42    }
43
44    fn node_node(&mut self) -> &mut Node {
45        &mut self.node
46    }
47}
48
49impl StackView for VButton {}
50
51impl BackgroundView for VButton {
52    fn background_node(&mut self) -> &mut BackgroundStyle {
53        &mut self.background
54    }
55}
56
57impl BorderView for VButton {
58    fn border_node(&mut self) -> &mut BorderStyle {
59        &mut self.border
60    }
61}
62
63impl ShadowView for VButton {
64    fn shadow_node(&mut self) -> &mut BoxShadow {
65        &mut self.shadow
66    }
67}