Commit 9a08ea41 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Add option to lock/unlock guides. Unlocked guides will move along when using...

Add option to lock/unlock guides. Unlocked guides will move along when using spacer tool or adding/removing space
parent 63bb2839
......@@ -824,6 +824,11 @@
<default>true</default>
</entry>
<entry name="lockedGuides" type="Bool">
<label>Lock guides on spacer movements (insert/remove space).</label>
<default>true</default>
</entry>
<entry name="tagsintimeline" type="Bool">
<label>Show color tags in timeline.</label>
<default>true</default>
......
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="kdenlive" version="200" translationDomain="kdenlive">
<kpartgui name="kdenlive" version="201" translationDomain="kdenlive">
<MenuBar>
<Menu name="file" >
<Action name="file_save"/>
......@@ -135,14 +135,15 @@
</Menu>
<Action name="grab_item" />
<Menu name="guide_menu" ><text>&amp;Guides</text>
<Action name="add_guide" />
<Action name="edit_guide" />
<Action name="delete_guide" />
<Action name="delete_all_guides" />
<Action name="add_guide" />
<Action name="edit_guide" />
<Action name="delete_guide" />
<Action name="delete_all_guides" />
<Action name="lock_guides" />
</Menu>
<Menu name="space_menu" ><text>Space</text>
<Action name="insert_space" />
<Action name="delete_space" />
<Action name="insert_space" />
<Action name="delete_space" />
<Action name="delete_space_all_tracks" />
</Menu>
<Action name="group_clip" />
......
......@@ -630,6 +630,7 @@ void MainWindow::init(const QString &mltPath)
auto *timelineRulerMenu = new QMenu(this);
timelineRulerMenu->addAction(actionCollection()->action(QStringLiteral("add_guide")));
timelineRulerMenu->addAction(actionCollection()->action(QStringLiteral("edit_guide")));
timelineRulerMenu->addAction(actionCollection()->action(QStringLiteral("lock_guides")));
timelineRulerMenu->addMenu(guideMenu);
timelineRulerMenu->addAction(actionCollection()->action(QStringLiteral("add_project_note")));
timelineRulerMenu->addAction(actionCollection()->action(QStringLiteral("add_subtitle")));
......@@ -1778,6 +1779,11 @@ void MainWindow::setupActions()
addAction(QStringLiteral("add_guide"), i18n("Add/Remove Guide"), this, SLOT(slotAddGuide()), QIcon::fromTheme(QStringLiteral("list-add")), Qt::Key_G);
addAction(QStringLiteral("delete_guide"), i18n("Delete Guide"), this, SLOT(slotDeleteGuide()), QIcon::fromTheme(QStringLiteral("edit-delete")));
addAction(QStringLiteral("edit_guide"), i18n("Edit Guide"), this, SLOT(slotEditGuide()), QIcon::fromTheme(QStringLiteral("document-properties")));
QAction *lockGuides = addAction(QStringLiteral("lock_guides"), i18n("Guides Locked"), this, SLOT(slotLockGuides(bool)), QIcon::fromTheme(QStringLiteral("kdenlive-lock")));
lockGuides->setCheckable(true);
lockGuides->setChecked(KdenliveSettings::lockedGuides());
addAction(QStringLiteral("delete_all_guides"), i18n("Delete All Guides"), this, SLOT(slotDeleteAllGuides()),
QIcon::fromTheme(QStringLiteral("edit-delete")));
addAction(QStringLiteral("add_subtitle"), i18n("Add Subtitle"), this, SLOT(slotAddSubtitle()), QIcon::fromTheme(QStringLiteral("list-add")), Qt::SHIFT +Qt::Key_S);
......@@ -2804,6 +2810,12 @@ void MainWindow::slotEditGuide()
getCurrentTimeline()->controller()->editGuide();
}
void MainWindow::slotLockGuides(bool lock)
{
KdenliveSettings::setLockedGuides(lock);
getCurrentTimeline()->controller()->guidesLockedChanged();
}
void MainWindow::slotDeleteGuide()
{
getCurrentTimeline()->controller()->switchGuide(-1, true);
......
......@@ -407,6 +407,7 @@ private slots:
void slotRemoveAllSpace();
void slotAddGuide();
void slotEditGuide();
void slotLockGuides(bool lock);
void slotDeleteGuide();
void slotDeleteAllGuides();
void slotGuidesUpdated();
......
......@@ -402,6 +402,14 @@ bool TimelineFunctions::requestSpacerEndOperation(const std::shared_ptr<Timeline
} else {
timeline->requestSubtitleMove(itemId, startPosition, false, false);
}
// Move guides
if (!KdenliveSettings::lockedGuides()) {
GenTime fromPos(startPosition, pCore->getCurrentFps());
GenTime toPos(endPosition, pCore->getCurrentFps());
QList<CommentedTime> guides = pCore->currentDoc()->getGuideModel()->getMarkersInRange(startPosition, -1);
pCore->currentDoc()->getGuideModel()->moveMarkers(guides, fromPos, toPos, undo, redo);
}
std::unordered_set<int> clips = timeline->getGroupElements(itemId);
int mainGroup = timeline->m_groups->getRootId(itemId);
bool final = false;
......
......@@ -122,6 +122,7 @@ Item {
visible: timeline.showMarkers
width: mlabel.contentWidth + 4
height: guideLabelHeight
radius: timeline.guidesLocked ? 0 : height / 4
anchors {
top: parent.top
left: parent.left
......
......@@ -766,7 +766,7 @@ void TimelineController::gotoNextSnap()
if (m_activeSnaps.empty() || pCore->undoIndex() != m_snapStackIndex) {
m_snapStackIndex = pCore->undoIndex();
m_activeSnaps.clear();
m_activeSnaps = pCore->projectManager()->current()->getGuideModel()->getSnapPoints();
m_activeSnaps = pCore->currentDoc()->getGuideModel()->getSnapPoints();
m_activeSnaps.push_back(m_zone.x());
m_activeSnaps.push_back(m_zone.y() - 1);
}
......@@ -782,7 +782,7 @@ void TimelineController::gotoPreviousSnap()
if (m_activeSnaps.empty() || pCore->undoIndex() != m_snapStackIndex) {
m_snapStackIndex = pCore->undoIndex();
m_activeSnaps.clear();
m_activeSnaps = pCore->projectManager()->current()->getGuideModel()->getSnapPoints();
m_activeSnaps = pCore->currentDoc()->getGuideModel()->getSnapPoints();
m_activeSnaps.push_back(m_zone.x());
m_activeSnaps.push_back(m_zone.y() - 1);
}
......@@ -792,7 +792,7 @@ void TimelineController::gotoPreviousSnap()
void TimelineController::gotoNextGuide()
{
QList<CommentedTime> guides = pCore->projectManager()->current()->getGuideModel()->getAllMarkers();
QList<CommentedTime> guides = pCore->currentDoc()->getGuideModel()->getAllMarkers();
int pos = pCore->getTimelinePosition();
double fps = pCore->getCurrentFps();
for (auto &guide : guides) {
......@@ -807,7 +807,7 @@ void TimelineController::gotoNextGuide()
void TimelineController::gotoPreviousGuide()
{
if (pCore->getTimelinePosition() > 0) {
QList<CommentedTime> guides = pCore->projectManager()->current()->getGuideModel()->getAllMarkers();
QList<CommentedTime> guides = pCore->currentDoc()->getGuideModel()->getAllMarkers();
int pos = pCore->getTimelinePosition();
double fps = pCore->getCurrentFps();
int lastGuidePos = 0;
......@@ -1146,14 +1146,14 @@ void TimelineController::editGuide(int frame)
if (frame == -1) {
frame = pCore->getTimelinePosition();
}
auto guideModel = pCore->projectManager()->current()->getGuideModel();
auto guideModel = pCore->currentDoc()->getGuideModel();
GenTime pos(frame, pCore->getCurrentFps());
guideModel->editMarkerGui(pos, qApp->activeWindow(), false);
}
void TimelineController::moveGuide(int frame, int newFrame)
{
auto guideModel = pCore->projectManager()->current()->getGuideModel();
auto guideModel = pCore->currentDoc()->getGuideModel();
GenTime pos(frame, pCore->getCurrentFps());
GenTime newPos(newFrame, pCore->getCurrentFps());
guideModel->editMarker(pos, newPos);
......@@ -1161,7 +1161,7 @@ void TimelineController::moveGuide(int frame, int newFrame)
void TimelineController::moveGuideWithoutUndo(int mid, int newFrame)
{
auto guideModel = pCore->projectManager()->current()->getGuideModel();
auto guideModel = pCore->currentDoc()->getGuideModel();
GenTime newPos(newFrame, pCore->getCurrentFps());
guideModel->moveMarker(mid, newPos);
}
......@@ -1189,8 +1189,8 @@ bool TimelineController::moveGuidesInRange(int start, int end, int offset, Fun &
{
GenTime fromPos(start, pCore->getCurrentFps());
GenTime toPos(start + offset, pCore->getCurrentFps());
QList<CommentedTime> guides = pCore->projectManager()->current()->getGuideModel()->getMarkersInRange(start, end);
return pCore->projectManager()->current()->getGuideModel()->moveMarkers(guides, fromPos, toPos, undo, redo);
QList<CommentedTime> guides = pCore->currentDoc()->getGuideModel()->getMarkersInRange(start, end);
return pCore->currentDoc()->getGuideModel()->moveMarkers(guides, fromPos, toPos, undo, redo);
}
void TimelineController::switchGuide(int frame, bool deleteOnly)
......@@ -1199,16 +1199,16 @@ void TimelineController::switchGuide(int frame, bool deleteOnly)
if (frame == -1) {
frame = pCore->getTimelinePosition();
}
CommentedTime marker = pCore->projectManager()->current()->getGuideModel()->getMarker(GenTime(frame, pCore->getCurrentFps()), &markerFound);
CommentedTime marker = pCore->currentDoc()->getGuideModel()->getMarker(GenTime(frame, pCore->getCurrentFps()), &markerFound);
if (!markerFound) {
if (deleteOnly) {
pCore->displayMessage(i18n("No guide found at current position"), ErrorMessage, 500);
return;
}
GenTime pos(frame, pCore->getCurrentFps());
pCore->projectManager()->current()->getGuideModel()->addMarker(pos, i18n("guide"));
pCore->currentDoc()->getGuideModel()->addMarker(pos, i18n("guide"));
} else {
pCore->projectManager()->current()->getGuideModel()->removeMarker(marker.time());
pCore->currentDoc()->getGuideModel()->removeMarker(marker.time());
}
}
......@@ -1642,10 +1642,9 @@ bool TimelineController::requestSpacerEndOperation(int clipId, int startPosition
// Start undoable command
std::function<bool(void)> undo = []() { return true; };
std::function<bool(void)> redo = []() { return true; };
if(guideStart > -1) {
if(guideStart > -1 && KdenliveSettings::lockedGuides()) {
moveGuidesInRange(guideStart, -1, endPosition - startPosition, undo, redo);
}
bool result = TimelineFunctions::requestSpacerEndOperation(m_model, clipId, startPosition, endPosition, affectedTrack, undo, redo);
return result;
}
......@@ -4276,6 +4275,11 @@ bool TimelineController::subtitlesLocked() const
return false;
}
bool TimelineController::guidesLocked() const
{
return KdenliveSettings::lockedGuides();
}
void TimelineController::showToolTip(const QString &info) const
{
pCore->displayMessage(info, DirectMessage);
......
......@@ -89,6 +89,7 @@ class TimelineController : public QObject
Q_PROPERTY(QColor groupColor READ groupColor NOTIFY colorsChanged)
Q_PROPERTY(bool subtitlesDisabled READ subtitlesDisabled NOTIFY subtitlesDisabledChanged)
Q_PROPERTY(bool subtitlesLocked READ subtitlesLocked NOTIFY subtitlesLockedChanged)
Q_PROPERTY(bool guidesLocked READ guidesLocked NOTIFY guidesLockedChanged)
Q_PROPERTY(QPoint effectZone MEMBER m_effectZone NOTIFY effectZoneChanged)
public:
......@@ -191,6 +192,7 @@ public:
bool subtitlesDisabled() const;
void switchSubtitleLock();
bool subtitlesLocked() const;
bool guidesLocked() const;
/** @brief Request a seek operation
@param position is the desired new timeline position
*/
......@@ -753,6 +755,7 @@ signals:
/** @brief Center timeline view on current position
*/
void centerView();
void guidesLockedChanged();
void effectZoneChanged();
void masterZonesChanged();
Q_INVOKABLE void ungrabHack();
......
  • hi

    i find BUG! see video!

  • I can confirm that. The first guide, on clip begin doesn't move.

    Edited by Eugen Mohr
  • mentioned in issue #651

    Toggle commit list
  • mentioned in commit 1bb40db3

    Toggle commit list
  • mentioned in commit 4f522688

    Toggle commit list
  • @manuelmuzzurru @emohr I made some fixes please try again

  • ok, i will wait last appimage nightly..

  • this is FIXED!! thank you (works for moving unlock all guides, works remove space empty, guide is moving unlock,works)

    but i find other BUG: when i lock guide and i can move my mouse ..maybe is not work for locked..?

    version: kdenlive-21.07.70-4f522688-x86_64.appimage

  • Not fixed. Left guide on the first clip doesn't move.

    Animation

  • @emohr this was intended: only markers after mouse position are moved.

    @manuelmuzzurru can you explain the bug a bit more? Maybe provide a screenshot/-record?

  • @emohr your video is not bug, that is correct works, that spacer tool is correct...first guide not move: why? because you did not move "before" than first guide..spacer tool function is for move all items in timeline like "shift-time" so guide is works, for me this is not bug.. it's correct ok?

    @jlskuz : ok i try explain you my case; is the question :

    "Guides Locked" see here image:

    image

    this is little "confusion" communication visual UI:

    A-

    "guides locked" is for spacer tool/remove space(in timeline)?

    if YES: then need to change words: Guide Locked for spacer tool/remove space"

    B-

    "Guide Locked": i was understand that i cant move all guides with mouse...instead i click guides are locked but i can move all guide..so im confusing.. so i ask you : Guide locked is for locked for me ?

    if YES: then need to change words: Guide Locked for timeline,(this mean i cant move all guide in timeline), ADD WORDS: Guide Locked for spacer tool/remove space,(this mean guides can move by spacer tool(unlock), or spacer tool will not move all guides (lock).

    (see video this first time is works , second time: question..)

    example in menu:

    -Guide Lock for timeline

    -Guide Lock for spacer tool/remove space

    Edited by manuel muzzurru
  • @manuelmuzzurru This option is only for the spacer tool and remove space. I agree that the wording is a bit confusing, but "Guide Locked for spacer tool/remove space" is very long…

  • @jlskuz What to do in this situation? The most left guide will never move as it can't be grabed left of the clip:

    image

    I would suggest: If you grab a clip with the spacer tool all guides are moving with it.

  • @jlskuz i know for long words, im not good English phrase, try ask to @mardelle @massimostella team devs for find correct words ok?

    @emohr : sorry , im not understand what is your problem? for me i don't see an issue for unlock/lock for guide..

  • @emohr : now im understand that you mean:

    first frame (begin) spacer tool + guide (unlock) not move, right? this yes ISSUe: proposal: add 5 frames "UNUSABLE" ALL TRACKS VIDEO/AUDIO/SUBTITLE , like as empty space vertical, actually is space unusable is 0 size so need ADD 5pixel empty space vertical..

    see example space_vertical

    for code:

    frame 0 = start timeline (works playhead, clips items,subtitles items, audio items, transition items, zone preview, zone selection,guides)

    frame -1 until -5 frame = unusable this mean can move by spacer tool for (guide), nothing works all function editing..only for move the guides..

    this is good idea

    @jlskuz : you can add -5 frames timeline for unusable but works with mouse, but not playhead, playhead start by 1 frame of timeline , this will be resolve..

    Edited by manuel muzzurru
  • OR good idea by @emohr :

    "I would suggest: If you grab a clip with the spacer tool all guides are moving with it."

    but only for FIST START OF ITEM IN TIMELINE...is it okay?

  • Yes, that would be a solution.

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