#![allow(clippy::type_complexity)]
mod platform_impl;
use bevy::app::{App, Plugin};
use bevy::ecs::component::HookContext;
use bevy::ecs::world::DeferredWorld;
use bevy::prelude::{Component, Entity, Reflect, ReflectComponent, ReflectDefault, ReflectDeserialize, ReflectSerialize};
use serde::{Deserialize, Serialize};
#[allow(missing_docs)]
pub mod prelude {
pub use crate::ChildWindowPlugin;
pub use crate::ParentWindow;
}
pub struct ChildWindowPlugin;
impl Plugin for ChildWindowPlugin {
fn build(&self, app: &mut App) {
app
.register_type::<ParentWindow>()
.register_type::<UnInitializeWindow>()
.add_plugins(platform_impl::ChildWindowPlugin);
app
.world_mut()
.register_component_hooks::<ParentWindow>()
.on_add(|mut world: DeferredWorld, context: HookContext| {
world.commands().entity(context.entity).insert(UnInitializeWindow);
});
}
}
#[derive(Component, Reflect, Serialize, Deserialize)]
#[reflect(Component, Serialize, Deserialize)]
pub struct ParentWindow(pub Entity);
#[derive(Component, Reflect, Serialize, Deserialize, Default)]
#[reflect(Component, Serialize, Deserialize, Default)]
struct UnInitializeWindow;