]> git.sesse.net Git - kdenlive/blobdiff - src/effectstackview.cpp
on-monitor editing: show controls next to the edit monitor
[kdenlive] / src / effectstackview.cpp
index 5a2d1fb9da366e6b85060943c7c9f251a12973b5..944e2841a12937f6057ee2aebf20b2ab8544902f 100644 (file)
@@ -23,6 +23,7 @@
 #include "docclipbase.h"
 #include "projectlist.h"
 #include "kthumb.h"
+#include "monitoreditwidget.h"
 #include "monitorscene.h"
 #include "kdenlivesettings.h"
 
@@ -51,7 +52,7 @@ EffectStackView::EffectStackView(Monitor *monitor, QWidget *parent) :
     vbox1->setContentsMargins(0, 0, 0, 0);
     vbox1->setSpacing(0);
     vbox1->addWidget(m_effectedit);
-    m_ui.frame->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
+
     //m_ui.region_url->fileDialog()->setFilter(ProjectList::getExtensions());
     //m_ui.effectlist->horizontalHeader()->setVisible(false);
     //m_ui.effectlist->verticalHeader()->setVisible(false);
@@ -69,10 +70,13 @@ EffectStackView::EffectStackView(Monitor *monitor, QWidget *parent) :
     m_ui.buttonReset->setIcon(KIcon("view-refresh"));
     m_ui.buttonReset->setToolTip(i18n("Reset effect"));
     m_ui.checkAll->setToolTip(i18n("Enable/Disable all effects"));
-
+    m_ui.buttonShowComments->setIcon(KIcon("help-about"));
+    m_ui.buttonShowComments->setToolTip(i18n("Show additional information for the parameters"));
 
     m_ui.effectlist->setDragDropMode(QAbstractItemView::NoDragDrop); //use internal if drop is recognised right
 
+    m_ui.labelComment->setHidden(true);
+
     //connect(m_ui.region_url, SIGNAL(urlSelected(const KUrl &)), this , SLOT(slotRegionChanged()));
     //connect(m_ui.region_url, SIGNAL(returnPressed()), this , SLOT(slotRegionChanged()));
     connect(m_ui.effectlist, SIGNAL(itemSelectionChanged()), this , SLOT(slotItemSelectionChanged()));
@@ -83,16 +87,19 @@ EffectStackView::EffectStackView(Monitor *monitor, QWidget *parent) :
     connect(m_ui.buttonSave, SIGNAL(clicked()), this, SLOT(slotSaveEffect()));
     connect(m_ui.buttonReset, SIGNAL(clicked()), this, SLOT(slotResetEffect()));
     connect(m_ui.checkAll, SIGNAL(stateChanged(int)), this, SLOT(slotCheckAll(int)));
+    connect(m_ui.buttonShowComments, SIGNAL(clicked()), this, SLOT(slotShowComments()));
     connect(m_effectedit, SIGNAL(parameterChanged(const QDomElement, const QDomElement)), this , SLOT(slotUpdateEffectParams(const QDomElement, const QDomElement)));
     connect(m_effectedit, SIGNAL(seekTimeline(int)), this , SLOT(slotSeekTimeline(int)));
     connect(m_effectedit, SIGNAL(displayMessage(const QString&, int)), this, SIGNAL(displayMessage(const QString&, int)));
     connect(m_effectedit, SIGNAL(checkMonitorPosition(int)), this, SLOT(slotCheckMonitorPosition(int)));
     connect(monitor, SIGNAL(renderPosition(int)), this, SLOT(slotRenderPos(int)));
+    connect(this, SIGNAL(showComments(bool)), m_effectedit, SIGNAL(showComments(bool)));
     m_effectLists["audio"] = &MainWindow::audioEffects;
     m_effectLists["video"] = &MainWindow::videoEffects;
     m_effectLists["custom"] = &MainWindow::customEffects;
     m_ui.splitter->setStretchFactor(1, 10);
     m_ui.splitter->setStretchFactor(0, 1);
