Clean up handling of track vs region automation a bit.

git-svn-id: svn://localhost/ardour2/branches/3.0@7544 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2010-08-05 13:35:43 +00:00
parent 355c079f10
commit e7a2b99f3d
8 changed files with 79 additions and 56 deletions

View file

@ -158,10 +158,11 @@ AutomationStreamView::set_automation_state (AutoState state)
if (region_views.empty()) { if (region_views.empty()) {
_pending_automation_state = state; _pending_automation_state = state;
} else { } else {
for (std::list<RegionView *>::iterator i = region_views.begin(); i != region_views.end(); ++i) { list<boost::shared_ptr<AutomationLine> > lines = get_lines ();
boost::shared_ptr<AutomationLine> line = dynamic_cast<AutomationRegionView*>(*i)->line();
if (line && line->the_list()) { for (list<boost::shared_ptr<AutomationLine> >::iterator i = lines.begin(); i != lines.end(); ++i) {
line->the_list()->set_automation_state (state); if ((*i)->the_list()) {
(*i)->the_list()->set_automation_state (state);
} }
} }
} }
@ -225,13 +226,12 @@ AutomationStreamView::automation_state () const
bool bool
AutomationStreamView::has_automation () const AutomationStreamView::has_automation () const
{ {
list<RegionView*>::const_iterator i = region_views.begin (); list<boost::shared_ptr<AutomationLine> > lines = get_lines ();
while (i != region_views.end()) {
AutomationRegionView* rv = static_cast<AutomationRegionView*> (*i); for (list<boost::shared_ptr<AutomationLine> >::iterator i = lines.begin(); i != lines.end(); ++i) {
if (rv->line() && rv->line()->npoints() > 0) { if ((*i)->npoints() > 0) {
return true; return true;
} }
++i;
} }
return false; return false;
@ -243,10 +243,10 @@ AutomationStreamView::has_automation () const
void void
AutomationStreamView::set_interpolation (AutomationList::InterpolationStyle s) AutomationStreamView::set_interpolation (AutomationList::InterpolationStyle s)
{ {
for (list<RegionView*>::const_iterator i = region_views.begin(); i != region_views.end(); ++i) { list<boost::shared_ptr<AutomationLine> > lines = get_lines ();
AutomationRegionView* arv = dynamic_cast<AutomationRegionView*> (*i);
assert (arv); for (list<boost::shared_ptr<AutomationLine> >::iterator i = lines.begin(); i != lines.end(); ++i) {
arv->line()->the_list()->set_interpolation (s); (*i)->the_list()->set_interpolation (s);
} }
} }
@ -267,10 +267,10 @@ AutomationStreamView::interpolation () const
void void
AutomationStreamView::clear () AutomationStreamView::clear ()
{ {
for (list<RegionView*>::iterator i = region_views.begin(); i != region_views.end(); ++i) { list<boost::shared_ptr<AutomationLine> > lines = get_lines ();
AutomationRegionView* arv = dynamic_cast<AutomationRegionView*> (*i);
assert (arv); for (list<boost::shared_ptr<AutomationLine> >::iterator i = lines.begin(); i != lines.end(); ++i) {
arv->line()->clear (); (*i)->clear ();
} }
} }
@ -287,9 +287,23 @@ AutomationStreamView::get_selectables (nframes_t start, nframes_t end, double bo
void void
AutomationStreamView::set_selected_points (PointSelection& ps) 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 ();
AutomationRegionView* arv = dynamic_cast<AutomationRegionView*> (*i);
assert (arv); for (list<boost::shared_ptr<AutomationLine> >::iterator i = lines.begin(); i != lines.end(); ++i) {
arv->line()->set_selected_points (ps); (*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);
lines.push_back (arv->line());
}
return lines;
}

View file

@ -64,6 +64,8 @@ class AutomationStreamView : public StreamView
void get_selectables (nframes_t, nframes_t, double, double, std::list<Selectable*> &); void get_selectables (nframes_t, nframes_t, double, double, std::list<Selectable*> &);
void set_selected_points (PointSelection &); void set_selected_points (PointSelection &);
std::list<boost::shared_ptr<AutomationLine> > get_lines () const;
private: private:
void setup_rec_box (); void setup_rec_box ();

View file

@ -407,8 +407,9 @@ AutomationTimeAxisView::set_height (uint32_t h)
TimeAxisView::set_height (h); TimeAxisView::set_height (h);
_base_rect->property_y2() = h; _base_rect->property_y2() = h;
if (_line) if (_line) {
_line->set_height(h); _line->set_height(h);
}
if (_view) { if (_view) {
_view->set_height(h); _view->set_height(h);
@ -480,11 +481,13 @@ AutomationTimeAxisView::set_samples_per_unit (double spu)
{ {
TimeAxisView::set_samples_per_unit (spu); TimeAxisView::set_samples_per_unit (spu);
if (_line) if (_line) {
_line->reset (); _line->reset ();
}
if (_view) if (_view) {
_view->set_samples_per_unit (spu); _view->set_samples_per_unit (spu);
}
} }
void void
@ -608,18 +611,26 @@ AutomationTimeAxisView::add_automation_event (ArdourCanvas::Item* /*item*/, GdkE
_session->set_dirty (); _session->set_dirty ();
} }
bool void
AutomationTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op) 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) AutomationTimeAxisView::cut_copy_clear_one (AutomationLine& line, Selection& selection, CutCopyOp op)
{ {
boost::shared_ptr<Evoral::ControlList> what_we_got; boost::shared_ptr<Evoral::ControlList> what_we_got;
boost::shared_ptr<AutomationList> alist (line.the_list()); boost::shared_ptr<AutomationList> alist (line.the_list());
bool ret = false;
XMLNode &before = alist->get_state(); 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) { if ((what_we_got = alist->cut (selection.time.front().start, selection.time.front().end)) != 0) {
_editor.get_cut_buffer().add (what_we_got); _editor.get_cut_buffer().add (what_we_got);
_session->add_command(new MementoCommand<AutomationList>(*alist.get(), &before, &alist->get_state())); _session->add_command(new MementoCommand<AutomationList>(*alist.get(), &before, &alist->get_state()));
ret = true;
} }
break; break;
case Copy: case Copy:
@ -640,7 +650,6 @@ AutomationTimeAxisView::cut_copy_clear_one (AutomationLine& line, Selection& sel
case Clear: case Clear:
if ((what_we_got = alist->cut (selection.time.front().start, selection.time.front().end)) != 0) { 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())); _session->add_command(new MementoCommand<AutomationList>(*alist.get(), &before, &alist->get_state()));
ret = true;
} }
break; break;
} }
@ -654,8 +663,6 @@ AutomationTimeAxisView::cut_copy_clear_one (AutomationLine& line, Selection& sel
(*x)->value = val; (*x)->value = val;
} }
} }
return ret;
} }
void void
@ -681,18 +688,26 @@ AutomationTimeAxisView::reset_objects_one (AutomationLine& line, PointSelection&
} }
} }
bool void
AutomationTimeAxisView::cut_copy_clear_objects (PointSelection& selection, CutCopyOp op) 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) AutomationTimeAxisView::cut_copy_clear_objects_one (AutomationLine& line, PointSelection& selection, CutCopyOp op)
{ {
boost::shared_ptr<Evoral::ControlList> what_we_got; boost::shared_ptr<Evoral::ControlList> what_we_got;
boost::shared_ptr<AutomationList> alist(line.the_list()); boost::shared_ptr<AutomationList> alist(line.the_list());
bool ret = false;
XMLNode &before = alist->get_state(); 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) { if ((what_we_got = alist->cut ((*i).start, (*i).end)) != 0) {
_editor.get_cut_buffer().add (what_we_got); _editor.get_cut_buffer().add (what_we_got);
_session->add_command (new MementoCommand<AutomationList>(*alist.get(), new XMLNode (before), &alist->get_state())); _session->add_command (new MementoCommand<AutomationList>(*alist.get(), new XMLNode (before), &alist->get_state()));
ret = true;
} }
break; break;
case Copy: case Copy:
@ -719,7 +733,6 @@ AutomationTimeAxisView::cut_copy_clear_objects_one (AutomationLine& line, PointS
case Clear: case Clear:
if ((what_we_got = alist->cut ((*i).start, (*i).end)) != 0) { 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())); _session->add_command (new MementoCommand<AutomationList>(*alist.get(), new XMLNode (before), &alist->get_state()));
ret = true;
} }
break; break;
} }
@ -727,6 +740,8 @@ AutomationTimeAxisView::cut_copy_clear_objects_one (AutomationLine& line, PointS
delete &before; delete &before;
cout << "CCC objects " << what_we_got->size() << "\n";
if (what_we_got) { if (what_we_got) {
for (AutomationList::iterator x = what_we_got->begin(); x != what_we_got->end(); ++x) { for (AutomationList::iterator x = what_we_got->begin(); x != what_we_got->end(); ++x) {
double when = (*x)->when; double when = (*x)->when;
@ -736,8 +751,6 @@ AutomationTimeAxisView::cut_copy_clear_objects_one (AutomationLine& line, PointS
(*x)->value = val; (*x)->value = val;
} }
} }
return ret;
} }
bool bool
@ -825,8 +838,9 @@ AutomationTimeAxisView::get_selectables (nframes_t start, nframes_t end, double
void void
AutomationTimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& result) AutomationTimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& result)
{ {
if (_line) if (_line) {
_line->get_inverted_selectables (sel, result); _line->get_inverted_selectables (sel, result);
}
} }
void void

