]> git.sesse.net Git - kdenlive/commitdiff
Optimize monitor scene show / hide
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 17 Apr 2012 21:22:43 +0000 (23:22 +0200)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 17 Apr 2012 21:22:43 +0000 (23:22 +0200)
src/effectstack/effectstackview2.cpp
src/effectstack/effectstackview2.h
src/monitor.cpp

index a7d21662db8374afb9e2187034a230c47e3f5eff..414f6f51f532f0957f4cbe1f0bc1f097bf3198e0 100644 (file)
@@ -50,7 +50,8 @@ EffectStackView2::EffectStackView2(Monitor *monitor, QWidget *parent) :
         m_trackindex(-1),
         m_draggedEffect(NULL),
         m_draggedGroup(NULL),
-        m_groupIndex(0)
+        m_groupIndex(0),
+        m_monitorSceneWanted(false)
 {
     m_effectMetaInfo.trackMode = false;
     m_effectMetaInfo.monitor = monitor;
@@ -85,7 +86,7 @@ void EffectStackView2::updatePalette()
 void EffectStackView2::slotRenderPos(int pos)
 {
     if (m_effects.isEmpty()) return;
-    slotCheckMonitorPosition(pos);
+    if (m_monitorSceneWanted) slotCheckMonitorPosition(pos);
     if (!m_effectMetaInfo.trackMode && m_clipref) pos = pos - m_clipref->startPos().frames(KdenliveSettings::project_fps());
 
     for (int i = 0; i< m_effects.count(); i++)
@@ -145,6 +146,7 @@ void EffectStackView2::slotTrackItemSelected(int ix, const TrackInfo info)
 void EffectStackView2::setupListView()
 {
     blockSignals(true);
+    m_monitorSceneWanted = false;
     m_draggedEffect = NULL;
     m_draggedGroup = NULL;
     disconnect(m_effectMetaInfo.monitor, SIGNAL(renderPosition(int)), this, SLOT(slotRenderPos(int)));
@@ -215,7 +217,10 @@ void EffectStackView2::setupListView()
        else {
            isSelected = currentEffect->effectIndex() == m_clipref->selectedEffectIndex();
        }
-       if (isSelected) currentEffect->setActive(true);
+       if (isSelected) {
+           currentEffect->setActive(true);
+           if (currentEffect->needsMonitorEffectScene()) m_monitorSceneWanted = true;
+       }
         m_effects.append(currentEffect);
         if (group) {
            group->addGroupEffect(currentEffect);
@@ -409,8 +414,7 @@ void EffectStackView2::slotSeekTimeline(int pos)
 
 void EffectStackView2::slotCheckMonitorPosition(int renderPos)
 {
-    CollapsibleEffect *current = currentEffect();
-    if (current && current->needsMonitorEffectScene()) {
+    if (m_monitorSceneWanted) {
        if (m_effectMetaInfo.trackMode || (m_clipref && renderPos >= m_clipref->startPos().frames(KdenliveSettings::project_fps()) && renderPos <= m_clipref->endPos().frames(KdenliveSettings::project_fps()))) {
            if (!m_effectMetaInfo.monitor->effectSceneDisplayed()) {
                m_effectMetaInfo.monitor->slotShowEffectScene(true);
@@ -433,6 +437,7 @@ int EffectStackView2::isTrackMode(bool *ok) const
 void EffectStackView2::clear()
 {
     m_effects.clear();
+    m_monitorSceneWanted = false;
     QWidget *view = m_ui.container->takeWidget();
     if (view) {
        delete view;
@@ -533,6 +538,7 @@ void EffectStackView2::slotSetCurrentEffect(int ix)
            if (m_effects.at(i)->effectIndex() == ix) {
                if (m_effects.at(i)->isActive()) return;
                m_effects.at(i)->setActive(true);
+               m_monitorSceneWanted = m_effects.at(i)->needsMonitorEffectScene();
                slotCheckMonitorPosition(m_effectMetaInfo.monitor->render->seekFramePosition());
                m_ui.labelComment->setText(i18n(m_effects.at(i)->effect().firstChildElement("description").firstChildElement("full").text().toUtf8().data()));
                m_ui.labelComment->setHidden(!m_ui.buttonShowComments->isChecked() || m_ui.labelComment->text().isEmpty());
@@ -542,14 +548,6 @@ void EffectStackView2::slotSetCurrentEffect(int ix)
     }
 }
 
-CollapsibleEffect *EffectStackView2::currentEffect() const
-{
-    for (int i = 0; i < m_effects.count(); i++) {
-       if (m_effects.at(i)->isActive()) return m_effects.at(i);
-    }
-    return NULL;
-}
-
 void EffectStackView2::slotDeleteGroup(QDomDocument doc)
 {
     QDomNodeList effects = doc.elementsByTagName("effect");
index 1166fa8d48769d46aac770d78954ca98584c7954..623f13442b39e179bf398333767453cfee472f12 100644 (file)
@@ -108,6 +108,9 @@ private:
     
     /** @brief The current number of groups. */
     int m_groupIndex;
+    
+    /** @brief The current effect may require an on monitor scene. */
+    bool m_monitorSceneWanted;
 
     /** @brief Sets the list of effects according to the clip's effect list. */
     void setupListView();
@@ -119,8 +122,6 @@ private:
     void connectEffect(CollapsibleEffect *currentEffect);
     /** @brief Connect a group to its signals. */
     void connectGroup(CollapsibleGroup *group);
-    /** @brief Returns the currentl active effect. */
-    CollapsibleEffect *currentEffect() const;
 
 public slots:
     /** @brief Sets the clip whose effect list should be managed.
index 2c9e6f2c3e697b534bbc61a201a99a26f5044ad3..34f23de87747b0ffba7e31b83cf7feabd4cc03dd 100644 (file)
@@ -989,7 +989,6 @@ void Monitor::slotSetSelectedClip(Transition* item)
 void Monitor::slotShowEffectScene(bool show)
 {
     if (m_id == Kdenlive::projectMonitor) {
-       kDebug()<<"// SHOWING SCENE: "<<show<<", IS DISPLAYD: "<<m_effectWidget->isVisible();
        if (m_effectWidget->isVisible() == show) return;
         if (videoSurface) {
             videoSurface->setVisible(!show);