public override void paint(
            PaintingContext context,
            Offset center,
            RenderBox parentBox               = null,
            SliderThemeData sliderTheme       = null,
            Animation <float> enableAnimation = null,
            Offset thumbCenter = null,
            bool?isEnabled     = null
            )
        {
            Color begin;
            Color end;

            bool isTickMarkRightOfThumb = center.dx > thumbCenter.dx;

            begin = isTickMarkRightOfThumb
                ? sliderTheme.disabledInactiveTickMarkColor
                : sliderTheme.disabledActiveTickMarkColor;
            end = isTickMarkRightOfThumb ? sliderTheme.inactiveTickMarkColor : sliderTheme.activeTickMarkColor;

            Paint paint = new Paint {
                color = new ColorTween(begin: begin, end: end).evaluate(enableAnimation)
            };

            float tickMarkRadius = this.getPreferredSize(
                isEnabled: isEnabled,
                sliderTheme: sliderTheme
                ).width / 2f;

            context.canvas.drawCircle(center, tickMarkRadius, paint);
        }
 public static SliderThemeData lerp(SliderThemeData a, SliderThemeData b, float t)
 {
     D.assert(a != null);
     D.assert(b != null);
     return(new SliderThemeData(
                trackHeight: MathUtils.lerpFloat(a.trackHeight, b.trackHeight, t),
                activeTrackColor: Color.lerp(a.activeTrackColor, b.activeTrackColor, t),
                inactiveTrackColor: Color.lerp(a.inactiveTrackColor, b.inactiveTrackColor, t),
                disabledActiveTrackColor: Color.lerp(a.disabledActiveTrackColor, b.disabledActiveTrackColor, t),
                disabledInactiveTrackColor: Color.lerp(a.disabledInactiveTrackColor, b.disabledInactiveTrackColor, t),
                activeTickMarkColor: Color.lerp(a.activeTickMarkColor, b.activeTickMarkColor, t),
                inactiveTickMarkColor: Color.lerp(a.inactiveTickMarkColor, b.inactiveTickMarkColor, t),
                disabledActiveTickMarkColor: Color.lerp(a.disabledActiveTickMarkColor, b.disabledActiveTickMarkColor,
                                                        t),
                disabledInactiveTickMarkColor: Color.lerp(a.disabledInactiveTickMarkColor,
                                                          b.disabledInactiveTickMarkColor, t),
                thumbColor: Color.lerp(a.thumbColor, b.thumbColor, t),
                disabledThumbColor: Color.lerp(a.disabledThumbColor, b.disabledThumbColor, t),
                overlayColor: Color.lerp(a.overlayColor, b.overlayColor, t),
                valueIndicatorColor: Color.lerp(a.valueIndicatorColor, b.valueIndicatorColor, t),
                trackShape: t < 0.5 ? a.trackShape : b.trackShape,
                tickMarkShape: t < 0.5 ? a.tickMarkShape : b.tickMarkShape,
                thumbShape: t < 0.5 ? a.thumbShape : b.thumbShape,
                overlayShape: t < 0.5 ? a.overlayShape : b.overlayShape,
                valueIndicatorShape: t < 0.5 ? a.valueIndicatorShape : b.valueIndicatorShape,
                showValueIndicator: t < 0.5 ? a.showValueIndicator : b.showValueIndicator,
                valueIndicatorTextStyle: TextStyle.lerp(a.valueIndicatorTextStyle, b.valueIndicatorTextStyle, t)
                ));
 }
        public bool Equals(SliderThemeData other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(other.trackHeight == this.trackHeight &&
                   other.activeTrackColor == this.activeTrackColor &&
                   other.inactiveTrackColor == this.inactiveTrackColor &&
                   other.disabledActiveTrackColor == this.disabledActiveTrackColor &&
                   other.disabledInactiveTrackColor == this.disabledInactiveTrackColor &&
                   other.activeTickMarkColor == this.activeTickMarkColor &&
                   other.inactiveTickMarkColor == this.inactiveTickMarkColor &&
                   other.disabledActiveTickMarkColor == this.disabledActiveTickMarkColor &&
                   other.disabledInactiveTickMarkColor == this.disabledInactiveTickMarkColor &&
                   other.thumbColor == this.thumbColor &&
                   other.disabledThumbColor == this.disabledThumbColor &&
                   other.overlayColor == this.overlayColor &&
                   other.valueIndicatorColor == this.valueIndicatorColor &&
                   other.trackShape == this.trackShape &&
                   other.tickMarkShape == this.tickMarkShape &&
                   other.thumbShape == this.thumbShape &&
                   other.overlayShape == this.overlayShape &&
                   other.valueIndicatorShape == this.valueIndicatorShape &&
                   other.showValueIndicator == this.showValueIndicator &&
                   other.valueIndicatorTextStyle == this.valueIndicatorTextStyle);
        }
        public override void paint(
            PaintingContext context,
            Offset center,
            Animation <float> activationAnimation = null,
            Animation <float> enableAnimation     = null,
            bool?isDiscrete             = null,
            TextPainter labelPainter    = null,
            RenderBox parentBox         = null,
            SliderThemeData sliderTheme = null,
            float?value = null
            )
        {
            Canvas     canvas      = context.canvas;
            FloatTween radiusTween = new FloatTween(
                begin: 0.0f,
                end: this.overlayRadius
                );

            canvas.drawCircle(
                center,
                radiusTween.evaluate(activationAnimation),
                new Paint {
                color = sliderTheme.overlayColor
            }
                );
        }
        public override void paint(
            PaintingContext context,
            Offset center,
            Animation <float> activationAnimation = null,
            Animation <float> enableAnimation     = null,
            bool?isDiscrete             = null,
            TextPainter labelPainter    = null,
            RenderBox parentBox         = null,
            SliderThemeData sliderTheme = null,
            float?value = null)
        {
            ColorTween enableColor = new ColorTween(
                begin: sliderTheme.disabledThumbColor,
                end: sliderTheme.valueIndicatorColor
                );

            this._drawValueIndicator(
                parentBox,
                context.canvas,
                center,
                new Paint {
                color = enableColor.evaluate(enableAnimation)
            },
                activationAnimation.value,
                labelPainter
                );
        }