View file

@ -86,8 +86,8 @@ class AutomationTimeAxisView : public TimeAxisView {
/* editing operations */ /* editing operations */
bool cut_copy_clear (Selection&, Editing::CutCopyOp); void cut_copy_clear (Selection&, Editing::CutCopyOp);
bool cut_copy_clear_objects (PointSelection&, Editing::CutCopyOp); void cut_copy_clear_objects (PointSelection&, Editing::CutCopyOp);
bool paste (nframes_t, float times, Selection&, size_t nth); bool paste (nframes_t, float times, Selection&, size_t nth);
void reset_objects (PointSelection&); void reset_objects (PointSelection&);
@ -146,8 +146,8 @@ class AutomationTimeAxisView : public TimeAxisView {
void build_display_menu (); void build_display_menu ();
bool cut_copy_clear_one (AutomationLine&, Selection&, Editing::CutCopyOp); void cut_copy_clear_one (AutomationLine&, Selection&, Editing::CutCopyOp);
bool cut_copy_clear_objects_one (AutomationLine&, PointSelection&, Editing::CutCopyOp); void cut_copy_clear_objects_one (AutomationLine&, PointSelection&, Editing::CutCopyOp);
bool paste_one (AutomationLine&, nframes_t, float times, Selection&, size_t nth); bool paste_one (AutomationLine&, nframes_t, float times, Selection&, size_t nth);
void reset_objects_one (AutomationLine&, PointSelection&); void reset_objects_one (AutomationLine&, PointSelection&);

View file

@ -3106,8 +3106,6 @@ RubberbandSelectDrag::finished (GdkEvent* event, bool movement_occurred)
_editor->begin_reversible_command (_("rubberband selection")); _editor->begin_reversible_command (_("rubberband selection"));
cout << "RSD finished, selecting all within <fred>\n";
if (grab_frame() < last_pointer_frame()) { if (grab_frame() < last_pointer_frame()) {
committed = _editor->select_all_within (grab_frame(), last_pointer_frame() - 1, y1, y2, _editor->track_views, op); committed = _editor->select_all_within (grab_frame(), last_pointer_frame() - 1, y1, y2, _editor->track_views, op);
} else { } else {

View file

@ -1299,17 +1299,16 @@ RouteTimeAxisView::find_next_region_boundary (nframes64_t pos, int32_t dir)
return -1; return -1;
} }
bool void
RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op) RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
{ {
boost::shared_ptr<Playlist> what_we_got; boost::shared_ptr<Playlist> what_we_got;
boost::shared_ptr<Track> tr = track (); boost::shared_ptr<Track> tr = track ();
boost::shared_ptr<Playlist> playlist; boost::shared_ptr<Playlist> playlist;
bool ret = false;
if (tr == 0) { if (tr == 0) {
/* route is a bus, not a track */ /* route is a bus, not a track */
return false; return;
} }
playlist = tr->playlist(); playlist = tr->playlist();
@ -1339,7 +1338,6 @@ RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
_session->add_command (*c); _session->add_command (*c);
} }
_session->add_command (new StatefulDiffCommand (playlist)); _session->add_command (new StatefulDiffCommand (playlist));
ret = true;
} }
break; break;
case Copy: case Copy:
@ -1359,12 +1357,9 @@ RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
} }
_session->add_command (new StatefulDiffCommand (playlist)); _session->add_command (new StatefulDiffCommand (playlist));
what_we_got->release (); what_we_got->release ();
ret = true;
} }
break; break;
} }
return ret;
} }
bool bool

View file

@ -92,7 +92,7 @@ public:
nframes64_t find_next_region_boundary (nframes64_t pos, int32_t dir); nframes64_t find_next_region_boundary (nframes64_t pos, int32_t dir);
/* Editing operations */ /* 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); bool paste (nframes_t, float times, Selection&, size_t nth);
TimeAxisView::Children get_child_list(); TimeAxisView::Children get_child_list();

View file

@ -177,7 +177,7 @@ class TimeAxisView : public virtual AxisView, public PBD::Stateful
/* editing operations */ /* 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 bool paste (nframes_t, float /*times*/, Selection&, size_t /*nth*/) { return false; }
virtual void set_selected_regionviews (RegionSelection&) {} virtual void set_selected_regionviews (RegionSelection&) {}