Trait cuicui_layout::dsl::IntoUiBundle
source · pub trait IntoUiBundle<Marker> {
type Target: Bundle;
// Required method
fn into_ui_bundle(self) -> Self::Target;
}
Expand description
Something that can be converted into a bevy [Bundle
].
Implement this trait on anything you want, then you can use LayoutDsl::ui
with anything you want!
Marker
is completely ignored. It only exists to make it easier for
consumers of the API to extend the DSL with their own bundle.
Example
use cuicui_layout::{LayoutDsl, dsl};
use cuicui_layout::dsl::IntoUiBundle;
use cuicui_layout::dsl_functions::px;
enum MyDsl {}
impl IntoUiBundle<MyDsl> for &'_ str {
type Target = TextBundle;
fn into_ui_bundle(self) -> Self::Target {
TextBundle {
// ...
// text: Text::from_section(self, Default::default()),
// ...
}
}
}
fn setup(mut cmds: Commands) {
dsl! {
<LayoutDsl> &mut cmds.spawn_empty(),
Entity {
Entity(ui("Hello world") width(px(350)))
Entity(ui("Even hi!") width(px(350)))
Entity(ui("Howdy partner") width(px(350)))
}
};
}
Required Associated Types§
Required Methods§
sourcefn into_ui_bundle(self) -> Self::Target
fn into_ui_bundle(self) -> Self::Target
Convert self
into an Self::Target
, will be directly inserted by
LayoutDsl::ui
with an additional Node
component.
Since Target
is inserted after the Node
component, you can
overwrite it by including it in the bundle.