pub trait SliderComponentShape: Any + Debug {
// Required methods
fn get_preferred_size(&self, is_enabled: bool, is_discrete: bool) -> Size;
fn paint(
&self,
app: &mut App,
context: &mut PaintingContext,
center: Offset,
activation_animation: AnyAnimation<f64>,
enable_animation: AnyAnimation<f64>,
is_discrete: bool,
label_painter: &mut TextPainter,
parent_box: AnyRenderBox,
slider_theme: &SliderThemeData,
text_direction: TextDirection,
value: f64,
text_scale_factor: f64,
size_with_overflow: Size,
);
fn as_any(&self) -> &dyn Any;
// Provided method
fn eq_shape(&self, other: &dyn SliderComponentShape) -> bool { ... }
}Expand description
Base class for slider thumb, thumb overlay, and value indicator shapes.
Create a subclass of this if you would like a custom shape.
All shapes are painted to the same canvas and ordering is important. The overlay is painted first, then the value indicator, then the thumb.
The thumb painting can be skipped by specifying [no_thumb](SliderThemeData::thumb_shape.
The overlay painting can be skipped by specifying
[no_overlay](SliderThemeData::overlay_shape.
Equality is eq_shape: identity, as Dart’s default ==, unless the
shape overrides it.
See also:
RoundSliderThumbShape, which is the defaultSlider’s thumb shape that paints a solid circle.RoundSliderOverlayShape, which is the defaultSliderandRangeSlider’s overlay shape that paints a transparent circle.PaddleSliderValueIndicatorShape, which is the defaultSlider’s value indicator shape that paints a custom path with text in it.
Required Methods§
Sourcefn get_preferred_size(&self, is_enabled: bool, is_discrete: bool) -> Size
fn get_preferred_size(&self, is_enabled: bool, is_discrete: bool) -> Size
Returns the preferred size of the shape, based on the given conditions.
Sourcefn paint(
&self,
app: &mut App,
context: &mut PaintingContext,
center: Offset,
activation_animation: AnyAnimation<f64>,
enable_animation: AnyAnimation<f64>,
is_discrete: bool,
label_painter: &mut TextPainter,
parent_box: AnyRenderBox,
slider_theme: &SliderThemeData,
text_direction: TextDirection,
value: f64,
text_scale_factor: f64,
size_with_overflow: Size,
)
fn paint( &self, app: &mut App, context: &mut PaintingContext, center: Offset, activation_animation: AnyAnimation<f64>, enable_animation: AnyAnimation<f64>, is_discrete: bool, label_painter: &mut TextPainter, parent_box: AnyRenderBox, slider_theme: &SliderThemeData, text_direction: TextDirection, value: f64, text_scale_factor: f64, size_with_overflow: Size, )
Paints the shape, taking into account the state passed to it.
The context argument is the same as the one that includes the Slider’s
render box.
The center argument is the offset for where this shape’s center should be
painted. This offset is relative to the origin of the context canvas.
The activation_animation argument is an animation triggered when the user
begins to interact with the slider. It reverses when the user stops interacting
with the slider.
The enable_animation argument is an animation triggered when the Slider
is enabled, and it reverses when the slider is disabled. The Slider is
enabled when Slider::on_changed is not null. Use this to paint
intermediate frames for this shape when the slider changes enabled state.
The is_discrete argument is true if Slider::divisions is non-null. When
true, the slider will render tick marks on top of the track.
If the label_painter argument is non-null, then TextPainter::paint
should be called on the label_painter with the location that the label
should appear. If the label_painter argument is null, then no label was
supplied to the Slider.
The parent_box argument is the RenderBox of the Slider. Its attributes,
such as size, can be used to assist in painting this shape.
the slider_theme argument is the theme assigned to the Slider that this
shape belongs to.
The text_direction argument can be used to determine how any extra text
or graphics (besides the text painted by the label_painter) should be
positioned. The label_painter already has the text_direction set.
The value argument is the current parametric value (from 0.0 to 1.0) of
the slider.
The text_scale_factor argument can be used to determine whether the
component should paint larger or smaller, depending on whether
text_scale_factor is greater than 1 for larger, and between 0 and 1 for
smaller. It’s usually computed from MediaQueryData::text_scaler.
The size_with_overflow argument can be used to determine the bounds the
drawing of the components that are outside of the regular slider bounds.
It’s the size of the box, whose center is aligned with the slider’s
bounds, that the value indicators must be drawn within. Typically, it is
bigger than the slider.
Provided Methods§
Sourcefn eq_shape(&self, other: &dyn SliderComponentShape) -> bool
fn eq_shape(&self, other: &dyn SliderComponentShape) -> bool
Dart’s ==: identity unless a shape overrides it.
Implementations§
Source§impl dyn SliderComponentShape
impl dyn SliderComponentShape
Sourcepub fn no_thumb() -> SliderComponentShapeRef
pub fn no_thumb() -> SliderComponentShapeRef
Special instance of SliderComponentShape to skip the thumb drawing.
Each call hands out the same instance, as Dart’s static final field is one object.
See also:
SliderThemeData::thumb_shape, which is the shape that theSlideruses when painting the thumb.
Sourcepub fn no_overlay() -> SliderComponentShapeRef
pub fn no_overlay() -> SliderComponentShapeRef
Special instance of SliderComponentShape to skip the overlay drawing.
Each call hands out the same instance, as Dart’s static final field is one object.
See also:
SliderThemeData::overlay_shape, which is the shape that theSlideruses when painting the overlay.
Trait Implementations§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".