Do not draw Slider tick marks if they are too dense (#27969)
This commit is contained in:
parent
d1707ab0ad
commit
d1371cd269
@ -1005,23 +1005,27 @@ class _RenderSlider extends RenderBox {
|
|||||||
isEnabled: isInteractive,
|
isEnabled: isInteractive,
|
||||||
sliderTheme: _sliderTheme,
|
sliderTheme: _sliderTheme,
|
||||||
).width;
|
).width;
|
||||||
for (int i = 0; i <= divisions; i++) {
|
// If the ticks would be too dense, don't bother painting them.
|
||||||
final double tickValue = i / divisions;
|
if ((trackRect.width - tickMarkWidth) / divisions >= 3.0 * tickMarkWidth) {
|
||||||
// The ticks are mapped to be within the track, so the tick mark width
|
for (int i = 0; i <= divisions; i++) {
|
||||||
// must be subtracted from the track width.
|
final double tickValue = i / divisions;
|
||||||
final double tickX = trackRect.left + tickValue * (trackRect.width - tickMarkWidth) + tickMarkWidth / 2;
|
// The ticks are mapped to be within the track, so the tick mark width
|
||||||
final double tickY = trackRect.center.dy;
|
// must be subtracted from the track width.
|
||||||
final Offset tickMarkOffset = Offset(tickX, tickY);
|
final double tickX = trackRect.left +
|
||||||
_sliderTheme.tickMarkShape.paint(
|
tickValue * (trackRect.width - tickMarkWidth) + tickMarkWidth / 2;
|
||||||
context,
|
final double tickY = trackRect.center.dy;
|
||||||
tickMarkOffset,
|
final Offset tickMarkOffset = Offset(tickX, tickY);
|
||||||
parentBox: this,
|
_sliderTheme.tickMarkShape.paint(
|
||||||
sliderTheme: _sliderTheme,
|
context,
|
||||||
enableAnimation: _enableAnimation,
|
tickMarkOffset,
|
||||||
textDirection: _textDirection,
|
parentBox: this,
|
||||||
thumbCenter: thumbCenter,
|
sliderTheme: _sliderTheme,
|
||||||
isEnabled: isInteractive,
|
enableAnimation: _enableAnimation,
|
||||||
);
|
textDirection: _textDirection,
|
||||||
|
thumbCenter: thumbCenter,
|
||||||
|
isEnabled: isInteractive,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user