3 #include "awindowgui.h"
11 #include "cwindowgui.h"
13 #include "edlsession.h"
17 #include "levelwindow.h"
18 #include "localsession.h"
19 #include "mainclock.h"
20 #include "mainindexes.h"
22 #include "mainsession.h"
25 #include "mwindowgui.h"
28 #include "playbackengine.h"
29 #include "pluginset.h"
30 #include "recordlabel.h"
31 #include "samplescroll.h"
32 #include "trackcanvas.h"
34 #include "trackscroll.h"
36 #include "transition.h"
37 #include "transportque.h"
39 #include "vplayback.h"
41 #include "vwindowgui.h"
53 void MWindow::add_audio_track_entry(int above, Track *dst)
55 undo->update_undo_before("add track", LOAD_ALL);
56 add_audio_track(above, dst);
58 undo->update_undo_after();
61 gui->get_scrollbars();
63 gui->patchbay->update();
66 gui->canvas->activate();
67 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
73 void MWindow::add_video_track_entry(Track *dst)
75 undo->update_undo_before(_("add track"), LOAD_ALL);
76 add_video_track(1, dst);
77 undo->update_undo_after();
80 gui->get_scrollbars();
82 gui->patchbay->update();
85 gui->canvas->activate();
86 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
94 int MWindow::add_audio_track(int above, Track *dst)
96 edl->tracks->add_audio_track(above, dst);
97 edl->tracks->update_y_pixels(theme);
102 int MWindow::add_video_track(int above, Track *dst)
104 edl->tracks->add_video_track(above, dst);
105 edl->tracks->update_y_pixels(theme);
114 void MWindow::asset_to_size()
116 if(session->drag_assets->total &&
117 session->drag_assets->values[0]->video_data)
121 w = session->drag_assets->values[0]->width;
122 h = session->drag_assets->values[0]->height;
124 undo->update_undo_before(_("asset to size"), LOAD_ALL);
125 edl->session->output_w = w;
126 edl->session->output_h = h;
129 undo->update_undo_after();
131 sync_parameters(CHANGE_ALL);
137 void MWindow::clear_entry()
139 undo->update_undo_before(_("clear"), LOAD_EDITS | LOAD_TIMEBAR);
144 undo->update_undo_after();
147 update_plugin_guis();
148 gui->update(1, 2, 1, 1, 1, 1, 0);
149 cwindow->update(1, 0, 0, 0, 1);
150 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
156 void MWindow::clear(int clear_handle)
158 double start = edl->local_session->get_selectionstart();
159 double end = edl->local_session->get_selectionend();
160 if(clear_handle || !EQUIV(start, end))
164 edl->session->labels_follow_edits,
165 edl->session->plugins_follow_edits);
169 void MWindow::clear_automation()
171 undo->update_undo_before(_("clear keyframes"), LOAD_AUTOMATION);
172 edl->tracks->clear_automation(edl->local_session->get_selectionstart(),
173 edl->local_session->get_selectionend());
175 undo->update_undo_after();
178 update_plugin_guis();
179 gui->canvas->draw_overlays();
180 gui->canvas->flash();
181 sync_parameters(CHANGE_PARAMS);
182 gui->patchbay->update();
183 cwindow->update(1, 0, 0);
186 int MWindow::clear_default_keyframe()
188 undo->update_undo_before(_("clear default keyframe"), LOAD_AUTOMATION);
189 edl->tracks->clear_default_keyframe();
191 undo->update_undo_after();
194 gui->canvas->draw_overlays();
195 gui->canvas->flash();
196 sync_parameters(CHANGE_PARAMS);
197 gui->patchbay->update();
198 cwindow->update(1, 0, 0);
203 void MWindow::clear_labels()
205 undo->update_undo_before(_("clear"), LOAD_TIMEBAR);
206 clear_labels(edl->local_session->get_selectionstart(),
207 edl->local_session->get_selectionend());
208 undo->update_undo_after();
210 gui->timebar->update();
211 cwindow->update(0, 0, 0, 0, 1);
215 int MWindow::clear_labels(double start, double end)
217 edl->labels->clear(start, end, 0);
221 void MWindow::concatenate_tracks()
223 undo->update_undo_before(_("concatenate tracks"), LOAD_EDITS);
224 edl->tracks->concatenate_tracks(edl->session->plugins_follow_edits);
226 undo->update_undo_after();
229 gui->update(1, 1, 0, 0, 1, 0, 0);
230 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
239 copy(edl->local_session->get_selectionstart(),
240 edl->local_session->get_selectionend());
243 int MWindow::copy(double start, double end)
245 if(start == end) return 1;
247 //printf("MWindow::copy 1\n");
249 //printf("MWindow::copy 1\n");
259 //printf("MWindow::copy 1\n");
261 // File is now terminated and rewound
263 //printf("MWindow::copy 1\n");
264 gui->get_clipboard()->to_clipboard(file.string, strlen(file.string), SECONDARY_SELECTION);
265 //printf("MWindow::copy\n%s\n", file.string);
266 //printf("MWindow::copy 2\n");
271 int MWindow::copy_automation()
274 edl->tracks->copy_automation(edl->local_session->get_selectionstart(),
275 edl->local_session->get_selectionend(),
279 gui->get_clipboard()->to_clipboard(file.string,
281 SECONDARY_SELECTION);
285 int MWindow::copy_default_keyframe()
288 edl->tracks->copy_default_keyframe(&file);
289 gui->get_clipboard()->to_clipboard(file.string,
291 SECONDARY_SELECTION);
296 // Uses cropping coordinates in edl session to crop and translate video.
297 // We modify the projector since camera automation depends on the track size.
298 void MWindow::crop_video()
300 undo->update_undo_before(_("crop"), LOAD_ALL);
303 float old_projector_x = (float)edl->session->output_w / 2;
304 float old_projector_y = (float)edl->session->output_h / 2;
305 float new_projector_x = (float)(edl->session->crop_x1 + edl->session->crop_x2) / 2;
306 float new_projector_y = (float)(edl->session->crop_y1 + edl->session->crop_y2) / 2;
307 float projector_offset_x = -(new_projector_x - old_projector_x);
308 float projector_offset_y = -(new_projector_y - old_projector_y);
310 edl->tracks->translate_projector(projector_offset_x, projector_offset_y);
312 edl->session->output_w = edl->session->crop_x2 - edl->session->crop_x1;
313 edl->session->output_h = edl->session->crop_y2 - edl->session->crop_y1;
314 edl->session->crop_x1 = 0;
315 edl->session->crop_y1 = 0;
316 edl->session->crop_x2 = edl->session->output_w;
317 edl->session->crop_y2 = edl->session->output_h;
318 undo->update_undo_after();
321 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
330 undo->update_undo_before(_("cut"), LOAD_EDITS | LOAD_TIMEBAR);
332 double start = edl->local_session->get_selectionstart();
333 double end = edl->local_session->get_selectionend();
338 edl->session->labels_follow_edits,
339 edl->session->plugins_follow_edits);
344 undo->update_undo_after();
347 update_plugin_guis();
348 gui->update(1, 2, 1, 1, 1, 1, 0);
349 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
355 int MWindow::cut_automation()
357 undo->update_undo_before(_("cut keyframes"), LOAD_AUTOMATION);
361 edl->tracks->clear_automation(edl->local_session->get_selectionstart(),
362 edl->local_session->get_selectionend());
364 undo->update_undo_after();
368 update_plugin_guis();
369 gui->canvas->draw_overlays();
370 gui->canvas->flash();
371 sync_parameters(CHANGE_PARAMS);
372 gui->patchbay->update();
373 cwindow->update(1, 0, 0);
377 int MWindow::cut_default_keyframe()
379 undo->update_undo_before(_("cut default keyframe"), LOAD_AUTOMATION);
381 copy_default_keyframe();
382 edl->tracks->clear_default_keyframe();
383 undo->update_undo_after();
386 gui->canvas->draw_overlays();
387 gui->canvas->flash();
388 sync_parameters(CHANGE_PARAMS);
389 gui->patchbay->update();
390 cwindow->update(1, 0, 0);
397 void MWindow::delete_inpoint()
399 edl->local_session->in_point = -1;
403 void MWindow::delete_outpoint()
405 edl->local_session->out_point = -1;
409 void MWindow::delete_track()
411 undo->update_undo_before(_("delete track"), LOAD_ALL);
412 edl->tracks->delete_track();
413 undo->update_undo_after();
417 update_plugin_states();
418 gui->update(1, 1, 1, 0, 1, 0, 0);
419 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
425 void MWindow::delete_tracks()
427 undo->update_undo_before(_("delete tracks"), LOAD_ALL);
428 edl->tracks->delete_tracks();
429 undo->update_undo_after();
433 update_plugin_states();
434 gui->update(1, 1, 1, 0, 1, 0, 0);
435 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
439 //printf("MWindow::delete_tracks 5\n");
442 void MWindow::delete_track(Track *track)
444 undo->update_undo_before(_("delete track"), LOAD_ALL);
445 edl->tracks->delete_track(track);
446 undo->update_undo_after();
449 update_plugin_states();
450 gui->update(1, 1, 1, 0, 1, 0, 0);
451 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
458 void MWindow::detach_transition(Transition *transition)
460 undo->update_undo_before(_("detach transition"), LOAD_ALL);
461 hide_plugin(transition, 1);
462 int is_video = (transition->edit->track->data_type == TRACK_VIDEO);
463 transition->edit->detach_transition();
465 undo->update_undo_after();
467 if(is_video) restart_brender();
475 sync_parameters(CHANGE_EDL);
482 // Insert data from clipboard
483 void MWindow::insert(double position,
489 // For clipboard pasting make the new edl use a separate session
490 // from the master EDL. Then it can be resampled to the master rates.
491 // For splice, overwrite, and dragging need same session to get the assets.
493 ArrayList<EDL*> new_edls;
494 uint32_t load_flags = LOAD_ALL;
496 new_edls.append(&edl);
497 edl.create_objects();
501 if(parent_edl) load_flags &= ~LOAD_SESSION;
502 if(!edl.session->autos_follow_edits) load_flags &= ~LOAD_AUTOMATION;
503 if(!edl.session->labels_follow_edits) load_flags &= ~LOAD_TIMEBAR;
504 edl.load_xml(plugindb, file, load_flags);
510 paste_edls(&new_edls,
517 // printf("MWindow::insert 5 %f %f\n",
518 // vwindow->edl->local_session->in_point,
519 // vwindow->edl->local_session->out_point);
520 new_edls.remove_all();
521 //printf("MWindow::insert 6 %p\n", vwindow->get_edl());
524 void MWindow::insert_effects_canvas(double start,
527 Track *dest_track = session->track_highlighted;
528 if(!dest_track) return;
530 undo->update_undo_before(_("insert effect"), LOAD_EDITS | LOAD_PATCHES);
532 for(int i = 0; i < session->drag_pluginservers->total; i++)
534 PluginServer *plugin = session->drag_pluginservers->values[i];
536 insert_effect(plugin->title,
539 i == 0 ? session->pluginset_highlighted : 0,
546 undo->update_undo_after();
548 sync_parameters(CHANGE_EDL);
549 // GUI updated in TrackCanvas, after current_operations are reset
552 void MWindow::insert_effects_cwindow(Track *dest_track)
554 if(!dest_track) return;
556 undo->update_undo_before(_("insert effect"), LOAD_EDITS | LOAD_PATCHES);
559 double length = dest_track->get_length();
561 if(edl->local_session->get_selectionend() >
562 edl->local_session->get_selectionstart())
564 start = edl->local_session->get_selectionstart();
565 length = edl->local_session->get_selectionend() -
566 edl->local_session->get_selectionstart();
569 for(int i = 0; i < session->drag_pluginservers->total; i++)
571 PluginServer *plugin = session->drag_pluginservers->values[i];
574 insert_effect(plugin->title,
584 undo->update_undo_after();
586 sync_parameters(CHANGE_EDL);
598 void MWindow::insert_effect(char *title,
599 SharedLocation *shared_location,
601 PluginSet *plugin_set,
606 KeyFrame *default_keyframe = 0;
607 PluginServer *server = 0;
614 // Get default keyframe
615 if(plugin_type == PLUGIN_STANDALONE)
617 default_keyframe = new KeyFrame;
618 server = new PluginServer(*scan_plugindb(title));
620 server->open_plugin(0, preferences, edl, 0, -1);
621 server->save_data(default_keyframe);
626 // Insert plugin object
627 track->insert_effect(title,
638 if(plugin_type == PLUGIN_STANDALONE)
640 server->close_plugin();
642 delete default_keyframe;
646 int MWindow::modify_edithandles()
648 undo->update_undo_before(_("drag handle"), LOAD_EDITS | LOAD_TIMEBAR);
654 edl->modify_edithandles(session->drag_start,
655 session->drag_position,
656 session->drag_handle,
657 edl->session->edit_handle_mode[session->drag_button],
658 edl->session->labels_follow_edits,
659 edl->session->plugins_follow_edits);
661 finish_modify_handles();
664 //printf("MWindow::modify_handles 1\n");
668 int MWindow::modify_pluginhandles()
670 undo->update_undo_before(_("drag handle"), LOAD_EDITS | LOAD_TIMEBAR);
672 edl->modify_pluginhandles(session->drag_start,
673 session->drag_position,
674 session->drag_handle,
675 edl->session->edit_handle_mode[session->drag_button],
676 edl->session->labels_follow_edits);
678 finish_modify_handles();
684 // Common to edithandles and plugin handles
685 void MWindow::finish_modify_handles()
687 int edit_mode = edl->session->edit_handle_mode[session->drag_button];
689 //printf("TrackCanvas::end_handle_selection 1\n");
690 if((session->drag_handle == 1 && edit_mode != MOVE_NO_EDITS) ||
691 (session->drag_handle == 0 && edit_mode == MOVE_ONE_EDIT))
693 edl->local_session->selectionstart =
694 edl->local_session->selectionend =
695 session->drag_position;
698 if(edit_mode != MOVE_NO_EDITS)
700 edl->local_session->selectionstart =
701 edl->local_session->selectionend =
705 //printf("TrackCanvas::end_handle_selection 1\n");
706 if(edl->local_session->selectionstart < 0)
707 edl->local_session->selectionstart =
708 edl->local_session->selectionend = 0;
709 //printf("TrackCanvas::end_handle_selection 1\n");
712 undo->update_undo_after();
714 sync_parameters(CHANGE_EDL);
715 //printf("TrackCanvas::end_handle_selection 1\n");
716 update_plugin_guis();
717 gui->update(1, 2, 1, 1, 1, 1, 0);
718 cwindow->update(1, 0, 0, 0, 1);
719 //printf("TrackCanvas::end_handle_selection 2\n");
724 void MWindow::match_output_size(Track *track)
726 undo->update_undo_before(_("match output size"), LOAD_ALL);
727 track->track_w = edl->session->output_w;
728 track->track_h = edl->session->output_h;
730 undo->update_undo_after();
733 sync_parameters(CHANGE_EDL);
737 void MWindow::move_edits(ArrayList<Edit*> *edits,
741 undo->update_undo_before(_("move edit"), LOAD_ALL);
743 edl->tracks->move_edits(edits,
746 edl->session->labels_follow_edits,
747 edl->session->plugins_follow_edits);
750 undo->update_undo_after();
753 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
758 update_plugin_guis();
760 1, // 1 for incremental drawing. 2 for full refresh
768 void MWindow::move_effect(Plugin *plugin,
769 PluginSet *dest_plugin_set,
771 int64_t dest_position)
773 undo->update_undo_before(_("move effect"), LOAD_ALL);
775 edl->tracks->move_effect(plugin,
781 undo->update_undo_after();
784 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
789 update_plugin_guis();
791 1, // 1 for incremental drawing. 2 for full refresh
799 void MWindow::move_plugins_up(PluginSet *plugin_set)
801 undo->update_undo_before(_("move effect up"), LOAD_ALL);
803 plugin_set->track->move_plugins_up(plugin_set);
806 undo->update_undo_after();
809 1, // 1 for incremental drawing. 2 for full refresh
815 sync_parameters(CHANGE_EDL);
818 void MWindow::move_plugins_down(PluginSet *plugin_set)
820 undo->update_undo_before(_("move effect down"), LOAD_ALL);
822 plugin_set->track->move_plugins_down(plugin_set);
825 undo->update_undo_after();
828 1, // 1 for incremental drawing. 2 for full refresh
834 sync_parameters(CHANGE_EDL);
837 void MWindow::move_track_down(Track *track)
839 undo->update_undo_before(_("move track down"), LOAD_ALL);
840 edl->tracks->move_track_down(track);
842 undo->update_undo_after();
845 gui->update(1, 1, 0, 0, 1, 0, 0);
846 sync_parameters(CHANGE_EDL);
850 void MWindow::move_tracks_down()
852 undo->update_undo_before(_("move tracks down"), LOAD_ALL);
853 edl->tracks->move_tracks_down();
855 undo->update_undo_after();
858 gui->update(1, 1, 0, 0, 1, 0, 0);
859 sync_parameters(CHANGE_EDL);
863 void MWindow::move_track_up(Track *track)
865 undo->update_undo_before(_("move track up"), LOAD_ALL);
866 edl->tracks->move_track_up(track);
868 undo->update_undo_after();
870 gui->update(1, 1, 0, 0, 1, 0, 0);
871 sync_parameters(CHANGE_EDL);
875 void MWindow::move_tracks_up()
877 undo->update_undo_before(_("move tracks up"), LOAD_ALL);
878 edl->tracks->move_tracks_up();
880 undo->update_undo_after();
882 gui->update(1, 1, 0, 0, 1, 0, 0);
883 sync_parameters(CHANGE_EDL);
887 void MWindow::mute_selection()
889 double start = edl->local_session->get_selectionstart();
890 double end = edl->local_session->get_selectionend();
893 undo->update_undo_before(_("mute"), LOAD_EDITS);
899 edl->session->plugins_follow_edits);
900 edl->local_session->selectionend = end;
901 edl->local_session->selectionstart = start;
902 edl->paste_silence(start, end, 0, edl->session->plugins_follow_edits);
904 undo->update_undo_after();
907 update_plugin_guis();
908 gui->update(1, 2, 1, 1, 1, 1, 0);
909 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
918 void MWindow::overwrite(EDL *source)
921 source->copy(source->local_session->in_point,
922 source->local_session->out_point,
930 undo->update_undo_before(_("overwrite"), LOAD_EDITS);
932 double start = edl->local_session->get_selectionstart();
933 double end = edl->local_session->get_selectionend();
934 // Calculate overwrite length from length of source
935 if(EQUIV(end, start))
938 source->local_session->out_point -
939 source->local_session->in_point;
948 edl->local_session->selectionstart =
949 edl->local_session->selectionend =
951 source->local_session->out_point -
952 source->local_session->in_point;
954 undo->update_undo_after();
957 update_plugin_guis();
958 gui->update(1, 1, 1, 1, 0, 1, 0);
959 sync_parameters(CHANGE_EDL);
962 // For splice and overwrite
963 int MWindow::paste(double start,
969 //printf("MWindow::paste 1\n");
972 // Want to insert with assets shared with the master EDL.
979 //printf("MWindow::paste 2\n");
983 // For editing use insertion point position
984 void MWindow::paste()
986 double start = edl->local_session->get_selectionstart();
987 double end = edl->local_session->get_selectionend();
988 int64_t len = gui->get_clipboard()->clipboard_len(SECONDARY_SELECTION);
989 char *string = new char[len + 1];
991 gui->get_clipboard()->from_clipboard(string,
993 SECONDARY_SELECTION);
995 file.read_from_string(string);
998 undo->update_undo_before(_("paste"), LOAD_EDITS | LOAD_TIMEBAR);
1003 edl->session->labels_follow_edits,
1004 edl->session->plugins_follow_edits);
1013 undo->update_undo_after();
1015 update_plugin_guis();
1016 gui->update(1, 2, 1, 1, 0, 1, 0);
1017 awindow->gui->update_assets();
1018 sync_parameters(CHANGE_EDL);
1021 int MWindow::paste_assets(double position, Track *dest_track)
1025 undo->update_undo_before(_("paste assets"), LOAD_EDITS);
1029 if(session->drag_assets->total)
1031 load_assets(session->drag_assets,
1036 edl->session->labels_follow_edits,
1037 edl->session->plugins_follow_edits);
1042 if(session->drag_clips->total)
1044 paste_edls(session->drag_clips,
1048 edl->session->labels_follow_edits,
1049 edl->session->plugins_follow_edits);
1056 undo->update_undo_after();
1065 sync_parameters(CHANGE_EDL);
1069 void MWindow::load_assets(ArrayList<Asset*> *new_assets,
1073 RecordLabels *labels,
1077 //printf("MWindow::load_assets 1\n");
1078 if(position < 0) position = edl->local_session->get_selectionstart();
1080 ArrayList<EDL*> new_edls;
1081 for(int i = 0; i < new_assets->total; i++)
1083 EDL *new_edl = new EDL;
1084 new_edl->create_objects();
1085 new_edl->copy_session(edl);
1086 new_edls.append(new_edl);
1089 //printf("MWindow::load_assets 2 %d %d\n", new_assets->values[i]->audio_length, new_assets->values[i]->video_length);
1090 asset_to_edl(new_edl, new_assets->values[i]);
1094 for(RecordLabel *label = labels->first; label; label = label->next)
1096 new_edl->labels->toggle_label(label->position, label->position);
1099 //printf("MWindow::load_assets 3\n");
1101 paste_edls(&new_edls,
1107 //printf("MWindow::load_assets 4\n");
1111 new_edls.remove_all_objects();
1115 int MWindow::paste_automation()
1117 int64_t len = gui->get_clipboard()->clipboard_len(SECONDARY_SELECTION);
1119 char *string = new char[len + 1];
1120 gui->get_clipboard()->from_clipboard(string,
1122 SECONDARY_SELECTION);
1124 file.read_from_string(string);
1126 undo->update_undo_before(_("paste keyframes"), LOAD_AUTOMATION);
1127 edl->tracks->clear_automation(edl->local_session->get_selectionstart(),
1128 edl->local_session->get_selectionend());
1129 edl->tracks->paste_automation(edl->local_session->get_selectionstart(),
1133 undo->update_undo_after();
1138 update_plugin_guis();
1139 gui->canvas->draw_overlays();
1140 gui->canvas->flash();
1141 sync_parameters(CHANGE_PARAMS);
1142 gui->patchbay->update();
1143 cwindow->update(1, 0, 0);
1148 int MWindow::paste_default_keyframe()
1150 int64_t len = gui->get_clipboard()->clipboard_len(SECONDARY_SELECTION);
1151 char *string = new char[len + 1];
1152 gui->get_clipboard()->from_clipboard(string,
1154 SECONDARY_SELECTION);
1156 file.read_from_string(string);
1157 undo->update_undo_before(_("paste default keyframe"), LOAD_AUTOMATION);
1158 edl->tracks->paste_default_keyframe(&file);
1159 undo->update_undo_after();
1163 update_plugin_guis();
1164 gui->canvas->draw_overlays();
1165 gui->canvas->flash();
1166 sync_parameters(CHANGE_PARAMS);
1167 gui->patchbay->update();
1168 cwindow->update(1, 0, 0);
1176 // Insert edls with project deletion and index file generation.
1177 int MWindow::paste_edls(ArrayList<EDL*> *new_edls,
1180 double current_position,
1184 ArrayList<Track*> destination_tracks;
1185 int need_new_tracks = 0;
1187 if(!new_edls->total) return 0;
1188 //printf("MWindow::paste_edls 1\n");
1190 // Delete current project
1191 if(load_mode == LOAD_REPLACE ||
1192 load_mode == LOAD_REPLACE_CONCATENATE)
1194 edl->save_defaults(defaults);
1196 // this has to be cleaned because patches[x]->track points nowhere
1198 patches->delete_all_patches();
1201 edl->create_objects();
1202 edl->copy_session(new_edls->values[0]);
1203 gui->mainmenu->update_toggles();
1205 // Insert labels for certain modes constitutively
1209 //printf("MWindow::paste_edls 2\n");
1211 // Assume any paste operation from the same EDL won't contain any clips.
1212 // If it did it would duplicate every clip here.
1213 for(int i = 0; i < new_edls->total; i++)
1215 EDL *new_edl = new_edls->values[i];
1217 for(int j = 0; j < new_edl->clips.total; j++)
1219 edl->add_clip(new_edl->clips.values[j]);
1222 if(new_edl->vwindow_edl)
1224 if(edl->vwindow_edl) delete edl->vwindow_edl;
1225 edl->vwindow_edl = new EDL(edl);
1226 edl->vwindow_edl->create_objects();
1227 edl->vwindow_edl->copy_all(new_edl->vwindow_edl);
1230 //printf("MWindow::paste_edls 2\n");
1232 // Create new tracks in master EDL
1233 if(load_mode == LOAD_REPLACE ||
1234 load_mode == LOAD_REPLACE_CONCATENATE ||
1235 load_mode == LOAD_NEW_TRACKS)
1237 need_new_tracks = 1;
1238 for(int i = 0; i < new_edls->total; i++)
1240 EDL *new_edl = new_edls->values[i];
1241 for(Track *current = new_edl->tracks->first;
1245 if(current->data_type == TRACK_VIDEO)
1247 edl->tracks->add_video_track(0, 0);
1248 if(current->draw) edl->tracks->last->draw = 1;
1249 destination_tracks.append(edl->tracks->last);
1252 if(current->data_type == TRACK_AUDIO)
1254 edl->tracks->add_audio_track(0, 0);
1255 destination_tracks.append(edl->tracks->last);
1257 edl->session->highlighted_track = edl->tracks->total() - 1;
1260 // Base track count on first EDL only for concatenation
1261 if(load_mode == LOAD_REPLACE_CONCATENATE) break;
1265 // Recycle existing tracks of master EDL
1266 if(load_mode == LOAD_CONCATENATE || load_mode == LOAD_PASTE)
1268 // The point of this is to shift forward labels after the selection so they can
1269 // then be shifted back to their original locations without recursively
1270 // shifting back every paste.
1271 if(load_mode == LOAD_PASTE && edl->session->labels_follow_edits)
1272 edl->labels->clear(edl->local_session->get_selectionstart(),
1273 edl->local_session->get_selectionend(),
1276 Track *current = first_track ? first_track : edl->tracks->first;
1277 for( ; current; current = NEXT)
1281 destination_tracks.append(current);
1283 // This should be done in the caller so we don't get recursive clear disease.
1284 // if(load_mode == LOAD_PASTE)
1285 // current->clear(edl->local_session->get_selectionstart(),
1286 // edl->local_session->get_selectionend(),
1288 // edl->session->labels_follow_edits,
1289 // edl->session->plugins_follow_edits,
1296 //printf("MWindow::paste_edls 2\n");
1298 int destination_track = 0;
1299 double *paste_position = new double[destination_tracks.total];
1305 // Iterate through the edls
1306 for(int i = 0; i < new_edls->total; i++)
1308 EDL *new_edl = new_edls->values[i];
1309 double edl_length = new_edl->local_session->clipboard_length ?
1310 new_edl->local_session->clipboard_length :
1311 new_edl->tracks->total_length();
1312 // printf("MWindow::paste_edls 2\n");
1317 // Resample EDL to master rates
1318 new_edl->resample(new_edl->session->sample_rate,
1319 edl->session->sample_rate,
1321 new_edl->resample(new_edl->session->frame_rate,
1322 edl->session->frame_rate,
1327 //printf("MWindow::paste_edls 2 %d\n", new_edl->assets->total());
1328 // Add assets and prepare index files
1329 edl->update_assets(new_edl);
1330 for(Asset *new_asset = edl->assets->first;
1332 new_asset = new_asset->next)
1334 mainindexes->add_next_asset(new_asset);
1338 // Get starting point of insertion. Need this to paste labels.
1342 case LOAD_NEW_TRACKS:
1343 current_position = 0;
1346 case LOAD_CONCATENATE:
1347 case LOAD_REPLACE_CONCATENATE:
1348 destination_track = 0;
1349 if(destination_tracks.total)
1350 current_position = destination_tracks.values[0]->get_length();
1352 current_position = 0;
1356 destination_track = 0;
1359 for(int j = 0; j < destination_tracks.total; j++)
1361 paste_position[j] = (current_position >= 0) ?
1363 edl->local_session->get_selectionstart();
1368 case LOAD_RESOURCESONLY:
1369 edl->add_clip(new_edl);
1377 if(load_mode != LOAD_RESOURCESONLY)
1380 //printf("MWindow::paste_edls %f %f\n", current_position, edl_length);
1381 if(load_mode == LOAD_PASTE)
1382 edl->labels->insert_labels(new_edl->labels,
1383 destination_tracks.total ? paste_position[0] : 0.0,
1387 edl->labels->insert_labels(new_edl->labels,
1392 for(Track *new_track = new_edl->tracks->first;
1394 new_track = new_track->next)
1396 // Get destination track of same type as new_track
1398 k < destination_tracks.total &&
1399 destination_tracks.values[destination_track]->data_type != new_track->data_type;
1400 k++, destination_track++)
1402 if(destination_track >= destination_tracks.total - 1)
1403 destination_track = 0;
1406 // Insert data into destination track
1407 if(destination_track < destination_tracks.total &&
1408 destination_tracks.values[destination_track]->data_type == new_track->data_type)
1410 Track *track = destination_tracks.values[destination_track];
1412 // Replace default keyframes if first EDL and new tracks were created.
1413 // This means data copied from one track and pasted to another won't retain
1414 // the camera position unless it's a keyframe. If it did, previous data in the
1415 // track might get unknowingly corrupted. Ideally we would detect when differing
1416 // default keyframes existed and create discrete keyframes for both.
1417 int replace_default = (i == 0) && need_new_tracks;
1419 //printf("MWindow::paste_edls 1 %d\n", replace_default);
1420 // Insert new track at current position
1423 case LOAD_REPLACE_CONCATENATE:
1424 case LOAD_CONCATENATE:
1425 current_position = track->get_length();
1429 current_position = paste_position[destination_track];
1430 paste_position[destination_track] += new_track->get_length();
1434 track->insert_track(new_track,
1440 // Get next destination track
1441 destination_track++;
1442 if(destination_track >= destination_tracks.total)
1443 destination_track = 0;
1447 if(load_mode == LOAD_PASTE)
1448 current_position += edl_length;
1450 //printf("MWindow::paste_edls 3\n");
1452 if(paste_position) delete [] paste_position;
1454 // This is already done in load_filenames and everything else that uses paste_edls
1455 // update_project(load_mode);
1457 //printf("MWindow::paste_edls 5\n");
1459 // Start examining next batch of index files
1460 mainindexes->start_build();
1461 //printf("MWindow::paste_edls 6\n");
1463 // Don't save a backup after loading since the loaded file is on disk already.
1468 void MWindow::paste_silence()
1470 double start = edl->local_session->get_selectionstart();
1471 double end = edl->local_session->get_selectionend();
1472 undo->update_undo_before(_("silence"), LOAD_EDITS | LOAD_TIMEBAR);
1473 edl->paste_silence(start,
1475 edl->session->labels_follow_edits,
1476 edl->session->plugins_follow_edits);
1479 undo->update_undo_after();
1481 update_plugin_guis();
1483 gui->update(1, 2, 1, 1, 1, 1, 0);
1484 cwindow->update(1, 0, 0, 0, 1);
1485 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1491 void MWindow::paste_transition()
1493 undo->update_undo_before(_("transition"), LOAD_EDITS);
1494 // Only the first transition gets dropped.
1495 PluginServer *server = session->drag_pluginservers->values[0];
1497 strcpy(edl->session->default_atransition, server->title);
1499 strcpy(edl->session->default_vtransition, server->title);
1501 edl->tracks->paste_transition(server, session->edit_highlighted);
1503 undo->update_undo_after();
1505 if(server->video) restart_brender();
1506 sync_parameters(CHANGE_ALL);
1509 void MWindow::paste_transition_cwindow(Track *dest_track)
1511 undo->update_undo_before(_("transition"), LOAD_EDITS);
1512 PluginServer *server = session->drag_pluginservers->values[0];
1513 edl->tracks->paste_video_transition(server, 1);
1516 gui->update(0, 1, 0, 0, 0, 0, 0);
1517 sync_parameters(CHANGE_ALL);
1520 void MWindow::paste_audio_transition()
1522 PluginServer *server = scan_plugindb(edl->session->default_atransition);
1525 char string[BCTEXTLEN];
1526 sprintf(string, _("No default transition %s found."), edl->session->default_atransition);
1527 gui->show_message(string);
1531 undo->update_undo_before(_("paste transition"), LOAD_EDITS);
1532 edl->tracks->paste_audio_transition(server);
1534 undo->update_undo_after();
1536 sync_parameters(CHANGE_ALL);
1537 gui->update(0, 1, 0, 0, 0, 0, 0);
1540 void MWindow::paste_video_transition()
1542 PluginServer *server = scan_plugindb(edl->session->default_vtransition);
1545 char string[BCTEXTLEN];
1546 sprintf(string, _("No default transition %s found."), edl->session->default_vtransition);
1547 gui->show_message(string);
1552 undo->update_undo_before(_("paste transition"), LOAD_EDITS);
1553 edl->tracks->paste_video_transition(server);
1555 undo->update_undo_after();
1557 sync_parameters(CHANGE_ALL);
1559 gui->update(0, 1, 0, 0, 0, 0, 0);
1562 void MWindow::redo_entry(int is_mwindow)
1565 gui->unlock_window();
1567 cwindow->gui->unlock_window();
1570 cwindow->playback_engine->que->send_command(STOP,
1574 vwindow->playback_engine->que->send_command(STOP,
1578 cwindow->playback_engine->interrupt_playback(0);
1579 vwindow->playback_engine->interrupt_playback(0);
1582 cwindow->gui->lock_window("MWindow::redo_entry");
1588 update_plugin_states();
1589 update_plugin_guis();
1591 gui->update(1, 2, 1, 1, 1, 1, 0);
1592 cwindow->update(1, 1, 1, 1, 1);
1595 cwindow->gui->unlock_window();
1597 gui->unlock_window();
1599 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1607 void MWindow::resize_track(Track *track, int w, int h)
1609 undo->update_undo_before(_("resize track"), LOAD_ALL);
1612 undo->update_undo_after();
1616 sync_parameters(CHANGE_EDL);
1620 void MWindow::set_inpoint(int is_mwindow)
1622 undo->update_undo_before(_("in point"), LOAD_TIMEBAR);
1623 edl->set_inpoint(edl->local_session->selectionstart);
1625 undo->update_undo_after();
1630 gui->lock_window("MWindow::set_inpoint 1");
1632 gui->timebar->update();
1636 gui->unlock_window();
1641 cwindow->gui->lock_window("MWindow::set_inpoint 2");
1643 cwindow->gui->timebar->update();
1644 cwindow->gui->flush();
1647 cwindow->gui->unlock_window();
1651 void MWindow::set_outpoint(int is_mwindow)
1653 undo->update_undo_before(_("out point"), LOAD_TIMEBAR);
1654 edl->set_outpoint(edl->local_session->selectionend);
1656 undo->update_undo_after();
1661 gui->lock_window("MWindow::set_outpoint 1");
1663 gui->timebar->update();
1667 gui->unlock_window();
1672 cwindow->gui->lock_window("MWindow::set_outpoint 2");
1674 cwindow->gui->timebar->update();
1675 cwindow->gui->flush();
1678 cwindow->gui->unlock_window();
1682 void MWindow::splice(EDL *source)
1686 source->copy(source->local_session->in_point,
1687 source->local_session->out_point,
1696 undo->update_undo_before(_("splice"), LOAD_EDITS | LOAD_TIMEBAR);
1700 double start = edl->local_session->get_selectionstart();
1701 double end = edl->local_session->get_selectionend();
1706 edl->session->labels_follow_edits,
1707 edl->session->plugins_follow_edits);
1709 edl->local_session->selectionstart =
1710 edl->local_session->selectionend =
1712 source->local_session->out_point -
1713 source->local_session->in_point;
1716 undo->update_undo_after();
1717 update_plugin_guis();
1719 gui->update(1, 1, 1, 1, 0, 1, 0);
1720 sync_parameters(CHANGE_EDL);
1723 void MWindow::to_clip()
1728 start = edl->local_session->get_selectionstart();
1729 end = edl->local_session->get_selectionend();
1731 if(EQUIV(end, start))
1734 end = edl->tracks->total_length();
1737 // Don't copy all since we don't want the clips twice.
1748 //printf("MWindow::to_clip 1 %s\n", edl->local_session->clip_title);
1753 EDL *new_edl = new EDL(edl);
1754 new_edl->create_objects();
1755 new_edl->load_xml(plugindb, &file, LOAD_ALL);
1756 sprintf(new_edl->local_session->clip_title, _("Clip %d\n"), session->clip_number++);
1758 //printf("VWindowEditing::to_clip 2 %d\n", edl->assets->total());
1759 awindow->clip_edit->create_clip(new_edl);
1761 //printf("VWindowEditing::to_clip 3 %d\n", edl->assets->total());
1767 int MWindow::toggle_label(int is_mwindow)
1769 double position1, position2;
1771 //printf("MWindow::toggle_label 1\n");
1772 undo->update_undo_before(_("label"), LOAD_TIMEBAR);
1773 //printf("MWindow::toggle_label 1\n");
1775 if(cwindow->playback_engine->is_playing_back)
1777 position1 = position2 =
1778 cwindow->playback_engine->get_tracking_position();
1782 position1 = edl->local_session->selectionstart;
1783 position2 = edl->local_session->selectionend;
1786 //printf("MWindow::toggle_label 1 %f %f\n", position1,position2 );
1787 position1 = edl->align_to_frame(position1, 0);
1788 position2 = edl->align_to_frame(position2, 0);
1790 //printf("MWindow::toggle_label 1\n");
1791 edl->labels->toggle_label(position1, position2);
1794 //printf("MWindow::toggle_label 1\n");
1797 gui->lock_window("MWindow::toggle_label 1");
1799 gui->timebar->update();
1800 gui->canvas->activate();
1804 gui->unlock_window();
1807 //printf("MWindow::toggle_label 1\n");
1810 cwindow->gui->lock_window("MWindow::toggle_label 2");
1812 cwindow->gui->timebar->update();
1813 cwindow->gui->flush();
1816 cwindow->gui->unlock_window();
1819 //printf("MWindow::toggle_label 1\n");
1820 undo->update_undo_after();
1821 //printf("MWindow::toggle_label 2\n");
1825 void MWindow::trim_selection()
1827 undo->update_undo_before("trim selection", LOAD_EDITS | LOAD_TIMEBAR);
1830 edl->trim_selection(edl->local_session->get_selectionstart(),
1831 edl->local_session->get_selectionend(),
1832 edl->session->labels_follow_edits,
1833 edl->session->plugins_follow_edits);
1836 undo->update_undo_after();
1837 update_plugin_guis();
1838 gui->update(1, 2, 1, 1, 1, 1, 0);
1840 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1848 void MWindow::undo_entry(int is_mwindow)
1851 gui->unlock_window();
1853 cwindow->gui->unlock_window();
1855 cwindow->playback_engine->que->send_command(STOP,
1859 vwindow->playback_engine->que->send_command(STOP,
1863 cwindow->playback_engine->interrupt_playback(0);
1864 vwindow->playback_engine->interrupt_playback(0);
1866 cwindow->gui->lock_window("MWindow::undo_entry 1");
1867 gui->lock_window("MWindow::undo_entry 2");
1873 update_plugin_states();
1874 update_plugin_guis();
1875 gui->update(1, 2, 1, 1, 1, 1, 0);
1876 cwindow->update(1, 1, 1, 1, 1);
1879 cwindow->gui->unlock_window();
1881 gui->unlock_window();
1883 awindow->gui->lock_window("MWindow::undo_entry 3");
1884 awindow->gui->update_assets();
1885 awindow->gui->flush();
1886 awindow->gui->unlock_window();
1887 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1895 void MWindow::new_folder(char *new_folder)
1897 undo->update_undo_before(_("new folder"), LOAD_ALL);
1898 edl->new_folder(new_folder);
1899 undo->update_undo_after();
1900 awindow->gui->lock_window("MWindow::new_folder");
1901 awindow->gui->update_assets();
1902 awindow->gui->unlock_window();
1905 void MWindow::delete_folder(char *folder)
1907 undo->update_undo_before(_("new folder"), LOAD_ALL);
1908 undo->update_undo_after();
1911 void MWindow::select_point(double position)
1913 edl->local_session->selectionstart =
1914 edl->local_session->selectionend = position;
1916 cwindow->update(1, 0, 0, 0, 1);
1917 update_plugin_guis();
1918 gui->patchbay->update();
1919 gui->cursor->hide();
1920 gui->cursor->draw();
1921 gui->mainclock->update(edl->local_session->selectionstart);
1922 gui->zoombar->update();
1923 gui->canvas->flash();