From: Jean-Baptiste Mardelle Date: Tue, 17 Apr 2012 21:22:43 +0000 (+0200) Subject: Optimize monitor scene show / hide X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=e482c50f761b28c3a5b51f8a4517ef3a3addb6ba;p=kdenlive Optimize monitor scene show / hide --- diff --git a/src/effectstack/effectstackview2.cpp b/src/effectstack/effectstackview2.cpp index a7d21662..414f6f51 100644 --- a/src/effectstack/effectstackview2.cpp +++ b/src/effectstack/effectstackview2.cpp @@ -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"); diff --git a/src/effectstack/effectstackview2.h b/src/effectstack/effectstackview2.h index 1166fa8d..623f1344 100644 --- a/src/effectstack/effectstackview2.h +++ b/src/effectstack/effectstackview2.h @@ -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. diff --git a/src/monitor.cpp b/src/monitor.cpp index 2c9e6f2c..34f23de8 100644 --- a/src/monitor.cpp +++ b/src/monitor.cpp @@ -989,7 +989,6 @@ void Monitor::slotSetSelectedClip(Transition* item) void Monitor::slotShowEffectScene(bool show) { if (m_id == Kdenlive::projectMonitor) { - kDebug()<<"// SHOWING SCENE: "<isVisible(); if (m_effectWidget->isVisible() == show) return; if (videoSurface) { videoSurface->setVisible(!show);