pub trait RangeSliderValueIndicatorShape: Any + Debug {
// Required methods
fn get_preferred_size(
&self,
is_enabled: bool,
is_discrete: bool,
label_painter: &TextPainter,
text_scale_factor: f64,
) -> Size;
fn paint(
&self,
app: &mut App,
context: &mut PaintingContext,
center: Offset,
activation_animation: AnyAnimation<f64>,
enable_animation: AnyAnimation<f64>,
is_discrete: Option<bool>,
is_on_top: Option<bool>,
label_painter: &mut TextPainter,
text_scale_factor: Option<f64>,
size_with_overflow: Option<Size>,
parent_box: AnyRenderBox,
slider_theme: &SliderThemeData,
text_direction: Option<TextDirection>,
value: Option<f64>,
thumb: Option<Thumb>,
);
fn as_any(&self) -> &dyn Any;
// Provided methods
fn get_horizontal_shift(
&self,
app: &App,
parent_box: Option<AnyRenderBox>,
center: Option<Offset>,
label_painter: Option<&TextPainter>,
activation_animation: Option<AnyAnimation<f64>>,
text_scale_factor: Option<f64>,
size_with_overflow: Option<Size>,
) -> f64 { ... }
fn eq_shape(&self, other: &dyn RangeSliderValueIndicatorShape) -> bool { ... }
}Expand description
Base class for RangeSlider value indicator shapes.
Equality is eq_shape: identity, as Dart’s default ==, unless the
shape overrides it.
See also:
PaddleRangeSliderValueIndicatorShapefor the defaultRangeSlider’s value indicator shape that paints a custom path with text in it.RangeSliderTickMarkShape, which can be used to create custom shapes for theRangeSlider’s tick marks.RangeSliderThumbShape, which can be used to create custom shapes for theRangeSlider’s thumb.RangeSliderTrackShape, which can be used to create custom shapes for theRangeSlider’s track.SliderComponentShape, which can be used to create custom shapes for theSlider’s thumb, overlay, and value indicator and theRangeSlider’s overlay.
Required Methods§
Sourcefn get_preferred_size(
&self,
is_enabled: bool,
is_discrete: bool,
label_painter: &TextPainter,
text_scale_factor: f64,
) -> Size
fn get_preferred_size( &self, is_enabled: bool, is_discrete: bool, label_painter: &TextPainter, text_scale_factor: f64, ) -> Size
Returns the preferred size of the shape, based on the given conditions.
The is_enabled argument is false when RangeSlider::on_changed is null and
true otherwise. When true, the slider will respond to input.
The is_discrete argument is true if RangeSlider::divisions is non-null.
When true, the slider will render tick marks on top of the track.
The label_painter argument helps determine the width of the shape. It is
variable width because it is derived from a formatted string.
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.
Sourcefn paint(
&self,
app: &mut App,
context: &mut PaintingContext,
center: Offset,
activation_animation: AnyAnimation<f64>,
enable_animation: AnyAnimation<f64>,
is_discrete: Option<bool>,
is_on_top: Option<bool>,
label_painter: &mut TextPainter,
text_scale_factor: Option<f64>,
size_with_overflow: Option<Size>,
parent_box: AnyRenderBox,
slider_theme: &SliderThemeData,
text_direction: Option<TextDirection>,
value: Option<f64>,
thumb: Option<Thumb>,
)
fn paint( &self, app: &mut App, context: &mut PaintingContext, center: Offset, activation_animation: AnyAnimation<f64>, enable_animation: AnyAnimation<f64>, is_discrete: Option<bool>, is_on_top: Option<bool>, label_painter: &mut TextPainter, text_scale_factor: Option<f64>, size_with_overflow: Option<Size>, parent_box: AnyRenderBox, slider_theme: &SliderThemeData, text_direction: Option<TextDirection>, value: Option<f64>, thumb: Option<Thumb>, )
Paints the value indicator shape based on the state passed to it.
The context argument represents the RangeSlider’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 RangeSlider. It reverses when the user stops
interacting with the slider.
The enable_animation argument is an animation triggered when the
RangeSlider is enabled, and it reverses when the slider is disabled. The
RangeSlider is enabled when RangeSlider::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 RangeSlider::divisions is non-null.
When true, the slider will render tick marks on top of the track.
The is_on_top argument is the top-most value indicator between the two value
indicators, which is always the indicator for the most recently selected thumb. In
the default case, this is used to paint a stroke around the top indicator
for better visibility between the two indicators.
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.
The parent_box argument is the RenderBox of the RangeSlider. Its
attributes, such as size, can be used to assist in painting this shape.
The slider_theme argument is the theme assigned to the RangeSlider 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 argument already has the text_direction
set.
The value argument is the current parametric value (from 0.0 to 1.0) of
the slider.
The thumb argument is the specifier for which of the two thumbs this
method should paint (start or end).
None is Dart’s argument left out.
Provided Methods§
Sourcefn get_horizontal_shift(
&self,
app: &App,
parent_box: Option<AnyRenderBox>,
center: Option<Offset>,
label_painter: Option<&TextPainter>,
activation_animation: Option<AnyAnimation<f64>>,
text_scale_factor: Option<f64>,
size_with_overflow: Option<Size>,
) -> f64
fn get_horizontal_shift( &self, app: &App, parent_box: Option<AnyRenderBox>, center: Option<Offset>, label_painter: Option<&TextPainter>, activation_animation: Option<AnyAnimation<f64>>, text_scale_factor: Option<f64>, size_with_overflow: Option<Size>, ) -> f64
Determines the best offset to keep this shape on the screen.
Override this method when the center of the value indicator should be shifted from the vertical center of the thumb.
Sourcefn eq_shape(&self, other: &dyn RangeSliderValueIndicatorShape) -> bool
fn eq_shape(&self, other: &dyn RangeSliderValueIndicatorShape) -> bool
Dart’s ==: identity unless a shape overrides it.
Trait Implementations§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".