[vlmc-devel] Timeline: Show effects on clips
Yikai Lu
git at videolan.org
Sat Jul 30 07:48:59 CEST 2016
vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Sat Jul 30 14:27:16 2016 +0900| [9f20927a3192259264750540c3d80a1529a12b99] | committer: Yikai Lu
Timeline: Show effects on clips
> https://code.videolan.org/videolan/vlmc/commit/9f20927a3192259264750540c3d80a1529a12b99
---
src/EffectsEngine/EffectHelper.cpp | 8 ++++++-
src/Gui/timeline/Clip.qml | 47 ++++++++++++++++++++++++++++++++++++++
src/Gui/timeline/Timeline.cpp | 1 +
src/Gui/timeline/main.qml | 7 ++++++
src/Workflow/MainWorkflow.cpp | 5 ++--
src/Workflow/MainWorkflow.h | 2 ++
6 files changed, 67 insertions(+), 3 deletions(-)
diff --git a/src/EffectsEngine/EffectHelper.cpp b/src/EffectsEngine/EffectHelper.cpp
index 01829ed..13cd15c 100644
--- a/src/EffectsEngine/EffectHelper.cpp
+++ b/src/EffectsEngine/EffectHelper.cpp
@@ -195,7 +195,13 @@ EffectHelper::toVariant()
auto val = value( QString::fromStdString( param->identifier() ) );
h.insert( val->key(), val->get() );
}
- return QVariantHash{ { "identifier", identifier() }, { "parameters", h } };
+ return QVariantHash{
+ { "begin", begin() },
+ { "end", end() },
+ { "length", length() },
+ { "identifier", identifier() },
+ { "parameters", h }
+ };
}
QVariant
diff --git a/src/Gui/timeline/Clip.qml b/src/Gui/timeline/Clip.qml
index b79014a..be19783 100644
--- a/src/Gui/timeline/Clip.qml
+++ b/src/Gui/timeline/Clip.qml
@@ -63,6 +63,16 @@ Rectangle {
findClipItem( linkedClip ).selected = true;
}
+ function updateEffects( clipInfo ) {
+ if ( !clipInfo["filters"] )
+ return;
+
+ effects.clear();
+ for ( var i = 0; i < clipInfo["filters"].length; ++i ) {
+ effects.append( clipInfo["filters"][i] );
+ }
+ }
+
onXChanged: {
if ( sView.width - initPosOfCursor < width )
return;
@@ -165,6 +175,8 @@ Rectangle {
selected = true;
newTrackId = trackId;
allClips.push( clip );
+
+ updateEffects( workflow.clipInfo( uuid ) );
}
Component.onDestruction: {
@@ -188,6 +200,10 @@ Rectangle {
Drag.keys: ["Clip"]
Drag.active: dragArea.drag.active
+ ListModel {
+ id: effects
+ }
+
Text {
id: text
color: "white"
@@ -200,6 +216,37 @@ Rectangle {
wrapMode: Text.Wrap
}
+ ListView {
+ id: effectsView
+ property int effectHeight: 5
+ anchors.bottom: clip.bottom
+ width: clip.width
+ height: effectHeight * count
+ model: effects
+ delegate: Rectangle {
+ width: ftop( model.length )
+ x: ftop( model.begin )
+ height: effectsView.effectHeight
+ radius: 2
+ gradient: Gradient {
+ GradientStop {
+ position: 0.00;
+ color: "#24245c";
+ }
+ GradientStop {
+ position: 1.00;
+ color: "#200f3c";
+ }
+ }
+ Text {
+ text: model.identifier
+ color: "white"
+ font.pointSize: parent.height
+ anchors.centerIn: parent
+ }
+ }
+ }
+
MouseArea {
id: dragArea
anchors.fill: parent
diff --git a/src/Gui/timeline/Timeline.cpp b/src/Gui/timeline/Timeline.cpp
index 55d1c69..bf2d49a 100644
--- a/src/Gui/timeline/Timeline.cpp
+++ b/src/Gui/timeline/Timeline.cpp
@@ -66,5 +66,6 @@ void
Timeline::showEffectStack( const QString& uuid )
{
auto w = new EffectStack( Core::instance()->workflow()->clip( uuid )->input() );
+ connect( w, &EffectStack::finished, Core::instance()->workflow(), [uuid]{ emit Core::instance()->workflow()->effectsUpdated( uuid ); } );
w->show();
}
diff --git a/src/Gui/timeline/main.qml b/src/Gui/timeline/main.qml
index dff2b41..42a9098 100644
--- a/src/Gui/timeline/main.qml
+++ b/src/Gui/timeline/main.qml
@@ -569,12 +569,19 @@ Rectangle {
clip.position = clipInfo["position"];
clip.end = clipInfo["end"];
clip.begin = clipInfo["begin"];
+ clip.updateEffects( clipInfo );
}
onClipLinked: {
findClipItem( uuidA ).linkedClip = uuidB;
findClipItem( uuidB ).linkedClip = uuidA;
}
+
+ onEffectsUpdated: {
+ var item = findClipItem( clipUuid );
+ if ( item )
+ item.updateEffects( workflow.clipInfo( clipUuid ) );
+ }
}
Connections {
diff --git a/src/Workflow/MainWorkflow.cpp b/src/Workflow/MainWorkflow.cpp
index 6b3cfdf..c4dd45d 100644
--- a/src/Workflow/MainWorkflow.cpp
+++ b/src/Workflow/MainWorkflow.cpp
@@ -234,7 +234,7 @@ MainWorkflow::clipInfo( const QString& uuid )
if ( lClip != nullptr )
{
auto h = lClip->toVariant().toHash();
- h["length"] = lClip->length();
+ h["length"] = (qint64)( lClip->input()->length() );
h["name"] = lClip->media()->fileName();
h["audio"] = lClip->formats().testFlag( Clip::Audio );
h["video"] = lClip->formats().testFlag( Clip::Video );
@@ -252,7 +252,7 @@ MainWorkflow::clipInfo( const QString& uuid )
{
auto clip = it.value();
auto h = clip->toVariant().toHash();
- h["length"] = clip->length();
+ h["length"] = (qint64)( clip->input()->length() );
h["name"] = clip->media()->fileName();
h["audio"] = clip->formats().testFlag( Clip::Audio );
h["video"] = clip->formats().testFlag( Clip::Video );
@@ -354,6 +354,7 @@ MainWorkflow::addEffect( const QString &clipUuid, const QString &effectId )
if ( clip->uuid().toString() == clipUuid )
{
trigger( new Commands::Effect::Add( newEffect, clip->input() ) );
+ emit effectsUpdated( clipUuid );
return newEffect->uuid().toString();
}
diff --git a/src/Workflow/MainWorkflow.h b/src/Workflow/MainWorkflow.h
index 2553bc1..0b22ee4 100644
--- a/src/Workflow/MainWorkflow.h
+++ b/src/Workflow/MainWorkflow.h
@@ -269,6 +269,8 @@ class MainWorkflow : public QObject
void clipRemoved( const QString& uuid );
void clipMoved( const QString& uuid );
void clipLinked( const QString& uuidA, const QString& uuidB );
+
+ void effectsUpdated( const QString& clipUuid );
};
#endif // MAINWORKFLOW_H
More information about the Vlmc-devel
mailing list