swoop_ui/container/stack/
v_stack.rs

1use bevy_ecs::prelude::*;
2use bevy_ui::prelude::*;
3
4use crate::View;
5use crate::background::{BackgroundStyle, BackgroundView};
6use crate::border::{BorderStyle, BorderView};
7use crate::prelude::PositionView;
8use crate::shadow::BoxShadowView;
9
10use super::StackView;
11
12/// A vertical stack layout container that arranges children in a column.
13/// Implements background and border styling, and conforms to StackContainer behavior.
14#[derive(Bundle, Debug, Clone)]
15pub struct VStack {
16    /// The name component used to identify the UI node
17    name: Name,
18    /// The layout node controlling size, flex direction, spacing, etc.
19    node: Node,
20    /// Border rendering style (color and radius)
21    border: BorderStyle,
22    /// Background rendering style (color or image)
23    background: BackgroundStyle,
24    /// Shadow rendering style (Vec<ShadowStyle>)
25    shadow: BoxShadow,
26}
27
28impl Default for VStack {
29    fn default() -> Self {
30        Self {
31            name: Name::new("VStack"),
32            node: Node {
33                display: Display::Flex,
34                flex_direction: FlexDirection::Column,
35                justify_content: JustifyContent::Start,
36                align_items: AlignItems::Center,
37                row_gap: Val::Px(0.0),
38                ..Default::default()
39            },
40            border: BorderStyle::default(),
41            background: BackgroundStyle::default(),
42            shadow: BoxShadow::default(),
43        }
44    }
45}
46
47impl View for VStack {
48    fn name_node(&mut self) -> &mut Name {
49        &mut self.name
50    }
51
52    fn node_node(&mut self) -> &mut Node {
53        &mut self.node
54    }
55}
56
57impl StackView for VStack {}
58
59impl BackgroundView for VStack {
60    fn background_node(&mut self) -> &mut BackgroundStyle {
61        &mut self.background
62    }
63}
64
65impl BorderView for VStack {
66    fn border_node(&mut self) -> &mut BorderStyle {
67        &mut self.border
68    }
69}
70
71impl BoxShadowView for VStack {
72    fn box_shadow_node(&mut self) -> &mut BoxShadow {
73        &mut self.shadow
74    }
75}
76
77impl PositionView for VStack {}