Mercurial > hg > svgui
comparison layer/NoteLayer.cpp @ 335:2f83b6e3b8ca
* Add Erase tool and mode
* Add icons for Normalize buttons in property boxes, and for Show Peaks
* Add support for velocity in notes -- not yet reflected in display or
editable in the note edit dialog, but they are imported from MIDI,
played, and exported
* Begin work on making pastes align pasted times (subtler than I thought)
author | Chris Cannam |
---|---|
date | Fri, 23 Nov 2007 16:48:23 +0000 |
parents | 984c1975f1ff |
children | 020c485aa7e0 0895517bb2d1 |
comparison
equal
deleted
inserted
replaced
334:0a74248af622 | 335:2f83b6e3b8ca |
---|---|
39 | 39 |
40 NoteLayer::NoteLayer() : | 40 NoteLayer::NoteLayer() : |
41 SingleColourLayer(), | 41 SingleColourLayer(), |
42 m_model(0), | 42 m_model(0), |
43 m_editing(false), | 43 m_editing(false), |
44 m_originalPoint(0, 0.0, 0, tr("New Point")), | 44 m_originalPoint(0, 0.0, 0, 1.f, tr("New Point")), |
45 m_editingPoint(0, 0.0, 0, tr("New Point")), | 45 m_editingPoint(0, 0.0, 0, 1.f, tr("New Point")), |
46 m_editingCommand(0), | 46 m_editingCommand(0), |
47 m_verticalScale(AutoAlignScale) | 47 m_verticalScale(AutoAlignScale) |
48 { | 48 { |
49 | 49 |
50 } | 50 } |
617 if (frame < 0) frame = 0; | 617 if (frame < 0) frame = 0; |
618 frame = frame / m_model->getResolution() * m_model->getResolution(); | 618 frame = frame / m_model->getResolution() * m_model->getResolution(); |
619 | 619 |
620 float value = getValueForY(v, e->y()); | 620 float value = getValueForY(v, e->y()); |
621 | 621 |
622 m_editingPoint = NoteModel::Point(frame, value, 0, tr("New Point")); | 622 m_editingPoint = NoteModel::Point(frame, value, 0, 0.8, tr("New Point")); |
623 m_originalPoint = m_editingPoint; | 623 m_originalPoint = m_editingPoint; |
624 | 624 |
625 if (m_editingCommand) m_editingCommand->finish(); | 625 if (m_editingCommand) m_editingCommand->finish(); |
626 m_editingCommand = new NoteModel::EditCommand(m_model, | 626 m_editingCommand = new NoteModel::EditCommand(m_model, |
627 tr("Draw Point")); | 627 tr("Draw Point")); |
662 void | 662 void |
663 NoteLayer::drawEnd(View *, QMouseEvent *) | 663 NoteLayer::drawEnd(View *, QMouseEvent *) |
664 { | 664 { |
665 // std::cerr << "NoteLayer::drawEnd(" << e->x() << "," << e->y() << ")" << std::endl; | 665 // std::cerr << "NoteLayer::drawEnd(" << e->x() << "," << e->y() << ")" << std::endl; |
666 if (!m_model || !m_editing) return; | 666 if (!m_model || !m_editing) return; |
667 m_editingCommand->finish(); | |
668 m_editingCommand = 0; | |
669 m_editing = false; | |
670 } | |
671 | |
672 void | |
673 NoteLayer::eraseStart(View *v, QMouseEvent *e) | |
674 { | |
675 if (!m_model) return; | |
676 | |
677 NoteModel::PointList points = getLocalPoints(v, e->x()); | |
678 if (points.empty()) return; | |
679 | |
680 m_editingPoint = *points.begin(); | |
681 | |
682 if (m_editingCommand) { | |
683 m_editingCommand->finish(); | |
684 m_editingCommand = 0; | |
685 } | |
686 | |
687 m_editing = true; | |
688 } | |
689 | |
690 void | |
691 NoteLayer::eraseDrag(View *v, QMouseEvent *e) | |
692 { | |
693 } | |
694 | |
695 void | |
696 NoteLayer::eraseEnd(View *v, QMouseEvent *e) | |
697 { | |
698 if (!m_model || !m_editing) return; | |
699 | |
700 m_editing = false; | |
701 | |
702 NoteModel::PointList points = getLocalPoints(v, e->x()); | |
703 if (points.empty()) return; | |
704 if (points.begin()->frame != m_editingPoint.frame || | |
705 points.begin()->value != m_editingPoint.value) return; | |
706 | |
707 m_editingCommand = new NoteModel::EditCommand | |
708 (m_model, tr("Erase Point")); | |
709 | |
710 m_editingCommand->deletePoint(m_editingPoint); | |
711 | |
667 m_editingCommand->finish(); | 712 m_editingCommand->finish(); |
668 m_editingCommand = 0; | 713 m_editingCommand = 0; |
669 m_editing = false; | 714 m_editing = false; |
670 } | 715 } |
671 | 716 |
879 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); | 924 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); |
880 | 925 |
881 for (NoteModel::PointList::iterator i = points.begin(); | 926 for (NoteModel::PointList::iterator i = points.begin(); |
882 i != points.end(); ++i) { | 927 i != points.end(); ++i) { |
883 if (s.contains(i->frame)) { | 928 if (s.contains(i->frame)) { |
884 Clipboard::Point point(i->frame, i->value, i->duration, i->label); | 929 Clipboard::Point point(i->frame, i->value, i->duration, i->level, i->label); |
930 point.setReferenceFrame(m_model->alignToReference(i->frame)); | |
885 to.addPoint(point); | 931 to.addPoint(point); |
886 } | 932 } |
887 } | 933 } |
888 } | 934 } |
889 | 935 |
909 | 955 |
910 if (i->haveLabel()) newPoint.label = i->getLabel(); | 956 if (i->haveLabel()) newPoint.label = i->getLabel(); |
911 if (i->haveValue()) newPoint.value = i->getValue(); | 957 if (i->haveValue()) newPoint.value = i->getValue(); |
912 else newPoint.value = (m_model->getValueMinimum() + | 958 else newPoint.value = (m_model->getValueMinimum() + |
913 m_model->getValueMaximum()) / 2; | 959 m_model->getValueMaximum()) / 2; |
960 if (i->haveLevel()) newPoint.level = i->getLevel(); | |
914 if (i->haveDuration()) newPoint.duration = i->getDuration(); | 961 if (i->haveDuration()) newPoint.duration = i->getDuration(); |
915 else { | 962 else { |
916 size_t nextFrame = frame; | 963 size_t nextFrame = frame; |
917 Clipboard::PointList::const_iterator j = i; | 964 Clipboard::PointList::const_iterator j = i; |
918 for (; j != points.end(); ++j) { | 965 for (; j != points.end(); ++j) { |