Mercurial > hg > svgui
comparison 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 |
comparison
equal
deleted
inserted
replaced
803:5d2966b7c201 | 804:5c4a405a70fc |
---|---|
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 |
782 Pane::drawModelTimeExtents(QRect r, QPainter &paint, const Model *model) | 785 Pane::drawModelTimeExtents(QRect r, QPainter &paint, const Model *model) |
783 { | 786 { |
784 int x0 = getXForFrame(model->getStartFrame()); | 787 int x0 = getXForFrame(model->getStartFrame()); |
785 int x1 = getXForFrame(model->getEndFrame()); | 788 int x1 = getXForFrame(model->getEndFrame()); |
786 | 789 |
787 int lw = 10; | |
788 | |
789 paint.save(); | 790 paint.save(); |
790 | 791 |
791 QBrush brush; | 792 QBrush brush; |
792 | 793 |
793 if (hasLightBackground()) { | 794 if (hasLightBackground()) { |
936 llx -= 36; | 937 llx -= 36; |
937 } | 938 } |
938 | 939 |
939 if (r.x() + r.width() >= llx - fontAscent - 3) { | 940 if (r.x() + r.width() >= llx - fontAscent - 3) { |
940 | 941 |
941 for (size_t i = 0; i < texts.size(); ++i) { | 942 for (int i = 0; i < texts.size(); ++i) { |
942 | 943 |
943 // cerr << "Pane "<< this << ": text " << i << ": " << texts[i] << endl; | 944 // cerr << "Pane "<< this << ": text " << i << ": " << texts[i] << endl; |
944 | 945 |
945 if (i + 1 == texts.size()) { | 946 if (i + 1 == texts.size()) { |
946 paint.setPen(getForeground()); | 947 paint.setPen(getForeground()); |
1329 float vmin, vmax, dmin, dmax; | 1330 float vmin, vmax, dmin, dmax; |
1330 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) { | 1331 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) { |
1331 m_dragStartMinValue = dmin; | 1332 m_dragStartMinValue = dmin; |
1332 } | 1333 } |
1333 | 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 | |
1334 } else if (mode == ViewManager::SelectMode) { | 1340 } else if (mode == ViewManager::SelectMode) { |
1335 | 1341 |
1336 if (!hasTopLayerTimeXAxis()) return; | 1342 if (!hasTopLayerTimeXAxis()) return; |
1337 | 1343 |
1338 bool closeToLeft = false, closeToRight = false; | 1344 bool closeToLeft = false, closeToRight = false; |
1371 alignToReference(snapFrame + resolution)), | 1377 alignToReference(snapFrame + resolution)), |
1372 !m_ctrlPressed); | 1378 !m_ctrlPressed); |
1373 } | 1379 } |
1374 | 1380 |
1375 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); | |
1376 } | 1388 } |
1377 | 1389 |
1378 update(); | 1390 update(); |
1379 | 1391 |
1380 } else if (mode == ViewManager::DrawMode) { | 1392 } else if (mode == ViewManager::DrawMode) { |
1414 | 1426 |
1415 emit paneInteractedWith(); | 1427 emit paneInteractedWith(); |
1416 } | 1428 } |
1417 | 1429 |
1418 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 | |
1419 Pane::mouseReleaseEvent(QMouseEvent *e) | 1449 Pane::mouseReleaseEvent(QMouseEvent *e) |
1420 { | 1450 { |
1421 if (e->buttons() & Qt::RightButton) { | 1451 if (e->buttons() & Qt::RightButton) { |
1422 return; | 1452 return; |
1423 } | 1453 } |
1430 m_releasing = true; | 1460 m_releasing = true; |
1431 | 1461 |
1432 if (m_clickedInRange) { | 1462 if (m_clickedInRange) { |
1433 mouseMoveEvent(e); | 1463 mouseMoveEvent(e); |
1434 } | 1464 } |
1465 | |
1466 int mouseFrame = e ? getFrameForX(e->x()) : 0; | |
1467 if (mouseFrame < 0) mouseFrame = 0; | |
1435 | 1468 |
1436 if (m_navigating || mode == ViewManager::NavigateMode) { | 1469 if (m_navigating || mode == ViewManager::NavigateMode) { |
1437 | 1470 |
1438 m_navigating = false; | 1471 m_navigating = false; |
1439 | 1472 |
1475 if (exclusive) { | 1508 if (exclusive) { |
1476 m_manager->setSelection(selection); | 1509 m_manager->setSelection(selection); |
1477 } else { | 1510 } else { |
1478 m_manager->addSelection(selection); | 1511 m_manager->addSelection(selection); |
1479 } | 1512 } |
1480 } | |
1481 else if (m_manager && !m_manager->haveInProgressSelection()) { | |
1482 | |
1483 //cerr << "JTEST: release without selection" << endl; | |
1484 // Get frame location of mouse | |
1485 int mouseFrame = getFrameForX(e->x()); | |
1486 //cerr << "JTEST: frame location of click is " << mouseFrame << endl; | |
1487 // Move play head to that frame location | |
1488 int playbackFrame = fmax(0,mouseFrame); | |
1489 m_manager->setPlaybackFrame(playbackFrame); | |
1490 } | 1513 } |
1491 | 1514 |
1492 update(); | 1515 update(); |
1493 | 1516 |
1494 } else if (mode == ViewManager::DrawMode) { | 1517 } else if (mode == ViewManager::DrawMode) { |
1588 // 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. |
1589 if (mode == ViewManager::NoteEditMode) { | 1612 if (mode == ViewManager::NoteEditMode) { |
1590 FlexiNoteLayer *layer = qobject_cast<FlexiNoteLayer *>(getTopFlexiNoteLayer()); | 1613 FlexiNoteLayer *layer = qobject_cast<FlexiNoteLayer *>(getTopFlexiNoteLayer()); |
1591 if (layer) { | 1614 if (layer) { |
1592 layer->mouseMoveEvent(this, e); //!!! ew | 1615 layer->mouseMoveEvent(this, e); //!!! ew |
1593 return; | 1616 update(); |
1617 // return; | |
1594 } | 1618 } |
1595 } | 1619 } |
1596 | 1620 |
1597 if (mode == ViewManager::SelectMode && hasTopLayerTimeXAxis()) { | 1621 if (mode == ViewManager::SelectMode && hasTopLayerTimeXAxis()) { |
1598 bool closeToLeft = false, closeToRight = false; | 1622 bool closeToLeft = false, closeToRight = false; |
1807 layer->measureDrag(this, e); | 1831 layer->measureDrag(this, e); |
1808 if (layer->hasTimeXAxis()) edgeScrollMaybe(e->x()); | 1832 if (layer->hasTimeXAxis()) edgeScrollMaybe(e->x()); |
1809 } | 1833 } |
1810 | 1834 |
1811 update(); | 1835 update(); |
1836 } | |
1837 | |
1838 if (m_dragMode != UnresolvedDrag) { | |
1839 m_playbackFrameMoveScheduled = false; | |
1812 } | 1840 } |
1813 } | 1841 } |
1814 | 1842 |
1815 void | 1843 void |
1816 Pane::zoomToRegion(QRect r) | 1844 Pane::zoomToRegion(QRect r) |
2079 } | 2107 } |
2080 | 2108 |
2081 edgeScrollMaybe(e->x()); | 2109 edgeScrollMaybe(e->x()); |
2082 | 2110 |
2083 update(); | 2111 update(); |
2112 | |
2113 if (min != max) { | |
2114 m_playbackFrameMoveScheduled = false; | |
2115 } | |
2084 } | 2116 } |
2085 | 2117 |
2086 void | 2118 void |
2087 Pane::edgeScrollMaybe(int x) | 2119 Pane::edgeScrollMaybe(int x) |
2088 { | 2120 { |
2115 { | 2147 { |
2116 if (e->buttons() & Qt::RightButton) { | 2148 if (e->buttons() & Qt::RightButton) { |
2117 return; | 2149 return; |
2118 } | 2150 } |
2119 | 2151 |
2120 // cerr << "mouseDoubleClickEvent" << endl; | 2152 cerr << "mouseDoubleClickEvent" << endl; |
2121 | 2153 |
2122 m_clickPos = e->pos(); | 2154 m_clickPos = e->pos(); |
2123 m_clickedInRange = true; | 2155 m_clickedInRange = true; |
2124 m_shiftPressed = (e->modifiers() & Qt::ShiftModifier); | 2156 m_shiftPressed = (e->modifiers() & Qt::ShiftModifier); |
2125 m_ctrlPressed = (e->modifiers() & Qt::ControlModifier); | 2157 m_ctrlPressed = (e->modifiers() & Qt::ControlModifier); |
2126 m_altPressed = (e->modifiers() & Qt::AltModifier); | 2158 m_altPressed = (e->modifiers() & Qt::AltModifier); |
2159 | |
2160 // cancel any pending move that came from a single click | |
2161 m_playbackFrameMoveScheduled = false; | |
2127 | 2162 |
2128 ViewManager::ToolMode mode = ViewManager::NavigateMode; | 2163 ViewManager::ToolMode mode = ViewManager::NavigateMode; |
2129 if (m_manager) mode = m_manager->getToolModeFor(this); | 2164 if (m_manager) mode = m_manager->getToolModeFor(this); |
2130 | 2165 |
2131 bool relocate = (mode == ViewManager::NavigateMode || | 2166 bool relocate = (mode == ViewManager::NavigateMode || |