]> git.sesse.net Git - kdenlive/commitdiff
Rewrote correct implementation of vertical timeline zoom
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Thu, 18 Jun 2009 17:41:32 +0000 (17:41 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Thu, 18 Jun 2009 17:41:32 +0000 (17:41 +0000)
svn path=/trunk/kdenlive/; revision=3580

13 files changed:
src/clipitem.cpp
src/customtrackscene.cpp
src/customtrackscene.h
src/customtrackview.cpp
src/customtrackview.h
src/guide.cpp
src/headertrack.cpp
src/headertrack.h
src/kdenlivesettings.kcfg
src/mainwindow.cpp
src/trackview.cpp
src/trackview.h
src/transition.cpp

index a962bf96b9b8c6cb14e0392f181f87bf66180e58..bbe0c1fb295412552e275c4d8954a93df455dee7 100644 (file)
@@ -512,7 +512,7 @@ void ClipItem::slotThumbReady(int frame, QPixmap pix)
 {
     if (scene() == NULL) return;
     QRectF r = boundingRect();
-    double width = pix.width() / projectScene()->scale();
+    double width = pix.width() / projectScene()->scale().x();
     if (m_startThumbRequested && frame == cropStart().frames(m_fps)) {
         m_startPix = pix;
         m_startThumbRequested = false;
@@ -874,7 +874,7 @@ OPERATIONTYPE ClipItem::operationMode(QPointF pos)
         if (m_editedKeyframe != -1) return KEYFRAME;
     }
     QRectF rect = sceneBoundingRect();
-    const double scale = projectScene()->scale();
+    const double scale = projectScene()->scale().x();
     double maximumOffset = 6 / scale;
 
     if (qAbs((int)(pos.x() - (rect.x() + m_startFade))) < maximumOffset  && qAbs((int)(pos.y() - rect.y())) < 6) {
@@ -1078,7 +1078,7 @@ void ClipItem::hoverEnterEvent(QGraphicsSceneHoverEvent */*e*/)
     if (isItemLocked()) return;
     m_hover = true;
     QRectF r = boundingRect();
-    double width = 35 / projectScene()->scale();
+    double width = 35 / projectScene()->scale().x();
     double height = r.height() / 2;
     //WARNING: seems like it generates a full repaint of the clip, maybe not so good...
     update(r.x(), r.y() + height, width, height);
@@ -1091,7 +1091,7 @@ void ClipItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *)
     if (isItemLocked()) return;
     m_hover = false;
     QRectF r = boundingRect();
-    double width = 35 / projectScene()->scale();
+    double width = 35 / projectScene()->scale().x();
     double height = r.height() / 2;
     //WARNING: seems like it generates a full repaint of the clip, maybe not so good...
     update(r.x(), r.y() + height, width, height);
index eff285956c208b1c9dcc54c11ac98f6b9e3a6d47..7a3209e42efe79ffbb8497a9807b80239f687a5f 100644 (file)
@@ -25,7 +25,7 @@
 CustomTrackScene::CustomTrackScene(KdenliveDoc *doc, QObject *parent) :
         QGraphicsScene(parent),
         m_document(doc),
-        m_scale(1.0)
+        m_scale(1.0, 1.0)
 {
     m_transitionPixmap = QPixmap(KStandardDirs::locate("appdata", "transition.png"));
 }
@@ -38,8 +38,8 @@ double CustomTrackScene::getSnapPointForPos(double pos, bool doSnap)
 {
     double maximumOffset;
     if (doSnap) {
-        if (m_scale > 3) maximumOffset = 10 / m_scale;
-        else maximumOffset = 6 / m_scale;
+        if (m_scale.x() > 3) maximumOffset = 10 / m_scale.x();
+        else maximumOffset = 6 / m_scale.x();
         for (int i = 0; i < m_snapPoints.size(); ++i) {
             if (qAbs((int)(pos - m_snapPoints.at(i).frames(m_document->fps()))) < maximumOffset) {
                 return m_snapPoints.at(i).frames(m_document->fps());
@@ -76,12 +76,13 @@ GenTime CustomTrackScene::nextSnapPoint(GenTime pos)
     return pos;
 }
 
-void CustomTrackScene::setScale(double scale)
+void CustomTrackScene::setScale(double scale, double vscale)
 {
-    m_scale = scale;
+    m_scale.setX(scale);
+    m_scale.setY(vscale);
 }
 
-double CustomTrackScene::scale() const
+QPointF CustomTrackScene::scale() const
 {
     return m_scale;
 }
index 822a0676f5ee9d177618b832fd4882a9f54b555a..eb22ec90c6e3e435f3c788ab3c657795069a880f 100644 (file)
@@ -42,15 +42,15 @@ public:
     GenTime previousSnapPoint(GenTime pos);
     GenTime nextSnapPoint(GenTime pos);
     double getSnapPointForPos(double pos, bool doSnap = true);
-    void setScale(double scale);
-    double scale() const;
+    void setScale(double scale, double vscale);
+    QPointF scale() const;
     int tracksCount() const;
     QPixmap m_transitionPixmap;
 
 private:
     KdenliveDoc *m_document;
     QList <GenTime> m_snapPoints;
-    double m_scale;
+    QPointF m_scale;
 };
 
 #endif
index e2c07e64712a13255dcd9d6868d2bf43b5cede55..0a88b2a97ac69ffc9ba3b2d1e020224a923c9ccc 100644 (file)
@@ -84,7 +84,7 @@
 
 CustomTrackView::CustomTrackView(KdenliveDoc *doc, CustomTrackScene* projectscene, QWidget *parent) :
         QGraphicsView(projectscene, parent),
-        m_tracksHeight(KdenliveSettings::defaulttrackheight()),
+        m_tracksHeight(KdenliveSettings::trackheight()),
         m_projectDuration(0),
         m_cursorPos(0),
         m_document(doc),
@@ -198,14 +198,11 @@ void CustomTrackView::checkAutoScroll()
     return m_scene->m_tracksList;
 }*/
 
-void CustomTrackView::checkTrackHeight(bool resetTrackHeight)
+void CustomTrackView::checkTrackHeight()
 {
-    if (resetTrackHeight) {
-        KdenliveSettings::setTrackheight(KdenliveSettings::defaulttrackheight());
-    }
     if (m_tracksHeight == KdenliveSettings::trackheight()) return;
     m_tracksHeight = KdenliveSettings::trackheight();
-    emit trackHeightChanged(resetTrackHeight);
+    emit trackHeightChanged();
     QList<QGraphicsItem *> itemList = items();
     ClipItem *item;
     Transition *transitionitem;
@@ -3724,11 +3721,12 @@ void CustomTrackView::setTool(PROJECTTOOL tool)
     m_tool = tool;
 }
 
-void CustomTrackView::setScale(double scaleFactor)
+void CustomTrackView::setScale(double scaleFactor, double verticalScale)
 {
     QMatrix matrix;
-    matrix = matrix.scale(scaleFactor, 1);
-    m_scene->setScale(scaleFactor);
+    matrix = matrix.scale(scaleFactor, verticalScale);
+    m_scene->setScale(scaleFactor, verticalScale);
+    kDebug() << "// Set SCALE: " << scaleFactor << "," << verticalScale;
     //scale(scaleFactor, 1);
     m_animationTimer->stop();
     delete m_visualTip;
index 7990df41d5ab8e63cc18b7172a067a5a6d0d6a91..290159ecb0d0d44618bcf672988d55b7778ee776 100644 (file)
@@ -64,7 +64,7 @@ public:
     void slotDeleteClipMarker(const QString &comment, const QString &id, const GenTime &position);
     void slotDeleteAllClipMarkers(const QString &id);
     void addMarker(const QString &id, const GenTime &pos, const QString comment);
-    void setScale(double scaleFactor);
+    void setScale(double scaleFactor, double verticalScale);
     void deleteClip(const QString &clipId);
     void slotAddEffect(QDomElement effect, GenTime pos, int track);
     void slotAddGroupEffect(QDomElement effect, AbstractGroupItem *group);
@@ -81,7 +81,7 @@ public:
     void deleteSelectedClips();
     void cutSelectedClips();
     void setContextMenu(QMenu *timeline, QMenu *clip, QMenu *transition, QActionGroup *clipTypeGroup);
-    void checkTrackHeight(bool resetTrackHeight = false);
+    void checkTrackHeight();
     //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(bool zoom);
+    void trackHeightChanged();
     void displayMessage(const QString, MessageType);
     void showClipFrame(DocClipBase *, const int);
     void doTrackLock(int, bool);
index 0e55e9017ecd30375622b7b51746d79552d24243..4fbc53b9bbe550177836c0b66b702a18f490894b 100644 (file)
@@ -111,7 +111,7 @@ QRectF Guide::boundingRect() const
     if (KdenliveSettings::showmarkers()) {
         QRectF rect = QGraphicsLineItem::boundingRect();
         rect.setLeft(line().x1());
-        rect.setWidth(m_width / static_cast <CustomTrackScene*>(scene())->scale());
+        rect.setWidth(m_width / static_cast <CustomTrackScene*>(scene())->scale().x());
         return rect;
     } else return QGraphicsLineItem::boundingRect();
 }
@@ -124,7 +124,7 @@ QPainterPath Guide::shape() const
     if (KdenliveSettings::showmarkers()) {
         const QFontMetrics metric = m_view->fontMetrics();
         int height = metric.height();
-        path.addRoundedRect(line().x1(), line().y1() + 10, m_width / static_cast <CustomTrackScene*>(scene())->scale(), height, 3, 3);
+        path.addRoundedRect(line().x1(), line().y1() + 10, m_width / static_cast <CustomTrackScene*>(scene())->scale().x(), height, 3, 3);
     }
     return path;
 }
index 607d5ab06336af1d54f9844f2db64f978a9c4726..c158ba04c78ab7edc39db2e640ae9d7d60fecde7 100644 (file)
@@ -19,7 +19,6 @@
 
 
 #include "headertrack.h"
-#include "kdenlivesettings.h"
 
 #include <KIcon>
 #include <KLocale>
 #include <QPainter>
 #include <QAction>
 
-HeaderTrack::HeaderTrack(int index, TrackInfo info, QWidget *parent) :
+HeaderTrack::HeaderTrack(int index, TrackInfo info, int height, QWidget *parent) :
         QWidget(parent),
         m_index(index),
         m_type(info.type)
 {
-    setFixedHeight(KdenliveSettings::trackheight());
+    setFixedHeight(height);
     m_view.setupUi(this);
     m_view.track_number->setText(QString::number(m_index));
 
@@ -65,7 +64,7 @@ HeaderTrack::HeaderTrack(int index, TrackInfo info, QWidget *parent) :
     connect(m_view.buttonLock, SIGNAL(clicked()), this, SLOT(switchLock()));
 
     // Don't show track buttons if size is too small
-    if (KdenliveSettings::trackheight() < 40) {
+    if (height < 40) {
         m_view.buttonVideo->setHidden(true);
         m_view.buttonAudio->setHidden(true);
         m_view.buttonLock->setHidden(true);
index 27a6373a9491554379a13d00f12e73b8c97b2567..70bcd8a7c3e58ac2f186e7b033e6fb94d4602601 100644 (file)
@@ -31,7 +31,7 @@ class HeaderTrack : public QWidget
     Q_OBJECT
 
 public:
-    HeaderTrack(int index, TrackInfo info, QWidget *parent = 0);
+    HeaderTrack(int index, TrackInfo info, int height, QWidget *parent = 0);
     ~HeaderTrack();
     void setLock(bool lock);
 
index 74998a8bd6cdddb4148aa555d5807ecf767abdd2..693a449d8dc05432172daef641606fd6bfba13e9 100644 (file)
@@ -75,7 +75,7 @@
       <default>true</default>
     </entry>
 
-    <entry name="defaulttrackheight" type="Int">
+    <entry name="trackheight" 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 0cf498daa50fa244e4f599fe293ef677de64d637..7477b95d611c3bdd828e4a0415a010cdcb2aa025 100644 (file)
@@ -1976,7 +1976,7 @@ void MainWindow::updateConfiguration()
     if (m_activeTimeline) {
         m_activeTimeline->refresh();
         m_activeTimeline->projectView()->checkAutoScroll();
-        m_activeTimeline->projectView()->checkTrackHeight(true);
+        m_activeTimeline->projectView()->checkTrackHeight();
         if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
     }
     m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
index c163f34d245938e03a126ce37e3e4d57ffeba575..f34077a69a39882c0e386adcea5b03f6101ee5a1 100644 (file)
@@ -98,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(bool)), this, SLOT(slotRebuildTrackHeaders(bool)));
+    connect(m_trackview, SIGNAL(trackHeightChanged()), this, SLOT(slotRebuildTrackHeaders()));
 
     parseDocument(m_doc->toXml());
     m_doc->setSceneList();
@@ -403,7 +403,7 @@ void TrackView::slotChangeZoom(int factor)
     m_doc->setZoom(factor);
     m_ruler->setPixelPerMark(factor);
     m_scale = (double) FRAME_SIZE / m_ruler->comboScale[factor]; // m_ruler->comboScale[m_currentZoom] /
-    m_trackview->setScale(m_scale);
+    m_trackview->setScale(m_scale, m_scene->scale().y());
 }
 
 int TrackView::fitZoom() const
@@ -425,18 +425,18 @@ void TrackView::refresh()
     m_trackview->viewport()->update();
 }
 
-void TrackView::slotRebuildTrackHeaders(bool resetZoom)
+void TrackView::slotRebuildTrackHeaders()
 {
     // 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) {
         delete child;
     }
     int max = list.count();
+    int height = KdenliveSettings::trackheight() * m_scene->scale().y();
     for (int i = 0; i < max; i++) {
-        HeaderTrack *header = new HeaderTrack(i, list.at(max - i - 1), this);
+        HeaderTrack *header = new HeaderTrack(i, list.at(max - i - 1), height, this);
         connect(header, SIGNAL(switchTrackVideo(int)), m_trackview, SLOT(slotSwitchTrackVideo(int)));
         connect(header, SIGNAL(switchTrackAudio(int)), m_trackview, SLOT(slotSwitchTrackAudio(int)));
         connect(header, SIGNAL(switchTrackLock(int)), m_trackview, SLOT(slotSwitchTrackLock(int)));
@@ -763,16 +763,22 @@ void TrackView::slotVerticalZoomDown()
 {
     if (m_verticalZoom == 0) return;
     m_verticalZoom--;
-    KdenliveSettings::setTrackheight(KdenliveSettings::trackheight() / 2);
-    m_trackview->checkTrackHeight(false);
+    if (m_verticalZoom == 0) m_trackview->setScale(m_scene->scale().x(), 0.5);
+    else m_trackview->setScale(m_scene->scale().x(), 1);
+    slotRebuildTrackHeaders();
+    /*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);
+    /*KdenliveSettings::setTrackheight(KdenliveSettings::trackheight() * 2);
+    m_trackview->checkTrackHeight(false);*/
+    if (m_verticalZoom == 2) m_trackview->setScale(m_scene->scale().x(), 2);
+    else m_trackview->setScale(m_scene->scale().x(), 1);
+    slotRebuildTrackHeaders();
 }
 
 #include "trackview.moc"
index 514cdd880c54d3f9e7391148a73dd2f141974195..b938d44158ac54cc066a5407564f5d384b8fed44 100644 (file)
@@ -86,7 +86,7 @@ private:
 private slots:
     void setCursorPos(int pos);
     void moveCursorPos(int pos);
-    void slotRebuildTrackHeaders(bool resetZoom = false);
+    void slotRebuildTrackHeaders();
     void slotChangeTrackLock(int ix, bool lock);
     void slotVerticalZoomDown();
     void slotVerticalZoomUp();
index 3fc7ac9cabf5b65b35f4988b7d19bb33117038d4..cd3a4d7818c802ee84535c59d7f2d1aa8b6be077 100644 (file)
@@ -268,7 +268,7 @@ OPERATIONTYPE Transition::operationMode(QPointF pos)
 {
     if (isItemLocked()) return NONE;
 
-    const double scale = projectScene()->scale();
+    const double scale = projectScene()->scale().x();
     double maximumOffset = 6 / scale;
 
     QRectF rect = sceneBoundingRect();