pub struct LayoutDsl<T = BaseDsl> { /* private fields */ }
Expand description

The DslBundle for layouting.

The defaults are:

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>

source

pub fn flow(&mut self, flow: Flow)

Set the flow direction of a container node.

source

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.

source

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.

source

pub fn distrib_start(&mut self)

Push children of this Node to the start of the main flow axis, the default is Distribution::FillMain.

source

pub fn distrib_end(&mut self)

Push children of this Node to the end of the main flow axis, the default is Distribution::FillMain.

source

pub fn fill_main_axis(&mut self)

Distribute the children of this Node to fill this Container’s main flow axis.

Note that this is the default.

source

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: Start, End or Center.

An error is logged on illegal values.

source

pub fn margins(&mut self, main: f32, cross: f32)

Set both the cross and main margins.

source

pub fn margin(&mut self, pixels: f32)

Set both the cross and main margins to pixels

source

pub fn main_margin(&mut self, pixels: f32)

Set this Container’s margin on the main flow axis.

source

pub fn cross_margin(&mut self, pixels: f32)

Set this Container’s margin on the cross flow axis.

source

pub fn rules(&mut self, width: Rule, height: Rule)

Set both width and height rules.

source

pub fn width(&mut self, rule: Rule)

Set the width Rule of this Node.

source

pub fn height(&mut self, rule: Rule)

Set the height Rule of this Node.

source

pub fn align_start(&mut self)

Use Alignment::Start for this Node, the default is Alignment::Center.

source

pub fn align_end(&mut self)

Use Alignment::End for this Node, the default is Alignment::Center.

source

pub fn screen_root(&mut self)

Set this node as the ScreenRoot, its size will follow that of the LayoutRootCamera camera.

source

pub fn root(&mut self)

Set this node as a Root.

source

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.

source

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.

source

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: Debug> Debug for LayoutDsl<D>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T: Default> Default for LayoutDsl<T>

source§

fn default() -> LayoutDsl<T>

Returns the “default value” for a type. Read more
source§

impl<T> Deref for LayoutDsl<T>

§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<T> DerefMut for LayoutDsl<T>

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl<D: DslBundle> DslBundle for LayoutDsl<D>

source§

fn insert(&mut self, cmds: &mut EntityCommands<'_, '_, '_>)

Add given Bundle to the entity.
source§

fn node( &mut self, cmds: &mut EntityCommands<'_, '_, '_>, f: impl FnOnce(&mut ChildBuilder<'_, '_, '_>) )

Spawn the entity as a parent of other entities.
source§

impl<D: DslBundle + ParseDsl> ParseDsl for LayoutDsl<D>

source§

fn method(&mut self, data: MethodCtx<'_, '_, '_>) -> Result<(), Error>

Apply method named name to self. Read more

Auto Trait Implementations§

§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T, U> AsBindGroupShaderType<U> for T
where U: ShaderType, &'a T: for<'a> Into<U>,

§

fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U

Return the T [ShaderType] for self. When used in [AsBindGroup] derives, it is safe to assume that all images in self exist.
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromWorld for T
where T: Default,

§

fn from_world(_world: &mut World) -> T

Creates Self using data from the given [World].
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more