Add automation track control points to undo history (and selection_op history).
authornick_m <mainsbridge@gmail.com>
Tue, 23 Dec 2014 17:29:43 +0000 (04:29 +1100)
committerPaul Davis <paul@linuxaudiosystems.com>
Fri, 2 Jan 2015 13:01:12 +0000 (08:01 -0500)
gtk2_ardour/editor.cc
gtk2_ardour/editor.h
gtk2_ardour/editor_actions.cc
gtk2_ardour/selection.cc

index 27631cd66a84186ab3282caaa42c34d1b1ad5348..019d2f91e8d60aff2c19115d781bc0d15a1c9b69 100644 (file)
@@ -3360,7 +3360,7 @@ Editor::commit_reversible_selection_op ()
 }
 
 void
-Editor::undo_reversible_selection_op ()
+Editor::undo_selection_op ()
 {
        if (_session) {
                selection_op_history_it++;
@@ -3381,7 +3381,7 @@ Editor::undo_reversible_selection_op ()
 }
 
 void
-Editor::redo_reversible_selection_op ()
+Editor::redo_selection_op ()
 {
        if (_session) {
                if (selection_op_history_it > 0) {
index b5c4fa404cc59a920e6564f04873df90fff4d942..655782e269476e1d6b1756bf68d91e2040121d3f 100644 (file)
@@ -443,8 +443,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void begin_selection_op_history ();
        void begin_reversible_selection_op (std::string cmd_name);
        void commit_reversible_selection_op ();
-       void undo_reversible_selection_op ();
-       void redo_reversible_selection_op ();
+       void undo_selection_op ();
+       void redo_selection_op ();
        void begin_reversible_command (std::string cmd_name);
        void begin_reversible_command (GQuark);
        void commit_reversible_command ();
index 214eebac6ed740f22c19bc0adffcd756f21ff0d3..49b39397cd884a90dacdd27080af15688f3e9f40 100644 (file)
@@ -317,8 +317,8 @@ Editor::register_actions ()
        alternate_redo_action = reg_sens (editor_actions, "alternate-redo", _("Redo"), sigc::bind (sigc::mem_fun(*this, &Editor::redo), 1U));
        alternate_alternate_redo_action = reg_sens (editor_actions, "alternate-alternate-redo", _("Redo"), sigc::bind (sigc::mem_fun(*this, &Editor::redo), 1U));
 
-       selection_undo_action = reg_sens (editor_actions, "undo-last-selection-op", _("Undo Last Selection Op"), sigc::mem_fun(*this, &Editor::undo_reversible_selection_op));
-       selection_redo_action = reg_sens (editor_actions, "redo-last-selection-op", _("Redo Last Selection Op"), sigc::mem_fun(*this, &Editor::redo_reversible_selection_op));
+       selection_undo_action = reg_sens (editor_actions, "undo-last-selection-op", _("Undo Selection Change"), sigc::mem_fun(*this, &Editor::undo_selection_op));
+       selection_redo_action = reg_sens (editor_actions, "redo-last-selection-op", _("Redo Selection Change"), sigc::mem_fun(*this, &Editor::redo_selection_op));
 
        reg_sens (editor_actions, "export-audio", _("Export Audio"), sigc::mem_fun(*this, &Editor::export_audio));
        reg_sens (editor_actions, "export-range", _("Export Range"), sigc::mem_fun(*this, &Editor::export_range));
index ae00c4f8c4e7af1c89b387ae07fa29fef1d0beb9..4a619e1b039e46904c7b4bfb70b459e0e9ab03dd 100644 (file)
@@ -1232,6 +1232,20 @@ Selection::get_state () const
                
        }
 
+       for (PointSelection::const_iterator i = points.begin(); i != points.end(); ++i) {
+               AutomationTimeAxisView* atv = dynamic_cast<AutomationTimeAxisView*> (&(*i)->line().trackview);
+               if (atv) {
+                       XMLNode* r = node->add_child (X_("ControlPoint"));
+                       r->add_property (X_("type"), "track");
+                       r->add_property (X_("route-id"), atoi (atv->parent_route()->id ().to_s ().c_str()));
+                       r->add_property (X_("automation-list-id"), atoi ((*i)->line().the_list()->id ().to_s ().c_str()));
+                       r->add_property (X_("parameter"), EventTypeMap::instance().to_symbol ((*i)->line().the_list()->parameter ()));
+
+                       snprintf(buf, sizeof(buf), "%d", (*i)->view_index());
+                       r->add_property (X_("view-index"), string(buf));
+               }
+       }
+
        for (TimeSelection::const_iterator i = time.begin(); i != time.end(); ++i) {
                XMLNode* t = node->add_child (X_("AudioRange"));
                snprintf(buf, sizeof(buf), "%" PRId64, (*i).start);
@@ -1261,6 +1275,7 @@ Selection::set_state (XMLNode const & node, int)
        }
 
        clear_regions ();
+       clear_points ();
        clear_time ();
        clear_tracks ();
        clear_markers ();
@@ -1295,6 +1310,39 @@ Selection::set_state (XMLNode const & node, int)
                                regions.pending.push_back (id);
                        }
                        
+               } else if  ((*i)->name() == X_("ControlPoint")) {
+                       XMLProperty* prop_type = (*i)->property (X_("type"));
+                       XMLProperty* prop_route_id = (*i)->property (X_("route-id"));
+                       XMLProperty* prop_alist_id = (*i)->property (X_("automation-list-id"));
+                       XMLProperty* prop_parameter = (*i)->property (X_("parameter"));
+                       XMLProperty* prop_view_index = (*i)->property (X_("view-index"));
+
+                       assert (prop_type);
+                       assert (prop_route_id);
+                       assert (prop_alist_id);
+                       assert (prop_parameter);
+                       assert (prop_view_index);
+
+                       if (prop_type->value () == "track") {
+                               PBD::ID id (prop_route_id->value ());
+                               RouteTimeAxisView* rtv = editor->get_route_view_by_route_id (id);
+
+                               if (rtv) {
+                                       boost::shared_ptr<AutomationTimeAxisView> atv = rtv->automation_child (EventTypeMap::instance().from_symbol (prop_parameter->value ()));
+                                       if (atv) {
+                                               list<boost::shared_ptr<AutomationLine> > lines = atv->lines();
+                                               for (list<boost::shared_ptr<AutomationLine> > ::iterator i = lines.begin(); i != lines.end(); ++i) {
+                                                       if ((*i)->the_list()->id() == prop_alist_id->value()) {
+                                                               ControlPoint* cp = (*i)->nth(atol(prop_view_index->value().c_str()));
+                                                               if (cp) {
+                                                                       add (cp);
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+                       } 
+
                } else if  ((*i)->name() == X_("AudioRange")) {
                        XMLProperty* prop_start = (*i)->property (X_("start"));
                        XMLProperty* prop_end = (*i)->property (X_("end"));