+/** Our parent AutomationTimeAxisView calls this when the user requests a particular
+ * InterpolationStyle; tell the AutomationLists in our regions.
+ */
+void
+AutomationStreamView::set_interpolation (AutomationList::InterpolationStyle 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);
+ }
+}
+
+AutomationList::InterpolationStyle
+AutomationStreamView::interpolation () const
+{
+ if (region_views.empty()) {
+ return AutomationList::Linear;
+ }
+
+ AutomationRegionView* v = dynamic_cast<AutomationRegionView*> (region_views.front());
+ assert (v);
+
+ return v->line()->the_list()->interpolation ();
+}
+
+/** Clear all automation displayed in this view */
+void
+AutomationStreamView::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 ();
+ }
+}
+
+/** @param start Start position in session frames.
+ * @param end End position in session frames.
+ * @param bot Bottom position expressed as a fraction of track height where 0 is the bottom of the track.
+ * @param top Top position expressed as a fraction of track height where 0 is the bottom of the track.
+ * NOTE: this y system is different to that for the StreamView method that this overrides, which is a little
+ * confusing.
+ */
+void
+AutomationStreamView::get_selectables (framepos_t start, framepos_t end, double botfrac, double topfrac, list<Selectable*>& results)
+{
+ for (list<RegionView*>::iterator i = region_views.begin(); i != region_views.end(); ++i) {
+ AutomationRegionView* arv = dynamic_cast<AutomationRegionView*> (*i);
+ assert (arv);
+ arv->line()->get_selectables (start, end, botfrac, topfrac, results);
+ }
+}
+
+void
+AutomationStreamView::set_selected_points (PointSelection& ps)
+{
+ 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);
+ lines.push_back (arv->line());
+ }
+
+ return lines;
+}
+
+struct RegionPositionSorter {
+ bool operator() (RegionView* a, RegionView* b) {
+ return a->region()->position() < b->region()->position();
+ }
+};
+
+
+/** @param pos Position, in session frames.
+ * @return AutomationLine to paste to for that position, or 0 if there is none appropriate.
+ */
+boost::shared_ptr<AutomationLine>
+AutomationStreamView::paste_line (framepos_t pos)
+{
+ /* XXX: not sure how best to pick this; for now, just use the last region which starts before pos */
+
+ if (region_views.empty()) {
+ return boost::shared_ptr<AutomationLine> ();
+ }
+
+ region_views.sort (RegionPositionSorter ());
+
+ list<RegionView*>::const_iterator prev = region_views.begin ();
+
+ for (list<RegionView*>::const_iterator i = region_views.begin(); i != region_views.end(); ++i) {
+ if ((*i)->region()->position() > pos) {
+ break;
+ }
+ prev = i;
+ }
+
+ boost::shared_ptr<Region> r = (*prev)->region ();
+
+ /* If *prev doesn't cover pos, it's no good */
+ if (r->position() > pos || ((r->position() + r->length()) < pos)) {
+ return boost::shared_ptr<AutomationLine> ();
+ }
+
+ AutomationRegionView* arv = dynamic_cast<AutomationRegionView*> (*prev);
+ assert (arv);
+
+ return arv->line ();
+}