Skip to main content

gizmo_ui/
lib.rs

1pub mod components;
2pub mod layout;
3pub mod system;
4pub mod interaction;
5pub mod bundles;
6
7use gizmo_app::{App, Plugin};
8use gizmo_core::system::IntoSystemConfig;
9pub use components::*;
10pub use bundles::*;
11pub use layout::*;
12
13pub struct UiPlugin;
14
15impl<State: 'static> Plugin<State> for UiPlugin {
16    fn build(&self, app: &mut App<State>) {
17        app.world.register_component_type::<Style>();
18        app.world.register_component_type::<Node>();
19        app.world.register_component_type::<Interaction>();
20        app.world.register_component_type::<BackgroundColor>();
21        app.world.register_component_type::<UiRoot>();
22
23        app.world.insert_resource(UiContext::new());
24
25        app.schedule.add_di_system(
26            system::ui_layout_system
27                .into_config()
28                .label("ui_layout"),
29        );
30        app.schedule.add_di_system(
31            interaction::ui_interaction_system
32                .into_config()
33                .label("ui_interaction")
34                .after("ui_layout"),
35        );
36    }
37}
38
39pub mod prelude {
40    pub use crate::{
41        components::{Style, Node, Interaction, BackgroundColor, UiRoot},
42        bundles::{NodeBundle, ButtonBundle},
43        UiPlugin,
44    };
45    pub use taffy::style::*;
46    pub use taffy::geometry::*;
47}