Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offset marker control position to its line when dragging (OT-887) #1140

Merged
merged 1 commit into from
May 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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,
Expand Down
Loading