]> git.sesse.net Git - kdenlive/commitdiff
some other fixes and improvements for guides
authorAlberto Villa <avilla@FreeBSD.org>
Tue, 12 May 2009 09:45:16 +0000 (09:45 +0000)
committerAlberto Villa <avilla@FreeBSD.org>
Tue, 12 May 2009 09:45:16 +0000 (09:45 +0000)
- set a wider selectable line (fix a regression introduced in last commit)
- fix right click not always colliding with a guide
- always give precedence to guides context menu:
http://www.kdenlive.org/mantis/view.php?id=785

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

src/customtrackview.cpp
src/guide.cpp

index 9b489cb16fbf4de13231465b0908ae75f1fe1f99..42d0c3dcfc48dbf1904549e9196e62292f5c2462 100644 (file)
@@ -574,6 +574,8 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event)
     kDebug() << "mousePressEvent STARTED";
     m_menuPosition = QPoint();
     m_blockRefresh = true;
+    m_dragItem = NULL;
+    m_dragGuide = NULL;
     bool collision = false;
 
     if (m_tool != RAZORTOOL) activateMonitor();
@@ -614,29 +616,30 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event)
         return;
     }
 
-    for (int i = 0; event->button() == Qt::LeftButton && i < collisionList.count(); ++i) {
-        // if a guide and a clip were pressed, just move the guide
+    // if a guide and a clip were pressed, just select the guide
+    for (int i = 0; i < collisionList.count(); ++i) {
         if (collisionList.at(i)->type() == GUIDEITEM) {
             // a guide item was pressed
-            collisionList.at(i)->setFlag(QGraphicsItem::ItemIsMovable, true);
-            m_dragItem = NULL;
             m_dragGuide = (Guide *) collisionList.at(i);
-            collision = true;
-            m_operationMode = MOVEGUIDE;
-            // deselect all clips so that only the guide will move
-            m_scene->clearSelection();
-            resetSelectionGroup(false);
-            updateSnapPoints(NULL);
-            QGraphicsView::mousePressEvent(event);
-            return;
+            if (event->button() == Qt::LeftButton) { // move it
+                m_dragGuide->setFlag(QGraphicsItem::ItemIsMovable, true);
+                collision = true;
+                m_operationMode = MOVEGUIDE;
+                // deselect all clips so that only the guide will move
+                m_scene->clearSelection();
+                resetSelectionGroup(false);
+                updateSnapPoints(NULL);
+                QGraphicsView::mousePressEvent(event);
+                return;
+            } else // show context menu
+                break;
         }
     }
 
-    // Find first clip, transition or group under mouse
+    // Find first clip, transition or group under mouse (when no guides selected)
     int ct = 0;
-    m_dragItem = NULL;
     AbstractGroupItem *dragGroup = NULL;
-    while (ct < collisionList.count()) {
+    while (!m_dragGuide && ct < collisionList.count()) {
         if (collisionList.at(ct)->type() == AVWIDGET || collisionList.at(ct)->type() == TRANSITIONWIDGET) {
             m_dragItem = static_cast <AbstractClipItem *>(collisionList.at(ct));
             m_dragItemInfo = m_dragItem->info();
@@ -657,7 +660,6 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event)
 
     // context menu requested
     if (event->button() == Qt::RightButton) {
-        m_dragGuide = NULL;
         if (m_dragItem) {
             if (dragGroup) dragGroup->setSelected(true);
             else if (!m_dragItem->isSelected()) {
@@ -665,16 +667,23 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event)
                 m_scene->clearSelection();
                 m_dragItem->setSelected(true);
             }
+        } else if (!m_dragGuide) {
+            // check if there is a guide close to mouse click
+            QList<QGraphicsItem *> guidesCollisionList = items(event->pos().x() - 5, event->pos().y(), 10, 2); // a rect of height < 2 does not always collide with the guide
+            for (int i = 0; i < guidesCollisionList.count(); i++) {
+                if (guidesCollisionList.at(i)->type() == GUIDEITEM) {
+                    m_dragGuide = static_cast <Guide *>(guidesCollisionList.at(i));
+                    break;
+                }
+            }
+            // keep this to support multiple guides context menu in the future (?)
+                /*if (guidesCollisionList.at(0)->type() != GUIDEITEM)
+                    guidesCollisionList.removeAt(0);
+            }
+            if (!guidesCollisionList.isEmpty())
+                m_dragGuide = static_cast <Guide *>(guidesCollisionList.at(0));*/
         }
 
-        // check if there is a guide close to mouse click
-        QList<QGraphicsItem *> guidesCollisionList = items(event->pos().x() - 5, event->pos().y(), 10, 1);
-        for (int i = 0; i < guidesCollisionList.count(); i++) {
-            if (guidesCollisionList.at(0)->type() != GUIDEITEM)
-                guidesCollisionList.removeAt(0);
-        }
-        if (!guidesCollisionList.isEmpty())
-            m_dragGuide = static_cast <Guide *>(guidesCollisionList.at(0));
         m_operationMode = NONE;
         displayContextMenu(event->globalPos(), m_dragItem, dragGroup);
         m_menuPosition = m_clickEvent;
index 08e5e9ef26d422eb79ff1de0a0548d19100b475a..0e55e9017ecd30375622b7b51746d79552d24243 100644 (file)
@@ -120,7 +120,7 @@ QRectF Guide::boundingRect() const
 QPainterPath Guide::shape() const
 {
     QPainterPath path;
-    path.addRect(line().x1(), line().y1(), line().x2() - line().x1(), line().y2() - line().y1());
+    path.addRect(line().x1() - pen().widthF() / 2, line().y1(), pen().widthF(), line().y2() - line().y1());
     if (KdenliveSettings::showmarkers()) {
         const QFontMetrics metric = m_view->fontMetrics();
         int height = metric.height();