示例#6
0
        public override Widget build(BuildContext context)
        {
            D.assert(MaterialD.debugCheckHasMaterial(context));
            D.assert(WidgetsD.debugCheckHasMediaQuery(context));

            SliderThemeData sliderTheme = SliderTheme.of(context);

            if (this.widget.activeColor != null || this.widget.inactiveColor != null)
            {
                sliderTheme = sliderTheme.copyWith(
                    activeTrackColor: this.widget.activeColor,
                    inactiveTrackColor: this.widget.inactiveColor,
                    activeTickMarkColor: this.widget.inactiveColor,
                    inactiveTickMarkColor: this.widget.activeColor,
                    thumbColor: this.widget.activeColor,
                    valueIndicatorColor: this.widget.activeColor,
                    overlayColor: this.widget.activeColor?.withAlpha(0x29)
                    );
            }

            return(new _SliderRenderObjectWidget(
                       value: this._unlerp(this.widget.value),
                       divisions: this.widget.divisions,
                       label: this.widget.label,
                       sliderTheme: sliderTheme,
                       mediaQueryData: MediaQuery.of(context),
                       onChanged: (this.widget.onChanged != null) && (this.widget.max > this.widget.min)
                    ? this._handleChanged
                    : (ValueChanged <float>)null,
                       onChangeStart: this.widget.onChangeStart != null ? this._handleDragStart : (ValueChanged <float>)null,
                       onChangeEnd: this.widget.onChangeEnd != null ? this._handleDragEnd : (ValueChanged <float>)null,
                       state: this
                       ));
        }
 public override Size getPreferredSize(
     SliderThemeData sliderTheme = null,
     bool?isEnabled = null
     )
 {
     return(Size.fromRadius(this.tickMarkRadius ?? sliderTheme.trackHeight / 2f));
 }
