diff options
author | Carl Hetherington <carl@carlh.net> | 2012-06-09 00:36:21 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2012-06-09 00:36:21 +0000 |
commit | 0ac73d8513dff0566b290b49127776b28859e69a (patch) | |
tree | 79b61e9a660ccf814ad5a3469be4a8f6563c6a2a /gtk2_ardour/editor_mouse.cc | |
parent | f8401337683fece85b16c14e6de8b4250e0e06c1 (diff) |
Extend a previous region if we click in a MIDI automation lane where there is no region (#4155).
git-svn-id: svn://localhost/ardour2/branches/3.0@12622 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/editor_mouse.cc')
-rw-r--r-- | gtk2_ardour/editor_mouse.cc | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index 1ce02457fc..011374f951 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -1003,8 +1003,23 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT AutomationTimeAxisView* atv = dynamic_cast<AutomationTimeAxisView*> (clicked_axisview); assert (atv); if (parent && dynamic_cast<MidiTimeAxisView*> (parent) && atv->show_regions ()) { - /* create a MIDI region so that we have somewhere to put automation */ - _drags->set (new RegionCreateDrag (this, item, parent), event); + + RouteTimeAxisView* p = dynamic_cast<RouteTimeAxisView*> (parent); + assert (p); + boost::shared_ptr<Playlist> pl = p->track()->playlist (); + if (pl->n_regions() == 0) { + /* Parent has no regions; create one so that we have somewhere to put automation */ + _drags->set (new RegionCreateDrag (this, item, parent), event); + } else { + /* See if there's a region before the click that we can extend, and extend it if so */ + framepos_t const t = event_frame (event); + boost::shared_ptr<Region> prev = pl->find_next_region (t, End, -1); + if (!prev) { + _drags->set (new RegionCreateDrag (this, item, parent), event); + } else { + prev->set_length (t - prev->position ()); + } + } } else { /* rubberband drag to select automation points */ _drags->set (new EditorRubberbandSelectDrag (this, item), event); |