3 * Copyright (C) 1997-2012 Adam Williams <broadcast at earthling dot net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "awindowgui.h"
25 #include "bcsignals.h"
29 #include "commercials.h"
30 #include "cplayback.h"
33 #include "cwindowgui.h"
36 #include "edlsession.h"
38 #include "floatauto.h"
39 #include "floatautos.h"
41 #include "gwindowgui.h"
45 #include "levelwindow.h"
46 #include "localsession.h"
47 #include "mainclock.h"
48 #include "maincursor.h"
49 #include "mainerror.h"
50 #include "mainindexes.h"
52 #include "mainsession.h"
54 #include "maskautos.h"
56 #include "mwindowgui.h"
60 #include "playbackengine.h"
61 #include "pluginset.h"
62 #include "recordlabel.h"
63 #include "samplescroll.h"
64 #include "trackcanvas.h"
66 #include "trackscroll.h"
68 #include "transition.h"
69 #include "transportque.h"
71 #include "undostackitem.h"
72 #include "vplayback.h"
74 #include "vwindowgui.h"
76 #include "automation.h"
77 #include "maskautos.h"
87 void MWindow::add_audio_track_entry(int above, Track *dst)
89 undo->update_undo_before();
90 add_audio_track(above, dst);
92 undo->update_undo_after(_("add track"), LOAD_ALL);
102 gui->activate_timeline();
104 // gui->get_scrollbars(0);
105 // gui->canvas->draw();
106 // gui->patchbay->update();
107 // gui->cursor->draw(1);
108 // gui->canvas->flash();
109 // gui->canvas->activate();
110 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
116 void MWindow::add_video_track_entry(Track *dst)
118 undo->update_undo_before();
119 add_video_track(1, dst);
120 undo->update_undo_after(_("add track"), LOAD_ALL);
124 gui->update(1, 1, 0, 0, 1, 0, 0);
125 gui->activate_timeline();
126 // gui->get_scrollbars(0);
127 // gui->canvas->draw();
128 // gui->patchbay->update();
129 // gui->cursor->draw(1);
130 // gui->canvas->flash();
131 // gui->canvas->activate();
132 cwindow->playback_engine->que->
133 send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);
137 void MWindow::add_subttl_track_entry(Track *dst)
139 undo->update_undo_before();
140 add_subttl_track(1, dst);
141 undo->update_undo_after(_("add track"), LOAD_ALL);
145 gui->update(1, 1, 0, 0, 1, 0, 0);
146 gui->activate_timeline();
147 // gui->get_scrollbars(0);
148 // gui->canvas->draw();
149 // gui->patchbay->update();
150 // gui->cursor->draw(1);
151 // gui->canvas->flash();
152 // gui->canvas->activate();
153 cwindow->playback_engine->que->
154 send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);
159 int MWindow::add_audio_track(int above, Track *dst)
161 edl->tracks->add_audio_track(above, dst);
162 edl->tracks->update_y_pixels(theme);
167 int MWindow::add_video_track(int above, Track *dst)
169 edl->tracks->add_video_track(above, dst);
170 edl->tracks->update_y_pixels(theme);
175 int MWindow::add_subttl_track(int above, Track *dst)
177 edl->tracks->add_subttl_track(above, dst);
178 edl->tracks->update_y_pixels(theme);
186 void MWindow::asset_to_all()
188 if(!session->drag_assets->size()) return;
189 Indexable *indexable = session->drag_assets->get(0);
191 // if(indexable->have_video())
195 undo->update_undo_before();
198 w = indexable->get_w();
199 h = indexable->get_h();
200 double new_framerate = session->drag_assets->get(0)->get_frame_rate();
201 double old_framerate = edl->session->frame_rate;
202 int old_samplerate = edl->session->sample_rate;
203 int new_samplerate = session->drag_assets->get(0)->get_sample_rate();
206 if(indexable->have_video())
208 edl->session->output_w = w;
209 edl->session->output_h = h;
210 edl->session->frame_rate = new_framerate;
211 create_aspect_ratio(edl->session->aspect_w,
212 edl->session->aspect_h,
216 for(Track *current = edl->tracks->first;
220 if(current->data_type == TRACK_VIDEO /* &&
223 current->track_w = w;
224 current->track_h = h;
229 if(((edl->session->output_w % 4) ||
230 (edl->session->output_h % 4)) &&
231 edl->session->playback_config->vconfig->driver == PLAYBACK_X11_GL)
233 MainError::show_error(
234 _("This project's dimensions are not multiples of 4 so\n"
235 "it can't be rendered by OpenGL."));
240 if(defaults->get("AUTOASPECT", 0))
242 create_aspect_ratio(edl->session->aspect_w,
243 edl->session->aspect_h,
249 if(indexable->have_audio())
251 edl->session->sample_rate = new_samplerate;
252 edl->resample(old_framerate, new_framerate, TRACK_VIDEO);
253 edl->resample(old_samplerate, new_samplerate, TRACK_AUDIO);
259 undo->update_undo_after(_("asset to all"), LOAD_ALL);
268 sync_parameters(CHANGE_ALL);
277 void MWindow::asset_to_size()
279 if(!session->drag_assets->size()) return;
280 Indexable *indexable = session->drag_assets->get(0);
282 if(indexable->have_video())
285 undo->update_undo_before();
288 w = indexable->get_w();
289 h = indexable->get_h();
292 edl->session->output_w = w;
293 edl->session->output_h = h;
295 if(((edl->session->output_w % 4) ||
296 (edl->session->output_h % 4)) &&
297 edl->session->playback_config->vconfig->driver == PLAYBACK_X11_GL)
299 MainError::show_error(
300 _("This project's dimensions are not multiples of 4 so\n"
301 "it can't be rendered by OpenGL."));
306 if(defaults->get("AUTOASPECT", 0))
308 create_aspect_ratio(edl->session->aspect_w,
309 edl->session->aspect_h,
316 undo->update_undo_after(_("asset to size"), LOAD_ALL);
318 sync_parameters(CHANGE_ALL);
323 void MWindow::asset_to_rate()
325 if(session->drag_assets->size() &&
326 session->drag_assets->get(0)->have_video())
328 double new_framerate = session->drag_assets->get(0)->get_frame_rate();
329 double old_framerate = edl->session->frame_rate;
330 undo->update_undo_before();
332 edl->session->frame_rate = new_framerate;
333 edl->resample(old_framerate, new_framerate, TRACK_VIDEO);
337 undo->update_undo_after(_("asset to rate"), LOAD_ALL);
346 sync_parameters(CHANGE_ALL);
352 void MWindow::clear_entry()
354 undo->update_undo_before();
359 undo->update_undo_after(_("clear"), LOAD_EDITS | LOAD_TIMEBAR);
362 update_plugin_guis();
363 gui->update(1, 2, 1, 1, 1, 1, 0);
364 cwindow->update(1, 0, 0, 0, 1);
365 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
371 void MWindow::clear(int clear_handle)
373 double start = edl->local_session->get_selectionstart();
374 double end = edl->local_session->get_selectionend();
375 if(clear_handle || !EQUIV(start, end))
379 edl->session->labels_follow_edits,
380 edl->session->plugins_follow_edits,
381 edl->session->autos_follow_edits);
385 void MWindow::set_automation_mode(int mode)
387 undo->update_undo_before();
388 edl->tracks->set_automation_mode(
389 edl->local_session->get_selectionstart(),
390 edl->local_session->get_selectionend(),
393 char string[BCSTRLEN];
394 sprintf(string,"set %s", FloatAuto::curve_name(mode));
395 undo->update_undo_after(string, LOAD_AUTOMATION);
398 update_plugin_guis();
399 gui->draw_overlays(1);
400 sync_parameters(CHANGE_PARAMS);
401 gui->update_patchbay();
402 cwindow->update(1, 0, 0);
405 void MWindow::clear_automation()
407 undo->update_undo_before();
408 edl->tracks->clear_automation(edl->local_session->get_selectionstart(),
409 edl->local_session->get_selectionend());
411 undo->update_undo_after(_("clear keyframes"), LOAD_AUTOMATION);
414 update_plugin_guis();
415 gui->draw_overlays(1);
416 sync_parameters(CHANGE_PARAMS);
417 gui->update_patchbay();
418 cwindow->update(1, 0, 0);
421 int MWindow::clear_default_keyframe()
423 undo->update_undo_before();
424 edl->tracks->clear_default_keyframe();
426 undo->update_undo_after(_("clear default keyframe"), LOAD_AUTOMATION);
429 gui->draw_overlays(1);
430 sync_parameters(CHANGE_PARAMS);
431 gui->update_patchbay();
432 cwindow->update(1, 0, 0);
437 void MWindow::clear_labels()
439 undo->update_undo_before();
440 clear_labels(edl->local_session->get_selectionstart(),
441 edl->local_session->get_selectionend());
442 undo->update_undo_after(_("clear labels"), LOAD_TIMEBAR);
444 gui->update_timebar(1);
445 cwindow->update(0, 0, 0, 0, 1);
449 int MWindow::clear_labels(double start, double end)
451 edl->labels->clear(start, end, 0);
455 void MWindow::concatenate_tracks()
457 undo->update_undo_before();
458 edl->tracks->concatenate_tracks(edl->session->plugins_follow_edits,
459 edl->session->autos_follow_edits);
461 undo->update_undo_after(_("concatenate tracks"), LOAD_EDITS);
464 gui->update(1, 1, 0, 0, 1, 0, 0);
465 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
474 copy(edl->local_session->get_selectionstart(),
475 edl->local_session->get_selectionend());
478 int MWindow::copy(double start, double end)
480 if(start == end) return 1;
482 //printf("MWindow::copy 1\n");
484 //printf("MWindow::copy 1\n");
493 //printf("MWindow::copy 1\n");
495 // File is now terminated and rewound
497 //printf("MWindow::copy 1\n");
498 const char *file_string = file.string();
499 long file_length = strlen(file_string);
500 gui->get_clipboard()->to_clipboard(file_string, file_length,
501 SECONDARY_SELECTION);
502 gui->get_clipboard()->to_clipboard(file_string, file_length,
503 BC_PRIMARY_SELECTION);
504 //printf("MWindow::copy\n%s\n", file.string);
505 //printf("MWindow::copy 2\n");
510 int MWindow::copy_automation()
513 edl->tracks->copy_automation(edl->local_session->get_selectionstart(),
514 edl->local_session->get_selectionend(),
518 const char *file_string = file.string();
519 long file_length = strlen(file_string);
520 gui->get_clipboard()->to_clipboard(file_string, file_length,
521 BC_PRIMARY_SELECTION);
522 gui->get_clipboard()->to_clipboard(file_string, file_length,
523 SECONDARY_SELECTION);
527 int MWindow::copy_default_keyframe()
530 edl->tracks->copy_automation(edl->local_session->get_selectionstart(),
531 edl->local_session->get_selectionend(),
535 const char *file_string = file.string();
536 long file_length = strlen(file_string);
537 gui->get_clipboard()->to_clipboard(file_string, file_length,
538 BC_PRIMARY_SELECTION);
539 gui->get_clipboard()->to_clipboard(file_string, file_length,
540 SECONDARY_SELECTION);
545 // Uses cropping coordinates in edl session to crop and translate video.
546 // We modify the projector since camera automation depends on the track size.
547 void MWindow::crop_video()
550 undo->update_undo_before();
551 // Clamp EDL crop region
552 if(edl->session->crop_x1 > edl->session->crop_x2)
554 edl->session->crop_x1 ^= edl->session->crop_x2;
555 edl->session->crop_x2 ^= edl->session->crop_x1;
556 edl->session->crop_x1 ^= edl->session->crop_x2;
558 if(edl->session->crop_y1 > edl->session->crop_y2)
560 edl->session->crop_y1 ^= edl->session->crop_y2;
561 edl->session->crop_y2 ^= edl->session->crop_y1;
562 edl->session->crop_y1 ^= edl->session->crop_y2;
565 float old_projector_x = (float)edl->session->output_w / 2;
566 float old_projector_y = (float)edl->session->output_h / 2;
567 float new_projector_x = (float)(edl->session->crop_x1 + edl->session->crop_x2) / 2;
568 float new_projector_y = (float)(edl->session->crop_y1 + edl->session->crop_y2) / 2;
569 float projector_offset_x = -(new_projector_x - old_projector_x);
570 float projector_offset_y = -(new_projector_y - old_projector_y);
572 edl->tracks->translate_projector(projector_offset_x, projector_offset_y);
574 edl->session->output_w = edl->session->crop_x2 - edl->session->crop_x1;
575 edl->session->output_h = edl->session->crop_y2 - edl->session->crop_y1;
576 edl->session->crop_x1 = 0;
577 edl->session->crop_y1 = 0;
578 edl->session->crop_x2 = edl->session->output_w;
579 edl->session->crop_y2 = edl->session->output_h;
581 // Recalculate aspect ratio
582 if(defaults->get("AUTOASPECT", 0))
584 create_aspect_ratio(edl->session->aspect_w,
585 edl->session->aspect_h,
586 edl->session->output_w,
587 edl->session->output_h);
590 undo->update_undo_after(_("crop"), LOAD_ALL);
593 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
602 undo->update_undo_before();
604 double start = edl->local_session->get_selectionstart();
605 double end = edl->local_session->get_selectionend();
610 edl->session->labels_follow_edits,
611 edl->session->plugins_follow_edits,
612 edl->session->autos_follow_edits);
617 undo->update_undo_after(_("cut"), LOAD_EDITS | LOAD_TIMEBAR);
620 update_plugin_guis();
621 gui->update(1, 2, 1, 1, 1, 1, 0);
622 cwindow->update(1, 0, 0, 0, 1);
623 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
629 int MWindow::cut_automation()
631 undo->update_undo_before();
635 edl->tracks->clear_automation(edl->local_session->get_selectionstart(),
636 edl->local_session->get_selectionend());
638 undo->update_undo_after(_("cut keyframes"), LOAD_AUTOMATION);
642 update_plugin_guis();
643 gui->draw_overlays(1);
644 sync_parameters(CHANGE_PARAMS);
645 gui->update_patchbay();
646 cwindow->update(1, 0, 0);
650 int MWindow::cut_default_keyframe()
653 undo->update_undo_before();
654 copy_default_keyframe();
655 edl->tracks->clear_default_keyframe();
656 undo->update_undo_after(_("cut default keyframe"), LOAD_AUTOMATION);
659 gui->draw_overlays(1);
660 sync_parameters(CHANGE_PARAMS);
661 gui->update_patchbay();
662 cwindow->update(1, 0, 0);
670 void MWindow::delete_inpoint()
672 edl->local_session->unset_inpoint();
676 void MWindow::delete_outpoint()
678 edl->local_session->unset_outpoint();
683 void MWindow::delete_track()
685 if (edl->tracks->last)
686 delete_track(edl->tracks->last);
689 void MWindow::delete_tracks()
691 undo->update_undo_before();
692 edl->tracks->delete_tracks();
693 undo->update_undo_after(_("delete tracks"), LOAD_ALL);
697 update_plugin_states();
699 gui->update(1, 1, 1, 0, 1, 0, 0);
700 cwindow->playback_engine->que->
701 send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);
704 void MWindow::delete_track(Track *track)
706 undo->update_undo_before();
707 edl->tracks->delete_track(track);
708 undo->update_undo_after(_("delete track"), LOAD_ALL);
711 update_plugin_states();
713 gui->update(1, 1, 1, 0, 1, 0, 0);
714 cwindow->playback_engine->que->
715 send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);
720 // Insert data from clipboard
721 void MWindow::insert(double position,
728 // For clipboard pasting make the new edl use a separate session
729 // from the master EDL. Then it can be resampled to the master rates.
730 // For splice, overwrite, and dragging need same session to get the assets.
731 EDL *edl = new EDL(parent_edl);
732 ArrayList<EDL*> new_edls;
733 uint32_t load_flags = LOAD_ALL;
736 new_edls.append(edl);
737 edl->create_objects();
742 if(parent_edl) load_flags &= ~LOAD_SESSION;
743 if(!edl->session->autos_follow_edits) load_flags &= ~LOAD_AUTOMATION;
744 if(!edl->session->labels_follow_edits) load_flags &= ~LOAD_TIMEBAR;
746 edl->load_xml(file, load_flags);
749 //printf("MWindow::insert %f\n", edl->local_session->clipboard_length);
753 paste_edls(&new_edls,
762 // printf("MWindow::insert 5 %f %f\n",
763 // vwindow->edl->local_session->in_point,
764 // vwindow->edl->local_session->out_point);
765 new_edls.remove_all();
766 edl->Garbage::remove_user();
767 //printf("MWindow::insert 6 %p\n", vwindow->get_edl());
770 void MWindow::insert_effects_canvas(double start,
773 Track *dest_track = session->track_highlighted;
774 if(!dest_track) return;
776 undo->update_undo_before();
778 for(int i = 0; i < session->drag_pluginservers->total; i++)
780 PluginServer *plugin = session->drag_pluginservers->values[i];
782 insert_effect(plugin->title,
785 i == 0 ? session->pluginset_highlighted : 0,
792 undo->update_undo_after(_("insert effect"), LOAD_EDITS | LOAD_PATCHES);
794 sync_parameters(CHANGE_EDL);
795 // GUI updated in TrackCanvas, after current_operations are reset
798 void MWindow::insert_effects_cwindow(Track *dest_track)
800 if(!dest_track) return;
802 undo->update_undo_before();
805 double length = dest_track->get_length();
807 if(edl->local_session->get_selectionend() >
808 edl->local_session->get_selectionstart())
810 start = edl->local_session->get_selectionstart();
811 length = edl->local_session->get_selectionend() -
812 edl->local_session->get_selectionstart();
815 for(int i = 0; i < session->drag_pluginservers->total; i++)
817 PluginServer *plugin = session->drag_pluginservers->values[i];
820 insert_effect(plugin->title,
830 undo->update_undo_after(_("insert effect"), LOAD_EDITS | LOAD_PATCHES);
832 sync_parameters(CHANGE_EDL);
842 void MWindow::insert_effect(char *title,
843 SharedLocation *shared_location,
846 int single_standalone)
848 Track *current = edl->tracks->first;
849 SharedLocation shared_location_local;
850 shared_location_local.copy_from(shared_location);
852 for( ; current; current = NEXT)
854 if(current->data_type == data_type &&
858 &shared_location_local,
867 if(plugin_type == PLUGIN_STANDALONE && single_standalone)
869 plugin_type = PLUGIN_SHAREDPLUGIN;
870 shared_location_local.module = edl->tracks->number_of(current);
871 shared_location_local.plugin = current->plugin_set.total - 1;
880 void MWindow::insert_effect(char *title,
881 SharedLocation *shared_location,
883 PluginSet *plugin_set,
888 KeyFrame *default_keyframe = 0;
889 PluginServer *server = 0;
896 // Get default keyframe
897 if(plugin_type == PLUGIN_STANDALONE)
899 default_keyframe = new KeyFrame;
900 server = new PluginServer(*scan_plugindb(title, track->data_type));
902 server->open_plugin(0, preferences, edl, 0);
903 server->save_data(default_keyframe);
908 // Insert plugin object
909 track->insert_effect(title,
920 if(plugin_type == PLUGIN_STANDALONE)
922 server->close_plugin();
924 delete default_keyframe;
928 int MWindow::modify_edithandles()
930 undo->update_undo_before();
931 edl->modify_edithandles(session->drag_start,
932 session->drag_position,
933 session->drag_handle,
934 edl->session->edit_handle_mode[session->drag_button],
935 edl->session->labels_follow_edits,
936 edl->session->plugins_follow_edits,
937 edl->session->autos_follow_edits);
939 finish_modify_handles();
942 //printf("MWindow::modify_handles 1\n");
946 int MWindow::modify_pluginhandles()
948 undo->update_undo_before();
950 edl->modify_pluginhandles(session->drag_start,
951 session->drag_position,
952 session->drag_handle,
953 edl->session->edit_handle_mode[session->drag_button],
954 edl->session->labels_follow_edits,
955 edl->session->autos_follow_edits,
956 session->trim_edits);
958 finish_modify_handles();
964 // Common to edithandles and plugin handles
965 void MWindow::finish_modify_handles()
967 int edit_mode = edl->session->edit_handle_mode[session->drag_button];
969 if((session->drag_handle == 1 && edit_mode != MOVE_NO_EDITS) ||
970 (session->drag_handle == 0 && edit_mode == MOVE_ONE_EDIT))
972 edl->local_session->set_selectionstart(session->drag_position);
973 edl->local_session->set_selectionend(session->drag_position);
976 if(edit_mode != MOVE_NO_EDITS)
978 edl->local_session->set_selectionstart(session->drag_start);
979 edl->local_session->set_selectionend(session->drag_start);
982 if(edl->local_session->get_selectionstart(1) < 0)
984 edl->local_session->set_selectionstart(0);
985 edl->local_session->set_selectionend(0);
987 undo->update_undo_after(_("drag handle"), LOAD_EDITS | LOAD_TIMEBAR);
991 sync_parameters(CHANGE_EDL);
992 update_plugin_guis();
993 gui->update(1, 2, 1, 1, 1, 1, 0);
994 cwindow->update(1, 0, 0, 0, 1);
997 void MWindow::match_output_size(Track *track)
999 undo->update_undo_before();
1000 track->track_w = edl->session->output_w;
1001 track->track_h = edl->session->output_h;
1003 undo->update_undo_after(_("match output size"), LOAD_ALL);
1006 sync_parameters(CHANGE_EDL);
1010 void MWindow::move_edits(ArrayList<Edit*> *edits,
1015 undo->update_undo_before();
1017 edl->tracks->move_edits(edits,
1020 edl->session->labels_follow_edits,
1021 edl->session->plugins_follow_edits,
1022 edl->session->autos_follow_edits,
1026 undo->update_undo_after(_("move edit"), LOAD_ALL);
1029 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1034 update_plugin_guis();
1036 1, // 1 for incremental drawing. 2 for full refresh
1044 void MWindow::move_effect(Plugin *plugin, Track *track, int64_t position)
1046 undo->update_undo_before();
1047 edl->tracks->move_effect(plugin, track, position);
1049 undo->update_undo_after(_("paste effect"), LOAD_ALL);
1052 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1053 CHANGE_EDL, edl, 1);
1055 update_plugin_guis();
1056 gui->update(1, 1, // 1 for incremental drawing. 2 for full refresh
1060 void MWindow::move_effect(Plugin *plugin, PluginSet *plugin_set, int64_t position)
1062 undo->update_undo_before();
1063 edl->tracks->move_effect(plugin, plugin_set, position);
1065 undo->update_undo_after(_("move effect"), LOAD_ALL);
1068 cwindow->playback_engine->que->send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);
1069 update_plugin_guis();
1070 gui->update(1, 1, // 1 for incremental drawing. 2 for full refresh
1074 void MWindow::move_plugins_up(PluginSet *plugin_set)
1077 undo->update_undo_before();
1078 plugin_set->track->move_plugins_up(plugin_set);
1081 undo->update_undo_after(_("move effect up"), LOAD_ALL);
1084 1, // 1 for incremental drawing. 2 for full refresh
1090 sync_parameters(CHANGE_EDL);
1093 void MWindow::move_plugins_down(PluginSet *plugin_set)
1095 undo->update_undo_before();
1097 plugin_set->track->move_plugins_down(plugin_set);
1100 undo->update_undo_after(_("move effect down"), LOAD_ALL);
1103 1, // 1 for incremental drawing. 2 for full refresh
1109 sync_parameters(CHANGE_EDL);
1112 void MWindow::move_track_down(Track *track)
1114 undo->update_undo_before();
1115 edl->tracks->move_track_down(track);
1117 undo->update_undo_after(_("move track down"), LOAD_ALL);
1120 gui->update(1, 1, 0, 0, 1, 0, 0);
1121 sync_parameters(CHANGE_EDL);
1125 void MWindow::move_tracks_down()
1127 undo->update_undo_before();
1128 edl->tracks->move_tracks_down();
1130 undo->update_undo_after(_("move tracks down"), LOAD_ALL);
1133 gui->update(1, 1, 0, 0, 1, 0, 0);
1134 sync_parameters(CHANGE_EDL);
1138 void MWindow::move_track_up(Track *track)
1140 undo->update_undo_before();
1141 edl->tracks->move_track_up(track);
1143 undo->update_undo_after(_("move track up"), LOAD_ALL);
1145 gui->update(1, 1, 0, 0, 1, 0, 0);
1146 sync_parameters(CHANGE_EDL);
1150 void MWindow::move_tracks_up()
1152 undo->update_undo_before();
1153 edl->tracks->move_tracks_up();
1155 undo->update_undo_after(_("move tracks up"), LOAD_ALL);
1157 gui->update(1, 1, 0, 0, 1, 0, 0);
1158 sync_parameters(CHANGE_EDL);
1162 void MWindow::mute_selection()
1164 double start = edl->local_session->get_selectionstart();
1165 double end = edl->local_session->get_selectionend();
1168 undo->update_undo_before();
1172 edl->session->plugins_follow_edits,
1173 edl->session->autos_follow_edits);
1174 edl->local_session->set_selectionend(end);
1175 edl->local_session->set_selectionstart(start);
1176 edl->paste_silence(start,
1179 edl->session->plugins_follow_edits,
1180 edl->session->autos_follow_edits);
1182 undo->update_undo_after(_("mute"), LOAD_EDITS);
1185 update_plugin_guis();
1186 gui->update(1, 2, 1, 1, 1, 1, 0);
1187 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1196 void MWindow::overwrite(EDL *source)
1200 double src_start = source->local_session->get_selectionstart();
1201 double overwrite_len = source->local_session->get_selectionend() - src_start;
1202 double dst_start = edl->local_session->get_selectionstart();
1203 double dst_len = edl->local_session->get_selectionend() - dst_start;
1205 undo->update_undo_before();
1206 if (!EQUIV(dst_len, 0) && (dst_len < overwrite_len))
1208 // in/out points or selection present and shorter than overwrite range
1209 // shorten the copy range
1210 overwrite_len = dst_len;
1213 source->copy(src_start,
1214 src_start + overwrite_len,
1222 // HACK around paste_edl get_start/endselection on its own
1223 // so we need to clear only when not using both io points
1224 // FIXME: need to write simple overwrite_edl to be used for overwrite function
1225 if (edl->local_session->get_inpoint() < 0 ||
1226 edl->local_session->get_outpoint() < 0)
1227 edl->clear(dst_start,
1228 dst_start + overwrite_len,
1234 dst_start + overwrite_len,
1240 edl->local_session->set_selectionstart(dst_start + overwrite_len);
1241 edl->local_session->set_selectionend(dst_start + overwrite_len);
1244 undo->update_undo_after(_("overwrite"), LOAD_EDITS);
1247 update_plugin_guis();
1248 gui->update(1, 1, 1, 1, 0, 1, 0);
1249 sync_parameters(CHANGE_EDL);
1252 // For splice and overwrite
1253 int MWindow::paste(double start,
1262 // Want to insert with assets shared with the master EDL.
1273 // For editing using insertion point
1274 void MWindow::paste()
1276 double start = edl->local_session->get_selectionstart();
1277 //double end = edl->local_session->get_selectionend();
1278 int64_t len = gui->get_clipboard()->clipboard_len(SECONDARY_SELECTION);
1282 char *string = new char[len + 1];
1284 undo->update_undo_before();
1287 gui->get_clipboard()->from_clipboard(string,
1289 BC_PRIMARY_SELECTION);
1291 file.read_from_string(string);
1300 edl->session->labels_follow_edits,
1301 edl->session->plugins_follow_edits,
1302 edl->session->autos_follow_edits,
1315 undo->update_undo_after(_("paste"), LOAD_EDITS | LOAD_TIMEBAR);
1317 update_plugin_guis();
1318 gui->update(1, 2, 1, 1, 0, 1, 0);
1319 awindow->gui->async_update_assets();
1320 sync_parameters(CHANGE_EDL);
1325 int MWindow::paste_assets(double position, Track *dest_track, int overwrite)
1329 undo->update_undo_before();
1333 if(session->drag_assets->total)
1335 load_assets(session->drag_assets,
1340 edl->session->labels_follow_edits,
1341 edl->session->plugins_follow_edits,
1342 edl->session->autos_follow_edits,
1348 if(session->drag_clips->total)
1350 paste_edls(session->drag_clips,
1354 edl->session->labels_follow_edits,
1355 edl->session->plugins_follow_edits,
1356 edl->session->autos_follow_edits,
1364 undo->update_undo_after(_("paste assets"), LOAD_EDITS);
1373 sync_parameters(CHANGE_EDL);
1377 void MWindow::load_assets(ArrayList<Indexable*> *new_assets,
1381 RecordLabels *labels,
1387 const int debug = 0;
1388 if(debug) printf("MWindow::load_assets %d\n", __LINE__);
1389 if(position < 0) position = edl->local_session->get_selectionstart();
1391 ArrayList<EDL*> new_edls;
1392 for(int i = 0; i < new_assets->total; i++)
1394 Indexable *indexable = new_assets->get(i);
1395 if(indexable->is_asset)
1397 remove_asset_from_caches((Asset*)indexable);
1399 EDL *new_edl = new EDL;
1400 new_edl->create_objects();
1401 new_edl->copy_session(edl);
1402 new_edls.append(new_edl);
1405 if(indexable->is_asset)
1407 if(debug) printf("MWindow::load_assets %d\n", __LINE__);
1408 if(debug) ((Asset*)indexable)->dump();
1409 asset_to_edl(new_edl, (Asset*)indexable);
1412 edl_to_nested(new_edl, (EDL*)indexable);
1413 if(debug) printf("MWindow::load_assets %d\n", __LINE__);
1418 for(RecordLabel *label = labels->first; label; label = label->next)
1420 new_edl->labels->toggle_label(label->position, label->position);
1424 if(debug) printf("MWindow::load_assets %d\n", __LINE__);
1426 paste_edls(&new_edls,
1434 if(debug) printf("MWindow::load_assets %d\n", __LINE__);
1438 for(int i = 0; i < new_edls.size(); i++)
1439 new_edls.get(i)->Garbage::remove_user();
1441 if(debug) printf("MWindow::load_assets %d\n", __LINE__);
1444 int MWindow::paste_automation()
1446 int64_t len = gui->get_clipboard()->clipboard_len(SECONDARY_SELECTION);
1450 undo->update_undo_before();
1451 char *string = new char[len + 1];
1452 gui->get_clipboard()->from_clipboard(string,
1454 BC_PRIMARY_SELECTION);
1456 file.read_from_string(string);
1458 edl->tracks->clear_automation(edl->local_session->get_selectionstart(),
1459 edl->local_session->get_selectionend());
1460 edl->tracks->paste_automation(edl->local_session->get_selectionstart(),
1464 edl->session->typeless_keyframes);
1466 undo->update_undo_after(_("paste keyframes"), LOAD_AUTOMATION);
1471 update_plugin_guis();
1472 gui->draw_overlays(1);
1473 sync_parameters(CHANGE_PARAMS);
1474 gui->update_patchbay();
1475 cwindow->update(1, 0, 0);
1481 int MWindow::paste_default_keyframe()
1483 int64_t len = gui->get_clipboard()->clipboard_len(SECONDARY_SELECTION);
1487 undo->update_undo_before();
1488 char *string = new char[len + 1];
1489 gui->get_clipboard()->from_clipboard(string,
1491 BC_PRIMARY_SELECTION);
1493 file.read_from_string(string);
1494 edl->tracks->paste_automation(edl->local_session->get_selectionstart(),
1498 edl->session->typeless_keyframes);
1499 // edl->tracks->paste_default_keyframe(&file);
1500 undo->update_undo_after(_("paste default keyframe"), LOAD_AUTOMATION);
1504 update_plugin_guis();
1505 gui->draw_overlays(1);
1506 sync_parameters(CHANGE_PARAMS);
1507 gui->update_patchbay();
1508 cwindow->update(1, 0, 0);
1517 // Insert edls with project deletion and index file generation.
1518 int MWindow::paste_edls(ArrayList<EDL*> *new_edls,
1521 double current_position,
1528 ArrayList<Track*> destination_tracks;
1529 int need_new_tracks = 0;
1532 if(!new_edls->total) return 0;
1535 // double original_length = edl->tracks->total_playable_length();
1536 // double original_preview_end = edl->local_session->preview_end;
1539 // Delete current project
1540 if(load_mode == LOADMODE_REPLACE ||
1541 load_mode == LOADMODE_REPLACE_CONCATENATE)
1545 edl->save_defaults(defaults);
1549 edl->Garbage::remove_user();
1553 edl->create_objects();
1555 edl->copy_session(new_edls->values[0]);
1557 gui->mainmenu->update_toggles(0);
1560 gui->unlock_window();
1562 gwindow->gui->update_toggles(1);
1564 gui->lock_window("MWindow::paste_edls");
1567 // Insert labels for certain modes constitutively
1571 // Force reset of preview
1572 // original_length = 0;
1573 // original_preview_end = -1;
1579 // Create new tracks in master EDL
1580 if(load_mode == LOADMODE_REPLACE ||
1581 load_mode == LOADMODE_REPLACE_CONCATENATE ||
1582 load_mode == LOADMODE_NEW_TRACKS)
1585 need_new_tracks = 1;
1586 for(int i = 0; i < new_edls->total; i++)
1588 EDL *new_edl = new_edls->values[i];
1589 for(Track *current = new_edl->tracks->first;
1593 if(current->data_type == TRACK_VIDEO)
1595 edl->tracks->add_video_track(0, 0);
1596 if(current->draw) edl->tracks->last->draw = 1;
1597 destination_tracks.append(edl->tracks->last);
1600 if(current->data_type == TRACK_AUDIO)
1602 edl->tracks->add_audio_track(0, 0);
1603 destination_tracks.append(edl->tracks->last);
1606 if(current->data_type == TRACK_SUBTITLE)
1608 edl->tracks->add_subttl_track(0, 0);
1609 destination_tracks.append(edl->tracks->last);
1611 edl->session->highlighted_track = edl->tracks->total() - 1;
1614 // Base track count on first EDL only for concatenation
1615 if(load_mode == LOADMODE_REPLACE_CONCATENATE) break;
1620 // Recycle existing tracks of master EDL
1621 if(load_mode == LOADMODE_CONCATENATE ||
1622 load_mode == LOADMODE_PASTE ||
1623 load_mode == LOADMODE_NESTED)
1627 // The point of this is to shift forward labels after the selection so they can
1628 // then be shifted back to their original locations without recursively
1629 // shifting back every paste.
1630 if((load_mode == LOADMODE_PASTE ||
1631 load_mode == LOADMODE_NESTED) &&
1632 edl->session->labels_follow_edits)
1633 edl->labels->clear(edl->local_session->get_selectionstart(),
1634 edl->local_session->get_selectionend(),
1637 Track *current = first_track ? first_track : edl->tracks->first;
1638 for( ; current; current = NEXT)
1642 destination_tracks.append(current);
1653 int destination_track = 0;
1654 double *paste_position = new double[destination_tracks.total];
1660 // Iterate through the edls
1661 for(int i = 0; i < new_edls->total; i++)
1664 EDL *new_edl = new_edls->values[i];
1665 double edl_length = new_edl->local_session->clipboard_length ?
1666 new_edl->local_session->clipboard_length :
1667 new_edl->tracks->total_length();
1668 // printf("MWindow::paste_edls 2 %f %f\n",
1669 // new_edl->local_session->clipboard_length,
1670 // new_edl->tracks->total_length());
1677 // Convert EDL to master rates
1678 new_edl->resample(new_edl->session->sample_rate,
1679 edl->session->sample_rate,
1681 new_edl->resample(new_edl->session->frame_rate,
1682 edl->session->frame_rate,
1689 // Add assets and prepare index files
1690 for(Asset *new_asset = new_edl->assets->first;
1692 new_asset = new_asset->next)
1694 mainindexes->add_next_asset(0, new_asset);
1696 // Capture index file status from mainindex test
1697 edl->update_assets(new_edl);
1702 // Get starting point of insertion. Need this to paste labels.
1705 case LOADMODE_REPLACE:
1706 case LOADMODE_NEW_TRACKS:
1707 current_position = 0;
1710 case LOADMODE_CONCATENATE:
1711 case LOADMODE_REPLACE_CONCATENATE:
1712 destination_track = 0;
1713 if(destination_tracks.total)
1714 current_position = destination_tracks.values[0]->get_length();
1716 current_position = 0;
1719 case LOADMODE_PASTE:
1720 case LOADMODE_NESTED:
1721 destination_track = 0;
1724 for(int j = 0; j < destination_tracks.total; j++)
1726 paste_position[j] = (current_position >= 0) ?
1728 edl->local_session->get_selectionstart();
1733 case LOADMODE_RESOURCESONLY:
1734 edl->add_clip(new_edl);
1744 if(load_mode != LOADMODE_RESOURCESONLY)
1747 //printf("MWindow::paste_edls %f %f\n", current_position, edl_length);
1748 if(load_mode == LOADMODE_PASTE ||
1749 load_mode == LOADMODE_NESTED)
1750 edl->labels->insert_labels(new_edl->labels,
1751 destination_tracks.total ? paste_position[0] : 0.0,
1755 edl->labels->insert_labels(new_edl->labels,
1761 for(Track *new_track = new_edl->tracks->first;
1763 new_track = new_track->next)
1765 // Get destination track of same type as new_track
1767 k < destination_tracks.total &&
1768 destination_tracks.values[destination_track]->data_type != new_track->data_type;
1769 k++, destination_track++)
1771 if(destination_track >= destination_tracks.total - 1)
1772 destination_track = 0;
1775 // Insert data into destination track
1776 if(destination_track < destination_tracks.total &&
1777 destination_tracks.values[destination_track]->data_type == new_track->data_type)
1779 Track *track = destination_tracks.values[destination_track];
1781 // Replace default keyframes if first EDL and new tracks were created.
1782 // This means data copied from one track and pasted to another won't retain
1783 // the camera position unless it's a keyframe. If it did, previous data in the
1784 // track might get unknowingly corrupted. Ideally we would detect when differing
1785 // default keyframes existed and create discrete keyframes for both.
1786 int replace_default = (i == 0) && need_new_tracks;
1788 //printf("MWindow::paste_edls 1 %d\n", replace_default);
1789 // Insert new track at current position
1792 case LOADMODE_REPLACE_CONCATENATE:
1793 case LOADMODE_CONCATENATE:
1794 current_position = track->get_length();
1797 case LOADMODE_PASTE:
1798 case LOADMODE_NESTED:
1799 current_position = paste_position[destination_track];
1800 paste_position[destination_track] += new_track->get_length();
1804 track->clear(current_position,
1805 current_position + new_track->get_length(),
1815 track->insert_track(new_track,
1824 // Get next destination track
1825 destination_track++;
1826 if(destination_track >= destination_tracks.total)
1827 destination_track = 0;
1831 if(load_mode == LOADMODE_PASTE ||
1832 load_mode == LOADMODE_NESTED)
1833 current_position += edl_length;
1837 // Move loading of clips and vwindow to the end - this fixes some
1838 // strange issue, for index not being shown
1839 // Assume any paste operation from the same EDL won't contain any clips.
1840 // If it did it would duplicate every clip here.
1841 for(int i = 0; i < new_edls->total; i++)
1843 EDL *new_edl = new_edls->values[i];
1845 for(int j = 0; j < new_edl->clips.total; j++)
1847 edl->add_clip(new_edl->clips.values[j]);
1850 if(new_edl->total_vwindow_edls())
1852 // if(edl->vwindow_edl)
1853 // edl->vwindow_edl->Garbage::remove_user();
1854 // edl->vwindow_edl = new EDL(edl);
1855 // edl->vwindow_edl->create_objects();
1856 // edl->vwindow_edl->copy_all(new_edl->vwindow_edl);
1858 for(int j = 0; j < new_edl->total_vwindow_edls(); j++)
1860 EDL *vwindow_edl = new EDL(edl);
1861 vwindow_edl->create_objects();
1862 vwindow_edl->copy_all(new_edl->get_vwindow_edl(j));
1863 edl->append_vwindow_edl(vwindow_edl, 0);
1869 if(paste_position) delete [] paste_position;
1872 // This is already done in load_filenames and everything else that uses paste_edls
1873 // update_project(load_mode);
1875 // Fix preview range
1876 // if(EQUIV(original_length, original_preview_end))
1878 // edl->local_session->preview_end = edl->tracks->total_playable_length();
1882 // Start examining next batch of index files
1883 mainindexes->start_build();
1886 // Don't save a backup after loading since the loaded file is on disk already.
1893 void MWindow::paste_silence()
1895 double start = edl->local_session->get_selectionstart();
1896 double end = edl->local_session->get_selectionend();
1897 undo->update_undo_before();
1898 edl->paste_silence(start,
1900 edl->session->labels_follow_edits,
1901 edl->session->plugins_follow_edits,
1902 edl->session->autos_follow_edits);
1905 undo->update_undo_after(_("silence"), LOAD_EDITS | LOAD_TIMEBAR);
1907 update_plugin_guis();
1909 gui->update(1, 2, 1, 1, 1, 1, 0);
1910 cwindow->update(1, 0, 0, 0, 1);
1911 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1917 void MWindow::detach_transition(Transition *transition)
1919 undo->update_undo_before();
1920 hide_plugin(transition, 1);
1921 int is_video = (transition->edit->track->data_type == TRACK_VIDEO);
1922 transition->edit->detach_transition();
1924 undo->update_undo_after(_("detach transition"), LOAD_ALL);
1926 if(is_video) restart_brender();
1934 sync_parameters(CHANGE_EDL);
1937 void MWindow::detach_transitions()
1939 gui->lock_window("MWindow::detach_transitions 1");
1941 undo->update_undo_before();
1942 double start = edl->local_session->get_selectionstart();
1943 double end = edl->local_session->get_selectionend();
1944 edl->tracks->clear_transitions(start, end);
1947 undo->update_undo_after(_("detach transitions"), LOAD_EDITS);
1949 sync_parameters(CHANGE_EDL);
1950 gui->update(0, 1, 0, 0, 0, 0, 0);
1951 gui->unlock_window();
1954 void MWindow::paste_transition()
1956 // Only the first transition gets dropped.
1957 PluginServer *server = session->drag_pluginservers->values[0];
1959 undo->update_undo_before();
1961 strcpy(edl->session->default_atransition, server->title);
1963 strcpy(edl->session->default_vtransition, server->title);
1965 edl->tracks->paste_transition(server, session->edit_highlighted);
1967 undo->update_undo_after(_("transition"), LOAD_EDITS);
1969 if(server->video) restart_brender();
1970 sync_parameters(CHANGE_ALL);
1973 void MWindow::paste_transitions(int track_type, char *title)
1975 gui->lock_window("MWindow::detach_transitions 1");
1977 undo->update_undo_before();
1978 double start = edl->local_session->get_selectionstart();
1979 double end = edl->local_session->get_selectionend();
1980 edl->tracks->paste_transitions(start, end, track_type, title);
1983 undo->update_undo_after(_("attach transitions"), LOAD_EDITS);
1985 sync_parameters(CHANGE_EDL);
1986 gui->update(0, 1, 0, 0, 0, 0, 0);
1987 gui->unlock_window();
1990 void MWindow::paste_transition_cwindow(Track *dest_track)
1992 PluginServer *server = session->drag_pluginservers->values[0];
1993 undo->update_undo_before();
1994 edl->tracks->paste_video_transition(server, 1);
1996 undo->update_undo_after(_("transition"), LOAD_EDITS);
1998 gui->update(0, 1, 0, 0, 0, 0, 0);
1999 sync_parameters(CHANGE_ALL);
2002 void MWindow::paste_audio_transition()
2004 PluginServer *server = scan_plugindb(edl->session->default_atransition,
2008 char string[BCTEXTLEN];
2009 sprintf(string, _("No default transition %s found."), edl->session->default_atransition);
2010 gui->show_message(string);
2014 undo->update_undo_before();
2015 edl->tracks->paste_audio_transition(server);
2017 undo->update_undo_after(_("transition"), LOAD_EDITS);
2019 sync_parameters(CHANGE_EDL);
2020 gui->update(0, 1, 0, 0, 0, 0, 0);
2023 void MWindow::paste_video_transition()
2025 PluginServer *server = scan_plugindb(edl->session->default_vtransition,
2029 char string[BCTEXTLEN];
2030 sprintf(string, _("No default transition %s found."), edl->session->default_vtransition);
2031 gui->show_message(string);
2035 undo->update_undo_before();
2037 edl->tracks->paste_video_transition(server);
2039 undo->update_undo_after(_("transition"), LOAD_EDITS);
2041 sync_parameters(CHANGE_EDL);
2043 gui->update(0, 1, 0, 0, 0, 0, 0);
2046 void MWindow::shuffle_edits()
2048 gui->lock_window("MWindow::shuffle_edits 1");
2050 undo->update_undo_before();
2051 double start = edl->local_session->get_selectionstart();
2052 double end = edl->local_session->get_selectionend();
2054 edl->tracks->shuffle_edits(start, end);
2057 undo->update_undo_after(_("shuffle edits"), LOAD_EDITS | LOAD_TIMEBAR);
2059 sync_parameters(CHANGE_EDL);
2061 gui->update(0, 1, 1, 0, 0, 0, 0);
2062 gui->unlock_window();
2065 void MWindow::reverse_edits()
2067 gui->lock_window("MWindow::reverse_edits 1");
2069 undo->update_undo_before();
2070 double start = edl->local_session->get_selectionstart();
2071 double end = edl->local_session->get_selectionend();
2073 edl->tracks->reverse_edits(start, end);
2076 undo->update_undo_after(_("reverse edits"), LOAD_EDITS | LOAD_TIMEBAR);
2078 sync_parameters(CHANGE_EDL);
2080 gui->update(0, 1, 1, 0, 0, 0, 0);
2081 gui->unlock_window();
2084 void MWindow::align_edits()
2086 gui->lock_window("MWindow::align_edits 1");
2088 undo->update_undo_before();
2089 double start = edl->local_session->get_selectionstart();
2090 double end = edl->local_session->get_selectionend();
2092 edl->tracks->align_edits(start, end);
2095 undo->update_undo_after(_("align edits"), LOAD_EDITS | LOAD_TIMEBAR);
2097 sync_parameters(CHANGE_EDL);
2099 gui->update(0, 1, 1, 0, 0, 0, 0);
2100 gui->unlock_window();
2103 void MWindow::set_edit_length(double length)
2105 gui->lock_window("MWindow::detach_transitions 1");
2107 undo->update_undo_before();
2108 double start = edl->local_session->get_selectionstart();
2109 double end = edl->local_session->get_selectionend();
2111 edl->tracks->set_edit_length(start, end, length);
2114 undo->update_undo_after(_("edit length"), LOAD_EDITS | LOAD_TIMEBAR);
2116 sync_parameters(CHANGE_EDL);
2118 gui->update(0, 1, 1, 0, 0, 0, 0);
2119 gui->unlock_window();
2123 void MWindow::set_transition_length(Transition *transition, double length)
2125 gui->lock_window("MWindow::detach_transitions 1");
2127 undo->update_undo_before();
2128 //double start = edl->local_session->get_selectionstart();
2129 //double end = edl->local_session->get_selectionend();
2131 edl->tracks->set_transition_length(transition, length);
2134 undo->update_undo_after(_("transition length"), LOAD_EDITS);
2136 edl->session->default_transition_length = length;
2137 sync_parameters(CHANGE_PARAMS);
2138 gui->update(0, 1, 0, 0, 0, 0, 0);
2139 gui->unlock_window();
2142 void MWindow::set_transition_length(double length)
2144 gui->lock_window("MWindow::detach_transitions 1");
2146 undo->update_undo_before();
2147 double start = edl->local_session->get_selectionstart();
2148 double end = edl->local_session->get_selectionend();
2150 edl->tracks->set_transition_length(start, end, length);
2153 undo->update_undo_after(_("transition length"), LOAD_EDITS);
2155 edl->session->default_transition_length = length;
2156 sync_parameters(CHANGE_PARAMS);
2158 gui->update(0, 1, 0, 0, 0, 0, 0);
2159 gui->unlock_window();
2163 void MWindow::redo_entry(BC_WindowBase *calling_window_gui)
2166 calling_window_gui->unlock_window();
2168 cwindow->playback_engine->que->send_command(STOP,
2172 cwindow->playback_engine->interrupt_playback(0);
2174 for(int i = 0; i < vwindows.size(); i++)
2176 if(vwindows.get(i)->is_running())
2178 vwindows.get(i)->playback_engine->que->send_command(STOP,
2182 vwindows.get(i)->playback_engine->interrupt_playback(0);
2186 cwindow->gui->lock_window("MWindow::redo_entry");
2187 for(int i = 0; i < vwindows.size(); i++)
2189 if(vwindows.get(i)->is_running())
2191 if (calling_window_gui != vwindows.get(i)->gui)
2193 vwindows.get(i)->gui->lock_window("MWindow::redo_entry 2");
2202 update_plugin_states();
2203 update_plugin_guis();
2205 gui->update(1, 2, 1, 1, 1, 1, 1);
2206 cwindow->update(1, 1, 1, 1, 1);
2208 if (calling_window_gui != cwindow->gui)
2209 cwindow->gui->unlock_window();
2210 if (calling_window_gui != gui)
2211 gui->unlock_window();
2214 for(int i = 0; i < vwindows.size(); i++)
2216 if(vwindows.get(i)->is_running())
2218 if (calling_window_gui != vwindows.get(i)->gui)
2220 vwindows.get(i)->gui->unlock_window();
2225 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
2233 void MWindow::resize_track(Track *track, int w, int h)
2235 undo->update_undo_before();
2236 // We have to move all maskpoints so they do not move in relation to image areas
2237 ((MaskAutos*)track->automation->autos[AUTOMATION_MASK])->translate_masks(
2238 (w - track->track_w) / 2,
2239 (h - track->track_h) / 2);
2242 undo->update_undo_after(_("resize track"), LOAD_ALL);
2246 sync_parameters(CHANGE_EDL);
2250 void MWindow::set_inpoint(int is_mwindow)
2252 undo->update_undo_before();
2253 edl->set_inpoint(edl->local_session->get_selectionstart(1));
2255 undo->update_undo_after(_("in point"), LOAD_TIMEBAR);
2259 gui->lock_window("MWindow::set_inpoint 1");
2261 gui->update_timebar(1);
2264 gui->unlock_window();
2269 cwindow->gui->lock_window("MWindow::set_inpoint 2");
2271 cwindow->gui->timebar->update(1);
2274 cwindow->gui->unlock_window();
2278 void MWindow::set_outpoint(int is_mwindow)
2280 undo->update_undo_before();
2281 edl->set_outpoint(edl->local_session->get_selectionend(1));
2283 undo->update_undo_after(_("out point"), LOAD_TIMEBAR);
2287 gui->lock_window("MWindow::set_outpoint 1");
2289 gui->update_timebar(1);
2292 gui->unlock_window();
2297 cwindow->gui->lock_window("MWindow::set_outpoint 2");
2299 cwindow->gui->timebar->update(1);
2302 cwindow->gui->unlock_window();
2306 void MWindow::splice(EDL *source)
2310 undo->update_undo_before();
2311 source->copy(source->local_session->get_selectionstart(),
2312 source->local_session->get_selectionend(),
2323 double start = edl->local_session->get_selectionstart();
2324 //double end = edl->local_session->get_selectionend();
2325 double source_start = source->local_session->get_selectionstart();
2326 double source_end = source->local_session->get_selectionend();
2331 edl->session->labels_follow_edits,
2332 edl->session->plugins_follow_edits,
2333 edl->session->autos_follow_edits);
2335 // Position at end of clip
2336 edl->local_session->set_selectionstart(start +
2339 edl->local_session->set_selectionend(start +
2344 undo->update_undo_after(_("splice"), LOAD_EDITS | LOAD_TIMEBAR);
2345 update_plugin_guis();
2347 gui->update(1, 1, 1, 1, 0, 1, 0);
2348 sync_parameters(CHANGE_EDL);
2351 void MWindow::to_clip()
2356 gui->lock_window("MWindow::to_clip 1");
2357 start = edl->local_session->get_selectionstart();
2358 end = edl->local_session->get_selectionend();
2360 if(EQUIV(end, start))
2363 end = edl->tracks->total_length();
2366 // Don't copy all since we don't want the clips twice.
2377 EDL *new_edl = new EDL(edl);
2378 new_edl->create_objects();
2379 new_edl->load_xml(&file, LOAD_ALL);
2380 sprintf(new_edl->local_session->clip_title, _("Clip %d"), session->clip_number++);
2381 char string[BCTEXTLEN];
2382 Units::totext(string,
2384 edl->session->time_format,
2385 edl->session->sample_rate,
2386 edl->session->frame_rate,
2387 edl->session->frames_per_foot);
2389 sprintf(new_edl->local_session->clip_notes, _("%s\nCreated from main window"), string);
2391 new_edl->local_session->set_selectionstart(0);
2392 new_edl->local_session->set_selectionend(0);
2394 gui->unlock_window();
2396 awindow->clip_edit->create_clip(new_edl);
2398 gui->lock_window("MWindow::to_clip 2");
2400 gui->unlock_window();
2403 int MWindow::toggle_label(int is_mwindow)
2405 double position1, position2;
2406 undo->update_undo_before();
2408 if(cwindow->playback_engine->is_playing_back)
2410 position1 = position2 =
2411 cwindow->playback_engine->get_tracking_position();
2415 position1 = edl->local_session->get_selectionstart(1);
2416 position2 = edl->local_session->get_selectionend(1);
2419 position1 = edl->align_to_frame(position1, 0);
2420 position2 = edl->align_to_frame(position2, 0);
2422 //printf("MWindow::toggle_label 1\n");
2424 edl->labels->toggle_label(position1, position2);
2429 gui->lock_window("MWindow::toggle_label 1");
2431 gui->update_timebar(0);
2432 gui->activate_timeline();
2436 gui->unlock_window();
2441 cwindow->gui->lock_window("MWindow::toggle_label 2");
2443 cwindow->gui->timebar->update(1);
2446 cwindow->gui->unlock_window();
2449 undo->update_undo_after(_("label"), LOAD_TIMEBAR);
2453 void MWindow::trim_selection()
2455 undo->update_undo_before();
2458 edl->trim_selection(edl->local_session->get_selectionstart(),
2459 edl->local_session->get_selectionend(),
2460 edl->session->labels_follow_edits,
2461 edl->session->plugins_follow_edits,
2462 edl->session->autos_follow_edits);
2465 undo->update_undo_after(_("trim selection"), LOAD_EDITS | LOAD_TIMEBAR);
2466 update_plugin_guis();
2467 gui->update(1, 2, 1, 1, 1, 1, 0);
2468 cwindow->update(1, 0, 0, 0, 1);
2470 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
2478 void MWindow::undo_entry(BC_WindowBase *calling_window_gui)
2480 calling_window_gui->unlock_window();
2482 cwindow->playback_engine->que->send_command(STOP,
2486 cwindow->playback_engine->interrupt_playback(0);
2488 //printf("MWindow::undo_entry %d %d\n", __LINE__, vwindows.size());
2489 for(int i = 0; i < vwindows.size(); i++)
2491 if(vwindows.get(i)->is_running())
2493 vwindows.get(i)->playback_engine->que->send_command(STOP,
2497 vwindows.get(i)->playback_engine->interrupt_playback(0);
2501 cwindow->gui->lock_window("MWindow::undo_entry 1");
2502 for(int i = 0; i < vwindows.size(); i++)
2504 if(vwindows.get(i)->is_running())
2506 if (calling_window_gui != vwindows.get(i)->gui)
2508 vwindows.get(i)->gui->lock_window("MWindow::undo_entry 4");
2512 gui->lock_window("MWindow::undo_entry 2");
2518 update_plugin_states();
2519 update_plugin_guis();
2523 gui->update(1, 2, 1, 1, 1, 1, 1);
2525 gui->unlock_window();
2527 cwindow->update(1, 1, 1, 1, 1);
2529 cwindow->gui->unlock_window();
2531 for(int i = 0; i < vwindows.size(); i++)
2533 if(vwindows.get(i)->is_running())
2535 if (calling_window_gui != vwindows.get(i)->gui)
2537 vwindows.get(i)->gui->unlock_window();
2542 if (calling_window_gui != gui)
2543 gui->unlock_window();
2546 awindow->gui->async_update_assets();
2548 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
2552 calling_window_gui->lock_window("MWindow::undo_entry 4");
2557 void MWindow::new_folder(const char *new_folder)
2559 undo->update_undo_before();
2560 edl->new_folder(new_folder);
2561 undo->update_undo_after(_("new folder"), LOAD_ALL);
2562 awindow->gui->async_update_assets();
2565 void MWindow::delete_folder(char *folder)
2567 // undo->update_undo_after(_("delete folder"), LOAD_ALL);
2570 void MWindow::select_point(double position)
2572 edl->local_session->set_selectionstart(position);
2573 edl->local_session->set_selectionend(position);
2576 cwindow->update(1, 0, 0, 0, 1);
2579 update_plugin_guis();
2580 gui->update_patchbay();
2581 gui->hide_cursor(0);
2582 gui->draw_cursor(0);
2583 gui->mainclock->update(edl->local_session->get_selectionstart(1));
2584 gui->zoombar->update();
2585 gui->update_timebar(0);
2586 gui->flash_canvas(0);
2593 void MWindow::map_audio(int pattern)
2595 undo->update_undo_before();
2596 remap_audio(pattern);
2597 undo->update_undo_after(
2598 pattern == MWindow::AUDIO_1_TO_1 ? _("map 1:1") : _("map 5.1:2"),
2600 sync_parameters(CHANGE_PARAMS);
2601 gui->update(0, 1, 0, 0, 1, 0, 0);
2604 void MWindow::remap_audio(int pattern)
2606 int current_channel = 0;
2607 int current_track = 0;
2608 for(Track *current = edl->tracks->first; current; current = NEXT)
2610 if(current->data_type == TRACK_AUDIO &&
2613 Autos *pan_autos = current->automation->autos[AUTOMATION_PAN];
2614 PanAuto *pan_auto = (PanAuto*)pan_autos->get_auto_for_editing(-1);
2616 for(int i = 0; i < MAXCHANNELS; i++)
2618 pan_auto->values[i] = 0.0;
2621 if(pattern == MWindow::AUDIO_1_TO_1)
2623 pan_auto->values[current_channel] = 1.0;
2626 if(pattern == MWindow::AUDIO_5_1_TO_2)
2628 switch(current_track)
2631 pan_auto->values[0] = 0.5;
2632 pan_auto->values[1] = 0.5;
2635 pan_auto->values[0] = 1;
2638 pan_auto->values[1] = 1;
2641 pan_auto->values[0] = 1;
2644 pan_auto->values[1] = 1;
2647 pan_auto->values[0] = 0.5;
2648 pan_auto->values[1] = 0.5;
2653 BC_Pan::calculate_stick_position(edl->session->audio_channels,
2654 edl->session->achannel_positions,
2659 pan_auto->handle_y);
2663 if(current_channel >= edl->session->audio_channels)
2664 current_channel = 0;
2669 void MWindow::cut_commercials()
2671 undo->update_undo_before();
2672 commercials->scan_media();
2675 undo->update_undo_after(_("cut ads"), LOAD_EDITS | LOAD_TIMEBAR);
2678 update_plugin_guis();
2679 gui->update(1, 2, 1, 1, 1, 1, 0);
2680 cwindow->update(1, 0, 0, 0, 1);
2681 cwindow->playback_engine->que->
2682 send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);