Struct zng_app::widget::info::WidgetLayout
source · pub struct WidgetLayout { /* private fields */ }
Expand description
Represents the in-progress layout pass for a widget tree.
Implementations§
source§impl WidgetLayout
impl WidgetLayout
sourcepub fn with_root_widget(
layout_widgets: Arc<LayoutUpdates>,
layout: impl FnOnce(&mut Self) -> PxSize,
) -> PxSize
pub fn with_root_widget( layout_widgets: Arc<LayoutUpdates>, layout: impl FnOnce(&mut Self) -> PxSize, ) -> PxSize
Defines the root widget outer-bounds scope.
The default window implementation calls this inside the root widget context.
sourcepub fn parallel_split(&self) -> ParallelBuilder<WidgetLayout>
pub fn parallel_split(&self) -> ParallelBuilder<WidgetLayout>
Start a parallel layout.
Returns an instance that can be used to acquire multiple mutable WidgetLayout
during layout.
The parallel_fold
method must be called after the parallel processing is done.
Must be called outside of the child scope.
sourcepub fn parallel_fold(&mut self, split: ParallelBuilder<WidgetLayout>)
pub fn parallel_fold(&mut self, split: ParallelBuilder<WidgetLayout>)
Collect the parallel changes back.
sourcepub fn with_widget(
&mut self,
layout: impl FnOnce(&mut Self) -> PxSize,
) -> PxSize
pub fn with_widget( &mut self, layout: impl FnOnce(&mut Self) -> PxSize, ) -> PxSize
Defines a widget scope, translations inside layout
target the widget’s inner offset.
If the widget layout is not invalidated and none of the used metrics have changed skips calling
layout
and returns the current outer-size, the outer transform is still updated.
The default widget constructor calls this, see base::node::widget
.
sourcepub fn with_inline_visual(
&mut self,
layout: impl FnOnce(&mut Self) -> PxSize,
) -> PxSize
pub fn with_inline_visual( &mut self, layout: impl FnOnce(&mut Self) -> PxSize, ) -> PxSize
Calls layout
with inline force enabled on the widget.
The widget will use the inline visual even if the parent did not inline it, but it will not inline if it has properties that disable inlining.
sourcepub fn with_inner(&mut self, layout: impl FnOnce(&mut Self) -> PxSize) -> PxSize
pub fn with_inner(&mut self, layout: impl FnOnce(&mut Self) -> PxSize) -> PxSize
Defines the widget’s inner scope, translations inside layout
target the widget’s child offset.
This method also updates the border info.
The default widget borders constructor calls this, see base::node::widget_inner
.
sourcepub fn with_child(
&mut self,
layout: impl FnOnce(&mut Self) -> PxSize,
) -> (PxSize, bool)
pub fn with_child( &mut self, layout: impl FnOnce(&mut Self) -> PxSize, ) -> (PxSize, bool)
Defines the widget’s child scope, translations inside layout
target the widget’s child offset.
Returns the child size and if a reference frame is required to offset the child.
The default widget child layout constructor implements this, see base::node::widget_child
.
sourcepub fn require_child_ref_frame(&mut self)
pub fn require_child_ref_frame(&mut self)
Ensure that the parent with_child
will receive a reference frame request.
Nodes that branch out children inside the widget’s child scope must call this to ensure that the offsets are not given to the only widget child among other nodes.
sourcepub fn with_branch_child(
&mut self,
layout: impl FnOnce(&mut Self) -> PxSize,
) -> (PxSize, PxVector)
pub fn with_branch_child( &mut self, layout: impl FnOnce(&mut Self) -> PxSize, ) -> (PxSize, PxVector)
Defines a custom scope that does not affect the widget’s offsets, only any widget inside layout
.
Nodes that branch out children outside widget’s child scope must use this method.
Returns the output of layout
and a translate vector if any translations inside layout
where not handled
by child widgets.
sourcepub fn translate(&mut self, offset: PxVector)
pub fn translate(&mut self, offset: PxVector)
Adds the offset
to the closest inner bounds offset.
This affects the inner offset if called from a node inside the widget and before the BORDER
group, or it affects
the child offset if called inside the widget and inside the BORDER
group.
sourcepub fn set_baseline(&mut self, baseline: Px)
pub fn set_baseline(&mut self, baseline: Px)
Set the baseline offset of the widget. The value is up from the bottom of the inner bounds.
sourcepub fn translate_baseline(&mut self, enabled: bool)
pub fn translate_baseline(&mut self, enabled: bool)
Set if the baseline is added to the inner offset y axis.
sourcepub fn set_transform_style(&mut self, style: TransformStyle)
pub fn set_transform_style(&mut self, style: TransformStyle)
Set if the widget preserved 3D perspective form the parent.
sourcepub fn set_perspective(&mut self, d: f32)
pub fn set_perspective(&mut self, d: f32)
Set the 3D perspective that defines the children 3D space.
This is the distance from the Z-plane to the viewer.
sourcepub fn set_perspective_origin(&mut self, origin: PxPoint)
pub fn set_perspective_origin(&mut self, origin: PxPoint)
Sets the vanishing point of the children 3D space as a point in the inner bounds of this widget.
sourcepub fn allow_auto_hide(&mut self, enabled: bool)
pub fn allow_auto_hide(&mut self, enabled: bool)
Sets if the widget only renders if outer_bounds
intersects with the FrameBuilder::auto_hide_rect
.
This is true
by default.
sourcepub fn collapse(&mut self)
pub fn collapse(&mut self)
Collapse the layout of self
and descendants, the size and offsets are set to zero.
Nodes that set the visibility to the equivalent of Collapsed
must skip layout and return PxSize::zero
as
the size, ignoring the min-size constraints, and call this method to update all the descendant
bounds information to be a zero-sized point.
Note that the widget will automatically not be rendered when collapsed.
sourcepub fn collapse_descendants(&mut self)
pub fn collapse_descendants(&mut self)
Collapse layout of all descendants, the size and offsets are set to zero.
Widgets that control the visibility of their children can use this method and then, in the same layout pass, layout the children that should be visible.
Note that the widgets will automatically not be rendered when collapsed.
sourcepub fn collapse_child(&mut self, index: usize)
pub fn collapse_child(&mut self, index: usize)
Collapse layout of the child and all its descendants, the size and offsets are set to zero.
Widgets that control the visibility of their children can use this method and then, in the same layout pass, layout the children that should be visible.
Note that the widgets will automatically not be rendered when collapsed.
sourcepub fn is_inline(&self) -> bool
pub fn is_inline(&self) -> bool
If the parent widget is doing inline layout and this widget signaled that it can support this during measure.
See WidgetMeasure::inline
for more details.
sourcepub fn inline(&mut self) -> Option<&mut WidgetInlineInfo>
pub fn inline(&mut self) -> Option<&mut WidgetInlineInfo>
Mutable reference to the current widget’s inline info.
This is Some(_)
if the parent widget is doing inline layout and this widget signaled that it can be inlined
in the previous measure pass. You can use WidgetMeasure::disable_inline
in the measure pass to disable
inline in both passes, measure and layout.
The rows and negative space are already reset when widget layout started, and the inner size will be updated when the widget layout ends, the inline layout node only needs to push rows.
When this is Some(_)
the LayoutMetrics::inline_constraints
is also Some(_)
.
See WidgetInlineInfo
for more details.
sourcepub fn to_measure(&self, inline: Option<WidgetInlineMeasure>) -> WidgetMeasure
pub fn to_measure(&self, inline: Option<WidgetInlineMeasure>) -> WidgetMeasure
Create an WidgetMeasure
for an UiNode::measure
call.
sourcepub fn layout_block(&mut self, child: &mut impl UiNode) -> PxSize
pub fn layout_block(&mut self, child: &mut impl UiNode) -> PxSize
Layout the child node in a context without inline constraints.
This must be called inside inlining widgets to layout block child nodes, otherwise the inline constraints from the calling widget propagate to the child.
sourcepub fn layout_inline(
&mut self,
first: PxRect,
mid_clear: Px,
last: PxRect,
first_segs: Arc<Vec<InlineSegmentPos>>,
last_segs: Arc<Vec<InlineSegmentPos>>,
child: &mut impl UiNode,
) -> PxSize
pub fn layout_inline( &mut self, first: PxRect, mid_clear: Px, last: PxRect, first_segs: Arc<Vec<InlineSegmentPos>>, last_segs: Arc<Vec<InlineSegmentPos>>, child: &mut impl UiNode, ) -> PxSize
Layout the child node with inline enabled in the child
node context.
The mid_clear
, last
, first_segs
and last_segs
parameters match the InlineConstraintsLayout
members, and will be set in
the child
context.
Returns the child final size.
sourcepub fn with_layout_updates(
&mut self,
layout_updates: Arc<LayoutUpdates>,
layout: impl FnOnce(&mut WidgetLayout) -> PxSize,
) -> PxSize
pub fn with_layout_updates( &mut self, layout_updates: Arc<LayoutUpdates>, layout: impl FnOnce(&mut WidgetLayout) -> PxSize, ) -> PxSize
Call layout
with a different set of layout_updates
.
This is usually managed by the window implementer, nested windows can use this to override the updates.
Auto Trait Implementations§
impl !Freeze for WidgetLayout
impl !RefUnwindSafe for WidgetLayout
impl Send for WidgetLayout
impl Sync for WidgetLayout
impl Unpin for WidgetLayout
impl !UnwindSafe for WidgetLayout
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more