pub trait RangeSliderTrackShape: Any + Debug {
// Required methods
fn get_preferred_rect(
&self,
app: &App,
parent_box: AnyRenderBox,
offset: Offset,
slider_theme: &SliderThemeData,
is_enabled: Option<bool>,
is_discrete: Option<bool>,
) -> Rect;
fn paint(
&self,
app: &mut App,
context: &mut PaintingContext,
offset: Offset,
parent_box: AnyRenderBox,
slider_theme: &SliderThemeData,
enable_animation: AnyAnimation<f64>,
start_thumb_center: Offset,
end_thumb_center: Offset,
is_enabled: bool,
is_discrete: bool,
text_direction: TextDirection,
);
fn as_any(&self) -> &dyn Any;
// Provided methods
fn is_rounded(&self) -> bool { ... }
fn eq_shape(&self, other: &dyn RangeSliderTrackShape) -> bool { ... }
}Expand description
Base class for RangeSlider track shapes.
The slider’s thumbs move along the track. A discrete slider’s tick marks are drawn after the track, but before the thumb, and are aligned with the track.
The get_preferred_rect helps position the slider thumbs and
tick marks relative to the track.
Equality is eq_shape: identity, as Dart’s default ==, unless the
shape overrides it.
See also:
RoundedRectRangeSliderTrackShapefor the defaultRangeSlider’s track shape that paints a stadium-like track.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.RangeSliderValueIndicatorShape, which can be used to create custom shapes for theRangeSlider’s value indicator.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_rect(
&self,
app: &App,
parent_box: AnyRenderBox,
offset: Offset,
slider_theme: &SliderThemeData,
is_enabled: Option<bool>,
is_discrete: Option<bool>,
) -> Rect
fn get_preferred_rect( &self, app: &App, parent_box: AnyRenderBox, offset: Offset, slider_theme: &SliderThemeData, is_enabled: Option<bool>, is_discrete: Option<bool>, ) -> Rect
Returns the preferred bounds of the shape.
It is used to provide horizontal boundaries for the position of the thumbs, and to help position the slider thumbs and tick marks relative to the track.
The parent_box argument can be used to help determine the preferredRect
relative to attributes of the render box of the slider itself, such as
size.
The offset argument is relative to the caller’s bounding box. It can be
used to convert gesture coordinates from global to slider-relative
coordinates; Dart’s default is Offset.zero.
The slider_theme argument is the theme assigned to the RangeSlider that
this shape belongs to.
The is_enabled argument is false when RangeSlider::on_changed is null and
true otherwise. When true, the slider will respond to input. None is Dart’s
argument left out.
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. None is
Dart’s argument left out.
Sourcefn paint(
&self,
app: &mut App,
context: &mut PaintingContext,
offset: Offset,
parent_box: AnyRenderBox,
slider_theme: &SliderThemeData,
enable_animation: AnyAnimation<f64>,
start_thumb_center: Offset,
end_thumb_center: Offset,
is_enabled: bool,
is_discrete: bool,
text_direction: TextDirection,
)
fn paint( &self, app: &mut App, context: &mut PaintingContext, offset: Offset, parent_box: AnyRenderBox, slider_theme: &SliderThemeData, enable_animation: AnyAnimation<f64>, start_thumb_center: Offset, end_thumb_center: Offset, is_enabled: bool, is_discrete: bool, text_direction: TextDirection, )
Paints the track shape based on the state passed to it.
The context argument is the same as the one that includes the Slider’s
render box.
The offset argument is the offset of the origin of the parent_box to
the origin of its context canvas. This shape must be painted relative
to this offset. See PaintingContextCallback.
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 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 start_thumb_center argument is the offset of the center of the start
thumb relative to the origin of the PaintingContext::canvas. It can be
used as one point that divides the track between inactive and active.
The end_thumb_center argument is the offset of the center of the end
thumb relative to the origin of the PaintingContext::canvas. It can be
used as one point that divides the track between inactive and active.
The is_enabled argument is false when RangeSlider::on_changed is null and
true otherwise. When true, the slider will respond to input; Dart’s default is
false.
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; Dart’s default
is false.
The text_direction argument can be used to determine how the track
segments are painted depending on whether they are on an active track
segment or not.
The track segment between the two thumbs is the active track segment. The
track segments between the thumb and each end of the slider are the inactive
track segments. In TextDirection::Ltr, the start of the slider is on the
left, and in TextDirection::Rtl, the start of the slider is on the right.
Provided Methods§
Sourcefn is_rounded(&self) -> bool
fn is_rounded(&self) -> bool
Whether the track shape is rounded. This is used to determine the correct position of the thumbs in relation to the track. Defaults to false.
Sourcefn eq_shape(&self, other: &dyn RangeSliderTrackShape) -> bool
fn eq_shape(&self, other: &dyn RangeSliderTrackShape) -> 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".