]> git.sesse.net Git - kdenlive/commitdiff
new icons, snapping can now be en/disabled
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 24 Jun 2008 21:52:46 +0000 (21:52 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 24 Jun 2008 21:52:46 +0000 (21:52 +0000)
svn path=/branches/KDE4/; revision=2272

12 files changed:
icons/hi16-action-kdenlive-show-audio.png
icons/hi16-action-kdenlive-show-audiothumb.png [new file with mode: 0644]
icons/hi16-action-kdenlive-show-markers.png [new file with mode: 0644]
icons/hi16-action-kdenlive-show-video.png
icons/hi16-action-kdenlive-show-videothumb.png [new file with mode: 0644]
icons/hi16-action-kdenlive-snap.png [new file with mode: 0644]
src/customtrackview.cpp
src/kdenlivesettings.kcfg
src/mainwindow.cpp
src/mainwindow.h
src/renderer.cpp
src/renderer.h

index 6247a1579e966a802bfb901cd40da146c24439a0..268ecfff65a805a637de51838a092a342b896285 100644 (file)
Binary files a/icons/hi16-action-kdenlive-show-audio.png and b/icons/hi16-action-kdenlive-show-audio.png differ
diff --git a/icons/hi16-action-kdenlive-show-audiothumb.png b/icons/hi16-action-kdenlive-show-audiothumb.png
new file mode 100644 (file)
index 0000000..816c54b
Binary files /dev/null and b/icons/hi16-action-kdenlive-show-audiothumb.png differ
diff --git a/icons/hi16-action-kdenlive-show-markers.png b/icons/hi16-action-kdenlive-show-markers.png
new file mode 100644 (file)
index 0000000..724a5c2
Binary files /dev/null and b/icons/hi16-action-kdenlive-show-markers.png differ
index 2639ab87f3b7496be6c3754bceff50eb00a6a0fc..e61bf432cb1894923829310af200fc4752d5725f 100644 (file)
Binary files a/icons/hi16-action-kdenlive-show-video.png and b/icons/hi16-action-kdenlive-show-video.png differ
diff --git a/icons/hi16-action-kdenlive-show-videothumb.png b/icons/hi16-action-kdenlive-show-videothumb.png
new file mode 100644 (file)
index 0000000..c4e9cbf
Binary files /dev/null and b/icons/hi16-action-kdenlive-show-videothumb.png differ
diff --git a/icons/hi16-action-kdenlive-snap.png b/icons/hi16-action-kdenlive-snap.png
new file mode 100644 (file)
index 0000000..d13dc30
Binary files /dev/null and b/icons/hi16-action-kdenlive-snap.png differ
index 93a0a2b41d8e8a30560feeb4bd30103258b39f4f..60af8b521f329c5492f01be64fd9751dd047b5a5 100644 (file)
@@ -405,6 +405,10 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event) {
             setCursor(Qt::PointingHandCursor);
         }
     } // no clip under mouse
