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