pub struct VisualChanged {
pub new_visual_aabb: Rect,
pub new_world_transform: Affine,
}Expand description
Event fired when a view’s visual representation in the window changes.
This is fired when the view’s final rendered position or transform changes, including changes from CSS-like transforms (translation, scale, rotation). This represents the view’s actual visual appearance in the window after all transforms have been applied.
§Important: Visual vs Layout Coordinates
Use this event when you need to know where the view actually appears on screen. The coordinates and transform provided here reflect the final rendered state after all transforms (translation, scale, rotation) from this view and all ancestors have been applied.
§When to use VisualChanged vs LayoutChanged
- Use
VisualChanged: When you need the actual rendered position on screen, or to position elements relative to where a view visually appears (e.g., tooltips, popovers, overlays) - Use
LayoutChanged: When you only care about layout box sizes or relative positioning within the layout tree, ignoring transforms
§Coordinate Spaces in Floem
Note: All event handling and painting in Floem happen in the view’s local coordinate space. Floem automatically handles transformations to and from local coordinates. You typically only need visual window coordinates when positioning separate elements (like overlays or platform windows) relative to a view’s visual appearance, or when interacting with platform APIs that expect window coordinates.
§Use Cases for VisualChanged
- Positioning tooltips or popovers relative to a transformed view
- Implementing drag-and-drop with visual feedback
- Coordinating with platform overlays or native windows
- Calculating whether two views visually overlap on screen
Fields§
§new_visual_aabb: RectThe new axis-aligned bounding box in window coordinates after all transforms
This is the smallest rectangle that contains the view after all transforms are applied. For rotated views, this will be larger than the view’s layout box.
new_world_transform: AffineThe new world transform matrix combining all parent and local transforms
This transform maps from the view’s local coordinate space to window coordinates.
Implementations§
Source§impl VisualChanged
impl VisualChanged
Sourcepub fn listener() -> VisualChangedListener
pub fn listener() -> VisualChangedListener
Get the event listener for this custom event
Sourcepub fn extract(event: &Event) -> Option<&VisualChanged>
pub fn extract(event: &Event) -> Option<&VisualChanged>
Attempt to extract this event type from a generic [Event].
Equivalent to:
Self::listener_key().extract(event)
Source§impl VisualChanged
impl VisualChanged
Sourcepub fn visual_window_origin(&self) -> Point
pub fn visual_window_origin(&self) -> Point
Get the visual origin of the view in window coordinates
This returns the top-left corner of the visual bounding box after all transforms.
Note that for rotated or scaled views, this may not correspond directly to the
layout box origin transformed by new_world_transform.
Sourcepub fn local_to_window(&self, local_point: Point) -> Point
pub fn local_to_window(&self, local_point: Point) -> Point
Transform a point from the view’s local coordinate space to window coordinates
This applies the full world transform to convert a point in the view’s local coordinate space to its position in the window.
Sourcepub fn window_to_local(&self, window_point: Point) -> Point
pub fn window_to_local(&self, window_point: Point) -> Point
Transform a point from window coordinates to the view’s local coordinate space
This applies the inverse world transform to convert a point in window coordinates
to the view’s local coordinate space. Returns None if the transform is not invertible.
Trait Implementations§
Source§impl Clone for VisualChanged
impl Clone for VisualChanged
Source§fn clone(&self) -> VisualChanged
fn clone(&self) -> VisualChanged
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for VisualChanged
Source§impl CustomEvent for VisualChanged
impl CustomEvent for VisualChanged
Source§fn listener_key() -> EventListenerKey
fn listener_key() -> EventListenerKey
Source§fn listener_key_dyn(&self) -> EventListenerKey
fn listener_key_dyn(&self) -> EventListenerKey
fn allow_disabled(&self) -> bool
Source§fn clone_box(&self) -> Box<dyn CustomEvent>
fn clone_box(&self) -> Box<dyn CustomEvent>
fn transform(&mut self, transform: Affine)
Source§impl Debug for VisualChanged
impl Debug for VisualChanged
Source§impl PartialEq for VisualChanged
impl PartialEq for VisualChanged
Source§fn eq(&self, other: &VisualChanged) -> bool
fn eq(&self, other: &VisualChanged) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for VisualChanged
Auto Trait Implementations§
impl Freeze for VisualChanged
impl RefUnwindSafe for VisualChanged
impl Send for VisualChanged
impl Sync for VisualChanged
impl Unpin for VisualChanged
impl UnsafeUnpin for VisualChanged
impl UnwindSafe for VisualChanged
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
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>
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>
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)
&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)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§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>
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