]> git.sesse.net Git - kdenlive/blobdiff - src/customruler.cpp
Integrate with the required MLT hooks for getting Movit to work.
[kdenlive] / src / customruler.cpp
index a02c2f6d98d76656ba64804789c4dff974aded1f..08370c21e1a973ae3719142c5fb85391067d694e 100644 (file)
@@ -50,7 +50,7 @@ static int bigMarkDistance;
 
 const int CustomRuler::comboScale[] = { 1, 2, 5, 10, 25, 50, 125, 250, 500, 750, 1500, 3000, 6000, 12000};
 
-CustomRuler::CustomRuler(Timecode tc, CustomTrackView *parent) :
+CustomRuler::CustomRuler(const Timecode &tc, CustomTrackView *parent) :
         QWidget(parent),
         m_timecode(tc),
         m_view(parent),
@@ -76,6 +76,7 @@ CustomRuler::CustomRuler(Timecode tc, CustomTrackView *parent) :
     updateFrameSize();
     m_scale = 3;
     m_zoneColor = KStatefulBrush(KColorScheme::View, KColorScheme::FocusColor, KSharedConfig::openConfig(KdenliveSettings::colortheme())).brush(this).color();
+    m_zoneColor.setAlpha(180);
     m_zoneStart = 0;
     m_zoneEnd = 100;
     m_contextMenu = new QMenu(this);
@@ -88,16 +89,17 @@ CustomRuler::CustomRuler(Timecode tc, CustomTrackView *parent) :
     QAction *delAllGuides = m_contextMenu->addAction(KIcon("edit-delete"), i18n("Delete All Guides"));
     connect(delAllGuides, SIGNAL(triggered()), m_view, SLOT(slotDeleteAllGuides()));
     m_goMenu = m_contextMenu->addMenu(i18n("Go To"));
-    connect(m_goMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotGoToGuide(QAction *)));
+    connect(m_goMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotGoToGuide(QAction*)));
     setMouseTracking(true);
 }
 
 void CustomRuler::updatePalette()
 {
     m_zoneColor = KStatefulBrush(KColorScheme::View, KColorScheme::FocusColor, KSharedConfig::openConfig(KdenliveSettings::colortheme())).brush(this).color();
+    m_zoneColor.setAlpha(180);
 }
 
-void CustomRuler::updateProjectFps(Timecode t)
+void CustomRuler::updateProjectFps(const Timecode &t)
 {
     m_timecode = t;
     mediumMarkDistance = FRAME_SIZE * m_timecode.fps();
@@ -131,7 +133,7 @@ void CustomRuler::slotGoToGuide(QAction *act)
     m_view->initCursorPos(act->data().toInt());
 }
 
-void CustomRuler::setZone(QPoint p)
+void CustomRuler::setZone(const QPoint &p)
 {
     m_zoneStart = p.x();
     m_zoneEnd = p.y();
@@ -179,11 +181,13 @@ void CustomRuler::mousePressEvent(QMouseEvent * event)
 // virtual
 void CustomRuler::mouseMoveEvent(QMouseEvent * event)
 {
+    int mappedXPos = (int)((event->x() + offset()) / m_factor);
+    emit mousePosition(mappedXPos);
     if (event->buttons() == Qt::LeftButton) {
         int pos;
         if (m_moveCursor == RULER_START || m_moveCursor == RULER_END) {
-            pos = m_view->getSnapPointForPos((int)((event->x() + offset()) / m_factor));
-        } else pos = (int)((event->x() + offset()) / m_factor);
+            pos = m_view->getSnapPointForPos(mappedXPos);
+        } else pos = mappedXPos;
         int zoneStart = m_zoneStart;
         int zoneEnd = m_zoneEnd;
         if (pos < 0) pos = 0;
@@ -222,10 +226,10 @@ void CustomRuler::mouseMoveEvent(QMouseEvent * event)
         int pos = (int)((event->x() + m_offset));
        if (m_cursorColor == palette().text() && qAbs(pos - m_view->cursorPos() * m_factor) < 7) {
            // Mouse is over cursor
-           m_cursorColor = palette().highlight();
+           m_cursorColor = palette().link();
            update(m_view->cursorPos() * m_factor - m_offset - 10, LABEL_SIZE + 2, 20, MAX_HEIGHT - LABEL_SIZE - 2);
        }
-       else if (m_cursorColor == palette().highlight() && qAbs(pos - m_view->cursorPos() * m_factor) >= 7) {
+       else if (m_cursorColor == palette().link() && qAbs(pos - m_view->cursorPos() * m_factor) >= 7) {
            m_cursorColor = palette().text();
            update(m_view->cursorPos() * m_factor - m_offset - 10, LABEL_SIZE + 2, 20, MAX_HEIGHT - LABEL_SIZE - 2);
        }
@@ -256,9 +260,9 @@ void CustomRuler::mouseMoveEvent(QMouseEvent * event)
 void CustomRuler::leaveEvent(QEvent * event)
 {
     QWidget::leaveEvent(event);
-    if (m_cursorColor == palette().highlight()) {
-       m_cursorColor = palette().text();
-       update();
+    if (m_cursorColor == palette().link()) {
+        m_cursorColor = palette().text();
+        update();
     }
 }
 
@@ -266,6 +270,7 @@ void CustomRuler::leaveEvent(QEvent * event)
 void CustomRuler::wheelEvent(QWheelEvent * e)
 {
     int delta = 1;
+    m_view->activateMonitor();
     if (e->modifiers() == Qt::ControlModifier) delta = m_timecode.fps();
     if (e->delta() < 0) delta = 0 - delta;
     m_view->moveCursorPos(delta);
@@ -283,8 +288,10 @@ int CustomRuler::outPoint() const
 
 void CustomRuler::slotMoveRuler(int newPos)
 {
-    m_offset = newPos;
-    update();
+    if (m_offset != newPos) {
+        m_offset = newPos;
+        update();
+    }
 }
 
 int CustomRuler::offset() const
@@ -489,7 +496,7 @@ void CustomRuler::paintEvent(QPaintEvent *e)
     p.drawPolygon(pa);
     
     if (m_lastSeekPosition != SEEK_INACTIVE && m_lastSeekPosition != m_view->cursorPos()) {
-       p.fillRect(m_lastSeekPosition * m_factor - m_offset - 1, BIG_MARK_X + 1, 3, MAX_HEIGHT - BIG_MARK_X - 1, palette().highlight());
+       p.fillRect(m_lastSeekPosition * m_factor - m_offset - 1, BIG_MARK_X + 1, 3, MAX_HEIGHT - BIG_MARK_X - 1, palette().linkVisited());
     }
 
 }