]> git.sesse.net Git - kdenlive/commitdiff
Waveform:
authorSimon A. Eugster <simon.eu@gmail.com>
Thu, 2 Sep 2010 16:19:18 +0000 (16:19 +0000)
committerSimon A. Eugster <simon.eu@gmail.com>
Thu, 2 Sep 2010 16:19:18 +0000 (16:19 +0000)
* Display the x position of the source clip

svn path=/trunk/kdenlive/; revision=4809

src/waveform.cpp
src/waveform.h

index 505c972f7791416c7d654a2a4979809df571781a..2b73dd0e57235e05f5a1d7b1006c105547f8838c 100644 (file)
 #include <QPainter>
 #include <QPoint>
 
+// For reading out the project resolution
+#include "kdenlivesettings.h"
+#include "profilesdialog.h"
+
 #include "renderer.h"
 #include "waveform.h"
 #include "waveformgenerator.h"
 
 
 const QSize Waveform::m_textWidth(35,0);
+const int Waveform::m_paddingBottom(20);
 
 Waveform::Waveform(Monitor *projMonitor, Monitor *clipMonitor, QWidget *parent) :
     AbstractScopeWidget(projMonitor, clipMonitor, true, parent)
@@ -89,7 +94,6 @@ QRect Waveform::scopeRect()
 {
     // Distance from top/left/right
     int offset = 6;
-
     QPoint topleft(offset, ui->verticalSpacer->geometry().y()+offset);
 
     return QRect(topleft, this->size() - QSize(offset+topleft.x(), offset+topleft.y()));
@@ -111,28 +115,55 @@ QImage Waveform::renderHUD(uint)
     QPainter davinci(&hud);
     davinci.setPen(penLight);
 
-    int x = scopeRect().width()-m_textWidth.width()+3;
-    int y = m_mousePos.y() - scopeRect().y();
+    QMap< QString, QString > values = ProfilesDialog::getSettingsFromFile(KdenliveSettings::current_profile());
+//    qDebug() << values.value("width");
 
-    if (scopeRect().height() > 0 && m_mouseWithinWidget) {
-        // Draw a horizontal line through the current mouse position
-        // and show the value of the waveform there
-        davinci.drawLine(0, y, scopeRect().size().width()-m_textWidth.width(), y);
+    const int rightX = scopeRect().width()-m_textWidth.width()+3;
+    const int x = m_mousePos.x() - scopeRect().x();
+    const int y = m_mousePos.y() - scopeRect().y();
 
-        // Make the value stick to the line unless it is at the top/bottom of the scope
+    if (scopeRect().height() > 0 && m_mouseWithinWidget) {
         const int top = 30;
         const int bottom = 20;
-        int valY = y+5;
-        if (valY < top) {
-            valY = top;
-        } else if (valY > scopeRect().height()-bottom) {
-            valY = scopeRect().height()-bottom;
-        }
         int val = 255*(1-(float)y/scopeRect().height());
-        davinci.drawText(x, valY, QVariant(val).toString());
+
+        if (val >= 0 && val <= 255) {
+            // Draw a horizontal line through the current mouse position
+            // and show the value of the waveform there
+            davinci.drawLine(0, y, scopeRect().size().width()-m_textWidth.width(), y);
+
+            // Make the value stick to the line unless it is at the top/bottom of the scope
+            int valY = y+5;
+            if (valY < top) {
+                valY = top;
+            } else if (valY > scopeRect().height()-bottom) {
+                valY = scopeRect().height()-bottom;
+            }
+            davinci.drawText(rightX, valY, QVariant(val).toString());
+        }
+
+        if (scopeRect().width() > 0) {
+            // Draw a vertical line and the x position of the source clip
+            bool ok;
+            const int profileWidth = values.value("width").toInt(&ok);
+
+            if (ok) {
+                const int clipX = (float)x/(scopeRect().width()-m_textWidth.width()-1)*(profileWidth-1);
+
+                if (clipX >= 0 && clipX <= profileWidth) {
+                    int valX = x-15;
+                    if (valX < 0) { valX = 0; }
+                    if (valX > scopeRect().width()-55-m_textWidth.width()) { valX = scopeRect().width()-55-m_textWidth.width(); }
+
+                    davinci.drawLine(x, y, x, scopeRect().height()-m_paddingBottom);
+                    davinci.drawText(valX, scopeRect().height()-5, QVariant(clipX).toString() + " px");
+                }
+            }
+        }
+
     }
-    davinci.drawText(x, scopeRect().height(), "0");
-    davinci.drawText(x, 10, "255");
+    davinci.drawText(rightX, scopeRect().height()-m_paddingBottom, "0");
+    davinci.drawText(rightX, 10, "255");
 
     emit signalHUDRenderingFinished(0, 1);
     return hud;
@@ -145,8 +176,8 @@ QImage Waveform::renderScope(uint accelFactor, QImage qimage)
 
     int paintmode = ui->paintMode->itemData(ui->paintMode->currentIndex()).toInt();
     WaveformGenerator::Rec rec = m_aRec601->isChecked() ? WaveformGenerator::Rec_601 : WaveformGenerator::Rec_709;
-    QImage wave = m_waveformGenerator->calculateWaveform(scopeRect().size() - m_textWidth, qimage, (WaveformGenerator::PaintMode) paintmode,
-                                                         true, rec, accelFactor);
+    QImage wave = m_waveformGenerator->calculateWaveform(scopeRect().size() - m_textWidth - QSize(0,m_paddingBottom), qimage,
+                                                         (WaveformGenerator::PaintMode) paintmode, true, rec, accelFactor);
 
     emit signalScopeRenderingFinished(start.elapsed(), 1);
     return wave;
index 3dbdead308739ecc83be4e94a69868aca9667757..e70f2f6563cfc1006e0f95622fecd5269e174450 100644 (file)
@@ -40,6 +40,7 @@ private:
     QActionGroup *m_agRec;
 
     static const QSize m_textWidth;
+    static const int m_paddingBottom;
 
     QImage m_waveform;