Add 3 point edit INSERT

Ref T1961
parent 9019c47b
......@@ -75,6 +75,14 @@ namespace PlaylistState {
};
namespace TimelineMode {
enum EditMode {
NormalEdit = 0,
OverwriteEdit = 1,
InsertEdit = 2
};
};
enum ClipType {
Unknown = 0,
Audio = 1,
......
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="kdenlive" version="111" translationDomain="kdenlive">
<kpartgui name="kdenlive" version="112" translationDomain="kdenlive">
<ToolBar name="extraToolBar" >
<text>Extra Toolbar</text>
<Action name="project_render" />
......@@ -103,7 +103,8 @@
<Action name="deselect_timeline_transition" />
</Menu>
<Menu name="keyboard_insert" ><text>Insertion</text>
<Action name="overwrite_to_in_point" />
<Action name="insert_to_in_point" />
<Action name="overwrite_to_in_point" />
</Menu>
<Action name="resize_timeline_clip_start" />
<Action name="resize_timeline_clip_end" />
......
......@@ -1182,7 +1182,8 @@ void MainWindow::setupActions()
addAction(QStringLiteral("edit_item_duration"), i18n("Edit Duration"), this, SLOT(slotEditItemDuration()), KoIconUtils::themedIcon(QStringLiteral("measure")));
addAction(QStringLiteral("clip_in_project_tree"), i18n("Clip in Project Bin"), this, SLOT(slotClipInProjectTree()), KoIconUtils::themedIcon(QStringLiteral("go-jump-definition")));
addAction(QStringLiteral("overwrite_to_in_point"), i18n("Insert Clip Zone in Timeline (Overwrite)"), this, SLOT(slotInsertClipOverwrite()), QIcon(), Qt::Key_V);
addAction(QStringLiteral("overwrite_to_in_point"), i18n("Insert Clip Zone in Timeline (Overwrite)"), this, SLOT(slotInsertClipOverwrite()), QIcon(), Qt::Key_B);
addAction(QStringLiteral("insert_to_in_point"), i18n("Insert Clip Zone in Timeline (Insert)"), this, SLOT(slotInsertClipInsert()), QIcon(), Qt::Key_V);
addAction(QStringLiteral("select_timeline_clip"), i18n("Select Clip"), this, SLOT(slotSelectTimelineClip()), KoIconUtils::themedIcon(QStringLiteral("edit-select")), Qt::Key_Plus);
addAction(QStringLiteral("deselect_timeline_clip"), i18n("Deselect Clip"), this, SLOT(slotDeselectTimelineClip()), KoIconUtils::themedIcon(QStringLiteral("edit-select")), Qt::Key_Minus);
addAction(QStringLiteral("select_add_timeline_clip"), i18n("Add Clip To Selection"), this, SLOT(slotSelectAddTimelineClip()),
......@@ -2198,7 +2199,15 @@ void MainWindow::slotInsertClipOverwrite()
{
if (pCore->projectManager()->currentTimeline()) {
QStringList data = m_clipMonitor->getZoneInfo();
pCore->projectManager()->currentTimeline()->projectView()->insertZoneOverwrite(data, pCore->projectManager()->currentTimeline()->projectView()->seekPosition());
pCore->projectManager()->currentTimeline()->projectView()->insertZone(TimelineMode::OverwriteEdit, data, pCore->projectManager()->currentTimeline()->projectView()->seekPosition());
}
}
void MainWindow::slotInsertClipInsert()
{
if (pCore->projectManager()->currentTimeline()) {
QStringList data = m_clipMonitor->getZoneInfo();
pCore->projectManager()->currentTimeline()->projectView()->insertZone(TimelineMode::InsertEdit, data, pCore->projectManager()->currentTimeline()->projectView()->seekPosition());
}
}
......@@ -2462,11 +2471,11 @@ void MainWindow::slotChangeEdit(QAction * action)
return;
if (action == m_overwriteEditTool)
pCore->projectManager()->currentTimeline()->projectView()->setEditMode(OverwriteEdit);
pCore->projectManager()->currentTimeline()->projectView()->setEditMode(TimelineMode::OverwriteEdit);
else if (action == m_insertEditTool)
pCore->projectManager()->currentTimeline()->projectView()->setEditMode(InsertEdit);
pCore->projectManager()->currentTimeline()->projectView()->setEditMode(TimelineMode::InsertEdit);
else
pCore->projectManager()->currentTimeline()->projectView()->setEditMode(NormalEdit);
pCore->projectManager()->currentTimeline()->projectView()->setEditMode(TimelineMode::NormalEdit);
}
void MainWindow::slotSetTool(ProjectTool tool)
......
......@@ -320,6 +320,7 @@ private slots:
void slotAddMarkerGuideQuickly();
void slotCutTimelineClip();
void slotInsertClipOverwrite();
void slotInsertClipInsert();
void slotSelectTimelineClip();
void slotSelectTimelineTransition();
void slotDeselectTimelineClip();
......
......@@ -306,7 +306,7 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant
QList<QGraphicsItem*> collidingItems;
QPainterPath shape;
if (projectScene()->editMode() == NormalEdit) {
if (projectScene()->editMode() == TimelineMode::NormalEdit) {
shape = clipGroupShape(newPos - pos());
collidingItems = scene->items(shape, Qt::IntersectsItemShape);
collidingItems.removeAll(this);
......@@ -362,7 +362,7 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant
}
}
if (projectScene()->editMode() == NormalEdit) {
if (projectScene()->editMode() == TimelineMode::NormalEdit) {
shape = transitionGroupShape(newPos - pos());
collidingItems = scene->items(shape, Qt::IntersectsItemShape);
collidingItems.removeAll(this);
......
......@@ -1206,7 +1206,7 @@ QVariant ClipItem::itemChange(GraphicsItemChange change, const QVariant &value)
QRectF sceneShape = rect();
sceneShape.translate(newPos);
QList<QGraphicsItem*> items;
if (scene->editMode() == NormalEdit) {
if (scene->editMode() == TimelineMode::NormalEdit) {
items = scene->items(sceneShape, Qt::IntersectsItemShape);
}
items.removeAll(this);
......
......@@ -26,7 +26,7 @@ CustomTrackScene::CustomTrackScene(Timeline *timeline, QObject *parent) :
isZooming(false),
m_timeline(timeline),
m_scale(1.0, 1.0),
m_editMode(NormalEdit)
m_editMode(TimelineMode::NormalEdit)
{
}
......@@ -99,12 +99,12 @@ MltVideoProfile CustomTrackScene::profile() const
return m_timeline->mltProfile();
}
void CustomTrackScene::setEditMode(EditMode mode)
void CustomTrackScene::setEditMode(TimelineMode::EditMode mode)
{
m_editMode = mode;
}
EditMode CustomTrackScene::editMode() const
TimelineMode::EditMode CustomTrackScene::editMode() const
{
return m_editMode;
}
......
......@@ -30,16 +30,11 @@
#include <QGraphicsScene>
#include "gentime.h"
#include "definitions.h"
class Timeline;
class MltVideoProfile;
enum EditMode {
NormalEdit = 0,
OverwriteEdit = 1,
InsertEdit = 2
};
class CustomTrackScene : public QGraphicsScene
......@@ -57,14 +52,14 @@ public:
QPointF scale() const;
int tracksCount() const;
MltVideoProfile profile() const;
void setEditMode(EditMode mode);
EditMode editMode() const;
void setEditMode(TimelineMode::EditMode mode);
TimelineMode::EditMode editMode() const;
bool isZooming;
private:
Timeline *m_timeline;
QPointF m_scale;
EditMode m_editMode;
TimelineMode::EditMode m_editMode;
QList <GenTime> m_snapPoints;
};
......
......@@ -3050,11 +3050,11 @@ void CustomTrackView::dropEvent(QDropEvent * event)
setFocus();
}
void CustomTrackView::adjustTimelineClips(EditMode mode, ClipItem *item, ItemInfo posinfo, QUndoCommand *command, bool doIt)
void CustomTrackView::adjustTimelineClips(TimelineMode::EditMode mode, ClipItem *item, ItemInfo posinfo, QUndoCommand *command, bool doIt)
{
bool snap = KdenliveSettings::snaptopoints();
KdenliveSettings::setSnaptopoints(false);
if (mode == OverwriteEdit) {
if (mode == TimelineMode::OverwriteEdit) {
// if we are in overwrite mode, move clips accordingly
ItemInfo info;
if (item == NULL) info = posinfo;
......@@ -3117,7 +3117,7 @@ void CustomTrackView::adjustTimelineClips(EditMode mode, ClipItem *item, ItemInf
}
}
}
} else if (mode == InsertEdit) {
} else if (mode == TimelineMode::InsertEdit) {
// if we are in push mode, move clips accordingly
ItemInfo info;
if (item == NULL) info = posinfo;
......@@ -3128,29 +3128,61 @@ void CustomTrackView::adjustTimelineClips(EditMode mode, ClipItem *item, ItemInf
for (int i = 0; i < selection.count(); ++i) {
if (selection.at(i)->type() == AVWidget) {
ClipItem *clip = static_cast<ClipItem *>(selection.at(i));
if (clip->startPos() < info.startPos) {
if (clip->endPos() > info.startPos) {
ItemInfo clipInfo = clip->info();
ItemInfo dupInfo = clipInfo;
GenTime diff = info.startPos - clipInfo.startPos;
dupInfo.startPos = info.startPos;
dupInfo.cropStart += diff;
dupInfo.cropDuration = clipInfo.endPos - info.startPos;
new RazorClipCommand(this, clipInfo, clip->effectList(), info.startPos, true, command);
if (clip->startPos() < info.startPos && clip->endPos() > info.startPos) {
// Clip goes before and after insert zone, cut
new RazorClipCommand(this, clip->info(), clip->effectList(), info.startPos, true, command);
}
}
}
// Insert blank
if (m_timeline->isTrackLocked(info.track)) {
emit displayMessage(i18n("Cannot insert space in a locked track"), ErrorMessage);
return;
}
int pos = info.startPos.frames(m_document->fps());
// Make sure there is no group in the way
rect = QRectF(pos, getPositionFromTrack(info.track) + m_tracksHeight / 2, sceneRect().width() - pos, m_tracksHeight / 2 - 2);
bool isOk;
selection = checkForGroups(rect, &isOk);
if (!isOk) {
// groups found on track, do not allow the move
emit displayMessage(i18n("Cannot insert space in a track with a group"), ErrorMessage);
return;
}
QList<ItemInfo> clipsToMove;
QList<ItemInfo> transitionsToMove;
for (int i = 0; i < selection.count(); ++i) {
if (selection.at(i)->type() == AVWidget || selection.at(i)->type() == TransitionWidget) {
AbstractClipItem *item = static_cast <AbstractClipItem *>(selection.at(i));
ItemInfo moveInfo = item->info();
if (item->type() == AVWidget) {
if (moveInfo.startPos < info.startPos) {
// This is the clip that we have just cut, adjust start
moveInfo.startPos = info.startPos;
}
clipsToMove.append(moveInfo);
}
// TODO: add insertspacecommand
else if (item->type() == TransitionWidget)
transitionsToMove.append(moveInfo);
}
}
if (!clipsToMove.isEmpty() || !transitionsToMove.isEmpty()) {
new InsertSpaceCommand(this, clipsToMove, transitionsToMove, info.track, info.cropDuration, true, command);
updateTrackDuration(info.track, command);
}
}
KdenliveSettings::setSnaptopoints(snap);
}
void CustomTrackView::adjustTimelineTransitions(EditMode mode, Transition *item, QUndoCommand *command)
void CustomTrackView::adjustTimelineTransitions(TimelineMode::EditMode mode, Transition *item, QUndoCommand *command)
{
if (mode == OverwriteEdit) {
if (mode == TimelineMode::OverwriteEdit) {
// if we are in overwrite or push mode, move clips accordingly
bool snap = KdenliveSettings::snaptopoints();
KdenliveSettings::setSnaptopoints(false);
......@@ -3664,7 +3696,6 @@ void CustomTrackView::insertSpace(QList<ItemInfo> clipsToMove, QList<ItemInfo> t
trackClipStartList[i] = -1;
trackTransitionStartList[i] = -1;
}
if (!clipsToMove.isEmpty()) for (int i = 0; i < clipsToMove.count(); ++i) {
ClipItem *clip = getClipItemAtStart(clipsToMove.at(i).startPos + offset, clipsToMove.at(i).track);
if (clip) {
......@@ -6217,7 +6248,7 @@ void CustomTrackView::copyClip()
bool CustomTrackView::canBePastedTo(ItemInfo info, int type) const
{
if (m_scene->editMode() != NormalEdit) {
if (m_scene->editMode() != TimelineMode::NormalEdit) {
// If we are in overwrite mode, always allow the move
return true;
}
......@@ -7519,7 +7550,7 @@ QStringList CustomTrackView::extractTransitionsLumas()
return urls;
}
void CustomTrackView::setEditMode(EditMode mode)
void CustomTrackView::setEditMode(TimelineMode::EditMode mode)
{
m_scene->setEditMode(mode);
}
......@@ -7545,7 +7576,7 @@ void CustomTrackView::checkTrackSequence(int track)
if (times != timelineList) KMessageBox::sorry(this, i18n("error"), i18n("TRACTOR"));
}
void CustomTrackView::insertZoneOverwrite(QStringList data, int in)
void CustomTrackView::insertZone(TimelineMode::EditMode sceneMode, QStringList data, int in)
{
if (data.isEmpty()) return;
ItemInfo info;
......@@ -7556,7 +7587,7 @@ void CustomTrackView::insertZoneOverwrite(QStringList data, int in)
info.track = m_selectedTrack;
QUndoCommand *addCommand = new QUndoCommand();
addCommand->setText(i18n("Insert clip"));
adjustTimelineClips(OverwriteEdit, NULL, info, addCommand);
adjustTimelineClips(sceneMode, NULL, info, addCommand);
new AddTimelineClipCommand(this, data.at(0), info, EffectsList(), PlaylistState::Original, true, false, addCommand);
updateTrackDuration(info.track, addCommand);
m_commandStack->push(addCommand);
......
......@@ -184,7 +184,7 @@ public:
void selectClip(bool add, bool group = false, int track = -1, int pos = -1);
void selectTransition(bool add, bool group = false);
QStringList extractTransitionsLumas();
void setEditMode(EditMode mode);
void setEditMode(TimelineMode::EditMode mode);
/** @brief Inserts @param clip.
* @param clip The clip to insert
......@@ -299,7 +299,7 @@ public slots:
void slotTrackUp();
void slotTrackDown();
void slotSelectTrack(int ix);
void insertZoneOverwrite(QStringList data, int in);
void insertZone(TimelineMode::EditMode sceneMode, QStringList data, int in);
/** @brief Rebuilds a group to fit again after children changed.
* @param childTrack the track of one of the groups children
......@@ -470,8 +470,8 @@ private:
/** Selects all items in the scene rect, and sets ok to false if a group going over several tracks is found in it */
QList<QGraphicsItem *> checkForGroups(const QRectF &rect, bool *ok);
/** Adjust clips under another one when working in overwrite mode */
void adjustTimelineClips(EditMode mode, ClipItem *item, ItemInfo posinfo, QUndoCommand *command, bool doIt = true);
void adjustTimelineTransitions(EditMode mode, Transition *item, QUndoCommand *command);
void adjustTimelineClips(TimelineMode::EditMode mode, ClipItem *item, ItemInfo posinfo, QUndoCommand *command, bool doIt = true);
void adjustTimelineTransitions(TimelineMode::EditMode mode, Transition *item, QUndoCommand *command);
/** Adjust keyframes when pasted to another clip */
void adjustKeyfames(GenTime oldstart, GenTime newstart, GenTime duration, QDomElement xml);
......
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