Feature/highlighter snap (#48)
* perf: fix Home and Library screen stutter by removing main thread file checks * feat(pdf): implement straight-line highlighter snap - Added "Straight Line" toggle to highlighter settings popup with persistent state. - Implemented "rubber-band" drawing effect for highlighters with cardinal direction snapping (0°, 90°, 180°, 270°). - Optimized gesture loops in Vertical and Paginated readers to respond instantly to setting toggles. - Rewrote eraser hit detection using point-to-line segment distance math for pixel-perfect erasure of straight lines.
This commit is contained in:
parent
6ea414c9b2
commit
8c7c8cb48e
8 changed files with 203 additions and 61 deletions
|
|
@ -417,7 +417,8 @@ internal fun PdfPageComposable(
|
|||
draggingBoxId: String? = null,
|
||||
isScrollLocked: Boolean = false,
|
||||
isVisible: Boolean = true,
|
||||
isStylusOnlyMode: Boolean = false
|
||||
isStylusOnlyMode: Boolean = false,
|
||||
isHighlighterSnapEnabled: Boolean = false
|
||||
) {
|
||||
SideEffect { Timber.tag("PdfDrawPerf").v("PdfPageComposable Recompose: Page $pageIndex") }
|
||||
val pdfDocumentItem = pdfDocument.item
|
||||
|
|
@ -2608,7 +2609,8 @@ internal fun PdfPageComposable(
|
|||
isScrolling,
|
||||
isVerticalScroll,
|
||||
selectedTool,
|
||||
isStylusOnlyMode
|
||||
isStylusOnlyMode,
|
||||
isHighlighterSnapEnabled
|
||||
) {
|
||||
val canDraw = isEditMode && selectedTool != InkType.TEXT && !isScrolling && !isVerticalScroll && actualBitmapWidthPx > 0 && actualBitmapHeightPx > 0
|
||||
|
||||
|
|
@ -4611,6 +4613,16 @@ class PdfDrawingState {
|
|||
currentPoints.clear()
|
||||
return finalAnnot
|
||||
}
|
||||
|
||||
fun updateDrag(point: PdfPoint) {
|
||||
if (currentPoints.isNotEmpty()) {
|
||||
val start = currentPoints.first()
|
||||
currentPoints.clear()
|
||||
currentPoints.add(start)
|
||||
currentPoints.add(point)
|
||||
currentAnnotation = currentAnnotation?.copy(points = currentPoints.toList())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue