Skip to main content

RangeSliderTrackShape

Trait RangeSliderTrackShape 

Source
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:

  • RoundedRectRangeSliderTrackShape for the default RangeSlider’s track shape that paints a stadium-like track.
  • RangeSliderTickMarkShape, which can be used to create custom shapes for the RangeSlider’s tick marks.
  • RangeSliderThumbShape, which can be used to create custom shapes for the RangeSlider’s thumb.
  • RangeSliderValueIndicatorShape, which can be used to create custom shapes for the RangeSlider’s value indicator.
  • SliderComponentShape, which can be used to create custom shapes for the Slider’s thumb, overlay, and value indicator and the RangeSlider’s overlay.

Required Methods§

Source

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.

Source

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.

Source

fn as_any(&self) -> &dyn Any

Downcast support for Dart’s is checks.

Provided Methods§

Source

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.

Source

fn eq_shape(&self, other: &dyn RangeSliderTrackShape) -> bool

Dart’s ==: identity unless a shape overrides it.

Trait Implementations§

Source§

impl PartialEq for dyn RangeSliderTrackShape

Source§

fn eq(&self, other: &dyn RangeSliderTrackShape) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§