]> git.sesse.net Git - kdenlive/commitdiff
some progress on timeline view
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 20 Jan 2008 23:42:08 +0000 (23:42 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 20 Jan 2008 23:42:08 +0000 (23:42 +0000)
svn path=/branches/KDE4/; revision=1806

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

index 7912cbc938a87794824a242e936486f8a4addbdf..8cc20aea973e91f9e06378b9df6421dbd8313e9d 100644 (file)
@@ -51,7 +51,7 @@ int ClipItem::type () const
                            QWidget *widget)
  {
     painter->setClipRect( option->exposedRect );
-    painter->fillRect(rect(), Qt::red);
+    painter->fillRect(rect(), QColor(200, 50, 50, 150));
     //kDebug()<<"ITEM REPAINT RECT: "<<boundingRect().width();
     //painter->drawText(rect(), Qt::AlignCenter, m_name);
     painter->drawRect(rect());
index 4b26427cfa80019736f62805796bf4f0cde8db6e..57c2920841802f811de5d69ab022bb9300e94754 100644 (file)
@@ -91,7 +91,7 @@ CustomRuler::CustomRuler(Timecode tc, QWidget *parent)
 void CustomRuler::mousePressEvent ( QMouseEvent * event )
 {
   int pos = event->x();
-  slotNewValue( pos );
+  slotNewValue( pos, true );
   kDebug()<<pos;
 }
 
@@ -99,14 +99,14 @@ void CustomRuler::mousePressEvent ( QMouseEvent * event )
 void CustomRuler::mouseMoveEvent ( QMouseEvent * event )
 {
   int pos = event->x();
-  slotNewValue( pos );
+  slotNewValue( pos, true );
   kDebug()<<pos;
 }
 
-void CustomRuler::slotNewValue ( int _value )
+void CustomRuler::slotNewValue ( int _value, bool emitSignal )
 {
   m_cursorPosition = _value / pixelPerMark();
-  emit cursorMoved(m_cursorPosition / FRAME_SIZE);
+  if (emitSignal) emit cursorMoved(m_cursorPosition / FRAME_SIZE);
   KRuler::slotNewValue(_value);
 }
 
index ad468c8c12f5a1f6b5344ab38494dc1729bbfc0c..5ee1a38f8e712b24042a480418fad6201d13d2ca 100644 (file)
@@ -23,7 +23,7 @@ class CustomRuler : public KRuler
     Timecode m_timecode;
 
   public slots:
-    void slotNewValue ( int _value );
+    void slotNewValue ( int _value, bool emitSignal = false );
 
   signals:
     void cursorMoved(int);
index 376be5c7eda17bec7f101bc8cc6902da036f89f6..ea585553de3fb4105f8b1f46d2f5715173526db3 100644 (file)
@@ -23,6 +23,7 @@
 #include <QDomDocument>
 
 #include <KDebug>
+#include <KLocale>
 #include <KUrl>
 
 #include "customtrackview.h"
 #include "definitions.h"
 
 CustomTrackView::CustomTrackView(QGraphicsScene * scene, QWidget *parent)
-    : QGraphicsView(scene, parent), m_tracksCount(0), m_cursorPos(0), m_dropItem(NULL)
+    : QGraphicsView(scene, parent), m_tracksCount(0), m_cursorPos(0), m_dropItem(NULL), m_cursorLine(NULL)
 {
   setMouseTracking(true);
   setAcceptDrops(true);
 }
 
+void CustomTrackView::initView()
+{
+  m_cursorLine = scene()->addLine(0, 0, 0, height());
+}
+
+// virtual
+void CustomTrackView::resizeEvent ( QResizeEvent * event )
+{
+  if (m_cursorLine) m_cursorLine->setLine(m_cursorLine->line().x1(), 0, m_cursorLine->line().x1(), height());
+}
+
 // virtual 
 void CustomTrackView::mouseMoveEvent ( QMouseEvent * event )
 {
@@ -45,10 +57,16 @@ void CustomTrackView::mouseMoveEvent ( QMouseEvent * event )
   else if (event->modifiers() == Qt::ShiftModifier) 
     setDragMode(QGraphicsView::RubberBandDrag);
   else {
-    QGraphicsItem * item = itemAt(event->pos());
+    QList<QGraphicsItem *> itemList = items ( event->pos());
+    int i = 0;
+    QGraphicsItem *item = NULL;
+    for (int i = 0; i < itemList.count(); i++) {
+      if (itemList.at(i)->type() == 70000) {
+       item = itemList.at(i);
+       break;
+      }
+    }
     if (item) {
-      while (item->parentItem()) 
-       item = item->parentItem();
       int cursorPos = event->x();
       QRectF itemRect = item->sceneBoundingRect();
       int itemStart = mapFromScene(itemRect.x(), 0).x();
@@ -175,6 +193,7 @@ void CustomTrackView::removeTrack ()
 void CustomTrackView::setCursorPos(int pos)
 {
   m_cursorPos = pos;
+  m_cursorLine->setPos(pos, 0);
 }
 
 int CustomTrackView::cursorPos()
@@ -191,17 +210,19 @@ void CustomTrackView::mouseReleaseEvent ( QMouseEvent * event )
 void CustomTrackView::drawBackground ( QPainter * painter, const QRectF & rect )  
 {
   //kDebug()<<"/////  DRAWING BG: "<<rect.x()<<", width: "<<rect.width();
-  painter->drawRect(rect);
+  painter->drawLine(rect.x(), 0, rect.x() + rect.width(), 0);
     for (uint i = 0; i < m_tracksCount;i++)
     {
-      painter->drawLine(rect.x(), 50 * i, rect.x() + rect.width(), 50 * i);
+      painter->drawLine(rect.x(), 50 * (i+1), rect.x() + rect.width(), 50 * (i+1));
+      painter->drawText(QRectF(10, 50 * i, 100, 50 * i + 49), Qt::AlignLeft, i18n(" Track ") + QString::number(i));
     }
 }
-
+/*
 void CustomTrackView::drawForeground ( QPainter * painter, const QRectF & rect )  
 {
   //kDebug()<<"/////  DRAWING FB: "<<rect.x()<<", width: "<<rect.width();
+  painter->fillRect(rect, QColor(50, rand() % 250,50,100));
   painter->drawLine(m_cursorPos, rect.y(), m_cursorPos, rect.y() + rect.height());
 }
-
+*/
 #include "customtrackview.moc"
index 8d601acddc09149039e526f7da591b245b246b2d..d92b1a67174e065a2147445ac1a0d3ad330977a5 100644 (file)
@@ -38,22 +38,25 @@ class CustomTrackView : public QGraphicsView
     void removeTrack();
     void setCursorPos(int pos);
     int cursorPos();
+    void initView();
 
   protected:
     virtual void drawBackground ( QPainter * painter, const QRectF & rect );
-    virtual void drawForeground ( QPainter * painter, const QRectF & rect );
+    //virtual void drawForeground ( QPainter * painter, const QRectF & rect );
     virtual void dragEnterEvent ( QDragEnterEvent * event );
     virtual void dragMoveEvent(QDragMoveEvent * event);
     virtual void dragLeaveEvent ( QDragLeaveEvent * event );
     virtual void dropEvent ( QDropEvent * event );
     virtual QStringList mimeTypes() const;
     virtual Qt::DropActions supportedDropActions () const;
+    virtual void resizeEvent ( QResizeEvent * event );
 
   private:
     int m_tracksCount;
     int m_cursorPos;
     ClipItem *m_dropItem;
     void addItem(QString producer, QPoint pos);
+    QGraphicsLineItem *m_cursorLine;
 
   signals:
     void cursorMoved(int);
index 4547bf2ba0c536475aaa88de0dbb35d884f49c5f..ccde0a67a8bea64dacf5cb5e08f58bea10bfd21b 100644 (file)
@@ -27,7 +27,7 @@
 #include "labelitem.h"
 
 LabelItem::LabelItem(QString text, QGraphicsRectItem *parent)
-    : QGraphicsSimpleTextItem(text, parent)
+    : QGraphicsSimpleTextItem(" " + text + " ", parent)
 {
   //setParentItem(parent); 
   setFlags(QGraphicsItem::ItemIgnoresTransformations);
@@ -39,7 +39,7 @@ int LabelItem::type () const
 }
 
 // virtual 
-/*
+
  void LabelItem::paint(QPainter *painter,
                            const QStyleOptionGraphicsItem *option,
                            QWidget *widget)
@@ -56,13 +56,13 @@ int LabelItem::type () const
     //painter->setClipRect( par);
     //painter->fillRect(rect(), Qt::red);
     QPainterPath path;
-    path.addPolygon(mapFromParent(parentItem()->boundingRect()));
+    path.addRoundRect(boundingRect(), 40);
     //painter->fillPath(path, QColor(200, 100, 200, 150));
     //painter->setClipPath(path);
-    painter->fillRect(boundingRect(), QColor(200, 100, 200, 150));
+    painter->fillPath(path, QColor(200, 200, 200, 100));
     painter->drawText(boundingRect(), Qt::AlignCenter, text());
     //painter->drawRect(rect());
     //painter->drawRoundRect(-10, -10, 20, 20);
- }*/
+ }
 
 #include "labelitem.moc"
index 042a9e8aaae136b0d7f6c178a1590837953f78f4..3bfc61244f55a8dceaaedc0f653501164a3a8776 100644 (file)
@@ -30,7 +30,7 @@ class LabelItem : public QGraphicsSimpleTextItem
   
   public:
     LabelItem(QString text, QGraphicsRectItem *parent = 0);
-    //virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+    virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
     virtual int type () const;
 };
 
index fa770a59fd86aafd70cde71415aab0ff44aabfc8..8e2d70054d303a6445e81c743af7e3088d3fc1fa 100644 (file)
@@ -70,7 +70,7 @@ TrackView::TrackView(KdenliveDoc *doc, QWidget *parent)
   connect(m_ruler, SIGNAL(cursorMoved ( int )), this, SLOT(slotCursorMoved( int )));
   connect(m_trackview, SIGNAL(cursorMoved ( int )), this, SLOT(slotCursorMoved( int )));
 
-  m_cursorLine = m_scene->addLine(0, 0, 0, 200); //m_trackview->height());
+  m_trackview->initView();
 }
 
 void TrackView::registerFunction(const QString & name, TrackPanelFunction * function) 
@@ -109,10 +109,10 @@ void TrackView::parseDocument(QDomDocument doc)
 
 void TrackView::slotCursorMoved(int pos)
 {
-  kDebug()<<"///// CURSOR: "<<pos;
-  //m_cursorLine->setPos(pos, 0);
+  //kDebug()<<"///// CURSOR: "<<pos;
+  m_ruler->slotNewValue(m_trackview->mapToScene(QPoint(pos, 0)).x());
   m_trackview->setCursorPos(pos);
-  m_trackview->invalidateScene(QRectF(), QGraphicsScene::ForegroundLayer);
+  //m_trackview->invalidateScene(QRectF(), QGraphicsScene::ForegroundLayer);
 }
 
 void TrackView::slotChangeZoom(int factor)
index 8f82af1f15eeecad614f08b401165e9b4cad879e..5a816f50423f07441fff0617e50b296defe36337 100644 (file)
@@ -76,7 +76,7 @@ class TrackView : public QWidget
     QString m_editMode;
     QGraphicsScene *m_scene;
     uint m_currentZoom;
-    QGraphicsLineItem *m_cursorLine;
+
 
     KdenliveDoc *m_doc;
     QVBoxLayout *m_tracksLayout;