+void MWindow::move_group(EDL *group, Track *first_track, double position)
+{
+ undo->update_undo_before();
+ ArrayList<Edit *>edits;
+ edl->tracks->get_selected_edits(&edits);
+ edl->delete_edits(&edits, 0);
+ Track *src = group->tracks->first;
+ for( Track *track=first_track; track && src; track=track->next ) {
+ if( !track->record ) continue;
+ int64_t pos = track->to_units(position, 0);
+ for( Edit *edit=src->edits->first; edit; edit=edit->next ) {
+ if( edit->silence() ) continue;
+ int64_t start = pos + edit->startproject;
+ int64_t end = start + edit->length;
+ track->edits->clear(start, end);
+ Edit *dst = track->edits->insert_new_edit(start);
+ dst->copy_from(edit);
+ dst->startproject = start;
+ dst->is_selected = 1;
+ while( (dst=dst->next) != 0 )
+ dst->startproject += edit->length;
+ }
+ if( edl->session->autos_follow_edits ) {
+ for( int i=0; i<AUTOMATION_TOTAL; ++i ) {
+ Autos *src_autos = src->automation->autos[i];
+ if( !src_autos ) continue;
+ Autos *autos = track->automation->autos[i];
+ for( Auto *aut0=src_autos->first; aut0; aut0=aut0->next ) {
+ int64_t position = pos + aut0->position;
+ autos->insert_auto(position, aut0);
+ }
+ }
+ }
+ if( edl->session->plugins_follow_edits ) {
+ for( int i=0; i<src->plugin_set.size(); ++i ) {
+ PluginSet *plugin_set = src->plugin_set[i];
+ if( !plugin_set ) continue;
+ while( i >= track->plugin_set.size() )
+ track->plugin_set.append(0);
+ PluginSet *dst_plugin_set = track->plugin_set[i];
+ if( !dst_plugin_set ) {
+ dst_plugin_set = new PluginSet(edl, track);
+ track->plugin_set[i] = dst_plugin_set;
+ }
+ Plugin *plugin = (Plugin *)plugin_set->first;
+ for( ; plugin; plugin=(Plugin *)plugin->next ) {
+ int64_t start = pos + plugin->startproject;
+ int64_t end = start + plugin->length;
+ dst_plugin_set->clear(start, end, 1);
+ Plugin *dst = dst_plugin_set->insert_plugin(
+ plugin->title, start, end-start,
+ plugin->plugin_type, &plugin->shared_location,
+ (KeyFrame*)plugin->keyframes->default_auto, 0);
+ KeyFrame *keyframe = (KeyFrame*)plugin->keyframes->first;
+ for( ; keyframe; keyframe=(KeyFrame*)keyframe->next ) {
+ int64_t position = pos + keyframe->position;
+ dst->keyframes->insert_auto(position, keyframe);
+ }
+ }
+ }
+ }
+ track->optimize();
+ src = src->next;
+ }
+ edl->tracks->clear_selected_edits();
+
+ save_backup();
+ undo->update_undo_after(_("move group"), LOAD_ALL);
+ restart_brender();
+ cwindow->refresh_frame(CHANGE_EDL);
+
+ update_plugin_guis();
+ gui->update(1, NORMAL_DRAW, 1, 0, 0, 0, 0);
+}
+