Enum masonry::LifeCycle

source ·
#[non_exhaustive]
pub enum LifeCycle { WidgetAdded, AnimFrame(u64), DisabledChanged(bool), BuildFocusChain, RequestPanToChild(Rect), Internal(InternalLifeCycle), }
Expand description

Application life cycle events.

Unlike [Event]s, LifeCycle events are generated by Masonry, and may occur at different times during a given pass of the event loop. The LifeCycle::WidgetAdded event, for instance, may occur when the app first launches (during the handling of [Event::WindowConnected]) or it may occur during an on_event pass, if some widget has been added then.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

WidgetAdded

Sent to a Widget when it is added to the widget tree. This should be the first message that each widget receives.

Widgets should handle this event in order to do any initial setup.

In addition to setup, this event is also used by the framework to track certain types of important widget state.

§Registering children

Container widgets (widgets which use WidgetPod to manage children) must ensure that this event is forwarded to those children. The WidgetPod itself will handle registering those children with the system; this is required for things like correct routing of events.

§

AnimFrame(u64)

Called at the beginning of a new animation frame.

On the first frame when transitioning from idle to animating, interval will be 0. (This logic is presently per-window but might change to per-widget to make it more consistent). Otherwise it is in nanoseconds.

The paint method will be called shortly after this event is finished. As a result, you should try to avoid doing anything computationally intensive in response to an AnimFrame event: it might make the app miss the monitor’s refresh, causing lag or jerky animations.

§

DisabledChanged(bool)

Called when the Disabled state of the widgets is changed.

To check if a widget is disabled, see is_disabled.

To change a widget’s disabled state, see set_disabled.

§

BuildFocusChain

Called when the widget tree changes and Masonry wants to rebuild the Focus-chain.

It is the only place from which register_for_focus should be called. By doing so the widget can get focused by other widgets using focus_next or focus_prev.

§

RequestPanToChild(Rect)

Called when a child widgets uses EventCtx::request_pan_to_this.

§

Internal(InternalLifeCycle)

Internal Masonry lifecycle event.

This should always be passed down to descendant WidgetPods.

Implementations§

source§

impl LifeCycle

source

pub fn should_propagate_to_hidden(&self) -> bool

Whether this event should be sent to widgets which are currently not visible and not accessible.

If a widget changes which children are hidden it must call children_changed. For a more detailed explanation of the hidden state, see Event::should_propagate_to_hidden.

source

pub fn short_name(&self) -> &str

Short name, for debug logging.

Essentially returns the enum variant name.

Trait Implementations§

source§

impl Clone for LifeCycle

source§

fn clone(&self) -> LifeCycle

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 LifeCycle

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> AsAny for T
where T: Any,

source§

fn as_dyn_any(&self) -> &(dyn Any + 'static)

Return self.
source§

fn as_mut_dyn_any(&mut self) -> &mut (dyn Any + 'static)

Return self.
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> 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 + Send + Sync>

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

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

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

§

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

§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

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> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T

source§

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

source§

impl<T> WasmNotSendSync for T

source§

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