Unverified Commit 0423809c authored by Jose Alba's avatar Jose Alba Committed by GitHub

Value Indicator uses Global position (#57327)

* Value Indicator uses Global position when calculating horizontal position

* fixed test

* fixed analyzer

* Made globalCenter variable and added comments
parent 9e2775fe
...@@ -2793,13 +2793,16 @@ class _RectangularSliderValueIndicatorPathPainter { ...@@ -2793,13 +2793,16 @@ class _RectangularSliderValueIndicatorPathPainter {
assert(!sizeWithOverflow.isEmpty); assert(!sizeWithOverflow.isEmpty);
const double edgePadding = 8.0; const double edgePadding = 8.0;
final double rectangleWidth = _upperRectangleWidth(labelPainter, scale, textScaleFactor); final double rectangleWidth = _upperRectangleWidth(labelPainter, scale, textScaleFactor);
/// Value indicator draws on the Overlay and by using the global Offset
/// we are making sure we use the bounds of the Overlay instead of the Slider.
final Offset globalCenter = parentBox.localToGlobal(center);
// The rectangle must be shifted towards the center so that it minimizes the // The rectangle must be shifted towards the center so that it minimizes the
// chance of it rendering outside the bounds of the render box. If the shift // chance of it rendering outside the bounds of the render box. If the shift
// is negative, then the lobe is shifted from right to left, and if it is // is negative, then the lobe is shifted from right to left, and if it is
// positive, then the lobe is shifted from left to right. // positive, then the lobe is shifted from left to right.
final double overflowLeft = math.max(0, rectangleWidth / 2 - center.dx + edgePadding); final double overflowLeft = math.max(0, rectangleWidth / 2 - globalCenter.dx + edgePadding);
final double overflowRight = math.max(0, rectangleWidth / 2 - (sizeWithOverflow.width - center.dx - edgePadding)); final double overflowRight = math.max(0, rectangleWidth / 2 - (sizeWithOverflow.width - globalCenter.dx - edgePadding));
if (rectangleWidth < sizeWithOverflow.width) { if (rectangleWidth < sizeWithOverflow.width) {
return overflowLeft - overflowRight; return overflowLeft - overflowRight;
......
...@@ -1042,9 +1042,9 @@ void main() { ...@@ -1042,9 +1042,9 @@ void main() {
..path( ..path(
includes: const <Offset>[ includes: const <Offset>[
Offset(0.0, 0.0), Offset(0.0, 0.0),
Offset(0.0, -38.0), Offset(0.0, -8.0),
Offset(-30.0, -16.0), Offset(-276.0, -16.0),
Offset(30.0, -16.0), Offset(-216.0, -16.0),
], ],
color: const Color(0xf55f5f5f), color: const Color(0xf55f5f5f),
), ),
...@@ -1064,9 +1064,9 @@ void main() { ...@@ -1064,9 +1064,9 @@ void main() {
..path( ..path(
includes: const <Offset>[ includes: const <Offset>[
Offset(0.0, 0.0), Offset(0.0, 0.0),
Offset(0.0, -52.0), Offset(0.0, -8.0),
Offset(-44.0, -16.0), Offset(-304.0, -16.0),
Offset(44.0, -16.0), Offset(-216.0, -16.0),
], ],
color: const Color(0xf55f5f5f), color: const Color(0xf55f5f5f),
), ),
...@@ -1090,9 +1090,9 @@ void main() { ...@@ -1090,9 +1090,9 @@ void main() {
..path( ..path(
includes: const <Offset>[ includes: const <Offset>[
Offset(0.0, 0.0), Offset(0.0, 0.0),
Offset(0.0, -38.0), Offset(0.0, -8.0),
Offset(-30.0, -16.0), Offset(-276.0, -16.0),
Offset(30.0, -16.0), Offset(-216.0, -16.0),
], ],
color: const Color(0xf55f5f5f), color: const Color(0xf55f5f5f),
), ),
...@@ -1116,9 +1116,9 @@ void main() { ...@@ -1116,9 +1116,9 @@ void main() {
..path( ..path(
includes: const <Offset>[ includes: const <Offset>[
Offset(0.0, 0.0), Offset(0.0, 0.0),
Offset(0.0, -52.0), Offset(0.0, -8.0),
Offset(-44.0, -16.0), Offset(-276.0, -16.0),
Offset(44.0, -16.0), Offset(-216.0, -16.0),
], ],
color: const Color(0xf55f5f5f), color: const Color(0xf55f5f5f),
), ),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment