Skip to main content

MagnifierController

Struct MagnifierController 

Source
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

Source

pub fn new(app: &mut App) -> Ref<MagnifierController>

If there is no in / out animation for the magnifier, animation_controller should be left unset.

Source

pub fn animation_controller( self: Ref<Self>, app: &mut App, animation_controller: Ref<AnimationController>, ) -> Ref<Self>

Dart MagnifierController(animationController:).

Source

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.

Source

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.

Source

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.

Source

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:

Source

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.

Source

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.

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> 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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>