Mercurial > hg > svgui
diff view/Pane.cpp @ 804:5c4a405a70fc tony_integration
Merge from branch "tonioni"
author | Chris Cannam |
---|---|
date | Tue, 17 Jun 2014 12:55:18 +0100 |
parents | 584b11df8e4f |
children | 40c6c9344ff6 |
line wrap: on
line diff
--- a/view/Pane.cpp Tue Jun 17 12:55:10 2014 +0100 +++ b/view/Pane.cpp Tue Jun 17 12:55:18 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); @@ -784,8 +787,6 @@ int x0 = getXForFrame(model->getStartFrame()); int x1 = getXForFrame(model->getEndFrame()); - int lw = 10; - paint.save(); QBrush brush; @@ -938,7 +939,7 @@ if (r.x() + r.width() >= llx - fontAscent - 3) { - for (size_t i = 0; i < texts.size(); ++i) { + for (int i = 0; i < texts.size(); ++i) { // cerr << "Pane "<< this << ": text " << i << ": " << texts[i] << endl; @@ -1331,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; @@ -1373,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(); @@ -1416,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) { @@ -1433,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; @@ -1478,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(); @@ -1590,7 +1613,8 @@ FlexiNoteLayer *layer = qobject_cast<FlexiNoteLayer *>(getTopFlexiNoteLayer()); if (layer) { layer->mouseMoveEvent(this, e); //!!! ew - return; + update(); + // return; } } @@ -1810,6 +1834,10 @@ update(); } + + if (m_dragMode != UnresolvedDrag) { + m_playbackFrameMoveScheduled = false; + } } void @@ -2081,6 +2109,10 @@ edgeScrollMaybe(e->x()); update(); + + if (min != max) { + m_playbackFrameMoveScheduled = false; + } } void @@ -2117,7 +2149,7 @@ return; } -// cerr << "mouseDoubleClickEvent" << endl; + cerr << "mouseDoubleClickEvent" << endl; m_clickPos = e->pos(); m_clickedInRange = true; @@ -2125,6 +2157,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);