Mercurial > hg > svgui
diff 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 |
line wrap: on
line diff
--- a/layer/NoteLayer.cpp Thu Nov 22 14:27:41 2007 +0000 +++ b/layer/NoteLayer.cpp Fri Nov 23 16:48:23 2007 +0000 @@ -41,8 +41,8 @@ SingleColourLayer(), m_model(0), m_editing(false), - m_originalPoint(0, 0.0, 0, tr("New Point")), - m_editingPoint(0, 0.0, 0, tr("New Point")), + m_originalPoint(0, 0.0, 0, 1.f, tr("New Point")), + m_editingPoint(0, 0.0, 0, 1.f, tr("New Point")), m_editingCommand(0), m_verticalScale(AutoAlignScale) { @@ -619,7 +619,7 @@ float value = getValueForY(v, e->y()); - m_editingPoint = NoteModel::Point(frame, value, 0, tr("New Point")); + m_editingPoint = NoteModel::Point(frame, value, 0, 0.8, tr("New Point")); m_originalPoint = m_editingPoint; if (m_editingCommand) m_editingCommand->finish(); @@ -670,6 +670,51 @@ } void +NoteLayer::eraseStart(View *v, QMouseEvent *e) +{ + if (!m_model) return; + + NoteModel::PointList points = getLocalPoints(v, e->x()); + if (points.empty()) return; + + m_editingPoint = *points.begin(); + + if (m_editingCommand) { + m_editingCommand->finish(); + m_editingCommand = 0; + } + + m_editing = true; +} + +void +NoteLayer::eraseDrag(View *v, QMouseEvent *e) +{ +} + +void +NoteLayer::eraseEnd(View *v, QMouseEvent *e) +{ + if (!m_model || !m_editing) return; + + m_editing = false; + + NoteModel::PointList points = getLocalPoints(v, e->x()); + if (points.empty()) return; + if (points.begin()->frame != m_editingPoint.frame || + points.begin()->value != m_editingPoint.value) return; + + m_editingCommand = new NoteModel::EditCommand + (m_model, tr("Erase Point")); + + m_editingCommand->deletePoint(m_editingPoint); + + m_editingCommand->finish(); + m_editingCommand = 0; + m_editing = false; +} + +void NoteLayer::editStart(View *v, QMouseEvent *e) { // std::cerr << "NoteLayer::editStart(" << e->x() << "," << e->y() << ")" << std::endl; @@ -881,7 +926,8 @@ for (NoteModel::PointList::iterator i = points.begin(); i != points.end(); ++i) { if (s.contains(i->frame)) { - Clipboard::Point point(i->frame, i->value, i->duration, i->label); + Clipboard::Point point(i->frame, i->value, i->duration, i->level, i->label); + point.setReferenceFrame(m_model->alignToReference(i->frame)); to.addPoint(point); } } @@ -911,6 +957,7 @@ if (i->haveValue()) newPoint.value = i->getValue(); else newPoint.value = (m_model->getValueMinimum() + m_model->getValueMaximum()) / 2; + if (i->haveLevel()) newPoint.level = i->getLevel(); if (i->haveDuration()) newPoint.duration = i->getDuration(); else { size_t nextFrame = frame;