Struct zng_app::widget::info::WidgetInfo

source ·
pub struct WidgetInfo { /* private fields */ }
Expand description

Reference to a widget info in a WidgetInfoTree.

Implementations§

source§

impl WidgetInfo

source

pub fn access(&self) -> Option<WidgetAccessInfo>

Accessibility info, if the widget is accessible.

The widget is accessible only if access_enabled and some accessibility metadata was set on the widget.

source

pub fn access_children(&self) -> impl Iterator<Item = WidgetAccessInfo>

Descendant branches that have accessibility info.

The iterator enters descendants only until it finds a node that has access info, these nodes are yielded.

source

pub fn access_parent(&self) -> Option<WidgetAccessInfo>

First ancestor that is accessible.

source§

impl WidgetInfo

source

pub fn id(&self) -> WidgetId

Widget id.

source

pub fn path(&self) -> WidgetPath

Full path to this widget.

source

pub fn trace_path(&self) -> Txt

Path details to help finding the widget during debug.

If the inspector metadata is present the widget type is included.

source

pub fn trace_id(&self) -> Txt

Detailed id text.

If the inspector metadata is present the widget type is included.

source

pub fn interaction_path(&self) -> InteractionPath

Full path to this widget with interactivity values.

source

pub fn new_path(&self, old_path: &WidgetPath) -> Option<WidgetPath>

Gets the path if it is different from old_path.

Only allocates a new path if needed.

§Panics

If old_path does not point to the same widget id as self.

source

pub fn new_interaction_path( &self, old_path: &InteractionPath ) -> Option<InteractionPath>

Gets the interaction_path if it is different from old_path.

Only allocates a new path if needed.

§Panics

If old_path does not point to the same widget id as self.

source

pub fn z_index(&self) -> Option<(ZIndex, ZIndex)>

Get the z-index of the widget in the latest frame if it was rendered.

Note that widgets can render in the back and front of each descendant, these indexes are the back-most index, the moment the widget starts rendering and the front-most index at the moment the widget and all contents finishes rendering.

This value is updated every render without causing a tree rebuild.

source

pub fn visibility(&self) -> Visibility

Gets the visibility of the widget or the widget’s descendants in the last rendered frame.

A widget is Visible if it rendered at least one display item, Hidden if it rendered only space and hit-test items, Collapsed if it did not render. All widgets are Visible if no frame was ever rendered.

source

pub fn interactivity(&self) -> Interactivity

Get or compute the interactivity of the widget.

The interactivity of a widget is the combined result of all interactivity filters applied to it and its ancestors. If a parent is blocked this is blocked, same for disabled.

source

pub fn bounds_info(&self) -> WidgetBoundsInfo

All the transforms introduced by this widget, starting from the outer info.

This information is up-to-date, it is updated every layout and render without causing a tree rebuild.

source

pub fn border_info(&self) -> WidgetBorderInfo

Clone a reference to the widget border and corner radius information.

This information is up-to-date, it is updated every layout without causing a tree rebuild.

source

pub fn perspective(&self) -> Option<(f32, PxPoint)>

Gets the 3D perspective for this widget.

The f32 is a distance from the Z-plane to the viewer, the point is the vanishing center in the parent widget inner bounds.

source

pub fn transform_style(&self) -> TransformStyle

Gets the transform style for this widget.

Is Flat unless it or the parent widget sets Preserve3D.

source

pub fn outer_size(&self) -> PxSize

Size of the widget outer area, not transformed.

Returns an up-to-date size, the size is updated every layout without causing a tree rebuild.

source

pub fn inner_size(&self) -> PxSize

Size of the widget inner area, not transformed.

Returns an up-to-date size, the size is updated every layout without causing a tree rebuild.

source

pub fn inner_border_size(&self) -> PxSize

Size of the widget child area, not transformed.

Returns an up-to-date size, the size is updated every layout without causing a tree rebuild.

source

pub fn baseline(&self) -> Px

Gets the baseline offset up from the inner bounds bottom line.

source

pub fn outer_transform(&self) -> PxTransform

Widget outer transform in window space.

Returns an up-to-date transform, the transform is updated every render or render update without causing a tree rebuild.

source

pub fn inner_transform(&self) -> PxTransform

Widget inner transform in the window space.

