Mercurial > hg > svgui
comparison 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 |
comparison
equal
deleted
inserted
replaced
807:e4773943c9c1 | 808:40c6c9344ff6 |
---|---|
39 #include <QDragEnterEvent> | 39 #include <QDragEnterEvent> |
40 #include <QDropEvent> | 40 #include <QDropEvent> |
41 #include <QCursor> | 41 #include <QCursor> |
42 #include <QTextStream> | 42 #include <QTextStream> |
43 #include <QMimeData> | 43 #include <QMimeData> |
44 #include <QApplication> | |
44 | 45 |
45 #include <iostream> | 46 #include <iostream> |
46 #include <cmath> | 47 #include <cmath> |
47 | 48 |
48 //!!! for HUD -- pull out into a separate class | 49 //!!! for HUD -- pull out into a separate class |
80 m_headsUpDisplay(0), | 81 m_headsUpDisplay(0), |
81 m_vpan(0), | 82 m_vpan(0), |
82 m_hthumb(0), | 83 m_hthumb(0), |
83 m_vthumb(0), | 84 m_vthumb(0), |
84 m_reset(0), | 85 m_reset(0), |
85 m_mouseInWidget(false) | 86 m_mouseInWidget(false), |
87 m_playbackFrameMoveScheduled(false), | |
88 m_playbackFrameMoveTo(0) | |
86 { | 89 { |
87 setObjectName("Pane"); | 90 setObjectName("Pane"); |
88 setMouseTracking(true); | 91 setMouseTracking(true); |
89 setAcceptDrops(true); | 92 setAcceptDrops(true); |
90 | 93 |
1327 float vmin, vmax, dmin, dmax; | 1330 float vmin, vmax, dmin, dmax; |
1328 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) { | 1331 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) { |
1329 m_dragStartMinValue = dmin; | 1332 m_dragStartMinValue = dmin; |
1330 } | 1333 } |
1331 | 1334 |
1335 // Schedule a play-head move to the mouse frame location. This | |
1336 // will happen only if nothing else of interest happens | |
1337 // (double-click, drag) before the timeout. | |
1338 schedulePlaybackFrameMove(getFrameForX(e->x())); | |
1339 | |
1332 } else if (mode == ViewManager::SelectMode) { | 1340 } else if (mode == ViewManager::SelectMode) { |
1333 | 1341 |
1334 if (!hasTopLayerTimeXAxis()) return; | 1342 if (!hasTopLayerTimeXAxis()) return; |
1335 | 1343 |
1336 bool closeToLeft = false, closeToRight = false; | 1344 bool closeToLeft = false, closeToRight = false; |
1369 alignToReference(snapFrame + resolution)), | 1377 alignToReference(snapFrame + resolution)), |
1370 !m_ctrlPressed); | 1378 !m_ctrlPressed); |
1371 } | 1379 } |
1372 | 1380 |
1373 m_resizing = false; | 1381 m_resizing = false; |
1382 | |
1383 // Schedule a play-head move to the mouse frame | |
1384 // location. This will happen only if nothing else of | |
1385 // interest happens (double-click, drag) before the | |
1386 // timeout. | |
1387 schedulePlaybackFrameMove(mouseFrame); | |
1374 } | 1388 } |
1375 | 1389 |
1376 update(); | 1390 update(); |
1377 | 1391 |
1378 } else if (mode == ViewManager::DrawMode) { | 1392 } else if (mode == ViewManager::DrawMode) { |
1412 | 1426 |
1413 emit paneInteractedWith(); | 1427 emit paneInteractedWith(); |
1414 } | 1428 } |
1415 | 1429 |
1416 void | 1430 void |
1431 Pane::schedulePlaybackFrameMove(int frame) | |
1432 { | |
1433 m_playbackFrameMoveTo = frame; | |
1434 m_playbackFrameMoveScheduled = true; | |
1435 QTimer::singleShot(QApplication::doubleClickInterval() + 10, this, | |
1436 SLOT(playbackScheduleTimerElapsed())); | |
1437 } | |
1438 | |
1439 void | |
1440 Pane::playbackScheduleTimerElapsed() | |
1441 { | |
1442 if (m_playbackFrameMoveScheduled) { | |
1443 m_manager->setPlaybackFrame(m_playbackFrameMoveTo); | |
1444 m_playbackFrameMoveScheduled = false; | |
1445 } | |
1446 } | |
1447 | |
1448 void | |
1417 Pane::mouseReleaseEvent(QMouseEvent *e) | 1449 Pane::mouseReleaseEvent(QMouseEvent *e) |
1418 { | 1450 { |
1419 if (e->buttons() & Qt::RightButton) { | 1451 if (e->buttons() & Qt::RightButton) { |
1420 return; | 1452 return; |
1421 } | 1453 } |
1428 m_releasing = true; | 1460 m_releasing = true; |
1429 | 1461 |
1430 if (m_clickedInRange) { | 1462 if (m_clickedInRange) { |
1431 mouseMoveEvent(e); | 1463 mouseMoveEvent(e); |
1432 } | 1464 } |
1465 | |
1466 int mouseFrame = e ? getFrameForX(e->x()) : 0; | |
1467 if (mouseFrame < 0) mouseFrame = 0; | |
1433 | 1468 |
1434 if (m_navigating || mode == ViewManager::NavigateMode) { | 1469 if (m_navigating || mode == ViewManager::NavigateMode) { |
1435 | 1470 |
1436 m_navigating = false; | 1471 m_navigating = false; |
1437 | 1472 |
1473 if (exclusive) { | 1508 if (exclusive) { |
1474 m_manager->setSelection(selection); | 1509 m_manager->setSelection(selection); |
1475 } else { | 1510 } else { |
1476 m_manager->addSelection(selection); | 1511 m_manager->addSelection(selection); |
1477 } | 1512 } |
1478 } | |
1479 else if (m_manager && !m_manager->haveInProgressSelection()) { | |
1480 | |
1481 //cerr << "JTEST: release without selection" << endl; | |
1482 // Get frame location of mouse | |
1483 int mouseFrame = getFrameForX(e->x()); | |
1484 //cerr << "JTEST: frame location of click is " << mouseFrame << endl; | |
1485 // Move play head to that frame location | |
1486 int playbackFrame = fmax(0,mouseFrame); | |
1487 m_manager->setPlaybackFrame(playbackFrame); | |
1488 } | 1513 } |
1489 | 1514 |
1490 update(); | 1515 update(); |
1491 | 1516 |
1492 } else if (mode == ViewManager::DrawMode) { | 1517 } else if (mode == ViewManager::DrawMode) { |
1586 // GF: Propagate the event to FlexiNoteLayer. I somehow feel it's best handeled there rather than here, but perhaps not if this will be needed elsewhere too. | 1611 // GF: Propagate the event to FlexiNoteLayer. I somehow feel it's best handeled there rather than here, but perhaps not if this will be needed elsewhere too. |
1587 if (mode == ViewManager::NoteEditMode) { | 1612 if (mode == ViewManager::NoteEditMode) { |
1588 FlexiNoteLayer *layer = qobject_cast<FlexiNoteLayer *>(getTopFlexiNoteLayer()); | 1613 FlexiNoteLayer *layer = qobject_cast<FlexiNoteLayer *>(getTopFlexiNoteLayer()); |
1589 if (layer) { | 1614 if (layer) { |
1590 layer->mouseMoveEvent(this, e); //!!! ew | 1615 layer->mouseMoveEvent(this, e); //!!! ew |
1591 return; | 1616 update(); |
1617 // return; | |
1592 } | 1618 } |
1593 } | 1619 } |
1594 | 1620 |
1595 if (mode == ViewManager::SelectMode && hasTopLayerTimeXAxis()) { | 1621 if (mode == ViewManager::SelectMode && hasTopLayerTimeXAxis()) { |
1596 bool closeToLeft = false, closeToRight = false; | 1622 bool closeToLeft = false, closeToRight = false; |
1805 layer->measureDrag(this, e); | 1831 layer->measureDrag(this, e); |
1806 if (layer->hasTimeXAxis()) edgeScrollMaybe(e->x()); | 1832 if (layer->hasTimeXAxis()) edgeScrollMaybe(e->x()); |
1807 } | 1833 } |
1808 | 1834 |
1809 update(); | 1835 update(); |
1836 } | |
1837 | |
1838 if (m_dragMode != UnresolvedDrag) { | |
1839 m_playbackFrameMoveScheduled = false; | |
1810 } | 1840 } |
1811 } | 1841 } |
1812 | 1842 |
1813 void | 1843 void |
1814 Pane::zoomToRegion(QRect r) | 1844 Pane::zoomToRegion(QRect r) |
2076 } | 2106 } |
2077 | 2107 |
2078 edgeScrollMaybe(e->x()); | 2108 edgeScrollMaybe(e->x()); |
2079 | 2109 |
2080 update(); | 2110 update(); |
2111 | |
2112 if (min != max) { | |
2113 m_playbackFrameMoveScheduled = false; | |
2114 } | |
2081 } | 2115 } |
2082 | 2116 |
2083 void | 2117 void |
2084 Pane::edgeScrollMaybe(int x) | 2118 Pane::edgeScrollMaybe(int x) |
2085 { | 2119 { |
2112 { | 2146 { |
2113 if (e->buttons() & Qt::RightButton) { | 2147 if (e->buttons() & Qt::RightButton) { |
2114 return; | 2148 return; |
2115 } | 2149 } |
2116 | 2150 |
2117 // cerr << "mouseDoubleClickEvent" << endl; | 2151 cerr << "mouseDoubleClickEvent" << endl; |
2118 | 2152 |
2119 m_clickPos = e->pos(); | 2153 m_clickPos = e->pos(); |
2120 m_clickedInRange = true; | 2154 m_clickedInRange = true; |
2121 m_shiftPressed = (e->modifiers() & Qt::ShiftModifier); | 2155 m_shiftPressed = (e->modifiers() & Qt::ShiftModifier); |
2122 m_ctrlPressed = (e->modifiers() & Qt::ControlModifier); | 2156 m_ctrlPressed = (e->modifiers() & Qt::ControlModifier); |
2123 m_altPressed = (e->modifiers() & Qt::AltModifier); | 2157 m_altPressed = (e->modifiers() & Qt::AltModifier); |
2158 | |
2159 // cancel any pending move that came from a single click | |
2160 m_playbackFrameMoveScheduled = false; | |
2124 | 2161 |
2125 ViewManager::ToolMode mode = ViewManager::NavigateMode; | 2162 ViewManager::ToolMode mode = ViewManager::NavigateMode; |
2126 if (m_manager) mode = m_manager->getToolModeFor(this); | 2163 if (m_manager) mode = m_manager->getToolModeFor(this); |
2127 | 2164 |
2128 bool relocate = (mode == ViewManager::NavigateMode || | 2165 bool relocate = (mode == ViewManager::NavigateMode || |