]> git.sesse.net Git - kdenlive/commitdiff
Start fixing timeline view/ruler sync
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 23 Jan 2008 00:40:38 +0000 (00:40 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 23 Jan 2008 00:40:38 +0000 (00:40 +0000)
svn path=/branches/KDE4/; revision=1817

src/customruler.cpp
src/customruler.h
src/customtrackview.cpp
src/customtrackview.h
src/trackview.cpp

index 57c2920841802f811de5d69ab022bb9300e94754..5e1069b36b3878f825749d0fa87a435699877698 100644 (file)
@@ -91,7 +91,7 @@ CustomRuler::CustomRuler(Timecode tc, QWidget *parent)
 void CustomRuler::mousePressEvent ( QMouseEvent * event )
 {
   int pos = event->x();
-  slotNewValue( pos, true );
+  slotMoveCursor( pos, true );
   kDebug()<<pos;
 }
 
@@ -99,15 +99,31 @@ void CustomRuler::mousePressEvent ( QMouseEvent * event )
 void CustomRuler::mouseMoveEvent ( QMouseEvent * event )
 {
   int pos = event->x();
-  slotNewValue( pos, true );
+  slotMoveCursor( pos, true );
   kDebug()<<pos;
 }
 
+void CustomRuler::slotMoveRuler(int newPos)
+{
+  int diff = offset() - newPos;
+  KRuler::slotNewOffset(newPos);
+  KRuler::slotNewValue(value() + diff);
+}
+
+void CustomRuler::slotMoveCursor( int _value, bool emitSignal )
+{
+  KRuler::slotNewValue(_value );
+  m_cursorPosition= (_value + offset()) / pixelPerMark();
+  if (emitSignal) emit cursorMoved(m_cursorPosition / FRAME_SIZE);
+}
+
+
 void CustomRuler::slotNewValue ( int _value, bool emitSignal )
 {
-  m_cursorPosition = _value / pixelPerMark();
+  kDebug()<<"--------------  SET NEW CURSOR: "<<_value;
+  m_cursorPosition= _value / pixelPerMark();
   if (emitSignal) emit cursorMoved(m_cursorPosition / FRAME_SIZE);
-  KRuler::slotNewValue(_value);
+  KRuler::slotNewValue(_value* pixelPerMark() - offset());
 }
 
 void CustomRuler::setPixelPerMark (double rate)
index 5ee1a38f8e712b24042a480418fad6201d13d2ca..e4b1affcb560e4806e2541df00ed5c361a3e975a 100644 (file)
@@ -21,9 +21,12 @@ class CustomRuler : public KRuler
   private:
     int m_cursorPosition;
     Timecode m_timecode;
+    void slotMoveCursor( int _value, bool emitSignal );
 
   public slots:
     void slotNewValue ( int _value, bool emitSignal = false );
+    void slotMoveRuler (int newPos);
+
 
   signals:
     void cursorMoved(int);
index 142334764f4f4b5a2767677845faa4676a67cf73..6258358a16d1930bb26da87ab5e63bb9496b3f9d 100644 (file)
@@ -255,7 +255,8 @@ void CustomTrackView::mousePressEvent ( QMouseEvent * event )
       kDebug()<<"//////// NO ITEMĀ FOUND ON CLICK";
       m_dragItem = NULL;
       setCursor(Qt::ArrowCursor);
-      emit cursorMoved((int) mapToScene(event->x(), 0).x());
+      setCursorPos((int) mapToScene(event->x(), 0).x());
+      emit cursorMoved(cursorPos());
     }
   }
   //kDebug()<<pos;
index 22e71dc84d342709436a6ee601c691efb97cac28..3b8057e7b24739704e6b63e0044da733569f1c7c 100644 (file)
@@ -40,7 +40,6 @@ class CustomTrackView : public QGraphicsView
     virtual void mouseMoveEvent ( QMouseEvent * event );
     void addTrack();
     void removeTrack();
-    void setCursorPos(int pos);
     int cursorPos();
     void initView();
     void moveClip ( const QPointF &startPos, const QPointF &endPos );
@@ -48,6 +47,9 @@ class CustomTrackView : public QGraphicsView
     void addClip ( int clipType, QString clipName, int clipProducer, int maxDuration, const QRectF &rect );
     void deleteClip ( const QRectF &rect );
 
+  public slots:
+    void setCursorPos(int pos);
+
   protected:
     virtual void drawBackground ( QPainter * painter, const QRectF & rect );
     //virtual void drawForeground ( QPainter * painter, const QRectF & rect );
index dbf9123eede79df75a9f48adb7145ed26af40edc..6a48058c83f2f65886749ecd52f5dfda976b6e72 100644 (file)
@@ -67,10 +67,11 @@ TrackView::TrackView(KdenliveDoc *doc, QWidget *parent)
   view->horizontalSlider->setValue(0);
   m_currentZoom = view->horizontalSlider->value();
   connect(view->horizontalSlider, SIGNAL(valueChanged ( int )), this, SLOT(slotChangeZoom( int )));
-  connect(m_ruler, SIGNAL(cursorMoved ( int )), this, SLOT(slotCursorMoved( int )));
+  connect(m_ruler, SIGNAL(cursorMoved ( int )), m_trackview, SLOT(setCursorPos( int )));
   connect(m_trackview, SIGNAL(cursorMoved ( int )), this, SLOT(slotCursorMoved( int )));
   connect(m_trackview, SIGNAL(zoomIn ()), this, SLOT(slotZoomIn()));
   connect(m_trackview, SIGNAL(zoomOut ()), this, SLOT(slotZoomOut()));
+  connect(m_trackview->horizontalScrollBar(), SIGNAL(sliderMoved( int )), m_ruler, SLOT(slotMoveRuler( int )));
   m_trackview->initView();
 }
 
@@ -110,9 +111,9 @@ void TrackView::parseDocument(QDomDocument doc)
 
 void TrackView::slotCursorMoved(int pos)
 {
-  //kDebug()<<"///// CURSOR: "<<pos;
-  m_ruler->slotNewValue(m_trackview->mapToScene(QPoint(pos, 0)).x());
-  m_trackview->setCursorPos(pos);
+  kDebug()<<"///// CURSOR: "<<pos;
+  m_ruler->slotNewValue(pos * FRAME_SIZE); //(int) m_trackview->mapToScene(QPoint(pos, 0)).x());
+  //m_trackview->setCursorPos(pos);
   //m_trackview->invalidateScene(QRectF(), QGraphicsScene::ForegroundLayer);
 }