Returns an up-to-date transform, the transform is updated every render or render update without causing a tree rebuild.

source

pub fn outer_bounds(&self) -> PxRect

Widget outer rectangle in the window space.

Returns an up-to-date rect, the bounds are updated every render or render update without causing a tree rebuild.

source

pub fn inner_bounds(&self) -> PxRect

Widget inner rectangle in the window space.

Returns an up-to-date rect, the bounds are updated every render or render update without causing a tree rebuild.

source

pub fn spatial_bounds(&self) -> PxBox

Compute the bounding box that envelops self and descendants inner bounds.

source

pub fn center(&self) -> PxPoint

Widget inner bounds center in the window space.

source

pub fn meta(&self) -> StateMapRef<'_, WidgetInfoMeta>

Custom metadata associated with the widget during info build.

source

pub fn tree(&self) -> &WidgetInfoTree

Reference the WidgetInfoTree that owns self.

source

pub fn is_reused(&self) -> bool

If the widget info and all descendants did not change in the last rebuild.

source

pub fn root(&self) -> Self

Reference to the root widget.

source

pub fn parent(&self) -> Option<Self>

Reference to the widget that contains this widget.

Is None only for root.

source

pub fn prev_sibling(&self) -> Option<Self>

Reference to the previous widget within the same parent.

source

pub fn next_sibling(&self) -> Option<Self>

Reference to the next widget within the same parent.

source

pub fn first_child(&self) -> Option<Self>

Reference to the first widget within this widget.

source

pub fn last_child(&self) -> Option<Self>

Reference to the last widget within this widget.

source

pub fn has_siblings(&self) -> bool

If the parent widget has multiple children.

source

pub fn has_children(&self) -> bool

If the widget has at least one child.

source

pub fn siblings(&self) -> impl Iterator<Item = WidgetInfo>

All parent children except this widget.

source

pub fn children(&self) -> Children

Iterator over the direct descendants of the widget.

source

pub fn children_count(&self) -> usize

Count of children.

source

pub fn self_and_children(&self) -> Children

Iterator over the widget and the direct descendants of the widget.

source

pub fn descendants(&self) -> TreeIter

Iterator over all widgets contained by this widget.

source

pub fn descendants_len(&self) -> usize

Total number of descendants.

source

pub fn self_and_descendants(&self) -> TreeIter

Iterator over the widget and all widgets contained by it.

source

pub fn ancestors(&self) -> Ancestors

Iterator over parent -> grandparent -> .. -> root.

source

pub fn descendants_range(&self) -> WidgetDescendantsRange

Gets a value that can check if widgets are descendant of self in O(1) time.

source

pub fn is_ancestor(&self, maybe_descendant: &WidgetInfo) -> bool

If self is an ancestor of maybe_descendant.

source

pub fn is_descendant(&self, maybe_ancestor: &WidgetInfo) -> bool

If self is inside maybe_ancestor.

source

pub fn self_and_ancestors(&self) -> Ancestors

Iterator over self -> parent -> grandparent -> .. -> root.

source

pub fn prev_siblings(&self) -> PrevSiblings

Iterator over all previous widgets within the same parent.

source

pub fn self_and_prev_siblings(&self) -> PrevSiblings

Iterator over self and all previous widgets within the same parent.

source

pub fn next_siblings(&self) -> NextSiblings

Iterator over all next widgets within the same parent.

source

pub fn self_and_next_siblings(&self) -> NextSiblings

Iterator over self and all next widgets within the same parent.

source

pub fn prev_siblings_in(&self, ancestor: &WidgetInfo) -> RevTreeIter

Iterator over all previous widgets within the same ancestor, including descendants of siblings.

If ancestor is not actually an ancestor iterates to the root.

source

pub fn self_and_prev_siblings_in(&self, ancestor: &WidgetInfo) -> RevTreeIter

Iterator over self, descendants and all previous widgets within the same ancestor.

If ancestor is not actually an ancestor iterates to the root.

source

pub fn next_siblings_in(&self, ancestor: &WidgetInfo) -> TreeIter

Iterator over all next widgets within the same ancestor, including descendants of siblings.

If ancestor is not actually an ancestor iterates to the root.

source

pub fn self_and_next_siblings_in(&self, ancestor: &WidgetInfo) -> TreeIter

Iterator over self, descendants and all next widgets within the same ancestor.

