Bug 503693 - Snap Time Cursor when dragging it.
Summary: Snap Time Cursor when dragging it.
Status: REPORTED
Alias: None
Product: kdenlive
Classification: Applications
Component: Timeline & Editing (other bugs)
Version First Reported In: unspecified
Platform: Other Other
: NOR wishlist
Target Milestone: ---
Assignee: Jean-Baptiste Mardelle
URL:
Keywords: junior-jobs
Depends on:
Blocks:
 
Reported: 2025-05-03 00:07 UTC by Gabriel Gazzán
Modified: 2026-02-13 17:48 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gabriel Gazzán 2025-05-03 00:07:47 UTC
While the Snap feature is enabled, it'd be useful if the Time Cursor also snapped to the same elements clips currently do when dragged.

This would be useful for quickly placing the time cursor to any significant position in the timeline (clips' edges, guides, markers, zone in/out). 
Much like what can be achieved by using Alt+left/right arrow keys, but using only the mouse, as an alternative workflow.

Thanks! :)
Comment 1 luzpaz 2026-01-31 13:38:48 UTC
Here's a Claude suggestion on how to implement this:

diff --git a/src/timeline2/view/qml/timelineplayhead.h b/src/timeline2/view/qml/timelineplayhead.h
index e0147f2..f3bde45 100644
--- a/src/timeline2/view/qml/timelineplayhead.h
+++ b/src/timeline2/view/qml/timelineplayhead.h
@@ -12,6 +12,8 @@
 
 public:
     TimelinePlayhead(QQuickItem *parent = nullptr);
+    
+    void snapToClosestPoint(int currentPosition);
     void paint(QPainter *painter) override;
 
 Q_SIGNALS:
diff --git a/src/timeline2/view/qml/timelineplayhead.cpp b/src/timeline2/view/qml/timelineplayhead.cpp
index 00d3d9d..328b5bc 100644
--- a/src/timeline2/view/qml/timelineplayhead.cpp
+++ b/src/timeline2/view/qml/timelineplayhead.cpp
@@ -9,6 +9,15 @@

 TimelinePlayhead::TimelinePlayhead(QQuickItem *parent)
     : QQuickPaintedItem(parent)
+{
+    // Initialize snapping system if required
 }
 
+void TimelinePlayhead::snapToClosestPoint(int currentPosition) {
+    int snappedPosition = SnapModel::getClosestPoint(currentPosition);
+    // Move the playhead to the snapped position
+    setCursorPosition(snappedPosition);
+}
+
 void TimelinePlayhead::paint(QPainter *painter)
 {
diff --git a/src/monitor/monitorproxy.h b/src/monitor/monitorproxy.h
index d1227bc..72634de 100644
--- a/src/monitor/monitorproxy.h
+++ b/src/monitor/monitorproxy.h
@@ -12,6 +12,7 @@
     void setCursorPosition(int pos);
     void setJobsProgress(const ObjectId &owner, const QStringList &jobNames, const QList<int> &jobProgress, const QStringList &jobUuids);
     void addSnap(int);
+    void snapCursorToElements(int currentPos);
     void removeSnap(int);
diff --git a/src/monitor/monitorproxy.cpp b/src/monitor/monitorproxy.cpp
index 5a9f45b..91df1da 100644
--- a/src/monitor/monitorproxy.cpp
+++ b/src/monitor/monitorproxy.cpp
@@ -16,6 +16,19 @@
 }
 
 void MonitorProxy::addSnap(int pos) {
+    SnapModel::addPoint(pos); // Register a new snap point
 }
+
+void MonitorProxy::snapCursorToElements(int currentPos) {
+    if (KdenliveSettings::snaptopoints()) { // Only snap when the feature is enabled
+        int snapPos = SnapModel::getClosestPoint(currentPos);
+        if (snapPos != -1) {
+            setCursorPosition(snapPos);
+        }
+    }
+}
+
Comment 2 Jean-Baptiste Mardelle 2026-02-13 09:47:04 UTC
Hmm, but that would prevent normal seeking, for example if you want to find a specific image, you might want to seek and see all frames. If we implement the snapping behavior, the playhead would directly jump from one snap point to another... I think both behavior might make sense but users should still be able to seek normally...
Comment 3 Gabriel Gazzán 2026-02-13 17:48:01 UTC
(In reply to Jean-Baptiste Mardelle from comment #2)

Yes, sorry, I didn't include in my initial feature description an important detail: This snapping would only occur within a certain amount of (probably) pixels around each snapping point.
So, the user would be able to freely drag the time cursor to any place outside those sensitive areas around snapping points, only when the time cursor enters that sensitive area is that it gets snapped; if the user continues dragging past that snapping area, the time cursor will again be free to move wherever the user wants.
 
Note:
If those areas around snapping points are defined using screen pixels, the user would be able to graduate the feature precision by zooming in/out the Timeline view.