]> git.sesse.net Git - kdenlive/commitdiff
Add vertical timeline zoom:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Thu, 18 Jun 2009 17:01:22 +0000 (17:01 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Thu, 18 Jun 2009 17:01:22 +0000 (17:01 +0000)
http://kdenlive.org/mantis/view.php?id=380

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

src/customtrackview.cpp
src/customtrackview.h
src/headertrack.cpp
src/kdenlivesettings.kcfg
src/mainwindow.cpp
src/trackview.cpp
src/trackview.h

index e17a3228884a382c8ba5c806e2d7a193a5a46090..e2c07e64712a13255dcd9d6868d2bf43b5cede55 100644 (file)
@@ -84,7 +84,7 @@
 
 CustomTrackView::CustomTrackView(KdenliveDoc *doc, CustomTrackScene* projectscene, QWidget *parent) :
         QGraphicsView(projectscene, parent),
-        m_tracksHeight(KdenliveSettings::trackheight()),
+        m_tracksHeight(KdenliveSettings::defaulttrackheight()),
         m_projectDuration(0),
         m_cursorPos(0),
         m_document(doc),
@@ -114,6 +114,7 @@ CustomTrackView::CustomTrackView(KdenliveDoc *doc, CustomTrackScene* projectscen
     else m_commandStack = NULL;
     setMouseTracking(true);
     setAcceptDrops(true);
+    KdenliveSettings::setTrackheight(m_tracksHeight);
     m_animationTimer = new QTimeLine(800);
     m_animationTimer->setFrameRange(0, 5);
     m_animationTimer->setUpdateInterval(100);
@@ -197,11 +198,14 @@ void CustomTrackView::checkAutoScroll()
     return m_scene->m_tracksList;
 }*/
 
-void CustomTrackView::checkTrackHeight()
+void CustomTrackView::checkTrackHeight(bool resetTrackHeight)
 {
+    if (resetTrackHeight) {
+        KdenliveSettings::setTrackheight(KdenliveSettings::defaulttrackheight());
+    }
     if (m_tracksHeight == KdenliveSettings::trackheight()) return;
     m_tracksHeight = KdenliveSettings::trackheight();
-    emit trackHeightChanged();
+    emit trackHeightChanged(resetTrackHeight);
     QList<QGraphicsItem *> itemList = items();
     ClipItem *item;
     Transition *transitionitem;
@@ -230,7 +234,7 @@ void CustomTrackView::checkTrackHeight()
     setSceneRect(0, 0, sceneRect().width(), m_tracksHeight * m_document->tracksCount());
 //     verticalScrollBar()->setMaximum(m_tracksHeight * m_document->tracksCount());
     KdenliveSettings::setSnaptopoints(snap);
-    update();
+    viewport()->update();
 }
 
 /** Zoom or move viewport on mousewheel
@@ -588,7 +592,7 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event)
 // virtual
 void CustomTrackView::mousePressEvent(QMouseEvent * event)
 {
-    kDebug() << "mousePressEvent STARTED";
+    //kDebug() << "mousePressEvent STARTED";
     setFocus(Qt::MouseFocusReason);
     m_menuPosition = QPoint();
 
@@ -1867,7 +1871,7 @@ void CustomTrackView::addTrack(TrackInfo type, int ix)
     }
     m_cursorLine->setLine(m_cursorLine->line().x1(), 0, m_cursorLine->line().x1(), maxHeight);
     setSceneRect(0, 0, sceneRect().width(), maxHeight);
-    QTimer::singleShot(300, this, SIGNAL(trackHeightChanged()));
+    QTimer::singleShot(300, this, SIGNAL(trackHeightChanged(false)));
     viewport()->update();
     //setFixedHeight(50 * m_tracksCount);
 }
@@ -1932,7 +1936,7 @@ void CustomTrackView::removeTrack(int ix)
     }
     m_cursorLine->setLine(m_cursorLine->line().x1(), 0, m_cursorLine->line().x1(), maxHeight);
     setSceneRect(0, 0, sceneRect().width(), maxHeight);
-    QTimer::singleShot(300, this, SIGNAL(trackHeightChanged()));
+    QTimer::singleShot(300, this, SIGNAL(trackHeightChanged(false)));
     viewport()->update();
 }
 
@@ -1941,7 +1945,7 @@ void CustomTrackView::changeTrack(int ix, TrackInfo type)
     int tracknumber = m_document->tracksCount() - ix;
     m_document->setTrackType(tracknumber - 1, type);
     m_document->renderer()->mltChangeTrackState(tracknumber, m_document->trackInfoAt(tracknumber - 1).isMute, m_document->trackInfoAt(tracknumber - 1).isBlind);
-    QTimer::singleShot(300, this, SIGNAL(trackHeightChanged()));
+    QTimer::singleShot(300, this, SIGNAL(trackHeightChanged(false)));
     viewport()->update();
 }
 
@@ -2291,7 +2295,7 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event)
         resetSelectionGroup(false);
         m_operationMode = NONE;
     } else if (m_operationMode == RUBBERSELECTION) {
-        kDebug() << "// END RUBBER SELECT";
+        //kDebug() << "// END RUBBER SELECT";
         resetSelectionGroup();
         groupSelectedItems();
         m_operationMode = NONE;
@@ -2505,7 +2509,7 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event)
                 m_document->setModified(true);
             }
         }
-
+        m_document->renderer()->doRefresh();
     } else if (m_operationMode == RESIZESTART && m_dragItem->startPos() != m_dragItemInfo.startPos) {
         // resize start
         if (m_dragItem->type() == AVWIDGET) {
@@ -3148,7 +3152,8 @@ void CustomTrackView::moveClip(const ItemInfo start, const ItemInfo end)
         // undo last move and emit error message
         emit displayMessage(i18n("Cannot move clip to position %1", m_document->timecode().getTimecodeFromFrames(end.startPos.frames(m_document->fps()))), ErrorMessage);
     }
-    kDebug() << " // MOVED CLIP TO: " << end.startPos.frames(25) << ", ITEM START: " << item->startPos().frames(25);
+    m_document->renderer()->doRefresh();
+    //kDebug() << " // MOVED CLIP TO: " << end.startPos.frames(25) << ", ITEM START: " << item->startPos().frames(25);
 }
 
 void CustomTrackView::moveGroup(QList <ItemInfo> startClip, QList <ItemInfo> startTransition, const GenTime offset, const int trackOffset, bool reverseMove)
@@ -3239,6 +3244,7 @@ void CustomTrackView::moveGroup(QList <ItemInfo> startClip, QList <ItemInfo> sta
             }
         }
         KdenliveSettings::setSnaptopoints(snap);
+        m_document->renderer()->doRefresh();
     } else kDebug() << "///////// WARNING; NO GROUP TO MOVE";
 }
 
@@ -3283,6 +3289,7 @@ void CustomTrackView::moveTransition(const ItemInfo start, const ItemInfo end)
         }
         emit transitionItemSelected(item, getPreviousVideoTrack(item->track()), p);
     }
+    m_document->renderer()->doRefresh();
 }
 
 void CustomTrackView::resizeClip(const ItemInfo start, const ItemInfo end)
@@ -3751,7 +3758,7 @@ void CustomTrackView::slotRefreshGuides()
     }
 }
 
-void CustomTrackView::drawBackground(QPainter * painter, const QRectF & rect)
+void CustomTrackView::drawBackground(QPainter * painter, const QRectF &rect)
 {
     QRectF r = rect;
     r.setWidth(r.width() + 1);
index 3ed0fc76a558ba8056a9d7a1bd7726d91f461937..7990df41d5ab8e63cc18b7172a067a5a6d0d6a91 100644 (file)
@@ -81,7 +81,7 @@ public:
     void deleteSelectedClips();
     void cutSelectedClips();
     void setContextMenu(QMenu *timeline, QMenu *clip, QMenu *transition, QActionGroup *clipTypeGroup);
-    void checkTrackHeight();
+    void checkTrackHeight(bool resetTrackHeight = false);
     //QList <TrackInfo> tracksList() const;
     void setTool(PROJECTTOOL tool);
     void cutClip(ItemInfo info, GenTime cutTime, bool cut);
@@ -265,7 +265,7 @@ signals:
     void clipItemSelected(ClipItem*, int ix = -1);
     void transitionItemSelected(Transition*, int track = 0, QPoint p = QPoint(), bool update = false);
     void activateDocumentMonitor();
-    void trackHeightChanged();
+    void trackHeightChanged(bool zoom);
     void displayMessage(const QString, MessageType);
     void showClipFrame(DocClipBase *, const int);
     void doTrackLock(int, bool);
index af41b01525a61ad97bdce7f27dc3f526d8cecf3a..607d5ab06336af1d54f9844f2db64f978a9c4726 100644 (file)
@@ -38,6 +38,7 @@ HeaderTrack::HeaderTrack(int index, TrackInfo info, QWidget *parent) :
     setFixedHeight(KdenliveSettings::trackheight());
     m_view.setupUi(this);
     m_view.track_number->setText(QString::number(m_index));
+
     m_view.buttonVideo->setChecked(!info.isBlind);
     m_view.buttonVideo->setToolTip(i18n("Hide track"));
     m_view.buttonAudio->setChecked(!info.isMute);
@@ -63,6 +64,14 @@ HeaderTrack::HeaderTrack(int index, TrackInfo info, QWidget *parent) :
     connect(m_view.buttonAudio, SIGNAL(clicked()), this, SLOT(switchAudio()));
     connect(m_view.buttonLock, SIGNAL(clicked()), this, SLOT(switchLock()));
 
+    // Don't show track buttons if size is too small
+    if (KdenliveSettings::trackheight() < 40) {
+        m_view.buttonVideo->setHidden(true);
+        m_view.buttonAudio->setHidden(true);
+        m_view.buttonLock->setHidden(true);
+        //m_view.horizontalSpacer;
+    }
+
     setContextMenuPolicy(Qt::ActionsContextMenu);
     QAction *insertAction = new QAction(i18n("Insert Track"), this);
     addAction(insertAction);
index 693a449d8dc05432172daef641606fd6bfba13e9..74998a8bd6cdddb4148aa555d5807ecf767abdd2 100644 (file)
@@ -75,7 +75,7 @@
       <default>true</default>
     </entry>
 
-    <entry name="trackheight" type="Int">
+    <entry name="defaulttrackheight" type="Int">
       <label>Tracks height in pixel.</label>
       <default>50</default>
     </entry>
 
 
   <group name="unmanaged">
+    <entry name="trackheight" type="Int">
+      <label>Tracks height in pixel.</label>
+      <default>50</default>
+    </entry>
+
     <entry name="project_display_ratio" type="Double">
       <label>Current project display ratio.</label>
       <default>1.7777778</default>
index 7477b95d611c3bdd828e4a0415a010cdcb2aa025..0cf498daa50fa244e4f599fe293ef677de64d637 100644 (file)
@@ -1976,7 +1976,7 @@ void MainWindow::updateConfiguration()
     if (m_activeTimeline) {
         m_activeTimeline->refresh();
         m_activeTimeline->projectView()->checkAutoScroll();
-        m_activeTimeline->projectView()->checkTrackHeight();
+        m_activeTimeline->projectView()->checkTrackHeight(true);
         if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
     }
     m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
index 1316483d26c4585a016438f6485b82399d1c38dc..c163f34d245938e03a126ce37e3e4d57ffeba575 100644 (file)
@@ -40,7 +40,8 @@ TrackView::TrackView(KdenliveDoc *doc, QWidget *parent) :
         QWidget(parent),
         m_scale(1.0),
         m_projectTracks(0),
-        m_doc(doc)
+        m_doc(doc),
+        m_verticalZoom(1)
 {
 
     m_view.setupUi(this);
@@ -59,6 +60,26 @@ TrackView::TrackView(KdenliveDoc *doc, QWidget *parent) :
     m_view.ruler_frame->setLayout(layout);
     layout->addWidget(m_ruler);
 
+
+    QHBoxLayout *sizeLayout = new QHBoxLayout;
+    sizeLayout->setContentsMargins(0, 0, 0, 0);
+    sizeLayout->setSpacing(0);
+    m_view.size_frame->setLayout(sizeLayout);
+
+    QString style1 = "QToolButton {border-style: none;margin: 0px 3px;padding: 0px;} QToolButton:pressed:hover { background-color: rgba(224, 224, 0, 100); border-style: inset; border:1px solid #cc6666;border-radius: 3px;} QToolButton:hover { background-color: rgba(255, 255, 255, 100); border-style: inset; border:1px solid #cc6666;border-radius: 3px;}";
+
+    QToolButton *butSmall = new QToolButton(this);
+    butSmall->setIcon(KIcon("kdenlive-zoom-small"));
+    connect(butSmall, SIGNAL(clicked()), this, SLOT(slotVerticalZoomDown()));
+    sizeLayout->addWidget(butSmall);
+
+    QToolButton *butLarge = new QToolButton(this);
+    butLarge->setIcon(KIcon("kdenlive-zoom-large"));
+    connect(butLarge, SIGNAL(clicked()), this, SLOT(slotVerticalZoomUp()));
+    sizeLayout->addWidget(butLarge);
+    m_view.size_frame->setStyleSheet(style1);
+
+
     QHBoxLayout *tracksLayout = new QHBoxLayout;
     tracksLayout->setContentsMargins(0, 0, 0, 0);
     tracksLayout->setSpacing(0);
@@ -77,7 +98,7 @@ TrackView::TrackView(KdenliveDoc *doc, QWidget *parent) :
     tracksLayout->addWidget(m_trackview);
 
     connect(m_trackview->verticalScrollBar(), SIGNAL(valueChanged(int)), m_view.headers_area->verticalScrollBar(), SLOT(setValue(int)));
-    connect(m_trackview, SIGNAL(trackHeightChanged()), this, SLOT(slotRebuildTrackHeaders()));
+    connect(m_trackview, SIGNAL(trackHeightChanged(bool)), this, SLOT(slotRebuildTrackHeaders(bool)));
 
     parseDocument(m_doc->toXml());
     m_doc->setSceneList();
@@ -90,6 +111,11 @@ TrackView::TrackView(KdenliveDoc *doc, QWidget *parent) :
     slotSetZone(m_doc->zone());
 }
 
+TrackView::~TrackView()
+{
+    delete m_ruler;
+    delete m_trackview;
+}
 
 int TrackView::duration() const
 {
@@ -345,12 +371,12 @@ void TrackView::parseDocument(QDomDocument doc)
     m_trackview->loadGroups(groups);
     m_trackview->setDuration(duration);
     kDebug() << "///////////  TOTAL PROJECT DURATION: " << duration;
-    
+
     // Remove Kdenlive extra info from xml doc before sending it to MLT
     QDomElement mlt = doc.firstChildElement("mlt");
     QDomElement infoXml = mlt.firstChildElement("kdenlivedoc");
     mlt.removeChild(infoXml);
-    
+
     slotRebuildTrackHeaders();
     if (!m_documentErrors.isNull()) KMessageBox::sorry(this, m_documentErrors);
     //m_trackview->setCursorPos(cursorPos);
@@ -399,8 +425,10 @@ void TrackView::refresh()
     m_trackview->viewport()->update();
 }
 
-void TrackView::slotRebuildTrackHeaders()
+void TrackView::slotRebuildTrackHeaders(bool resetZoom)
 {
+    // If the slot was triggered by a change in default track size, reset vertical zoom
+    if (resetZoom) m_verticalZoom = 1;
     QList <TrackInfo> list = m_doc->tracksList();
     QLayoutItem *child;
     while ((child = m_headersLayout->takeAt(0)) != 0) {
@@ -418,7 +446,7 @@ void TrackView::slotRebuildTrackHeaders()
         connect(header, SIGNAL(changeTrack(int)), this, SIGNAL(changeTrack(int)));
         m_headersLayout->addWidget(header);
     }
-    m_view.headers_container->adjustSize();
+    //m_view.headers_container->adjustSize();
 }
 
 
@@ -731,5 +759,20 @@ void TrackView::slotChangeTrackLock(int ix, bool lock)
     widgets.at(ix)->setLock(lock);
 }
 
+void TrackView::slotVerticalZoomDown()
+{
+    if (m_verticalZoom == 0) return;
+    m_verticalZoom--;
+    KdenliveSettings::setTrackheight(KdenliveSettings::trackheight() / 2);
+    m_trackview->checkTrackHeight(false);
+}
+
+void TrackView::slotVerticalZoomUp()
+{
+    if (m_verticalZoom == 2) return;
+    m_verticalZoom++;
+    KdenliveSettings::setTrackheight(KdenliveSettings::trackheight() * 2);
+    m_trackview->checkTrackHeight(false);
+}
 
 #include "trackview.moc"
index 5358fc1baaddba604cc54bd08eed87c521e1ecaa..514cdd880c54d3f9e7391148a73dd2f141974195 100644 (file)
@@ -46,7 +46,7 @@ class TrackView : public QWidget
 
 public:
     explicit TrackView(KdenliveDoc *doc, QWidget *parent = 0);
-
+    virtual ~ TrackView();
     void setEditMode(const QString & editMode);
     const QString & editMode() const;
     QGraphicsScene *projectScene();
@@ -76,6 +76,7 @@ private:
     CustomTrackScene *m_scene;
 
     KdenliveDoc *m_doc;
+    int m_verticalZoom;
     QVBoxLayout *m_headersLayout;
     QString m_documentErrors;
     void parseDocument(QDomDocument doc);
@@ -85,8 +86,10 @@ private:
 private slots:
     void setCursorPos(int pos);
     void moveCursorPos(int pos);
-    void slotRebuildTrackHeaders();
+    void slotRebuildTrackHeaders(bool resetZoom = false);
     void slotChangeTrackLock(int ix, bool lock);
+    void slotVerticalZoomDown();
+    void slotVerticalZoomUp();
 
 signals:
     void mousePosition(int);