If ancestor is not actually an ancestor iterates to the root.

source

pub fn orientation_from(&self, origin: PxPoint) -> Option<Orientation2D>

The center orientation in relation to an origin.

Returns None if the origin is the center.

source

pub fn distance_key(&self, origin: PxPoint) -> DistanceKey

Value that indicates the distance between this widget center and origin.

source

pub fn depth(&self) -> usize

Count of ancestors.

source

pub fn shared_ancestor(&self, other: &Self) -> Option<WidgetInfo>

First ancestor of self and other.

Returns None if other is not from the same tree.

source

pub fn is_in_bounds(&self) -> bool

Returns true if this widget’s inner bounds are fully contained by the parent inner bounds.

source

pub fn out_of_bounds(&self) -> impl Iterator<Item = WidgetInfo>

Iterator over all descendants with inner bounds not fully contained by their parent inner bounds.

source

pub fn spatial_iter( &self, filter: impl Fn(&WidgetInfo) -> bool + Clone ) -> impl Iterator<Item = WidgetInfo>

Iterator over self and descendants, first self, then all in-bounds descendants, then all out-of-bounds descendants.

If the filter returns false the widget and all it’s in-bounds descendants are skipped, otherwise they are yielded. After all in-bounds descendants reachable from self and filtered the iterator changes to each out-of-bounds descendants and their in-bounds descendants that are also filtered.

source

pub fn inner_contains(&self, point: PxPoint) -> impl Iterator<Item = WidgetInfo>

Iterator over self and all descendants with inner bounds that contain the point.

source

pub fn inner_intersects(&self, rect: PxRect) -> impl Iterator<Item = WidgetInfo>

Spatial iterator over self and descendants with inner bounds that intersects the rect.

source

pub fn inner_contains_rect( &self, rect: PxRect ) -> impl Iterator<Item = WidgetInfo>

Spatial iterator over self and descendants with inner bounds that fully envelops the rect.

source

pub fn inner_contained(&self, rect: PxRect) -> impl Iterator<Item = WidgetInfo>

Spatial iterator over self and descendants with inner bounds that are fully inside the rect.

source

pub fn center_contained(&self, area: PxRect) -> impl Iterator<Item = WidgetInfo>

Spatial iterator over self and descendants with center point inside the area.

source

pub fn center_in_distance( &self, origin: PxPoint, max_radius: Px ) -> impl Iterator<Item = WidgetInfo> + '_

Spatial iterator over self and descendants with center point within the max_radius of the origin.

source

pub fn hit_test(&self, point: PxPoint) -> HitTestInfo

Gets all widgets of self and descendants hit by a point, sorted by z-index of the hit, front to back.

source

pub fn nearest(&self, origin: PxPoint, max_radius: Px) -> Option<WidgetInfo>

Find the descendant with center point nearest of origin within the max_radius.

This method is faster than using sorting the result of center_in_distance, but is slower if any point in distance is acceptable.

source

pub fn nearest_filtered( &self, origin: PxPoint, max_radius: Px, filter: impl FnMut(&WidgetInfo) -> bool ) -> Option<WidgetInfo>

Find the widget, self or descendant, with center point nearest of origin within the max_radius and approved by the filter closure.

source

pub fn nearest_bounded_filtered( &self, origin: PxPoint, max_radius: Px, bounds: PxRect, filter: impl FnMut(&WidgetInfo) -> bool ) -> Option<WidgetInfo>

Find the widget, self or descendant, with center point nearest of origin within the max_radius and inside bounds; and approved by the filter closure.

source

pub fn oriented( &self, origin: PxPoint, max_distance: Px, orientation: Orientation2D ) -> impl Iterator<Item = WidgetInfo>

Spatial iterator over all widgets, self and descendants, with center in the direction defined by orientation and within max_distance of the origin, widgets are only visited once and the distance is clipped by the spatial_bounds.

Use Px::MAX on the distance to visit all widgets in the direction.

The direction is defined by a 45º frustum cast from the origin, see Orientation2D::point_is for more details.

source

pub fn oriented_box( &self, origin: PxBox, max_distance: Px, orientation: Orientation2D ) -> impl Iterator<Item = WidgetInfo>

Spatial iterator over all widgets, self and descendants, with inner_bounds in the direction defined by orientation in relation to origin and with center within max_distance of the origin center. Widgets are only visited once and the distance is clipped by the spatial_bounds.

