Commit 3addf6e3 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Display keyframes on compositions

parent df72d7c3
......@@ -84,6 +84,7 @@ AssetPanel::AssetPanel(QWidget *parent)
m_effectStackWidget->setVisible(false);
updatePalette();
connect(m_effectStackWidget, &EffectStackView::seekToPos, this, &AssetPanel::seekToPos);
connect(m_transitionWidget, &TransitionStackView::seekToTransPos, this, &AssetPanel::seekToPos);
}
void AssetPanel::showTransition(int tid, std::shared_ptr<AssetParameterModel> transitionModel)
......@@ -94,6 +95,7 @@ void AssetPanel::showTransition(int tid, std::shared_ptr<AssetParameterModel> tr
QString transitionName = TransitionsRepository::get()->getName(transitionId);
m_assetTitle->setText(i18n("Properties of transition %1", transitionName));
m_transitionWidget->setVisible(true);
m_timelineButton->setVisible(true);
m_transitionWidget->setModel(transitionModel, QPair<int, int>(-1, -1), QSize(), true);
}
......@@ -258,7 +260,11 @@ void AssetPanel::processSplitEffect(bool enable)
void AssetPanel::showKeyframes(bool enable)
{
pCore->showClipKeyframes(m_effectStackWidget->stackOwner(), enable);
if (m_transitionWidget->isVisible()) {
pCore->showClipKeyframes(m_transitionWidget->stackOwner(), enable);
} else {
pCore->showClipKeyframes(m_effectStackWidget->stackOwner(), enable);
}
}
ObjectId AssetPanel::effectStackOwner()
......
......@@ -544,6 +544,8 @@ void Core::showClipKeyframes(ObjectId id, bool enable)
{
if (id.first == ObjectType::TimelineClip) {
m_mainWindow->getCurrentTimeline()->controller()->showClipKeyframes(id.second, enable);
} else if (id.first == ObjectType::TimelineComposition) {
m_mainWindow->getCurrentTimeline()->controller()->showCompositionKeyframes(id.second, enable);
}
}
......@@ -22,6 +22,7 @@
#include "timelinemodel.hpp"
#include "trackmodel.hpp"
#include "transitions/transitionsrepository.hpp"
#include "assets/keyframes/model/keyframemodellist.hpp"
#include "undohelper.hpp"
#include <QDebug>
#include <mlt++/MltTransition.h>
......@@ -141,3 +142,23 @@ void CompositionModel::setATrack(int trackId)
service()->set("a_track", trackId);
}
}
KeyframeModel *CompositionModel::getEffectKeyframeModel()
{
if (getKeyframeModel()) {
return getKeyframeModel()->getKeyModel();
}
return nullptr;
}
bool CompositionModel::showKeyframes() const
{
READ_LOCK();
return service()->get_int("kdenlive:timeline_display");
}
void CompositionModel::setShowKeyframes(bool show)
{
QWriteLocker locker(&m_lock);
service()->set("kdenlive:timeline_display", (int) show);
}
......@@ -33,6 +33,7 @@ class Transition;
}
class TimelineModel;
class TrackModel;
class KeyframeModel;
/* @brief This class represents a Composition object, as viewed by the backend.
In general, the Gui associated with it will send modification queries (such as resize or move), and this class authorize them or not depending on the
......@@ -75,6 +76,12 @@ public:
*/
const QString getProperty(const QString &name) const override;
/* @brief returns the active effect's keyframe model
*/
KeyframeModel *getEffectKeyframeModel();
Q_INVOKABLE bool showKeyframes() const;
Q_INVOKABLE void setShowKeyframes(bool show);
protected:
Mlt::Transition *service() const override;
......
......@@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "timelinefunctions.hpp"
#include "clipmodel.hpp"
#include "compositionmodel.hpp"
#include "core.h"
#include "effects/effectstack/model/effectstackmodel.hpp"
#include "groupsmodel.hpp"
......@@ -296,3 +297,12 @@ void TimelineFunctions::showClipKeyframes(std::shared_ptr<TimelineItemModel> tim
QModelIndex modelIndex = timeline->makeClipIndexFromID(clipId);
timeline->dataChanged(modelIndex, modelIndex, {TimelineModel::KeyframesRole});
}
void TimelineFunctions::showCompositionKeyframes(std::shared_ptr<TimelineItemModel> timeline, int compoId, bool value)
{
timeline->m_allCompositions[compoId]->setShowKeyframes(value);
QModelIndex modelIndex = timeline->makeCompositionIndexFromID(compoId);
timeline->dataChanged(modelIndex, modelIndex, {TimelineModel::KeyframesRole});
}
......@@ -58,6 +58,7 @@ struct TimelineFunctions {
static bool requestClipCopy(std::shared_ptr<TimelineItemModel> timeline, int clipId, int trackId, int position);
static void showClipKeyframes(std::shared_ptr<TimelineItemModel> timeline, int clipId, bool value);
static void showCompositionKeyframes(std::shared_ptr<TimelineItemModel> timeline, int compoId, bool value);
};
#endif
......@@ -330,6 +330,11 @@ QVariant TimelineItemModel::data(const QModelIndex &index, int role) const
return 100;
case BinIdRole:
return 5;
case KeyframesRole: {
return QVariant::fromValue<KeyframeModel *>(compo->getEffectKeyframeModel());
}
case ShowKeyframesRole:
return compo->showKeyframes();
case ItemATrack:
return compo->getATrack();
case MarkersRole: {
......
......@@ -72,7 +72,7 @@ Rectangle {
onKeyframeModelChanged: {
console.log('keyframe model changed............')
keyframecanvas.requestPaint()
effectRow.keyframecanvas.requestPaint()
}
onClipDurationChanged: {
......
......@@ -40,6 +40,8 @@ Item {
property int clipDuration: 0
property bool isAudio: false
property bool isComposition: true
property bool showKeyframes: false
property var keyframeModel
property bool grouped: false
property int binId: 0
property int scrollX: 0
......@@ -68,6 +70,11 @@ Item {
signal trimmingOut(var clip, real newDuration, var mouse)
signal trimmedOut(var clip)
onKeyframeModelChanged: {
console.log('keyframe model changed............')
effectRow.keyframecanvas.requestPaint()
}
onModelStartChanged: {
x = modelStart * timeScale;
}
......@@ -129,6 +136,10 @@ Item {
color: 'black'
}
}
KeyframeView {
id: effectRow
visible: compositionRoot.showKeyframes
}
}
Drag.active: mouseArea.drag.active
Drag.proposedAction: Qt.MoveAction
......
......@@ -112,13 +112,13 @@ Column{
target: loader.item
property: "showKeyframes"
value: model.showKeyframes
when: loader.status == Loader.Ready && !loader.item.isComposition
when: loader.status == Loader.Ready
}
Binding {
target: loader.item
property: "keyframeModel"
value: model.keyframeModel
when: loader.status == Loader.Ready && !loader.item.isComposition
when: loader.status == Loader.Ready
}
Binding {
target: loader.item
......
......@@ -1133,3 +1133,8 @@ void TimelineController::showClipKeyframes(int clipId, bool value)
{
TimelineFunctions::showClipKeyframes(m_model, clipId, value);
}
void TimelineController::showCompositionKeyframes(int clipId, bool value)
{
TimelineFunctions::showCompositionKeyframes(m_model, clipId, value);
}
......@@ -297,6 +297,7 @@ public:
bool insertZone(const QString &binId, QPoint zone, bool overwrite);
void updateClip(int clipId, QVector <int> roles);
void showClipKeyframes(int clipId, bool value);
void showCompositionKeyframes(int clipId, bool value);
public slots:
void selectMultitrack();
......
......@@ -55,6 +55,11 @@ void TransitionStackView::setModel(const std::shared_ptr<AssetParameterModel> &m
lay->addWidget(m_trackBox);
m_lay->insertLayout(0, lay);
connect(m_trackBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTrack(int)));
connect(this, &AssetParameterView::seekToPos, [this](int pos){
// at this point, the effects returns a pos relative to the clip. We need to convert it to a global time
int clipIn = pCore->getItemIn(m_model->getOwnerId());
emit seekToTransPos(pos + clipIn);
});
}
void TransitionStackView::updateTrack(int newTrack)
......@@ -62,3 +67,11 @@ void TransitionStackView::updateTrack(int newTrack)
qDebug()<<"// Update transitiino TRACK to: "<<m_trackBox->currentData().toInt();
pCore->setCompositionATrack(m_model->getOwnerId().second, m_trackBox->currentData().toInt());
}
ObjectId TransitionStackView::stackOwner() const
{
if (m_model) {
return m_model->getOwnerId();
}
return ObjectId(ObjectType::NoItem, -1);
}
......@@ -23,6 +23,7 @@
#define TRANSITIONSTACKVIEW_H
#include "assets/view/assetparameterview.hpp"
#include "definitions.h"
class QComboBox;
......@@ -33,10 +34,14 @@ class TransitionStackView : public AssetParameterView
public:
TransitionStackView(QWidget *parent = nullptr);
void setModel(const std::shared_ptr<AssetParameterModel> &model, QPair<int, int> range, QSize frameSize, bool addSpacer = false);
ObjectId stackOwner() const;
private slots:
void updateTrack(int newTrack);
signals:
void seekToTransPos(int pos);
private:
QComboBox *m_trackBox;
};
......
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