Commit 7faa196f authored by Dan Dennedy's avatar Dan Dennedy

Add center-crop option to slideshow clip.

svn path=/trunk/kdenlive/; revision=4781
parent 9e7a2da2
......@@ -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);
......
......@@ -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 <DocClipBase *> getClipByResource(QString resource);
void slotDeleteClips(QStringList ids);
......
......@@ -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 <QString, QString> 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());
......
......@@ -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);
}
}
}
}
......
......@@ -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()));
}
......
......@@ -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 */
......
......@@ -1103,7 +1103,7 @@ void ProjectList::slotAddClip(const QList <QUrl> 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) {
......
......@@ -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()) {
......
......@@ -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();
......
......@@ -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;
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>295</width>
<height>418</height>
<width>302</width>
<height>424</height>
</rect>
</property>
<property name="windowTitle">
......@@ -324,21 +324,21 @@
<item row="1" column="2">
<widget class="KComboBox" name="slide_duration_format"/>
</item>
<item row="2" column="0" colspan="3">
<item row="3" column="0" colspan="3">
<widget class="QCheckBox" name="slide_loop">
<property name="text">
<string>Loop</string>
</property>
</widget>
</item>
<item row="3" column="0">
<item row="5" column="0">
<widget class="QCheckBox" name="slide_fade">
<property name="text">
<string>Dissolve</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<item row="5" column="1" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="KRestrictedLine" name="luma_duration">
......@@ -365,24 +365,24 @@
</item>
</layout>
</item>
<item row="4" column="0">
<item row="6" column="0">
<widget class="QCheckBox" name="slide_luma">
<property name="text">
<string>Wipe</string>
</property>
</widget>
</item>
<item row="4" column="1" colspan="2">
<item row="6" column="1" colspan="2">
<widget class="KComboBox" name="luma_file"/>
</item>
<item row="5" column="0">
<item row="7" column="0">
<widget class="QLabel" name="label_softness">
<property name="text">
<string>Softness</string>
</property>
</widget>
</item>
<item row="5" column="1" colspan="2">
<item row="7" column="1" colspan="2">
<widget class="QSlider" name="luma_softness">
<property name="maximum">
<number>100</number>
......@@ -392,14 +392,14 @@
</property>
</widget>
</item>
<item row="6" column="0" colspan="3">
<item row="8" column="0" colspan="3">
<widget class="QLabel" name="slide_info">
<property name="text">
<string>No image found</string>
</property>
</widget>
</item>
<item row="7" column="1">
<item row="9" column="1">
<spacer name="verticalSpacer_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -412,6 +412,13 @@
</property>
</spacer>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="slide_crop">
<property name="text">
<string>Center crop</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_4">
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>259</width>
<height>412</height>
<width>287</width>
<height>453</height>
</rect>
</property>
<property name="windowTitle">
......@@ -165,14 +165,14 @@
</property>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QCheckBox" name="slide_fade">
<property name="text">
<string>Dissolve</string>
</property>
</widget>
</item>
<item row="4" column="2" colspan="2">
<item row="5" column="2" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="KRestrictedLine" name="luma_duration">
......@@ -205,7 +205,7 @@
</item>
</layout>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QCheckBox" name="luma_fade">
<property name="enabled">
<bool>false</bool>
......@@ -215,14 +215,14 @@
</property>
</widget>
</item>
<item row="5" column="2" colspan="2">
<item row="6" column="2" colspan="2">
<widget class="KComboBox" name="luma_file">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="6" column="0">
<item row="7" column="0">
<widget class="QLabel" name="label_softness">
<property name="enabled">
<bool>false</bool>
......@@ -232,7 +232,7 @@
</property>
</widget>
</item>
<item row="6" column="2" colspan="2">
<item row="7" column="2" colspan="2">
<widget class="QSlider" name="luma_softness">
<property name="enabled">
<bool>false</bool>
......@@ -245,10 +245,10 @@
</property>
</widget>
</item>
<item row="7" column="0" colspan="4">
<item row="8" column="0" colspan="4">
<widget class="KListWidget" name="icon_list"/>
</item>
<item row="8" column="0" colspan="4">
<item row="9" column="0" colspan="4">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QCheckBox" name="show_thumbs">
......@@ -279,7 +279,7 @@
</item>
</layout>
</item>
<item row="9" column="2" colspan="2">
<item row="10" column="2" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -289,6 +289,13 @@
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="slide_crop">
<property name="text">
<string>Center crop</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
......
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