Allow guide move in timeline

parent 55ec8e69
...@@ -141,11 +141,14 @@ bool MarkerListModel::removeMarker(GenTime pos) ...@@ -141,11 +141,14 @@ bool MarkerListModel::removeMarker(GenTime pos)
return res; return res;
} }
bool MarkerListModel::editMarker(GenTime oldPos, GenTime pos, const QString &comment, int type) bool MarkerListModel::editMarker(GenTime oldPos, GenTime pos, QString comment, int type)
{ {
QWriteLocker locker(&m_lock); QWriteLocker locker(&m_lock);
Q_ASSERT(m_markerList.count(oldPos) > 0); Q_ASSERT(m_markerList.count(oldPos) > 0);
QString oldComment = m_markerList[oldPos].first; QString oldComment = m_markerList[oldPos].first;
if (comment.isEmpty()) {
comment = oldComment;
}
int oldType = m_markerList[oldPos].second; int oldType = m_markerList[oldPos].second;
if (oldPos == pos && oldComment == comment && oldType == type) return true; if (oldPos == pos && oldComment == comment && oldType == type) return true;
Fun undo = []() { return true; }; Fun undo = []() { return true; };
......
...@@ -86,7 +86,7 @@ public: ...@@ -86,7 +86,7 @@ public:
@param comment is the text associated with the marker @param comment is the text associated with the marker
@param type is the type (color) associated with the marker. If -1 is passed, then the value is pulled from kdenlive's defaults @param type is the type (color) associated with the marker. If -1 is passed, then the value is pulled from kdenlive's defaults
*/ */
bool editMarker(GenTime oldPos, GenTime pos, const QString &comment, int type = -1); bool editMarker(GenTime oldPos, GenTime pos, QString comment = QString(), int type = -1);
/* @brief This describes the available markers type and their corresponding colors */ /* @brief This describes the available markers type and their corresponding colors */
static std::array<QColor, 5> markerTypes; static std::array<QColor, 5> markerTypes;
......
...@@ -994,6 +994,7 @@ Rectangle { ...@@ -994,6 +994,7 @@ Rectangle {
id: guidesDelegateModel id: guidesDelegateModel
model: guidesModel model: guidesModel
Item { Item {
id: guideRoot
Rectangle { Rectangle {
id: guideBase id: guideBase
width: 1 width: 1
...@@ -1016,7 +1017,31 @@ Rectangle { ...@@ -1016,7 +1017,31 @@ Rectangle {
acceptedButtons: Qt.LeftButton acceptedButtons: Qt.LeftButton
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
hoverEnabled: true hoverEnabled: true
onDoubleClicked: timeline.editGuide(model.frame) property int startX
drag.axis: Drag.XAxis
drag.target: guideRoot
onPressed: {
drag.target = guideRoot
startX = guideRoot.x
}
onReleased: {
if (startX != guideRoot.x) {
timeline.moveGuide(model.frame, model.frame + guideRoot.x / timeline.scaleFactor)
}
drag.target = undefined
}
onPositionChanged: {
if (pressed) {
var frame = Math.round(model.frame + guideRoot.x / timeline.scaleFactor)
frame = controller.suggestSnapPoint(frame, root.snapping)
guideRoot.x = (frame - model.frame) * timeline.scaleFactor
}
}
drag.smoothed: false
onDoubleClicked: {
timeline.editGuide(model.frame)
drag.target = undefined
}
onClicked: timeline.position = guideBase.x / timeline.scaleFactor onClicked: timeline.position = guideBase.x / timeline.scaleFactor
} }
} }
......
...@@ -485,6 +485,14 @@ void TimelineController::editGuide(int frame) ...@@ -485,6 +485,14 @@ void TimelineController::editGuide(int frame)
guideModel->editMarkerGui(pos, qApp->activeWindow(), false); guideModel->editMarkerGui(pos, qApp->activeWindow(), false);
} }
void TimelineController::moveGuide(int frame, int newFrame)
{
auto guideModel = pCore->projectManager()->current()->getGuideModel();
GenTime pos(frame, pCore->getCurrentFps());
GenTime newPos(newFrame, pCore->getCurrentFps());
guideModel->editMarker(pos, newPos);
}
void TimelineController::switchGuide(int frame, bool deleteOnly) void TimelineController::switchGuide(int frame, bool deleteOnly)
{ {
bool markerFound = false; bool markerFound = false;
......
...@@ -160,6 +160,7 @@ public: ...@@ -160,6 +160,7 @@ public:
/* @brief Ask for edit timeline guide dialog /* @brief Ask for edit timeline guide dialog
*/ */
Q_INVOKABLE void editGuide(int frame = -1); Q_INVOKABLE void editGuide(int frame = -1);
Q_INVOKABLE void moveGuide(int frame, int newFrame);
/* @brief Add a timeline guide /* @brief Add a timeline guide
*/ */
Q_INVOKABLE void switchGuide(int frame = -1, bool deleteOnly = false); Q_INVOKABLE void switchGuide(int frame = -1, bool deleteOnly = false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment