First attempt of Ripple Window (ripple edit is not applied yet)

parent a9fb4655
import QtQuick 2.0
Item {
id: root
objectName: "rootripple"
// default size, but scalable by user
height: 300; width: 400
signal acceptRipple()
signal cancelRipple()
property int displayFontSize
Rectangle {
id: info
x: root.x
y: root.height / 2
width: root.width
height: root.displayFontSize * 2
color: "darkBlue"
Text {
text: 'Ripple Mode'
color: "white"
anchors.centerIn: parent
}
}
MouseArea {
width: root.width; height: root.height / 2 - info.height
anchors {
left: root.left
top: info.bottom
}
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onPressed: {
if (mouseX > width / 2) {
root.acceptRipple()
} else {
root.cancelRipple()
}
}
}
Rectangle {
id: cancel
anchors {
left: root.left
top: info.bottom
}
width: root.width / 2
height: root.height / 2 - info.height
color: "darkRed"
Text {
text: 'Cancel'
color: "white"
anchors.centerIn: parent
}
}
Rectangle {
id: accept
anchors {
right: root.right
top: info.bottom
}
width: root.width / 2
height: root.height / 2 - info.height
color: "darkGreen"
Text {
text: 'Accept'
color: "white"
anchors.centerIn: parent
}
}
}
......@@ -125,7 +125,8 @@ enum MonitorSceneType {
MonitorSceneGeometry,
MonitorSceneCorners,
MonitorSceneRoto,
MonitorSceneSplit
MonitorSceneSplit,
MonitorRipple
};
enum TransitionType {
......
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="kdenlive" version="140" translationDomain="kdenlive">
<kpartgui name="kdenlive" version="142" translationDomain="kdenlive">
<MenuBar>
<Menu name="file" >
<Action name="dvd_wizard" />
......@@ -237,6 +237,7 @@
<Action name="favorite_effects" />
<Separator />
<Action name="timeline_preview_button" />
<Action name="ripple_mode" />
</ToolBar>
<ToolBar name="extraToolBar" >
<text>Extra Toolbar</text>
......
......@@ -468,6 +468,11 @@ MainWindow::MainWindow(const QString &MltPath, const QUrl &Url, const QString &
previewButtonAction->setDefaultWidget(timelinePreview);
addAction(QStringLiteral("timeline_preview_button"), previewButtonAction);
QAction *rippleMode = new QAction(i18n("Ripple Mode"), this);
rippleMode->setCheckable(true);
connect(rippleMode, &QAction::triggered, pCore->projectManager(), &ProjectManager::rippleMode);
addAction(QStringLiteral("ripple_mode"), rippleMode);
setupGUI();
timelinePreview->setToolButtonStyle(m_timelineToolBar->toolButtonStyle());
connect(m_timelineToolBar, &QToolBar::toolButtonStyleChanged, timelinePreview, &ProgressButton::setToolButtonStyle);
......@@ -1729,6 +1734,7 @@ void MainWindow::connectDocument()
connect(project, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
connect(trackView->projectView(), SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
connect(trackView->projectView(), SIGNAL(loadMonitorScene(MonitorSceneType,bool)), m_projectMonitor, SLOT(slotShowEffectScene(MonitorSceneType,bool)));
connect(project, SIGNAL(saveTimelinePreview(QString)), trackView, SLOT(slotSaveTimelinePreview(QString)));
connect(trackView, SIGNAL(showTrackEffects(int,TrackInfo)), this, SLOT(slotTrackSelected(int,TrackInfo)));
......
......@@ -99,6 +99,9 @@ void QmlManager::setScene(Kdenlive::MonitorId id, MonitorSceneType type, QSize p
case MonitorSceneSplit:
m_view->setSource(QUrl(QStringLiteral("qrc:/qml/kdenlivemonitorsplit.qml")));
break;
case MonitorRipple:
m_view->setSource(QUrl(QStringLiteral("qrc:/qml/kdenlivemonitorripple.qml")));
break;
default:
m_view->setSource(QUrl(id == Kdenlive::ClipMonitor ? QStringLiteral("qrc:/qml/kdenliveclipmonitor.qml") : QStringLiteral("qrc:/qml/kdenlivemonitor.qml")));
root = m_view->rootObject();
......
......@@ -735,4 +735,8 @@ void ProjectManager::slotSwitchTrackTarget()
m_trackView->switchTrackTarget();
}
void ProjectManager::rippleMode(bool enable)
{
m_trackView->projectView()->rippleMode(enable);
}
......@@ -112,7 +112,7 @@ public slots:
void slotSwitchAllTrackLock();
/** @brief Un/Set current track as target */
void slotSwitchTrackTarget();
void rippleMode(bool enable);
private slots:
void slotRevert();
......
......@@ -2239,6 +2239,23 @@ bool CustomTrackView::createSplitOverlay(Mlt::Filter *filter)
return m_timeline->createOverlay(filter, m_dragItem->track(), m_dragItem->startPos().frames(m_document->fps()));
}
void CustomTrackView::rippleMode(bool enable)
{
if (!enable) {
m_timeline->removeSplitOverlay();
emit loadMonitorScene(MonitorSceneDefault, false);
monitorRefresh();
return;
}
if (!m_dragItem || m_dragItem->type() != AVWidget) {
emit displayMessage(i18n("Select a clip to enter ripple mode"), InformationMessage);
return;
}
m_timeline->createRippleWindow(m_dragItem->track(), m_dragItem->startPos().frames(m_document->fps()));
monitorRefresh();
emit loadMonitorScene(MonitorRipple, true);
}
void CustomTrackView::slotAddEffectToCurrentItem(QDomElement effect)
{
slotAddEffect(effect, GenTime(), -1);
......
......@@ -260,6 +260,7 @@ public:
void switchAllTrackLock();
/** @brief Insert space in timeline. track = -1 means all tracks */
void insertTimelineSpace(GenTime startPos, GenTime duration, int track = -1, QList <ItemInfo> excludeList = QList <ItemInfo>());
void rippleMode(bool enable);
public slots:
/** @brief Send seek request to MLT. */
......@@ -597,6 +598,7 @@ signals:
void showClipFrame(const QString &id, int frame);
/** @brief Select active keyframe in effect stack */
void setActiveKeyframe(int);
void loadMonitorScene(MonitorSceneType,bool);
};
#endif
......
......@@ -1679,7 +1679,13 @@ void Timeline::removeSplitOverlay()
{
if (!m_hasOverlayTrack) return;
m_tractor->lock();
m_tractor->remove_track(tracksCount());
Mlt::Producer *prod = m_tractor->track(tracksCount());
if (strcmp(prod->get("id"), "overlay_track") == 0) {
m_tractor->remove_track(tracksCount());
} else {
qWarning() << "Overlay track not found, something is wrong!!";
}
delete prod;
m_hasOverlayTrack = false;
m_tractor->unlock();
}
......@@ -1713,6 +1719,63 @@ bool Timeline::createOverlay(Mlt::Filter *filter, int tk, int startPos)
m_tractor->insert_track(overlay, trackIndex);
Mlt::Producer *overlayTrack = m_tractor->track(trackIndex);
overlayTrack->set("hide", 2);
overlayTrack->set("id", "overlay_track");
delete overlayTrack;
m_hasOverlayTrack = true;
m_tractor->unlock();
return true;
}
bool Timeline::createRippleWindow(int tk, int startPos)
{
Track *sourceTrack = track(tk);
if (!sourceTrack) return false;
m_tractor->lock();
int clipIndex = sourceTrack->playlist().get_clip_index_at(startPos);
Mlt::Producer *clipProducer = sourceTrack->playlist().get_clip(clipIndex);
Clip clp(clipProducer->parent());
Mlt::Producer *cln = clp.clone();
Clip(*cln).addEffects(*clipProducer);
Mlt::Producer *clipProducer2 = sourceTrack->playlist().get_clip(clipIndex - 1);
//Clip clp2(clipProducer2->parent());
Mlt::Producer *cln2 = new Mlt::Producer(clipProducer2->parent()); //clp2.clone();
cln2->set_in_and_out(clipProducer2->get_in(), -1);
Clip(*cln2).addEffects(*clipProducer2);
int secondStart = sourceTrack->playlist().clip_start(clipIndex) - clipProducer->get_in();
int rippleStart = sourceTrack->playlist().clip_start(clipIndex - 1);
Mlt::Filter f1(*m_tractor->profile(), "affine");
f1.set("transition.geometry", "50% 0 50% 50%");
cln->attach(f1);
Mlt::Playlist ripple1(*m_tractor->profile());
ripple1.insert_blank(0, secondStart);
ripple1.insert_at(secondStart, cln, 1);
Mlt::Playlist ripple2(*m_tractor->profile());
ripple2.insert_blank(0, rippleStart);
ripple2.insert_at(rippleStart, cln2, 1);
Mlt::Playlist overlay(*m_tractor->profile());
Mlt::Tractor trac(*m_tractor->profile());
// TODO: use GPU effect/trans with movit
Mlt::Transition t(*m_tractor->profile(), "affine");
t.set("geometry", "0% 0 50% 50%");
t.set("always_active", 1);
trac.set_track(ripple1, 0);
trac.set_track(ripple2, 1);
trac.plant_transition(t, 0, 1);
delete cln;
delete cln2;
delete clipProducer;
delete clipProducer2;
Mlt::Producer split(trac.get_producer());
overlay.insert_at(0, &split, 1);
int trackIndex = tracksCount();
m_tractor->insert_track(overlay, trackIndex);
Mlt::Producer *overlayTrack = m_tractor->track(trackIndex);
overlayTrack->set("hide", 2);
overlayTrack->set("id", "overlay_track");
delete overlayTrack;
m_hasOverlayTrack = true;
m_tractor->unlock();
......
......@@ -148,6 +148,8 @@ public:
void importPlaylist(ItemInfo info, QMap <QString, QString> processedUrl, QMap <QString, QString> idMaps, QDomDocument doc, QUndoCommand *command);
/** @brief Creates an overlay track with a filtered clip */
bool createOverlay(Mlt::Filter *filter, int tk, int startPos);
/** @brief Creates an overlay track with a ripple transition*/
bool createRippleWindow(int tk, int startPos);
void removeSplitOverlay();
/** @brief Temporarily add/remove track before saving */
void connectOverlayTrack(bool enable);
......
......@@ -8,6 +8,7 @@
<file alias="kdenlivemonitoreffectscene.qml">../data/kdenlivemonitoreffectscene.qml</file>
<file alias="kdenlivemonitorcornerscene.qml">../data/kdenlivemonitorcornerscene.qml</file>
<file alias="kdenlivemonitorsplit.qml">../data/kdenlivemonitorsplit.qml</file>
<file alias="kdenlivemonitorripple.qml">../data/kdenlivemonitorripple.qml</file>
<file alias="SceneToolBar.qml">../data/SceneToolBar.qml</file>
<file alias="EffectToolBar.qml">../data/EffectToolBar.qml</file>
</qresource>
......
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