Mercurial > hg > svgui
comparison view/Pane.cpp @ 374:64e84e5efb76 spectrogram-cache-rejig
* Merge from trunk
author | Chris Cannam |
---|---|
date | Wed, 27 Feb 2008 11:59:42 +0000 |
parents | 29fcf125f98b |
children |
comparison
equal
deleted
inserted
replaced
332:6440e280122e | 374:64e84e5efb76 |
---|---|
20 #include "base/RealTime.h" | 20 #include "base/RealTime.h" |
21 #include "base/Profiler.h" | 21 #include "base/Profiler.h" |
22 #include "ViewManager.h" | 22 #include "ViewManager.h" |
23 #include "base/CommandHistory.h" | 23 #include "base/CommandHistory.h" |
24 #include "base/TextAbbrev.h" | 24 #include "base/TextAbbrev.h" |
25 #include "base/Preferences.h" | |
25 #include "layer/WaveformLayer.h" | 26 #include "layer/WaveformLayer.h" |
26 | 27 |
27 //!!! ugh | 28 //!!! ugh |
28 #include "data/model/WaveFileModel.h" | 29 #include "data/model/WaveFileModel.h" |
29 | 30 |
47 #include "widgets/RangeInputDialog.h" | 48 #include "widgets/RangeInputDialog.h" |
48 #include "widgets/NotifyingPushButton.h" | 49 #include "widgets/NotifyingPushButton.h" |
49 | 50 |
50 #include "widgets/KeyReference.h" //!!! should probably split KeyReference into a data class in base and another that shows the widget | 51 #include "widgets/KeyReference.h" //!!! should probably split KeyReference into a data class in base and another that shows the widget |
51 | 52 |
53 //#define DEBUG_PANE | |
54 | |
52 using std::cerr; | 55 using std::cerr; |
53 using std::endl; | 56 using std::endl; |
54 | 57 |
55 QCursor *Pane::m_measureCursor1 = 0; | 58 QCursor *Pane::m_measureCursor1 = 0; |
56 QCursor *Pane::m_measureCursor2 = 0; | 59 QCursor *Pane::m_measureCursor2 = 0; |
61 m_clickedInRange(false), | 64 m_clickedInRange(false), |
62 m_shiftPressed(false), | 65 m_shiftPressed(false), |
63 m_ctrlPressed(false), | 66 m_ctrlPressed(false), |
64 m_navigating(false), | 67 m_navigating(false), |
65 m_resizing(false), | 68 m_resizing(false), |
69 m_editing(false), | |
70 m_releasing(false), | |
66 m_centreLineVisible(true), | 71 m_centreLineVisible(true), |
67 m_scaleWidth(0), | 72 m_scaleWidth(0), |
68 m_headsUpDisplay(0), | 73 m_headsUpDisplay(0), |
69 m_vpan(0), | 74 m_vpan(0), |
70 m_hthumb(0), | 75 m_hthumb(0), |
386 if (e) r = e->rect(); | 391 if (e) r = e->rect(); |
387 | 392 |
388 View::paintEvent(e); | 393 View::paintEvent(e); |
389 | 394 |
390 paint.begin(this); | 395 paint.begin(this); |
396 setPaintFont(paint); | |
391 | 397 |
392 if (e) paint.setClipRect(r); | 398 if (e) paint.setClipRect(r); |
393 | 399 |
394 ViewManager::ToolMode toolMode = m_manager->getToolMode(); | 400 ViewManager::ToolMode toolMode = m_manager->getToolMode(); |
395 | 401 |
1207 emit contextHelpChanged(""); | 1213 emit contextHelpChanged(""); |
1208 emit rightButtonMenuRequested(mapToGlobal(e->pos())); | 1214 emit rightButtonMenuRequested(mapToGlobal(e->pos())); |
1209 return; | 1215 return; |
1210 } | 1216 } |
1211 | 1217 |
1218 // std::cerr << "mousePressEvent" << std::endl; | |
1219 | |
1212 m_clickPos = e->pos(); | 1220 m_clickPos = e->pos(); |
1213 m_mousePos = m_clickPos; | 1221 m_mousePos = m_clickPos; |
1214 m_clickedInRange = true; | 1222 m_clickedInRange = true; |
1215 m_editingSelection = Selection(); | 1223 m_editingSelection = Selection(); |
1216 m_editingSelectionEdge = 0; | 1224 m_editingSelectionEdge = 0; |
1220 | 1228 |
1221 ViewManager::ToolMode mode = ViewManager::NavigateMode; | 1229 ViewManager::ToolMode mode = ViewManager::NavigateMode; |
1222 if (m_manager) mode = m_manager->getToolMode(); | 1230 if (m_manager) mode = m_manager->getToolMode(); |
1223 | 1231 |
1224 m_navigating = false; | 1232 m_navigating = false; |
1233 m_resizing = false; | |
1234 m_editing = false; | |
1235 m_releasing = false; | |
1225 | 1236 |
1226 if (mode == ViewManager::NavigateMode || | 1237 if (mode == ViewManager::NavigateMode || |
1227 (e->buttons() & Qt::MidButton) || | 1238 (e->buttons() & Qt::MidButton) || |
1228 (mode == ViewManager::MeasureMode && | 1239 (mode == ViewManager::MeasureMode && |
1229 (e->buttons() & Qt::LeftButton) && m_shiftPressed)) { | 1240 (e->buttons() & Qt::LeftButton) && m_shiftPressed)) { |
1274 } | 1285 } |
1275 | 1286 |
1276 if (snapFrame < 0) snapFrame = 0; | 1287 if (snapFrame < 0) snapFrame = 0; |
1277 m_selectionStartFrame = snapFrame; | 1288 m_selectionStartFrame = snapFrame; |
1278 if (m_manager) { | 1289 if (m_manager) { |
1279 m_manager->setInProgressSelection(Selection(snapFrame, | 1290 m_manager->setInProgressSelection |
1280 snapFrame + resolution), | 1291 (Selection(alignToReference(snapFrame), |
1281 !m_ctrlPressed); | 1292 alignToReference(snapFrame + resolution)), |
1293 !m_ctrlPressed); | |
1282 } | 1294 } |
1283 | 1295 |
1284 m_resizing = false; | 1296 m_resizing = false; |
1285 } | 1297 } |
1286 | 1298 |
1291 Layer *layer = getSelectedLayer(); | 1303 Layer *layer = getSelectedLayer(); |
1292 if (layer && layer->isLayerEditable()) { | 1304 if (layer && layer->isLayerEditable()) { |
1293 layer->drawStart(this, e); | 1305 layer->drawStart(this, e); |
1294 } | 1306 } |
1295 | 1307 |
1308 } else if (mode == ViewManager::EraseMode) { | |
1309 | |
1310 Layer *layer = getSelectedLayer(); | |
1311 if (layer && layer->isLayerEditable()) { | |
1312 layer->eraseStart(this, e); | |
1313 } | |
1314 | |
1296 } else if (mode == ViewManager::EditMode) { | 1315 } else if (mode == ViewManager::EditMode) { |
1297 | 1316 |
1298 if (!editSelectionStart(e)) { | 1317 // Do nothing here -- we'll do it in mouseMoveEvent when the |
1299 Layer *layer = getSelectedLayer(); | 1318 // drag threshold has been passed |
1300 if (layer && layer->isLayerEditable()) { | |
1301 layer->editStart(this, e); | |
1302 } | |
1303 } | |
1304 | 1319 |
1305 } else if (mode == ViewManager::MeasureMode) { | 1320 } else if (mode == ViewManager::MeasureMode) { |
1306 | 1321 |
1307 Layer *layer = getTopLayer(); | 1322 Layer *layer = getTopLayer(); |
1308 if (layer) layer->measureStart(this, e); | 1323 if (layer) layer->measureStart(this, e); |
1317 { | 1332 { |
1318 if (e->buttons() & Qt::RightButton) { | 1333 if (e->buttons() & Qt::RightButton) { |
1319 return; | 1334 return; |
1320 } | 1335 } |
1321 | 1336 |
1337 // std::cerr << "mouseReleaseEvent" << std::endl; | |
1338 | |
1322 ViewManager::ToolMode mode = ViewManager::NavigateMode; | 1339 ViewManager::ToolMode mode = ViewManager::NavigateMode; |
1323 if (m_manager) mode = m_manager->getToolMode(); | 1340 if (m_manager) mode = m_manager->getToolMode(); |
1341 | |
1342 m_releasing = true; | |
1324 | 1343 |
1325 if (m_clickedInRange) { | 1344 if (m_clickedInRange) { |
1326 mouseMoveEvent(e); | 1345 mouseMoveEvent(e); |
1327 } | 1346 } |
1328 | 1347 |
1346 zoomToRegion(x0, y0, x1, y1); | 1365 zoomToRegion(x0, y0, x1, y1); |
1347 } | 1366 } |
1348 | 1367 |
1349 } else if (mode == ViewManager::SelectMode) { | 1368 } else if (mode == ViewManager::SelectMode) { |
1350 | 1369 |
1351 if (!hasTopLayerTimeXAxis()) return; | 1370 if (!hasTopLayerTimeXAxis()) { |
1371 m_releasing = false; | |
1372 return; | |
1373 } | |
1352 | 1374 |
1353 if (m_manager && m_manager->haveInProgressSelection()) { | 1375 if (m_manager && m_manager->haveInProgressSelection()) { |
1354 | 1376 |
1355 bool exclusive; | 1377 bool exclusive; |
1356 Selection selection = m_manager->getInProgressSelection(exclusive); | 1378 Selection selection = m_manager->getInProgressSelection(exclusive); |
1376 if (layer && layer->isLayerEditable()) { | 1398 if (layer && layer->isLayerEditable()) { |
1377 layer->drawEnd(this, e); | 1399 layer->drawEnd(this, e); |
1378 update(); | 1400 update(); |
1379 } | 1401 } |
1380 | 1402 |
1403 } else if (mode == ViewManager::EraseMode) { | |
1404 | |
1405 Layer *layer = getSelectedLayer(); | |
1406 if (layer && layer->isLayerEditable()) { | |
1407 layer->eraseEnd(this, e); | |
1408 update(); | |
1409 } | |
1410 | |
1381 } else if (mode == ViewManager::EditMode) { | 1411 } else if (mode == ViewManager::EditMode) { |
1382 | 1412 |
1383 if (!editSelectionEnd(e)) { | 1413 if (m_editing) { |
1384 Layer *layer = getSelectedLayer(); | 1414 if (!editSelectionEnd(e)) { |
1385 if (layer && layer->isLayerEditable()) { | 1415 Layer *layer = getSelectedLayer(); |
1386 layer->editEnd(this, e); | 1416 if (layer && layer->isLayerEditable()) { |
1387 update(); | 1417 layer->editEnd(this, e); |
1388 } | 1418 update(); |
1389 } | 1419 } |
1420 } | |
1421 } | |
1390 | 1422 |
1391 } else if (mode == ViewManager::MeasureMode) { | 1423 } else if (mode == ViewManager::MeasureMode) { |
1392 | 1424 |
1393 Layer *layer = getTopLayer(); | 1425 Layer *layer = getTopLayer(); |
1394 if (layer) layer->measureEnd(this, e); | 1426 if (layer) layer->measureEnd(this, e); |
1395 if (m_measureCursor1) setCursor(*m_measureCursor1); | 1427 if (m_measureCursor1) setCursor(*m_measureCursor1); |
1396 update(); | 1428 update(); |
1397 } | 1429 } |
1398 | 1430 |
1399 m_clickedInRange = false; | 1431 m_clickedInRange = false; |
1432 m_releasing = false; | |
1400 | 1433 |
1401 emit paneInteractedWith(); | 1434 emit paneInteractedWith(); |
1402 } | 1435 } |
1403 | 1436 |
1404 void | 1437 void |
1406 { | 1439 { |
1407 if (e->buttons() & Qt::RightButton) { | 1440 if (e->buttons() & Qt::RightButton) { |
1408 return; | 1441 return; |
1409 } | 1442 } |
1410 | 1443 |
1444 // std::cerr << "mouseMoveEvent" << std::endl; | |
1445 | |
1411 updateContextHelp(&e->pos()); | 1446 updateContextHelp(&e->pos()); |
1447 | |
1448 if (m_navigating && m_clickedInRange && !m_releasing) { | |
1449 | |
1450 // if no buttons pressed, and not called from | |
1451 // mouseReleaseEvent, we want to reset clicked-ness (to avoid | |
1452 // annoying continual drags when we moved the mouse outside | |
1453 // the window after pressing button first time). | |
1454 | |
1455 if (!(e->buttons() & Qt::LeftButton) && | |
1456 !(e->buttons() & Qt::MidButton)) { | |
1457 m_clickedInRange = false; | |
1458 return; | |
1459 } | |
1460 } | |
1412 | 1461 |
1413 ViewManager::ToolMode mode = ViewManager::NavigateMode; | 1462 ViewManager::ToolMode mode = ViewManager::NavigateMode; |
1414 if (m_manager) mode = m_manager->getToolMode(); | 1463 if (m_manager) mode = m_manager->getToolMode(); |
1415 | 1464 |
1416 QPoint prevPoint = m_identifyPoint; | 1465 QPoint prevPoint = m_identifyPoint; |
1482 Layer *layer = getSelectedLayer(); | 1531 Layer *layer = getSelectedLayer(); |
1483 if (layer && layer->isLayerEditable()) { | 1532 if (layer && layer->isLayerEditable()) { |
1484 layer->drawDrag(this, e); | 1533 layer->drawDrag(this, e); |
1485 } | 1534 } |
1486 | 1535 |
1536 } else if (mode == ViewManager::EraseMode) { | |
1537 | |
1538 Layer *layer = getSelectedLayer(); | |
1539 if (layer && layer->isLayerEditable()) { | |
1540 layer->eraseDrag(this, e); | |
1541 } | |
1542 | |
1487 } else if (mode == ViewManager::EditMode) { | 1543 } else if (mode == ViewManager::EditMode) { |
1488 | 1544 |
1489 if (!editSelectionDrag(e)) { | 1545 if (m_editing) { |
1490 Layer *layer = getSelectedLayer(); | 1546 if (!editSelectionDrag(e)) { |
1491 if (layer && layer->isLayerEditable()) { | 1547 Layer *layer = getSelectedLayer(); |
1492 layer->editDrag(this, e); | 1548 if (layer && layer->isLayerEditable()) { |
1493 } | 1549 layer->editDrag(this, e); |
1494 } | 1550 } |
1551 } | |
1552 } | |
1553 | |
1554 if (!m_editing) { | |
1555 | |
1556 DragMode newDragMode = updateDragMode | |
1557 (m_dragMode, | |
1558 m_clickPos, | |
1559 e->pos(), | |
1560 true, // can move horiz | |
1561 true, // can move vert | |
1562 true, // resist horiz | |
1563 true); // resist vert | |
1564 | |
1565 if (newDragMode != UnresolvedDrag) { | |
1566 | |
1567 m_editing = true; | |
1568 | |
1569 QMouseEvent clickEvent(QEvent::MouseButtonPress, | |
1570 m_clickPos, | |
1571 Qt::NoButton, | |
1572 e->buttons(), | |
1573 e->modifiers()); | |
1574 | |
1575 if (!editSelectionStart(&clickEvent)) { | |
1576 Layer *layer = getSelectedLayer(); | |
1577 if (layer && layer->isLayerEditable()) { | |
1578 layer->editStart(this, &clickEvent); | |
1579 } | |
1580 } | |
1581 } | |
1582 } | |
1495 | 1583 |
1496 } else if (mode == ViewManager::MeasureMode) { | 1584 } else if (mode == ViewManager::MeasureMode) { |
1497 | 1585 |
1498 if (m_measureCursor2) setCursor(*m_measureCursor2); | 1586 if (m_measureCursor2) setCursor(*m_measureCursor2); |
1499 | 1587 |
1590 // other direction as well, we may switch into free mode. | 1678 // other direction as well, we may switch into free mode. |
1591 // | 1679 // |
1592 // If the top layer is incapable of being dragged | 1680 // If the top layer is incapable of being dragged |
1593 // vertically, the logic is short circuited. | 1681 // vertically, the logic is short circuited. |
1594 | 1682 |
1595 int xdiff = e->x() - m_clickPos.x(); | 1683 m_dragMode = updateDragMode |
1596 int ydiff = e->y() - m_clickPos.y(); | 1684 (m_dragMode, |
1597 int smallThreshold = 10, bigThreshold = 50; | 1685 m_clickPos, |
1598 | 1686 e->pos(), |
1599 bool canMoveVertical = canTopLayerMoveVertical(); | 1687 true, // can move horiz |
1600 bool canMoveHorizontal = true; | 1688 canTopLayerMoveVertical(), // can move vert |
1601 | 1689 canTopLayerMoveVertical() || (m_manager && m_manager->isPlaying()), // resist horiz |
1602 if (!canMoveHorizontal) { | 1690 !(m_manager && m_manager->isPlaying())); // resist vert |
1603 m_dragMode = HorizontalDrag; | 1691 |
1604 } | 1692 if (m_dragMode == HorizontalDrag || |
1605 | 1693 m_dragMode == FreeDrag) { |
1606 if (m_dragMode == UnresolvedDrag) { | |
1607 | |
1608 if (abs(ydiff) > smallThreshold && | |
1609 abs(ydiff) > abs(xdiff) * 2) { | |
1610 m_dragMode = VerticalDrag; | |
1611 } else if (abs(xdiff) > smallThreshold && | |
1612 abs(xdiff) > abs(ydiff) * 2) { | |
1613 m_dragMode = HorizontalDrag; | |
1614 } else if (abs(xdiff) > smallThreshold && | |
1615 abs(ydiff) > smallThreshold) { | |
1616 m_dragMode = FreeDrag; | |
1617 } else { | |
1618 // When playing, we don't want to disturb the play | |
1619 // position too easily; when not playing, we don't | |
1620 // want to move up/down too easily | |
1621 if (m_manager && m_manager->isPlaying()) { | |
1622 canMoveHorizontal = false; | |
1623 } else { | |
1624 canMoveVertical = false; | |
1625 } | |
1626 } | |
1627 } | |
1628 | |
1629 if (m_dragMode == VerticalDrag) { | |
1630 if (abs(xdiff) > bigThreshold) m_dragMode = FreeDrag; | |
1631 else canMoveHorizontal = false; | |
1632 } | |
1633 | |
1634 if (m_dragMode == HorizontalDrag && canMoveVertical) { | |
1635 if (abs(ydiff) > bigThreshold) m_dragMode = FreeDrag; | |
1636 else canMoveVertical = false; | |
1637 } | |
1638 | |
1639 if (canMoveHorizontal) { | |
1640 | 1694 |
1641 long frameOff = getFrameForX(e->x()) - getFrameForX(m_clickPos.x()); | 1695 long frameOff = getFrameForX(e->x()) - getFrameForX(m_clickPos.x()); |
1642 | 1696 |
1643 size_t newCentreFrame = m_dragCentreFrame; | 1697 size_t newCentreFrame = m_dragCentreFrame; |
1644 | 1698 |
1647 } else if (newCentreFrame >= size_t(frameOff)) { | 1701 } else if (newCentreFrame >= size_t(frameOff)) { |
1648 newCentreFrame -= frameOff; | 1702 newCentreFrame -= frameOff; |
1649 } else { | 1703 } else { |
1650 newCentreFrame = 0; | 1704 newCentreFrame = 0; |
1651 } | 1705 } |
1652 | 1706 |
1707 #ifdef DEBUG_PANE | |
1708 std::cerr << "Pane::dragTopLayer: newCentreFrame = " << newCentreFrame << | |
1709 ", models end frame = " << getModelsEndFrame() << std::endl; | |
1710 #endif | |
1711 | |
1653 if (newCentreFrame >= getModelsEndFrame()) { | 1712 if (newCentreFrame >= getModelsEndFrame()) { |
1654 newCentreFrame = getModelsEndFrame(); | 1713 newCentreFrame = getModelsEndFrame(); |
1655 if (newCentreFrame > 0) --newCentreFrame; | 1714 if (newCentreFrame > 0) --newCentreFrame; |
1656 } | 1715 } |
1657 | 1716 |
1658 if (getXForFrame(m_centreFrame) != getXForFrame(newCentreFrame)) { | 1717 if (getXForFrame(m_centreFrame) != getXForFrame(newCentreFrame)) { |
1659 setCentreFrame(newCentreFrame); | 1718 setCentreFrame(newCentreFrame); |
1660 } | 1719 } |
1661 } | 1720 } |
1662 | 1721 |
1663 if (canMoveVertical) { | 1722 if (m_dragMode == VerticalDrag || |
1723 m_dragMode == FreeDrag) { | |
1664 | 1724 |
1665 float vmin = 0.f, vmax = 0.f; | 1725 float vmin = 0.f, vmax = 0.f; |
1666 float dmin = 0.f, dmax = 0.f; | 1726 float dmin = 0.f, dmax = 0.f; |
1667 | 1727 |
1668 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) { | 1728 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) { |
1669 | 1729 |
1670 // std::cerr << "ydiff = " << ydiff << std::endl; | 1730 // std::cerr << "ydiff = " << ydiff << std::endl; |
1671 | 1731 |
1732 int ydiff = e->y() - m_clickPos.y(); | |
1672 float perpix = (dmax - dmin) / height(); | 1733 float perpix = (dmax - dmin) / height(); |
1673 float valdiff = ydiff * perpix; | 1734 float valdiff = ydiff * perpix; |
1674 // std::cerr << "valdiff = " << valdiff << std::endl; | 1735 // std::cerr << "valdiff = " << valdiff << std::endl; |
1736 | |
1737 if (m_dragMode == UnresolvedDrag && ydiff != 0) { | |
1738 m_dragMode = VerticalDrag; | |
1739 } | |
1675 | 1740 |
1676 float newmin = m_dragStartMinValue + valdiff; | 1741 float newmin = m_dragStartMinValue + valdiff; |
1677 float newmax = m_dragStartMinValue + (dmax - dmin) + valdiff; | 1742 float newmax = m_dragStartMinValue + (dmax - dmin) + valdiff; |
1678 if (newmin < vmin) { | 1743 if (newmin < vmin) { |
1679 newmax += vmin - newmin; | 1744 newmax += vmin - newmin; |
1688 | 1753 |
1689 setTopLayerDisplayExtents(newmin, newmax); | 1754 setTopLayerDisplayExtents(newmin, newmax); |
1690 updateVerticalPanner(); | 1755 updateVerticalPanner(); |
1691 } | 1756 } |
1692 } | 1757 } |
1758 } | |
1759 | |
1760 Pane::DragMode | |
1761 Pane::updateDragMode(DragMode dragMode, | |
1762 QPoint origin, | |
1763 QPoint point, | |
1764 bool canMoveHorizontal, | |
1765 bool canMoveVertical, | |
1766 bool resistHorizontal, | |
1767 bool resistVertical) | |
1768 { | |
1769 int xdiff = point.x() - origin.x(); | |
1770 int ydiff = point.y() - origin.y(); | |
1771 | |
1772 int smallThreshold = 10, bigThreshold = 80; | |
1773 | |
1774 // std::cerr << "Pane::updateDragMode: xdiff = " << xdiff << ", ydiff = " | |
1775 // << ydiff << ", canMoveVertical = " << canMoveVertical << ", drag mode = " << m_dragMode << std::endl; | |
1776 | |
1777 if (dragMode == UnresolvedDrag) { | |
1778 | |
1779 if (abs(ydiff) > smallThreshold && | |
1780 abs(ydiff) > abs(xdiff) * 2 && | |
1781 canMoveVertical) { | |
1782 // std::cerr << "Pane::updateDragMode: passed vertical threshold" << std::endl; | |
1783 dragMode = VerticalDrag; | |
1784 } else if (abs(xdiff) > smallThreshold && | |
1785 abs(xdiff) > abs(ydiff) * 2 && | |
1786 canMoveHorizontal) { | |
1787 // std::cerr << "Pane::updateDragMode: passed horizontal threshold" << std::endl; | |
1788 dragMode = HorizontalDrag; | |
1789 } else if (abs(xdiff) > smallThreshold && | |
1790 abs(ydiff) > smallThreshold && | |
1791 canMoveVertical && | |
1792 canMoveHorizontal) { | |
1793 // std::cerr << "Pane::updateDragMode: passed both thresholds" << std::endl; | |
1794 dragMode = FreeDrag; | |
1795 } | |
1796 } | |
1797 | |
1798 if (dragMode == VerticalDrag && canMoveHorizontal) { | |
1799 if (abs(xdiff) > bigThreshold) dragMode = FreeDrag; | |
1800 } | |
1801 | |
1802 if (dragMode == HorizontalDrag && canMoveVertical) { | |
1803 if (abs(ydiff) > bigThreshold) dragMode = FreeDrag; | |
1804 } | |
1805 | |
1806 if (dragMode == UnresolvedDrag) { | |
1807 if (!resistHorizontal && xdiff != 0) { | |
1808 dragMode = HorizontalDrag; | |
1809 } | |
1810 if (!resistVertical && ydiff != 0) { | |
1811 if (dragMode == HorizontalDrag) dragMode = FreeDrag; | |
1812 else dragMode = VerticalDrag; | |
1813 } | |
1814 } | |
1815 | |
1816 return dragMode; | |
1693 } | 1817 } |
1694 | 1818 |
1695 void | 1819 void |
1696 Pane::dragExtendSelection(QMouseEvent *e) | 1820 Pane::dragExtendSelection(QMouseEvent *e) |
1697 { | 1821 { |
1725 min = snapFrameLeft; | 1849 min = snapFrameLeft; |
1726 max = snapFrameRight; | 1850 max = snapFrameRight; |
1727 } | 1851 } |
1728 | 1852 |
1729 if (m_manager) { | 1853 if (m_manager) { |
1730 m_manager->setInProgressSelection(Selection(min, max), | 1854 m_manager->setInProgressSelection(Selection(alignToReference(min), |
1855 alignToReference(max)), | |
1731 !m_resizing && !m_ctrlPressed); | 1856 !m_resizing && !m_ctrlPressed); |
1732 } | 1857 } |
1733 | 1858 |
1734 edgeScrollMaybe(e->x()); | 1859 edgeScrollMaybe(e->x()); |
1735 | 1860 |
2185 break; | 2310 break; |
2186 | 2311 |
2187 case ViewManager::DrawMode: | 2312 case ViewManager::DrawMode: |
2188 setCursor(Qt::CrossCursor); | 2313 setCursor(Qt::CrossCursor); |
2189 break; | 2314 break; |
2315 | |
2316 case ViewManager::EraseMode: | |
2317 setCursor(Qt::CrossCursor); | |
2318 break; | |
2190 | 2319 |
2191 case ViewManager::MeasureMode: | 2320 case ViewManager::MeasureMode: |
2192 if (m_measureCursor1) setCursor(*m_measureCursor1); | 2321 if (m_measureCursor1) setCursor(*m_measureCursor1); |
2193 break; | 2322 break; |
2194 | 2323 |
2324 | 2453 |
2325 //!!! could call through to a layer function to find out exact meaning | 2454 //!!! could call through to a layer function to find out exact meaning |
2326 if (editable) { | 2455 if (editable) { |
2327 help = tr("Click to add a new item in the active layer"); | 2456 help = tr("Click to add a new item in the active layer"); |
2328 } | 2457 } |
2458 | |
2459 } else if (mode == ViewManager::EraseMode) { | |
2460 | |
2461 //!!! could call through to a layer function to find out exact meaning | |
2462 if (editable) { | |
2463 help = tr("Click to erase an item from the active layer"); | |
2464 } | |
2329 | 2465 |
2330 } else if (mode == ViewManager::EditMode) { | 2466 } else if (mode == ViewManager::EditMode) { |
2331 | 2467 |
2332 //!!! could call through to layer | 2468 //!!! could call through to layer |
2333 if (editable) { | 2469 if (editable) { |