pub struct ElementId(/* private fields */);Expand description
A visual identifier that represents a rectangle in the box tree.
§ViewId vs ElementId Relationship
ViewId represents a logical view in the view tree (1:1 with View instances). ElementId represents a visual rectangle in the box tree (can be many per View).
§Key Relationships:
- Each View has exactly one primary ViewId (1:1)
- Each View can create multiple ElementIds for sub-widget rectangles (1:many)
- Example: A scroll view creates VisualIds for content area, vertical scrollbar, horizontal scrollbar
- Each VisualId maps back to exactly one ViewId for event routing (many:1)
- Call
element_id.view_id()to get the owning ViewId
- Call
§Usage:
- Hit testing operates on VisualIds (tests against individual rectangles in box tree)
- Event handling happens on ViewIds (the view receives events with target VisualId)
- Painting iterates through VisualIds in z-index order from the box tree
- View hierarchy uses ViewIds for parent/child relationships
§Structure:
.0: The box tree NodeId (identifies the rectangle in the spatial index).1: The owning ViewId (identifies which view this rectangle belongs to)
§Example:
ⓘ
// A scroll view might create these VisualIds:
let scroll_view_id = ViewId::new();
let content_element_id = VisualId(node_id_1, scroll_view_id); // content area
let vscroll_element_id = VisualId(node_id_2, scroll_view_id); // vertical scrollbar
let hscroll_element_id = VisualId(node_id_3, scroll_view_id); // horizontal scrollbar
// All three VisualIds route events to the same scroll_view_id:
assert_eq!(content_element_id.view_id(), scroll_view_id);
assert_eq!(vscroll_element_id.view_id(), scroll_view_id);
assert_eq!(hscroll_element_id.view_id(), scroll_view_id);
// But hit testing can distinguish which specific rectangle was hitImplementations§
Trait Implementations§
impl Copy for ElementId
impl Eq for ElementId
impl StructuralPartialEq for ElementId
Auto Trait Implementations§
impl !Send for ElementId
impl !Sync for ElementId
impl Freeze for ElementId
impl RefUnwindSafe for ElementId
impl Unpin for ElementId
impl UnsafeUnpin for ElementId
impl UnwindSafe for ElementId
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
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.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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.§fn as_any(&self) -> &(dyn Any + 'static)
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.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
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.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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 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>
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