]> git.sesse.net Git - kdenlive/commitdiff
Effect stack update: enable / disable several effects now triggers only one refresh
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 18 Apr 2012 14:43:26 +0000 (16:43 +0200)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 18 Apr 2012 14:43:26 +0000 (16:43 +0200)
21 files changed:
src/clipitem.cpp
src/clipitem.h
src/commands/CMakeLists.txt
src/commands/changeeffectstatecommand.cpp [new file with mode: 0644]
src/commands/changeeffectstatecommand.h [new file with mode: 0644]
src/commands/editeffectcommand.cpp
src/customtrackview.cpp
src/customtrackview.h
src/effectslist.cpp
src/effectslist.h
src/effectstack/collapsibleeffect.cpp
src/effectstack/collapsibleeffect.h
src/effectstack/collapsiblegroup.cpp
src/effectstack/collapsiblegroup.h
src/effectstack/effectstackview2.cpp
src/effectstack/effectstackview2.h
src/kdenlivedoc.cpp
src/kdenlivedoc.h
src/mainwindow.cpp
src/renderer.cpp
src/renderer.h

index d6be7a43ec0892520f2aeecfa9ad029058d6e0ac..bf0013083c759fcbbd2f2c27e496bc939b70f750 100644 (file)
@@ -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()) {
index 978585c64f244362294066c8d8b4fe5b10f2a307..1bd69100cb79dec917432e9926d24b7a2fbbad10 100644 (file)
@@ -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*);
index e6cf61eb256c664219f53d304b9c282ffeb54404..1420bd444d3a8d9157a06fd4de99e08027566962 100644 (file)
@@ -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
diff --git a/src/commands/changeeffectstatecommand.cpp b/src/commands/changeeffectstatecommand.cpp
new file mode 100644 (file)
index 0000000..ecc455c
--- /dev/null
@@ -0,0 +1,55 @@
+/***************************************************************************
+ *   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;
+}
+
+
diff --git a/src/commands/changeeffectstatecommand.h b/src/commands/changeeffectstatecommand.h
new file mode 100644 (file)
index 0000000..563ef52
--- /dev/null
@@ -0,0 +1,50 @@
+/***************************************************************************
+ *   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
+
index 73ca47f220783acbe090d454dc053532d6c1664c..6ecc75b41d585233bab41b2e5d57c0fb61ca51ab 100644 (file)
@@ -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;
 }
index fa4a471a8f4fcdee1c9442f72363f60b65300f6a..ca8fae457e9aeddc3f15257c8b0fac2e316c14ee 100644 (file)
@@ -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()) {
index a5071e90f0f9c026f723dea8f3e27cb8c251e8a8..d3f04980a8c24f292d8876410f3aa07863230c98 100644 (file)
@@ -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);
index cff4941893ff030fabb476c4d5e01b14afe5ed0c..d6777eb73503e0602e928c7e8aa05569db80dcb6 100644 (file)
@@ -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();
index b0abdc1b27705d17c95142e17299d0a42f673a30..cbb58d6be5867cfed9b13fa61149467030dc4b4b 100644 (file)
@@ -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;
index 85b36c4aca8f97fc1586a3e32d4fad9892ca4016..a28baa7de078de85f85e1e5f669750b89e73e971 100644 (file)
@@ -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()
index 0572f7e15d3eaf78e4040e42fd570a85668fd4b5..d94fa3a1f7ce38cded4e930d0b293825abb9fa61 100644 (file)
@@ -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:
index aaf35b18bed7d1733b9dd165bb7fd16825ab65a3..bae783c5263279e7d3a14ac8a5bf13ec0fc03623 100644 (file)
@@ -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()
index ed54c246f5879926f58dc3aa3eb1c1bb3b42e3d1..8f3047da838bf5ad0eeb2f101ec28931f15c60a2 100644 (file)
@@ -77,7 +77,7 @@ public:
     void adjustEffects();
 
 public slots:
-    void slotEnable(bool enable);
+    void slotEnable(bool enable, bool emitInfo = true);
 
 private slots:
     void slotSwitch();
index 414f6f51f532f0957f4cbe1f0bc1f097bf3198e0..014ad293c37ed14d82609409734317b303e89e4a 100644 (file)
@@ -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()
index 623f13442b39e179bf398333767453cfee472f12..266ea5403b17ec9f2946d5ce28c6ad91986f14fe 100644 (file)
@@ -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 */
index d52d8fa7c6ce616f0ed5073812d78a8150dc5870..f431a26f2cb19d7e672fb9f58d309164cd7d07cb 100644 (file)
@@ -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()) {
index d9bacf130e5eacb8552e69583b11e3bfb0265871..cc74e5d34078058d4ba7fdc6168af01febc21c4f 100644 (file)
@@ -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;
index 9f4335682e9f4683b9c0bf15def84c3c79cc3051..94b8b594eee63307d1212ef7708c3349449fa8ab 100644 (file)
@@ -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)));
index a0b2c61073bff31abc62a4098b9eb47fc08add6f..9f8dc19815eb3a5a9470530f397cfc4cb71b90b3 100644 (file)
@@ -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;
+}
+
 void Render::mltUpdateEffectPosition(int track, GenTime position, int oldPos, int newPos)
 {
     Mlt::Service service(m_mltProducer->parent().get_service());
index cd81010e50bd46b3025af7e8bfdcc91b8bdf15f8..87edd1925613153663ba005f7a0eb4dc41ee7ec5 100644 (file)
@@ -229,6 +229,18 @@ Q_OBJECT public:
     bool addFilterToService(Mlt::Service service, EffectsParameterList params, int duration);
     bool mltAddEffect(Mlt::Service service, EffectsParameterList params, int duration, bool doRefresh);
     bool mltAddTrackEffect(int track, EffectsParameterList params);
+    
+    /** @brief Enable / disable clip effects. 
+     * @param track The track where the clip is
+     * @param position The start position of the clip
+     * @param effectIndexes The list of effect indexes to enable / disable
+     * @param disable True if effects should be disabled, false otherwise */
+    bool mltEnableEffects(int track, GenTime position, QList <int> effectIndexes, bool disable);
+    /** @brief Enable / disable track effects.
+     * @param track The track where the effect is
+     * @param effectIndexes The list of effect indexes to enable / disable
+     * @param disable True if effects should be disabled, false otherwise */
+    bool mltEnableTrackEffects(int track, QList <int> effectIndexes, bool disable);
 
     /** @brief Edits an effect parameters in MLT's playlist. */
     bool mltEditEffect(int track, GenTime position, EffectsParameterList params);