From 4d1fc2a63cbb38144f4b010dd84b40aead237472 Mon Sep 17 00:00:00 2001 From: Maxim Date: Thu, 2 May 2024 20:58:01 +0400 Subject: [PATCH] Offset marker control position to its line when dragging --- .../ui/narration/markers/VerseMarkersLayer.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/narration/markers/VerseMarkersLayer.kt b/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/narration/markers/VerseMarkersLayer.kt index f463270235..54b15afec6 100644 --- a/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/narration/markers/VerseMarkersLayer.kt +++ b/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/narration/markers/VerseMarkersLayer.kt @@ -88,20 +88,20 @@ class VerseMarkersLayer : BorderPane() { ) ) - var delta = 0.0 var oldPos = 0.0 + val markerLineOffset = MARKER_AREA_WIDTH / 2 + minHeightProperty().bind(this@VerseMarkersLayer.heightProperty()) prefHeightProperty().bind(this@VerseMarkersLayer.heightProperty()) dragTarget.setOnMousePressed { event -> - event.consume() userIsDraggingProperty.set(true) if (!canBeMovedProperty.value) return@setOnMousePressed delta = 0.0 - oldPos = layoutX + oldPos = layoutX + markerLineOffset FX.eventbus.fire( NarrationMovingMarkerEvent(verseMarkerControl.verseIndexProperty.value) @@ -120,7 +120,7 @@ class VerseMarkersLayer : BorderPane() { delta = currentPos - oldPos - layoutX = currentPos + layoutX = currentPos - markerLineOffset } catch (e: Exception) { // This can prevent attempting to move a marker that was originally created too close together // if the user spammed next verse while recording. Moving surrounding markers around will allow @@ -131,7 +131,8 @@ class VerseMarkersLayer : BorderPane() { dragTarget.setOnMouseReleased { event -> if (delta != 0.0) { - val frameDelta = pixelsToFrames(delta, width = this@VerseMarkersLayer.width.toInt()) + val frameDelta = pixelsToFrames(delta) + FX.eventbus.fire( NarrationMarkerChangedEvent( verseMarkerControl.verseIndexProperty.value,