comparison view/Pane.cpp @ 718:e5f4385615ac tony_integration

Merge from tonioni branch
author Chris Cannam
date Tue, 28 Jan 2014 15:02:09 +0000
parents 67b167bb60ab
children 62e7d4b378ae
comparison
equal deleted inserted replaced
704:b81f21f2c4c3 718:e5f4385615ac
22 #include "ViewManager.h" 22 #include "ViewManager.h"
23 #include "widgets/CommandHistory.h" 23 #include "widgets/CommandHistory.h"
24 #include "widgets/TextAbbrev.h" 24 #include "widgets/TextAbbrev.h"
25 #include "base/Preferences.h" 25 #include "base/Preferences.h"
26 #include "layer/WaveformLayer.h" 26 #include "layer/WaveformLayer.h"
27
28 // GF: added so we can propagate the mouse move event to the note layer for context handling.
29 #include "layer/LayerFactory.h"
30 #include "layer/FlexiNoteLayer.h"
31
27 32
28 //!!! ugh 33 //!!! ugh
29 #include "data/model/WaveFileModel.h" 34 #include "data/model/WaveFileModel.h"
30 35
31 #include <QPaintEvent> 36 #include <QPaintEvent>
166 RangeMapper *rm = layer->getNewVerticalZoomRangeMapper(); 171 RangeMapper *rm = layer->getNewVerticalZoomRangeMapper();
167 if (rm) m_vthumb->setRangeMapper(rm); 172 if (rm) m_vthumb->setRangeMapper(rm);
168 } 173 }
169 174
170 m_reset = new NotifyingPushButton; 175 m_reset = new NotifyingPushButton;
171 m_reset->setFlat(true); 176 m_reset->setFlat(true);
172 m_reset->setCursor(Qt::ArrowCursor); 177 m_reset->setCursor(Qt::ArrowCursor);
173 m_reset->setFixedHeight(16); 178 m_reset->setFixedHeight(16);
174 m_reset->setFixedWidth(16); 179 m_reset->setFixedWidth(16);
175 m_reset->setIcon(QPixmap(":/icons/zoom-reset.png")); 180 m_reset->setIcon(QPixmap(":/icons/zoom-reset.png"));
176 m_reset->setToolTip(tr("Reset zoom to default")); 181 m_reset->setToolTip(tr("Reset zoom to default"));
326 Pane::shouldIlluminateLocalFeatures(const Layer *layer, QPoint &pos) const 331 Pane::shouldIlluminateLocalFeatures(const Layer *layer, QPoint &pos) const
327 { 332 {
328 QPoint discard; 333 QPoint discard;
329 bool b0, b1; 334 bool b0, b1;
330 335
331 if (m_manager && m_manager->getToolMode() == ViewManager::MeasureMode) { 336 if (m_manager && m_manager->getToolModeFor(this) == ViewManager::MeasureMode) {
332 return false; 337 return false;
333 } 338 }
334 339
335 if (m_manager && !m_manager->shouldIlluminateLocalFeatures()) { 340 if (m_manager && !m_manager->shouldIlluminateLocalFeatures()) {
336 return false; 341 return false;
337 } 342 }
338 343
339 if (layer == getSelectedLayer() && 344 if (layer == getSelectedLayer() &&
340 !shouldIlluminateLocalSelection(discard, b0, b1)) { 345 !shouldIlluminateLocalSelection(discard, b0, b1)) {
341 346
342 pos = m_identifyPoint; 347 pos = m_identifyPoint;
343 return m_identifyFeatures; 348 return m_identifyFeatures;
344 } 349 }
345 350
346 return false; 351 return false;
347 } 352 }
348 353
349 bool 354 bool
350 Pane::shouldIlluminateLocalSelection(QPoint &pos, 355 Pane::shouldIlluminateLocalSelection(QPoint &pos,
351 bool &closeToLeft, 356 bool &closeToLeft,
352 bool &closeToRight) const 357 bool &closeToRight) const
353 { 358 {
354 if (m_identifyFeatures && 359 if (m_identifyFeatures &&
355 m_manager && 360 m_manager &&
356 m_manager->getToolMode() == ViewManager::EditMode && 361 m_manager->getToolModeFor(this) == ViewManager::EditMode &&
357 !m_manager->getSelections().empty() && 362 !m_manager->getSelections().empty() &&
358 !selectionIsBeingEdited()) { 363 !selectionIsBeingEdited()) {
359 364
360 Selection s(getSelectionAt(m_identifyPoint.x(), 365 Selection s(getSelectionAt(m_identifyPoint.x(),
361 closeToLeft, closeToRight)); 366 closeToLeft, closeToRight));
362 367
363 if (!s.isEmpty()) { 368 if (!s.isEmpty()) {
364 if (getSelectedLayer() && getSelectedLayer()->isLayerEditable()) { 369 if (getSelectedLayer() && getSelectedLayer()->isLayerEditable()) {
365 370
366 pos = m_identifyPoint; 371 pos = m_identifyPoint;
367 return true; 372 return true;
368 } 373 }
369 } 374 }
370 } 375 }
371 376
372 return false; 377 return false;
373 } 378 }
374 379
375 bool 380 bool
376 Pane::selectionIsBeingEdited() const 381 Pane::selectionIsBeingEdited() const
377 { 382 {
378 if (!m_editingSelection.isEmpty()) { 383 if (!m_editingSelection.isEmpty()) {
379 if (m_mousePos != m_clickPos && 384 if (m_mousePos != m_clickPos &&
380 getFrameForX(m_mousePos.x()) != getFrameForX(m_clickPos.x())) { 385 getFrameForX(m_mousePos.x()) != getFrameForX(m_clickPos.x())) {
381 return true; 386 return true;
382 } 387 }
383 } 388 }
384 return false; 389 return false;
385 } 390 }
386 391
387 void 392 void
406 paint.begin(this); 411 paint.begin(this);
407 setPaintFont(paint); 412 setPaintFont(paint);
408 413
409 if (e) paint.setClipRect(r); 414 if (e) paint.setClipRect(r);
410 415
411 ViewManager::ToolMode toolMode = m_manager->getToolMode(); 416 ViewManager::ToolMode toolMode = m_manager->getToolModeFor(this);
412 417
413 if (m_manager && 418 if (m_manager &&
414 // !m_manager->isPlaying() && 419 // !m_manager->isPlaying() &&
415 m_mouseInWidget && 420 m_mouseInWidget &&
416 toolMode == ViewManager::MeasureMode) { 421 toolMode == ViewManager::MeasureMode) {
624 629
625 if (!scaleLayer) m_scaleWidth = 0; 630 if (!scaleLayer) m_scaleWidth = 0;
626 631
627 if (m_scaleWidth > 0 && r.left() < m_scaleWidth) { 632 if (m_scaleWidth > 0 && r.left() < m_scaleWidth) {
628 633
629 // Profiler profiler("Pane::paintEvent - painting vertical scale", true); 634 // Profiler profiler("Pane::paintEvent - painting vertical scale", true);
630 635
631 // SVDEBUG << "Pane::paintEvent: calling paint.save() in vertical scale block" << endl; 636 // SVDEBUG << "Pane::paintEvent: calling paint.save() in vertical scale block" << endl;
632 paint.save(); 637 paint.save();
633 638
634 paint.setPen(getForeground()); 639 paint.setPen(getForeground());
635 paint.setBrush(getBackground()); 640 paint.setBrush(getBackground());
636 paint.drawRect(0, -1, m_scaleWidth, height()+1); 641 paint.drawRect(0, -1, m_scaleWidth, height()+1);
647 void 652 void
648 Pane::drawFeatureDescription(Layer *topLayer, QPainter &paint) 653 Pane::drawFeatureDescription(Layer *topLayer, QPainter &paint)
649 { 654 {
650 QPoint pos = m_identifyPoint; 655 QPoint pos = m_identifyPoint;
651 QString desc = topLayer->getFeatureDescription(this, pos); 656 QString desc = topLayer->getFeatureDescription(this, pos);
652 657
653 if (desc != "") { 658 if (desc != "") {
654 659
655 paint.save(); 660 paint.save();
656 661
657 int tabStop = 662 int tabStop =
724 int y = height() - fontHeight + fontAscent - 6; 729 int y = height() - fontHeight + fontAscent - 6;
725 730
726 LayerList::iterator vi = m_layers.end(); 731 LayerList::iterator vi = m_layers.end();
727 732
728 if (vi != m_layers.begin()) { 733 if (vi != m_layers.begin()) {
729 734
730 switch ((*--vi)->getPreferredFrameCountPosition()) { 735 switch ((*--vi)->getPreferredFrameCountPosition()) {
731 736
732 case Layer::PositionTop: 737 case Layer::PositionTop:
733 y = fontAscent + 6; 738 y = fontAscent + 6;
734 break; 739 break;
891 if (m_manager->getZoomWheelsEnabled()) { 896 if (m_manager->getZoomWheelsEnabled()) {
892 llx -= 36; 897 llx -= 36;
893 } 898 }
894 899
895 if (r.x() + r.width() >= llx - fontAscent - 3) { 900 if (r.x() + r.width() >= llx - fontAscent - 3) {
896 901
897 for (size_t i = 0; i < texts.size(); ++i) { 902 for (size_t i = 0; i < texts.size(); ++i) {
898 903
899 // cerr << "Pane "<< this << ": text " << i << ": " << texts[i] << endl; 904 // cerr << "Pane "<< this << ": text " << i << ": " << texts[i] << endl;
900 905
901 if (i + 1 == texts.size()) { 906 if (i + 1 == texts.size()) {
1145 1150
1146 if (!m_manager) return Selection(); 1151 if (!m_manager) return Selection();
1147 1152
1148 long testFrame = getFrameForX(x - 5); 1153 long testFrame = getFrameForX(x - 5);
1149 if (testFrame < 0) { 1154 if (testFrame < 0) {
1150 testFrame = getFrameForX(x); 1155 testFrame = getFrameForX(x);
1151 if (testFrame < 0) return Selection(); 1156 if (testFrame < 0) return Selection();
1152 } 1157 }
1153 1158
1154 Selection selection = m_manager->getContainingSelection(testFrame, true); 1159 Selection selection = m_manager->getContainingSelection(testFrame, true);
1155 if (selection.isEmpty()) return selection; 1160 if (selection.isEmpty()) return selection;
1156 1161
1289 m_ctrlPressed = (e->modifiers() & Qt::ControlModifier); 1294 m_ctrlPressed = (e->modifiers() & Qt::ControlModifier);
1290 m_altPressed = (e->modifiers() & Qt::AltModifier); 1295 m_altPressed = (e->modifiers() & Qt::AltModifier);
1291 m_dragMode = UnresolvedDrag; 1296 m_dragMode = UnresolvedDrag;
1292 1297
1293 ViewManager::ToolMode mode = ViewManager::NavigateMode; 1298 ViewManager::ToolMode mode = ViewManager::NavigateMode;
1294 if (m_manager) mode = m_manager->getToolMode(); 1299 if (m_manager) mode = m_manager->getToolModeFor(this);
1295 1300
1296 m_navigating = false; 1301 m_navigating = false;
1297 m_resizing = false; 1302 m_resizing = false;
1298 m_editing = false; 1303 m_editing = false;
1299 m_releasing = false; 1304 m_releasing = false;
1301 if (mode == ViewManager::NavigateMode || 1306 if (mode == ViewManager::NavigateMode ||
1302 (e->buttons() & Qt::MidButton) || 1307 (e->buttons() & Qt::MidButton) ||
1303 (mode == ViewManager::MeasureMode && 1308 (mode == ViewManager::MeasureMode &&
1304 (e->buttons() & Qt::LeftButton) && m_shiftPressed)) { 1309 (e->buttons() & Qt::LeftButton) && m_shiftPressed)) {
1305 1310
1306 if (mode != ViewManager::NavigateMode) { 1311 if (mode != ViewManager::NavigateMode) {
1307 setCursor(Qt::PointingHandCursor); 1312 setCursor(Qt::PointingHandCursor);
1308 } 1313 }
1309 1314
1310 m_navigating = true; 1315 m_navigating = true;
1311 m_dragCentreFrame = m_centreFrame; 1316 m_dragCentreFrame = m_centreFrame;
1312 m_dragStartMinValue = 0; 1317 m_dragStartMinValue = 0;
1313 1318
1314 float vmin, vmax, dmin, dmax; 1319 float vmin, vmax, dmin, dmax;
1315 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) { 1320 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) {
1316 m_dragStartMinValue = dmin; 1321 m_dragStartMinValue = dmin;
1318 1323
1319 } else if (mode == ViewManager::SelectMode) { 1324 } else if (mode == ViewManager::SelectMode) {
1320 1325
1321 if (!hasTopLayerTimeXAxis()) return; 1326 if (!hasTopLayerTimeXAxis()) return;
1322 1327
1323 bool closeToLeft = false, closeToRight = false; 1328 bool closeToLeft = false, closeToRight = false;
1324 Selection selection = getSelectionAt(e->x(), closeToLeft, closeToRight); 1329 Selection selection = getSelectionAt(e->x(), closeToLeft, closeToRight);
1325 1330
1326 if ((closeToLeft || closeToRight) && !(closeToLeft && closeToRight)) { 1331 if ((closeToLeft || closeToRight) && !(closeToLeft && closeToRight)) {
1327 1332
1328 m_manager->removeSelection(selection); 1333 m_manager->removeSelection(selection);
1329 1334
1330 if (closeToLeft) { 1335 if (closeToLeft) {
1331 m_selectionStartFrame = selection.getEndFrame(); 1336 m_selectionStartFrame = selection.getEndFrame();
1332 } else { 1337 } else {
1333 m_selectionStartFrame = selection.getStartFrame(); 1338 m_selectionStartFrame = selection.getStartFrame();
1334 } 1339 }
1335 1340
1336 m_manager->setInProgressSelection(selection, false); 1341 m_manager->setInProgressSelection(selection, false);
1337 m_resizing = true; 1342 m_resizing = true;
1338 1343
1339 } else { 1344 } else {
1340 1345
1341 int mouseFrame = getFrameForX(e->x()); 1346 int mouseFrame = getFrameForX(e->x());
1342 size_t resolution = 1; 1347 size_t resolution = 1;
1343 int snapFrame = mouseFrame; 1348 int snapFrame = mouseFrame;
1344 1349
1345 Layer *layer = getSelectedLayer(); 1350 Layer *layer = getSelectedLayer();
1346 if (layer && !m_shiftPressed) { 1351 if (layer && !m_shiftPressed) {
1347 layer->snapToFeatureFrame(this, snapFrame, 1352 layer->snapToFeatureFrame(this, snapFrame,
1348 resolution, Layer::SnapLeft); 1353 resolution, Layer::SnapLeft);
1349 } 1354 }
1350 1355
1351 if (snapFrame < 0) snapFrame = 0; 1356 if (snapFrame < 0) snapFrame = 0;
1352 m_selectionStartFrame = snapFrame; 1357 m_selectionStartFrame = snapFrame;
1353 if (m_manager) { 1358 if (m_manager) {
1354 m_manager->setInProgressSelection 1359 m_manager->setInProgressSelection
1355 (Selection(alignToReference(snapFrame), 1360 (Selection(alignToReference(snapFrame),
1356 alignToReference(snapFrame + resolution)), 1361 alignToReference(snapFrame + resolution)),
1357 !m_ctrlPressed); 1362 !m_ctrlPressed);
1358 } 1363 }
1359 1364
1360 m_resizing = false; 1365 m_resizing = false;
1361 } 1366 }
1362 1367
1363 update(); 1368 update();
1364 1369
1365 } else if (mode == ViewManager::DrawMode) { 1370 } else if (mode == ViewManager::DrawMode) {
1366 1371
1367 Layer *layer = getSelectedLayer(); 1372 Layer *layer = getSelectedLayer();
1368 if (layer && layer->isLayerEditable()) { 1373 if (layer && layer->isLayerEditable()) {
1369 layer->drawStart(this, e); 1374 layer->drawStart(this, e);
1370 } 1375 }
1371 1376
1372 } else if (mode == ViewManager::EraseMode) { 1377 } else if (mode == ViewManager::EraseMode) {
1373 1378
1374 Layer *layer = getSelectedLayer(); 1379 Layer *layer = getSelectedLayer();
1375 if (layer && layer->isLayerEditable()) { 1380 if (layer && layer->isLayerEditable()) {
1376 layer->eraseStart(this, e); 1381 layer->eraseStart(this, e);
1377 } 1382 }
1383
1384 // GF: handle mouse press for NoteEditMode
1385 } else if (mode == ViewManager::NoteEditMode) {
1386
1387 std::cerr << "mouse pressed in note edit mode" << std::endl;
1388 Layer *layer = getSelectedLayer();
1389 if (layer && layer->isLayerEditable()) {
1390 layer->splitStart(this, e);
1391 }
1378 1392
1379 } else if (mode == ViewManager::EditMode) { 1393 } else if (mode == ViewManager::EditMode) {
1380 1394
1381 // Do nothing here -- we'll do it in mouseMoveEvent when the 1395 // Do nothing here -- we'll do it in mouseMoveEvent when the
1382 // drag threshold has been passed 1396 // drag threshold has been passed
1399 } 1413 }
1400 1414
1401 // cerr << "mouseReleaseEvent" << endl; 1415 // cerr << "mouseReleaseEvent" << endl;
1402 1416
1403 ViewManager::ToolMode mode = ViewManager::NavigateMode; 1417 ViewManager::ToolMode mode = ViewManager::NavigateMode;
1404 if (m_manager) mode = m_manager->getToolMode(); 1418 if (m_manager) mode = m_manager->getToolModeFor(this);
1405 1419
1406 m_releasing = true; 1420 m_releasing = true;
1407 1421
1408 if (m_clickedInRange) { 1422 if (m_clickedInRange) {
1409 mouseMoveEvent(e); 1423 mouseMoveEvent(e);
1410 } 1424 }
1411 1425
1412 if (m_navigating || mode == ViewManager::NavigateMode) { 1426 if (m_navigating || mode == ViewManager::NavigateMode) {
1413 1427
1414 m_navigating = false; 1428 m_navigating = false;
1415 1429
1416 if (mode != ViewManager::NavigateMode) { 1430 if (mode != ViewManager::NavigateMode) {
1417 // restore cursor 1431 // restore cursor
1418 toolModeChanged(); 1432 toolModeChanged();
1419 } 1433 }
1420 1434
1421 if (m_shiftPressed) { 1435 if (m_shiftPressed) {
1422 1436
1423 int x0 = std::min(m_clickPos.x(), m_mousePos.x()); 1437 int x0 = std::min(m_clickPos.x(), m_mousePos.x());
1424 int x1 = std::max(m_clickPos.x(), m_mousePos.x()); 1438 int x1 = std::max(m_clickPos.x(), m_mousePos.x());
1425 1439
1426 int y0 = std::min(m_clickPos.y(), m_mousePos.y()); 1440 int y0 = std::min(m_clickPos.y(), m_mousePos.y());
1427 int y1 = std::max(m_clickPos.y(), m_mousePos.y()); 1441 int y1 = std::max(m_clickPos.y(), m_mousePos.y());
1428 1442
1429 zoomToRegion(x0, y0, x1, y1); 1443 zoomToRegion(x0, y0, x1, y1);
1430 } 1444 }
1431 1445
1432 } else if (mode == ViewManager::SelectMode) { 1446 } else if (mode == ViewManager::SelectMode) {
1433 1447
1434 if (!hasTopLayerTimeXAxis()) { 1448 if (!hasTopLayerTimeXAxis()) {
1435 m_releasing = false; 1449 m_releasing = false;
1436 return; 1450 return;
1437 } 1451 }
1438 1452
1439 if (m_manager && m_manager->haveInProgressSelection()) { 1453 if (m_manager && m_manager->haveInProgressSelection()) {
1440 1454
1441 bool exclusive; 1455 bool exclusive;
1442 Selection selection = m_manager->getInProgressSelection(exclusive); 1456 Selection selection = m_manager->getInProgressSelection(exclusive);
1443 1457
1444 if (selection.getEndFrame() < selection.getStartFrame() + 2) { 1458 if (selection.getEndFrame() < selection.getStartFrame() + 2) {
1445 selection = Selection(); 1459 selection = Selection();
1446 } 1460 }
1447 1461
1448 m_manager->clearInProgressSelection(); 1462 m_manager->clearInProgressSelection();
1449 1463
1450 if (exclusive) { 1464 if (exclusive) {
1451 m_manager->setSelection(selection); 1465 m_manager->setSelection(selection);
1452 } else { 1466 } else {
1453 m_manager->addSelection(selection); 1467 m_manager->addSelection(selection);
1454 } 1468 }
1455 } 1469 }
1456 1470
1457 update(); 1471 update();
1458 1472
1459 } else if (mode == ViewManager::DrawMode) { 1473 } else if (mode == ViewManager::DrawMode) {
1460 1474
1461 Layer *layer = getSelectedLayer(); 1475 Layer *layer = getSelectedLayer();
1462 if (layer && layer->isLayerEditable()) { 1476 if (layer && layer->isLayerEditable()) {
1463 layer->drawEnd(this, e); 1477 layer->drawEnd(this, e);
1464 update(); 1478 update();
1465 } 1479 }
1466 1480
1467 } else if (mode == ViewManager::EraseMode) { 1481 } else if (mode == ViewManager::EraseMode) {
1468 1482
1469 Layer *layer = getSelectedLayer(); 1483 Layer *layer = getSelectedLayer();
1470 if (layer && layer->isLayerEditable()) { 1484 if (layer && layer->isLayerEditable()) {
1471 layer->eraseEnd(this, e); 1485 layer->eraseEnd(this, e);
1472 update(); 1486 update();
1473 } 1487 }
1474 1488
1475 } else if (mode == ViewManager::EditMode) { 1489 } else if (mode == ViewManager::NoteEditMode) {
1490
1491 //GF: handle mouse release for NoteEditMode (note: works but will need to re-think this a bit later)
1492 Layer *layer = getSelectedLayer();
1493 if (layer && layer->isLayerEditable()) {
1494 layer->splitEnd(this, e);
1495 update(); }
1476 1496
1477 if (m_editing) { 1497 if (m_editing) {
1478 if (!editSelectionEnd(e)) { 1498 if (!editSelectionEnd(e)) {
1479 Layer *layer = getSelectedLayer(); 1499 Layer *layer = getSelectedLayer();
1480 if (layer && layer->isLayerEditable()) { 1500 if (layer && layer->isLayerEditable()) {
1481 layer->editEnd(this, e); 1501 layer->editEnd(this, e);
1482 update(); 1502 update();
1483 } 1503 }
1484 } 1504 }
1485 } 1505 }
1506
1507 } else if (mode == ViewManager::EditMode) {
1508
1509 // GF: edited this previously, but restored to original state
1510 if (m_editing) {
1511 if (!editSelectionEnd(e)) {
1512 Layer *layer = getSelectedLayer();
1513 if (layer && layer->isLayerEditable()) {
1514 layer->editEnd(this, e);
1515 update();
1516 }
1517 }
1518 }
1486 1519
1487 } else if (mode == ViewManager::MeasureMode) { 1520 } else if (mode == ViewManager::MeasureMode) {
1488 1521
1489 Layer *layer = getTopLayer(); 1522 Layer *layer = getTopLayer();
1490 if (layer) layer->measureEnd(this, e); 1523 if (layer) layer->measureEnd(this, e);
1523 return; 1556 return;
1524 } 1557 }
1525 } 1558 }
1526 1559
1527 ViewManager::ToolMode mode = ViewManager::NavigateMode; 1560 ViewManager::ToolMode mode = ViewManager::NavigateMode;
1528 if (m_manager) mode = m_manager->getToolMode(); 1561 if (m_manager) mode = m_manager->getToolModeFor(this);
1529 1562
1530 QPoint prevPoint = m_identifyPoint; 1563 QPoint prevPoint = m_identifyPoint;
1531 m_identifyPoint = e->pos(); 1564 m_identifyPoint = e->pos();
1532 1565
1533 if (!m_clickedInRange) { 1566 if (!m_clickedInRange) {
1534 1567
1535 if (mode == ViewManager::SelectMode && hasTopLayerTimeXAxis()) { 1568 // GF: handle mouse move for context sensitive cursor switching in NoteEditMode.
1536 bool closeToLeft = false, closeToRight = false; 1569 // 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.
1537 getSelectionAt(e->x(), closeToLeft, closeToRight); 1570 if (mode == ViewManager::NoteEditMode && LayerFactory::getInstance()->getLayerType(getTopLayer()) == LayerFactory::FlexiNotes) {
1538 if ((closeToLeft || closeToRight) && !(closeToLeft && closeToRight)) { 1571
1539 setCursor(Qt::SizeHorCursor); 1572 dynamic_cast<FlexiNoteLayer *>(getTopLayer())->mouseMoveEvent(this, e);
1540 } else { 1573
1541 setCursor(Qt::ArrowCursor); 1574 }
1542 } 1575
1543 } 1576 if (mode == ViewManager::SelectMode && hasTopLayerTimeXAxis()) {
1577 bool closeToLeft = false, closeToRight = false;
1578 getSelectionAt(e->x(), closeToLeft, closeToRight);
1579 if ((closeToLeft || closeToRight) && !(closeToLeft && closeToRight)) {
1580 setCursor(Qt::SizeHorCursor);
1581 } else {
1582 setCursor(Qt::ArrowCursor);
1583 }
1584 }
1544 1585
1545 if (!m_manager->isPlaying()) { 1586 if (!m_manager->isPlaying()) {
1546 1587
1547 bool updating = false; 1588 bool updating = false;
1548 1589
1568 update(); 1609 update();
1569 } 1610 }
1570 } 1611 }
1571 } 1612 }
1572 1613
1573 return; 1614 return;
1574 } 1615 }
1575 1616
1576 if (m_navigating || mode == ViewManager::NavigateMode) { 1617 if (m_navigating || mode == ViewManager::NavigateMode) {
1577 1618
1578 if (m_shiftPressed) { 1619 if (m_shiftPressed) {
1579 1620
1580 m_mousePos = e->pos(); 1621 m_mousePos = e->pos();
1581 update(); 1622 update();
1582 1623
1583 } else { 1624 } else {
1584 1625
1585 dragTopLayer(e); 1626 dragTopLayer(e);
1586 } 1627 }
1587 1628
1588 } else if (mode == ViewManager::SelectMode) { 1629 } else if (mode == ViewManager::SelectMode) {
1591 1632
1592 dragExtendSelection(e); 1633 dragExtendSelection(e);
1593 1634
1594 } else if (mode == ViewManager::DrawMode) { 1635 } else if (mode == ViewManager::DrawMode) {
1595 1636
1596 Layer *layer = getSelectedLayer(); 1637 Layer *layer = getSelectedLayer();
1597 if (layer && layer->isLayerEditable()) { 1638 if (layer && layer->isLayerEditable()) {
1598 layer->drawDrag(this, e); 1639 layer->drawDrag(this, e);
1599 } 1640 }
1600 1641
1601 } else if (mode == ViewManager::EraseMode) { 1642 } else if (mode == ViewManager::EraseMode) {
1602 1643
1603 Layer *layer = getSelectedLayer(); 1644 Layer *layer = getSelectedLayer();
1604 if (layer && layer->isLayerEditable()) { 1645 if (layer && layer->isLayerEditable()) {
1605 layer->eraseDrag(this, e); 1646 layer->eraseDrag(this, e);
1606 } 1647 }
1607 1648
1608 } else if (mode == ViewManager::EditMode) { 1649 // GF: handling NoteEditMode dragging and boundary actions for mouseMoveEvent
1650 } else if (mode == ViewManager::NoteEditMode) {
1609 1651
1610 bool resist = true; 1652 bool resist = true;
1611 1653
1612 if ((e->modifiers() & Qt::ShiftModifier)) { 1654 if ((e->modifiers() & Qt::ShiftModifier)) {
1613 m_shiftPressed = true; 1655 m_shiftPressed = true;
1614 // ... but don't set it false if shift has been
1615 // released -- we want the state when we started
1616 // dragging to be used most of the time
1617 } 1656 }
1618 1657
1619 if (m_shiftPressed) resist = false; 1658 if (m_shiftPressed) resist = false;
1620 1659
1621 m_dragMode = updateDragMode 1660 m_dragMode = updateDragMode
1640 e->modifiers()); 1679 e->modifiers());
1641 1680
1642 if (!editSelectionStart(&clickEvent)) { 1681 if (!editSelectionStart(&clickEvent)) {
1643 Layer *layer = getSelectedLayer(); 1682 Layer *layer = getSelectedLayer();
1644 if (layer && layer->isLayerEditable()) { 1683 if (layer && layer->isLayerEditable()) {
1684 std::cerr << "calling edit start" << std::endl;
1685 layer->editStart(this, &clickEvent);
1686 }
1687 }
1688 }
1689
1690 } else {
1691
1692 if (!editSelectionDrag(e)) {
1693
1694 Layer *layer = getSelectedLayer();
1695
1696 if (layer && layer->isLayerEditable()) {
1697
1698 int x = e->x();
1699 int y = e->y();
1700 if (m_dragMode == VerticalDrag) x = m_clickPos.x();
1701 else if (m_dragMode == HorizontalDrag) y = m_clickPos.y();
1702
1703 QMouseEvent moveEvent(QEvent::MouseMove,
1704 QPoint(x, y),
1705 Qt::NoButton,
1706 e->buttons(),
1707 e->modifiers());
1708 std::cerr << "calling editDrag" << std::endl;
1709 layer->editDrag(this, &moveEvent);
1710 }
1711 }
1712 }
1713
1714 } else if (mode == ViewManager::EditMode) {
1715
1716 bool resist = true;
1717
1718 if ((e->modifiers() & Qt::ShiftModifier)) {
1719 m_shiftPressed = true;
1720 // ... but don't set it false if shift has been
1721 // released -- we want the state when we started
1722 // dragging to be used most of the time
1723 }
1724
1725 if (m_shiftPressed) resist = false;
1726
1727 m_dragMode = updateDragMode
1728 (m_dragMode,
1729 m_clickPos,
1730 e->pos(),
1731 true, // can move horiz
1732 true, // can move vert
1733 resist, // resist horiz
1734 resist); // resist vert
1735
1736 if (!m_editing) {
1737
1738 if (m_dragMode != UnresolvedDrag) {
1739
1740 m_editing = true;
1741
1742 QMouseEvent clickEvent(QEvent::MouseButtonPress,
1743 m_clickPos,
1744 Qt::NoButton,
1745 e->buttons(),
1746 e->modifiers());
1747
1748 if (!editSelectionStart(&clickEvent)) {
1749 Layer *layer = getSelectedLayer();
1750 if (layer && layer->isLayerEditable()) {
1645 layer->editStart(this, &clickEvent); 1751 layer->editStart(this, &clickEvent);
1646 } 1752 }
1647 } 1753 }
1648 } 1754 }
1649 1755
1687 1793
1688 void 1794 void
1689 Pane::zoomToRegion(int x0, int y0, int x1, int y1) 1795 Pane::zoomToRegion(int x0, int y0, int x1, int y1)
1690 { 1796 {
1691 int w = x1 - x0; 1797 int w = x1 - x0;
1692 1798
1693 long newStartFrame = getFrameForX(x0); 1799 long newStartFrame = getFrameForX(x0);
1694 1800
1695 long visibleFrames = getEndFrame() - getStartFrame(); 1801 long visibleFrames = getEndFrame() - getStartFrame();
1696 if (newStartFrame <= -visibleFrames) { 1802 if (newStartFrame <= -visibleFrames) {
1697 newStartFrame = -visibleFrames + 1; 1803 newStartFrame = -visibleFrames + 1;
1698 } 1804 }
1699 1805
1700 if (newStartFrame >= long(getModelsEndFrame())) { 1806 if (newStartFrame >= long(getModelsEndFrame())) {
1701 newStartFrame = getModelsEndFrame() - 1; 1807 newStartFrame = getModelsEndFrame() - 1;
1702 } 1808 }
1703 1809
1704 float ratio = float(w) / float(width()); 1810 float ratio = float(w) / float(width());
1705 // cerr << "ratio: " << ratio << endl; 1811 // cerr << "ratio: " << ratio << endl;
1706 size_t newZoomLevel = (size_t)nearbyint(m_zoomLevel * ratio); 1812 size_t newZoomLevel = (size_t)nearbyint(m_zoomLevel * ratio);
1707 if (newZoomLevel < 1) newZoomLevel = 1; 1813 if (newZoomLevel < 1) newZoomLevel = 1;
1708 1814
1783 m_dragMode == FreeDrag) { 1889 m_dragMode == FreeDrag) {
1784 1890
1785 long frameOff = getFrameForX(e->x()) - getFrameForX(m_clickPos.x()); 1891 long frameOff = getFrameForX(e->x()) - getFrameForX(m_clickPos.x());
1786 1892
1787 size_t newCentreFrame = m_dragCentreFrame; 1893 size_t newCentreFrame = m_dragCentreFrame;
1788 1894
1789 if (frameOff < 0) { 1895 if (frameOff < 0) {
1790 newCentreFrame -= frameOff; 1896 newCentreFrame -= frameOff;
1791 } else if (newCentreFrame >= size_t(frameOff)) { 1897 } else if (newCentreFrame >= size_t(frameOff)) {
1792 newCentreFrame -= frameOff; 1898 newCentreFrame -= frameOff;
1793 } else { 1899 } else {
1794 newCentreFrame = 0; 1900 newCentreFrame = 0;
1795 } 1901 }
1796 1902
1797 #ifdef DEBUG_PANE 1903 #ifdef DEBUG_PANE
1798 SVDEBUG << "Pane::dragTopLayer: newCentreFrame = " << newCentreFrame << 1904 SVDEBUG << "Pane::dragTopLayer: newCentreFrame = " << newCentreFrame <<
1799 ", models end frame = " << getModelsEndFrame() << endl; 1905 ", models end frame = " << getModelsEndFrame() << endl;
1800 #endif 1906 #endif
1801 1907
1802 if (newCentreFrame >= getModelsEndFrame()) { 1908 if (newCentreFrame >= getModelsEndFrame()) {
1911 { 2017 {
1912 int mouseFrame = getFrameForX(e->x()); 2018 int mouseFrame = getFrameForX(e->x());
1913 size_t resolution = 1; 2019 size_t resolution = 1;
1914 int snapFrameLeft = mouseFrame; 2020 int snapFrameLeft = mouseFrame;
1915 int snapFrameRight = mouseFrame; 2021 int snapFrameRight = mouseFrame;
1916 2022
1917 Layer *layer = getSelectedLayer(); 2023 Layer *layer = getSelectedLayer();
1918 if (layer && !m_shiftPressed) { 2024 if (layer && !m_shiftPressed) {
1919 layer->snapToFeatureFrame(this, snapFrameLeft, 2025 layer->snapToFeatureFrame(this, snapFrameLeft,
1920 resolution, Layer::SnapLeft); 2026 resolution, Layer::SnapLeft);
1921 layer->snapToFeatureFrame(this, snapFrameRight, 2027 layer->snapToFeatureFrame(this, snapFrameRight,
1924 2030
1925 // cerr << "snap: frame = " << mouseFrame << ", start frame = " << m_selectionStartFrame << ", left = " << snapFrameLeft << ", right = " << snapFrameRight << endl; 2031 // cerr << "snap: frame = " << mouseFrame << ", start frame = " << m_selectionStartFrame << ", left = " << snapFrameLeft << ", right = " << snapFrameRight << endl;
1926 2032
1927 if (snapFrameLeft < 0) snapFrameLeft = 0; 2033 if (snapFrameLeft < 0) snapFrameLeft = 0;
1928 if (snapFrameRight < 0) snapFrameRight = 0; 2034 if (snapFrameRight < 0) snapFrameRight = 0;
1929 2035
1930 size_t min, max; 2036 size_t min, max;
1931 2037
1932 if (m_selectionStartFrame > size_t(snapFrameLeft)) { 2038 if (m_selectionStartFrame > size_t(snapFrameLeft)) {
1933 min = snapFrameLeft; 2039 min = snapFrameLeft;
1934 max = m_selectionStartFrame; 2040 max = m_selectionStartFrame;
1935 } else if (size_t(snapFrameRight) > m_selectionStartFrame) { 2041 } else if (size_t(snapFrameRight) > m_selectionStartFrame) {
1936 min = m_selectionStartFrame; 2042 min = m_selectionStartFrame;
1992 m_shiftPressed = (e->modifiers() & Qt::ShiftModifier); 2098 m_shiftPressed = (e->modifiers() & Qt::ShiftModifier);
1993 m_ctrlPressed = (e->modifiers() & Qt::ControlModifier); 2099 m_ctrlPressed = (e->modifiers() & Qt::ControlModifier);
1994 m_altPressed = (e->modifiers() & Qt::AltModifier); 2100 m_altPressed = (e->modifiers() & Qt::AltModifier);
1995 2101
1996 ViewManager::ToolMode mode = ViewManager::NavigateMode; 2102 ViewManager::ToolMode mode = ViewManager::NavigateMode;
1997 if (m_manager) mode = m_manager->getToolMode(); 2103 if (m_manager) mode = m_manager->getToolModeFor(this);
1998 2104
1999 bool relocate = (mode == ViewManager::NavigateMode || 2105 bool relocate = (mode == ViewManager::NavigateMode ||
2000 (e->buttons() & Qt::MidButton)); 2106 (e->buttons() & Qt::MidButton));
2001 2107
2108 if (mode == ViewManager::SelectMode) {
2109 m_clickedInRange = false;
2110 m_manager->clearInProgressSelection();
2111 emit doubleClickSelectInvoked(getFrameForX(e->x()));
2112 return;
2113 }
2114
2002 if (mode == ViewManager::NavigateMode || 2115 if (mode == ViewManager::NavigateMode ||
2003 mode == ViewManager::EditMode) { 2116 mode == ViewManager::EditMode) {
2004 2117
2005 Layer *layer = getSelectedLayer(); 2118 Layer *layer = getSelectedLayer();
2006 if (layer && layer->isLayerEditable()) { 2119 if (layer && layer->isLayerEditable()) {
2007 if (layer->editOpen(this, e)) relocate = false; 2120 if (layer->editOpen(this, e)) relocate = false;
2008 } 2121 }
2009 2122
2010 } else if (mode == ViewManager::MeasureMode) { 2123 } else if (mode == ViewManager::MeasureMode) {
2011 2124
2012 Layer *layer = getTopLayer(); 2125 Layer *layer = getTopLayer();
2013 if (layer) layer->measureDoubleClick(this, e); 2126 if (layer) layer->measureDoubleClick(this, e);
2025 m_dragMode = UnresolvedDrag; 2138 m_dragMode = UnresolvedDrag;
2026 2139
2027 float vmin, vmax, dmin, dmax; 2140 float vmin, vmax, dmin, dmax;
2028 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) { 2141 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) {
2029 m_dragStartMinValue = dmin; 2142 m_dragStartMinValue = dmin;
2143 }
2144 }
2145
2146 if (mode == ViewManager::NoteEditMode) {
2147 std::cerr << "double click in note edit mode" << std::endl;
2148 Layer *layer = getSelectedLayer();
2149 if (layer && layer->isLayerEditable()) {
2150 layer->addNote(this, e);
2030 } 2151 }
2031 } 2152 }
2032 2153
2033 m_clickedInRange = false; // in case mouseReleaseEvent is not properly called 2154 m_clickedInRange = false; // in case mouseReleaseEvent is not properly called
2034 } 2155 }
2061 //cerr << "wheelEvent, delta " << e->delta() << endl; 2182 //cerr << "wheelEvent, delta " << e->delta() << endl;
2062 2183
2063 int count = e->delta(); 2184 int count = e->delta();
2064 2185
2065 if (count > 0) { 2186 if (count > 0) {
2066 if (count >= 120) count /= 120; 2187 if (count >= 120) count /= 120;
2067 else count = 1; 2188 else count = 1;
2068 } 2189 }
2069 2190
2070 if (count < 0) { 2191 if (count < 0) {
2071 if (count <= -120) count /= 120; 2192 if (count <= -120) count /= 120;
2072 else count = -1; 2193 else count = -1;
2073 } 2194 }
2074 2195
2075 if (e->modifiers() & Qt::ControlModifier) { 2196 if (e->modifiers() & Qt::ControlModifier) {
2076 2197
2077 // Scroll left or right, rapidly 2198 // Scroll left or right, rapidly
2078 2199
2079 if (getStartFrame() < 0 && 2200 if (getStartFrame() < 0 &&
2080 getEndFrame() >= getModelsEndFrame()) return; 2201 getEndFrame() >= getModelsEndFrame()) return;
2081 2202
2082 long delta = ((width() / 2) * count * m_zoomLevel); 2203 long delta = ((width() / 2) * count * m_zoomLevel);
2083 2204
2084 if (int(m_centreFrame) < delta) { 2205 if (int(m_centreFrame) < delta) {
2085 setCentreFrame(0); 2206 setCentreFrame(0);
2086 } else if (int(m_centreFrame) - delta >= int(getModelsEndFrame())) { 2207 } else if (int(m_centreFrame) - delta >= int(getModelsEndFrame())) {
2087 setCentreFrame(getModelsEndFrame()); 2208 setCentreFrame(getModelsEndFrame());
2088 } else { 2209 } else {
2089 setCentreFrame(m_centreFrame - delta); 2210 setCentreFrame(m_centreFrame - delta);
2090 } 2211 }
2091 2212
2092 } else if (e->modifiers() & Qt::ShiftModifier) { 2213 } else if (e->modifiers() & Qt::ShiftModifier) {
2093 2214
2094 // Zoom vertically 2215 // Zoom vertically
2095 2216
2105 m_vthumb->scroll(e->delta() > 0); 2226 m_vthumb->scroll(e->delta() > 0);
2106 } 2227 }
2107 2228
2108 } else { 2229 } else {
2109 2230
2110 // Zoom in or out 2231 // Zoom in or out
2111 2232
2112 int newZoomLevel = m_zoomLevel; 2233 int newZoomLevel = m_zoomLevel;
2113 2234
2114 while (count > 0) { 2235 while (count > 0) {
2115 if (newZoomLevel <= 2) { 2236 if (newZoomLevel <= 2) {
2116 newZoomLevel = 1; 2237 newZoomLevel = 1;
2117 break; 2238 break;
2118 } 2239 }
2119 newZoomLevel = getZoomConstraintBlockSize(newZoomLevel - 1, 2240 newZoomLevel = getZoomConstraintBlockSize(newZoomLevel - 1,
2120 ZoomConstraint::RoundDown); 2241 ZoomConstraint::RoundDown);
2121 --count; 2242 --count;
2122 } 2243 }
2123 2244
2124 while (count < 0) { 2245 while (count < 0) {
2125 newZoomLevel = getZoomConstraintBlockSize(newZoomLevel + 1, 2246 newZoomLevel = getZoomConstraintBlockSize(newZoomLevel + 1,
2126 ZoomConstraint::RoundUp); 2247 ZoomConstraint::RoundUp);
2127 ++count; 2248 ++count;
2128 } 2249 }
2129 2250
2130 if (newZoomLevel != m_zoomLevel) { 2251 if (newZoomLevel != m_zoomLevel) {
2131 setZoomLevel(newZoomLevel); 2252 setZoomLevel(newZoomLevel);
2132 } 2253 }
2133 } 2254 }
2134 2255
2135 emit paneInteractedWith(); 2256 emit paneInteractedWith();
2136 } 2257 }
2137 2258
2305 2426
2306 bool 2427 bool
2307 Pane::editSelectionStart(QMouseEvent *e) 2428 Pane::editSelectionStart(QMouseEvent *e)
2308 { 2429 {
2309 if (!m_identifyFeatures || 2430 if (!m_identifyFeatures ||
2310 !m_manager || 2431 !m_manager ||
2311 m_manager->getToolMode() != ViewManager::EditMode) { 2432 m_manager->getToolModeFor(this) != ViewManager::EditMode) {
2312 return false; 2433 return false;
2313 } 2434 }
2314 2435
2315 bool closeToLeft, closeToRight; 2436 bool closeToLeft, closeToRight;
2316 Selection s(getSelectionAt(e->x(), closeToLeft, closeToRight)); 2437 Selection s(getSelectionAt(e->x(), closeToLeft, closeToRight));
2317 if (s.isEmpty()) return false; 2438 if (s.isEmpty()) return false;
2337 2458
2338 int offset = m_mousePos.x() - m_clickPos.x(); 2459 int offset = m_mousePos.x() - m_clickPos.x();
2339 Layer *layer = getSelectedLayer(); 2460 Layer *layer = getSelectedLayer();
2340 2461
2341 if (offset == 0 || !layer) { 2462 if (offset == 0 || !layer) {
2342 m_editingSelection = Selection(); 2463 m_editingSelection = Selection();
2343 return true; 2464 return true;
2344 } 2465 }
2345 2466
2346 int p0 = getXForFrame(m_editingSelection.getStartFrame()) + offset; 2467 int p0 = getXForFrame(m_editingSelection.getStartFrame()) + offset;
2347 int p1 = getXForFrame(m_editingSelection.getEndFrame()) + offset; 2468 int p1 = getXForFrame(m_editingSelection.getEndFrame()) + offset;
2348 2469
2350 long f1 = getFrameForX(p1); 2471 long f1 = getFrameForX(p1);
2351 2472
2352 Selection newSelection(f0, f1); 2473 Selection newSelection(f0, f1);
2353 2474
2354 if (m_editingSelectionEdge == 0) { 2475 if (m_editingSelectionEdge == 0) {
2355 2476
2356 CommandHistory::getInstance()->startCompoundOperation 2477 CommandHistory::getInstance()->startCompoundOperation
2357 (tr("Drag Selection"), true); 2478 (tr("Drag Selection"), true);
2358 2479
2359 layer->moveSelection(m_editingSelection, f0); 2480 layer->moveSelection(m_editingSelection, f0);
2360 2481
2361 } else { 2482 } else {
2362 2483
2363 CommandHistory::getInstance()->startCompoundOperation 2484 CommandHistory::getInstance()->startCompoundOperation
2364 (tr("Resize Selection"), true); 2485 (tr("Resize Selection"), true);
2365 2486
2366 if (m_editingSelectionEdge < 0) { 2487 if (m_editingSelectionEdge < 0) {
2367 f1 = m_editingSelection.getEndFrame(); 2488 f1 = m_editingSelection.getEndFrame();
2368 } else { 2489 } else {
2369 f0 = m_editingSelection.getStartFrame(); 2490 f0 = m_editingSelection.getStartFrame();
2370 } 2491 }
2371 2492
2372 newSelection = Selection(f0, f1); 2493 newSelection = Selection(f0, f1);
2373 layer->resizeSelection(m_editingSelection, newSelection); 2494 layer->resizeSelection(m_editingSelection, newSelection);
2374 } 2495 }
2375 2496
2376 m_manager->removeSelection(m_editingSelection); 2497 m_manager->removeSelection(m_editingSelection);
2377 m_manager->addSelection(newSelection); 2498 m_manager->addSelection(newSelection);
2378 2499
2383 } 2504 }
2384 2505
2385 void 2506 void
2386 Pane::toolModeChanged() 2507 Pane::toolModeChanged()
2387 { 2508 {
2388 ViewManager::ToolMode mode = m_manager->getToolMode(); 2509 ViewManager::ToolMode mode = m_manager->getToolModeFor(this);
2389 // SVDEBUG << "Pane::toolModeChanged(" << mode << ")" << endl; 2510 // SVDEBUG << "Pane::toolModeChanged(" << mode << ")" << endl;
2390 2511
2391 if (mode == ViewManager::MeasureMode && !m_measureCursor1) { 2512 if (mode == ViewManager::MeasureMode && !m_measureCursor1) {
2392 m_measureCursor1 = new QCursor(QBitmap(":/icons/measure1cursor.xbm"), 2513 m_measureCursor1 = new QCursor(QBitmap(":/icons/measure1cursor.xbm"),
2393 QBitmap(":/icons/measure1mask.xbm"), 2514 QBitmap(":/icons/measure1mask.xbm"),
2398 } 2519 }
2399 2520
2400 switch (mode) { 2521 switch (mode) {
2401 2522
2402 case ViewManager::NavigateMode: 2523 case ViewManager::NavigateMode:
2403 setCursor(Qt::PointingHandCursor); 2524 setCursor(Qt::PointingHandCursor);
2404 break; 2525 break;
2405 2526
2406 case ViewManager::SelectMode: 2527 case ViewManager::SelectMode:
2407 setCursor(Qt::ArrowCursor); 2528 setCursor(Qt::ArrowCursor);
2408 break; 2529 break;
2409 2530
2410 case ViewManager::EditMode: 2531 case ViewManager::EditMode:
2411 setCursor(Qt::UpArrowCursor); 2532 setCursor(Qt::UpArrowCursor);
2412 break; 2533 break;
2413 2534
2414 case ViewManager::DrawMode: 2535 case ViewManager::DrawMode:
2415 setCursor(Qt::CrossCursor); 2536 setCursor(Qt::CrossCursor);
2416 break; 2537 break;
2417 2538
2418 case ViewManager::EraseMode: 2539 case ViewManager::EraseMode:
2419 setCursor(Qt::CrossCursor); 2540 setCursor(Qt::CrossCursor);
2420 break; 2541 break;
2421 2542
2422 case ViewManager::MeasureMode: 2543 case ViewManager::MeasureMode:
2423 if (m_measureCursor1) setCursor(*m_measureCursor1); 2544 if (m_measureCursor1) setCursor(*m_measureCursor1);
2424 break; 2545 break;
2425 2546
2426 /* 2547 // GF: NoteEditMode uses the same default cursor as EditMode, but it will change in a context sensitive manner.
2548 case ViewManager::NoteEditMode:
2549 setCursor(Qt::UpArrowCursor);
2550 break;
2551
2552 /*
2427 case ViewManager::TextMode: 2553 case ViewManager::TextMode:
2428 setCursor(Qt::IBeamCursor); 2554 setCursor(Qt::IBeamCursor);
2429 break; 2555 break;
2430 */ 2556 */
2431 } 2557 }
2432 } 2558 }
2433 2559
2434 void 2560 void
2508 emit contextHelpChanged(""); 2634 emit contextHelpChanged("");
2509 return; 2635 return;
2510 } 2636 }
2511 2637
2512 ViewManager::ToolMode mode = ViewManager::NavigateMode; 2638 ViewManager::ToolMode mode = ViewManager::NavigateMode;
2513 if (m_manager) mode = m_manager->getToolMode(); 2639 if (m_manager) mode = m_manager->getToolModeFor(this);
2514 2640
2515 bool editable = false; 2641 bool editable = false;
2516 Layer *layer = getSelectedLayer(); 2642 Layer *layer = getSelectedLayer();
2517 if (layer && layer->isLayerEditable()) { 2643 if (layer && layer->isLayerEditable()) {
2518 editable = true; 2644 editable = true;
2560 } 2686 }
2561 2687
2562 } else if (mode == ViewManager::DrawMode) { 2688 } else if (mode == ViewManager::DrawMode) {
2563 2689
2564 //!!! 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
2565 if (editable) { 2691 if (editable) {
2566 help = tr("Click to add a new item in the active layer"); 2692 help = tr("Click to add a new item in the active layer");
2567 } 2693 }
2568 2694
2569 } else if (mode == ViewManager::EraseMode) { 2695 } else if (mode == ViewManager::EraseMode) {
2570 2696
2571 //!!! could call through to a layer function to find out exact meaning 2697 //!!! could call through to a layer function to find out exact meaning
2572 if (editable) { 2698 if (editable) {
2573 help = tr("Click to erase an item from the active layer"); 2699 help = tr("Click to erase an item from the active layer");
2574 } 2700 }
2575 2701
2576 } else if (mode == ViewManager::EditMode) { 2702 } else if (mode == ViewManager::EditMode) {
2577 2703
2578 //!!! could call through to layer 2704 //!!! could call through to layer
2579 if (editable) { 2705 if (editable) {
2580 help = tr("Click and drag an item in the active layer to move it; hold Shift to override initial resistance"); 2706 help = tr("Click and drag an item in the active layer to move it; hold Shift to override initial resistance");
2581 if (pos) { 2707 if (pos) {
2582 bool closeToLeft = false, closeToRight = false; 2708 bool closeToLeft = false, closeToRight = false;
2583 Selection selection = getSelectionAt(pos->x(), closeToLeft, closeToRight); 2709 Selection selection = getSelectionAt(pos->x(), closeToLeft, closeToRight);
2584 if (!selection.isEmpty()) { 2710 if (!selection.isEmpty()) {
2618 Pane::toXml(QTextStream &stream, 2744 Pane::toXml(QTextStream &stream,
2619 QString indent, QString extraAttributes) const 2745 QString indent, QString extraAttributes) const
2620 { 2746 {
2621 View::toXml 2747 View::toXml
2622 (stream, indent, 2748 (stream, indent,
2623 QString("type=\"pane\" centreLineVisible=\"%1\" height=\"%2\" %3") 2749 QString("type=\"pane\" centreLineVisible=\"%1\" height=\"%2\" %3")
2624 .arg(m_centreLineVisible).arg(height()).arg(extraAttributes)); 2750 .arg(m_centreLineVisible).arg(height()).arg(extraAttributes));
2625 } 2751 }
2626 2752
2627 2753