#[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
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 WidgetPod
s.
Implementations§
source§impl LifeCycle
impl LifeCycle
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
.
sourcepub fn short_name(&self) -> &str
pub fn short_name(&self) -> &str
Short name, for debug logging.
Essentially returns the enum variant name.