pub struct LayoutDsl<T = BaseDsl> { /* private fields */ }
Expand description
The DslBundle
for layouting.
The defaults are:
- For containers: Child sized, meaning a container node has the minimum size to fit all its children.
Distribution::FillMain
Alignment::Center
For terminal nodes (spawned through spawn
or ui
) the default
size is [LeafRule::Fixed(0.)
], or content-sized.
Implementations§
Source§impl<D: DslBundle> LayoutDsl<D>
impl<D: DslBundle> LayoutDsl<D>
Sourcepub fn column(&mut self)
pub fn column(&mut self)
Spawn this Node
as a Node::Container
with children flowing vertically.
f
will then build the children of this Container
.
Sourcepub fn row(&mut self)
pub fn row(&mut self)
Spawn this Node
as a Node::Container
with children flowing horizontally.
f
will then build the children of this Container
.
Sourcepub fn distrib_start(&mut self)
pub fn distrib_start(&mut self)
Push children of this Node
to the start of the main flow axis,
the default is Distribution::FillMain
.
Sourcepub fn distrib_end(&mut self)
pub fn distrib_end(&mut self)
Push children of this Node
to the end of the main flow axis,
the default is Distribution::FillMain
.
Sourcepub fn fill_main_axis(&mut self)
pub fn fill_main_axis(&mut self)
Sourcepub fn layout(&mut self, spec: &str)
pub fn layout(&mut self, spec: &str)
Set properties based on the given spec
.
spec
specifies the flow, (d)istribution
and (a)lignment of the container in the form: [v>]d[SEC]a[SEC]
.
legal values are: S
tart, E
nd or C
enter.
An error is logged on illegal values.
Sourcepub fn main_margin(&mut self, pixels: f32)
pub fn main_margin(&mut self, pixels: f32)
Set this Container
’s margin on the main flow axis.
Sourcepub fn cross_margin(&mut self, pixels: f32)
pub fn cross_margin(&mut self, pixels: f32)
Set this Container
’s margin on the cross flow axis.
Sourcepub fn align_start(&mut self)
pub fn align_start(&mut self)
Use Alignment::Start
for this Node
, the default is Alignment::Center
.
Sourcepub fn align_end(&mut self)
pub fn align_end(&mut self)
Use Alignment::End
for this Node
, the default is Alignment::Center
.
Sourcepub fn screen_root(&mut self)
pub fn screen_root(&mut self)
Set this node as the ScreenRoot
, its size will follow that of the
LayoutRootCamera
camera.
Sourcepub fn empty_pct(&mut self, percent: u8)
pub fn empty_pct(&mut self, percent: u8)
Spawn an empty Node::Axis
with the main
axis set to percent
%
of parent’s size,
and the cross
axis to 0.
§Panics
If percent
is greater than 100. It would mean this node overflows its parent.
Sourcepub fn empty_px(&mut self, pixels: u16)
pub fn empty_px(&mut self, pixels: u16)
Spawn an empty Node::Axis
with the main
axis set to pixels
pixels
and the cross
axis to 0.
Sourcepub fn ui<M>(&mut self, ui_bundle: impl IntoUiBundle<M>)
pub fn ui<M>(&mut self, ui_bundle: impl IntoUiBundle<M>)
Spawn ui_bundle
.
Note that axis without set rules or Rule::Children
are considered content-sized.
Trait Implementations§
Source§impl<D: DslBundle> DslBundle for LayoutDsl<D>
impl<D: DslBundle> DslBundle for LayoutDsl<D>
Source§fn insert(&mut self, cmds: &mut EntityCommands<'_, '_, '_>)
fn insert(&mut self, cmds: &mut EntityCommands<'_, '_, '_>)
Bundle
to the entity.Source§fn node(
&mut self,
cmds: &mut EntityCommands<'_, '_, '_>,
f: impl FnOnce(&mut ChildBuilder<'_, '_, '_>),
)
fn node( &mut self, cmds: &mut EntityCommands<'_, '_, '_>, f: impl FnOnce(&mut ChildBuilder<'_, '_, '_>), )
Auto Trait Implementations§
impl<T> Freeze for LayoutDsl<T>where
T: Freeze,
impl<T = BaseDsl> !RefUnwindSafe for LayoutDsl<T>
impl<T = BaseDsl> !Send for LayoutDsl<T>
impl<T = BaseDsl> !Sync for LayoutDsl<T>
impl<T> Unpin for LayoutDsl<T>where
T: Unpin,
impl<T = BaseDsl> !UnwindSafe for LayoutDsl<T>
Blanket Implementations§
Source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Self
using data from the given World
.