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 <noreply@anthropic.com>
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user