floem

Struct ViewId

Source
pub struct ViewId(/* private fields */);
Expand description

A small unique identifier for an instance of a View.

This id is how you can access and modify a view, including accessing children views and updating state.

Implementations§

Source§

impl ViewId

Source

pub fn new() -> ViewId

Create a new unique Viewid.

Source

pub fn remove(&self)

Remove this view id and all of it’s children from the VIEW_STORAGE

Source

pub fn new_taffy_node(&self) -> NodeId

Create a new taffy layout node

Source

pub fn set_taffy_style(&self, node: NodeId, style: Style)

Set the layout properties on a taffy node

Source

pub fn taffy_layout(&self, node: NodeId) -> Option<Layout>

Get the layout for a taffy node relative to it’s parent

Source

pub fn taffy_node(&self) -> NodeId

Get the taffy node associated with this Id

Source

pub fn add_child(&self, child: Box<dyn View>)

Add a child View to this Id’s list of children

Source

pub fn set_children(&self, children: Vec<impl IntoView>)

Set the children views of this Id

Source

pub fn set_view(&self, view: Box<dyn View>)

Set the view that should be associated with this Id

Source

pub fn set_parent(&self, parent: ViewId)

Set the Id that should be used as the parent of this Id

Source

pub fn set_children_ids(&self, children: Vec<ViewId>)

Set the Ids that should be used as the children of this Id

Source

pub fn children(&self) -> Vec<ViewId>

Get the list of ViewIds that are associated with the children views of this ViewId

Source

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

Get the ViewId that has been set as this ViewId’s parent

Source

pub fn layout_rect(&self) -> Rect

Get the computed rectangle that covers the area of this View

Source

pub fn get_size(&self) -> Option<Size>

Get the size of this View

Source

pub fn parent_size(&self) -> Option<Size>

Get the Size of the parent View

Source

pub fn get_content_rect(&self) -> Rect

Returns the layout rect excluding borders, padding and position. This is relative to the view.

Source

pub fn get_layout(&self) -> Option<Layout>

This gets the Taffy Layout and adjusts it to be relative to the parent View.

Source

pub fn style_has_hidden(&self) -> bool

Returns true if the computed style for this view is marked as hidden (Display::None)

Source

pub fn is_hidden_recursive(&self) -> bool

Is this view, or any parent view, marked as hidden

Source

pub fn request_all(&self)

Request that this the id view be styled, laid out and painted again. This will recursively request this for all parents.

Source

pub fn request_layout(&self)

Request that this view have it’s layout pass run

Source

pub fn window_id(&self) -> Option<WindowId>

Get the window id of the window containing this view, if there is one.

Source

pub fn request_paint(&self)

Request that this view have it’s paint pass run

Source

pub fn request_style(&self)

request that this node be styled again This will recursively request style for all parents.

Source

pub fn request_focus(&self)

Request that this view gain the window focus

Source

pub fn clear_focus(&self)

Clear the focus from this window

Source