示例#8
0
        public _RenderSlider(
            float?value   = null,
            int?divisions = null,
            string label  = null,
            SliderThemeData sliderTheme        = null,
            MediaQueryData mediaQueryData      = null,
            RuntimePlatform?platform           = null,
            ValueChanged <float> onChanged     = null,
            ValueChanged <float> onChangeStart = null,
            ValueChanged <float> onChangeEnd   = null,
            _SliderState state          = null,
            TextDirection?textDirection = null
            )
        {
            D.assert(value != null && value >= 0.0 && value <= 1.0);
            D.assert(state != null);
            D.assert(textDirection != null);

            this.onChangeStart = onChangeStart;
            this.onChangeEnd   = onChangeEnd;
            _platform          = platform;
            _label             = label;
            _value             = value.Value;
            _divisions         = divisions;
            _sliderTheme       = sliderTheme;
            _mediaQueryData    = mediaQueryData;
            _onChanged         = onChanged;
            _state             = state;
            _textDirection     = textDirection.Value;

            _updateLabelPainter();
            GestureArenaTeam team = new GestureArenaTeam();

            _drag = new HorizontalDragGestureRecognizer {
                team     = team,
                onStart  = _handleDragStart,
                onUpdate = _handleDragUpdate,
                onEnd    = _handleDragEnd,
                onCancel = _endInteraction
            };

            _tap = new TapGestureRecognizer {
                team        = team,
                onTapDown   = _handleTapDown,
                onTapUp     = _handleTapUp,
                onTapCancel = _endInteraction
            };

            _overlayAnimation = new CurvedAnimation(
                parent: _state.overlayController,
                curve: Curves.fastOutSlowIn);

            _valueIndicatorAnimation = new CurvedAnimation(
                parent: _state.valueIndicatorController,
                curve: Curves.fastOutSlowIn);

            _enableAnimation = new CurvedAnimation(
                parent: _state.enableController,
                curve: Curves.easeInOut);
        }
        public override Widget build(BuildContext context)
        {
            D.assert(material_.debugCheckHasMaterial(context));
            D.assert(WidgetsD.debugCheckHasMediaQuery(context));

            ThemeData       theme       = Theme.of(context);
            SliderThemeData sliderTheme = SliderTheme.of(context);

            sliderTheme = sliderTheme.copyWith(
                trackHeight: sliderTheme.trackHeight ?? _defaultTrackHeight,
                activeTrackColor: widget.activeColor ?? sliderTheme.activeTrackColor ?? theme.colorScheme.primary,
                inactiveTrackColor: widget.inactiveColor ??
                sliderTheme.inactiveTrackColor ?? theme.colorScheme.primary.withOpacity(0.24f),
                disabledActiveTrackColor: sliderTheme.disabledActiveTrackColor ??
                theme.colorScheme.onSurface.withOpacity(0.32f),
                disabledInactiveTrackColor: sliderTheme.disabledInactiveTrackColor ??
                theme.colorScheme.onSurface.withOpacity(0.12f),
                activeTickMarkColor: widget.inactiveColor ??
                sliderTheme.activeTickMarkColor ?? theme.colorScheme.onPrimary.withOpacity(0.54f),
                inactiveTickMarkColor: widget.activeColor ??
                sliderTheme.inactiveTickMarkColor ??
                theme.colorScheme.primary.withOpacity(0.54f),
                disabledActiveTickMarkColor: sliderTheme.disabledActiveTickMarkColor ??
                theme.colorScheme.onPrimary.withOpacity(0.12f),
                disabledInactiveTickMarkColor: sliderTheme.disabledInactiveTickMarkColor ??
                theme.colorScheme.onSurface.withOpacity(0.12f),
                thumbColor: widget.activeColor ?? sliderTheme.thumbColor ?? theme.colorScheme.primary,
                overlappingShapeStrokeColor: sliderTheme.overlappingShapeStrokeColor ?? theme.colorScheme.surface,
                disabledThumbColor: sliderTheme.disabledThumbColor ?? theme.colorScheme.onSurface.withOpacity(0.38f),
                overlayColor: widget.activeColor?.withOpacity(0.12f) ??
                sliderTheme.overlayColor ?? theme.colorScheme.primary.withOpacity(0.12f),
                valueIndicatorColor: widget.activeColor ?? sliderTheme.valueIndicatorColor ?? theme.colorScheme.primary,
                rangeTrackShape: sliderTheme.rangeTrackShape ?? _defaultTrackShape,
                rangeTickMarkShape: sliderTheme.rangeTickMarkShape ?? _defaultTickMarkShape,
                rangeThumbShape: sliderTheme.rangeThumbShape ?? _defaultThumbShape,
                overlayShape: sliderTheme.overlayShape ?? _defaultOverlayShape,
                rangeValueIndicatorShape: sliderTheme.rangeValueIndicatorShape ?? _defaultValueIndicatorShape,
                showValueIndicator: sliderTheme.showValueIndicator ?? _defaultShowValueIndicator,
                valueIndicatorTextStyle: sliderTheme.valueIndicatorTextStyle ?? theme.textTheme.bodyText1.copyWith(
                    color: theme.colorScheme.onPrimary
                    ),
                minThumbSeparation: sliderTheme.minThumbSeparation ?? _defaultMinThumbSeparation,
                thumbSelector: sliderTheme.thumbSelector ?? _defaultRangeThumbSelector
                );

            return(new _RangeSliderRenderObjectWidget(
                       values: _unlerpRangeValues(widget.values),
                       divisions: widget.divisions,
                       labels: widget.labels,
                       sliderTheme: sliderTheme,
                       textScaleFactor: MediaQuery.of(context).textScaleFactor,
                       onChanged: (widget.onChanged != null) && (widget.max > widget.min)
                    ? _handleChanged
                    : (ValueChanged <RangeValues>)null,
                       onChangeStart: widget.onChangeStart != null ? _handleDragStart : (ValueChanged <RangeValues>)null,
                       onChangeEnd: widget.onChangeEnd != null ? _handleDragEnd : (ValueChanged <RangeValues>)null,
                       state: this
                       ));
        }
 public abstract void paint(
     PaintingContext context,
     Offset offset,
     RenderBox parentBox               = null,
     SliderThemeData sliderTheme       = null,
     Animation <float> enableAnimation = null,
     Offset thumbCenter = null,
     bool?isEnabled     = null);
 public SliderTheme(
     Key key = null,
     SliderThemeData data = null,
     Widget child         = null)
     : base(key: key, child: child)
 {
     D.assert(child != null);
     D.assert(data != null);
     this.data = data;
 }
 public abstract void paint(
     PaintingContext context,
     Offset center,
     Animation <float> activationAnimation = null,
     Animation <float> enableAnimation     = null,
     bool?isDiscrete             = null,
     TextPainter labelPainter    = null,
     RenderBox parentBox         = null,
     SliderThemeData sliderTheme = null,
     float?value = null);
        public override void paint(
            PaintingContext context,
            Offset offset,
            RenderBox parentBox               = null,
            SliderThemeData sliderTheme       = null,
            Animation <float> enableAnimation = null,
            Offset thumbCenter = null,
            bool?isEnabled     = null,
            bool?isDiscrete    = null)
        {
            if (sliderTheme.trackHeight == 0)
            {
                return;
            }

            ColorTween activeTrackColorTween = new ColorTween(begin: sliderTheme.disabledActiveTrackColor,
                                                              end: sliderTheme.activeTrackColor);
            ColorTween inactiveTrackColorTween = new ColorTween(begin: sliderTheme.disabledInactiveTrackColor,
                                                                end: sliderTheme.inactiveTrackColor);
            Paint activePaint = new Paint {
                color = activeTrackColorTween.evaluate(enableAnimation)
            };
            Paint inactivePaint = new Paint {
                color = inactiveTrackColorTween.evaluate(enableAnimation)
            };
            Paint leftTrackPaint  = activePaint;
            Paint rightTrackPaint = inactivePaint;

            float horizontalAdjustment = 0.0f;

            if (!isEnabled.Value)
            {
                float disabledThumbRadius = sliderTheme.thumbShape.getPreferredSize(false, isDiscrete).width / 2.0f;
                float gap = this.disabledThumbGapWidth * (1.0f - enableAnimation.value);
                horizontalAdjustment = disabledThumbRadius + gap;
            }

            Rect trackRect = this.getPreferredRect(
                parentBox: parentBox,
                offset: offset,
                sliderTheme: sliderTheme,
                isEnabled: isEnabled,
                isDiscrete: isDiscrete
                );

            Rect leftTrackSegment = Rect.fromLTRB(trackRect.left, trackRect.top, thumbCenter.dx - horizontalAdjustment,
                                                  trackRect.bottom);

            context.canvas.drawRect(leftTrackSegment, leftTrackPaint);

            Rect rightTrackSegment = Rect.fromLTRB(thumbCenter.dx + horizontalAdjustment, trackRect.top,
                                                   trackRect.right, trackRect.bottom);

            context.canvas.drawRect(rightTrackSegment, rightTrackPaint);
        }
        public override void debugFillProperties(DiagnosticPropertiesBuilder properties)
        {
            base.debugFillProperties(properties);
            ThemeData       defaultTheme = ThemeData.fallback();
            SliderThemeData defaultData  = fromPrimaryColors(
                primaryColor: defaultTheme.primaryColor,
                primaryColorDark: defaultTheme.primaryColorDark,
                primaryColorLight: defaultTheme.primaryColorLight,
                valueIndicatorTextStyle: defaultTheme.accentTextTheme.body2
                );

            properties.add(new DiagnosticsProperty <Color>("activeTrackColor", this.activeTrackColor,
                                                           defaultValue: defaultData.activeTrackColor));
            properties.add(new DiagnosticsProperty <Color>("activeTrackColor", this.activeTrackColor,
                                                           defaultValue: defaultData.activeTrackColor));
            properties.add(new DiagnosticsProperty <Color>("inactiveTrackColor", this.inactiveTrackColor,
                                                           defaultValue: defaultData.inactiveTrackColor));
            properties.add(new DiagnosticsProperty <Color>("disabledActiveTrackColor", this.disabledActiveTrackColor,
                                                           defaultValue: defaultData.disabledActiveTrackColor, level: DiagnosticLevel.debug));
            properties.add(new DiagnosticsProperty <Color>("disabledInactiveTrackColor", this.disabledInactiveTrackColor,
                                                           defaultValue: defaultData.disabledInactiveTrackColor, level: DiagnosticLevel.debug));
            properties.add(new DiagnosticsProperty <Color>("activeTickMarkColor", this.activeTickMarkColor,
                                                           defaultValue: defaultData.activeTickMarkColor, level: DiagnosticLevel.debug));
            properties.add(new DiagnosticsProperty <Color>("inactiveTickMarkColor", this.inactiveTickMarkColor,
                                                           defaultValue: defaultData.inactiveTickMarkColor, level: DiagnosticLevel.debug));
            properties.add(new DiagnosticsProperty <Color>("disabledActiveTickMarkColor",
                                                           this.disabledActiveTickMarkColor, defaultValue: defaultData.disabledActiveTickMarkColor,
                                                           level: DiagnosticLevel.debug));
            properties.add(new DiagnosticsProperty <Color>("disabledInactiveTickMarkColor",
                                                           this.disabledInactiveTickMarkColor, defaultValue: defaultData.disabledInactiveTickMarkColor,
                                                           level: DiagnosticLevel.debug));
            properties.add(new DiagnosticsProperty <Color>("thumbColor", this.thumbColor,
                                                           defaultValue: defaultData.thumbColor));
            properties.add(new DiagnosticsProperty <Color>("disabledThumbColor", this.disabledThumbColor,
                                                           defaultValue: defaultData.disabledThumbColor, level: DiagnosticLevel.debug));
            properties.add(new DiagnosticsProperty <Color>("overlayColor", this.overlayColor,
                                                           defaultValue: defaultData.overlayColor, level: DiagnosticLevel.debug));
            properties.add(new DiagnosticsProperty <Color>("valueIndicatorColor", this.valueIndicatorColor,
                                                           defaultValue: defaultData.valueIndicatorColor));
            properties.add(new DiagnosticsProperty <SliderTrackShape>("trackShape", this.trackShape,
                                                                      defaultValue: defaultData.trackShape, level: DiagnosticLevel.debug));
            properties.add(new DiagnosticsProperty <SliderTickMarkShape>("tickMarkShape", this.tickMarkShape,
                                                                         defaultValue: defaultData.tickMarkShape, level: DiagnosticLevel.debug));
            properties.add(new DiagnosticsProperty <SliderComponentShape>("thumbShape", this.thumbShape,
                                                                          defaultValue: defaultData.thumbShape, level: DiagnosticLevel.debug));
            properties.add(new DiagnosticsProperty <SliderComponentShape>("overlayShape", this.overlayShape,
                                                                          defaultValue: defaultData.overlayShape, level: DiagnosticLevel.debug));
            properties.add(new DiagnosticsProperty <SliderComponentShape>("valueIndicatorShape",
                                                                          this.valueIndicatorShape, defaultValue: defaultData.valueIndicatorShape, level: DiagnosticLevel.debug));
            properties.add(new EnumProperty <ShowValueIndicator>("showValueIndicator", this.showValueIndicator,
                                                                 defaultValue: defaultData.showValueIndicator));
            properties.add(new DiagnosticsProperty <TextStyle>("valueIndicatorTextStyle", this.valueIndicatorTextStyle,
                                                               defaultValue: defaultData.valueIndicatorTextStyle));
        }