+
     setEnabled(false);
 }
 
@@ -183,8 +190,9 @@ void EffectStackView::slotClipItemSelected(ClipItem* c, int ix)
             double factor = c->baseClip()->getProperty("aspect_ratio").toDouble();
             QPoint p((int)(size.section('x', 0, 0).toInt() * factor + 0.5), size.section('x', 1, 1).toInt());
             m_effectedit->setFrameSize(p);
-            m_effectedit->setFrameSize(p);
-        } else ix = 0;
+        } else {
+            ix = 0;
+        }
     }
     if (m_clipref == NULL) {
         m_ui.effectlist->blockSignals(true);
@@ -194,6 +202,7 @@ void EffectStackView::slotClipItemSelected(ClipItem* c, int ix)
         m_ui.effectlist->blockSignals(false);
         m_ui.checkAll->setToolTip(QString());
         m_ui.checkAll->setText(QString());
+        m_ui.labelComment->setText(QString());
         setEnabled(false);
         return;
     }
@@ -208,6 +217,7 @@ void EffectStackView::slotTrackItemSelected(int ix, const TrackInfo info)
     m_clipref = NULL;
     m_trackMode = true;
     m_currentEffectList = info.effectsList;
+    m_trackInfo = info;
     kDebug() << "// TRACK; " << ix << ", EFFECTS: " << m_currentEffectList.count();
     setEnabled(true);
     m_ui.checkAll->setToolTip(QString());
@@ -220,13 +230,15 @@ void EffectStackView::slotItemChanged(QListWidgetItem *item)
 {
     bool disable = true;
     if (item->checkState() == Qt::Checked) disable = false;
-    m_ui.frame_layout->setEnabled(!disable);
+    m_ui.frame->setEnabled(!disable);
     m_ui.buttonReset->setEnabled(!disable);
     int activeRow = m_ui.effectlist->currentRow();
     if (activeRow >= 0) {
         m_effectedit->updateParameter("disable", QString::number((int) disable));
-        if (m_trackMode) emit changeEffectState(NULL, m_trackindex, activeRow, disable);
-        else emit changeEffectState(m_clipref, -1, activeRow, disable);
+        if (m_trackMode)
+            emit changeEffectState(NULL, m_trackindex, activeRow, disable);
+        else
+            emit changeEffectState(m_clipref, -1, activeRow, disable);
     }
     slotUpdateCheckAllButton();
 }
@@ -267,8 +279,10 @@ void EffectStackView::setupListView(int ix)
                 item = new QListWidgetItem(videoIcon, i18n(namenode.toElement().text().toUtf8().data()), m_ui.effectlist);
             }
             item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
-            if (d.attribute("disable") == "1") item->setCheckState(Qt::Unchecked);
-            else item->setCheckState(Qt::Checked);
+            if (d.attribute("disable") == "1")
+                item->setCheckState(Qt::Unchecked);
+            else
+                item->setCheckState(Qt::Checked);
         }
     }
     if (m_ui.effectlist->count() == 0) {
@@ -278,9 +292,10 @@ void EffectStackView::setupListView(int ix)
         m_ui.buttonUp->setEnabled(false);
         m_ui.buttonDown->setEnabled(false);
         m_ui.checkAll->setEnabled(false);
+        m_ui.buttonShowComments->setEnabled(false);
+        m_ui.labelComment->setHidden(true);
     } else {
-        if (ix < 0) ix = 0;
-        if (ix > m_ui.effectlist->count() - 1) ix = m_ui.effectlist->count() - 1;
+        ix = qBound(0, ix, m_ui.effectlist->count() - 1);
         m_ui.effectlist->setCurrentRow(ix);
         m_ui.checkAll->setEnabled(true);
     }
