Skip to main content

InkSparkle

Struct InkSparkle 

Source
pub struct InkSparkle { /* private fields */ }
Expand description

Begin a Material 3 ink sparkle ripple, centered at the tap or click position relative to the reference_box.

To use this effect, pass an instance of InkSparkle::splash_factory to the splash_factory parameter of either the Material ThemeData or any component that has a splash_factory parameter, such as buttons:

  • ElevatedButton
  • TextButton
  • OutlinedButton

The controller argument is typically obtained via Material::of(app, context).

If contained_ink_well is true, then the effect will be sized to fit the well rectangle, and clipped to it when drawn. The well rectangle is the box returned by rect_callback, if provided, or otherwise is the bounds of the reference_box.

If contained_ink_well is false, then rect_callback should be null. The ink ripple is clipped only to the edges of the Material. This is the default.

When the ripple is removed, on_removed will be called.

For typical use, pass the InkSparkle::splash_factory to the splash_factory parameter of a button style or ThemeData.

Implementations§

Source§

impl InkSparkle

Source

pub fn new( app: &mut App, controller: AnyMaterialInkController, reference_box: AnyRenderBox, color: Color, position: Offset, text_direction: TextDirection, contained_ink_well: bool, rect_callback: Option<RectCallback>, border_radius: Option<BorderRadius>, custom_border: Option<ShapeBorderRef>, radius: Option<f64>, on_removed: Option<Listener>, turbulence_seed: Option<f64>, ) -> Ref<InkSparkle>

Begin a sparkly ripple effect, centered at position relative to reference_box.

The color defines the color of the splash itself. The sparkles are always white.

The controller argument is typically obtained via Material::of(app, context).

text_direction is used by custom_border if it is non-null. This allows the custom_border’s path to be properly defined if it was the path was expressed in terms of “start” and “end” instead of “left” and “right”.

If contained_ink_well is true, then the ripple will be sized to fit the well rectangle, then clipped to it when drawn. The well rectangle is the box returned by rect_callback, if provided, or otherwise is the bounds of the reference_box.

If contained_ink_well is false, then rect_callback should be null. The ink ripple is clipped only to the edges of the Material. This is the default.

Clipping can happen in 3 different ways:

  1. If custom_border is provided, it is used to determine the path for clipping.
  2. If custom_border is null, and border_radius is provided, then the canvas is clipped by an RRect created from border_radius.
  3. If border_radius is the default BorderRadius::ZERO, then the canvas is clipped with rect_callback.

When the ripple is removed, on_removed will be called.

turbulence_seed can be passed if a non random seed should be used for the turbulence and sparkles. By default, the seed is a random number between 0.0 and 1000.0.

Turbulence is an input to the shader and helps to provides a more natural, non-circular, “splash” effect.

Sparkle randomization is also driven by the turbulence_seed. Sparkles are identified in the shader as “noise”, and the sparkles are derived from pseudorandom triangular noise.

Dart’s default contained_ink_well is true.

Source

pub fn splash_factory() -> InteractiveInkFeatureFactoryRef

Used to specify this type of ink splash for an InkWell, InkResponse, material Theme, or ButtonStyle.

Since no turbulence_seed is passed, the effect will be random for subsequent presses in the same position.

Dart’s static const: every call hands out the same factory, so they compare equal.

Source

pub fn constant_turbulence_seed_splash_factory() -> InteractiveInkFeatureFactoryRef

Used to specify this type of ink splash for an InkWell, InkResponse, material Theme, or ButtonStyle.

Since a turbulence_seed is passed, the effect will not be random for subsequent presses in the same position. This can be used for testing.

Dart’s static const: every call hands out the same factory, so they compare equal.

Trait Implementations§

Source§

impl InkFeatureLeaf for InkSparkle

Source§

fn dispose(self: Handle<Self>, app: &mut App)

Free up the resources associated with this ink feature. Read more
Source§

fn paint_feature( self: Handle<Self>, app: &mut App, canvas: &mut Canvas, transform: &Matrix4, )

Override this method to paint the ink feature. Read more
Source§

impl InkFeatureLeafData for InkSparkle

Source§

fn ink_feature(&self) -> &InkFeatureData

The leaf’s InkFeature bag.
Source§

fn ink_feature_mut(&mut self) -> &mut InkFeatureData

