#![warn(clippy::pedantic, clippy::nursery, missing_docs)]
#![allow(
clippy::match_bool,
clippy::manual_range_contains,
clippy::use_self,
clippy::redundant_pub_crate,
clippy::module_name_repetitions
)]
use bevy::app::{App, Plugin as BevyPlugin, Update};
use bevy::ecs::prelude::*;
pub use alignment::{Alignment, Distribution};
pub use content_sized::{AppContentSizeExt, ComputeContentParam, ComputeContentSize};
pub use cuicui_dsl::{dsl, DslBundle, IntoEntityCommands};
pub use direction::{Flow, Oriented, Size};
pub use dsl::LayoutDsl;
pub use error::ComputeLayoutError;
pub use labels::{
ComputeLayout, ComputeLayoutSet, ContentSizedComputeSystem, ContentSizedComputeSystemSet,
};
pub use layout::{Container, LayoutRect, LeafRule, Node, Root, Rule};
pub use systems::{
compute_layout, require_layout_recompute, update_leaf_nodes, LastLayoutChange,
LayoutRootCamera, LeafNode, LeafNodeInsertWitness, ScreenRoot,
};
mod alignment;
mod content_sized;
mod direction;
mod error;
mod labels;
mod layout;
mod systems;
pub mod bundles;
#[cfg(feature = "debug")]
pub mod debug;
pub mod dsl;
pub mod dsl_functions {
pub use crate::dsl::{child, pct, px};
}
pub struct Plugin;
impl BevyPlugin for Plugin {
fn build(&self, app: &mut App) {
app.init_resource::<LastLayoutChange>()
.init_resource::<LeafNodeInsertWitness>();
let should_update = LeafNodeInsertWitness::new(true);
app.add_systems(
Update,
(
compute_layout
.run_if(require_layout_recompute)
.in_set(ComputeLayout)
.in_set(ComputeLayoutSet),
(
update_leaf_nodes,
apply_deferred.run_if(resource_exists_and_equals(should_update)),
)
.chain()
.in_set(ComputeLayoutSet)
.before(ContentSizedComputeSystemSet),
),
);
#[cfg(feature = "debug")]
app.add_plugins(debug::Plugin);
#[cfg(feature = "reflect")]
app.register_type::<Alignment>()
.register_type::<Container>()
.register_type::<Distribution>()
.register_type::<Flow>()
.register_type::<LeafNode>()
.register_type::<LeafRule>()
.register_type::<Node>()
.register_type::<Oriented<LeafRule>>()
.register_type::<LayoutRect>()
.register_type::<Root>()
.register_type::<Rule>()
.register_type::<ScreenRoot>()
.register_type::<Size<f32>>()
.register_type::<Size<LeafRule>>()
.register_type::<Size<Rule>>();
}
}