Effect stack update: enable / disable several effects now triggers only one refresh

parent e482c50f
......@@ -1386,6 +1386,11 @@ void ClipItem::updateEffect(QDomElement effect)
}
}
void ClipItem::enableEffects(QList <int> indexes, bool disable)
{
m_effectList.enableEffects(indexes, disable);
}
bool ClipItem::moveEffect(QDomElement effect, int ix)
{
if (ix <= 0 || ix > (m_effectList.count()) || effect.isNull()) {
......
......@@ -100,6 +100,8 @@ public:
* @param ix The effect's index in effectlist
* @param effect The new effect */
void updateEffect(QDomElement effect);
/** @brief Enable / disable a list of effect from their indexes. */
void enableEffects(QList <int> indexes, bool disable);
bool moveEffect(QDomElement effect, int ix);
void flashClip();
void addTransition(Transition*);
......
......@@ -9,6 +9,7 @@ set(kdenlive_SRCS
commands/addtrackcommand.cpp
commands/addtransitioncommand.cpp
commands/changecliptypecommand.cpp
commands/changeeffectstatecommand.cpp
commands/changespeedcommand.cpp
commands/configtrackscommand.cpp
commands/editclipcommand.cpp
......
/***************************************************************************
* Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#include "changeeffectstatecommand.h"
#include "customtrackview.h"
#include <KLocale>
ChangeEffectStateCommand::ChangeEffectStateCommand(CustomTrackView *view, const int track, GenTime pos, QList <int> effectIndexes, bool disable, bool refreshEffectStack, bool doIt, QUndoCommand *parent) :
QUndoCommand(parent),
m_view(view),
m_track(track),
m_effectIndexes(effectIndexes),
m_pos(pos),
m_disable(disable),
m_doIt(doIt),
m_refreshEffectStack(refreshEffectStack)
{
if (disable)
setText(i18np("Disable effect", "Disable effects", effectIndexes.count()));
else
setText(i18np("Enable effect", "Enable effects", effectIndexes.count()));
}
// virtual
void ChangeEffectStateCommand::undo()
{
m_view->updateEffectState(m_track, m_pos, m_effectIndexes, !m_disable, true);
}
// virtual
void ChangeEffectStateCommand::redo()
{
if (m_doIt) m_view->updateEffectState(m_track, m_pos, m_effectIndexes, m_disable, m_refreshEffectStack);
m_doIt = true;
m_refreshEffectStack = true;
}
/***************************************************************************
* Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#ifndef CHANGEEFFECTSTATECOMMAND_H
#define CHANGEEFFECTSTATECOMMAND_H
#include <QUndoCommand>
#include <KDebug>
#include <gentime.h>
#include <QDomElement>
class CustomTrackView;
class ChangeEffectStateCommand : public QUndoCommand
{
public:
ChangeEffectStateCommand(CustomTrackView *view, const int track, GenTime pos, QList <int> effectIndexes, bool disable, bool refreshEffectStack, bool doIt, QUndoCommand *parent = 0);
virtual void undo();
virtual void redo();
private:
CustomTrackView *m_view;
const int m_track;
QList <int> m_effectIndexes;
const GenTime m_pos;
bool m_disable;
bool m_doIt;
bool m_refreshEffectStack;
};
#endif
......@@ -61,12 +61,12 @@ bool EditEffectCommand::mergeWith(const QUndoCommand * other)
// virtual
void EditEffectCommand::undo()
{
m_view->updateEffect(m_track, m_pos, m_oldeffect, m_stackPos, true);
m_view->updateEffect(m_track, m_pos, m_oldeffect, true);
}
// virtual
void EditEffectCommand::redo()
{
if (m_doIt) m_view->updateEffect(m_track, m_pos, m_effect, m_stackPos, m_refreshEffectStack);
if (m_doIt) m_view->updateEffect(m_track, m_pos, m_effect, m_refreshEffectStack);
m_doIt = true;
m_refreshEffectStack = true;
}
......
......@@ -48,6 +48,7 @@
#include "commands/insertspacecommand.h"
#include "spacerdialog.h"
#include "commands/addtrackcommand.h"
#include "commands/changeeffectstatecommand.h"
#include "commands/movegroupcommand.h"
#include "ui_addtrack_ui.h"
#include "initeffects.h"
......@@ -1290,7 +1291,7 @@ void CustomTrackView::mouseDoubleClickEvent(QMouseEvent *event)
EditEffectCommand *command = new EditEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), oldEffect, newEffect, item->selectedEffectIndex(), false, false);
//EditKeyFrameCommand *command = new EditKeyFrameCommand(this, m_dragItem->track(), m_dragItem->startPos(), item->selectedEffectIndex(), previous, next, false);
m_commandStack->push(command);
updateEffect(m_document->tracksCount() - item->track(), item->startPos(), item->selectedEffect(), item->selectedEffectIndex());
updateEffect(m_document->tracksCount() - item->track(), item->startPos(), item->selectedEffect());
emit clipItemSelected(item, item->selectedEffectIndex());
}
} else if (m_dragItem && !m_dragItem->isItemLocked()) {
......@@ -1927,12 +1928,13 @@ void CustomTrackView::slotDeleteEffect(ClipItem *clip, int track, QDomElement ef
setDocumentModified();
}
void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedEffect, int ix, bool updateEffectStack)
void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedEffect, bool updateEffectStack)
{
if (insertedEffect.isNull()) {
emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
return;
}
int ix = insertedEffect.attribute("kdenlive_ix").toInt();
QDomElement effect = insertedEffect.cloneNode().toElement();
//kDebug() << "// update effect ix: " << effect.attribute("kdenlive_ix")<<", GAIN: "<<EffectsList::parameter(effect, "gain");
if (pos < GenTime()) {
......@@ -2010,6 +2012,38 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE
setDocumentModified();
}
void CustomTrackView::updateEffectState(int track, GenTime pos, QList <int> effectIndexes, bool disable, bool updateEffectStack)
{
if (pos < GenTime()) {
// editing a track effect
if (!m_document->renderer()->mltEnableEffects(m_document->tracksCount() - track, pos, effectIndexes, disable)) {
emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
return;
}
m_document->enableTrackEffects(m_document->tracksCount() - track - 1, effectIndexes, disable);
emit updateTrackEffectState(track);
setDocumentModified();
return;
}
// editing a clip effect
ClipItem *clip = getClipItemAt((int)pos.frames(m_document->fps()), m_document->tracksCount() - track);
if (clip) {
bool success = m_document->renderer()->mltEnableEffects(m_document->tracksCount() - clip->track(), clip->startPos(), effectIndexes, disable);
if (success) {
clip->enableEffects(effectIndexes, disable);
if (updateEffectStack && clip->isSelected()) {
emit clipItemSelected(clip);
}
if (effectIndexes.contains(clip->selectedEffectIndex())) {
// make sure to update display of clip keyframes
clip->setSelectedEffect(clip->selectedEffectIndex());
}
}
else emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
}
else emit displayMessage(i18n("Cannot find clip to update effect"), ErrorMessage);
}
void CustomTrackView::moveEffect(int track, GenTime pos, QList <int> oldPos, QList <int> newPos)
{
if (pos < GenTime()) {
......@@ -2070,24 +2104,33 @@ void CustomTrackView::moveEffect(int track, GenTime pos, QList <int> oldPos, QLi
} else emit displayMessage(i18n("Cannot move effect"), ErrorMessage);
}
void CustomTrackView::slotChangeEffectState(ClipItem *clip, int track, int effectPos, bool disable)
void CustomTrackView::slotChangeEffectState(ClipItem *clip, int track, QList <int> effectIndexes, bool disable)
{
EditEffectCommand *command;
QDomElement effect;
if (clip == NULL) effect = m_document->getTrackEffect(track - 1, effectPos);
else effect = clip->effectAt(effectPos);
QDomElement oldEffect = effect.cloneNode().toElement();
effect.setAttribute("disable", (int) disable);
ChangeEffectStateCommand *command;
if (clip == NULL) {
// editing track effect
command = new EditEffectCommand(this, m_document->tracksCount() - track, GenTime(-1), oldEffect, effect, effectPos, false, true);
command = new ChangeEffectStateCommand(this, m_document->tracksCount() - track, GenTime(-1), effectIndexes, disable, false, true);
} else {
command = new EditEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), oldEffect, effect, effectPos, false, true);
// Check if we have a speed effect, disabling / enabling it needs a special procedure since it is a pseudoo effect
QList <int> speedEffectIndexes;
for (int i = 0; i < effectIndexes.count(); i++) {
QDomElement effect = clip->effectAt(effectIndexes.at(i));
if (effect.attribute("id") == "speed") {
// speed effect
speedEffectIndexes << effectIndexes.at(i);
QDomElement newEffect = effect.cloneNode().toElement();
newEffect.setAttribute("disable", (int) disable);
EditEffectCommand *editcommand = new EditEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), effect, newEffect, effectIndexes.at(i), false, true);
m_commandStack->push(editcommand);
}
}
for (int j = 0; j < speedEffectIndexes.count(); j++) {
effectIndexes.removeAll(speedEffectIndexes.at(j));
}
command = new ChangeEffectStateCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), effectIndexes, disable, false, true);
}
m_commandStack->push(command);
setDocumentModified();;
setDocumentModified();
}
void CustomTrackView::slotChangeEffectPosition(ClipItem *clip, int track, QList <int> currentPos, int newPos)
......@@ -3827,7 +3870,7 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event)
EditEffectCommand *command = new EditEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), oldEffect, newEffect, item->selectedEffectIndex(), false, false);
m_commandStack->push(command);
updateEffect(m_document->tracksCount() - item->track(), item->startPos(), item->selectedEffect(), item->selectedEffectIndex());
updateEffect(m_document->tracksCount() - item->track(), item->startPos(), item->selectedEffect());
emit clipItemSelected(item);
}
if (m_dragItem && m_dragItem->type() == TRANSITIONWIDGET && m_dragItem->isSelected()) {
......
......@@ -76,7 +76,9 @@ public:
void slotAddGroupEffect(QDomElement effect, AbstractGroupItem *group);
void addEffect(int track, GenTime pos, QDomElement effect);
void deleteEffect(int track, GenTime pos, QDomElement effect);
void updateEffect(int track, GenTime pos, QDomElement insertedEffect, int ix, bool refreshEffectStack = false);
void updateEffect(int track, GenTime pos, QDomElement insertedEffect, bool refreshEffectStack = false);
/** @brief Enable / disable a list of effects */
void updateEffectState(int track, GenTime pos, QList <int> effectIndexes, bool disable, bool updateEffectStack);
void moveEffect(int track, GenTime pos, QList <int> oldPos, QList <int> newPos);
void addTransition(ItemInfo transitionInfo, int endTrack, QDomElement params, bool refresh);
void deleteTransition(ItemInfo transitionInfo, int endTrack, QDomElement params, bool refresh);
......@@ -192,7 +194,7 @@ public slots:
void moveCursorPos(int delta);
void updateCursorPos();
void slotDeleteEffect(ClipItem *clip, int track, QDomElement effect, bool affectGroup = true);
void slotChangeEffectState(ClipItem *clip, int track, int effectPos, bool disable);
void slotChangeEffectState(ClipItem *clip, int track, QList <int> effectIndexes, bool disable);
void slotChangeEffectPosition(ClipItem *clip, int track, QList <int> currentPos, int newPos);
void slotUpdateClipEffect(ClipItem *clip, int track, QDomElement oldeffect, QDomElement effect, int ix, bool refreshEffectStack = true);
void slotUpdateClipRegion(ClipItem *clip, int ix, QString region);
......
......@@ -393,6 +393,16 @@ void EffectsList::updateIndexes(QDomNodeList effects, int startIndex)
}
}
void EffectsList::enableEffects(QList <int> indexes, bool disable)
{
QDomNodeList effects = m_baseElement.childNodes();
QDomElement effect;
for (int i = 0; i < indexes.count(); i++) {
effect = effectFromIndex(effects, indexes.at(i));
effect.setAttribute("disable", (int) disable);
}
}
QDomElement EffectsList::effectFromIndex(QDomNodeList effects, int ix)
{
if (ix <= 0 || ix > effects.count()) return QDomElement();
......
......@@ -92,6 +92,8 @@ public:
QDomElement effectFromIndex(QDomNodeList effects, int ix);
/** @brief Update all effects indexes to make sure they are 1, 2, 3, ... */
void updateIndexes(QDomNodeList effects, int startIndex);
/** @brief Enable / disable a list of effects */
void enableEffects(QList <int> indexes, bool disable);
private:
QDomElement m_baseElement;
......
......@@ -253,7 +253,7 @@ void CollapsibleEffect::mouseReleaseEvent( QMouseEvent *event )
QWidget::mouseReleaseEvent(event);
}
void CollapsibleEffect::slotEnable(bool disable, bool updateMainStatus)
void CollapsibleEffect::slotEnable(bool disable, bool emitInfo)
{
title->setEnabled(!disable);
enabledButton->blockSignals(true);
......@@ -264,7 +264,7 @@ void CollapsibleEffect::slotEnable(bool disable, bool updateMainStatus)
if (!disable || KdenliveSettings::disable_effect_parameters()) {
widgetFrame->setEnabled(!disable);
}
emit effectStateChanged(disable, effectIndex(), updateMainStatus);
if (emitInfo) emit effectStateChanged(disable, effectIndex());
}
void CollapsibleEffect::slotDeleteEffect()
......
......@@ -76,7 +76,7 @@ public:
public slots:
void slotSyncEffectsPos(int pos);
void slotEnable(bool enable, bool updateMainStatus = true);
void slotEnable(bool enable, bool emitInfo = true);
void slotResetEffect();
private slots:
......
......@@ -128,7 +128,7 @@ void CollapsibleGroup::mouseDoubleClickEvent ( QMouseEvent * event )
}
void CollapsibleGroup::slotEnable(bool disable)
void CollapsibleGroup::slotEnable(bool disable, bool emitInfo)
{
m_title->setEnabled(!disable);
enabledButton->blockSignals(true);
......@@ -136,7 +136,7 @@ void CollapsibleGroup::slotEnable(bool disable)
enabledButton->setIcon(disable ? KIcon("novisible") : KIcon("visible"));
enabledButton->blockSignals(false);
for (int i = 0; i < m_subWidgets.count(); i++)
m_subWidgets.at(i)->slotEnable(disable);
m_subWidgets.at(i)->slotEnable(disable, emitInfo);
}
void CollapsibleGroup::slotDeleteGroup()
......
......@@ -77,7 +77,7 @@ public:
void adjustEffects();
public slots:
void slotEnable(bool enable);
void slotEnable(bool enable, bool emitInfo = true);
private slots:
void slotSwitch();
......
......@@ -259,7 +259,7 @@ void EffectStackView2::connectEffect(CollapsibleEffect *currentEffect)
connect(currentEffect, SIGNAL(reloadEffects()), this , SIGNAL(reloadEffects()));
connect(currentEffect, SIGNAL(resetEffect(int)), this , SLOT(slotResetEffect(int)));
connect(currentEffect, SIGNAL(changeEffectPosition(QList <int>,bool)), this , SLOT(slotMoveEffectUp(QList <int>,bool)));
connect(currentEffect, SIGNAL(effectStateChanged(bool,int,bool)), this, SLOT(slotUpdateEffectState(bool,int,bool)));
connect(currentEffect, SIGNAL(effectStateChanged(bool,int)), this, SLOT(slotUpdateEffectState(bool,int)));
connect(currentEffect, SIGNAL(activateEffect(int)), this, SLOT(slotSetCurrentEffect(int)));
connect(currentEffect, SIGNAL(seekTimeline(int)), this , SLOT(slotSeekTimeline(int)));
connect(currentEffect, SIGNAL(createGroup(int)), this , SLOT(slotCreateGroup(int)));
......@@ -380,13 +380,13 @@ void EffectStackView2::startDrag()
}
void EffectStackView2::slotUpdateEffectState(bool disable, int index, bool updateMainStatus)
void EffectStackView2::slotUpdateEffectState(bool disable, int index)
{
if (m_effectMetaInfo.trackMode)
emit changeEffectState(NULL, m_trackindex, index, disable);
emit changeEffectState(NULL, m_trackindex, QList <int>() << index, disable);
else
emit changeEffectState(m_clipref, -1, index, disable);
if (updateMainStatus) slotUpdateCheckAllButton();
emit changeEffectState(m_clipref, -1, QList <int>() <<index, disable);
slotUpdateCheckAllButton();
}
......@@ -459,11 +459,22 @@ void EffectStackView2::slotCheckAll(int state)
}
bool disabled = state == Qt::Unchecked;
// Disable all effects
QList <int> indexes;
for (int i = 0; i < m_effects.count(); i++) {
if (!m_effects.at(i)->isGroup()) {
m_effects.at(i)->slotEnable(disabled, false);
}
m_effects.at(i)->slotEnable(disabled, false);
indexes << m_effects.at(i)->effectIndex();
}
// Take care of groups
QList<CollapsibleGroup *> allGroups = m_ui.container->widget()->findChildren<CollapsibleGroup *>();
for (int i = 0; i < allGroups.count(); i++) {
allGroups.at(i)->slotEnable(disabled, false);
}
if (m_effectMetaInfo.trackMode)
emit changeEffectState(NULL, m_trackindex, indexes, disabled);
else
emit changeEffectState(m_clipref, -1, indexes, disabled);
}
void EffectStackView2::slotUpdateCheckAllButton()
......
......@@ -162,7 +162,7 @@ private slots:
void slotRenderPos(int pos);
/** @brief Called whenever an effect is enabled / disabled by user. */
void slotUpdateEffectState(bool disable, int index, bool updateMainStatus);
void slotUpdateEffectState(bool disable, int index);
void slotSetCurrentEffect(int ix);
......@@ -212,7 +212,7 @@ signals:
all effects for this clip in the playlist */
void refreshEffectStack(ClipItem *);
/** Enable or disable an effect */
void changeEffectState(ClipItem*, int, int, bool);
void changeEffectState(ClipItem*, int, QList <int>, bool);
/** An effect in stack was moved */
void changeEffectPosition(ClipItem*, int, QList <int>, int);
/** an effect was saved, reload list */
......
......@@ -1532,6 +1532,20 @@ void KdenliveDoc::setTrackEffect(int trackIndex, int effectIndex, QDomElement ef
//m_tracksList[trackIndex].effectsList.updateEffect(effect);
}
void KdenliveDoc::enableTrackEffects(int trackIndex, QList <int> effectIndexes, bool disable)
{
if (trackIndex < 0 || trackIndex >= m_tracksList.count()) {
kWarning() << "Set Track effect outisde of range";
return;
}
EffectsList list = m_tracksList.at(trackIndex).effectsList;
QDomElement effect;
for (int i = 0; i < effectIndexes.count(); i++) {
effect = list.itemFromIndex(effectIndexes.at(i));
if (!effect.isNull()) effect.setAttribute("disable", (int) disable);
}
}
const EffectsList KdenliveDoc::getTrackEffects(int ix)
{
if (ix < 0 || ix >= m_tracksList.count()) {
......
......@@ -154,6 +154,8 @@ Q_OBJECT public:
void removeTrackEffect(int ix, QDomElement effect);
void setTrackEffect(int trackIndex, int effectIndex, QDomElement effect);
const EffectsList getTrackEffects(int ix);
/** @brief Enable / disable an effect in Kdenlive's xml list. */
void enableTrackEffects(int trackIndex, QList <int> effectIndexes, bool disable);
QDomElement getTrackEffect(int trackIndex, int effectIndex) const;
/** @brief Check if a track already contains a specific effect. */
int hasTrackEffect(int trackIndex, const QString &tag, const QString &id) const;
......
......@@ -2487,7 +2487,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //cha
disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int,bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int,bool)));
disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
disconnect(m_effectStack, SIGNAL(addEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotAddEffect(ClipItem*, QDomElement)));
disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, QList <int>, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, QList <int>, bool)));
disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, QList<int>, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, QList <int>, int)));
disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
......@@ -2563,7 +2563,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //cha
connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
connect(m_effectStack, SIGNAL(addEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotAddEffect(ClipItem*, QDomElement)));
connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, QList <int>, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, QList <int>, bool)));
connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, QList <int>, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, QList <int>, int)));
connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
......
......@@ -2768,7 +2768,6 @@ bool Render::mltEditTrackEffect(int track, EffectsParameterList params)
refresh();
return true;
}
bool Render::mltEditEffect(int track, GenTime position, EffectsParameterList params)
......@@ -2875,6 +2874,71 @@ bool Render::mltEditEffect(int track, GenTime position, EffectsParameterList par
return true;
}
bool Render::mltEnableEffects(int track, GenTime position, QList <int> effectIndexes, bool disable)
{
if (position < GenTime()) {
return mltEnableTrackEffects(track, effectIndexes, disable);
}
// find filter
Mlt::Service service(m_mltProducer->parent().get_service());
Mlt::Tractor tractor(service);
Mlt::Producer trackProducer(tractor.track(track));
Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
int clipIndex = trackPlaylist.get_clip_index_at((int) position.frames(m_fps));
Mlt::Producer *clip = trackPlaylist.get_clip(clipIndex);
if (!clip) {
kDebug() << "WARINIG, CANNOT FIND CLIP ON track: " << track << ", AT POS: " << position.frames(m_fps);
return false;
}
int duration = clip->get_playtime();
bool doRefresh = true;
// Check if clip is visible in monitor
int diff = trackPlaylist.clip_start(clipIndex) + duration - m_mltProducer->position();
if (diff < 0 || diff > duration)
doRefresh = false;
int ct = 0;
Mlt::Filter *filter = clip->filter(ct);
while (filter) {
if (effectIndexes.contains(filter->get_int("kdenlive_ix"))) {
filter->set("disable", (int) disable);
}
ct++;
filter = clip->filter(ct);
}
delete clip;
service.unlock();
if (doRefresh) refresh();
return true;
}
bool Render::mltEnableTrackEffects(int track, QList <int> effectIndexes, bool disable)
{
Mlt::Service service(m_mltProducer->parent().get_service());
Mlt::Tractor tractor(service);
Mlt::Producer trackProducer(tractor.track(track));
Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
Mlt::Service clipService(trackPlaylist.get_service());
int ct = 0;
Mlt::Filter *filter = clipService.filter(ct);
while (filter) {
if (effectIndexes.contains(filter->get_int("kdenlive_ix"))) {
filter->set("disable", (int) disable);
}
ct++;
filter = clipService.filter(ct);
}
service.unlock();
refresh();
return true;
}