--- /dev/null
+/***************************************************************************
+ * 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 <KLocale>
+
+#include "addeffectcommand.h"
+
+AddEffectCommand::AddEffectCommand(CustomTrackView *view, const int track, GenTime pos, const QString &tag, QMap <QString, QString> args, bool doIt)
+ : m_view(view), m_track(track), m_pos(pos), m_tag(tag), m_args(args), m_doIt(doIt) {
+ if (doIt) setText(i18n("Add effect"));
+ else setText(i18n("Delete effect"));
+ }
+
+
+// virtual
+void AddEffectCommand::undo()
+{
+kDebug()<<"---- undoing action";
+ if (m_doIt) m_view->deleteEffect(m_track, m_pos, m_tag);
+ else m_view->addEffect(m_track, m_pos, m_tag, m_args);
+}
+// virtual
+void AddEffectCommand::redo()
+{
+kDebug()<<"---- redoing action";
+ if (m_doIt) m_view->addEffect(m_track, m_pos, m_tag, m_args);
+ else m_view->deleteEffect(m_track, m_pos, m_tag);
+}
+
+#include "addeffectcommand.moc"
--- /dev/null
+/***************************************************************************
+ * 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 ADDEFFECTCOMMAND_H
+#define ADDEFFECTCOMMAND_H
+
+#include <QUndoCommand>
+#include <KDebug>
+
+#include "customtrackview.h"
+
+class AddEffectCommand : public QUndoCommand
+ {
+ public:
+ AddEffectCommand(CustomTrackView *view, const int track, GenTime pos, const QString &tag, QMap <QString, QString> args, bool doIt);
+
+ virtual void undo();
+ virtual void redo();
+
+ private:
+ CustomTrackView *m_view;
+ int m_track;
+ QString m_tag;
+ GenTime m_pos;
+ QMap <QString, QString> m_args;
+ bool m_doIt;
+ };
+
+#endif
+
#include "moveclipcommand.h"
#include "resizeclipcommand.h"
#include "addtimelineclipcommand.h"
+#include "addeffectcommand.h"
CustomTrackView::CustomTrackView(KdenliveDoc *doc, QGraphicsScene * projectscene, QWidget *parent)
: QGraphicsView(projectscene, parent), m_tracksCount(0), m_cursorPos(0), m_dropItem(NULL), m_cursorLine(NULL), m_operationMode(NONE), m_startPos(QPointF()), m_dragItem(NULL), m_visualTip(NULL), m_moveOpMode(NONE), m_animation(NULL), m_projectDuration(0), m_scale(1.0), m_clickPoint(0), m_document(doc)
}
updateSnapPoints(m_dragItem);
//kDebug()<<pos;
- //QGraphicsView::mousePressEvent(event);
+ QGraphicsView::mousePressEvent(event);
}
void CustomTrackView::dragEnterEvent ( QDragEnterEvent * event )
}
}
+void CustomTrackView::addEffect(int track, GenTime pos, QString tag, QMap <QString, QString> args)
+{
+ m_document->renderer()->mltAddEffect(track, pos, tag, args);
+}
+
+void CustomTrackView::deleteEffect(int track, GenTime pos, QString tag)
+{
+ m_document->renderer()->mltRemoveEffect(track, pos, tag, -1);
+}
+
+void CustomTrackView::slotAddEffect(QMap <QString, QString> filter)
+{
+ QList<QGraphicsItem *> itemList = items();
+ for (int i = 0; i < itemList.count(); i++) {
+ if (itemList.at(i)->type() == 70000 && itemList.at(i)->isSelected()) {
+ ClipItem *item = (ClipItem *)itemList.at(i);
+ QString tag = filter.value("mlt_service");
+ AddEffectCommand *command = new AddEffectCommand(this, m_tracksCount - item->track(),GenTime(item->startPos(), 25), tag, filter, true);
+ m_commandStack->push(command);
+ }
+ }
+}
+
void CustomTrackView::addItem(DocClipBase *clip, QPoint pos)
{
int in =0;
void setDuration(int duration);
void setScale(double scaleFactor);
void deleteClip(int clipId);
+ void slotAddEffect(QMap <QString, QString> filter);
+ void addEffect(int track, GenTime pos, QString tag, QMap <QString, QString> args);
+ void deleteEffect(int track, GenTime pos, QString tag);
public slots:
void setCursorPos(int pos, bool seek = true);
{
}
+QMap <QString, QString> EffectsList::effect(const QString & name)
+{
+ QMap <QString, QString> filter;
+ QString effectName;
+ QDomElement effect;
+ for (int i = 0; i < this->size(); ++i) {
+ effect = this->at(i);
+ QDomNode namenode = effect.elementsByTagName("name").item(0);
+ if (!namenode.isNull()) {
+ effectName = i18n(qstrdup(namenode.toElement().text().toUtf8()));
+ if (name == effectName) break;
+ }
+ }
+ filter.insert("mlt_service", effect.attribute("tag"));
+ filter.insert("name", name);
+ return filter;
+}
+
QDomElement EffectsList::getEffectByName(const QString & name)
{
QString effectName;
QDomElement getEffectByName(const QString & name);
QStringList effectNames();
QString getInfo(QString effectName);
-
+ QMap <QString, QString> effect(const QString & name);
};
#endif
connect(ui.type_combo, SIGNAL(currentIndexChanged(int)), this, SLOT(initList(int)));
connect(ui.button_info, SIGNAL(stateChanged(int)), this, SLOT(showInfoPanel(int)));
connect(ui.effectlist, SIGNAL(itemSelectionChanged()), this, SLOT(slotUpdateInfo()));
+ connect(ui.effectlist, SIGNAL(doubleClicked(QListWidgetItem *,const QPoint &)), this, SLOT(slotEffectSelected()));
+
+
}
void EffectsListView::initList(int pos)
else ui.infopanel->show();
}
+void EffectsListView::slotEffectSelected()
+{
+ emit addEffect(ui.type_combo->currentIndex(), ui.effectlist->currentItem()->text());
+}
+
void EffectsListView::slotUpdateInfo()
{
QString info;
void initList(int pos);
void slotUpdateInfo();
void showInfoPanel(int state);
+ void slotEffectSelected();
public slots:
+
+ signals:
+ void addEffect(int, QString);
};
m_isBlocked = false;
}
-void Render::mltRemoveEffect(int track, GenTime position, QString id, QString tag, int index)
+void Render::mltRemoveEffect(int track, GenTime position, QString tag, int index)
{
Mlt::Service service(m_mltProducer->parent().get_service());
int ct = 0;
Mlt::Filter *filter = clipService.filter( ct );
while (filter) {
- if (filter->get("mlt_service") == tag && filter->get("kdenlive_id") == id) {
+ if (filter->get("mlt_service") == tag) {// && filter->get("kdenlive_id") == id) {
clipService.detach(*filter);
kDebug()<<" / / / DLEETED EFFECT: "<<ct;
}
}
else {
Mlt::Filter *filter = clipService.filter( index );
- if (filter && filter->get("mlt_service") == tag && filter->get("kdenlive_id") == id) clipService.detach(*filter);
+ if (filter && filter->get("mlt_service") == tag /*&& filter->get("kdenlive_id") == id*/) clipService.detach(*filter);
else {
- kDebug()<<"WARINIG, FILTER "<<id<<" NOT FOUND!!!!!";
+ kDebug()<<"WARINIG, FILTER "<<tag<<" NOT FOUND!!!!!";
}
}
m_isBlocked = false;
}
-void Render::mltAddEffect(int track, GenTime position, QString id, QString tag, QMap <QString, QString> args)
+void Render::mltAddEffect(int track, GenTime position, QString tag, QMap <QString, QString> args)
{
Mlt::Service service(m_mltProducer->parent().get_service());
Mlt::Tractor tractor(service);
Mlt::Service clipService(clip->get_service());
m_isBlocked = true;
// create filter
- kDebug()<<" / / INSERTING EFFECT: "<<id;
+ //kDebug()<<" / / INSERTING EFFECT: "<<id;
if (tag.startsWith("ladspa")) tag = "ladspa";
char *filterId = decodedString(tag);
Mlt::Filter *filter = new Mlt::Filter(*m_mltProfile, filterId);
QMap<QString, QString>::Iterator it = args.begin();
if (it.key().startsWith("#") || tag.startsWith("ladspa") || tag == "sox" || tag == "autotrack_rectangle") {
// This is a keyframe effect, to edit it, we remove it and re-add it.
- mltRemoveEffect(track, position, id, tag, -1);
- mltAddEffect(track, position, id, tag, args);
+ mltRemoveEffect(track, position, tag, -1);
+ mltAddEffect(track, position, tag, args);
return;
}
m_isBlocked = true;
void mltMoveClip(int startTrack, int endTrack, GenTime pos, GenTime moveStart);
void mltMoveClip(int startTrack, int endTrack, int pos, int moveStart);
void mltRemoveClip(int track, GenTime position);
- void mltRemoveEffect(int track, GenTime position, QString id, QString tag, int index);
- void mltAddEffect(int track, GenTime position, QString id, QString tag, QMap <QString, QString> args);
+ void mltRemoveEffect(int track, GenTime position, QString tag, int index);
+ void mltAddEffect(int track, GenTime position, QString tag, QMap <QString, QString> args);
void mltEditEffect(int track, GenTime position, int index, QString id, QString tag, QMap <QString, QString> args);
void mltChangeTrackState(int track, bool mute, bool blind);
void mltMoveTransition(QString type, int startTrack, int trackOffset, GenTime oldIn, GenTime oldOut, GenTime newIn, GenTime newOut);