add "remove gaps" editing operation

Like the libardour functionality it uses, this likely needs work to properly deal with the
intended cross-track workflow
This commit is contained in:
Paul Davis 2021-05-28 12:36:17 -06:00
parent fecce7c333
commit d0f94dd63d
4 changed files with 61 additions and 0 deletions

View File

@ -414,6 +414,7 @@
<separator/>
<menuitem action='insert-time'/>
<menuitem action='remove-time'/>
<menuitem action='remove-gaps'/>
<menuitem action="move-selected-tracks-up"/>
<menuitem action="move-selected-tracks-down"/>
<menu action='TrackHeightMenu'>

View File

@ -579,6 +579,7 @@ public:
void split_regions_at (ARDOUR::MusicSample, RegionSelection&);
void split_region_at_points (boost::shared_ptr<ARDOUR::Region>, ARDOUR::AnalysisFeatureList&, bool can_ferret, bool select_new = false);
RegionSelection get_regions_from_selection_and_mouse (samplepos_t);
void remove_gaps ();
void mouse_add_new_tempo_event (samplepos_t where);
void mouse_add_new_meter_event (samplepos_t where);

View File

@ -455,6 +455,10 @@ Editor::register_actions ()
ActionManager::session_sensitive_actions.push_back (act);
ActionManager::track_selection_sensitive_actions.push_back (act);
act = reg_sens (editor_actions, "remove-gaps", _("Remove Gaps"), (sigc::mem_fun(*this, &Editor::remove_gaps)));
ActionManager::track_selection_sensitive_actions.push_back (act);
ActionManager::session_sensitive_actions.push_back (act);
act = reg_sens (editor_actions, "toggle-track-active", _("Toggle Active"), (sigc::mem_fun(*this, &Editor::toggle_tracks_active)));
ActionManager::route_selection_sensitive_actions.push_back (act);

View File

@ -8922,3 +8922,58 @@ Editor::make_region_markers_global (bool as_cd_marker)
commit_reversible_command ();
}
}
void
Editor::remove_gaps ()
{
bool in_command = false;
TrackViewList ts = selection->tracks.filter_to_unique_playlists ();
bool all_playlists = false;
for (TrackSelection::iterator x = ts.begin(); x != ts.end(); ++x) {
/* don't operate on any playlist more than once, which could
* happen if "all playlists" is enabled, but there is more
* than 1 track using playlists "from" a given track.
*/
set<boost::shared_ptr<Playlist> > pl;
if (all_playlists) {
RouteTimeAxisView* rtav = dynamic_cast<RouteTimeAxisView*> (*x);
if (rtav && rtav->track ()) {
vector<boost::shared_ptr<Playlist> > all = _session->playlists()->playlists_for_track (rtav->track ());
for (vector<boost::shared_ptr<Playlist> >::iterator p = all.begin(); p != all.end(); ++p) {
pl.insert (*p);
}
}
} else {
if ((*x)->playlist ()) {
pl.insert ((*x)->playlist ());
}
}
for (set<boost::shared_ptr<Playlist> >::iterator i = pl.begin(); i != pl.end(); ++i) {
(*i)->clear_changes ();
(*i)->clear_owned_changes ();
if (!in_command) {
begin_reversible_command (_("remove gaps"));
in_command = true;
}
(*i)->remove_gaps (24000, 4410);
vector<Command*> cmds;
(*i)->rdiff (cmds);
_session->add_commands (cmds);
_session->add_command (new StatefulDiffCommand (*i));
}
}
if (in_command) {
commit_reversible_command ();
}
}