Re-add erroneously-removed methods related to cut/copy of
authorCarl Hetherington <carl@carlh.net>
Fri, 27 Apr 2012 21:34:44 +0000 (21:34 +0000)
committerCarl Hetherington <carl@carlh.net>
Fri, 27 Apr 2012 21:34:44 +0000 (21:34 +0000)
automation time ranges.

git-svn-id: svn://localhost/ardour2/branches/3.0@12114 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/automation_time_axis.cc
gtk2_ardour/automation_time_axis.h

index 4b10ea5cb5df380952f4a53159d9f557810a09c4..3332a066d9c4b2a45d66b4d861b60f846e5183ab 100644 (file)
@@ -900,3 +900,69 @@ AutomationTimeAxisView::parse_state_id (
 
        return true;
 }
+
+void
+AutomationTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
+{
+       list<boost::shared_ptr<AutomationLine> > lines;
+       if (_line) {
+               lines.push_back (_line);
+       } else if (_view) {
+               lines = _view->get_lines ();
+       }
+
+       for (list<boost::shared_ptr<AutomationLine> >::iterator i = lines.begin(); i != lines.end(); ++i) {
+               cut_copy_clear_one (**i, selection, op);
+       }
+}
+
+void
+AutomationTimeAxisView::cut_copy_clear_one (AutomationLine& line, Selection& selection, CutCopyOp op)
+{
+       boost::shared_ptr<Evoral::ControlList> what_we_got;
+       boost::shared_ptr<AutomationList> alist (line.the_list());
+
+       XMLNode &before = alist->get_state();
+
+       /* convert time selection to automation list model coordinates */
+       const Evoral::TimeConverter<double, ARDOUR::framepos_t>& tc = line.time_converter ();
+       double const start = tc.from (selection.time.front().start - tc.origin_b ());
+       double const end = tc.from (selection.time.front().end - tc.origin_b ());
+
+       switch (op) {
+       case Delete:
+               if (alist->cut (start, end) != 0) {
+                       _session->add_command(new MementoCommand<AutomationList>(*alist.get(), &before, &alist->get_state()));
+               }
+               break;
+
+       case Cut:
+
+               if ((what_we_got = alist->cut (start, end)) != 0) {
+                       _editor.get_cut_buffer().add (what_we_got);
+                       _session->add_command(new MementoCommand<AutomationList>(*alist.get(), &before, &alist->get_state()));
+               }
+               break;
+       case Copy:
+               if ((what_we_got = alist->copy (start, end)) != 0) {
+                       _editor.get_cut_buffer().add (what_we_got);
+               }
+               break;
+
+       case Clear:
+               if ((what_we_got = alist->cut (start, end)) != 0) {
+                       _session->add_command(new MementoCommand<AutomationList>(*alist.get(), &before, &alist->get_state()));
+               }
+               break;
+       }
+
+       if (what_we_got) {
+               for (AutomationList::iterator x = what_we_got->begin(); x != what_we_got->end(); ++x) {
+                       double when = (*x)->when;
+                       double val  = (*x)->value;
+                       line.model_to_view_coord (when, val);
+                       (*x)->when = when;
+                       (*x)->value = val;
+               }
+       }
+}
index 913cd1b467a57ff4660d45e4dff1936051feb768..d883b189c0f67417fef14eba49572406cc3e927b 100644 (file)
@@ -91,6 +91,7 @@ class AutomationTimeAxisView : public TimeAxisView {
 
        /* editing operations */
 
+       void cut_copy_clear (Selection&, Editing::CutCopyOp);
        bool paste (ARDOUR::framepos_t, float times, Selection&, size_t nth);
 
        int  set_state (const XMLNode&, int version);
@@ -166,6 +167,7 @@ class AutomationTimeAxisView : public TimeAxisView {
 
        void build_display_menu ();
 
+       void cut_copy_clear_one (AutomationLine&, Selection&, Editing::CutCopyOp);
        bool paste_one (AutomationLine&, ARDOUR::framepos_t, float times, Selection&, size_t nth);
        void route_going_away ();