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
|
|
@ -222,7 +222,8 @@ internal fun PdfVerticalReader(
|
|||
isScrollLocked: Boolean = false,
|
||||
autoScrollSpeed: Float = 1.0f,
|
||||
onInteractionListener: () -> Unit = {},
|
||||
isStylusOnlyMode: Boolean = false
|
||||
isStylusOnlyMode: Boolean = false,
|
||||
isHighlighterSnapEnabled: Boolean = false
|
||||
) {
|
||||
SideEffect { Timber.tag("PdfDrawPerf").v("LIST: PdfVerticalReader Recomposing.") }
|
||||
var globalEraserPosition by remember { mutableStateOf<Offset?>(null) }
|
||||
|
|
@ -748,7 +749,13 @@ internal fun PdfVerticalReader(
|
|||
}
|
||||
}
|
||||
|
||||
val globalDrawingModifier = Modifier.pointerInput(isEditMode, layoutInfo, selectedTool, isStylusOnlyMode) {
|
||||
val globalDrawingModifier = Modifier.pointerInput(
|
||||
isEditMode,
|
||||
layoutInfo,
|
||||
selectedTool,
|
||||
isStylusOnlyMode,
|
||||
isHighlighterSnapEnabled
|
||||
) {
|
||||
if (!isEditMode) return@pointerInput
|
||||
if (selectedTool == InkType.TEXT) return@pointerInput
|
||||
|
||||
|
|
@ -864,7 +871,14 @@ internal fun PdfVerticalReader(
|
|||
onDoubleTapToZoom(offset)
|
||||
})
|
||||
}
|
||||
.pointerInput(totalDocHeight, isEditMode, selectedTool, isScrollLocked, isStylusOnlyMode) {
|
||||
.pointerInput(
|
||||
totalDocHeight,
|
||||
isEditMode,
|
||||
selectedTool,
|
||||
isScrollLocked,
|
||||
isStylusOnlyMode,
|
||||
isHighlighterSnapEnabled
|
||||
) {
|
||||
val tracker = VelocityTracker()
|
||||
val decay = exponentialDecay<Float>()
|
||||
val touchSlop = viewConfiguration.touchSlop
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue