2 #include "awindowgui.h"
10 #include "cwindowgui.h"
12 #include "edlsession.h"
16 #include "levelwindow.h"
17 #include "localsession.h"
18 #include "mainclock.h"
19 #include "mainindexes.h"
21 #include "mainsession.h"
24 #include "mwindowgui.h"
27 #include "playbackengine.h"
28 #include "pluginset.h"
29 #include "recordlabel.h"
30 #include "samplescroll.h"
31 #include "trackcanvas.h"
33 #include "trackscroll.h"
35 #include "transition.h"
36 #include "transportque.h"
38 #include "vplayback.h"
40 #include "vwindowgui.h"
48 #define _(String) gettext(String)
49 #define gettext_noop(String) String
50 #define N_(String) gettext_noop (String)
55 void MWindow::add_audio_track_entry(int above, Track *dst)
57 undo->update_undo_before(_("add track"), LOAD_ALL);
58 add_audio_track(1, dst);
60 undo->update_undo_after();
63 gui->get_scrollbars();
65 gui->patchbay->update();
68 gui->canvas->activate();
69 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
75 void MWindow::add_video_track_entry(Track *dst)
77 undo->update_undo_before(_("add track"), LOAD_ALL);
78 add_video_track(1, dst);
79 undo->update_undo_after();
82 gui->get_scrollbars();
84 gui->patchbay->update();
87 gui->canvas->activate();
88 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
96 int MWindow::add_audio_track(int above, Track *dst)
98 edl->tracks->add_audio_track(above, dst);
99 edl->tracks->update_y_pixels(theme);
104 int MWindow::add_video_track(int above, Track *dst)
106 edl->tracks->add_video_track(above, dst);
107 edl->tracks->update_y_pixels(theme);
116 void MWindow::asset_to_size()
118 if(session->drag_assets->total &&
119 session->drag_assets->values[0]->video_data)
123 w = session->drag_assets->values[0]->width;
124 h = session->drag_assets->values[0]->height;
126 undo->update_undo_before(_("asset to size"), LOAD_ALL);
127 edl->session->output_w = w;
128 edl->session->output_h = h;
131 undo->update_undo_after();
133 sync_parameters(CHANGE_ALL);
139 void MWindow::clear_entry()
141 undo->update_undo_before(_("clear"), LOAD_EDITS | LOAD_TIMEBAR);
146 undo->update_undo_after();
149 update_plugin_guis();
150 gui->update(1, 2, 1, 1, 1, 1, 0);
151 cwindow->update(1, 0, 0, 0, 1);
152 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
158 void MWindow::clear(int clear_handle)
160 double start = edl->local_session->get_selectionstart();
161 double end = edl->local_session->get_selectionend();
162 if(clear_handle || !EQUIV(start, end))
166 edl->session->labels_follow_edits,
167 edl->session->plugins_follow_edits);
171 void MWindow::clear_automation()
173 undo->update_undo_before(_("clear keyframes"), LOAD_AUTOMATION);
174 edl->tracks->clear_automation(edl->local_session->get_selectionstart(),
175 edl->local_session->get_selectionend());
177 undo->update_undo_after();
180 update_plugin_guis();
181 gui->canvas->draw_overlays();
182 gui->canvas->flash();
183 sync_parameters(CHANGE_PARAMS);
184 gui->patchbay->update();
185 cwindow->update(1, 0, 0);
188 int MWindow::clear_default_keyframe()
190 undo->update_undo_before(_("clear default keyframe"), LOAD_AUTOMATION);
191 edl->tracks->clear_default_keyframe();
193 undo->update_undo_after();
196 gui->canvas->draw_overlays();
197 gui->canvas->flash();
198 sync_parameters(CHANGE_PARAMS);
199 gui->patchbay->update();
200 cwindow->update(1, 0, 0);
205 void MWindow::clear_labels()
207 undo->update_undo_before(_("clear"), LOAD_TIMEBAR);
208 clear_labels(edl->local_session->get_selectionstart(),
209 edl->local_session->get_selectionend());
210 undo->update_undo_after();
212 gui->timebar->update();
213 cwindow->update(0, 0, 0, 0, 1);
217 int MWindow::clear_labels(double start, double end)
219 edl->labels->clear(start, end, 0);
223 void MWindow::concatenate_tracks()
225 undo->update_undo_before(_("concatenate tracks"), LOAD_EDITS);
226 edl->tracks->concatenate_tracks(edl->session->plugins_follow_edits);
228 undo->update_undo_after();
231 gui->update(1, 1, 0, 0, 1, 0, 0);
232 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
241 copy(edl->local_session->get_selectionstart(),
242 edl->local_session->get_selectionend());
245 int MWindow::copy(double start, double end)
247 if(start == end) return 1;
249 //printf("MWindow::copy 1\n");
251 //printf("MWindow::copy 1\n");
261 //printf("MWindow::copy 1\n");
263 // File is now terminated and rewound
265 //printf("MWindow::copy 1\n");
266 gui->get_clipboard()->to_clipboard(file.string, strlen(file.string), SECONDARY_SELECTION);
267 //printf("MWindow::copy\n%s\n", file.string);
268 //printf("MWindow::copy 2\n");
273 int MWindow::copy_automation()
276 edl->tracks->copy_automation(edl->local_session->get_selectionstart(),
277 edl->local_session->get_selectionend(),
281 gui->get_clipboard()->to_clipboard(file.string,
283 SECONDARY_SELECTION);
287 int MWindow::copy_default_keyframe()
290 edl->tracks->copy_default_keyframe(&file);
291 gui->get_clipboard()->to_clipboard(file.string,
293 SECONDARY_SELECTION);
298 // Uses cropping coordinates in edl session to crop and translate video.
299 // We modify the projector since camera automation depends on the track size.
300 void MWindow::crop_video()
302 undo->update_undo_before(_("crop"), LOAD_ALL);
305 float old_projector_x = (float)edl->session->output_w / 2;
306 float old_projector_y = (float)edl->session->output_h / 2;
307 float new_projector_x = (float)(edl->session->crop_x1 + edl->session->crop_x2) / 2;
308 float new_projector_y = (float)(edl->session->crop_y1 + edl->session->crop_y2) / 2;
309 float projector_offset_x = -(new_projector_x - old_projector_x);
310 float projector_offset_y = -(new_projector_y - old_projector_y);
312 edl->tracks->translate_projector(projector_offset_x, projector_offset_y);
314 edl->session->output_w = edl->session->crop_x2 - edl->session->crop_x1;
315 edl->session->output_h = edl->session->crop_y2 - edl->session->crop_y1;
316 edl->session->crop_x1 = 0;
317 edl->session->crop_y1 = 0;
318 edl->session->crop_x2 = edl->session->output_w;
319 edl->session->crop_y2 = edl->session->output_h;
320 undo->update_undo_after();
323 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
332 undo->update_undo_before(_("cut"), LOAD_EDITS | LOAD_TIMEBAR);
334 double start = edl->local_session->get_selectionstart();
335 double end = edl->local_session->get_selectionend();
340 edl->session->labels_follow_edits,
341 edl->session->plugins_follow_edits);
346 undo->update_undo_after();
349 update_plugin_guis();
350 gui->update(1, 2, 1, 1, 1, 1, 0);
351 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
357 int MWindow::cut_automation()
359 undo->update_undo_before(_("cut keyframes"), LOAD_AUTOMATION);
363 edl->tracks->clear_automation(edl->local_session->get_selectionstart(),
364 edl->local_session->get_selectionend());
366 undo->update_undo_after();
370 update_plugin_guis();
371 gui->canvas->draw_overlays();
372 gui->canvas->flash();
373 sync_parameters(CHANGE_PARAMS);
374 gui->patchbay->update();
375 cwindow->update(1, 0, 0);
379 int MWindow::cut_default_keyframe()
381 undo->update_undo_before(_("cut default keyframe"), LOAD_AUTOMATION);
383 copy_default_keyframe();
384 edl->tracks->clear_default_keyframe();
385 undo->update_undo_after();
388 gui->canvas->draw_overlays();
389 gui->canvas->flash();
390 sync_parameters(CHANGE_PARAMS);
391 gui->patchbay->update();
392 cwindow->update(1, 0, 0);
399 void MWindow::delete_inpoint()
401 edl->local_session->in_point = -1;
405 void MWindow::delete_outpoint()
407 edl->local_session->out_point = -1;
411 void MWindow::delete_track()
413 undo->update_undo_before(_("delete track"), LOAD_ALL);
414 edl->tracks->delete_track();
415 undo->update_undo_after();
419 update_plugin_states();
420 gui->update(1, 1, 1, 0, 1, 0, 0);
421 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
427 void MWindow::delete_tracks()
429 undo->update_undo_before(_("delete tracks"), LOAD_ALL);
430 edl->tracks->delete_tracks();
431 undo->update_undo_after();
435 update_plugin_states();
436 gui->update(1, 1, 1, 0, 1, 0, 0);
437 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
441 //printf("MWindow::delete_tracks 5\n");
444 void MWindow::delete_track(Track *track)
446 undo->update_undo_before(_("delete track"), LOAD_ALL);
447 edl->tracks->delete_track(track);
448 undo->update_undo_after();
451 update_plugin_states();
452 gui->update(1, 1, 1, 0, 1, 0, 0);
453 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
460 void MWindow::detach_transition(Transition *transition)
462 undo->update_undo_before(_("detach transition"), LOAD_ALL);
463 hide_plugin(transition, 1);
464 int is_video = (transition->edit->track->data_type == TRACK_VIDEO);
465 transition->edit->detach_transition();
467 undo->update_undo_after();
469 if(is_video) restart_brender();
477 sync_parameters(CHANGE_EDL);
484 // Insert data from clipboard
485 void MWindow::insert(double position,
491 // For clipboard pasting make the new edl use a separate session
492 // from the master EDL. Then it can be resampled to the master rates.
493 // For splice, overwrite, and dragging need same session to get the assets.
495 ArrayList<EDL*> new_edls;
496 uint32_t load_flags = LOAD_ALL;
498 new_edls.append(&edl);
499 edl.create_objects();
503 if(parent_edl) load_flags &= ~LOAD_SESSION;
504 if(!edl.session->autos_follow_edits) load_flags &= ~LOAD_AUTOMATION;
505 if(!edl.session->labels_follow_edits) load_flags &= ~LOAD_TIMEBAR;
506 edl.load_xml(plugindb, file, load_flags);
512 paste_edls(&new_edls,
519 // printf("MWindow::insert 5 %f %f\n",
520 // vwindow->edl->local_session->in_point,
521 // vwindow->edl->local_session->out_point);
522 new_edls.remove_all();
523 //printf("MWindow::insert 6 %p\n", vwindow->get_edl());
526 void MWindow::insert_effects_canvas(double start,
529 Track *dest_track = session->track_highlighted;
530 if(!dest_track) return;
532 undo->update_undo_before(_("insert effect"), LOAD_EDITS | LOAD_PATCHES);
534 for(int i = 0; i < session->drag_pluginservers->total; i++)
536 PluginServer *plugin = session->drag_pluginservers->values[i];
538 insert_effect(plugin->title,
541 i == 0 ? session->pluginset_highlighted : 0,
548 undo->update_undo_after();
550 sync_parameters(CHANGE_EDL);
551 // GUI updated in TrackCanvas, after current_operations are reset
554 void MWindow::insert_effects_cwindow(Track *dest_track)
556 if(!dest_track) return;
558 undo->update_undo_before(_("insert effect"), LOAD_EDITS | LOAD_PATCHES);
561 double length = dest_track->get_length();
563 if(edl->local_session->get_selectionend() >
564 edl->local_session->get_selectionstart())
566 start = edl->local_session->get_selectionstart();
567 length = edl->local_session->get_selectionend() -
568 edl->local_session->get_selectionstart();
571 for(int i = 0; i < session->drag_pluginservers->total; i++)
573 PluginServer *plugin = session->drag_pluginservers->values[i];
576 insert_effect(plugin->title,
586 undo->update_undo_after();
588 sync_parameters(CHANGE_EDL);
600 void MWindow::insert_effect(char *title,
601 SharedLocation *shared_location,
603 PluginSet *plugin_set,
608 KeyFrame *default_keyframe = 0;
609 PluginServer *server = 0;
616 // Get default keyframe
617 if(plugin_type == PLUGIN_STANDALONE)
619 default_keyframe = new KeyFrame;
620 server = new PluginServer(*scan_plugindb(title));
622 server->open_plugin(0, edl, 0);
623 server->save_data(default_keyframe);
628 // Insert plugin object
629 track->insert_effect(title,
640 if(plugin_type == PLUGIN_STANDALONE)
642 server->close_plugin();
644 delete default_keyframe;
648 int MWindow::modify_edithandles()
650 undo->update_undo_before(_("drag handle"), LOAD_EDITS | LOAD_TIMEBAR);
656 edl->modify_edithandles(session->drag_start,
657 session->drag_position,
658 session->drag_handle,
659 edl->session->edit_handle_mode[session->drag_button],
660 edl->session->labels_follow_edits,
661 edl->session->plugins_follow_edits);
663 finish_modify_handles();
666 //printf("MWindow::modify_handles 1\n");
670 int MWindow::modify_pluginhandles()
672 undo->update_undo_before(_("drag handle"), LOAD_EDITS | LOAD_TIMEBAR);
674 edl->modify_pluginhandles(session->drag_start,
675 session->drag_position,
676 session->drag_handle,
677 edl->session->edit_handle_mode[session->drag_button],
678 edl->session->labels_follow_edits);
680 finish_modify_handles();
686 // Common to edithandles and plugin handles
687 void MWindow::finish_modify_handles()
689 int edit_mode = edl->session->edit_handle_mode[session->drag_button];
691 //printf("TrackCanvas::end_handle_selection 1\n");
692 if((session->drag_handle == 1 && edit_mode != MOVE_NO_EDITS) ||
693 (session->drag_handle == 0 && edit_mode == MOVE_ONE_EDIT))
695 edl->local_session->selectionstart =
696 edl->local_session->selectionend =
697 session->drag_position;
700 if(edit_mode != MOVE_NO_EDITS)
702 edl->local_session->selectionstart =
703 edl->local_session->selectionend =
707 //printf("TrackCanvas::end_handle_selection 1\n");
708 if(edl->local_session->selectionstart < 0)
709 edl->local_session->selectionstart =
710 edl->local_session->selectionend = 0;
711 //printf("TrackCanvas::end_handle_selection 1\n");
714 undo->update_undo_after();
716 sync_parameters(CHANGE_EDL);
717 //printf("TrackCanvas::end_handle_selection 1\n");
718 update_plugin_guis();
719 gui->update(1, 2, 1, 1, 1, 1, 0);
720 cwindow->update(1, 0, 0, 0, 1);
721 //printf("TrackCanvas::end_handle_selection 2\n");
726 void MWindow::match_output_size(Track *track)
728 undo->update_undo_before(_("match output size"), LOAD_ALL);
729 track->track_w = edl->session->output_w;
730 track->track_h = edl->session->output_h;
732 undo->update_undo_after();
735 sync_parameters(CHANGE_EDL);
739 void MWindow::move_edits(ArrayList<Edit*> *edits,
743 undo->update_undo_before(_("move edit"), LOAD_ALL);
745 edl->tracks->move_edits(edits,
748 edl->session->labels_follow_edits,
749 edl->session->plugins_follow_edits);
752 undo->update_undo_after();
755 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
760 update_plugin_guis();
762 1, // 1 for incremental drawing. 2 for full refresh
770 void MWindow::move_effect(Plugin *plugin,
771 PluginSet *dest_plugin_set,
773 int64_t dest_position)
775 undo->update_undo_before(_("move effect"), LOAD_ALL);
777 edl->tracks->move_effect(plugin,
783 undo->update_undo_after();
786 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
791 update_plugin_guis();
793 1, // 1 for incremental drawing. 2 for full refresh
801 void MWindow::move_plugins_up(PluginSet *plugin_set)
803 undo->update_undo_before(_("move effect up"), LOAD_ALL);
805 plugin_set->track->move_plugins_up(plugin_set);
808 undo->update_undo_after();
811 1, // 1 for incremental drawing. 2 for full refresh
817 sync_parameters(CHANGE_EDL);
820 void MWindow::move_plugins_down(PluginSet *plugin_set)
822 undo->update_undo_before(_("move effect down"), LOAD_ALL);
824 plugin_set->track->move_plugins_down(plugin_set);
827 undo->update_undo_after();
830 1, // 1 for incremental drawing. 2 for full refresh
836 sync_parameters(CHANGE_EDL);
839 void MWindow::move_track_down(Track *track)
841 undo->update_undo_before(_("move track down"), LOAD_ALL);
842 edl->tracks->move_track_down(track);
844 undo->update_undo_after();
847 gui->update(1, 1, 0, 0, 1, 0, 0);
848 sync_parameters(CHANGE_EDL);
852 void MWindow::move_tracks_down()
854 undo->update_undo_before(_("move tracks down"), LOAD_ALL);
855 edl->tracks->move_tracks_down();
857 undo->update_undo_after();
860 gui->update(1, 1, 0, 0, 1, 0, 0);
861 sync_parameters(CHANGE_EDL);
865 void MWindow::move_track_up(Track *track)
867 undo->update_undo_before(_("move track up"), LOAD_ALL);
868 edl->tracks->move_track_up(track);
870 undo->update_undo_after();
872 gui->update(1, 1, 0, 0, 1, 0, 0);
873 sync_parameters(CHANGE_EDL);
877 void MWindow::move_tracks_up()
879 undo->update_undo_before(_("move tracks up"), LOAD_ALL);
880 edl->tracks->move_tracks_up();
882 undo->update_undo_after();
884 gui->update(1, 1, 0, 0, 1, 0, 0);
885 sync_parameters(CHANGE_EDL);
889 void MWindow::mute_selection()
891 double start = edl->local_session->get_selectionstart();
892 double end = edl->local_session->get_selectionend();
895 undo->update_undo_before(_("mute"), LOAD_EDITS);
901 edl->session->plugins_follow_edits);
902 edl->local_session->selectionend = end;
903 edl->local_session->selectionstart = start;
904 edl->paste_silence(start, end, 0, edl->session->plugins_follow_edits);
906 undo->update_undo_after();
909 update_plugin_guis();
910 gui->update(1, 2, 1, 1, 1, 1, 0);
911 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
920 void MWindow::overwrite(EDL *source)
923 source->copy(source->local_session->in_point,
924 source->local_session->out_point,
932 undo->update_undo_before(_("overwrite"), LOAD_EDITS);
934 double start = edl->local_session->get_selectionstart();
935 double end = edl->local_session->get_selectionend();
936 // Calculate overwrite length from length of source
937 if(EQUIV(end, start))
940 source->local_session->out_point -
941 source->local_session->in_point;
950 edl->local_session->selectionstart =
951 edl->local_session->selectionend =
953 source->local_session->out_point -
954 source->local_session->in_point;
956 undo->update_undo_after();
959 update_plugin_guis();
960 gui->update(1, 1, 1, 1, 0, 1, 0);
961 sync_parameters(CHANGE_EDL);
964 // For splice and overwrite
965 int MWindow::paste(double start,
971 //printf("MWindow::paste 1\n");
974 // Want to insert with assets shared with the master EDL.
981 //printf("MWindow::paste 2\n");
985 // For editing use insertion point position
986 void MWindow::paste()
988 double start = edl->local_session->get_selectionstart();
989 double end = edl->local_session->get_selectionend();
990 int64_t len = gui->get_clipboard()->clipboard_len(SECONDARY_SELECTION);
991 char *string = new char[len + 1];
993 gui->get_clipboard()->from_clipboard(string,
995 SECONDARY_SELECTION);
997 file.read_from_string(string);
1000 undo->update_undo_before(_("paste"), LOAD_EDITS | LOAD_TIMEBAR);
1005 edl->session->labels_follow_edits,
1006 edl->session->plugins_follow_edits);
1015 undo->update_undo_after();
1017 update_plugin_guis();
1018 gui->update(1, 2, 1, 1, 0, 1, 0);
1019 awindow->gui->update_assets();
1020 sync_parameters(CHANGE_EDL);
1023 int MWindow::paste_assets(double position, Track *dest_track)
1027 undo->update_undo_before(_("paste assets"), LOAD_EDITS);
1031 if(session->drag_assets->total)
1033 load_assets(session->drag_assets,
1038 edl->session->labels_follow_edits,
1039 edl->session->plugins_follow_edits);
1044 if(session->drag_clips->total)
1046 paste_edls(session->drag_clips,
1050 edl->session->labels_follow_edits,
1051 edl->session->plugins_follow_edits);
1058 undo->update_undo_after();
1067 sync_parameters(CHANGE_EDL);
1071 void MWindow::load_assets(ArrayList<Asset*> *new_assets,
1075 RecordLabels *labels,
1079 //printf("MWindow::load_assets 1\n");
1080 if(position < 0) position = edl->local_session->get_selectionstart();
1082 ArrayList<EDL*> new_edls;
1083 for(int i = 0; i < new_assets->total; i++)
1085 EDL *new_edl = new EDL;
1086 new_edl->create_objects();
1087 new_edl->copy_session(edl);
1088 new_edls.append(new_edl);
1091 //printf("MWindow::load_assets 2 %d %d\n", new_assets->values[i]->audio_length, new_assets->values[i]->video_length);
1092 asset_to_edl(new_edl, new_assets->values[i]);
1096 for(RecordLabel *label = labels->first; label; label = label->next)
1098 new_edl->labels->toggle_label(label->position, label->position);
1101 //printf("MWindow::load_assets 3\n");
1103 paste_edls(&new_edls,
1109 //printf("MWindow::load_assets 4\n");
1113 new_edls.remove_all_objects();
1117 int MWindow::paste_automation()
1119 int64_t len = gui->get_clipboard()->clipboard_len(SECONDARY_SELECTION);
1121 char *string = new char[len + 1];
1122 gui->get_clipboard()->from_clipboard(string,
1124 SECONDARY_SELECTION);
1126 file.read_from_string(string);
1128 undo->update_undo_before(_("paste keyframes"), LOAD_AUTOMATION);
1129 edl->tracks->clear_automation(edl->local_session->get_selectionstart(),
1130 edl->local_session->get_selectionend());
1131 edl->tracks->paste_automation(edl->local_session->get_selectionstart(),
1135 undo->update_undo_after();
1140 update_plugin_guis();
1141 gui->canvas->draw_overlays();
1142 gui->canvas->flash();
1143 sync_parameters(CHANGE_PARAMS);
1144 gui->patchbay->update();
1145 cwindow->update(1, 0, 0);
1150 int MWindow::paste_default_keyframe()
1152 int64_t len = gui->get_clipboard()->clipboard_len(SECONDARY_SELECTION);
1153 char *string = new char[len + 1];
1154 gui->get_clipboard()->from_clipboard(string,
1156 SECONDARY_SELECTION);
1158 file.read_from_string(string);
1159 undo->update_undo_before(_("paste default keyframe"), LOAD_AUTOMATION);
1160 edl->tracks->paste_default_keyframe(&file);
1161 undo->update_undo_after();
1165 update_plugin_guis();
1166 gui->canvas->draw_overlays();
1167 gui->canvas->flash();
1168 sync_parameters(CHANGE_PARAMS);
1169 gui->patchbay->update();
1170 cwindow->update(1, 0, 0);
1178 // Insert edls with project deletion and index file generation.
1179 int MWindow::paste_edls(ArrayList<EDL*> *new_edls,
1182 double current_position,
1186 ArrayList<Track*> destination_tracks;
1187 int need_new_tracks = 0;
1189 if(!new_edls->total) return 0;
1190 //printf("MWindow::paste_edls 1\n");
1192 // Delete current project
1193 if(load_mode == LOAD_REPLACE ||
1194 load_mode == LOAD_REPLACE_CONCATENATE)
1196 edl->save_defaults(defaults);
1198 // this has to be cleaned because patches[x]->track points nowhere
1200 patches->delete_all_patches();
1203 edl->create_objects();
1204 edl->copy_session(new_edls->values[0]);
1205 gui->mainmenu->update_toggles();
1207 // Insert labels for certain modes constitutively
1211 //printf("MWindow::paste_edls 2\n");
1213 // Assume any paste operation from the same EDL won't contain any clips.
1214 // If it did it would duplicate every clip here.
1215 for(int i = 0; i < new_edls->total; i++)
1217 EDL *new_edl = new_edls->values[i];
1219 for(int j = 0; j < new_edl->clips.total; j++)
1221 edl->add_clip(new_edl->clips.values[j]);
1224 if(new_edl->vwindow_edl)
1226 if(edl->vwindow_edl) delete edl->vwindow_edl;
1227 edl->vwindow_edl = new EDL(edl);
1228 edl->vwindow_edl->create_objects();
1229 edl->vwindow_edl->copy_all(new_edl->vwindow_edl);
1232 //printf("MWindow::paste_edls 2\n");
1234 // Create new tracks in master EDL
1235 if(load_mode == LOAD_REPLACE ||
1236 load_mode == LOAD_REPLACE_CONCATENATE ||
1237 load_mode == LOAD_NEW_TRACKS)
1239 need_new_tracks = 1;
1240 for(int i = 0; i < new_edls->total; i++)
1242 EDL *new_edl = new_edls->values[i];
1243 for(Track *current = new_edl->tracks->first;
1247 if(current->data_type == TRACK_VIDEO)
1249 edl->tracks->add_video_track(0, 0);
1250 if(current->draw) edl->tracks->last->draw = 1;
1251 destination_tracks.append(edl->tracks->last);
1254 if(current->data_type == TRACK_AUDIO)
1256 edl->tracks->add_audio_track(0, 0);
1257 destination_tracks.append(edl->tracks->last);
1259 edl->session->highlighted_track = edl->tracks->total() - 1;
1262 // Base track count on first EDL only for concatenation
1263 if(load_mode == LOAD_REPLACE_CONCATENATE) break;
1267 // Recycle existing tracks of master EDL
1268 if(load_mode == LOAD_CONCATENATE || load_mode == LOAD_PASTE)
1270 // The point of this is to shift forward labels after the selection so they can
1271 // then be shifted back to their original locations without recursively
1272 // shifting back every paste.
1273 if(load_mode == LOAD_PASTE && edl->session->labels_follow_edits)
1274 edl->labels->clear(edl->local_session->get_selectionstart(),
1275 edl->local_session->get_selectionend(),
1278 Track *current = first_track ? first_track : edl->tracks->first;
1279 for( ; current; current = NEXT)
1283 destination_tracks.append(current);
1285 // This should be done in the caller so we don't get recursive clear disease.
1286 // if(load_mode == LOAD_PASTE)
1287 // current->clear(edl->local_session->get_selectionstart(),
1288 // edl->local_session->get_selectionend(),
1290 // edl->session->labels_follow_edits,
1291 // edl->session->plugins_follow_edits,
1298 //printf("MWindow::paste_edls 2\n");
1300 int destination_track = 0;
1301 double *paste_position = new double[destination_tracks.total];
1307 // Iterate through the edls
1308 for(int i = 0; i < new_edls->total; i++)
1310 EDL *new_edl = new_edls->values[i];
1311 double edl_length = new_edl->local_session->clipboard_length ?
1312 new_edl->local_session->clipboard_length :
1313 new_edl->tracks->total_length();
1314 // printf("MWindow::paste_edls 2\n");
1319 // Resample EDL to master rates
1320 new_edl->resample(new_edl->session->sample_rate,
1321 edl->session->sample_rate,
1323 new_edl->resample(new_edl->session->frame_rate,
1324 edl->session->frame_rate,
1329 //printf("MWindow::paste_edls 2 %d\n", new_edl->assets->total());
1330 // Add assets and prepare index files
1331 edl->update_assets(new_edl);
1332 for(Asset *new_asset = edl->assets->first;
1334 new_asset = new_asset->next)
1336 mainindexes->add_next_asset(new_asset);
1340 // Get starting point of insertion. Need this to paste labels.
1344 case LOAD_NEW_TRACKS:
1345 current_position = 0;
1348 case LOAD_CONCATENATE:
1349 case LOAD_REPLACE_CONCATENATE:
1350 destination_track = 0;
1351 if(destination_tracks.total)
1352 current_position = destination_tracks.values[0]->get_length();
1354 current_position = 0;
1358 destination_track = 0;
1361 for(int j = 0; j < destination_tracks.total; j++)
1363 paste_position[j] = (current_position >= 0) ?
1365 edl->local_session->get_selectionstart();
1370 case LOAD_RESOURCESONLY:
1371 edl->add_clip(new_edl);
1379 if(load_mode != LOAD_RESOURCESONLY)
1382 //printf("MWindow::paste_edls %f %f\n", current_position, edl_length);
1383 if(load_mode == LOAD_PASTE)
1384 edl->labels->insert_labels(new_edl->labels,
1385 destination_tracks.total ? paste_position[0] : 0.0,
1389 edl->labels->insert_labels(new_edl->labels,
1394 for(Track *new_track = new_edl->tracks->first;
1396 new_track = new_track->next)
1398 // Get destination track of same type as new_track
1400 k < destination_tracks.total &&
1401 destination_tracks.values[destination_track]->data_type != new_track->data_type;
1402 k++, destination_track++)
1404 if(destination_track >= destination_tracks.total - 1)
1405 destination_track = 0;
1408 // Insert data into destination track
1409 if(destination_track < destination_tracks.total &&
1410 destination_tracks.values[destination_track]->data_type == new_track->data_type)
1412 Track *track = destination_tracks.values[destination_track];
1413 // Replace default keyframes if first EDL and new tracks were created
1414 int replace_default = (i == 0) && need_new_tracks;
1416 // Insert new track at current position
1419 case LOAD_REPLACE_CONCATENATE:
1420 case LOAD_CONCATENATE:
1421 current_position = track->get_length();
1425 current_position = paste_position[destination_track];
1426 paste_position[destination_track] += new_track->get_length();
1430 track->insert_track(new_track,
1436 // Get next destination track
1437 destination_track++;
1438 if(destination_track >= destination_tracks.total)
1439 destination_track = 0;
1443 if(load_mode == LOAD_PASTE)
1444 current_position += edl_length;
1446 //printf("MWindow::paste_edls 3\n");
1448 if(paste_position) delete [] paste_position;
1450 // This is already done in load_filenames and everything else that uses paste_edls
1451 // update_project(load_mode);
1453 //printf("MWindow::paste_edls 5\n");
1455 // Start examining next batch of index files
1456 mainindexes->start_build();
1457 //printf("MWindow::paste_edls 6\n");
1459 // Don't save a backup after loading since the loaded file is on disk already.
1464 void MWindow::paste_silence()
1466 double start = edl->local_session->get_selectionstart();
1467 double end = edl->local_session->get_selectionend();
1468 undo->update_undo_before(_("silence"), LOAD_EDITS | LOAD_TIMEBAR);
1469 edl->paste_silence(start,
1471 edl->session->labels_follow_edits,
1472 edl->session->plugins_follow_edits);
1475 undo->update_undo_after();
1477 update_plugin_guis();
1479 gui->update(1, 2, 1, 1, 1, 1, 0);
1480 cwindow->update(1, 0, 0, 0, 1);
1481 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1487 void MWindow::paste_transition()
1489 undo->update_undo_before(_("transition"), LOAD_EDITS);
1490 // Only the first transition gets dropped.
1491 PluginServer *server = session->drag_pluginservers->values[0];
1493 strcpy(edl->session->default_atransition, server->title);
1495 strcpy(edl->session->default_vtransition, server->title);
1497 edl->tracks->paste_transition(server, session->edit_highlighted);
1499 undo->update_undo_after();
1501 if(server->video) restart_brender();
1502 sync_parameters(CHANGE_ALL);
1505 void MWindow::paste_transition_cwindow(Track *dest_track)
1507 undo->update_undo_before(_("transition"), LOAD_EDITS);
1508 PluginServer *server = session->drag_pluginservers->values[0];
1509 edl->tracks->paste_video_transition(server, 1);
1512 gui->update(0, 1, 0, 0, 0, 0, 0);
1513 sync_parameters(CHANGE_ALL);
1516 void MWindow::paste_audio_transition()
1518 PluginServer *server = scan_plugindb(edl->session->default_atransition);
1521 char string[BCTEXTLEN];
1522 sprintf(string, _("No default transition %s found."), edl->session->default_atransition);
1523 gui->show_message(string);
1527 undo->update_undo_before(_("paste transition"), LOAD_EDITS);
1528 edl->tracks->paste_audio_transition(server);
1530 undo->update_undo_after();
1532 sync_parameters(CHANGE_ALL);
1533 gui->update(0, 1, 0, 0, 0, 0, 0);
1536 void MWindow::paste_video_transition()
1538 PluginServer *server = scan_plugindb(edl->session->default_vtransition);
1541 char string[BCTEXTLEN];
1542 sprintf(string, _("No default transition %s found."), edl->session->default_vtransition);
1543 gui->show_message(string);
1548 undo->update_undo_before(_("paste transition"), LOAD_EDITS);
1549 edl->tracks->paste_video_transition(server);
1551 undo->update_undo_after();
1553 sync_parameters(CHANGE_ALL);
1555 gui->update(0, 1, 0, 0, 0, 0, 0);
1558 void MWindow::redo_entry(int is_mwindow)
1561 gui->unlock_window();
1563 cwindow->gui->unlock_window();
1566 cwindow->playback_engine->que->send_command(STOP,
1570 vwindow->playback_engine->que->send_command(STOP,
1574 cwindow->playback_engine->interrupt_playback(0);
1575 vwindow->playback_engine->interrupt_playback(0);
1578 cwindow->gui->lock_window();
1584 update_plugin_states();
1585 update_plugin_guis();
1587 gui->update(1, 2, 1, 1, 1, 1, 0);
1588 cwindow->update(1, 1, 1, 1, 1);
1591 cwindow->gui->unlock_window();
1593 gui->unlock_window();
1595 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1603 void MWindow::resize_track(Track *track, int w, int h)
1605 undo->update_undo_before(_("resize track"), LOAD_ALL);
1608 undo->update_undo_after();
1612 sync_parameters(CHANGE_EDL);
1616 void MWindow::set_inpoint(int is_mwindow)
1618 undo->update_undo_before(_("in point"), LOAD_TIMEBAR);
1619 edl->set_inpoint(edl->local_session->selectionstart);
1621 undo->update_undo_after();
1628 gui->timebar->update();
1632 gui->unlock_window();
1637 cwindow->gui->lock_window();
1639 cwindow->gui->timebar->update();
1640 cwindow->gui->flush();
1643 cwindow->gui->unlock_window();
1647 void MWindow::set_outpoint(int is_mwindow)
1649 undo->update_undo_before(_("out point"), LOAD_TIMEBAR);
1650 edl->set_outpoint(edl->local_session->selectionend);
1652 undo->update_undo_after();
1659 gui->timebar->update();
1663 gui->unlock_window();
1668 cwindow->gui->lock_window();
1670 cwindow->gui->timebar->update();
1671 cwindow->gui->flush();
1674 cwindow->gui->unlock_window();
1678 void MWindow::splice(EDL *source)
1682 source->copy(source->local_session->in_point,
1683 source->local_session->out_point,
1692 undo->update_undo_before(_("splice"), LOAD_EDITS | LOAD_TIMEBAR);
1696 double start = edl->local_session->get_selectionstart();
1697 double end = edl->local_session->get_selectionend();
1702 edl->session->labels_follow_edits,
1703 edl->session->plugins_follow_edits);
1705 edl->local_session->selectionstart =
1706 edl->local_session->selectionend =
1708 source->local_session->out_point -
1709 source->local_session->in_point;
1712 undo->update_undo_after();
1713 update_plugin_guis();
1715 gui->update(1, 1, 1, 1, 0, 1, 0);
1716 sync_parameters(CHANGE_EDL);
1719 void MWindow::to_clip()
1724 start = edl->local_session->get_selectionstart();
1725 end = edl->local_session->get_selectionend();
1727 if(EQUIV(end, start))
1730 end = edl->tracks->total_length();
1733 // Don't copy all since we don't want the clips twice.
1744 //printf("MWindow::to_clip 1 %s\n", edl->local_session->clip_title);
1749 EDL *new_edl = new EDL(edl);
1750 new_edl->create_objects();
1751 new_edl->load_xml(plugindb, &file, LOAD_ALL);
1752 sprintf(new_edl->local_session->clip_title, _("Clip %d\n"), session->clip_number++);
1754 //printf("VWindowEditing::to_clip 2 %d\n", edl->assets->total());
1755 awindow->clip_edit->create_clip(new_edl);
1757 //printf("VWindowEditing::to_clip 3 %d\n", edl->assets->total());
1763 int MWindow::toggle_label(int is_mwindow)
1765 double position1, position2;
1767 //printf("MWindow::toggle_label 1\n");
1768 undo->update_undo_before(_("label"), LOAD_TIMEBAR);
1769 //printf("MWindow::toggle_label 1\n");
1771 if(cwindow->playback_engine->is_playing_back)
1773 position1 = position2 =
1774 cwindow->playback_engine->get_tracking_position();
1778 position1 = edl->local_session->selectionstart;
1779 position2 = edl->local_session->selectionend;
1782 //printf("MWindow::toggle_label 1 %f %f\n", position1,position2 );
1783 position1 = edl->align_to_frame(position1, 0);
1784 position2 = edl->align_to_frame(position2, 0);
1786 //printf("MWindow::toggle_label 1\n");
1787 edl->labels->toggle_label(position1, position2);
1790 //printf("MWindow::toggle_label 1\n");
1795 gui->timebar->update();
1796 gui->canvas->activate();
1800 gui->unlock_window();
1803 //printf("MWindow::toggle_label 1\n");
1806 cwindow->gui->lock_window();
1808 cwindow->gui->timebar->update();
1809 cwindow->gui->flush();
1812 cwindow->gui->unlock_window();
1815 //printf("MWindow::toggle_label 1\n");
1816 undo->update_undo_after();
1817 //printf("MWindow::toggle_label 2\n");
1821 void MWindow::trim_selection()
1823 undo->update_undo_before(_("trim selection"), LOAD_EDITS);
1826 edl->trim_selection(edl->local_session->get_selectionstart(),
1827 edl->local_session->get_selectionend(),
1828 edl->session->labels_follow_edits,
1829 edl->session->plugins_follow_edits);
1832 undo->update_undo_after();
1833 update_plugin_guis();
1834 gui->update(1, 2, 1, 1, 1, 1, 0);
1836 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1844 void MWindow::undo_entry(int is_mwindow)
1847 gui->unlock_window();
1849 cwindow->gui->unlock_window();
1851 cwindow->playback_engine->que->send_command(STOP,
1855 vwindow->playback_engine->que->send_command(STOP,
1859 cwindow->playback_engine->interrupt_playback(0);
1860 vwindow->playback_engine->interrupt_playback(0);
1862 cwindow->gui->lock_window();
1869 update_plugin_states();
1870 update_plugin_guis();
1871 gui->update(1, 2, 1, 1, 1, 1, 0);
1872 cwindow->update(1, 1, 1, 1, 1);
1875 cwindow->gui->unlock_window();
1877 gui->unlock_window();
1879 awindow->gui->lock_window();
1880 awindow->gui->update_assets();
1881 awindow->gui->flush();
1882 awindow->gui->unlock_window();
1883 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1891 void MWindow::new_folder(char *new_folder)
1893 undo->update_undo_before(_("new folder"), LOAD_ALL);
1894 edl->new_folder(new_folder);
1895 undo->update_undo_after();
1896 awindow->gui->lock_window();
1897 awindow->gui->update_assets();
1898 awindow->gui->unlock_window();
1901 void MWindow::delete_folder(char *folder)
1903 undo->update_undo_before(_("new folder"), LOAD_ALL);
1904 undo->update_undo_after();
1907 void MWindow::select_point(double position)
1909 edl->local_session->selectionstart =
1910 edl->local_session->selectionend = position;
1912 cwindow->update(1, 0, 0, 0, 1);
1913 update_plugin_guis();
1914 gui->patchbay->update();
1915 gui->cursor->hide();
1916 gui->cursor->draw();
1917 gui->mainclock->update(edl->local_session->selectionstart);
1918 gui->zoombar->update();
1919 gui->canvas->flash();