diff view/Pane.cpp @ 808:40c6c9344ff6 warnfix_no_size_t

Merge from branch tony_integration
author Chris Cannam
date Wed, 18 Jun 2014 08:40:46 +0100
parents 4c8ca536b54f 584b11df8e4f
children 43256b925e15
line wrap: on
line diff
--- a/view/Pane.cpp	Tue Jun 17 15:55:27 2014 +0100
+++ b/view/Pane.cpp	Wed Jun 18 08:40:46 2014 +0100
@@ -41,6 +41,7 @@
 #include <QCursor>
 #include <QTextStream>
 #include <QMimeData>
+#include <QApplication>
 
 #include <iostream>
 #include <cmath>
@@ -82,7 +83,9 @@
     m_hthumb(0),
     m_vthumb(0),
     m_reset(0),
-    m_mouseInWidget(false)
+    m_mouseInWidget(false),
+    m_playbackFrameMoveScheduled(false),
+    m_playbackFrameMoveTo(0)
 {
     setObjectName("Pane");
     setMouseTracking(true);
@@ -1329,6 +1332,11 @@
             m_dragStartMinValue = dmin;
         }
 
+        // Schedule a play-head move to the mouse frame location. This
+        // will happen only if nothing else of interest happens
+        // (double-click, drag) before the timeout.
+        schedulePlaybackFrameMove(getFrameForX(e->x()));
+
     } else if (mode == ViewManager::SelectMode) {
 
         if (!hasTopLayerTimeXAxis()) return;
@@ -1371,6 +1379,12 @@
             }
 
             m_resizing = false;
+
+            // Schedule a play-head move to the mouse frame
+            // location. This will happen only if nothing else of
+            // interest happens (double-click, drag) before the
+            // timeout.
+            schedulePlaybackFrameMove(mouseFrame);
         }
 
         update();
@@ -1414,6 +1428,24 @@
 }
 
 void
+Pane::schedulePlaybackFrameMove(int frame)
+{
+    m_playbackFrameMoveTo = frame;
+    m_playbackFrameMoveScheduled = true;
+    QTimer::singleShot(QApplication::doubleClickInterval() + 10, this,
+                       SLOT(playbackScheduleTimerElapsed()));
+}
+
+void
+Pane::playbackScheduleTimerElapsed()
+{
+    if (m_playbackFrameMoveScheduled) {
+        m_manager->setPlaybackFrame(m_playbackFrameMoveTo);
+        m_playbackFrameMoveScheduled = false;
+    }
+}
+
+void
 Pane::mouseReleaseEvent(QMouseEvent *e)
 {
     if (e->buttons() & Qt::RightButton) {
@@ -1431,6 +1463,9 @@
         mouseMoveEvent(e);
     }
 
+    int mouseFrame = e ? getFrameForX(e->x()) : 0;
+    if (mouseFrame < 0) mouseFrame = 0;
+
     if (m_navigating || mode == ViewManager::NavigateMode) {
 
         m_navigating = false;
@@ -1476,16 +1511,6 @@
                 m_manager->addSelection(selection);
             }
         }
-        else if (m_manager && !m_manager->haveInProgressSelection()) {
-            
-            //cerr << "JTEST: release without selection" << endl;
-            // Get frame location of mouse
-            int mouseFrame = getFrameForX(e->x());
-            //cerr << "JTEST: frame location of click is " << mouseFrame << endl;
-            // Move play head to that frame location
-            int playbackFrame = fmax(0,mouseFrame);
-            m_manager->setPlaybackFrame(playbackFrame);
-        }
     
         update();
 
@@ -1588,7 +1613,8 @@
             FlexiNoteLayer *layer = qobject_cast<FlexiNoteLayer *>(getTopFlexiNoteLayer());
             if (layer) {
                 layer->mouseMoveEvent(this, e); //!!! ew
-                return;
+                update();
+                // return;
             }
         }   
     
@@ -1808,6 +1834,10 @@
 
         update();
     }
+    
+    if (m_dragMode != UnresolvedDrag) {
+        m_playbackFrameMoveScheduled = false;
+    }
 }
 
 void
@@ -2078,6 +2108,10 @@
     edgeScrollMaybe(e->x());
 
     update();
+
+    if (min != max) {
+        m_playbackFrameMoveScheduled = false;
+    }
 }
 
 void
@@ -2114,7 +2148,7 @@
         return;
     }
 
-//    cerr << "mouseDoubleClickEvent" << endl;
+    cerr << "mouseDoubleClickEvent" << endl;
 
     m_clickPos = e->pos();
     m_clickedInRange = true;
@@ -2122,6 +2156,9 @@
     m_ctrlPressed = (e->modifiers() & Qt::ControlModifier);
     m_altPressed = (e->modifiers() & Qt::AltModifier);
 
+    // cancel any pending move that came from a single click
+    m_playbackFrameMoveScheduled = false;
+
     ViewManager::ToolMode mode = ViewManager::NavigateMode;
     if (m_manager) mode = m_manager->getToolModeFor(this);