[vlmc-devel] Timeline: Implement adding/showing effects
Yikai Lu
git at videolan.org
Thu Jul 28 14:39:22 CEST 2016
vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Thu Jul 28 18:02:17 2016 +0900| [0c34c9be5a8104672593c8dc7f3df0c3f2035330] | committer: Yikai Lu
Timeline: Implement adding/showing effects
> https://code.videolan.org/videolan/vlmc/commit/0c34c9be5a8104672593c8dc7f3df0c3f2035330
---
src/Gui/timeline/Clip.qml | 16 ++++++++++++++++
src/Gui/timeline/ClipContextMenu.qml | 10 ++++++++++
src/Gui/timeline/Timeline.cpp | 17 +++++++++++++++++
src/Gui/timeline/Timeline.h | 18 ++++--------------
src/Gui/timeline/Track.qml | 29 +++++++++++++++++++++++------
src/Workflow/MainWorkflow.cpp | 10 ++++++++++
src/Workflow/MainWorkflow.h | 2 ++
7 files changed, 82 insertions(+), 20 deletions(-)
diff --git a/src/Gui/timeline/Clip.qml b/src/Gui/timeline/Clip.qml
index 34b5d5c..d3994c0 100644
--- a/src/Gui/timeline/Clip.qml
+++ b/src/Gui/timeline/Clip.qml
@@ -287,6 +287,16 @@ Rectangle {
]
}
+ DropArea {
+ id: effectDropArea
+ anchors.fill: parent
+ keys: ["vlmc/effect_name"]
+
+ onDropped: {
+ workflow.addEffect( uuid, drop.getDataAsString( "vlmc/effect_name" ) );
+ }
+ }
+
ClipContextMenu {
id: clipContextMenu
clip: clip
@@ -294,6 +304,12 @@ Rectangle {
states: [
State {
+ name: "EffectDrop"
+ when: effectDropArea.containsDrag
+ PropertyChanges { target: gStop1; color: "#427080" }
+ PropertyChanges { target: gStop2; color: "#225060" }
+ },
+ State {
name: "Selected"
when: selected
PropertyChanges { target: gStop1; color: "#6498c8" }
diff --git a/src/Gui/timeline/ClipContextMenu.qml b/src/Gui/timeline/ClipContextMenu.qml
index 35a5aff..2473773 100644
--- a/src/Gui/timeline/ClipContextMenu.qml
+++ b/src/Gui/timeline/ClipContextMenu.qml
@@ -61,4 +61,14 @@ Menu {
onAboutToShow: {
grouped = findGroup( clip.uuid );
}
+
+ MenuSeparator { }
+
+ MenuItem {
+ text: "Effects"
+
+ onTriggered: {
+ timeline.showEffectStack( clip.uuid );
+ }
+ }
}
diff --git a/src/Gui/timeline/Timeline.cpp b/src/Gui/timeline/Timeline.cpp
index 1e34fef..55d1c69 100644
--- a/src/Gui/timeline/Timeline.cpp
+++ b/src/Gui/timeline/Timeline.cpp
@@ -23,8 +23,10 @@
#include "Timeline.h"
#include "Main/Core.h"
+#include "Workflow/TrackWorkflow.h"
#include "Workflow/MainWorkflow.h"
#include "Gui/MainWindow.h"
+#include "Gui/effectsengine/EffectStack.h"
#include <QtQuick/QQuickView>
#include <QtQml/QQmlContext>
#include <QUrl>
@@ -36,6 +38,7 @@ Timeline::Timeline( MainWindow* parent )
{
m_container->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
m_container->setFocusPolicy( Qt::TabFocus );
+ m_view->rootContext()->setContextProperty( "timeline", this );
m_view->rootContext()->setContextProperty( "mainwindow", parent );
m_view->rootContext()->setContextProperty( "workflow", Core::instance()->workflow() );
m_view->setSource( QUrl( QStringLiteral( "qrc:/QML/main.qml" ) ) );
@@ -51,3 +54,17 @@ Timeline::container()
{
return m_container;
}
+
+void
+Timeline::showEffectStack( quint32 trackId )
+{
+ auto w = new EffectStack( Core::instance()->workflow()->track( trackId )->input() );
+ w->show();
+}
+
+void
+Timeline::showEffectStack( const QString& uuid )
+{
+ auto w = new EffectStack( Core::instance()->workflow()->clip( uuid )->input() );
+ w->show();
+}
diff --git a/src/Gui/timeline/Timeline.h b/src/Gui/timeline/Timeline.h
index d884fe1..d96d949 100644
--- a/src/Gui/timeline/Timeline.h
+++ b/src/Gui/timeline/Timeline.h
@@ -45,20 +45,10 @@ public:
QWidget* container();
public slots:
- /**
- * \brief Asks the workflow to clear itself.
- */
- void clear() {}
- /**
- * \brief Change the zoom level for all widgets of the timeline.
- * \param factor The zoom factor.
- */
- void changeZoom( int factor ) { Q_UNUSED( factor ) }
- /**
- * \brief Change the duration of the project.
- * \param duration Duration in frames.
- */
- void setDuration( int duration ) { Q_UNUSED( duration ) }
+
+ void showEffectStack( quint32 trackId );
+ void showEffectStack( const QString& uuid );
+
/**
* \brief Change the currently selected tool.
*/
diff --git a/src/Gui/timeline/Track.qml b/src/Gui/timeline/Track.qml
index 56a038e..9462341 100644
--- a/src/Gui/timeline/Track.qml
+++ b/src/Gui/timeline/Track.qml
@@ -387,12 +387,29 @@ Item {
color: "#111111"
}
- Text {
- text: type + " " + ( trackId + 1 )
- anchors.right: parent.right
- anchors.rightMargin: 10
- color: "white"
- font.pointSize: trackHeight / 3
+ Row {
+ spacing: 4
+ anchors.centerIn: parent
+
+ Text {
+ id: trackText
+ text: type + " " + ( trackId + 1 )
+ color: "white"
+ font.pointSize: trackHeight / 3
+ }
+
+ PropertyButton {
+ id: fxButton
+ text: "Fx"
+ selected: true
+
+ onSelectedChanged: {
+ if ( selected === false ) {
+ timeline.showEffectStack( trackId );
+ selected = true;
+ }
+ }
+ }
}
}
}
diff --git a/src/Workflow/MainWorkflow.cpp b/src/Workflow/MainWorkflow.cpp
index 88f5a84..0b32c45 100644
--- a/src/Workflow/MainWorkflow.cpp
+++ b/src/Workflow/MainWorkflow.cpp
@@ -168,6 +168,16 @@ MainWorkflow::trackCount() const
}
std::shared_ptr<Clip>
+MainWorkflow::clip( const QUuid& uuid )
+{
+ for ( auto it = m_clips.begin(); it != m_clips.end(); ++it )
+ if ( it.value()->uuid() == uuid )
+ return it.value();
+
+ return std::shared_ptr<Clip>( nullptr );
+}
+
+std::shared_ptr<Clip>
MainWorkflow::createClip( const QUuid& uuid, quint32 trackId )
{
Clip* clip = Core::instance()->library()->clip( uuid );
diff --git a/src/Workflow/MainWorkflow.h b/src/Workflow/MainWorkflow.h
index 8bc5169..8a3956b 100644
--- a/src/Workflow/MainWorkflow.h
+++ b/src/Workflow/MainWorkflow.h
@@ -132,6 +132,8 @@ class MainWorkflow : public QObject
*/
quint32 trackCount() const;
+ std::shared_ptr<Clip> clip( const QUuid& uuid );
+
/**
* \brief Create a clip from a parent clip's uuid.
*
More information about the Vlmc-devel
mailing list