1use crate::components::{Style, Node, BackgroundColor, Interaction};
2
3#[derive(Default)]
5pub struct NodeBundle {
6 pub style: Style,
8 pub node: Node,
10 pub background_color: BackgroundColor,
12}
13
14impl gizmo_core::component::Bundle for NodeBundle {
15 fn get_infos() -> Vec<gizmo_core::archetype::ComponentInfo> {
16 vec![
17 gizmo_core::archetype::ComponentInfo::of::<Style>(),
18 gizmo_core::archetype::ComponentInfo::of::<Node>(),
19 gizmo_core::archetype::ComponentInfo::of::<BackgroundColor>(),
20 ]
21 }
22
23 fn apply(self, world: &mut gizmo_core::world::World, entity: gizmo_core::entity::Entity) {
24 world.add_component(entity, self.style);
25 world.add_component(entity, self.node);
26 world.add_component(entity, self.background_color);
27 }
28
29 unsafe fn write_to_archetype(
30 self,
31 arch: &mut gizmo_core::archetype::Archetype,
32 row: usize,
33 tick: u32,
34 ) {
35 self.style.write_to_archetype(arch, row, tick);
36 self.node.write_to_archetype(arch, row, tick);
37 self.background_color.write_to_archetype(arch, row, tick);
38 }
39}
40
41#[derive(Default)]
43pub struct ButtonBundle {
44 pub style: Style,
46 pub node: Node,
48 pub background_color: BackgroundColor,
50 pub interaction: Interaction,
52}
53
54impl gizmo_core::component::Bundle for ButtonBundle {
55 fn get_infos() -> Vec<gizmo_core::archetype::ComponentInfo> {
56 vec![
57 gizmo_core::archetype::ComponentInfo::of::<Style>(),
58 gizmo_core::archetype::ComponentInfo::of::<Node>(),
59 gizmo_core::archetype::ComponentInfo::of::<BackgroundColor>(),
60 gizmo_core::archetype::ComponentInfo::of::<Interaction>(),
61 ]
62 }
63
64 fn apply(self, world: &mut gizmo_core::world::World, entity: gizmo_core::entity::Entity) {
65 world.add_component(entity, self.style);
66 world.add_component(entity, self.node);
67 world.add_component(entity, self.background_color);
68 world.add_component(entity, self.interaction);
69 }
70
71 unsafe fn write_to_archetype(
72 self,
73 arch: &mut gizmo_core::archetype::Archetype,
74 row: usize,
75 tick: u32,
76 ) {
77 self.style.write_to_archetype(arch, row, tick);
78 self.node.write_to_archetype(arch, row, tick);
79 self.background_color.write_to_archetype(arch, row, tick);
80 self.interaction.write_to_archetype(arch, row, tick);
81 }
82}