The leaf’s InkFeature bag, mutably.
Source§

impl InteractiveInkFeatureLeaf for InkSparkle

Source§

fn confirm(self: Handle<Self>, app: &mut App)

Called when the user input that triggered this feature’s appearance was confirmed. Read more
Source§

fn cancel(self: Handle<Self>, app: &mut App)

Called when the user input that triggered this feature’s appearance was canceled. Read more
Source§

impl InteractiveInkFeatureLeafData for InkSparkle

Auto Trait Implementations§

§

impl !RefUnwindSafe for InkSparkle

§

impl !Send for InkSparkle

§

impl !Sync for InkSparkle

§

impl !UnwindSafe for InkSparkle

§

impl Forget for InkSparkle

§

impl Freeze for InkSparkle
where NonZero<u32>: Freeze, PhantomData<fn() -> RenderInkFeatures>: Freeze, &'static RenderBoxVTable: Freeze, *const RcInner<dyn Fn(&mut App)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App)>>: Freeze, *const (): Freeze, *const RcInner<dyn ShapeBorder> is !null: Freeze, PhantomData<RcInner<dyn ShapeBorder>>: Freeze, PhantomData<fn() -> AnimationController>: Freeze, *const RcInner<Keep> is !null: Freeze, PhantomData<RcInner<Keep>>: Freeze, &'static AnimationVTable<Offset>: Freeze, &'static AnimationVTable<f64>: Freeze, *const RcInner<dyn Fn(&App) -> Rect> is !null: Freeze, PhantomData<RcInner<dyn Fn(&App) -> Rect>>: Freeze, *const ArcInner<FragmentProgram> is !null: Freeze, PhantomData<ArcInner<FragmentProgram>>: Freeze, *const u8 is !null: Freeze, PhantomData<f32>: Freeze, PhantomData<Option<EffectImage>>: Freeze,

§

impl Move for InkSparkle

§

impl Unpin for InkSparkle
where NonZero<u32>: Unpin, &'static RenderBoxVTable: Unpin, Rc<dyn Fn(&mut App)>: Unpin, *const (): Unpin, Rc<dyn ShapeBorder>: Unpin, Rc<Keep>: Unpin, &'static AnimationVTable<Offset>: Unpin, &'static AnimationVTable<f64>: Unpin, Rc<dyn Fn(&App) -> Rect>: Unpin, Arc<FragmentProgram>: Unpin, *const u8 is !null: Unpin, Arc<ImageInner>: Unpin,

§

impl UnsafeUnpin for InkSparkle
where NonZeroU32Inner: UnsafeUnpin, PhantomData<fn() -> RenderInkFeatures>: UnsafeUnpin, &'static RenderBoxVTable: UnsafeUnpin, *const RcInner<dyn Fn(&mut App)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App)>>: UnsafeUnpin, *const (): UnsafeUnpin, *const RcInner<dyn ShapeBorder> is !null: UnsafeUnpin, PhantomData<RcInner<dyn ShapeBorder>>: UnsafeUnpin, PhantomData<fn() -> AnimationController>: UnsafeUnpin, *const RcInner<Keep> is !null: UnsafeUnpin, PhantomData<RcInner<Keep>>: UnsafeUnpin, &'static AnimationVTable<Offset>: UnsafeUnpin, &'static AnimationVTable<f64>: UnsafeUnpin, *const RcInner<dyn Fn(&App) -> Rect> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&App) -> Rect>>: UnsafeUnpin, *const ArcInner<FragmentProgram> is !null: UnsafeUnpin, PhantomData<ArcInner<FragmentProgram>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<f32>: UnsafeUnpin, PhantomData<Option<EffectImage>>: UnsafeUnpin,

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<F> InkFeatureObject for F
where F: InkFeatureLeaf,

Source§

fn as_ink_feature(self: Handle<F>) -> AnyInkFeature

This feature as the erased AnyInkFeature — what to pass where a Dart API takes an InkFeature.
Source§

impl<F> InteractiveInkFeatureObject for F

Source§

fn as_interactive_ink_feature(self: Handle<F>) -> AnyInteractiveInkFeature

This feature as the erased AnyInteractiveInkFeature — what to pass where a Dart API takes an InteractiveInkFeature.
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>