From: Dan Dennedy Date: Mon, 30 Aug 2010 03:32:46 +0000 (+0000) Subject: Add center-crop option to slideshow clip. X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=7faa196f9b4a7c03dd2442439500efed29e6c53b;p=kdenlive Add center-crop option to slideshow clip. svn path=/trunk/kdenlive/; revision=4781 --- diff --git a/src/clipmanager.cpp b/src/clipmanager.cpp index 2e9367b9..fc48734f 100644 --- a/src/clipmanager.cpp +++ b/src/clipmanager.cpp @@ -372,7 +372,7 @@ void ClipManager::slotAddColorClipFile(const QString name, const QString color, m_doc->commandStack()->push(command); } -void ClipManager::slotAddSlideshowClipFile(const QString name, const QString path, int count, const QString duration, const bool loop, const bool fade, const QString &luma_duration, const QString &luma_file, const int softness, QString group, const QString &groupId) +void ClipManager::slotAddSlideshowClipFile(const QString name, const QString path, int count, const QString duration, const bool loop, const bool crop, const bool fade, const QString &luma_duration, const QString &luma_file, const int softness, QString group, const QString &groupId) { QDomDocument doc; QDomElement prod = doc.createElement("producer"); @@ -387,6 +387,7 @@ void ClipManager::slotAddSlideshowClipFile(const QString name, const QString pat prod.setAttribute("luma_duration", m_doc->getFramePos(luma_duration)); prod.setAttribute("name", name); prod.setAttribute("loop", loop); + prod.setAttribute("crop", crop); prod.setAttribute("fade", fade); prod.setAttribute("softness", QString::number(softness)); prod.setAttribute("luma_file", luma_file); diff --git a/src/clipmanager.h b/src/clipmanager.h index 4ba673eb..8ea9b4a8 100644 --- a/src/clipmanager.h +++ b/src/clipmanager.h @@ -76,7 +76,7 @@ Q_OBJECT public: void slotAddTextTemplateClip(QString titleName, const KUrl path, const QString group, const QString &groupId); void slotAddXmlClipFile(const QString name, const QDomElement xml, const QString group, const QString &groupId); void slotAddColorClipFile(const QString name, const QString color, QString duration, const QString group, const QString &groupId); - void slotAddSlideshowClipFile(const QString name, const QString path, int count, const QString duration, const bool loop, const bool fade, const QString &luma_duration, const QString &luma_file, const int softness, const QString group, const QString &groupId); + void slotAddSlideshowClipFile(const QString name, const QString path, int count, const QString duration, const bool loop, const bool crop, const bool fade, const QString &luma_duration, const QString &luma_file, const int softness, const QString group, const QString &groupId); DocClipBase *getClipById(QString clipId); const QList getClipByResource(QString resource); void slotDeleteClips(QStringList ids); diff --git a/src/clipproperties.cpp b/src/clipproperties.cpp index 5bbc0e32..4ff65f02 100644 --- a/src/clipproperties.cpp +++ b/src/clipproperties.cpp @@ -185,6 +185,7 @@ ClipProperties::ClipProperties(DocClipBase *clip, Timecode tc, double fps, QWidg m_view.image_type->addItem("Open EXR (*.exr)", "exr"); m_view.slide_loop->setChecked(props.value("loop").toInt()); + m_view.slide_crop->setChecked(props.value("crop").toInt()); m_view.slide_fade->setChecked(props.value("fade").toInt()); m_view.luma_softness->setValue(props.value("softness").toInt()); QString path = props.value("resource"); @@ -575,6 +576,8 @@ QMap ClipProperties::properties() } else if (t == SLIDESHOW) { QString value = QString::number((int) m_view.slide_loop->isChecked()); if (m_old_props.value("loop") != value) props["loop"] = value; + value = QString::number((int) m_view.slide_crop->isChecked()); + if (m_old_props.value("crop") != value) props["crop"] = value; value = QString::number((int) m_view.slide_fade->isChecked()); if (m_old_props.value("fade") != value) props["fade"] = value; value = QString::number((int) m_view.luma_softness->value()); diff --git a/src/docclipbase.cpp b/src/docclipbase.cpp index f75b0041..fc74fbf1 100644 --- a/src/docclipbase.cpp +++ b/src/docclipbase.cpp @@ -702,6 +702,36 @@ void DocClipBase::slotRefreshProducer() filter = clipService.filter(ct); } } + if (getProperty("crop") == "1") { + // we want a center crop filter effect + Mlt::Service clipService(m_baseTrackProducers.at(0)->get_service()); + int ct = 0; + Mlt::Filter *filter = clipService.filter(ct); + while (filter) { + if (strcmp(filter->get("mlt_service"), "crop") == 0) { + break; + } + ct++; + filter = clipService.filter(ct); + } + + if (!filter || strcmp(filter->get("mlt_service"), "crop")) { + // filter does not exist, create it... + Mlt::Filter *filter = new Mlt::Filter(*(m_baseTrackProducers.at(0)->profile()), "crop"); + filter->set("center", 1); + clipService.attach(*filter); + } + } else { + Mlt::Service clipService(m_baseTrackProducers.at(0)->get_service()); + int ct = 0; + Mlt::Filter *filter = clipService.filter(0); + while (filter) { + if (strcmp(filter->get("mlt_service"), "crop") == 0) { + clipService.detach(*filter); + } else ct++; + filter = clipService.filter(ct); + } + } } } diff --git a/src/kdenlivedoc.cpp b/src/kdenlivedoc.cpp index 8615b2ba..88cb4712 100644 --- a/src/kdenlivedoc.cpp +++ b/src/kdenlivedoc.cpp @@ -1074,9 +1074,9 @@ void KdenliveDoc::slotCreateColorClip(const QString &name, const QString &color, emit selectLastAddedClip(QString::number(m_clipManager->lastClipId())); } -void KdenliveDoc::slotCreateSlideshowClipFile(const QString name, const QString path, int count, const QString duration, const bool loop, const bool fade, const QString &luma_duration, const QString &luma_file, const int softness, QString group, const QString &groupId) +void KdenliveDoc::slotCreateSlideshowClipFile(const QString name, const QString path, int count, const QString duration, const bool loop, const bool crop, const bool fade, const QString &luma_duration, const QString &luma_file, const int softness, QString group, const QString &groupId) { - m_clipManager->slotAddSlideshowClipFile(name, path, count, duration, loop, fade, luma_duration, luma_file, softness, group, groupId); + m_clipManager->slotAddSlideshowClipFile(name, path, count, duration, loop, crop, fade, luma_duration, luma_file, softness, group, groupId); setModified(true); emit selectLastAddedClip(QString::number(m_clipManager->lastClipId())); } diff --git a/src/kdenlivedoc.h b/src/kdenlivedoc.h index 2274fe8d..f34dbabf 100644 --- a/src/kdenlivedoc.h +++ b/src/kdenlivedoc.h @@ -154,7 +154,7 @@ private: public slots: void slotCreateXmlClip(const QString &name, const QDomElement xml, QString group, const QString &groupId); void slotCreateColorClip(const QString &name, const QString &color, const QString &duration, QString group, const QString &groupId); - void slotCreateSlideshowClipFile(const QString name, const QString path, int count, const QString duration, const bool loop, const bool fade, const QString &luma_duration, const QString &luma_file, const int softness, QString group, const QString &groupId); + void slotCreateSlideshowClipFile(const QString name, const QString path, int count, const QString duration, const bool loop, const bool crop, const bool fade, const QString &luma_duration, const QString &luma_file, const int softness, QString group, const QString &groupId); void slotCreateTextClip(QString group, const QString &groupId, const QString &templatePath = QString()); void slotCreateTextTemplateClip(QString group, const QString &groupId, KUrl path); /** Set to true if document needs saving, false otherwise */ diff --git a/src/projectlist.cpp b/src/projectlist.cpp index 73c7d3b3..8b2d0aa5 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -1103,7 +1103,7 @@ void ProjectList::slotAddClip(const QList givenList, const QString &group fileName.chop(1); } - m_doc->slotCreateSlideshowClipFile(fileName, pattern, count, m_timecode.reformatSeparators(KdenliveSettings::sequence_duration()), false, false, m_timecode.getTimecodeFromFrames(int(ceil(m_timecode.fps()))), QString(), 0, groupInfo.at(0), groupInfo.at(1)); + m_doc->slotCreateSlideshowClipFile(fileName, pattern, count, m_timecode.reformatSeparators(KdenliveSettings::sequence_duration()), false, false, false, m_timecode.getTimecodeFromFrames(int(ceil(m_timecode.fps()))), QString(), 0, groupInfo.at(0), groupInfo.at(1)); return; } } @@ -1191,7 +1191,7 @@ void ProjectList::slotAddSlideshowClip() if (dia->exec() == QDialog::Accepted) { QStringList groupInfo = getGroup(); - m_doc->slotCreateSlideshowClipFile(dia->clipName(), dia->selectedPath(), dia->imageCount(), dia->clipDuration(), dia->loop(), dia->fade(), + m_doc->slotCreateSlideshowClipFile(dia->clipName(), dia->selectedPath(), dia->imageCount(), dia->clipDuration(), dia->loop(), dia->crop(), dia->fade(), dia->lumaDuration(), dia->lumaFile(), dia->softness(), groupInfo.at(0), groupInfo.at(1)); } delete dia; @@ -1301,7 +1301,7 @@ QDomElement ProjectList::producersList() QDomDocument doc; QDomElement prods = doc.createElement("producerlist"); doc.appendChild(prods); - kDebug() << "//////////// PRO LIST BUILD PRDSLIST "; + kDebug() << "//////////// PRO LIST BUILD PRDSLIST "; QTreeWidgetItemIterator it(m_listView); while (*it) { if ((*it)->type() != PROJECTCLIPTYPE) { diff --git a/src/renderer.cpp b/src/renderer.cpp index a964af7e..47d9bc67 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -732,6 +732,14 @@ void Render::getFileProperties(const QDomElement xml, const QString &clipId, int clipService.attach(*filter); } } + if (xml.attribute("crop") == "1") { + // user wants to center crop the slides + Mlt::Filter *filter = new Mlt::Filter(*m_mltProfile, "crop"); + if (filter && filter->is_valid()) { + filter->set("center", 1); + producer->attach(*filter); + } + } } @@ -2433,7 +2441,7 @@ bool Render::mltAddEffect(Mlt::Service service, EffectsParameterList params, int params.removeParam("max"); params.removeParam("factor"); int offset = 0; - // Special case, only one keyframe, means we want a constant value + // Special case, only one keyframe, means we want a constant value if (keyFrames.count() == 1) { Mlt::Filter *filter = new Mlt::Filter(*m_mltProfile, filterTag); if (filter && filter->is_valid()) { diff --git a/src/slideshowclip.cpp b/src/slideshowclip.cpp index 49494fef..aa8e67ba 100644 --- a/src/slideshowclip.cpp +++ b/src/slideshowclip.cpp @@ -353,6 +353,11 @@ bool SlideshowClip::loop() const return m_view.slide_loop->isChecked(); } +bool SlideshowClip::crop() const +{ + return m_view.slide_crop->isChecked(); +} + bool SlideshowClip::fade() const { return m_view.slide_fade->isChecked(); diff --git a/src/slideshowclip.h b/src/slideshowclip.h index dc9d07bb..9aa38387 100644 --- a/src/slideshowclip.h +++ b/src/slideshowclip.h @@ -43,6 +43,7 @@ public: QString lumaDuration() const; int imageCount() const; bool loop() const; + bool crop() const; bool fade() const; QString lumaFile() const; int softness() const; diff --git a/src/widgets/clipproperties_ui.ui b/src/widgets/clipproperties_ui.ui index 199019be..309822c3 100644 --- a/src/widgets/clipproperties_ui.ui +++ b/src/widgets/clipproperties_ui.ui @@ -6,8 +6,8 @@ 0 0 - 295 - 418 + 302 + 424 @@ -324,21 +324,21 @@ - + Loop - + Dissolve - + @@ -365,24 +365,24 @@ - + Wipe - + - + Softness - + 100 @@ -392,14 +392,14 @@ - + No image found - + Qt::Vertical @@ -412,6 +412,13 @@ + + + + Center crop + + + diff --git a/src/widgets/slideshowclip_ui.ui b/src/widgets/slideshowclip_ui.ui index 54ce9833..97dbdafd 100644 --- a/src/widgets/slideshowclip_ui.ui +++ b/src/widgets/slideshowclip_ui.ui @@ -6,8 +6,8 @@ 0 0 - 259 - 412 + 287 + 453 @@ -165,14 +165,14 @@ - + Dissolve - + @@ -205,7 +205,7 @@ - + false @@ -215,14 +215,14 @@ - + false - + false @@ -232,7 +232,7 @@ - + false @@ -245,10 +245,10 @@ - + - + @@ -279,7 +279,7 @@ - + Qt::Horizontal @@ -289,6 +289,13 @@ + + + + Center crop + + +