Support cut / copy / paste of MIDI automation.

git-svn-id: svn://localhost/ardour2/branches/3.0@7545 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2010-08-05 13:36:38 +00:00
parent e7a2b99f3d
commit 5e3ca4db5c
16 changed files with 169 additions and 67 deletions

View file

@ -274,13 +274,16 @@ AutomationStreamView::clear ()
}
}
/** @param start Start position in session frames.
* @param end End position in session frames.
*/
void
AutomationStreamView::get_selectables (nframes_t start, nframes_t end, double botfrac, double topfrac, list<Selectable*>& results)
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 - (*i)->region()->position(), end - (*i)->region()->position(), botfrac, topfrac, results);
arv->line()->get_selectables (start, end, botfrac, topfrac, results);
}
}
@ -307,3 +310,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<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 ();
}