#![allow(clippy::too_many_arguments)]
#![allow(clippy::type_complexity)]
use bevy::app::{App, Plugin, PostUpdate, PreUpdate};
use bevy::ecs::schedule::SystemSet;
use bevy::picking::PickingSystems;
use bevy::prelude::IntoScheduleConfigs;
use bevy::transform::TransformSystems;
use layout::{Container, LayoutControl};
mod hierarchy;
pub mod layout;
mod picking;
mod pipeline;
mod rect;
#[cfg(feature = "2d")]
mod sync_sprite;
mod tooltip;
mod transform;
#[cfg(feature = "window")]
mod window;
pub use hierarchy::*;
use picking::rectray_picking_backend;
pub use picking::RectrayPickable;
pub use pipeline::compute_transform_2d;
pub use rect::{Anchor, RotatedRect};
pub use tooltip::{AnchorDirection, OutOfFrameBehavior};
pub use transform::{Dimension, InterpolateTransform, SyncDimension, Transform2D};
#[cfg(feature = "window")]
pub use window::{RectrayCursor, RectrayWindow};
#[derive(Debug, Clone, Copy)]
pub struct RectrayPlugin;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, SystemSet)]
pub struct RectrayTransformSet;
impl Plugin for RectrayPlugin {
fn build(&self, app: &mut App) {
app.register_type::<Transform2D>();
app.register_type::<Dimension>();
app.register_type::<Container>();
app.register_type::<RotatedRect>();
app.register_type::<LayoutControl>();
app.register_type::<SyncDimension>();
app.configure_sets(
PostUpdate,
RectrayTransformSet.before(TransformSystems::Propagate),
);
app.add_systems(
PreUpdate,
rectray_picking_backend.in_set(PickingSystems::Backend),
);
app.add_systems(PostUpdate, compute_transform_2d.in_set(RectrayTransformSet));
#[cfg(feature = "window")]
app.add_systems(
PostUpdate,
window::window_frame_system
.in_set(RectrayTransformSet)
.before(compute_transform_2d),
);
#[cfg(feature = "2d")]
app.add_plugins(sync_sprite::SyncSpritePlugin);
}
}
#[allow(deprecated)]
mod bundles {
use bevy::prelude::Bundle;
use crate::{
layout::{Container, LayoutControl},
Dimension, RotatedRect, Transform2D,
};
#[derive(Debug, Default, Bundle)]
#[deprecated = "Add `Transform2D` and `Dimension` (optional) directly."]
pub struct RectrayBundle {
pub transform_2d: Transform2D,
pub dimension: Dimension,
pub layout: LayoutControl,
pub rotated_rect: RotatedRect,
}
#[derive(Debug, Default, Bundle)]
#[deprecated = "Add `Transform2D`, `Dimension` and `Container` directly."]
pub struct RectrayContainerBundle {
pub transform_2d: Transform2D,
pub dimension: Dimension,
pub container: Container,
pub layout: LayoutControl,
pub rotated_rect: RotatedRect,
}
}
#[allow(deprecated)]
pub use bundles::{RectrayBundle, RectrayContainerBundle};