# HG changeset patch # User matthiasm # Date 1371732456 -3600 # Node ID 8663a831838f566c315c84547d59e662f176afe1 # Parent 65b966394650c7b59ad454e530e7940587f5a84b# Parent 050404ae7799c4c4b92a08d60024f36f8273450f instrument is now "click" -- some other minor changes I don't remember diff -r 050404ae7799 -r 8663a831838f layer/FlexiNoteLayer.cpp --- a/layer/FlexiNoteLayer.cpp Thu Jun 20 10:58:40 2013 +0100 +++ b/layer/FlexiNoteLayer.cpp Thu Jun 20 13:47:36 2013 +0100 @@ -1158,6 +1158,44 @@ } void +FlexiNoteLayer::addNote(View *v, QMouseEvent *e) +{ + std::cerr << "addNote" << std::endl; + if (!m_model) return; + + long duration = 10000; + + long frame = v->getFrameForX(e->x()); + float value = getValueForY(v, e->y()); + + if (m_intelligentActions) { + long smallestRightNeighbourFrame = 0; + for (FlexiNoteModel::PointList::const_iterator i = m_model->getPoints().begin(); + i != m_model->getPoints().end(); ++i) { + FlexiNote currentNote = *i; + if (currentNote.frame > frame) { + smallestRightNeighbourFrame = currentNote.frame; + break; + } + } + + duration = std::min(smallestRightNeighbourFrame - frame + 1, duration); + duration = (duration > 0) ? duration : 0; + } + + if (!m_intelligentActions || + m_model->getPoints(frame).empty() && duration > 0) + { + FlexiNote newNote(frame, value, duration, 100, "new note"); + FlexiNoteModel::EditCommand *command = new FlexiNoteModel::EditCommand + (m_model, tr("Add Point")); + command->addPoint(newNote); + finish(command); + } +} + + +void FlexiNoteLayer::updateNoteValue(View *v, FlexiNoteModel::Point ¬e) const { //GF: update the note value conforming the median of pitch values in the underlying note layer @@ -1561,7 +1599,7 @@ std::cerr << "min frequency:" << minf << ", max frequency: " << maxf << std::endl; if (hasNotes) { - v->getLayer(1)->setDisplayExtents(minf*0.8,maxf*1.2); + v->getLayer(1)->setDisplayExtents(minf*0.66,maxf*1.5); // MM: this is a hack because we rely on // * this layer being automatically aligned to layer 1 // * layer one is a log frequency layer. diff -r 050404ae7799 -r 8663a831838f layer/FlexiNoteLayer.h --- a/layer/FlexiNoteLayer.h Thu Jun 20 10:58:40 2013 +0100 +++ b/layer/FlexiNoteLayer.h Thu Jun 20 13:47:36 2013 +0100 @@ -56,6 +56,8 @@ virtual void splitStart(View *v, QMouseEvent *); virtual void splitEnd(View *v, QMouseEvent *); + + virtual void addNote(View *v, QMouseEvent *e); virtual void mouseMoveEvent(View *v, QMouseEvent *); diff -r 050404ae7799 -r 8663a831838f layer/Layer.h --- a/layer/Layer.h Thu Jun 20 10:58:40 2013 +0100 +++ b/layer/Layer.h Thu Jun 20 13:47:36 2013 +0100 @@ -231,6 +231,7 @@ virtual void splitStart(View *, QMouseEvent *) { } virtual void splitEnd(View *, QMouseEvent *) { } + virtual void addNote(View *v, QMouseEvent *e) { }; // Measurement rectangle (or equivalent). Unlike draw and edit, // the base Layer class can provide working implementations of diff -r 050404ae7799 -r 8663a831838f view/Pane.cpp --- a/view/Pane.cpp Thu Jun 20 10:58:40 2013 +0100 +++ b/view/Pane.cpp Thu Jun 20 13:47:36 2013 +0100 @@ -2107,10 +2107,10 @@ if (mode == ViewManager::NavigateMode || mode == ViewManager::EditMode) { - Layer *layer = getSelectedLayer(); - if (layer && layer->isLayerEditable()) { - if (layer->editOpen(this, e)) relocate = false; - } + Layer *layer = getSelectedLayer(); + if (layer && layer->isLayerEditable()) { + if (layer->editOpen(this, e)) relocate = false; + } } else if (mode == ViewManager::MeasureMode) { @@ -2134,6 +2134,14 @@ m_dragStartMinValue = dmin; } } + + if (mode == ViewManager::NoteEditMode) { + std::cerr << "double click in note edit mode" << std::endl; + Layer *layer = getSelectedLayer(); + if (layer && layer->isLayerEditable()) { + layer->addNote(this, e); + } + } m_clickedInRange = false; // in case mouseReleaseEvent is not properly called }