Mercurial > hg > svgui
comparison layer/TimeInstantLayer.cpp @ 387:f329416bf1a5
* Permit holding Shift while dragging an instant or other edited thing,
to override the initial drag resistance (for #1928943 sticky time
instants)
* better handling of updates during progressive decode load
* ready() signal from model (used by vect)
author | Chris Cannam |
---|---|
date | Mon, 19 May 2008 17:23:11 +0000 |
parents | e1a9e478b7f2 |
children | 427e5c58658e |
comparison
equal
deleted
inserted
replaced
386:590b899b7e45 | 387:f329416bf1a5 |
---|---|
33 #include <QMessageBox> | 33 #include <QMessageBox> |
34 | 34 |
35 #include <iostream> | 35 #include <iostream> |
36 #include <cmath> | 36 #include <cmath> |
37 | 37 |
38 #define DEBUG_TIME_INSTANT_LAYER 1 | |
39 | |
38 TimeInstantLayer::TimeInstantLayer() : | 40 TimeInstantLayer::TimeInstantLayer() : |
39 SingleColourLayer(), | 41 SingleColourLayer(), |
40 m_model(0), | 42 m_model(0), |
41 m_editing(false), | 43 m_editing(false), |
42 m_editingPoint(0, tr("New Point")), | 44 m_editingPoint(0, tr("New Point")), |
55 if (m_model == model) return; | 57 if (m_model == model) return; |
56 m_model = model; | 58 m_model = model; |
57 | 59 |
58 connectSignals(m_model); | 60 connectSignals(m_model); |
59 | 61 |
62 #ifdef DEBUG_TIME_INSTANT_LAYER | |
60 std::cerr << "TimeInstantLayer::setModel(" << model << ")" << std::endl; | 63 std::cerr << "TimeInstantLayer::setModel(" << model << ")" << std::endl; |
64 #endif | |
61 | 65 |
62 emit modelReplaced(); | 66 emit modelReplaced(); |
63 } | 67 } |
64 | 68 |
65 Layer::PropertyList | 69 Layer::PropertyList |
444 } | 448 } |
445 | 449 |
446 void | 450 void |
447 TimeInstantLayer::drawStart(View *v, QMouseEvent *e) | 451 TimeInstantLayer::drawStart(View *v, QMouseEvent *e) |
448 { | 452 { |
453 #ifdef DEBUG_TIME_INSTANT_LAYER | |
449 std::cerr << "TimeInstantLayer::drawStart(" << e->x() << ")" << std::endl; | 454 std::cerr << "TimeInstantLayer::drawStart(" << e->x() << ")" << std::endl; |
455 #endif | |
450 | 456 |
451 if (!m_model) return; | 457 if (!m_model) return; |
452 | 458 |
453 long frame = v->getFrameForX(e->x()); | 459 long frame = v->getFrameForX(e->x()); |
454 if (frame < 0) frame = 0; | 460 if (frame < 0) frame = 0; |
465 } | 471 } |
466 | 472 |
467 void | 473 void |
468 TimeInstantLayer::drawDrag(View *v, QMouseEvent *e) | 474 TimeInstantLayer::drawDrag(View *v, QMouseEvent *e) |
469 { | 475 { |
476 #ifdef DEBUG_TIME_INSTANT_LAYER | |
470 std::cerr << "TimeInstantLayer::drawDrag(" << e->x() << ")" << std::endl; | 477 std::cerr << "TimeInstantLayer::drawDrag(" << e->x() << ")" << std::endl; |
478 #endif | |
471 | 479 |
472 if (!m_model || !m_editing) return; | 480 if (!m_model || !m_editing) return; |
473 | 481 |
474 long frame = v->getFrameForX(e->x()); | 482 long frame = v->getFrameForX(e->x()); |
475 if (frame < 0) frame = 0; | 483 if (frame < 0) frame = 0; |
480 } | 488 } |
481 | 489 |
482 void | 490 void |
483 TimeInstantLayer::drawEnd(View *, QMouseEvent *e) | 491 TimeInstantLayer::drawEnd(View *, QMouseEvent *e) |
484 { | 492 { |
493 #ifdef DEBUG_TIME_INSTANT_LAYER | |
485 std::cerr << "TimeInstantLayer::drawEnd(" << e->x() << ")" << std::endl; | 494 std::cerr << "TimeInstantLayer::drawEnd(" << e->x() << ")" << std::endl; |
495 #endif | |
486 if (!m_model || !m_editing) return; | 496 if (!m_model || !m_editing) return; |
487 QString newName = tr("Add Point at %1 s") | 497 QString newName = tr("Add Point at %1 s") |
488 .arg(RealTime::frame2RealTime(m_editingPoint.frame, | 498 .arg(RealTime::frame2RealTime(m_editingPoint.frame, |
489 m_model->getSampleRate()) | 499 m_model->getSampleRate()) |
490 .toText(false).c_str()); | 500 .toText(false).c_str()); |
539 } | 549 } |
540 | 550 |
541 void | 551 void |
542 TimeInstantLayer::editStart(View *v, QMouseEvent *e) | 552 TimeInstantLayer::editStart(View *v, QMouseEvent *e) |
543 { | 553 { |
554 #ifdef DEBUG_TIME_INSTANT_LAYER | |
544 std::cerr << "TimeInstantLayer::editStart(" << e->x() << ")" << std::endl; | 555 std::cerr << "TimeInstantLayer::editStart(" << e->x() << ")" << std::endl; |
556 #endif | |
545 | 557 |
546 if (!m_model) return; | 558 if (!m_model) return; |
547 | 559 |
548 SparseOneDimensionalModel::PointList points = getLocalPoints(v, e->x()); | 560 SparseOneDimensionalModel::PointList points = getLocalPoints(v, e->x()); |
549 if (points.empty()) return; | 561 if (points.empty()) return; |
559 } | 571 } |
560 | 572 |
561 void | 573 void |
562 TimeInstantLayer::editDrag(View *v, QMouseEvent *e) | 574 TimeInstantLayer::editDrag(View *v, QMouseEvent *e) |
563 { | 575 { |
576 #ifdef DEBUG_TIME_INSTANT_LAYER | |
564 std::cerr << "TimeInstantLayer::editDrag(" << e->x() << ")" << std::endl; | 577 std::cerr << "TimeInstantLayer::editDrag(" << e->x() << ")" << std::endl; |
578 #endif | |
565 | 579 |
566 if (!m_model || !m_editing) return; | 580 if (!m_model || !m_editing) return; |
567 | 581 |
568 long frame = v->getFrameForX(e->x()); | 582 long frame = v->getFrameForX(e->x()); |
569 if (frame < 0) frame = 0; | 583 if (frame < 0) frame = 0; |
580 } | 594 } |
581 | 595 |
582 void | 596 void |
583 TimeInstantLayer::editEnd(View *, QMouseEvent *e) | 597 TimeInstantLayer::editEnd(View *, QMouseEvent *e) |
584 { | 598 { |
599 #ifdef DEBUG_TIME_INSTANT_LAYER | |
585 std::cerr << "TimeInstantLayer::editEnd(" << e->x() << ")" << std::endl; | 600 std::cerr << "TimeInstantLayer::editEnd(" << e->x() << ")" << std::endl; |
601 #endif | |
586 if (!m_model || !m_editing) return; | 602 if (!m_model || !m_editing) return; |
587 if (m_editingCommand) { | 603 if (m_editingCommand) { |
588 QString newName = tr("Move Point to %1 s") | 604 QString newName = tr("Move Point to %1 s") |
589 .arg(RealTime::frame2RealTime(m_editingPoint.frame, | 605 .arg(RealTime::frame2RealTime(m_editingPoint.frame, |
590 m_model->getSampleRate()) | 606 m_model->getSampleRate()) |