Struct zng_wgt_layer::LAYERS

source ·
pub struct LAYERS;
Expand description

Windows layers.

The window layers is a z-order stacking panel that fills the window content area, widgets can be inserted with a z-index that is the LayerIndex. The inserted widgets parent is the window root widget and it is affected by the context properties set on the window only.

§Layout & Render

Layered widgets are measured and arranged using the same constraints as the window root widget, the desired size is discarded, only the root widget desired size can affect the window size.

Layered widgets are all layout and rendered after the window content, this means that the WidgetBoundsInfo of normal widgets are always up-to-date when the layered widget is arranged and rendered, so if you implement custom layouts that align the layered widget with a normal widget using the info values it will always be in sync with a single layout pass, see insert_anchored for more details.

Note that this single pass behavior only works automatically in the AnchorMode, to implement custom sizing and positioning based on the anchor you must wrap the layered widget with a custom widget node, this is because the default widget implementation skips layout and render when it was not requested for the widget or descendants. See the insert_anchored source code for an example.

Implementations§

source§

impl LAYERS

source

pub fn insert(&self, layer: impl IntoVar<LayerIndex>, widget: impl UiNode)

Insert the widget in the layer identified by a LayerIndex.

If the layer variable updates the widget is moved to the new layer, if multiple widgets are inserted in the same layer the later inserts are on top of the previous.

If the widget node is not a full widget after init it is immediately deinited and removed. Only full widgets are allowed, use this method when you know the node is a widget and know the widget ID so it can be removed later. Use insert_node to insert nodes that may not always be widgets.

source

pub fn insert_node( &self, layer: impl IntoVar<LayerIndex>, maybe_widget: impl UiNode, ) -> ResponseVar<WidgetId>

Like insert, but does not fail if maybe_widget is not a full widget.

If the maybe_widget is not a full widget after the first init, it is upgraded to a full widget. The widget ID (existing or upgraded) is set on a response var that can be used to remove the node.

This is the equivalent of calling insert with the node wrapped in UiNode::init_widget.

source

pub fn insert_anchored( &self, layer: impl IntoVar<LayerIndex>, anchor: impl IntoVar<WidgetId>, mode: impl IntoVar<AnchorMode>, widget: impl UiNode, )

Insert the widget in the layer and anchor it to the offset/transform of another widget.

The anchor is the ID of another widget, the inserted widget will be offset/transform so that it aligns with the anchor widget top-left. The mode is a value of AnchorMode that defines if the widget will receive the full transform or just the offset.

If the anchor widget is not found the widget is anchored to the window root. If the widget is not a full widget after init it is immediately deinited and removed. If you don’t know the widget ID use insert_anchored_node instead to receive the ID so the layer can be removed.

source

pub fn insert_anchored_node( &self, layer: impl IntoVar<LayerIndex>, anchor: impl IntoVar<WidgetId>, mode: impl IntoVar<AnchorMode>, maybe_widget: impl UiNode, ) -> ResponseVar<WidgetId>

Like insert_anchored, but does not fail if maybe_widget is not a full widget.

If the maybe_widget is not a full widget after the first init, it is upgraded to a full widget. The widget ID is set on a response var that can be used to remove the node.

This is the equivalent of calling insert_anchored with the node wrapped in UiNode::init_widget.

source

pub fn remove(&self, id: impl Into<WidgetId>)

Remove the widget in the next update.

The id must the widget id of a previous inserted widget, nothing happens if the widget is not found.

See also remove_node for removing nodes inserted by _node variants.

source

pub fn remove_node(&self, id: ResponseVar<WidgetId>)

Remove the widget in the next update.

If the id has not responded yet it will be removed as soon as it initializes. This can happen if the remove request is made before an update cycle allows time for the inserted widget first init.

source

pub fn anchor_id(&self) -> ReadOnlyContextVar<Option<WidgetId>>

Gets a read-only var that tracks the anchor widget in a layered widget context.

Auto Trait Implementations§

§

impl Freeze for LAYERS

§

impl RefUnwindSafe for LAYERS

§

impl Send for LAYERS

§

impl Sync for LAYERS

§

impl Unpin for LAYERS

§

impl UnwindSafe for LAYERS

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