Added adjustable eraser thickness and improved tool selection logic for highlighter (#95)

This commit is contained in:
Aryan 2026-03-19 15:48:03 +05:30 committed by GitHub
parent 982efb063d
commit eaf0d4af00
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 201 additions and 131 deletions

View file

@ -231,6 +231,7 @@ internal fun PdfVerticalReader(
onHighlightUpdate: (String, PdfHighlightColor) -> Unit = { _,_ -> },
onHighlightDelete: (String) -> Unit = {},
onTts: (Int, Int) -> Unit = { _, _ -> },
activeToolThickness: Float = 0f
) {
SideEffect { Timber.tag("PdfDrawPerf").v("LIST: PdfVerticalReader Recomposing.") }
var globalEraserPosition by remember { mutableStateOf<Offset?>(null) }
@ -1512,6 +1513,7 @@ internal fun PdfVerticalReader(
onHighlightUpdate = onHighlightUpdate,
onHighlightDelete = onHighlightDelete,
onTts = onTts,
activeToolThickness = activeToolThickness,
onTextBoxDragStart = { box, localTopLeft, touchOffset ->
val currentZoom = zoomAnimatable.value
val panX = panXAnimatable.value
@ -1911,7 +1913,11 @@ internal fun PdfVerticalReader(
if (isEditMode && selectedTool == InkType.ERASER && globalEraserPosition != null) {
Canvas(modifier = Modifier.fillMaxSize()) {
val pos = globalEraserPosition!!
val radiusPx = 8.dp.toPx()
val radiusPx = if (activeToolThickness > 0f) {
activeToolThickness * screenWidth * zoomAnimatable.value
} else {
8.dp.toPx()
}
drawCircle(color = Color.White.copy(alpha = 0.3f), radius = radiusPx, center = pos)