pub fn update_context_menu(&self, menu: impl Fn() -> Menu + 'static)

Set the system context menu that should be shown when this view is right-clicked

Source

pub fn update_popout_menu(&self, menu: impl Fn() -> Menu + 'static)

Set the system popout menu that should be shown when this view is clicked

Adds a primary-click context menu, which opens below the view.

Source

pub fn request_active(&self)

Request that this view receive the active state (mark that this element is currently being interacted with)

When an View has Active, it will receive events such as mouse events, even if the mouse is not directly over this view. This is usefor for views such as Sliders, where the mouse event should be sent to the slider view as long as the mouse is pressed down, even if the mouse moves out of the view, or even out of the Window.

Source

pub fn clear_active(&self)

Request that the active state be removed from this View

Source

pub fn inspect(&self)

Send a message to the application to open the Inspector for this Window

Source

pub fn scroll_to(&self, rect: Option<Rect>)

Scrolls the view and all direct and indirect children to bring the view to be visible. The optional rectangle can be used to add an additional offset and intersection.

Source

pub fn update_state(&self, state: impl Any)

Send a state update to the update method of the associated View

Source

pub fn add_event_listener( &self, listener: EventListener, action: Box<EventCallback>, )

Add an callback on an action for a given EventListener

Source

pub fn update_resize_listener(&self, action: Box<ResizeCallback>)

Set a callback that should be run when the size of the view changes

Source

pub fn update_move_listener(&self, action: Box<dyn Fn(Point)>)

Set a callback that should be run when the position of the view changes

Source

pub fn update_cleanup_listener(&self, action: Box<dyn Fn()>)

Set a callback that should be run when the view is removed from the view tree

Source

pub fn get_combined_style(&self) -> Style

Get the combined style that is associated with this View.

This will have all of the style properties set in it that are relevant to this view, including all properties from relevant classes.

§Warning

The view styles do not store property transition states, only markers of which properties should be transitioned over time on change.

If you have a property that could be transitioned over time, make sure to use a prop extractor that is updated in a style method of the View to extract the property.

Source

pub fn add_class(&self, class: StyleClassRef)

Add a class to the list of style classes that are associated with this ViewId

Source

pub fn remove_class(&self, class: StyleClassRef)

Remove a class from the list of style classes that are associated with this ViewId

Source

pub fn update_disabled(&self, is_disabled: bool)

Set whether this view should be marked as disabled or not.

When a view is disabled it will not receive events and it can be styled with the disabled style.

Source

pub fn keyboard_navigable(&self)

Mark this view as a view that can be navigated to using the keyboard

Source

pub fn remove_keyboard_navigatable(&self)

Mark this view as a view that can not be navigated to using the keyboard

Source

pub fn disable_default_event(&self, event: EventListener)

Disables the default view behavior for the specified event.

Children will still see the event, but the view event function will not be called nor the event listeners on the view

Source

pub fn remove_disable_default_event(&self, event: EventListener)

Re-enables the default view behavior for a previously disabled event.

Source

pub fn pointer_events(&self, pointer_events: bool)

Set if the view should process pointer events

Source

pub fn draggable(&self)

Mark this view as a view that can be dragged

You can customize the apearance of a view while dragging in the style

Source

pub fn window_visible(&self, visible: bool)

Alter the visibility of the current window the view represented by this ID is in.

Source

pub fn update_state_deferred(&self, state: impl Any)

Send a state update that will be placed in deferred messages

Source

pub fn screen_layout(&self) -> Option<ScreenLayout>

Get a layout in screen-coordinates for this view, if possible.

Trait Implementations§

Source§

impl Clone for ViewId

Source§

fn clone(&self) -> ViewId

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 ViewId

Source§

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

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

impl Default for ViewId

Source§

fn default() -> ViewId

Returns the “default value” for a type. Read more
Source§

impl From<KeyData> for ViewId

Source§

fn from(k: KeyData) -> Self

Converts to this type from the input type.
Source§

impl Hash for ViewId

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 Key for ViewId

Source§

fn data(&self) -> KeyData

Gets the KeyData stored in this key. Read more
Source§

fn null() -> Self

Creates a new key that is always invalid and distinct from any non-null key. A null key can only be created through this method (or default initialization of keys made with new_key_type!, which calls this method). Read more
Source§

fn is_null(&self) -> bool

Checks if a key is null. There is only a single null key, that is a.is_null() && b.is_null() implies a == b. Read more
Source§

impl Ord for ViewId

Source§

fn cmp(&self, other: &ViewId) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for ViewId

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for ViewId

Source§

fn partial_cmp(&self, other: &ViewId) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for ViewId

Source§

impl Eq for ViewId

Source§

impl StructuralPartialEq for ViewId

Auto Trait Implementations§

§

impl Freeze for ViewId

§

impl RefUnwindSafe for ViewId

§

impl Send for ViewId

§

impl Sync for ViewId

§

impl Unpin for ViewId

§

impl UnwindSafe for ViewId

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> Downcast for T
where T: Any,

Source§

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

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

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

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

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

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

Source§

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

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

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

Source§

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

Compare self to key and return true if they are equal.
Source§

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

Source§

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

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

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

Source§

const ALIGN: usize = _

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

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> ToOwned for T
where T: Clone,

Source§

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

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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,