pay some attention to the special guest of the night: KDE window stacking
[ardour.git] / gtk2_ardour / selection.cc
index feb7b3b1a578b7680f13b05f3ad35a25a59690a0..98b5d62c1043f2a4faa289ba8a6e40438e6eb99b 100644 (file)
@@ -41,7 +41,7 @@
 #include "public_editor.h"
 #include "control_point.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace std;
 using namespace ARDOUR;
@@ -1270,36 +1270,19 @@ Selection::get_state () const
        }
 
        /* midi region views have thir own internal selection. */
-       XMLNode* n = NULL;
        list<pair<PBD::ID, std::set<boost::shared_ptr<Evoral::Note<Evoral::Beats> > > > > rid_notes;
        editor->get_per_region_note_selection (rid_notes);
-       if (!rid_notes.empty()) {
-               n = node->add_child (X_("MIDINote"));
-       }
+
        list<pair<PBD::ID, std::set<boost::shared_ptr<Evoral::Note<Evoral::Beats> > > > >::iterator rn_it;
        for (rn_it = rid_notes.begin(); rn_it != rid_notes.end(); ++rn_it) {
-               assert(n); // hint for clang static analysis
-               n->add_property (X_("region_id"), atoi((*rn_it).first.to_s().c_str()));
+               XMLNode* n = node->add_child (X_("MIDINotes"));
+               n->add_property (X_("region-id"), atoi((*rn_it).first.to_s().c_str()));
 
                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_("note-id"), string(buf));
                }
        }
 
@@ -1394,7 +1377,7 @@ Selection::set_state (XMLNode const & node, int)
                                regions.pending.push_back (id);
                        }
 
-               } else if ((*i)->name() == X_("MIDINote")) {
+               } else if ((*i)->name() == X_("MIDINotes")) {
                        XMLProperty const * prop_region_id = (*i)->property (X_("region-id"));
 
                        assert (prop_region_id);
@@ -1404,35 +1387,15 @@ 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_("note-id"));
+                               if (prop_id) {
+                                       Evoral::event_id_t id = atoi(prop_id->value());
+                                       notes.push_back (id);
+                               }
                        }
 
                        for (RegionSelection::iterator rsi = rs.begin(); rsi != rs.end(); ++rsi) {