X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fautomation_streamview.cc;h=883f0449b3368f0f23d678a0099a24faeece9e1a;hb=b78d036aa056af0ef4f5821c45dae5f70bc69231;hp=6beb439b1115de96b8f7b403ec56e099b0597ea9;hpb=e7a2b99f3d4f7afe73a30ac85e770e228785c1be;p=ardour.git diff --git a/gtk2_ardour/automation_streamview.cc b/gtk2_ardour/automation_streamview.cc index 6beb439b11..883f0449b3 100644 --- a/gtk2_ardour/automation_streamview.cc +++ b/gtk2_ardour/automation_streamview.cc @@ -24,12 +24,8 @@ #include -#include "ardour/midi_playlist.h" #include "ardour/midi_region.h" #include "ardour/midi_source.h" -#include "ardour/midi_diskstream.h" -#include "ardour/midi_track.h" -#include "ardour/smf_source.h" #include "ardour/region_factory.h" #include "automation_streamview.h" @@ -79,8 +75,9 @@ AutomationStreamView::add_region_view_internal (boost::shared_ptr region if (wfd) { boost::shared_ptr mr = boost::dynamic_pointer_cast(region); - if (mr) + if (mr) { mr->midi_source()->load_model(); + } } const boost::shared_ptr control = boost::dynamic_pointer_cast ( @@ -151,9 +148,7 @@ AutomationStreamView::display_region(AutomationRegionView* region_view) void AutomationStreamView::set_automation_state (AutoState state) { - /* XXX: not sure if this is right, but for now the automation state is basically held by - the regions' AutomationLists. Each region is always set to have the same AutoState. - */ + /* Setting the automation state for this view sets the state of all regions' lists to the same thing */ if (region_views.empty()) { _pending_automation_state = state; @@ -274,13 +269,20 @@ AutomationStreamView::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 (nframes_t start, nframes_t end, double botfrac, double topfrac, list& results) +AutomationStreamView::get_selectables (framepos_t start, framepos_t end, double botfrac, double topfrac, list& results) { for (list::iterator i = region_views.begin(); i != region_views.end(); ++i) { AutomationRegionView* arv = dynamic_cast (*i); assert (arv); - arv->line()->get_selectables (start - (*i)->region()->position(), end - (*i)->region()->position(), botfrac, topfrac, results); + arv->line()->get_selectables (start, end, botfrac, topfrac, results); } } @@ -307,3 +309,46 @@ AutomationStreamView::get_lines () const 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 +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 (); + } + + region_views.sort (RegionPositionSorter ()); + + list::const_iterator prev = region_views.begin (); + + for (list::const_iterator i = region_views.begin(); i != region_views.end(); ++i) { + if ((*i)->region()->position() > pos) { + break; + } + prev = i; + } + + boost::shared_ptr 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 (); + } + + AutomationRegionView* arv = dynamic_cast (*prev); + assert (arv); + + return arv->line (); +}