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

Commit 5a369599 authored by Jerry Liu's avatar Jerry Liu Committed by Android (Google) Code Review
Browse files

Merge "Desktop screenshots: Set the minimum region box size to 48dp" into main

parents a7450c8d 157fb14b
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -251,6 +251,25 @@ private class RegionBoxState(private val minSizePx: Float, private val touchArea
    }

    fun dragEnd() {
        // Apply the minimum region box size after the drag.
        rect?.let { currentRect ->
            // Coerce the box dimensions to be within the min size and screen size.
            val finalWidth = currentRect.width.coerceIn(minSizePx, screenWidth)
            val finalHeight = currentRect.height.coerceIn(minSizePx, screenHeight)

            // Ensure the box's top-left corner is positioned so the box remains
            // entirely within the screen bounds.
            val finalLeft = currentRect.left.coerceAtMost(screenWidth - finalWidth)
            val finalTop = currentRect.top.coerceAtMost(screenHeight - finalHeight)

            rect =
                Rect(
                    left = finalLeft,
                    top = finalTop,
                    right = finalLeft + finalWidth,
                    bottom = finalTop + finalHeight,
                )
        }
        dragMode = DragMode.NONE
        resizeZone = null
    }
@@ -278,7 +297,7 @@ fun RegionBox(
    val density = LocalDensity.current

    // The minimum size allowed for the box.
    val minSize = 1.dp
    val minSize = 48.dp
    val minSizePx = remember(density) { with(density) { minSize.toPx() } }

    // The touch area for detecting an edge or corner resize drag.