zng_app::widget::info

Struct WidgetLayout

source
pub struct WidgetLayout { /* private fields */ }
Expand description

Represents the in-progress layout pass for a widget tree.

Implementations§

source§

impl WidgetLayout

source

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.

source

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.

source

pub fn parallel_fold(&mut self, split: ParallelBuilder<WidgetLayout>)

Collect the parallel changes back.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

pub fn translate_baseline(&mut self, enabled: bool)

Set if the baseline is added to the inner offset y axis.

source

pub fn set_transform_style(&mut self, style: TransformStyle)

Set if the widget preserved 3D perspective form the parent.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

pub fn to_measure(&self, inline: Option<WidgetInlineMeasure>) -> WidgetMeasure

Create an WidgetMeasure for an UiNode::measure call.

source

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.

source

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.

source

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§

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.

§

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

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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> 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
source§

impl<T> StateValue for T
where T: Any + Send + Sync,