From c3158873ef6565997ab58a232ae1a0b71201451b Mon Sep 17 00:00:00 2001 From: sam Date: Mon, 13 Jul 2026 00:20:17 +0200 Subject: [PATCH] Fix crop corner handles positioned from center instead of top-left The crop container uses contentAlignment=Center, so the draggable corner handles were offset from the middle of the box rather than the top-left, leaving them far from the actual document corners. Anchor them with align(TopStart) to match the Canvas coordinate space, and add a white border for visibility. Co-Authored-By: Claude Opus 4.8 --- .../main/java/eu/geyskens/pdfscan/ui/screens/CropScreen.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/eu/geyskens/pdfscan/ui/screens/CropScreen.kt b/app/src/main/java/eu/geyskens/pdfscan/ui/screens/CropScreen.kt index fae76b9..4394a19 100644 --- a/app/src/main/java/eu/geyskens/pdfscan/ui/screens/CropScreen.kt +++ b/app/src/main/java/eu/geyskens/pdfscan/ui/screens/CropScreen.kt @@ -4,6 +4,7 @@ import android.graphics.Bitmap import android.graphics.PointF import androidx.compose.foundation.Image import androidx.compose.foundation.background +import androidx.compose.foundation.border import androidx.compose.foundation.gestures.detectDragGestures import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box @@ -104,12 +105,17 @@ fun CropScreen(vm: ScanViewModel, navController: NavController, pageId: String) val handlePx = with(density) { 32.dp.toPx() } Box( modifier = Modifier + // Position from the container's top-left, matching the Canvas + // coordinate space (the container uses contentAlignment = Center, + // which would otherwise offset handles from the middle). + .align(Alignment.TopStart) .offset( x = with(density) { (screen.x - handlePx / 2).toDp() }, y = with(density) { (screen.y - handlePx / 2).toDp() }, ) .size(32.dp) .background(Color(0xAA388BFD), CircleShape) + .border(2.dp, Color.White, CircleShape) .pointerInput(pageId, i, dispW, dispH) { detectDragGestures { change, drag -> change.consume()