Clean up handling of track vs region automation a bit.
authorCarl Hetherington <carl@carlh.net>
Thu, 5 Aug 2010 13:35:43 +0000 (13:35 +0000)
committerCarl Hetherington <carl@carlh.net>
Thu, 5 Aug 2010 13:35:43 +0000 (13:35 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@7544 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/automation_streamview.cc
gtk2_ardour/automation_streamview.h
gtk2_ardour/automation_time_axis.cc
gtk2_ardour/automation_time_axis.h
gtk2_ardour/editor_drag.cc
gtk2_ardour/route_time_axis.cc
gtk2_ardour/route_time_axis.h
gtk2_ardour/time_axis_view.h

index 1f07aaaba7a878a2c59ceb5b2da695e67f6b67b6..6beb439b1115de96b8f7b403ec56e099b0597ea9 100644 (file)
@@ -158,10 +158,11 @@ AutomationStreamView::set_automation_state (AutoState state)
        if (region_views.empty()) {
                _pending_automation_state = state;
        } else {
-               for (std::list<RegionView *>::iterator i = region_views.begin(); i != region_views.end(); ++i) {
-                       boost::shared_ptr<AutomationLine> line = dynamic_cast<AutomationRegionView*>(*i)->line();
-                       if (line && line->the_list()) {
-                               line->the_list()->set_automation_state (state);
+               list<boost::shared_ptr<AutomationLine> > lines = get_lines ();
+
+               for (list<boost::shared_ptr<AutomationLine> >::iterator i = lines.begin(); i != lines.end(); ++i) {
+                       if ((*i)->the_list()) {
+                               (*i)->the_list()->set_automation_state (state);
                        }
                }
        }
@@ -225,13 +226,12 @@ AutomationStreamView::automation_state () const
 bool
 AutomationStreamView::has_automation () const
 {
-       list<RegionView*>::const_iterator i = region_views.begin ();
-       while (i != region_views.end()) {
-               AutomationRegionView* rv = static_cast<AutomationRegionView*> (*i);
-               if (rv->line() && rv->line()->npoints() > 0) {
+       list<boost::shared_ptr<AutomationLine> > lines = get_lines ();
+       
+       for (list<boost::shared_ptr<AutomationLine> >::iterator i = lines.begin(); i != lines.end(); ++i) {
+               if ((*i)->npoints() > 0) {
                        return true;
                }
-               ++i;
        }
 
        return false;
@@ -243,10 +243,10 @@ AutomationStreamView::has_automation () const
 void
 AutomationStreamView::set_interpolation (AutomationList::InterpolationStyle s)
 {
-       for (list<RegionView*>::const_iterator i = region_views.begin(); i != region_views.end(); ++i) {
-               AutomationRegionView* arv = dynamic_cast<AutomationRegionView*> (*i);
-               assert (arv);
-               arv->line()->the_list()->set_interpolation (s);
+       list<boost::shared_ptr<AutomationLine> > lines = get_lines ();
+       
+       for (list<boost::shared_ptr<AutomationLine> >::iterator i = lines.begin(); i != lines.end(); ++i) {
+               (*i)->the_list()->set_interpolation (s);
        }
 }
 
@@ -267,10 +267,10 @@ AutomationStreamView::interpolation () const
 void
 AutomationStreamView::clear ()
 {
-       for (list<RegionView*>::iterator i = region_views.begin(); i != region_views.end(); ++i) {
-               AutomationRegionView* arv = dynamic_cast<AutomationRegionView*> (*i);
-               assert (arv);
-               arv->line()->clear ();
+       list<boost::shared_ptr<AutomationLine> > lines = get_lines ();
+       
+       for (list<boost::shared_ptr<AutomationLine> >::iterator i = lines.begin(); i != lines.end(); ++i) {
+               (*i)->clear ();
        }
 }
 
@@ -287,9 +287,23 @@ AutomationStreamView::get_selectables (nframes_t start, nframes_t end, double bo
 void
 AutomationStreamView::set_selected_points (PointSelection& ps)
 {
-       for (list<RegionView*>::iterator i = region_views.begin(); i != region_views.end(); ++i) {
+       list<boost::shared_ptr<AutomationLine> > lines = get_lines ();
+       
+       for (list<boost::shared_ptr<AutomationLine> >::iterator i = lines.begin(); i != lines.end(); ++i) {
+               (*i)->set_selected_points (ps);
+       }
+}
+
+list<boost::shared_ptr<AutomationLine> >
+AutomationStreamView::get_lines () const
+{
+       list<boost::shared_ptr<AutomationLine> > lines;
+       
+       for (list<RegionView*>::const_iterator i = region_views.begin(); i != region_views.end(); ++i) {
                AutomationRegionView* arv = dynamic_cast<AutomationRegionView*> (*i);
                assert (arv);
-               arv->line()->set_selected_points (ps);
+               lines.push_back (arv->line());
        }
+
+       return lines;
 }
index 8c5acdcbd1087276a3f0a8dc39b4bf8bed414345..8afacd79cfa10e171bb5de61d2a6b67db74db809 100644 (file)
@@ -64,6 +64,8 @@ class AutomationStreamView : public StreamView
        void get_selectables (nframes_t, nframes_t, double, double, std::list<Selectable*> &);
        void set_selected_points (PointSelection &);
 
+       std::list<boost::shared_ptr<AutomationLine> > get_lines () const;
+
   private:
        void setup_rec_box ();
 
index 1596abfdf80cb8bd92a252c80a0355627594af7d..448cf4e501704fbee52c30ae1bb002472e2b9368 100644 (file)
@@ -407,8 +407,9 @@ AutomationTimeAxisView::set_height (uint32_t h)
        TimeAxisView::set_height (h);
        _base_rect->property_y2() = h;
 
-       if (_line)
+       if (_line) {
                _line->set_height(h);
+       }
 
        if (_view) {
                _view->set_height(h);
@@ -480,11 +481,13 @@ AutomationTimeAxisView::set_samples_per_unit (double spu)
 {
        TimeAxisView::set_samples_per_unit (spu);
 
-       if (_line)
+       if (_line) {
                _line->reset ();
+       }
 
-       if (_view)
+       if (_view) {
                _view->set_samples_per_unit (spu);
+       }
 }
 
 void
@@ -608,18 +611,26 @@ AutomationTimeAxisView::add_automation_event (ArdourCanvas::Item* /*item*/, GdkE
        _session->set_dirty ();
 }
 
-bool
+void
 AutomationTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
 {
-       return (_line ? cut_copy_clear_one (*_line, selection, op) : false);
+       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);
+       }
 }
 
-bool
+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());
-       bool ret = false;
 
        XMLNode &before = alist->get_state();
 
@@ -628,7 +639,6 @@ AutomationTimeAxisView::cut_copy_clear_one (AutomationLine& line, Selection& sel
                if ((what_we_got = alist->cut (selection.time.front().start, selection.time.front().end)) != 0) {
                        _editor.get_cut_buffer().add (what_we_got);
                        _session->add_command(new MementoCommand<AutomationList>(*alist.get(), &before, &alist->get_state()));
-                       ret = true;
                }
                break;
        case Copy:
@@ -640,7 +650,6 @@ AutomationTimeAxisView::cut_copy_clear_one (AutomationLine& line, Selection& sel
        case Clear:
                if ((what_we_got = alist->cut (selection.time.front().start, selection.time.front().end)) != 0) {
                        _session->add_command(new MementoCommand<AutomationList>(*alist.get(), &before, &alist->get_state()));
-                       ret = true;
                }
                break;
        }
@@ -654,8 +663,6 @@ AutomationTimeAxisView::cut_copy_clear_one (AutomationLine& line, Selection& sel
                        (*x)->value = val;
                }
        }
-
-       return ret;
 }
 
 void
@@ -681,18 +688,26 @@ AutomationTimeAxisView::reset_objects_one (AutomationLine& line, PointSelection&
        }
 }
 
-bool
+void
 AutomationTimeAxisView::cut_copy_clear_objects (PointSelection& selection, CutCopyOp op)
 {
-       return cut_copy_clear_objects_one (*_line, selection, 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_objects_one (**i, selection, op);
+       }
 }
 
-bool
+void
 AutomationTimeAxisView::cut_copy_clear_objects_one (AutomationLine& line, PointSelection& selection, CutCopyOp op)
 {
        boost::shared_ptr<Evoral::ControlList> what_we_got;
        boost::shared_ptr<AutomationList> alist(line.the_list());
-       bool ret = false;
 
        XMLNode &before = alist->get_state();
 
@@ -707,7 +722,6 @@ AutomationTimeAxisView::cut_copy_clear_objects_one (AutomationLine& line, PointS
                        if ((what_we_got = alist->cut ((*i).start, (*i).end)) != 0) {
                                _editor.get_cut_buffer().add (what_we_got);
                                _session->add_command (new MementoCommand<AutomationList>(*alist.get(), new XMLNode (before), &alist->get_state()));
-                               ret = true;
                        }
                        break;
                case Copy:
@@ -719,7 +733,6 @@ AutomationTimeAxisView::cut_copy_clear_objects_one (AutomationLine& line, PointS
                case Clear:
                        if ((what_we_got = alist->cut ((*i).start, (*i).end)) != 0) {
                                _session->add_command (new MementoCommand<AutomationList>(*alist.get(), new XMLNode (before), &alist->get_state()));
-                               ret = true;
                        }
                        break;
                }
@@ -727,6 +740,8 @@ AutomationTimeAxisView::cut_copy_clear_objects_one (AutomationLine& line, PointS
 
        delete &before;
 
+       cout << "CCC objects " << what_we_got->size() << "\n";
+       
        if (what_we_got) {
                for (AutomationList::iterator x = what_we_got->begin(); x != what_we_got->end(); ++x) {
                        double when = (*x)->when;
@@ -736,8 +751,6 @@ AutomationTimeAxisView::cut_copy_clear_objects_one (AutomationLine& line, PointS
                        (*x)->value = val;
                }
        }
-
-       return ret;
 }
 
 bool
@@ -825,8 +838,9 @@ AutomationTimeAxisView::get_selectables (nframes_t start, nframes_t end, double
 void
 AutomationTimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& result)
 {
-       if (_line)
+       if (_line) {
                _line->get_inverted_selectables (sel, result);
+       }
 }
 
 void
index 4b21ec85331ae0ffcf2a2a2264438c3cf058cac8..0da6c69acd7ce581fb3c66ecf04d484e92c0edf3 100644 (file)
@@ -86,8 +86,8 @@ class AutomationTimeAxisView : public TimeAxisView {
 
        /* editing operations */
 
-       bool cut_copy_clear (Selection&, Editing::CutCopyOp);
-       bool cut_copy_clear_objects (PointSelection&, Editing::CutCopyOp);
+       void cut_copy_clear (Selection&, Editing::CutCopyOp);
+       void cut_copy_clear_objects (PointSelection&, Editing::CutCopyOp);
        bool paste (nframes_t, float times, Selection&, size_t nth);
        void reset_objects (PointSelection&);
 
@@ -146,8 +146,8 @@ class AutomationTimeAxisView : public TimeAxisView {
 
        void build_display_menu ();
 
-       bool cut_copy_clear_one (AutomationLine&, Selection&, Editing::CutCopyOp);
-       bool cut_copy_clear_objects_one (AutomationLine&, PointSelection&, Editing::CutCopyOp);
+       void cut_copy_clear_one (AutomationLine&, Selection&, Editing::CutCopyOp);
+       void cut_copy_clear_objects_one (AutomationLine&, PointSelection&, Editing::CutCopyOp);
        bool paste_one (AutomationLine&, nframes_t, float times, Selection&, size_t nth);
        void reset_objects_one (AutomationLine&, PointSelection&);
 
index f167ea598f281dbf88c07960b06eec03f695d88e..48ddeb55d25c94fe2b96f33dba681083e4bb645b 100644 (file)
@@ -3106,8 +3106,6 @@ RubberbandSelectDrag::finished (GdkEvent* event, bool movement_occurred)
 
                _editor->begin_reversible_command (_("rubberband selection"));
 
-               cout << "RSD finished, selecting all within <fred>\n";
-
                if (grab_frame() < last_pointer_frame()) {
                        committed = _editor->select_all_within (grab_frame(), last_pointer_frame() - 1, y1, y2, _editor->track_views, op);
                } else {
index d1df63d187bd91a78b15614ce2efbac66f6a076b..9e50b67fac96a82e108992db493daa44e1ae2e87 100644 (file)
@@ -1299,17 +1299,16 @@ RouteTimeAxisView::find_next_region_boundary (nframes64_t pos, int32_t dir)
        return -1;
 }
 
-bool
+void
 RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
 {
        boost::shared_ptr<Playlist> what_we_got;
        boost::shared_ptr<Track> tr = track ();
        boost::shared_ptr<Playlist> playlist;
-       bool ret = false;
 
        if (tr == 0) {
                /* route is a bus, not a track */
-               return false;
+               return;
        }
 
        playlist = tr->playlist();
@@ -1339,7 +1338,6 @@ RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
                                 _session->add_command (*c);
                         }
                         _session->add_command (new StatefulDiffCommand (playlist));
-                       ret = true;
                }
                break;
        case Copy:
@@ -1359,12 +1357,9 @@ RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
                         }
                         _session->add_command (new StatefulDiffCommand (playlist));
                        what_we_got->release ();
-                       ret = true;
                }
                break;
        }
-
-       return ret;
 }
 
 bool
index 576c3533340d9986c053e6d0e9325aeb23d0bb35..6d832c8077a4661b8bf1a0d22289ea58f71612a8 100644 (file)
@@ -92,7 +92,7 @@ public:
        nframes64_t find_next_region_boundary (nframes64_t pos, int32_t dir);
 
        /* Editing operations */
-       bool cut_copy_clear (Selection&, Editing::CutCopyOp);
+       void cut_copy_clear (Selection&, Editing::CutCopyOp);
        bool paste (nframes_t, float times, Selection&, size_t nth);
 
        TimeAxisView::Children get_child_list();
index 93cb7eced3a4355072b1a1b100e7348e7d02df7a..dfdff2954e041f056741728c446e7fe37ab35522 100644 (file)
@@ -177,7 +177,7 @@ class TimeAxisView : public virtual AxisView, public PBD::Stateful
 
        /* editing operations */
 
-       virtual bool cut_copy_clear (Selection&, Editing::CutCopyOp) { return false; }
+       virtual void cut_copy_clear (Selection&, Editing::CutCopyOp) {}
        virtual bool paste (nframes_t, float /*times*/, Selection&, size_t /*nth*/) { return false; }
 
        virtual void set_selected_regionviews (RegionSelection&) {}