]> git.sesse.net Git - kdenlive/blobdiff - src/abstractscopewidget.cpp
Made AbstractAudioScope and AbstractGfxScope inherit from AbstractScope; Done for...
[kdenlive] / src / abstractscopewidget.cpp
index bbc5761a773e0de1d478db76b5782af8a310b019..c72e584f554eb6a1b81db9b54054f37626b3a113 100644 (file)
@@ -29,7 +29,9 @@ const QColor dark2(25,  25,  23, 255);
 const QPen AbstractScopeWidget::penThick(QBrush(QColor(250, 250, 250)),     2, Qt::SolidLine);
 const QPen AbstractScopeWidget::penThin(QBrush(QColor(250, 250, 250)),     1, Qt::SolidLine);
 const QPen AbstractScopeWidget::penLight(QBrush(QColor(200, 200, 250, 150)), 1, Qt::SolidLine);
+const QPen AbstractScopeWidget::penLightDots(QBrush(QColor(200, 200, 250, 150)), 1, Qt::DotLine);
 const QPen AbstractScopeWidget::penDark(QBrush(QColor(0, 0, 20, 250)),      1, Qt::SolidLine);
+const QPen AbstractScopeWidget::penDarkDots(QBrush(QColor(0, 0, 20, 250)),      1, Qt::DotLine);
 
 AbstractScopeWidget::AbstractScopeWidget(Monitor *projMonitor, Monitor *clipMonitor, bool trackMouse, QWidget *parent) :
         QWidget(parent),
@@ -44,7 +46,8 @@ AbstractScopeWidget::AbstractScopeWidget(Monitor *projMonitor, Monitor *clipMoni
         m_semaphoreHUD(1),
         m_semaphoreScope(1),
         m_semaphoreBackground(1),
-        initialDimensionUpdateDone(false)
+        initialDimensionUpdateDone(false),
+        m_requestForcedUpdate(false)
 
 {
     m_scopePalette = QPalette();
@@ -150,8 +153,8 @@ void AbstractScopeWidget::prodHUDThread()
 void AbstractScopeWidget::prodScopeThread()
 {
     // Only start a new thread if the scope is actually visible
-    // and not hidden by another widget on the stack.
-    if (this->visibleRegion().isEmpty()) {
+    // and not hidden by another widget on the stack and if user want the scope to update.
+    if (this->visibleRegion().isEmpty() || (!m_aAutoRefresh->isChecked() && !m_requestForcedUpdate)) {
 //        qDebug() << "Scope " << m_widgetName << " is not visible. Not calculating scope.";
     } else {
         // Try to acquire the semaphore. This must only succeed if m_threadScope is not running
@@ -167,7 +170,8 @@ void AbstractScopeWidget::prodScopeThread()
 
             // See http://doc.qt.nokia.com/latest/qtconcurrentrun.html#run about
             // running member functions in a thread
-            m_threadScope = QtConcurrent::run(this, &AbstractScopeWidget::renderScope, m_accelFactorScope, m_scopeImage);
+            m_threadScope = QtConcurrent::run(this, &AbstractScopeWidget::renderScope, m_accelFactorScope);
+            m_requestForcedUpdate = false;
 
 //            qDebug() << "Scope thread started in " << m_widgetName;
 
@@ -201,6 +205,7 @@ void AbstractScopeWidget::forceUpdate(bool doUpdate)
     if (!doUpdate) {
         return;
     }
+    m_requestForcedUpdate = true;
     m_newHUDUpdates.fetchAndAddRelaxed(1);
     m_newScopeUpdates.fetchAndAddRelaxed(1);
     m_newBackgroundUpdates.fetchAndAddRelaxed(1);
@@ -217,6 +222,7 @@ void AbstractScopeWidget::forceUpdateHUD()
 void AbstractScopeWidget::forceUpdateScope()
 {
     m_newScopeUpdates.fetchAndAddRelaxed(1);
+    m_requestForcedUpdate = true;
     prodScopeThread();
 
 }
@@ -232,7 +238,10 @@ void AbstractScopeWidget::forceUpdateBackground()
 
 void AbstractScopeWidget::mouseReleaseEvent(QMouseEvent *event)
 {
-    if (!m_aAutoRefresh->isChecked()) m_activeRender->sendFrameUpdate();
+    if (!m_aAutoRefresh->isChecked()) {
+        m_requestForcedUpdate = true;
+        m_activeRender->sendFrameUpdate();
+    }
     prodHUDThread();
     prodScopeThread();
     prodBackgroundThread();
@@ -243,7 +252,6 @@ void AbstractScopeWidget::resizeEvent(QResizeEvent *event)
 {
     // Update the dimension of the available rect for painting
     m_scopeRect = scopeRect();
-
     forceUpdate();
 
     QWidget::resizeEvent(event);
@@ -444,6 +452,8 @@ void AbstractScopeWidget::slotAutoRefreshToggled(bool autoRefresh)
     if (isVisible()) emit requestAutoRefresh(autoRefresh);
     // TODO only if depends on input
     if (autoRefresh) {
-        forceUpdate();
+        //forceUpdate();
+        m_requestForcedUpdate = true;
+        m_activeRender->sendFrameUpdate();
     }
 }