#[allow(unused_imports)]
pub mod prelude {
pub use super::{
interaction::InteractionPalette,
palette as ui_palette,
widgets::{Containers as _, Widgets as _},
};
}
这个Containers是一个特型.
pub trait Containers {
/// Spawns a root node that covers the full screen
/// and centers its content horizontally and vertically.
fn ui_root(&mut self) -> EntityCommands;
}
impl Containers for Commands<'_, '_> {
fn ui_root(&mut self) -> EntityCommands {
self.spawn((
Name::new("UI Root"),
Node {
width: Percent(100.0),
height: Percent(100.0),
justify_content: JustifyContent::Center,
align_items: AlignItems::Center,
flex_direction: FlexDirection::Column,
row_gap: Px(10.0),
position_type: PositionType::Absolute,
..default()
},
))
}
}
pub use widgets::Containers as _; 的本意是:
外面只对EntityCommands::ui_root感兴趣,对特型Containers不感兴趣.只暴露特型的实现,特型就不暴露了.