comparison layer/TimeInstantLayer.cpp @ 99:453f7da3534e

* Fix serious failure to reload "imported" (i.e. all non-derived non-main) models from .sv file * Give a short playback duration to notes with formal duration of 0 or 1 * Show crosshairs on spectrogram even when there is another layer on top (if it isn't opaque) * Always paste to the same time in the layer as the cut/copy was from, rather than to the playback pointer -- less flexible, but more predictable and less annoying. We probably need a way to get the old behaviour if pasting from somewhere else in the future (e.g. from a text file), but we can't do that yet anyway * Use a compound operation for dragging and resizing selections, so as to ensure a single undo operation works * Use a note model as the target for feature extraction plugins that output variable samplerate data with more than one value per feature * Avoid possible crashes in cut/paste if a layer proves to have no model
author Chris Cannam
date Thu, 11 May 2006 11:35:46 +0000
parents 4b98bda7e94d
children 999ae0f7d10c
comparison
equal deleted inserted replaced
98:2be85befe873 99:453f7da3534e
624 } 624 }
625 625
626 void 626 void
627 TimeInstantLayer::moveSelection(Selection s, size_t newStartFrame) 627 TimeInstantLayer::moveSelection(Selection s, size_t newStartFrame)
628 { 628 {
629 if (!m_model) return;
630
629 SparseOneDimensionalModel::EditCommand *command = 631 SparseOneDimensionalModel::EditCommand *command =
630 new SparseOneDimensionalModel::EditCommand(m_model, 632 new SparseOneDimensionalModel::EditCommand(m_model,
631 tr("Drag Selection")); 633 tr("Drag Selection"));
632 634
633 SparseOneDimensionalModel::PointList points = 635 SparseOneDimensionalModel::PointList points =
648 } 650 }
649 651
650 void 652 void
651 TimeInstantLayer::resizeSelection(Selection s, Selection newSize) 653 TimeInstantLayer::resizeSelection(Selection s, Selection newSize)
652 { 654 {
655 if (!m_model) return;
656
653 SparseOneDimensionalModel::EditCommand *command = 657 SparseOneDimensionalModel::EditCommand *command =
654 new SparseOneDimensionalModel::EditCommand(m_model, 658 new SparseOneDimensionalModel::EditCommand(m_model,
655 tr("Resize Selection")); 659 tr("Resize Selection"));
656 660
657 SparseOneDimensionalModel::PointList points = 661 SparseOneDimensionalModel::PointList points =
681 } 685 }
682 686
683 void 687 void
684 TimeInstantLayer::deleteSelection(Selection s) 688 TimeInstantLayer::deleteSelection(Selection s)
685 { 689 {
690 if (!m_model) return;
691
686 SparseOneDimensionalModel::EditCommand *command = 692 SparseOneDimensionalModel::EditCommand *command =
687 new SparseOneDimensionalModel::EditCommand(m_model, 693 new SparseOneDimensionalModel::EditCommand(m_model,
688 tr("Delete Selection")); 694 tr("Delete Selection"));
689 695
690 SparseOneDimensionalModel::PointList points = 696 SparseOneDimensionalModel::PointList points =
699 } 705 }
700 706
701 void 707 void
702 TimeInstantLayer::copy(Selection s, Clipboard &to) 708 TimeInstantLayer::copy(Selection s, Clipboard &to)
703 { 709 {
710 if (!m_model) return;
711
704 SparseOneDimensionalModel::PointList points = 712 SparseOneDimensionalModel::PointList points =
705 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); 713 m_model->getPoints(s.getStartFrame(), s.getEndFrame());
706 714
707 for (SparseOneDimensionalModel::PointList::iterator i = points.begin(); 715 for (SparseOneDimensionalModel::PointList::iterator i = points.begin();
708 i != points.end(); ++i) { 716 i != points.end(); ++i) {
714 } 722 }
715 723
716 void 724 void
717 TimeInstantLayer::paste(const Clipboard &from, int frameOffset) 725 TimeInstantLayer::paste(const Clipboard &from, int frameOffset)
718 { 726 {
727 if (!m_model) return;
728
719 const Clipboard::PointList &points = from.getPoints(); 729 const Clipboard::PointList &points = from.getPoints();
720 730
721 SparseOneDimensionalModel::EditCommand *command = 731 SparseOneDimensionalModel::EditCommand *command =
722 new SparseOneDimensionalModel::EditCommand(m_model, tr("Paste")); 732 new SparseOneDimensionalModel::EditCommand(m_model, tr("Paste"));
723 733