Struct LayoutChild

Source
pub struct LayoutChild {
    pub element_id: ElementId,
}
Expand description

Handle used by widgets to lay out one retained direct child.

§Examples

use ailloli_ui_core::ElementId;
use ailloli_ui_runtime::layout::LayoutChild;

let child = LayoutChild { element_id: ElementId(3) };
assert_eq!(child.element_id, ElementId(3));

Fields§

§element_id: ElementId

Retained-tree identity delegated to LayoutEngine.

Implementations§

Source§

impl LayoutChild

Provides the operations defined for LayoutChild.

Source

pub fn layout<A: 'static>( &mut self, engine: &mut LayoutEngine<'_, A>, ctx: &mut LayoutCtx<'_>, constraints: Constraints, ) -> LayoutResult

Lays out this child with the supplied logical-pixel constraints.

A stale or unknown element_id produces LayoutResult::zero and no diagnostic cache event. Other behavior, including widget panics, is delegated to LayoutEngine::layout_element.

§Examples
use ailloli_ui_core::{Constraints, ElementId, Scale, Size};
use ailloli_ui_runtime::element::ElementTree;
use ailloli_ui_runtime::layout::{LayoutChild, LayoutCtx, LayoutEngine};

let mut tree = ElementTree::<()>::new();
let mut engine = LayoutEngine::new(&mut tree);
let mut ctx = LayoutCtx::new(Scale::new(1.0));
let mut child = LayoutChild { element_id: ElementId(99) };
assert_eq!(
    child.layout(&mut engine, &mut ctx, Constraints::tight(10.0, 20.0)).size,
    Size::default(),
);

Auto Trait Implementations§

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
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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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> ErasedDestructor for T
where T: 'static,