@@ -298,16 +313,18 @@ void EffectStackView::slotItemSelectionChanged(bool update)
     int activeRow = m_ui.effectlist->currentRow();
     bool isChecked = false;
     if (hasItem && m_ui.effectlist->currentItem()->checkState() == Qt::Checked) isChecked = true;
+    QDomElement eff;
     if (hasItem && m_ui.effectlist->currentItem()->isSelected()) {
-        QDomElement eff = m_currentEffectList.at(activeRow);
+        eff = m_currentEffectList.at(activeRow);
         if (m_trackMode) {
             // showing track effects
-            m_effectedit->transferParamDesc(eff, 0, 0, -1);
+            m_effectedit->transferParamDesc(eff, 0, 0, m_trackInfo.duration);
         } else m_effectedit->transferParamDesc(eff,
                                                    0,
                                                    m_clipref->cropStart().frames(KdenliveSettings::project_fps()),
-                                                   (m_clipref->cropStart() + m_clipref->cropDuration()).frames(KdenliveSettings::project_fps())); //minx max frame
+                                                   (m_clipref->cropStart() + m_clipref->cropDuration()).frames(KdenliveSettings::project_fps()) - 1); //minx max frame
         //m_ui.region_url->setUrl(KUrl(eff.attribute("region")));
+        m_ui.labelComment->setText(i18n(eff.firstChildElement("description").firstChildElement("full").text().toUtf8().data()));
     }
     if (!m_trackMode && m_clipref && update) m_clipref->setSelectedEffect(activeRow);
     m_ui.buttonDel->setEnabled(hasItem);
@@ -315,7 +332,11 @@ void EffectStackView::slotItemSelectionChanged(bool update)
     m_ui.buttonReset->setEnabled(hasItem && isChecked);
     m_ui.buttonUp->setEnabled(activeRow > 0);
     m_ui.buttonDown->setEnabled((activeRow < m_ui.effectlist->count() - 1) && hasItem);
-    m_ui.frame_layout->setEnabled(isChecked);
+    m_ui.frame->setEnabled(isChecked);
+    m_ui.buttonShowComments->setEnabled(hasItem);
+
+    emit showComments(m_ui.buttonShowComments->isChecked());
+    m_ui.labelComment->setVisible(hasItem && m_ui.labelComment->text().count() && (m_ui.buttonShowComments->isChecked() || !eff.elementsByTagName("parameter").count()));
 }
 
 void EffectStackView::slotItemUp()
@@ -338,8 +359,10 @@ void EffectStackView::slotItemDel()
 {
     int activeRow = m_ui.effectlist->currentRow();
     if (activeRow >= 0) {
-        if (m_trackMode) emit removeEffect(NULL, m_trackindex, m_currentEffectList.at(activeRow).cloneNode().toElement());
-        else emit removeEffect(m_clipref, -1, m_clipref->effectAt(activeRow));
+        if (m_trackMode)
+            emit removeEffect(NULL, m_trackindex, m_currentEffectList.at(activeRow).cloneNode().toElement());
+        else
+            emit removeEffect(m_clipref, -1, m_clipref->effectAt(activeRow));
         slotUpdateCheckAllButton();
     }
 }
@@ -362,8 +385,8 @@ void EffectStackView::slotResetEffect()
         dom.setAttribute("kdenlive_ix", old.attribute("kdenlive_ix"));
         if (m_trackMode) {
             EffectsList::setParameter(dom, "in", QString::number(0));
-            EffectsList::setParameter(dom, "out", QString::number(0));
-            m_effectedit->transferParamDesc(dom, 0, 0, 0);//minx max frame
+            EffectsList::setParameter(dom, "out", QString::number(m_trackInfo.duration));
+            m_effectedit->transferParamDesc(dom, 0, 0, m_trackInfo.duration);//minx max frame
             emit updateEffect(NULL, m_trackindex, old, dom, activeRow);
         } else {
             m_clipref->initEffect(dom);
@@ -372,6 +395,9 @@ void EffectStackView::slotResetEffect()
             emit updateEffect(m_clipref, -1, old, dom, activeRow);
         }
     }
