Mercurial > hg > svgui
comparison view/Pane.cpp @ 840:d843e6275d0f
Use getInteractionLayer for immediate interactions, rather than getSelectedLayer (which may be invisible)
author | Chris Cannam |
---|---|
date | Tue, 02 Sep 2014 16:14:22 +0100 |
parents | 7792b7667f74 |
children | c17719e488c9 |
comparison
equal
deleted
inserted
replaced
839:757b7baac614 | 840:d843e6275d0f |
---|---|
345 | 345 |
346 if (m_manager && !m_manager->shouldIlluminateLocalFeatures()) { | 346 if (m_manager && !m_manager->shouldIlluminateLocalFeatures()) { |
347 return false; | 347 return false; |
348 } | 348 } |
349 | 349 |
350 if (layer == getSelectedLayer() && | 350 if (layer == getInteractionLayer() && |
351 !shouldIlluminateLocalSelection(discard, b0, b1)) { | 351 !shouldIlluminateLocalSelection(discard, b0, b1)) { |
352 | 352 |
353 pos = m_identifyPoint; | 353 pos = m_identifyPoint; |
354 return m_identifyFeatures; | 354 return m_identifyFeatures; |
355 } | 355 } |
370 | 370 |
371 Selection s(getSelectionAt(m_identifyPoint.x(), | 371 Selection s(getSelectionAt(m_identifyPoint.x(), |
372 closeToLeft, closeToRight)); | 372 closeToLeft, closeToRight)); |
373 | 373 |
374 if (!s.isEmpty()) { | 374 if (!s.isEmpty()) { |
375 if (getSelectedLayer() && getSelectedLayer()->isLayerEditable()) { | 375 if (getInteractionLayer() && getInteractionLayer()->isLayerEditable()) { |
376 | 376 |
377 pos = m_identifyPoint; | 377 pos = m_identifyPoint; |
378 return true; | 378 return true; |
379 } | 379 } |
380 } | 380 } |
1365 | 1365 |
1366 int mouseFrame = getFrameForX(e->x()); | 1366 int mouseFrame = getFrameForX(e->x()); |
1367 int resolution = 1; | 1367 int resolution = 1; |
1368 int snapFrame = mouseFrame; | 1368 int snapFrame = mouseFrame; |
1369 | 1369 |
1370 Layer *layer = getSelectedLayer(); | 1370 Layer *layer = getInteractionLayer(); |
1371 if (layer && !m_shiftPressed) { | 1371 if (layer && !m_shiftPressed) { |
1372 layer->snapToFeatureFrame(this, snapFrame, | 1372 layer->snapToFeatureFrame(this, snapFrame, |
1373 resolution, Layer::SnapLeft); | 1373 resolution, Layer::SnapLeft); |
1374 } | 1374 } |
1375 | 1375 |
1395 | 1395 |
1396 update(); | 1396 update(); |
1397 | 1397 |
1398 } else if (mode == ViewManager::DrawMode) { | 1398 } else if (mode == ViewManager::DrawMode) { |
1399 | 1399 |
1400 Layer *layer = getSelectedLayer(); | 1400 Layer *layer = getInteractionLayer(); |
1401 if (layer && layer->isLayerEditable()) { | 1401 if (layer && layer->isLayerEditable()) { |
1402 layer->drawStart(this, e); | 1402 layer->drawStart(this, e); |
1403 } | 1403 } |
1404 | 1404 |
1405 } else if (mode == ViewManager::EraseMode) { | 1405 } else if (mode == ViewManager::EraseMode) { |
1406 | 1406 |
1407 Layer *layer = getSelectedLayer(); | 1407 Layer *layer = getInteractionLayer(); |
1408 if (layer && layer->isLayerEditable()) { | 1408 if (layer && layer->isLayerEditable()) { |
1409 layer->eraseStart(this, e); | 1409 layer->eraseStart(this, e); |
1410 } | 1410 } |
1411 | 1411 |
1412 // GF: handle mouse press for NoteEditMode | 1412 // GF: handle mouse press for NoteEditMode |
1520 | 1520 |
1521 update(); | 1521 update(); |
1522 | 1522 |
1523 } else if (mode == ViewManager::DrawMode) { | 1523 } else if (mode == ViewManager::DrawMode) { |
1524 | 1524 |
1525 Layer *layer = getSelectedLayer(); | 1525 Layer *layer = getInteractionLayer(); |
1526 if (layer && layer->isLayerEditable()) { | 1526 if (layer && layer->isLayerEditable()) { |
1527 layer->drawEnd(this, e); | 1527 layer->drawEnd(this, e); |
1528 update(); | 1528 update(); |
1529 } | 1529 } |
1530 | 1530 |
1531 } else if (mode == ViewManager::EraseMode) { | 1531 } else if (mode == ViewManager::EraseMode) { |
1532 | 1532 |
1533 Layer *layer = getSelectedLayer(); | 1533 Layer *layer = getInteractionLayer(); |
1534 if (layer && layer->isLayerEditable()) { | 1534 if (layer && layer->isLayerEditable()) { |
1535 layer->eraseEnd(this, e); | 1535 layer->eraseEnd(this, e); |
1536 update(); | 1536 update(); |
1537 } | 1537 } |
1538 | 1538 |
1555 | 1555 |
1556 } else if (mode == ViewManager::EditMode) { | 1556 } else if (mode == ViewManager::EditMode) { |
1557 | 1557 |
1558 if (m_editing) { | 1558 if (m_editing) { |
1559 if (!editSelectionEnd(e)) { | 1559 if (!editSelectionEnd(e)) { |
1560 Layer *layer = getSelectedLayer(); | 1560 Layer *layer = getInteractionLayer(); |
1561 if (layer && layer->isLayerEditable()) { | 1561 if (layer && layer->isLayerEditable()) { |
1562 layer->editEnd(this, e); | 1562 layer->editEnd(this, e); |
1563 update(); | 1563 update(); |
1564 } | 1564 } |
1565 } | 1565 } |
1636 | 1636 |
1637 if (!m_manager->isPlaying()) { | 1637 if (!m_manager->isPlaying()) { |
1638 | 1638 |
1639 bool updating = false; | 1639 bool updating = false; |
1640 | 1640 |
1641 if (getSelectedLayer() && | 1641 if (getInteractionLayer() && |
1642 m_manager->shouldIlluminateLocalFeatures()) { | 1642 m_manager->shouldIlluminateLocalFeatures()) { |
1643 | 1643 |
1644 bool previouslyIdentifying = m_identifyFeatures; | 1644 bool previouslyIdentifying = m_identifyFeatures; |
1645 m_identifyFeatures = true; | 1645 m_identifyFeatures = true; |
1646 | 1646 |
1683 | 1683 |
1684 dragExtendSelection(e); | 1684 dragExtendSelection(e); |
1685 | 1685 |
1686 } else if (mode == ViewManager::DrawMode) { | 1686 } else if (mode == ViewManager::DrawMode) { |
1687 | 1687 |
1688 Layer *layer = getSelectedLayer(); | 1688 Layer *layer = getInteractionLayer(); |
1689 if (layer && layer->isLayerEditable()) { | 1689 if (layer && layer->isLayerEditable()) { |
1690 layer->drawDrag(this, e); | 1690 layer->drawDrag(this, e); |
1691 } | 1691 } |
1692 | 1692 |
1693 } else if (mode == ViewManager::EraseMode) { | 1693 } else if (mode == ViewManager::EraseMode) { |
1694 | 1694 |
1695 Layer *layer = getSelectedLayer(); | 1695 Layer *layer = getInteractionLayer(); |
1696 if (layer && layer->isLayerEditable()) { | 1696 if (layer && layer->isLayerEditable()) { |
1697 layer->eraseDrag(this, e); | 1697 layer->eraseDrag(this, e); |
1698 } | 1698 } |
1699 | 1699 |
1700 // GF: handling NoteEditMode dragging and boundary actions for mouseMoveEvent | 1700 // GF: handling NoteEditMode dragging and boundary actions for mouseMoveEvent |
1740 | 1740 |
1741 } else { | 1741 } else { |
1742 | 1742 |
1743 if (!editSelectionDrag(e)) { | 1743 if (!editSelectionDrag(e)) { |
1744 | 1744 |
1745 Layer *layer = getSelectedLayer(); | 1745 Layer *layer = getInteractionLayer(); |
1746 | 1746 |
1747 if (layer && layer->isLayerEditable()) { | 1747 if (layer && layer->isLayerEditable()) { |
1748 | 1748 |
1749 int x = e->x(); | 1749 int x = e->x(); |
1750 int y = e->y(); | 1750 int y = e->y(); |
1795 Qt::NoButton, | 1795 Qt::NoButton, |
1796 e->buttons(), | 1796 e->buttons(), |
1797 e->modifiers()); | 1797 e->modifiers()); |
1798 | 1798 |
1799 if (!editSelectionStart(&clickEvent)) { | 1799 if (!editSelectionStart(&clickEvent)) { |
1800 Layer *layer = getSelectedLayer(); | 1800 Layer *layer = getInteractionLayer(); |
1801 if (layer && layer->isLayerEditable()) { | 1801 if (layer && layer->isLayerEditable()) { |
1802 layer->editStart(this, &clickEvent); | 1802 layer->editStart(this, &clickEvent); |
1803 } | 1803 } |
1804 } | 1804 } |
1805 } | 1805 } |
1806 | 1806 |
1807 } else { | 1807 } else { |
1808 | 1808 |
1809 if (!editSelectionDrag(e)) { | 1809 if (!editSelectionDrag(e)) { |
1810 | 1810 |
1811 Layer *layer = getSelectedLayer(); | 1811 Layer *layer = getInteractionLayer(); |
1812 | 1812 |
1813 if (layer && layer->isLayerEditable()) { | 1813 if (layer && layer->isLayerEditable()) { |
1814 | 1814 |
1815 int x = e->x(); | 1815 int x = e->x(); |
1816 int y = e->y(); | 1816 int y = e->y(); |
2077 int mouseFrame = getFrameForX(e->x()); | 2077 int mouseFrame = getFrameForX(e->x()); |
2078 int resolution = 1; | 2078 int resolution = 1; |
2079 int snapFrameLeft = mouseFrame; | 2079 int snapFrameLeft = mouseFrame; |
2080 int snapFrameRight = mouseFrame; | 2080 int snapFrameRight = mouseFrame; |
2081 | 2081 |
2082 Layer *layer = getSelectedLayer(); | 2082 Layer *layer = getInteractionLayer(); |
2083 if (layer && !m_shiftPressed) { | 2083 if (layer && !m_shiftPressed) { |
2084 layer->snapToFeatureFrame(this, snapFrameLeft, | 2084 layer->snapToFeatureFrame(this, snapFrameLeft, |
2085 resolution, Layer::SnapLeft); | 2085 resolution, Layer::SnapLeft); |
2086 layer->snapToFeatureFrame(this, snapFrameRight, | 2086 layer->snapToFeatureFrame(this, snapFrameRight, |
2087 resolution, Layer::SnapRight); | 2087 resolution, Layer::SnapRight); |
2179 } | 2179 } |
2180 | 2180 |
2181 if (mode == ViewManager::NavigateMode || | 2181 if (mode == ViewManager::NavigateMode || |
2182 mode == ViewManager::EditMode) { | 2182 mode == ViewManager::EditMode) { |
2183 | 2183 |
2184 Layer *layer = getSelectedLayer(); | 2184 Layer *layer = getInteractionLayer(); |
2185 if (layer && layer->isLayerEditable()) { | 2185 if (layer && layer->isLayerEditable()) { |
2186 if (layer->editOpen(this, e)) relocate = false; | 2186 if (layer->editOpen(this, e)) relocate = false; |
2187 } | 2187 } |
2188 | 2188 |
2189 } else if (mode == ViewManager::MeasureMode) { | 2189 } else if (mode == ViewManager::MeasureMode) { |
2209 } | 2209 } |
2210 } | 2210 } |
2211 | 2211 |
2212 if (mode == ViewManager::NoteEditMode) { | 2212 if (mode == ViewManager::NoteEditMode) { |
2213 std::cerr << "double click in note edit mode" << std::endl; | 2213 std::cerr << "double click in note edit mode" << std::endl; |
2214 Layer *layer = getSelectedLayer(); | 2214 Layer *layer = getInteractionLayer(); |
2215 if (layer && layer->isLayerEditable()) { | 2215 if (layer && layer->isLayerEditable()) { |
2216 layer->addNote(this, e); | 2216 layer->addNote(this, e); |
2217 } | 2217 } |
2218 } | 2218 } |
2219 | 2219 |
2581 Pane::editSelectionEnd(QMouseEvent *) | 2581 Pane::editSelectionEnd(QMouseEvent *) |
2582 { | 2582 { |
2583 if (m_editingSelection.isEmpty()) return false; | 2583 if (m_editingSelection.isEmpty()) return false; |
2584 | 2584 |
2585 int offset = m_mousePos.x() - m_clickPos.x(); | 2585 int offset = m_mousePos.x() - m_clickPos.x(); |
2586 Layer *layer = getSelectedLayer(); | 2586 Layer *layer = getInteractionLayer(); |
2587 | 2587 |
2588 if (offset == 0 || !layer) { | 2588 if (offset == 0 || !layer) { |
2589 m_editingSelection = Selection(); | 2589 m_editingSelection = Selection(); |
2590 return true; | 2590 return true; |
2591 } | 2591 } |
2763 | 2763 |
2764 ViewManager::ToolMode mode = ViewManager::NavigateMode; | 2764 ViewManager::ToolMode mode = ViewManager::NavigateMode; |
2765 if (m_manager) mode = m_manager->getToolModeFor(this); | 2765 if (m_manager) mode = m_manager->getToolModeFor(this); |
2766 | 2766 |
2767 bool editable = false; | 2767 bool editable = false; |
2768 Layer *layer = getSelectedLayer(); | 2768 Layer *layer = getInteractionLayer(); |
2769 if (layer && layer->isLayerEditable()) { | 2769 if (layer && layer->isLayerEditable()) { |
2770 editable = true; | 2770 editable = true; |
2771 } | 2771 } |
2772 | 2772 |
2773 if (mode == ViewManager::NavigateMode) { | 2773 if (mode == ViewManager::NavigateMode) { |