示例#15
0
        Widget _buildMaterialSlider(BuildContext context)
        {
            ThemeData       theme       = Theme.of(context);
            SliderThemeData sliderTheme = SliderTheme.of(context);

            sliderTheme = sliderTheme.copyWith(
                trackHeight: sliderTheme.trackHeight ?? _defaultTrackHeight,
                activeTrackColor: widget.activeColor ?? sliderTheme.activeTrackColor ?? theme.colorScheme.primary,
                inactiveTrackColor: widget.inactiveColor ?? sliderTheme.inactiveTrackColor ?? theme.colorScheme.primary.withOpacity(0.24f),
                disabledActiveTrackColor: sliderTheme.disabledActiveTrackColor ?? theme.colorScheme.onSurface.withOpacity(0.32f),
                disabledInactiveTrackColor: sliderTheme.disabledInactiveTrackColor ?? theme.colorScheme.onSurface.withOpacity(0.12f),
                activeTickMarkColor: widget.inactiveColor ?? sliderTheme.activeTickMarkColor ?? theme.colorScheme.onPrimary.withOpacity(0.54f),
                inactiveTickMarkColor: widget.activeColor ?? sliderTheme.inactiveTickMarkColor ?? theme.colorScheme.primary.withOpacity(0.54f),
                disabledActiveTickMarkColor: sliderTheme.disabledActiveTickMarkColor ?? theme.colorScheme.onPrimary.withOpacity(0.12f),
                disabledInactiveTickMarkColor: sliderTheme.disabledInactiveTickMarkColor ?? theme.colorScheme.onSurface.withOpacity(0.12f),
                thumbColor: widget.activeColor ?? sliderTheme.thumbColor ?? theme.colorScheme.primary,
                disabledThumbColor: sliderTheme.disabledThumbColor ?? theme.colorScheme.onSurface.withOpacity(0.38f),
                overlayColor: widget.activeColor?.withOpacity(0.12f) ?? sliderTheme.overlayColor ?? theme.colorScheme.primary.withOpacity(0.12f),
                valueIndicatorColor: widget.activeColor ?? sliderTheme.valueIndicatorColor ?? theme.colorScheme.primary,
                trackShape: sliderTheme.trackShape ?? _defaultTrackShape,
                tickMarkShape: sliderTheme.tickMarkShape ?? _defaultTickMarkShape,
                thumbShape: sliderTheme.thumbShape ?? _defaultThumbShape,
                overlayShape: sliderTheme.overlayShape ?? _defaultOverlayShape,
                valueIndicatorShape: sliderTheme.valueIndicatorShape ?? _defaultValueIndicatorShape,
                showValueIndicator: sliderTheme.showValueIndicator ?? _defaultShowValueIndicator,
                valueIndicatorTextStyle: sliderTheme.valueIndicatorTextStyle ?? theme.textTheme.bodyText1.copyWith(
                    color: theme.colorScheme.onPrimary
                    )
                );

            return(new _SliderRenderObjectWidget(
                       value: _unlerp(widget.value),
                       divisions: widget.divisions,
                       label: widget.label,
                       sliderTheme: sliderTheme,
                       mediaQueryData: MediaQuery.of(context),
                       onChanged: (widget.onChanged != null) && (widget.max > widget.min) ? _handleChanged : (ValueChanged <float>)null,
                       onChangeStart: widget.onChangeStart != null ? _handleDragStart : (ValueChanged <float>)null,
                       onChangeEnd: widget.onChangeEnd != null ? _handleDragEnd : (ValueChanged <float>)null,
                       state: this
                       ));
        }
        public override Rect getPreferredRect(
            RenderBox parentBox         = null,
            Offset offset               = null,
            SliderThemeData sliderTheme = null,
            bool?isEnabled              = null,
            bool?isDiscrete             = null)
        {
            float overlayWidth = sliderTheme.overlayShape.getPreferredSize(isEnabled, isDiscrete).width;
            float trackHeight  = sliderTheme.trackHeight;

            D.assert(overlayWidth >= 0);
            D.assert(trackHeight >= 0);
            D.assert(parentBox.size.width >= overlayWidth);
            D.assert(parentBox.size.height >= trackHeight);

            float trackLeft  = offset.dx + overlayWidth / 2f;
            float trackTop   = offset.dy + (parentBox.size.height - trackHeight) / 2f;
            float trackWidth = parentBox.size.width - overlayWidth;

            return(Rect.fromLTWH(trackLeft, trackTop, trackWidth, trackHeight));
        }
 public _RangeSliderRenderObjectWidget(
     Key key                                  = null,
     RangeValues values                       = null,
     int?divisions                            = null,
     RangeLabels labels                       = null,
     SliderThemeData sliderTheme              = null,
     float textScaleFactor                    = 0f,
     ValueChanged <RangeValues> onChanged     = null,
     ValueChanged <RangeValues> onChangeStart = null,
     ValueChanged <RangeValues> onChangeEnd   = null,
     _RangeSliderState state                  = null) : base(key: key)
 {
     this.values          = values;
     this.divisions       = divisions;
     this.labels          = labels;
     this.sliderTheme     = sliderTheme;
     this.textScaleFactor = textScaleFactor;
     this.onChanged       = onChanged;
     this.onChangeStart   = onChangeStart;
     this.onChangeEnd     = onChangeEnd;
     this.state           = state;
 }