+       else if (m_tool == RAZORTOOL) {
+               QGraphicsView::mouseMoveEvent(event);
+               return;
+       }
     else if (opMode == MOVEGUIDE) {
         m_moveOpMode = opMode;
         setCursor(Qt::SplitHCursor);
@@ -959,9 +963,17 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) {
         setCursor(Qt::OpenHandCursor);
         // move clip
         if (m_dragItem->type() == AVWIDGET && (m_dragItemInfo.startPos != info.startPos || m_dragItemInfo.track != info.track)) {
-            MoveClipCommand *command = new MoveClipCommand(this, m_dragItemInfo, info, false);
-            m_commandStack->push(command);
-            m_document->renderer()->mltMoveClip((int)(m_tracksList.count() - m_dragItemInfo.track), (int)(m_tracksList.count() - m_dragItem->track()), (int) m_dragItemInfo.startPos.frames(m_document->fps()), (int)(m_dragItem->startPos().frames(m_document->fps())));
+            bool success = m_document->renderer()->mltMoveClip((int)(m_tracksList.count() - m_dragItemInfo.track), (int)(m_tracksList.count() - m_dragItem->track()), (int) m_dragItemInfo.startPos.frames(m_document->fps()), (int)(m_dragItem->startPos().frames(m_document->fps())));
+                       if (success) {
+                               MoveClipCommand *command = new MoveClipCommand(this, m_dragItemInfo, info, false);
+                               m_commandStack->push(command);
+                       }
+                       else {
+                               // undo last move and emit error message
+                               MoveClipCommand *command = new MoveClipCommand(this, info, m_dragItemInfo, true);
+                               m_commandStack->push(command);
+                               emit displayMessage(i18n("Cannot move clip to requested position"), ErrorMessage);
+                       }
         }
         if (m_dragItem->type() == TRANSITIONWIDGET && (m_dragItemInfo.startPos != info.startPos || m_dragItemInfo.track != info.track)) {
             MoveTransitionCommand *command = new MoveTransitionCommand(this, m_dragItemInfo, info, false);
@@ -1183,8 +1195,15 @@ void CustomTrackView::moveClip(const ItemInfo start, const ItemInfo end) {
         return;
     }
     //kDebug() << "----------------  Move CLIP FROM: " << startPos.x() << ", END:" << endPos.x() << ",TRACKS: " << startPos.y() << " TO " << endPos.y();
-    item->moveTo((int) end.startPos.frames(m_document->fps()), m_scale, (int)((end.track - start.track) * m_tracksHeight), end.track);
-    m_document->renderer()->mltMoveClip((int)(m_tracksList.count() - start.track), (int)(m_tracksList.count() - end.track), (int) start.startPos.frames(m_document->fps()), (int)end.startPos.frames(m_document->fps()));
+    
+    bool success = m_document->renderer()->mltMoveClip((int)(m_tracksList.count() - start.track), (int)(m_tracksList.count() - end.track), (int) start.startPos.frames(m_document->fps()), (int)end.startPos.frames(m_document->fps()));
+       if (success) {
+               item->moveTo((int) end.startPos.frames(m_document->fps()), m_scale, (int)((end.track - start.track) * m_tracksHeight), end.track);
+       }
+       else {
+               // undo last move and emit error message
+               emit displayMessage(i18n("Cannot move clip to requested position"), ErrorMessage);
+       }
 }
 
 void CustomTrackView::moveTransition(const ItemInfo start, const ItemInfo end) {
@@ -1279,6 +1298,7 @@ double CustomTrackView::getSnapPointForPos(double pos) {
 
 void CustomTrackView::updateSnapPoints(AbstractClipItem *selected) {
     m_snapPoints.clear();
+       if (!KdenliveSettings::snaptopoints()) return;
     GenTime offset;
     if (selected) offset = selected->duration();
     QList<QGraphicsItem *> itemList = items();
index 8395eb870bbd32ad7bc710c2347242c9ea10c2ff..dac1dba791c309e291875cfaf2b1c7d5f2941c0f 100644 (file)
       <default>false</default>
     </entry>
 
+    <entry name="snaptopoints" type="Bool">
+      <label>Snap movements to clips, guides and markers.</label>
+      <default>true</default>
+    </entry>
+
   </group>
 </kcfg>
\ No newline at end of file
index 22b0937139d0abba3de29781c15e0e74f2df7663..49885c3e3025b808d074c004bf4fe2b1044cd0ea 100644 (file)
@@ -376,7 +376,7 @@ void MainWindow::setupActions() {
 
     m_toolGroup = new QActionGroup(this);
 
-    QString style1 = "QToolButton { background-color: rgba(230, 230, 230, 20); border-style: inset; border:1px solid #666666;border-radius: 3px;margin: 0px 3px} QToolButton:checked { background-color: rgba(224, 0, 0, 100); border-style: inset; border:1px solid #666666;border-radius: 3px;}";
+    QString style1 = "QToolButton {background-color: rgba(230, 230, 230, 220); border-style: inset; border:1px solid #999999;border-radius: 3px;margin: 0px 3px;padding: 0px;} QToolButton:checked { background-color: rgba(224, 224, 0, 100); border-style: inset; border:1px solid #cc6666;border-radius: 3px;}";
 
     m_buttonSelectTool = toolbar->addAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"));
     m_buttonSelectTool->setCheckable(true);
@@ -389,6 +389,17 @@ void MainWindow::setupActions() {
     m_toolGroup->addAction(m_buttonSelectTool);
     m_toolGroup->addAction(m_buttonRazorTool);
     m_toolGroup->setExclusive(true);
+       toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
+
+       QWidget * actionWidget;
+       actionWidget = toolbar->widgetForAction( m_buttonSelectTool );
+       actionWidget->setMaximumWidth(24);
+       actionWidget->setMinimumHeight(18);
+
+       actionWidget = toolbar->widgetForAction( m_buttonRazorTool );
+       actionWidget->setMaximumWidth(24);
+       actionWidget->setMinimumHeight(18);
+
     toolbar->setStyleSheet(style1);
     connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
 
@@ -415,22 +426,44 @@ void MainWindow::setupActions() {
 
     toolbar->addWidget(m_zoomSlider);
 
-    m_buttonVideoThumbs = toolbar->addAction(KIcon("video-mpeg"), i18n("Show video thumbnails"));
+    m_buttonVideoThumbs = toolbar->addAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"));
     m_buttonVideoThumbs->setCheckable(true);
     m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
     connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
 
-    m_buttonAudioThumbs = toolbar->addAction(KIcon("audio-mpeg"), i18n("Show audio thumbnails"));
+    m_buttonAudioThumbs = toolbar->addAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"));
     m_buttonAudioThumbs->setCheckable(true);
     m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
     connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
 
-    m_buttonShowMarkers = toolbar->addAction(KIcon("audio-mpeg"), i18n("Show markers comments"));
+    m_buttonShowMarkers = toolbar->addAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"));
     m_buttonShowMarkers->setCheckable(true);
     m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
     connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
+
+    m_buttonSnap = toolbar->addAction(KIcon("kdenlive-snap"), i18n("Snap"));
+    m_buttonSnap->setCheckable(true);
+    m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
+    connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
     layout->addWidget(toolbar);
 
+
+       actionWidget = toolbar->widgetForAction( m_buttonVideoThumbs );
+       actionWidget->setMaximumWidth(24);
+       actionWidget->setMinimumHeight(18);
+
+       actionWidget = toolbar->widgetForAction( m_buttonAudioThumbs );
+       actionWidget->setMaximumWidth(24);
+       actionWidget->setMinimumHeight(18);
+
+       actionWidget = toolbar->widgetForAction( m_buttonShowMarkers );
+       actionWidget->setMaximumWidth(24);
+       actionWidget->setMinimumHeight(18);
+
+       actionWidget = toolbar->widgetForAction( m_buttonSnap );
+       actionWidget->setMaximumWidth(24);
+       actionWidget->setMinimumHeight(18);
+
     m_messageLabel = new StatusBarMessageLabel(this);
     m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
 
@@ -958,7 +991,10 @@ void MainWindow::slotSwitchMarkersComments() {
     m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
 }
 
-
+void MainWindow::slotSwitchSnap() {
+    KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
+    m_buttonShowMarkers->setChecked(KdenliveSettings::snaptopoints());
+}
 
 
 void MainWindow::slotDeleteTimelineClip() {
index 1347b9f02c74678da205a90ecfd0b041cef1725a..2a0deea1c26d2fe23f9807c342e245b67901dbf0 100644 (file)
@@ -124,6 +124,7 @@ private:
     QAction *m_buttonFitZoom;
     QAction *m_buttonSelectTool;
     QAction *m_buttonRazorTool;
+    QAction *m_buttonSnap;
     QActionGroup *m_toolGroup;
     QSlider *m_zoomSlider;
     StatusBarMessageLabel *m_messageLabel;
@@ -162,6 +163,7 @@ private slots:
     void slotSwitchVideoThumbs();
     void slotSwitchAudioThumbs();
     void slotSwitchMarkersComments();
+       void slotSwitchSnap();
     void slotRenderProject();
     void slotDoRender(const QString &dest, const QString &render, const QStringList &avformat_args, bool zoneOnly, bool playAfter);
     void slotFullScreen();
index 2fd774b6a1cb4480509f5662051e8ec69c7fa936..58749d3740d39d74ca51db7b2727bb37d8128caa 100644 (file)
@@ -808,12 +808,11 @@ void Render::switchPlay() {
     if (m_mltProducer->get_speed() == 0.0) m_mltProducer->set_speed(1.0);
     else {
         m_isBlocked = true;
-        m_mltProducer->set_speed(0.0);
-        m_mltConsumer->set("refresh", 0);
+               m_mltProducer->set_speed(0.0);
+        //m_mltConsumer->set("refresh", 0);
         m_mltProducer->seek((int) m_framePosition);
         m_isBlocked = false;
     }
-
     /*if (speed == 0.0) {
     m_mltProducer->seek((int) m_framePosition + 1);
         m_mltConsumer->purge();
@@ -1444,12 +1443,12 @@ void Render::mltResizeClipStart(int track, GenTime pos, GenTime moveEnd, GenTime
     m_isBlocked = false;
 }
 
-void Render::mltMoveClip(int startTrack, int endTrack, GenTime moveStart, GenTime moveEnd) {
-    mltMoveClip(startTrack, endTrack, (int) moveStart.frames(m_fps), (int) moveEnd.frames(m_fps));
+bool Render::mltMoveClip(int startTrack, int endTrack, GenTime moveStart, GenTime moveEnd) {
+    return mltMoveClip(startTrack, endTrack, (int) moveStart.frames(m_fps), (int) moveEnd.frames(m_fps));
 }
 
 
-void Render::mltMoveClip(int startTrack, int endTrack, int moveStart, int moveEnd) {
+bool Render::mltMoveClip(int startTrack, int endTrack, int moveStart, int moveEnd) {
     m_isBlocked = true;
 
     m_mltConsumer->set("refresh", 0);
@@ -1467,27 +1466,39 @@ void Render::mltMoveClip(int startTrack, int endTrack, int moveStart, int moveEn
         Mlt::Producer clipProducer(trackPlaylist.replace_with_blank(clipIndex));
         trackPlaylist.consolidate_blanks(0);
         if (!trackPlaylist.is_blank_at(moveEnd)) {
-            kWarning() << "// ERROR, CLIP COLLISION----------";
-            int ix = trackPlaylist.get_clip_index_at(moveEnd);
-            kDebug() << "BAD CLIP STARTS AT: " << trackPlaylist.clip_start(ix) << ", LENGT: " << trackPlaylist.clip_length(ix);
+                       // error, destination is not empty
+            //int ix = trackPlaylist.get_clip_index_at(moveEnd);
+                       mlt_service_unlock(m_mltConsumer->get_service());
+                       m_isBlocked = false;
+                       return false;
         }
-        trackPlaylist.insert_at(moveEnd, clipProducer, 1);
-        trackPlaylist.consolidate_blanks(0);
+               else {
+                       trackPlaylist.insert_at(moveEnd, clipProducer, 1);
+                       trackPlaylist.consolidate_blanks(0);
+               }
         //mlt_service_unlock(service.get_service());
     } else {
-        Mlt::Producer clipProducer(trackPlaylist.replace_with_blank(clipIndex));
-        trackPlaylist.consolidate_blanks(0);
-
         Mlt::Producer destTrackProducer(tractor.track(endTrack));
         Mlt::Playlist destTrackPlaylist((mlt_playlist) destTrackProducer.get_service());
-        destTrackPlaylist.consolidate_blanks(1);
-        destTrackPlaylist.insert_at(moveEnd, clipProducer, 1);
-        destTrackPlaylist.consolidate_blanks(0);
+               if (!destTrackPlaylist.is_blank_at(moveEnd)) {
+                       // error, destination is not empty
+                       mlt_service_unlock(m_mltConsumer->get_service());
+                       m_isBlocked = false;
+                       return false;
+               }
+               else {
+                       Mlt::Producer clipProducer(trackPlaylist.replace_with_blank(clipIndex));
+                       trackPlaylist.consolidate_blanks(0);
+                       destTrackPlaylist.consolidate_blanks(1);
+                       destTrackPlaylist.insert_at(moveEnd, clipProducer, 1);
+                       destTrackPlaylist.consolidate_blanks(0);
+               }
     }
     mltCheckLength();
     mlt_service_unlock(m_mltConsumer->get_service());
     m_isBlocked = false;
     m_mltConsumer->set("refresh", 1);
+       return true;
 }
 
 void Render::mltMoveTransition(QString type, int startTrack, int newTrack, int newTransitionTrack, GenTime oldIn, GenTime oldOut, GenTime newIn, GenTime newOut) {
@@ -1603,7 +1614,6 @@ void Render::mltUpdateTransitionParams(QString type, int a_track, int b_track, G
 }
 
 void Render::mltDeleteTransition(QString tag, int a_track, int b_track, GenTime in, GenTime out, QDomElement xml, bool do_refresh) {
-
     Mlt::Service service(m_mltProducer->parent().get_service());
     Mlt::Tractor tractor(service);
     Mlt::Field *field = tractor.field();
@@ -1627,6 +1637,7 @@ void Render::mltDeleteTransition(QString tag, int a_track, int b_track, GenTime
         if (resource == tag && b_track == currentTrack && currentIn <= old_pos && currentOut >= old_pos) {
             //kDebug() << " / / / / /DELETE TRANS DOOOMNE";
             mlt_field_disconnect_service(field->get_field(), nextservice);
+                       mlt_service_close(nextservice);
             break;
         }
         nextservice = mlt_service_producer(nextservice);
@@ -1677,7 +1688,6 @@ QMap<QString, QString> Render::mltGetTransitionParamsFromXml(QDomElement xml) {
 }
 
 void Render::mltAddTransition(QString tag, int a_track, int b_track, GenTime in, GenTime out, QDomElement xml, bool do_refresh) {
-    //kDebug() << "-- ADDING TRANSITION: " << tag << ", ON TRACKS: " << a_track << ", " << b_track;
     QMap<QString, QString> args = mltGetTransitionParamsFromXml(xml);
 
 
index 77fbdfaf558488a04bd64ae8f02af3be805d5c64..54510f1264084f4ceebae2b40b5e9d8685b73584 100644 (file)
@@ -154,8 +154,8 @@ Q_OBJECT public:
     void mltCutClip(int track, GenTime position);
     void mltResizeClipEnd(int track, GenTime pos, GenTime in, GenTime out);
     void mltResizeClipStart(int track, GenTime pos, GenTime moveEnd, GenTime moveStart, GenTime in, GenTime out);
-    void mltMoveClip(int startTrack, int endTrack, GenTime pos, GenTime moveStart);
-    void mltMoveClip(int startTrack, int endTrack, int pos, int moveStart);
+    bool mltMoveClip(int startTrack, int endTrack, GenTime pos, GenTime moveStart);
+    bool mltMoveClip(int startTrack, int endTrack, int pos, int moveStart);
     void mltRemoveClip(int track, GenTime position);
     void mltRemoveEffect(int track, GenTime position, QString index, bool doRefresh = true);
     void mltAddEffect(int track, GenTime position, QMap <QString, QString> args, bool doRefresh = true);