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
impl ViewId
Sourcepub fn new_taffy_node(&self) -> NodeId
pub fn new_taffy_node(&self) -> NodeId
Create a new taffy layout node
Sourcepub fn set_taffy_style(&self, node: NodeId, style: Style)
pub fn set_taffy_style(&self, node: NodeId, style: Style)
Set the layout properties on a taffy node
Sourcepub fn taffy_layout(&self, node: NodeId) -> Option<Layout>
pub fn taffy_layout(&self, node: NodeId) -> Option<Layout>
Get the layout for a taffy node relative to it’s parent
Sourcepub fn taffy_node(&self) -> NodeId
pub fn taffy_node(&self) -> NodeId
Get the taffy node associated with this Id
Sourcepub fn set_children(&self, children: Vec<impl IntoView>)
pub fn set_children(&self, children: Vec<impl IntoView>)
Set the children views of this Id
Sourcepub fn set_view(&self, view: Box<dyn View>)
pub fn set_view(&self, view: Box<dyn View>)
Set the view that should be associated with this Id
Sourcepub fn set_parent(&self, parent: ViewId)
pub fn set_parent(&self, parent: ViewId)
Set the Id that should be used as the parent of this Id
Sourcepub fn set_children_ids(&self, children: Vec<ViewId>)
pub fn set_children_ids(&self, children: Vec<ViewId>)
Set the Ids that should be used as the children of this Id
Sourcepub fn children(&self) -> Vec<ViewId>
pub fn children(&self) -> Vec<ViewId>
Get the list of ViewIds that are associated with the children views of this ViewId
Sourcepub fn parent(&self) -> Option<ViewId>
pub fn parent(&self) -> Option<ViewId>
Get the ViewId that has been set as this ViewId’s parent
Sourcepub fn layout_rect(&self) -> Rect
pub fn layout_rect(&self) -> Rect
Get the computed rectangle that covers the area of this View
Sourcepub fn parent_size(&self) -> Option<Size>
pub fn parent_size(&self) -> Option<Size>
Get the Size of the parent View
Sourcepub fn get_content_rect(&self) -> Rect
pub fn get_content_rect(&self) -> Rect
Returns the layout rect excluding borders, padding and position. This is relative to the view.
Sourcepub fn get_layout(&self) -> Option<Layout>
pub fn get_layout(&self) -> Option<Layout>
This gets the Taffy Layout and adjusts it to be relative to the parent View
.
Returns true if the computed style for this view is marked as hidden (Display::None)
Is this view, or any parent view, marked as hidden
Sourcepub fn request_all(&self)
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.
Sourcepub fn request_layout(&self)
pub fn request_layout(&self)
Request that this view have it’s layout pass run
Sourcepub fn window_id(&self) -> Option<WindowId>
pub fn window_id(&self) -> Option<WindowId>
Get the window id of the window containing this view, if there is one.
Sourcepub fn request_paint(&self)
pub fn request_paint(&self)
Request that this view have it’s paint pass run
Sourcepub fn request_style(&self)
pub fn request_style(&self)
request that this node be styled again This will recursively request style for all parents.
Sourcepub fn request_focus(&self)
pub fn request_focus(&self)
Request that this view gain the window focus
Sourcepub fn clear_focus(&self)
pub fn clear_focus(&self)
Clear the focus from this window
Set the system context menu that should be shown when this view is right-clicked
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.
Sourcepub fn request_active(&self)
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.
Sourcepub fn clear_active(&self)
pub fn clear_active(&self)
Request that the active state be removed from this View
Sourcepub fn scroll_to(&self, rect: Option<Rect>)
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.
Sourcepub fn update_state(&self, state: impl Any)
pub fn update_state(&self, state: impl Any)
Send a state update to the update
method of the associated View
Sourcepub fn add_event_listener(
&self,
listener: EventListener,
action: Box<EventCallback>,
)
pub fn add_event_listener( &self, listener: EventListener, action: Box<EventCallback>, )
Add an callback on an action for a given EventListener
Sourcepub fn update_resize_listener(&self, action: Box<ResizeCallback>)
pub fn update_resize_listener(&self, action: Box<ResizeCallback>)
Set a callback that should be run when the size of the view changes
Sourcepub fn update_move_listener(&self, action: Box<dyn Fn(Point)>)
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
Sourcepub fn update_cleanup_listener(&self, action: Box<dyn Fn()>)
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
Sourcepub fn get_combined_style(&self) -> Style
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.
Sourcepub fn add_class(&self, class: StyleClassRef)
pub fn add_class(&self, class: StyleClassRef)
Add a class to the list of style classes that are associated with this ViewId
Sourcepub fn remove_class(&self, class: StyleClassRef)
pub fn remove_class(&self, class: StyleClassRef)
Remove a class from the list of style classes that are associated with this ViewId
Sourcepub fn update_disabled(&self, is_disabled: bool)
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.
Mark this view as a view that can be navigated to using the keyboard
Mark this view as a view that can not be navigated to using the keyboard
Sourcepub fn disable_default_event(&self, event: EventListener)
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
Sourcepub fn remove_disable_default_event(&self, event: EventListener)
pub fn remove_disable_default_event(&self, event: EventListener)
Re-enables the default view behavior for a previously disabled event.
Sourcepub fn pointer_events(&self, pointer_events: bool)
pub fn pointer_events(&self, pointer_events: bool)
Set if the view should process pointer events
Sourcepub fn draggable(&self)
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
Sourcepub fn window_visible(&self, visible: bool)
pub fn window_visible(&self, visible: bool)
Alter the visibility of the current window the view represented by this ID is in.
Sourcepub fn update_state_deferred(&self, state: impl Any)
pub fn update_state_deferred(&self, state: impl Any)
Send a state update that will be placed in deferred messages
Sourcepub fn screen_layout(&self) -> Option<ScreenLayout>
pub fn screen_layout(&self) -> Option<ScreenLayout>
Get a layout in screen-coordinates for this view, if possible.
Trait Implementations§
Source§impl Key for ViewId
impl Key for ViewId
Source§fn null() -> Self
fn null() -> Self
new_key_type!
, which calls this
method). Read moreSource§impl Ord for ViewId
impl Ord for ViewId
Source§impl PartialOrd for ViewId
impl PartialOrd for ViewId
impl Copy for ViewId
impl Eq for ViewId
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> 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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