示例#18
0
 public _SliderRenderObjectWidget(
     Key key       = null,
     float?value   = null,
     int?divisions = null,
     string label  = null,
     SliderThemeData sliderTheme        = null,
     MediaQueryData mediaQueryData      = null,
     ValueChanged <float> onChanged     = null,
     ValueChanged <float> onChangeStart = null,
     ValueChanged <float> onChangeEnd   = null,
     _SliderState state = null
     ) : base(key: key)
 {
     this.value          = value.Value;
     this.divisions      = divisions;
     this.label          = label;
     this.sliderTheme    = sliderTheme;
     this.mediaQueryData = mediaQueryData;
     this.onChanged      = onChanged;
     this.onChangeStart  = onChangeStart;
     this.onChangeEnd    = onChangeEnd;
     this.state          = state;
 }
 public override Size getPreferredSize(
     SliderThemeData sliderTheme = null,
     bool?isEnabled = null)
 {
     return(Size.zero);
 }
        public _RenderRangeSlider(
            RangeValues values,
            int?divisions,
            RangeLabels labels,
            SliderThemeData sliderTheme,
            ThemeData theme,
            float textScaleFactor,
            RuntimePlatform platform,
            ValueChanged <RangeValues> onChanged,
            ValueChanged <RangeValues> onChangeStart,
            ValueChanged <RangeValues> onChangeEnd,
            _RangeSliderState state,
            TextDirection?textDirection)
        {
            D.assert(values != null);
            D.assert(values.start >= 0.0 && values.start <= 1.0);
            D.assert(values.end >= 0.0 && values.end <= 1.0);
            D.assert(state != null);
            D.assert(textDirection != null);

            this.onChangeStart = onChangeStart;
            this.onChangeEnd   = onChangeEnd;

            _platform        = platform;
            _labels          = labels;
            _values          = values;
            _divisions       = divisions;
            _sliderTheme     = sliderTheme;
            _theme           = theme;
            _textScaleFactor = textScaleFactor;
            _onChanged       = onChanged;
            _state           = state;
            _textDirection   = textDirection;

            _updateLabelPainters();

            GestureArenaTeam team = new GestureArenaTeam();

            _drag          = new HorizontalDragGestureRecognizer();
            _drag.team     = team;
            _drag.onStart  = _handleDragStart;
            _drag.onUpdate = _handleDragUpdate;
            _drag.onEnd    = _handleDragEnd;
            _drag.onCancel = _handleDragCancel;

            _tap             = new TapGestureRecognizer();
            _tap.team        = team;
            _tap.onTapDown   = _handleTapDown;
            _tap.onTapUp     = _handleTapUp;
            _tap.onTapCancel = _handleTapCancel;

            _overlayAnimation = new CurvedAnimation(
                parent: _state.overlayController,
                curve: Curves.fastOutSlowIn
                );
            _valueIndicatorAnimation = new CurvedAnimation(
                parent: _state.valueIndicatorController,
                curve: Curves.fastOutSlowIn
                );
            _enableAnimation = new CurvedAnimation(
                parent: _state.enableController,
                curve: Curves.easeInOut
                );
        }
 public abstract Rect getPreferredRect(
     RenderBox parentBox         = null,
     Offset offset               = null,
     SliderThemeData sliderTheme = null,
     bool?isEnabled              = null,
     bool?isDiscrete             = null);
 public abstract Size getPreferredSize(
     SliderThemeData sliderTheme = null,
     bool?isEnabled = null);