swoop_ui/container/grid/
h_grid.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::GridView;
11
12/// A horizontal grid layout container that arranges children using `GridAutoFlow::Row`.
13/// Supports background and border styling as well as custom grid track configuration.
14#[derive(Bundle, Debug, Clone)]
15pub struct HGrid {
16    /// The name component used to identify the UI node
17    name: Name,
18    /// The layout node controlling grid behavior and spacing
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 HGrid {
29    fn default() -> Self {
30        Self {
31            name: Name::new("HGrid"),
32            node: Node {
33                display: Display::Grid,
34                grid_auto_flow: GridAutoFlow::Column,
35                justify_content: JustifyContent::Start,
36                align_items: AlignItems::Center,
37                column_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 HGrid {
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 GridView for HGrid {}
58
59impl BackgroundView for HGrid {
60    fn background_node(&mut self) -> &mut BackgroundStyle {
61        &mut self.background
62    }
63}
64
65impl BorderView for HGrid {
66    fn border_node(&mut self) -> &mut BorderStyle {
67        &mut self.border
68    }
69}
70
71impl BoxShadowView for HGrid {
72    fn box_shadow_node(&mut self) -> &mut BoxShadow {
73        &mut self.shadow
74    }
75}
76
77impl PositionView for HGrid {}