Note selection state uses note event_id_t.
authornick_m <mainsbridge@gmail.com>
Sat, 15 Oct 2016 12:50:02 +0000 (23:50 +1100)
committernick_m <mainsbridge@gmail.com>
Sat, 15 Oct 2016 12:50:02 +0000 (23:50 +1100)
gtk2_ardour/editor.cc
gtk2_ardour/midi_region_view.cc
gtk2_ardour/midi_region_view.h
gtk2_ardour/selection.cc
gtk2_ardour/selection.h

index 53f1b032aee7c8d77285d84a3ea5b1bb9559aeba..f448f9ac2fa7693175d3c760e27a7dade525ac18 100644 (file)
@@ -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);
index 1900f71abc751558bee46675aee19690e0355dae..60a6630451932e4803b2dac2ecc68c870ba5deea 100644 (file)
@@ -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);
index db769b44fcde38c17ac3fa0be316c10ff0be3328..7827e1eb4dcbc666cef5fba33a156c76355bcb8b 100644 (file)
@@ -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);
index f7eb676d9693adeeca9c1388c6da76d51d30675f..dce8d13a41a3e5366267fcd0bf9614bb8f78910a 100644 (file)
@@ -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) {
index c9f5eddb4fd9e07e60b40278be5dd48edb6f1b55..8599da70d8287d478f0dbc1f289ba53006a18513 100644 (file)
@@ -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;