diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2008-01-26 02:57:10 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2008-01-26 02:57:10 +0000 |
commit | 1e51f099fd7baef957204d46bee302908d65de6b (patch) | |
tree | efc8fbf95a139ee90508ad6f6ea17ab652457c5a /gtk2_ardour/editor_ops.cc | |
parent | 315dd3d7705d314b935a7a35007347a41e0f9bfd (diff) |
first pass attempt at tab-to-transient (to be improved)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@2970 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/editor_ops.cc')
-rw-r--r-- | gtk2_ardour/editor_ops.cc | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index da6774c560..2755fcc764 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -5127,3 +5127,55 @@ Editor::split_region_at_points (boost::shared_ptr<Region> r, vector<nframes64_t> session->add_command (new MementoCommand<Playlist>(*pl, &before, &after)); } +void +Editor::tab_to_transient (bool forward) +{ + + vector<nframes64_t> positions; + + if (!session) { + return; + } + + ExclusiveRegionSelection esr (*this, entered_regionview); + + if (selection->regions.empty()) { + return; + } + + boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion> (selection->regions.front()->region()); + + if (!ar) { + return; + } + + ar->get_transients (positions); + nframes64_t pos = session->audible_frame (); + + if (forward) { + vector<nframes64_t>::iterator x; + + for (x = positions.begin(); x != positions.end(); ++x) { + if ((*x) > pos) { + break; + } + } + + if (x != positions.end ()) { + session->request_locate (*x); + } + + } else { + vector<nframes64_t>::reverse_iterator x; + + for (x = positions.rbegin(); x != positions.rend(); ++x) { + if ((*x) < pos) { + break; + } + } + + if (x != positions.rend ()) { + session->request_locate (*x); + } + } +} |