pub struct LayoutChanged {
pub new_box: Rect,
pub new_content_box: Rect,
pub new_window_origin: Point,
}Expand description
Event fired when a view’s layout changes
This is fired when the view’s size or position in the layout changes. It does not fire for visual-only changes from transforms (translation, scale, rotation).
§Important: Layout vs Visual Coordinates
WARNING: The window coordinates provided by this event (new_window_origin, box_window(),
content_box_window()) represent the position in the box layout tree, NOT the final visual
position after transforms are applied. If transforms like translation, scale, or rotation are
applied to this view or its ancestors, the actual rendered position will differ from these coordinates.
Use VisualChanged instead if you need the actual rendered position in the window after all
transforms have been applied.
§When to use LayoutChanged vs VisualChanged
- Use
LayoutChanged: When you need layout box sizes or relative positioning within the layout tree - Use
VisualChanged: When you need to know where the view actually appears on screen, or to position elements relative to the view’s visual appearance
§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 don’t need window coordinates unless you’re positioning elements relative to other views’ visual positions or interacting with platform APIs that expect window coordinates.
Use box_local() and content_box_local() to get coordinates in the view’s local space.
Fields§
§new_box: RectThe new layout box relative to the parent layout
new_content_box: RectThe new content box relative to the parent layout
new_window_origin: PointThe position of the layout box’s origin in window coordinates (box layout position, NOT visual position)
WARNING: This does point is not the final vistual position of the view because it intentionally does not include transforms.
Use VisualChanged for actual rendered position.
Implementations§
Source§impl LayoutChanged
impl LayoutChanged
Sourcepub fn listener() -> LayoutChangedListener
pub fn listener() -> LayoutChangedListener
Get the event listener for this custom event
Sourcepub fn extract(event: &Event) -> Option<&LayoutChanged>
pub fn extract(event: &Event) -> Option<&LayoutChanged>
Attempt to extract this event type from a generic [Event].
Equivalent to:
Self::listener_key().extract(event)
Source§impl LayoutChanged
impl LayoutChanged
Sourcepub fn box_local(&self) -> Rect
pub fn box_local(&self) -> Rect
Get the layout box in the view’s local coordinate space (relative to its own origin which is Point::ZERO)
Sourcepub fn content_box_local(&self) -> Rect
pub fn content_box_local(&self) -> Rect
Get the content box in the view’s local coordinate space (relative to the box origin)
Sourcepub fn box_window(&self) -> Rect
pub fn box_window(&self) -> Rect
Get the layout box in window coordinates (box layout position, NOT visual position)
WARNING: This does not include transforms. The actual rendered position may differ
if transforms are applied. Use VisualChanged for the actual visual position.
Sourcepub fn content_box_window(&self) -> Rect
pub fn content_box_window(&self) -> Rect
Get the content box in window coordinates (box layout position, NOT visual position)
WARNING: This does not include transforms. The actual rendered position may differ
if transforms are applied. Use VisualChanged for the actual visual position.
Trait Implementations§
Source§impl Clone for LayoutChanged
impl Clone for LayoutChanged
Source§fn clone(&self) -> LayoutChanged
fn clone(&self) -> LayoutChanged
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 LayoutChanged
Source§impl CustomEvent for LayoutChanged
impl CustomEvent for LayoutChanged
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 LayoutChanged
impl Debug for LayoutChanged
Source§impl PartialEq for LayoutChanged
impl PartialEq for LayoutChanged
Source§fn eq(&self, other: &LayoutChanged) -> bool
fn eq(&self, other: &LayoutChanged) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for LayoutChanged
Auto Trait Implementations§
impl Freeze for LayoutChanged
impl RefUnwindSafe for LayoutChanged
impl Send for LayoutChanged
impl Sync for LayoutChanged
impl Unpin for LayoutChanged
impl UnsafeUnpin for LayoutChanged
impl UnwindSafe for LayoutChanged
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