pub struct LayoutComponent {
pub available_width: f32,
pub authored_available_width: SizeDimension,
pub available_height: Option<f32>,
pub authored_available_height: Option<SizeDimension>,
pub dirty: bool,
pub unit_scale: f32,
pub inspect: bool,
pub computed_size_wu: Option<(f32, f32)>,
/* private fields */
}Expand description
The viewport of a self-contained layout subtree — analogous to the browser’s initial containing block.
LayoutComponent does not participate in flow itself; it defines the space
available to the first HtmlElementComponent child (usually Body).
Multiple LayoutComponent nodes can coexist — one per panel, one per HUD region,
one per workspace.
available_width is in glyph units (1.0 = one monospace character cell).
World-space scaling stays in TransformComponent.
Set dirty = true to signal the LayoutSystem to recompute the subtree on the next tick.
Fields§
§available_width: f32Available inline (X-axis) width for children, in glyph units.
Authored available width as entered in MMS.
available_height: Option<f32>Optional block (Y-axis) constraint. Used for overflow/clip; None = unconstrained.
Authored available height as entered in MMS.
dirty: boolWhen true, the layout system will recompute this subtree on the next tick.
unit_scale: f32Scale factor to convert glyph units → local coordinates of the nearest ancestor
TransformComponent.
When the parent TransformComponent already has scale = TEXT_SCALE (i.e. the whole
subtree is in glyph-unit space), leave this at the default 1.0.
When the parent TransformComponent has scale = 1.0 (world units) and the
StyleComponent heights are authored in glyph units, set unit_scale = TEXT_SCALE
(e.g. 0.08) so the emitted UpdateTransform translations land in world space.
inspect: boolWhen true, the layout pass spawns box-model viz quads (padding, content,
margin) for each styled item in this subtree. Per-tree dynamic toggle —
flipped via IntentValue::SetLayoutInspect (MMS: layout.set_inspect(bool)).
Static MMS declarations can also enable viz by attaching an
InspectLayoutComponent
child to the LayoutRoot.
computed_size_wu: Option<(f32, f32)>Computed total extent of this layout root’s direct children, in world units,
populated after each successful layout pass. None before the first layout.
Implementations§
Source§impl LayoutComponent
impl LayoutComponent
pub fn new(available_width: f32) -> Self
pub fn with_height(self, h: f32) -> Self
pub fn with_unit_scale(self, scale: f32) -> Self
Sourcepub fn mark_dirty(&mut self)
pub fn mark_dirty(&mut self)
Mark this layout root as needing a recompute.
Sourcepub fn set_available_width(&mut self, w: f32)
pub fn set_available_width(&mut self, w: f32)
Update available_width and flag this root for recompute on the next tick.
pub fn set_available_width_dimension(&mut self, width: SizeDimension)
pub fn set_available_height(&mut self, h: f32)
pub fn set_available_height_dimension(&mut self, height: SizeDimension)
pub fn set_unit_scale(&mut self, scale: f32)
Trait Implementations§
Source§impl Clone for LayoutComponent
impl Clone for LayoutComponent
Source§fn clone(&self) -> LayoutComponent
fn clone(&self) -> LayoutComponent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Component for LayoutComponent
impl Component for LayoutComponent
Source§fn name(&self) -> &'static str
fn name(&self) -> &'static str
fn set_id(&mut self, id: ComponentId)
fn as_any(&self) -> &dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Source§fn to_mms_ast(&self, _world: &World) -> ComponentExpression
fn to_mms_ast(&self, _world: &World) -> ComponentExpression
Source§fn init(&mut self, _emit: &mut dyn SignalEmitter, _component: ComponentId)
fn init(&mut self, _emit: &mut dyn SignalEmitter, _component: ComponentId)
Source§fn cleanup(&mut self, _emit: &mut dyn SignalEmitter, _component: ComponentId)
fn cleanup(&mut self, _emit: &mut dyn SignalEmitter, _component: ComponentId)
Auto Trait Implementations§
impl Freeze for LayoutComponent
impl RefUnwindSafe for LayoutComponent
impl Send for LayoutComponent
impl Sync for LayoutComponent
impl Unpin for LayoutComponent
impl UnsafeUnpin for LayoutComponent
impl UnwindSafe for LayoutComponent
Blanket Implementations§
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.