Use Px::MAX on the distance to visit all widgets in the direction.

The direction is a collision check between inner-bounds and origin, see Orientation2D::box_is for more details.

source

pub fn nearest_oriented( &self, origin: PxPoint, max_distance: Px, orientation: Orientation2D ) -> Option<WidgetInfo>

Find the widget with center point nearest of origin within the max_distance and with orientation to origin.

This method is faster than searching the result of oriented.

source

pub fn nearest_oriented_filtered( &self, origin: PxPoint, max_distance: Px, orientation: Orientation2D, filter: impl FnMut(&WidgetInfo) -> bool ) -> Option<WidgetInfo>

Find the widget with center point nearest of origin within the max_distance and with orientation to origin, and approved by the filter closure.

This method is faster than searching the result of oriented.

source

pub fn nearest_box_oriented( &self, origin: PxBox, max_distance: Px, orientation: Orientation2D ) -> Option<WidgetInfo>

Find the widget with center point nearest to origin center within the max_distance and with box orientation to origin.

This method is faster than searching the result of oriented_box.

source

pub fn nearest_box_oriented_filtered( &self, origin: PxBox, max_distance: Px, orientation: Orientation2D, filter: impl FnMut(&WidgetInfo) -> bool ) -> Option<WidgetInfo>

Find the widget with center point nearest to origin center within the max_distance and with box orientation to origin, and approved by the filter closure.

This method is faster than searching the result of oriented_box.

Trait Implementations§

source§

impl Clone for WidgetInfo

source§

fn clone(&self) -> WidgetInfo

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for WidgetInfo

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Hash for WidgetInfo

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for WidgetInfo

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl WidgetInfoInspectorExt for WidgetInfo

source§

fn inspector_info(&self) -> Option<Arc<InspectorInfo>>

Reference the builder that was used to generate the widget, the builder generated items and the widget info context. Read more
source§

fn can_inspect(&self) -> bool

If a inspector_info is defined for the widget.
source§

fn inspect_child<P: InspectWidgetPattern>( &self, pattern: P ) -> Option<WidgetInfo>

Returns the first child that matches.
source§

fn inspect_descendant<P: InspectWidgetPattern>( &self, pattern: P ) -> Option<WidgetInfo>

Returns the first descendant that matches. Read more
source§

fn inspect_ancestor<P: InspectWidgetPattern>( &self, pattern: P ) -> Option<WidgetInfo>

Returns the first ancestor that matches.
source§

fn inspect_property<P: InspectPropertyPattern>( &self, pattern: P ) -> Option<&dyn PropertyArgs>

Search for a property set on the widget. Read more
source§

fn parent_property(&self) -> Option<(PropertyId, usize)>

Gets the parent property that has this widget as an input. Read more
source§

impl WidgetPathProvider for WidgetInfo

§

type WidgetIter<'s> = Map<Ancestors, fn(_: WidgetInfo) -> WidgetId>

Output of widget_and_ancestors.
source§

fn window_id(&self) -> WindowId

The window parent.
source§

fn widget_and_ancestors(&self) -> Self::WidgetIter<'_>

Iterate over the widget, parent, grandparent, .., root.
source§

impl Eq for WidgetInfo

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> AnyVarValue for T
where T: VarValue,

source§

fn as_any(&self) -> &(dyn Any + 'static)

Access to dyn Any methods.
source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Access to mut dyn Any methods.
source§

fn clone_boxed(&self) -> Box<dyn AnyVarValue>

Clone the value.
source§

fn clone_boxed_var(&self) -> Box<dyn AnyVar>

Clone the value into a new boxed LocalVar<Self>.
source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Access to Box<dyn Any> methods.
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
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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
source§

impl<T> IntoVar<T> for T
where T: VarValue,

§

type Var = LocalVar<T>

Variable type that will wrap the T value. Read more
source§

fn into_var(self) -> <T as IntoVar<T>>::Var

Converts the source value into a var.
source§

fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>
where Self: Sized,

Converts into BoxedVar<T>. 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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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

§

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> IntoValue<T> for T
where T: VarValue,

source§

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

source§

impl<T> VarValue for T
where T: Debug + Clone + PartialEq + Any + Send + Sync,