Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f7e4aed8 authored by Denis's avatar Denis Committed by Denis Kuznetsov
Browse files

[flexiglass] [bouncer] Fix painting in-progress line on large screens

Correctly adjusts a line end of line being drawn in cases when
screen is large enough for pattern input to be larger than
dot drawing area.

Fix: 414781848
Test: manually verified that pattern is working as expected on a
large screen.
Flag: com.android.systemui.scene_container

Change-Id: Icd50f1268a60fc8231069baa07701e9ea1e2beaf
parent f2c59214
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.layout.LayoutCoordinates
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.layout.positionInParent
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.res.integerResource
@@ -211,9 +212,11 @@ fun PatternBouncer(
        }
    }

    // This is the position of the input pointer.
    // This is the position of the input pointer. Calculated in context of bouncer Box.
    var inputPosition: Offset? by remember { mutableStateOf(null) }
    // Calculated in context of Canvas inside the Box.
    var gridCoordinates: LayoutCoordinates? by remember { mutableStateOf(null) }
    // Calculated in context of Canvas inside the Box.
    var offset: Offset by remember { mutableStateOf(Offset.Zero) }
    var scale: Float by remember { mutableStateOf(1f) }
    // This is the size of the drawing area, in dips.
@@ -346,8 +349,10 @@ fun PatternBouncer(
                    }

                    // Draw the line between the most recently-selected dot and the input pointer
                    // position.
                    inputPosition?.let { lineEnd ->
                    // position. Note that `inputPosition` is calculated relative to enclosing
                    // `Box`.
                    inputPosition?.let { lineEndInParent ->
                        val lineEnd = lineEndInParent.minus(nonNullCoordinates.positionInParent())
                        currentDot?.let { dot ->
                            val from = pixelOffset(dot, spacing, horizontalOffset, verticalOffset)
                            val lineLength =