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

@ -438,6 +438,7 @@ internal fun PdfPageComposable(
onHighlightUpdate: (String, PdfHighlightColor) -> Unit = { _,_ -> },
onHighlightDelete: (String) -> Unit = {},
onTts: (Int, Int) -> Unit = { _, _ -> },
activeToolThickness: Float = 0f
) {
val pdfDocumentItem = pdfDocument.item
var bitmapState by remember { mutableStateOf(PdfThumbnailCache.get(pageIndex)) }
@ -3775,6 +3776,7 @@ internal fun PdfPageComposable(
isEditMode = isEditMode,
selectedTool = selectedTool,
eraserPosition = eraserPosition,
activeToolThickness = activeToolThickness,
richTextController = richTextController,
textBoxes = textBoxes,
selectedTextBoxId = selectedTextBoxId,
@ -4516,6 +4518,8 @@ private fun PdfPageRenderer(
onHighlightUpdate: (String, PdfHighlightColor) -> Unit,
onHighlightDelete: (String) -> Unit,
onTts: (Int, Int) -> Unit,
activeToolThickness: Float
) {
Box(modifier = Modifier.fillMaxSize()) {
Box(
@ -4704,7 +4708,11 @@ private fun PdfPageRenderer(
if (isEditMode && selectedTool == InkType.ERASER && eraserPosition != null) {
Canvas(modifier = Modifier.fillMaxSize()) {
val radiusPx = 8.dp.toPx()
val radiusPx = if (activeToolThickness > 0f && staticData.targetWidth > 0) {
activeToolThickness * staticData.targetWidth * scale // Calculate dynamic size based on tool settings scale
} else {
8.dp.toPx()
}
drawCircle(
color = Color.White.copy(alpha = 0.3f),