+
+    emit showComments(m_ui.buttonShowComments->isChecked());
+    m_ui.labelComment->setHidden(!m_ui.buttonShowComments->isChecked() || !m_ui.labelComment->text().count());
 }
 
 
@@ -393,14 +419,19 @@ void EffectStackView::clear()
     m_ui.checkAll->setEnabled(false);
     m_effectedit->transferParamDesc(QDomElement(), 0, 0, 0);
     //m_ui.region_url->clear();
+    m_ui.buttonShowComments->setEnabled(false);
+    m_ui.labelComment->setText(QString());
     m_ui.effectlist->blockSignals(false);
 }
 
 
 void EffectStackView::slotSeekTimeline(int pos)
 {
-    if (!m_trackMode && m_clipref)
+    if (m_trackMode) {
+        emit seekTimeline(pos);
+    } else if (m_clipref) {
         emit seekTimeline(m_clipref->startPos().frames(KdenliveSettings::project_fps()) + pos);
+    }
 }
 
 void EffectStackView::slotUpdateCheckAllButton()
@@ -433,8 +464,17 @@ void EffectStackView::slotCheckAll(int state)
         m_ui.checkAll->blockSignals(false);
     }
 
-    for (int i = 0; i < m_ui.effectlist->count(); ++i)
-        m_ui.effectlist->item(i)->setCheckState((Qt::CheckState)state);
+    bool disabled = (state != 2);
+    m_effectedit->updateParameter("disable", QString::number((int) disabled));
+    for (int i = 0; i < m_ui.effectlist->count(); ++i) {
+        if (m_ui.effectlist->item(i)->checkState() != (Qt::CheckState)state) {
+            m_ui.effectlist->item(i)->setCheckState((Qt::CheckState)state);
+            if (m_trackMode)
+                emit changeEffectState(NULL, m_trackindex, i, disabled);
+            else
+                emit changeEffectState(m_clipref, -1, i, disabled);
+        }
+    }
 }
 
 /*void EffectStackView::slotRegionChanged()
@@ -445,7 +485,7 @@ void EffectStackView::slotCheckAll(int state)
 void EffectStackView::slotCheckMonitorPosition(int renderPos)
 {
     if (m_trackMode || (renderPos >= m_clipref->startPos().frames(KdenliveSettings::project_fps()) && renderPos <= m_clipref->endPos().frames(KdenliveSettings::project_fps()))) {
-        if (!m_monitor->getEffectScene()->views().at(0)->isVisible())
+        if (!m_monitor->getEffectEdit()->getScene()->views().at(0)->isVisible())
             m_monitor->slotEffectScene(true);
     } else {
         m_monitor->slotEffectScene(false);
@@ -454,8 +494,25 @@ void EffectStackView::slotCheckMonitorPosition(int renderPos)
 
 void EffectStackView::slotRenderPos(int pos)
 {
-    if (m_clipref && m_effectedit && !m_trackMode)
-        m_effectedit->slotSyncEffectsPos(pos - m_clipref->startPos().frames(KdenliveSettings::project_fps()));
+    if (m_effectedit) {
+        if (m_trackMode) {
+            m_effectedit->slotSyncEffectsPos(pos);
+        } else if (m_clipref) {
+            m_effectedit->slotSyncEffectsPos(pos - m_clipref->startPos().frames(KdenliveSettings::project_fps()));
+        }
+    }
+}
+
+int EffectStackView::isTrackMode(bool *ok) const
+{
+    *ok = m_trackMode;
+    return m_trackindex;
+}
+
+void EffectStackView::slotShowComments()
+{
+    m_ui.labelComment->setHidden(!m_ui.buttonShowComments->isChecked() || !m_ui.labelComment->text().count());
+    emit showComments(m_ui.buttonShowComments->isChecked());
 }
 
 #include "effectstackview.moc"