pub struct MagnifierController {
pub animation_controller: Option<Ref<AnimationController>>,
/* private fields */
}Expand description
A controller for a magnifier.
MagnifierController’s main benefit over holding a raw OverlayEntry is that
MagnifierController will handle logic around waiting for a magnifier to animate in or out.
If a magnifier chooses to have an entry / exit animation, it should provide the animation
controller to MagnifierController::animation_controller. MagnifierController will then drive
the AnimationController and wait for it to be complete before removing it from the
Overlay.
To check the status of the magnifier, see MagnifierController::shown.
Fields§
§animation_controller: Option<Ref<AnimationController>>The controller that will be driven in / out when show / hide is triggered, respectively.
Implementations§
Source§impl MagnifierController
impl MagnifierController
Sourcepub fn new(app: &mut App) -> Ref<MagnifierController>
pub fn new(app: &mut App) -> Ref<MagnifierController>
If there is no in / out animation for the magnifier, animation_controller
should be left unset.
Sourcepub fn animation_controller(
self: Ref<Self>,
app: &mut App,
animation_controller: Ref<AnimationController>,
) -> Ref<Self>
pub fn animation_controller( self: Ref<Self>, app: &mut App, animation_controller: Ref<AnimationController>, ) -> Ref<Self>
Dart MagnifierController(animationController:).
Sourcepub fn overlay_entry(
self: Handle<Self>,
app: &App,
) -> Option<Handle<OverlayEntry>>
pub fn overlay_entry( self: Handle<Self>, app: &App, ) -> Option<Handle<OverlayEntry>>
The magnifier’s OverlayEntry, if currently in the overlay.
This is exposed so that other overlay entries can be positioned above or
below this overlay_entry. Anything in the paint order after the
RawMagnifier in this OverlayEntry will not be displayed in the
magnifier; if it is desired for an overlay entry to be displayed in the
magnifier, it must be positioned below the magnifier.
To check if a magnifier is in the overlay, use shown. The
overlay_entry field may be non-null even when the magnifier is
not visible.
Sourcepub fn shown(self: Handle<Self>, app: &App) -> bool
pub fn shown(self: Handle<Self>, app: &App) -> bool
Whether the magnifier is currently being shown.
This is false when nothing is in the overlay, when the
animation_controller is in the
waft_animation::AnimationStatus::Dismissed state, or when
the animation_controller is animating out (i.e. in the
waft_animation::AnimationStatus::Reverse state).
It is true in the opposite cases, i.e. when the overlay is not empty, and
either the animation_controller is None, in the
waft_animation::AnimationStatus::Completed state, or in the
waft_animation::AnimationStatus::Forward
state.
Sourcepub fn show(
self: Handle<Self>,
app: &mut App,
context: BuildContext,
builder: WidgetBuilder,
below: Option<Handle<OverlayEntry>>,
) -> TickerFuture ⓘ
pub fn show( self: Handle<Self>, app: &mut App, context: BuildContext, builder: WidgetBuilder, below: Option<Handle<OverlayEntry>>, ) -> TickerFuture ⓘ
Displays the magnifier.
Returns a future that completes when the magnifier is fully shown, i.e. done with its entry animation.
To control what overlays are shown in the magnifier, use below. See
overlay_entry for more details on how to utilize below.
If the magnifier already exists (i.e. overlay_entry is Some),
then show will replace the old overlay without playing an exit
animation. Consider awaiting hide first, to animate from the old
magnifier to the new one.
Sourcepub fn hide(
self: Handle<Self>,
app: &mut App,
remove_from_overlay: bool,
) -> TickerFuture ⓘ
pub fn hide( self: Handle<Self>, app: &mut App, remove_from_overlay: bool, ) -> TickerFuture ⓘ
Schedules a hide of the magnifier.
If this MagnifierController has an animation_controller,
then hide reverses the animation controller and waits
for the animation to complete. Then, if remove_from_overlay
is true, remove the magnifier from the overlay.
In general, remove_from_overlay should be true, unless
the magnifier needs to preserve states between shows / hides.
See also:
remove_from_overlaywhich removes theOverlayEntryfrom theOverlaysynchronously.
Sourcepub fn remove_from_overlay(self: Handle<Self>, app: &mut App)
pub fn remove_from_overlay(self: Handle<Self>, app: &mut App)
Remove the OverlayEntry from the Overlay.
This method removes the OverlayEntry synchronously,
regardless of exit animation: this leads to abrupt removals
of OverlayEntrys with animations.
To allow the OverlayEntry to play its exit animation, consider calling
hide instead, with remove_from_overlay set to true, and optionally await
the returned future.
Sourcepub fn shift_within_bounds(rect: Rect, bounds: Rect) -> Rect
pub fn shift_within_bounds(rect: Rect, bounds: Rect) -> Rect
A utility for calculating a new Rect from rect such that
rect is fully constrained within bounds.
Any point in the output rect is guaranteed to also be a point contained in bounds.
It is a runtime error for rect.width to be greater than bounds.width,
and it is also an error for rect.height to be greater than bounds.height.
This algorithm translates rect the shortest distance such that it is entirely within
bounds.
If rect is already within bounds, no shift will be applied to rect and
rect will be returned as-is.
It is perfectly valid for the output rect to have a point along the edge of the
bounds. If the desired output rect requires that no edges are parallel to edges
of bounds, see Rect::deflate by 1 on bounds to achieve this effect.