Mercurial > hg > svgui
comparison view/Pane.cpp @ 713:6d79ad93fef0 tonioni
Fix indentation
author | Chris Cannam |
---|---|
date | Fri, 10 Jan 2014 09:52:38 +0000 |
parents | 084fd76deb89 |
children | 67b167bb60ab |
comparison
equal
deleted
inserted
replaced
712:833cd1b8014f | 713:6d79ad93fef0 |
---|---|
171 RangeMapper *rm = layer->getNewVerticalZoomRangeMapper(); | 171 RangeMapper *rm = layer->getNewVerticalZoomRangeMapper(); |
172 if (rm) m_vthumb->setRangeMapper(rm); | 172 if (rm) m_vthumb->setRangeMapper(rm); |
173 } | 173 } |
174 | 174 |
175 m_reset = new NotifyingPushButton; | 175 m_reset = new NotifyingPushButton; |
176 m_reset->setFlat(true); | 176 m_reset->setFlat(true); |
177 m_reset->setCursor(Qt::ArrowCursor); | 177 m_reset->setCursor(Qt::ArrowCursor); |
178 m_reset->setFixedHeight(16); | 178 m_reset->setFixedHeight(16); |
179 m_reset->setFixedWidth(16); | 179 m_reset->setFixedWidth(16); |
180 m_reset->setIcon(QPixmap(":/icons/zoom-reset.png")); | 180 m_reset->setIcon(QPixmap(":/icons/zoom-reset.png")); |
181 m_reset->setToolTip(tr("Reset zoom to default")); | 181 m_reset->setToolTip(tr("Reset zoom to default")); |
1306 if (mode == ViewManager::NavigateMode || | 1306 if (mode == ViewManager::NavigateMode || |
1307 (e->buttons() & Qt::MidButton) || | 1307 (e->buttons() & Qt::MidButton) || |
1308 (mode == ViewManager::MeasureMode && | 1308 (mode == ViewManager::MeasureMode && |
1309 (e->buttons() & Qt::LeftButton) && m_shiftPressed)) { | 1309 (e->buttons() & Qt::LeftButton) && m_shiftPressed)) { |
1310 | 1310 |
1311 if (mode != ViewManager::NavigateMode) { | 1311 if (mode != ViewManager::NavigateMode) { |
1312 setCursor(Qt::PointingHandCursor); | 1312 setCursor(Qt::PointingHandCursor); |
1313 } | 1313 } |
1314 | 1314 |
1315 m_navigating = true; | 1315 m_navigating = true; |
1316 m_dragCentreFrame = m_centreFrame; | 1316 m_dragCentreFrame = m_centreFrame; |
1317 m_dragStartMinValue = 0; | 1317 m_dragStartMinValue = 0; |
1318 | 1318 |
1319 float vmin, vmax, dmin, dmax; | 1319 float vmin, vmax, dmin, dmax; |
1320 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) { | 1320 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) { |
1321 m_dragStartMinValue = dmin; | 1321 m_dragStartMinValue = dmin; |
1323 | 1323 |
1324 } else if (mode == ViewManager::SelectMode) { | 1324 } else if (mode == ViewManager::SelectMode) { |
1325 | 1325 |
1326 if (!hasTopLayerTimeXAxis()) return; | 1326 if (!hasTopLayerTimeXAxis()) return; |
1327 | 1327 |
1328 bool closeToLeft = false, closeToRight = false; | 1328 bool closeToLeft = false, closeToRight = false; |
1329 Selection selection = getSelectionAt(e->x(), closeToLeft, closeToRight); | 1329 Selection selection = getSelectionAt(e->x(), closeToLeft, closeToRight); |
1330 | 1330 |
1331 if ((closeToLeft || closeToRight) && !(closeToLeft && closeToRight)) { | 1331 if ((closeToLeft || closeToRight) && !(closeToLeft && closeToRight)) { |
1332 | 1332 |
1333 m_manager->removeSelection(selection); | 1333 m_manager->removeSelection(selection); |
1334 | 1334 |
1335 if (closeToLeft) { | 1335 if (closeToLeft) { |
1336 m_selectionStartFrame = selection.getEndFrame(); | 1336 m_selectionStartFrame = selection.getEndFrame(); |
1337 } else { | |
1338 m_selectionStartFrame = selection.getStartFrame(); | |
1339 } | |
1340 | |
1341 m_manager->setInProgressSelection(selection, false); | |
1342 m_resizing = true; | |
1343 | |
1337 } else { | 1344 } else { |
1338 m_selectionStartFrame = selection.getStartFrame(); | 1345 |
1339 } | 1346 int mouseFrame = getFrameForX(e->x()); |
1340 | 1347 size_t resolution = 1; |
1341 m_manager->setInProgressSelection(selection, false); | 1348 int snapFrame = mouseFrame; |
1342 m_resizing = true; | 1349 |
1343 | 1350 Layer *layer = getSelectedLayer(); |
1344 } else { | 1351 if (layer && !m_shiftPressed) { |
1345 | 1352 layer->snapToFeatureFrame(this, snapFrame, |
1346 int mouseFrame = getFrameForX(e->x()); | 1353 resolution, Layer::SnapLeft); |
1347 size_t resolution = 1; | 1354 } |
1348 int snapFrame = mouseFrame; | 1355 |
1349 | 1356 if (snapFrame < 0) snapFrame = 0; |
1350 Layer *layer = getSelectedLayer(); | 1357 m_selectionStartFrame = snapFrame; |
1351 if (layer && !m_shiftPressed) { | 1358 if (m_manager) { |
1352 layer->snapToFeatureFrame(this, snapFrame, | 1359 m_manager->setInProgressSelection |
1353 resolution, Layer::SnapLeft); | |
1354 } | |
1355 | |
1356 if (snapFrame < 0) snapFrame = 0; | |
1357 m_selectionStartFrame = snapFrame; | |
1358 if (m_manager) { | |
1359 m_manager->setInProgressSelection | |
1360 (Selection(alignToReference(snapFrame), | 1360 (Selection(alignToReference(snapFrame), |
1361 alignToReference(snapFrame + resolution)), | 1361 alignToReference(snapFrame + resolution)), |
1362 !m_ctrlPressed); | 1362 !m_ctrlPressed); |
1363 } | 1363 } |
1364 | 1364 |
1365 m_resizing = false; | 1365 m_resizing = false; |
1366 } | 1366 } |
1367 | 1367 |
1368 update(); | 1368 update(); |
1369 | 1369 |
1370 } else if (mode == ViewManager::DrawMode) { | 1370 } else if (mode == ViewManager::DrawMode) { |
1371 | 1371 |
1372 Layer *layer = getSelectedLayer(); | 1372 Layer *layer = getSelectedLayer(); |
1373 if (layer && layer->isLayerEditable()) { | 1373 if (layer && layer->isLayerEditable()) { |
1374 layer->drawStart(this, e); | 1374 layer->drawStart(this, e); |
1375 } | 1375 } |
1376 | 1376 |
1377 } else if (mode == ViewManager::EraseMode) { | 1377 } else if (mode == ViewManager::EraseMode) { |
1378 | 1378 |
1379 Layer *layer = getSelectedLayer(); | 1379 Layer *layer = getSelectedLayer(); |
1380 if (layer && layer->isLayerEditable()) { | 1380 if (layer && layer->isLayerEditable()) { |
1381 layer->eraseStart(this, e); | 1381 layer->eraseStart(this, e); |
1382 } | 1382 } |
1383 | 1383 |
1384 // GF: handle mouse press for NoteEditMode | 1384 // GF: handle mouse press for NoteEditMode |
1385 } else if (mode == ViewManager::NoteEditMode) { | 1385 } else if (mode == ViewManager::NoteEditMode) { |
1386 | 1386 |
1387 std::cerr << "mouse pressed in note edit mode" << std::endl; | 1387 std::cerr << "mouse pressed in note edit mode" << std::endl; |
1388 Layer *layer = getSelectedLayer(); | 1388 Layer *layer = getSelectedLayer(); |
1389 if (layer && layer->isLayerEditable()) { | 1389 if (layer && layer->isLayerEditable()) { |
1418 if (m_manager) mode = m_manager->getToolModeFor(this); | 1418 if (m_manager) mode = m_manager->getToolModeFor(this); |
1419 | 1419 |
1420 m_releasing = true; | 1420 m_releasing = true; |
1421 | 1421 |
1422 if (m_clickedInRange) { | 1422 if (m_clickedInRange) { |
1423 mouseMoveEvent(e); | 1423 mouseMoveEvent(e); |
1424 } | 1424 } |
1425 | 1425 |
1426 if (m_navigating || mode == ViewManager::NavigateMode) { | 1426 if (m_navigating || mode == ViewManager::NavigateMode) { |
1427 | 1427 |
1428 m_navigating = false; | 1428 m_navigating = false; |
1429 | 1429 |
1430 if (mode != ViewManager::NavigateMode) { | 1430 if (mode != ViewManager::NavigateMode) { |
1431 // restore cursor | 1431 // restore cursor |
1432 toolModeChanged(); | 1432 toolModeChanged(); |
1433 } | 1433 } |
1434 | 1434 |
1435 if (m_shiftPressed) { | 1435 if (m_shiftPressed) { |
1436 | 1436 |
1437 int x0 = std::min(m_clickPos.x(), m_mousePos.x()); | 1437 int x0 = std::min(m_clickPos.x(), m_mousePos.x()); |
1438 int x1 = std::max(m_clickPos.x(), m_mousePos.x()); | 1438 int x1 = std::max(m_clickPos.x(), m_mousePos.x()); |
1439 | 1439 |
1440 int y0 = std::min(m_clickPos.y(), m_mousePos.y()); | 1440 int y0 = std::min(m_clickPos.y(), m_mousePos.y()); |
1441 int y1 = std::max(m_clickPos.y(), m_mousePos.y()); | 1441 int y1 = std::max(m_clickPos.y(), m_mousePos.y()); |
1442 | 1442 |
1443 zoomToRegion(x0, y0, x1, y1); | 1443 zoomToRegion(x0, y0, x1, y1); |
1444 } | 1444 } |
1445 | 1445 |
1446 } else if (mode == ViewManager::SelectMode) { | 1446 } else if (mode == ViewManager::SelectMode) { |
1447 | 1447 |
1448 if (!hasTopLayerTimeXAxis()) { | 1448 if (!hasTopLayerTimeXAxis()) { |
1449 m_releasing = false; | 1449 m_releasing = false; |
1450 return; | 1450 return; |
1451 } | 1451 } |
1452 | 1452 |
1453 if (m_manager && m_manager->haveInProgressSelection()) { | 1453 if (m_manager && m_manager->haveInProgressSelection()) { |
1454 | 1454 |
1455 bool exclusive; | 1455 bool exclusive; |
1456 Selection selection = m_manager->getInProgressSelection(exclusive); | 1456 Selection selection = m_manager->getInProgressSelection(exclusive); |
1457 | 1457 |
1458 if (selection.getEndFrame() < selection.getStartFrame() + 2) { | 1458 if (selection.getEndFrame() < selection.getStartFrame() + 2) { |
1459 selection = Selection(); | 1459 selection = Selection(); |
1460 } | 1460 } |
1461 | 1461 |
1462 m_manager->clearInProgressSelection(); | 1462 m_manager->clearInProgressSelection(); |
1463 | 1463 |
1464 if (exclusive) { | 1464 if (exclusive) { |
1465 m_manager->setSelection(selection); | 1465 m_manager->setSelection(selection); |
1466 } else { | 1466 } else { |
1467 m_manager->addSelection(selection); | 1467 m_manager->addSelection(selection); |
1468 } | 1468 } |
1469 } | 1469 } |
1470 | 1470 |
1471 update(); | 1471 update(); |
1472 | 1472 |
1473 } else if (mode == ViewManager::DrawMode) { | 1473 } else if (mode == ViewManager::DrawMode) { |
1474 | 1474 |
1475 Layer *layer = getSelectedLayer(); | 1475 Layer *layer = getSelectedLayer(); |
1476 if (layer && layer->isLayerEditable()) { | 1476 if (layer && layer->isLayerEditable()) { |
1477 layer->drawEnd(this, e); | 1477 layer->drawEnd(this, e); |
1478 update(); | 1478 update(); |
1479 } | 1479 } |
1480 | 1480 |
1481 } else if (mode == ViewManager::EraseMode) { | 1481 } else if (mode == ViewManager::EraseMode) { |
1482 | 1482 |
1483 Layer *layer = getSelectedLayer(); | 1483 Layer *layer = getSelectedLayer(); |
1484 if (layer && layer->isLayerEditable()) { | 1484 if (layer && layer->isLayerEditable()) { |
1609 update(); | 1609 update(); |
1610 } | 1610 } |
1611 } | 1611 } |
1612 } | 1612 } |
1613 | 1613 |
1614 return; | 1614 return; |
1615 } | 1615 } |
1616 | 1616 |
1617 if (m_navigating || mode == ViewManager::NavigateMode) { | 1617 if (m_navigating || mode == ViewManager::NavigateMode) { |
1618 | 1618 |
1619 if (m_shiftPressed) { | 1619 if (m_shiftPressed) { |
1620 | 1620 |
1621 m_mousePos = e->pos(); | 1621 m_mousePos = e->pos(); |
1622 update(); | 1622 update(); |
1623 | 1623 |
1624 } else { | 1624 } else { |
1625 | 1625 |
1626 dragTopLayer(e); | 1626 dragTopLayer(e); |
1627 } | 1627 } |
1628 | 1628 |
1629 } else if (mode == ViewManager::SelectMode) { | 1629 } else if (mode == ViewManager::SelectMode) { |
1630 | 1630 |
1631 if (!hasTopLayerTimeXAxis()) return; | 1631 if (!hasTopLayerTimeXAxis()) return; |
1632 | 1632 |
1633 dragExtendSelection(e); | 1633 dragExtendSelection(e); |
1634 | 1634 |
1635 } else if (mode == ViewManager::DrawMode) { | 1635 } else if (mode == ViewManager::DrawMode) { |
1636 | 1636 |
1637 Layer *layer = getSelectedLayer(); | 1637 Layer *layer = getSelectedLayer(); |
1638 if (layer && layer->isLayerEditable()) { | 1638 if (layer && layer->isLayerEditable()) { |
1644 Layer *layer = getSelectedLayer(); | 1644 Layer *layer = getSelectedLayer(); |
1645 if (layer && layer->isLayerEditable()) { | 1645 if (layer && layer->isLayerEditable()) { |
1646 layer->eraseDrag(this, e); | 1646 layer->eraseDrag(this, e); |
1647 } | 1647 } |
1648 | 1648 |
1649 // GF: handling NoteEditMode dragging and boundary actions for mouseMoveEvent | 1649 // GF: handling NoteEditMode dragging and boundary actions for mouseMoveEvent |
1650 } else if (mode == ViewManager::NoteEditMode) { | 1650 } else if (mode == ViewManager::NoteEditMode) { |
1651 | 1651 |
1652 bool resist = true; | 1652 bool resist = true; |
1653 | 1653 |
1654 if ((e->modifiers() & Qt::ShiftModifier)) { | 1654 if ((e->modifiers() & Qt::ShiftModifier)) { |
2512 } | 2512 } |
2513 | 2513 |
2514 switch (mode) { | 2514 switch (mode) { |
2515 | 2515 |
2516 case ViewManager::NavigateMode: | 2516 case ViewManager::NavigateMode: |
2517 setCursor(Qt::PointingHandCursor); | 2517 setCursor(Qt::PointingHandCursor); |
2518 break; | 2518 break; |
2519 | 2519 |
2520 case ViewManager::SelectMode: | 2520 case ViewManager::SelectMode: |
2521 setCursor(Qt::ArrowCursor); | 2521 setCursor(Qt::ArrowCursor); |
2522 break; | 2522 break; |
2523 | 2523 |
2524 case ViewManager::EditMode: | 2524 case ViewManager::EditMode: |
2525 setCursor(Qt::UpArrowCursor); | 2525 setCursor(Qt::UpArrowCursor); |
2526 break; | 2526 break; |
2527 | 2527 |
2528 case ViewManager::DrawMode: | 2528 case ViewManager::DrawMode: |
2529 setCursor(Qt::CrossCursor); | 2529 setCursor(Qt::CrossCursor); |
2530 break; | 2530 break; |
2531 | 2531 |
2532 case ViewManager::EraseMode: | 2532 case ViewManager::EraseMode: |
2533 setCursor(Qt::CrossCursor); | 2533 setCursor(Qt::CrossCursor); |
2534 break; | 2534 break; |
2535 | 2535 |
2536 case ViewManager::MeasureMode: | 2536 case ViewManager::MeasureMode: |
2537 if (m_measureCursor1) setCursor(*m_measureCursor1); | 2537 if (m_measureCursor1) setCursor(*m_measureCursor1); |
2538 break; | 2538 break; |
2539 | 2539 |
2540 // GF: NoteEditMode uses the same default cursor as EditMode, but it will change in a context sensitive manner. | 2540 // GF: NoteEditMode uses the same default cursor as EditMode, but it will change in a context sensitive manner. |
2541 case ViewManager::NoteEditMode: | 2541 case ViewManager::NoteEditMode: |
2542 setCursor(Qt::UpArrowCursor); | 2542 setCursor(Qt::UpArrowCursor); |
2543 break; | 2543 break; |
2544 | 2544 |
2545 /* | 2545 /* |
2546 case ViewManager::TextMode: | 2546 case ViewManager::TextMode: |
2547 setCursor(Qt::IBeamCursor); | 2547 setCursor(Qt::IBeamCursor); |
2548 break; | 2548 break; |
2679 } | 2679 } |
2680 | 2680 |
2681 } else if (mode == ViewManager::DrawMode) { | 2681 } else if (mode == ViewManager::DrawMode) { |
2682 | 2682 |
2683 //!!! could call through to a layer function to find out exact meaning | 2683 //!!! could call through to a layer function to find out exact meaning |
2684 if (editable) { | 2684 if (editable) { |
2685 help = tr("Click to add a new item in the active layer"); | 2685 help = tr("Click to add a new item in the active layer"); |
2686 } | 2686 } |
2687 | 2687 |
2688 } else if (mode == ViewManager::EraseMode) { | 2688 } else if (mode == ViewManager::EraseMode) { |
2689 | 2689 |
2690 //!!! could call through to a layer function to find out exact meaning | 2690 //!!! could call through to a layer function to find out exact meaning |
2691 if (editable) { | 2691 if (editable) { |
2692 help = tr("Click to erase an item from the active layer"); | 2692 help = tr("Click to erase an item from the active layer"); |
2693 } | 2693 } |
2694 | 2694 |
2695 } else if (mode == ViewManager::EditMode) { | 2695 } else if (mode == ViewManager::EditMode) { |
2696 | 2696 |
2697 //!!! could call through to layer | 2697 //!!! could call through to layer |
2698 if (editable) { | 2698 if (editable) { |
2699 help = tr("Click and drag an item in the active layer to move it; hold Shift to override initial resistance"); | 2699 help = tr("Click and drag an item in the active layer to move it; hold Shift to override initial resistance"); |
2700 if (pos) { | 2700 if (pos) { |
2701 bool closeToLeft = false, closeToRight = false; | 2701 bool closeToLeft = false, closeToRight = false; |
2702 Selection selection = getSelectionAt(pos->x(), closeToLeft, closeToRight); | 2702 Selection selection = getSelectionAt(pos->x(), closeToLeft, closeToRight); |
2703 if (!selection.isEmpty()) { | 2703 if (!selection.isEmpty()) { |