Commit 9f20927a authored by luyikei's avatar luyikei

Timeline: Show effects on clips

parent 90bf6acc
......@@ -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
......
......@@ -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
......
......@@ -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();
}
......@@ -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 {
......
......@@ -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();
}
......
......@@ -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
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