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:
ElevatedButtonTextButtonOutlinedButton
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
impl InkSparkle
Sourcepub 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>
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:
- If
custom_borderis provided, it is used to determine the path for clipping. - If
custom_borderis null, andborder_radiusis provided, then the canvas is clipped by anRRectcreated fromborder_radius. - If
border_radiusis the defaultBorderRadius::ZERO, then the canvas is clipped withrect_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.
Sourcepub fn splash_factory() -> InteractiveInkFeatureFactoryRef
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.
Sourcepub fn constant_turbulence_seed_splash_factory() -> InteractiveInkFeatureFactoryRef
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
impl InkFeatureLeaf for InkSparkle
Source§impl InkFeatureLeafData for InkSparkle
impl InkFeatureLeafData for InkSparkle
Source§fn ink_feature(&self) -> &InkFeatureData
fn ink_feature(&self) -> &InkFeatureData
InkFeature bag.Source§fn ink_feature_mut(&mut self) -> &mut InkFeatureData
fn ink_feature_mut(&mut self) -> &mut InkFeatureData
InkFeature bag, mutably.Source§impl InteractiveInkFeatureLeafData for InkSparkle
impl InteractiveInkFeatureLeafData for InkSparkle
Source§fn interactive_ink_feature(&self) -> &InteractiveInkFeatureData
fn interactive_ink_feature(&self) -> &InteractiveInkFeatureData
InteractiveInkFeature bag.Source§fn interactive_ink_feature_mut(&mut self) -> &mut InteractiveInkFeatureData
fn interactive_ink_feature_mut(&mut self) -> &mut InteractiveInkFeatureData
InteractiveInkFeature bag, mutably.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 InkSparklewhere
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 InkSparklewhere
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 InkSparklewhere
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<F> InkFeatureObject for Fwhere
F: InkFeatureLeaf,
impl<F> InkFeatureObject for Fwhere
F: InkFeatureLeaf,
Source§fn as_ink_feature(self: Handle<F>) -> AnyInkFeature
fn as_ink_feature(self: Handle<F>) -> AnyInkFeature
AnyInkFeature — what to pass where a Dart API takes an
InkFeature.Source§impl<F> InteractiveInkFeatureObject for Fwhere
F: InteractiveInkFeatureLeaf,
impl<F> InteractiveInkFeatureObject for Fwhere
F: InteractiveInkFeatureLeaf,
Source§fn as_interactive_ink_feature(self: Handle<F>) -> AnyInteractiveInkFeature
fn as_interactive_ink_feature(self: Handle<F>) -> AnyInteractiveInkFeature
AnyInteractiveInkFeature — what to pass where a Dart API
takes an InteractiveInkFeature.