diff options
author | nick_m <mainsbridge@gmail.com> | 2016-10-15 23:50:02 +1100 |
---|---|---|
committer | nick_m <mainsbridge@gmail.com> | 2016-10-15 23:50:02 +1100 |
commit | 9698f16aee5f91d158551d333fe0fb1b23d22859 (patch) | |
tree | 0a23078aefc5e0df27908594ff8fed2c9d8a85e0 | |
parent | 7da51b979257bd051d26c35f82f37a2a69839232 (diff) |
Note selection state uses note event_id_t.
-rw-r--r-- | gtk2_ardour/editor.cc | 2 | ||||
-rw-r--r-- | gtk2_ardour/midi_region_view.cc | 14 | ||||
-rw-r--r-- | gtk2_ardour/midi_region_view.h | 6 | ||||
-rw-r--r-- | gtk2_ardour/selection.cc | 49 | ||||
-rw-r--r-- | gtk2_ardour/selection.h | 2 |
5 files changed, 19 insertions, 54 deletions
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 53f1b032ae..f448f9ac2f 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -5168,7 +5168,7 @@ Editor::region_view_added (RegionView * rv) MidiRegionView* mrv = dynamic_cast<MidiRegionView*> (rv); if (mrv) { - list<pair<PBD::ID const, list<boost::shared_ptr<Evoral::Note<Evoral::Beats> > > > >::iterator rnote; + list<pair<PBD::ID const, list<Evoral::event_id_t> > >::iterator rnote; for (rnote = selection->pending_midi_note_selection.begin(); rnote != selection->pending_midi_note_selection.end(); ++rnote) { if (rv->region()->id () == (*rnote).first) { mrv->select_notes ((*rnote).second); diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index 1900f71abc..60a6630451 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -1115,12 +1115,12 @@ MidiRegionView::find_canvas_note (boost::shared_ptr<NoteType> note) /** This version finds any canvas note matching the supplied note. */ NoteBase* -MidiRegionView::find_canvas_note (NoteType note) +MidiRegionView::find_canvas_note (Evoral::event_id_t id) { Events::iterator it; for (it = _events.begin(); it != _events.end(); ++it) { - if (*((*it)->note()) == note) { + if ((*it)->note()->id() == id) { return *it; } } @@ -1200,9 +1200,9 @@ MidiRegionView::redisplay_model() cne = add_note (note, visible); } - set<boost::shared_ptr<NoteType> >::iterator it; + set<Evoral::event_id_t>::iterator it; for (it = _pending_note_selection.begin(); it != _pending_note_selection.end(); ++it) { - if (*(*it) == *note) { + if ((*it) == note->id()) { add_to_selection (cne); } } @@ -2229,13 +2229,13 @@ MidiRegionView::invert_selection () The requested notes most likely won't exist in the view until the next model redisplay. */ void -MidiRegionView::select_notes (list<boost::shared_ptr<NoteType> > notes) +MidiRegionView::select_notes (list<Evoral::event_id_t> notes) { NoteBase* cne; - list<boost::shared_ptr<NoteType> >::iterator n; + list<Evoral::event_id_t>::iterator n; for (n = notes.begin(); n != notes.end(); ++n) { - if ((cne = find_canvas_note(*(*n))) != 0) { + if ((cne = find_canvas_note(*n)) != 0) { add_to_selection (cne); } else { _pending_note_selection.insert(*n); diff --git a/gtk2_ardour/midi_region_view.h b/gtk2_ardour/midi_region_view.h index db769b44fc..7827e1eb4d 100644 --- a/gtk2_ardour/midi_region_view.h +++ b/gtk2_ardour/midi_region_view.h @@ -202,7 +202,7 @@ public: void move_selection(double dx, double dy, double cumulative_dy); void note_dropped (NoteBase* ev, ARDOUR::frameoffset_t, int8_t d_note); - void select_notes (std::list<boost::shared_ptr<NoteType> >); + void select_notes (std::list<Evoral::event_id_t>); void select_matching_notes (uint8_t notenum, uint16_t channel_mask, bool add, bool extend); void toggle_matching_notes (uint8_t notenum, uint16_t channel_mask); @@ -444,7 +444,7 @@ private: std::set< boost::shared_ptr<NoteType> > _marked_for_selection; /** Notes that should be selected when the model is redisplayed. */ - std::set< boost::shared_ptr<NoteType> > _pending_note_selection; + std::set<Evoral::event_id_t> _pending_note_selection; /** New notes (created in the current command) which should have visible velocity * when they appear after the command is applied. */ @@ -456,7 +456,7 @@ private: PBD::ScopedConnection content_connection; NoteBase* find_canvas_note (boost::shared_ptr<NoteType>); - NoteBase* find_canvas_note (NoteType); + NoteBase* find_canvas_note (Evoral::event_id_t id); Events::iterator _optimization_iterator; void update_note (NoteBase*, bool update_ghost_regions = true); diff --git a/gtk2_ardour/selection.cc b/gtk2_ardour/selection.cc index f7eb676d96..dce8d13a41 100644 --- a/gtk2_ardour/selection.cc +++ b/gtk2_ardour/selection.cc @@ -1283,23 +1283,9 @@ Selection::get_state () const for (std::set<boost::shared_ptr<Evoral::Note<Evoral::Beats> > >::iterator i = (*rn_it).second.begin(); i != (*rn_it).second.end(); ++i) { XMLNode* nc = n->add_child(X_("note")); - snprintf(buf, sizeof(buf), "%d", (*i)->channel()); - nc->add_property(X_("channel"), string(buf)); - snprintf(buf, sizeof(buf), "%f", (*i)->time().to_double()); - nc->add_property(X_("time"), string(buf)); - - snprintf(buf, sizeof(buf), "%d", (*i)->note()); - nc->add_property(X_("note"), string(buf)); - - snprintf(buf, sizeof(buf), "%f", (*i)->length().to_double()); - nc->add_property(X_("length"), string(buf)); - - snprintf(buf, sizeof(buf), "%d", (*i)->velocity()); - nc->add_property(X_("velocity"), string(buf)); - - snprintf(buf, sizeof(buf), "%d", (*i)->off_velocity()); - nc->add_property(X_("off-velocity"), string(buf)); + snprintf(buf, sizeof(buf), "%d", (*i)->id()); + nc->add_property(X_("id"), string(buf)); } } @@ -1404,35 +1390,14 @@ Selection::set_state (XMLNode const & node, int) editor->get_regionviews_by_id (id, rs); // there could be more than one - std::list<boost::shared_ptr<Evoral::Note<Evoral::Beats> > > notes; + std::list<Evoral::event_id_t> notes; XMLNodeList children = (*i)->children (); for (XMLNodeList::const_iterator ci = children.begin(); ci != children.end(); ++ci) { - XMLProperty const * prop_channel = (*ci)->property (X_("channel")); - XMLProperty const * prop_time = (*ci)->property (X_("time")); - XMLProperty const * prop_note = (*ci)->property (X_("note")); - XMLProperty const * prop_length = (*ci)->property (X_("length")); - XMLProperty const * prop_velocity = (*ci)->property (X_("velocity")); - XMLProperty const * prop_off_velocity = (*ci)->property (X_("off-velocity")); - - assert (prop_channel); - assert (prop_time); - assert (prop_note); - assert (prop_length); - assert (prop_velocity); - assert (prop_off_velocity); - - uint8_t channel = atoi(prop_channel->value()); - Evoral::Beats time (atof(prop_time->value())); - Evoral::Beats length (atof(prop_length->value())); - uint8_t note = atoi(prop_note->value()); - uint8_t velocity = atoi(prop_velocity->value()); - uint8_t off_velocity = atoi(prop_off_velocity->value()); - boost::shared_ptr<Evoral::Note<Evoral::Beats> > the_note - (new Evoral::Note<Evoral::Beats> (channel, time, length, note, velocity)); - the_note->set_off_velocity (off_velocity); - - notes.push_back (the_note); + XMLProperty const * prop_id = (*ci)->property (X_("id")); + Evoral::event_id_t id = atoi(prop_id->value()); + + notes.push_back (id); } for (RegionSelection::iterator rsi = rs.begin(); rsi != rs.end(); ++rsi) { diff --git a/gtk2_ardour/selection.h b/gtk2_ardour/selection.h index c9f5eddb4f..8599da70d8 100644 --- a/gtk2_ardour/selection.h +++ b/gtk2_ardour/selection.h @@ -226,7 +226,7 @@ class Selection : public sigc::trackable, public PBD::ScopedConnectionList XMLNode& get_state () const; int set_state (XMLNode const &, int); - std::list<std::pair<PBD::ID const, std::list<boost::shared_ptr<Evoral::Note<Evoral::Beats> > > > > pending_midi_note_selection; + std::list<std::pair<PBD::ID const, std::list<Evoral::event_id_t> > > pending_midi_note_selection; private: PublicEditor const * editor; |