| Summary: | Snap Time Cursor when dragging it. | ||
|---|---|---|---|
| Product: | [Applications] kdenlive | Reporter: | Gabriel Gazzán <gabcorreo> |
| Component: | Timeline & Editing | Assignee: | Jean-Baptiste Mardelle <jb> |
| Status: | REPORTED --- | ||
| Severity: | wishlist | CC: | luzpaz |
| Priority: | NOR | Keywords: | junior-jobs |
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | Other | ||
| OS: | Other | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
|
Description
Gabriel Gazzán
2025-05-03 00:07:47 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);
+ }
+ }
+}
+
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... (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. |