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);
131 gui->activate_timeline();
132 // gui->get_scrollbars(0);
133 // gui->canvas->draw();
134 // gui->patchbay->update();
135 // gui->cursor->draw(1);
136 // gui->canvas->flash();
137 // gui->canvas->activate();
138 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
145 void MWindow::add_subttl_track_entry(Track *dst)
147 undo->update_undo_before();
148 add_subttl_track(1, dst);
149 undo->update_undo_after(_("add track"), LOAD_ALL);
152 // gui->get_scrollbars(0);
153 // gui->canvas->draw();
154 // gui->patchbay->update();
155 // gui->cursor->draw(1);
156 // gui->canvas->flash();
157 // gui->canvas->activate();
158 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
166 int MWindow::add_audio_track(int above, Track *dst)
168 edl->tracks->add_audio_track(above, dst);
169 edl->tracks->update_y_pixels(theme);
174 int MWindow::add_video_track(int above, Track *dst)
176 edl->tracks->add_video_track(above, dst);
177 edl->tracks->update_y_pixels(theme);
182 int MWindow::add_subttl_track(int above, Track *dst)
184 edl->tracks->add_subttl_track(above, dst);
185 edl->tracks->update_y_pixels(theme);
193 void MWindow::asset_to_all()
195 if(!session->drag_assets->size()) return;
196 Indexable *indexable = session->drag_assets->get(0);
198 // if(indexable->have_video())
202 undo->update_undo_before();
205 w = indexable->get_w();
206 h = indexable->get_h();
207 double new_framerate = session->drag_assets->get(0)->get_frame_rate();
208 double old_framerate = edl->session->frame_rate;
209 int old_samplerate = edl->session->sample_rate;
210 int new_samplerate = session->drag_assets->get(0)->get_sample_rate();
213 if(indexable->have_video())
215 edl->session->output_w = w;
216 edl->session->output_h = h;
217 edl->session->frame_rate = new_framerate;
218 create_aspect_ratio(edl->session->aspect_w,
219 edl->session->aspect_h,
223 for(Track *current = edl->tracks->first;
227 if(current->data_type == TRACK_VIDEO /* &&
230 current->track_w = w;
231 current->track_h = h;
236 if(((edl->session->output_w % 4) ||
237 (edl->session->output_h % 4)) &&
238 edl->session->playback_config->vconfig->driver == PLAYBACK_X11_GL)
240 MainError::show_error(
241 _("This project's dimensions are not multiples of 4 so\n"
242 "it can't be rendered by OpenGL."));
247 if(defaults->get("AUTOASPECT", 0))
249 create_aspect_ratio(edl->session->aspect_w,
250 edl->session->aspect_h,
256 if(indexable->have_audio())
258 edl->session->sample_rate = new_samplerate;
259 edl->resample(old_framerate, new_framerate, TRACK_VIDEO);
260 edl->resample(old_samplerate, new_samplerate, TRACK_AUDIO);
266 undo->update_undo_after(_("asset to all"), LOAD_ALL);
275 sync_parameters(CHANGE_ALL);
284 void MWindow::asset_to_size()
286 if(!session->drag_assets->size()) return;
287 Indexable *indexable = session->drag_assets->get(0);
289 if(indexable->have_video())
292 undo->update_undo_before();
295 w = indexable->get_w();
296 h = indexable->get_h();
299 edl->session->output_w = w;
300 edl->session->output_h = h;
302 if(((edl->session->output_w % 4) ||
303 (edl->session->output_h % 4)) &&
304 edl->session->playback_config->vconfig->driver == PLAYBACK_X11_GL)
306 MainError::show_error(
307 _("This project's dimensions are not multiples of 4 so\n"
308 "it can't be rendered by OpenGL."));
313 if(defaults->get("AUTOASPECT", 0))
315 create_aspect_ratio(edl->session->aspect_w,
316 edl->session->aspect_h,
323 undo->update_undo_after(_("asset to size"), LOAD_ALL);
325 sync_parameters(CHANGE_ALL);
330 void MWindow::asset_to_rate()
332 if(session->drag_assets->size() &&
333 session->drag_assets->get(0)->have_video())
335 double new_framerate = session->drag_assets->get(0)->get_frame_rate();
336 double old_framerate = edl->session->frame_rate;
337 undo->update_undo_before();
339 edl->session->frame_rate = new_framerate;
340 edl->resample(old_framerate, new_framerate, TRACK_VIDEO);
344 undo->update_undo_after(_("asset to rate"), LOAD_ALL);
353 sync_parameters(CHANGE_ALL);
359 void MWindow::clear_entry()
361 undo->update_undo_before();
366 undo->update_undo_after(_("clear"), LOAD_EDITS | LOAD_TIMEBAR);
369 update_plugin_guis();
370 gui->update(1, 2, 1, 1, 1, 1, 0);
371 cwindow->update(1, 0, 0, 0, 1);
372 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
378 void MWindow::clear(int clear_handle)
380 double start = edl->local_session->get_selectionstart();
381 double end = edl->local_session->get_selectionend();
382 if(clear_handle || !EQUIV(start, end))
386 edl->session->labels_follow_edits,
387 edl->session->plugins_follow_edits,
388 edl->session->autos_follow_edits);
392 void MWindow::set_automation_mode(int mode)
394 undo->update_undo_before();
395 edl->tracks->set_automation_mode(
396 edl->local_session->get_selectionstart(),
397 edl->local_session->get_selectionend(),
400 char string[BCSTRLEN];
401 sprintf(string,"set %s", FloatAuto::curve_name(mode));
402 undo->update_undo_after(string, LOAD_AUTOMATION);
405 update_plugin_guis();
406 gui->draw_overlays(1);
407 sync_parameters(CHANGE_PARAMS);
408 gui->update_patchbay();
409 cwindow->update(1, 0, 0);
412 void MWindow::clear_automation()
414 undo->update_undo_before();
415 edl->tracks->clear_automation(edl->local_session->get_selectionstart(),
416 edl->local_session->get_selectionend());
418 undo->update_undo_after(_("clear keyframes"), LOAD_AUTOMATION);
421 update_plugin_guis();
422 gui->draw_overlays(1);
423 sync_parameters(CHANGE_PARAMS);
424 gui->update_patchbay();
425 cwindow->update(1, 0, 0);
428 int MWindow::clear_default_keyframe()
430 undo->update_undo_before();
431 edl->tracks->clear_default_keyframe();
433 undo->update_undo_after(_("clear default keyframe"), LOAD_AUTOMATION);
436 gui->draw_overlays(1);
437 sync_parameters(CHANGE_PARAMS);
438 gui->update_patchbay();
439 cwindow->update(1, 0, 0);
444 void MWindow::clear_labels()
446 undo->update_undo_before();
447 clear_labels(edl->local_session->get_selectionstart(),
448 edl->local_session->get_selectionend());
449 undo->update_undo_after(_("clear labels"), LOAD_TIMEBAR);
451 gui->update_timebar(1);
452 cwindow->update(0, 0, 0, 0, 1);
456 int MWindow::clear_labels(double start, double end)
458 edl->labels->clear(start, end, 0);
462 void MWindow::concatenate_tracks()
464 undo->update_undo_before();
465 edl->tracks->concatenate_tracks(edl->session->plugins_follow_edits,
466 edl->session->autos_follow_edits);
468 undo->update_undo_after(_("concatenate tracks"), LOAD_EDITS);
471 gui->update(1, 1, 0, 0, 1, 0, 0);
472 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
481 copy(edl->local_session->get_selectionstart(),
482 edl->local_session->get_selectionend());
485 int MWindow::copy(double start, double end)
487 if(start == end) return 1;
489 //printf("MWindow::copy 1\n");
491 //printf("MWindow::copy 1\n");
500 //printf("MWindow::copy 1\n");
502 // File is now terminated and rewound
504 //printf("MWindow::copy 1\n");
505 const char *file_string = file.string();
506 long file_length = strlen(file_string);
507 gui->get_clipboard()->to_clipboard(file_string, file_length,
508 SECONDARY_SELECTION);
509 gui->get_clipboard()->to_clipboard(file_string, file_length,
510 BC_PRIMARY_SELECTION);
511 //printf("MWindow::copy\n%s\n", file.string);
512 //printf("MWindow::copy 2\n");
517 int MWindow::copy_automation()
520 edl->tracks->copy_automation(edl->local_session->get_selectionstart(),
521 edl->local_session->get_selectionend(),
525 const char *file_string = file.string();
526 long file_length = strlen(file_string);
527 gui->get_clipboard()->to_clipboard(file_string, file_length,
528 BC_PRIMARY_SELECTION);
529 gui->get_clipboard()->to_clipboard(file_string, file_length,
530 SECONDARY_SELECTION);
534 int MWindow::copy_default_keyframe()
537 edl->tracks->copy_automation(edl->local_session->get_selectionstart(),
538 edl->local_session->get_selectionend(),
542 const char *file_string = file.string();
543 long file_length = strlen(file_string);
544 gui->get_clipboard()->to_clipboard(file_string, file_length,
545 BC_PRIMARY_SELECTION);
546 gui->get_clipboard()->to_clipboard(file_string, file_length,
547 SECONDARY_SELECTION);
552 // Uses cropping coordinates in edl session to crop and translate video.
553 // We modify the projector since camera automation depends on the track size.
554 void MWindow::crop_video()
557 undo->update_undo_before();
558 // Clamp EDL crop region
559 if(edl->session->crop_x1 > edl->session->crop_x2)
561 edl->session->crop_x1 ^= edl->session->crop_x2;
562 edl->session->crop_x2 ^= edl->session->crop_x1;
563 edl->session->crop_x1 ^= edl->session->crop_x2;
565 if(edl->session->crop_y1 > edl->session->crop_y2)
567 edl->session->crop_y1 ^= edl->session->crop_y2;
568 edl->session->crop_y2 ^= edl->session->crop_y1;
569 edl->session->crop_y1 ^= edl->session->crop_y2;
572 float old_projector_x = (float)edl->session->output_w / 2;
573 float old_projector_y = (float)edl->session->output_h / 2;
574 float new_projector_x = (float)(edl->session->crop_x1 + edl->session->crop_x2) / 2;
575 float new_projector_y = (float)(edl->session->crop_y1 + edl->session->crop_y2) / 2;
576 float projector_offset_x = -(new_projector_x - old_projector_x);
577 float projector_offset_y = -(new_projector_y - old_projector_y);
579 edl->tracks->translate_projector(projector_offset_x, projector_offset_y);
581 edl->session->output_w = edl->session->crop_x2 - edl->session->crop_x1;
582 edl->session->output_h = edl->session->crop_y2 - edl->session->crop_y1;
583 edl->session->crop_x1 = 0;
584 edl->session->crop_y1 = 0;
585 edl->session->crop_x2 = edl->session->output_w;
586 edl->session->crop_y2 = edl->session->output_h;
588 // Recalculate aspect ratio
589 if(defaults->get("AUTOASPECT", 0))
591 create_aspect_ratio(edl->session->aspect_w,
592 edl->session->aspect_h,
593 edl->session->output_w,
594 edl->session->output_h);
597 undo->update_undo_after(_("crop"), LOAD_ALL);
600 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
609 undo->update_undo_before();
611 double start = edl->local_session->get_selectionstart();
612 double end = edl->local_session->get_selectionend();
617 edl->session->labels_follow_edits,
618 edl->session->plugins_follow_edits,
619 edl->session->autos_follow_edits);
624 undo->update_undo_after(_("cut"), LOAD_EDITS | LOAD_TIMEBAR);
627 update_plugin_guis();
628 gui->update(1, 2, 1, 1, 1, 1, 0);
629 cwindow->update(1, 0, 0, 0, 1);
630 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
636 int MWindow::cut_automation()
638 undo->update_undo_before();
642 edl->tracks->clear_automation(edl->local_session->get_selectionstart(),
643 edl->local_session->get_selectionend());
645 undo->update_undo_after(_("cut keyframes"), LOAD_AUTOMATION);
649 update_plugin_guis();
650 gui->draw_overlays(1);
651 sync_parameters(CHANGE_PARAMS);
652 gui->update_patchbay();
653 cwindow->update(1, 0, 0);
657 int MWindow::cut_default_keyframe()
660 undo->update_undo_before();
661 copy_default_keyframe();
662 edl->tracks->clear_default_keyframe();
663 undo->update_undo_after(_("cut default keyframe"), LOAD_AUTOMATION);
666 gui->draw_overlays(1);
667 sync_parameters(CHANGE_PARAMS);
668 gui->update_patchbay();
669 cwindow->update(1, 0, 0);
676 void MWindow::delete_inpoint()
678 edl->local_session->unset_inpoint();
682 void MWindow::delete_outpoint()
684 edl->local_session->unset_outpoint();
688 void MWindow::delete_track()
690 if (edl->tracks->last)
691 delete_track(edl->tracks->last);
694 void MWindow::delete_tracks()
696 undo->update_undo_before();
697 edl->tracks->delete_tracks();
698 undo->update_undo_after(_("delete tracks"), LOAD_ALL);
702 update_plugin_states();
703 gui->update(1, 1, 1, 0, 1, 0, 0);
704 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
710 void MWindow::delete_track(Track *track)
712 undo->update_undo_before();
713 edl->tracks->delete_track(track);
714 undo->update_undo_after(_("delete track"), LOAD_ALL);
717 update_plugin_states();
718 gui->update(1, 1, 1, 0, 1, 0, 0);
719 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
730 // Insert data from clipboard
731 void MWindow::insert(double position,
738 // For clipboard pasting make the new edl use a separate session
739 // from the master EDL. Then it can be resampled to the master rates.
740 // For splice, overwrite, and dragging need same session to get the assets.
741 EDL *edl = new EDL(parent_edl);
742 ArrayList<EDL*> new_edls;
743 uint32_t load_flags = LOAD_ALL;
746 new_edls.append(edl);
747 edl->create_objects();
752 if(parent_edl) load_flags &= ~LOAD_SESSION;
753 if(!edl->session->autos_follow_edits) load_flags &= ~LOAD_AUTOMATION;
754 if(!edl->session->labels_follow_edits) load_flags &= ~LOAD_TIMEBAR;
756 edl->load_xml(file, load_flags);
759 //printf("MWindow::insert %f\n", edl->local_session->clipboard_length);
763 paste_edls(&new_edls,
772 // printf("MWindow::insert 5 %f %f\n",
773 // vwindow->edl->local_session->in_point,
774 // vwindow->edl->local_session->out_point);
775 new_edls.remove_all();
776 edl->Garbage::remove_user();
777 //printf("MWindow::insert 6 %p\n", vwindow->get_edl());
780 void MWindow::insert_effects_canvas(double start,
783 Track *dest_track = session->track_highlighted;
784 if(!dest_track) return;
786 undo->update_undo_before();
788 for(int i = 0; i < session->drag_pluginservers->total; i++)
790 PluginServer *plugin = session->drag_pluginservers->values[i];
792 insert_effect(plugin->title,
795 i == 0 ? session->pluginset_highlighted : 0,
802 undo->update_undo_after(_("insert effect"), LOAD_EDITS | LOAD_PATCHES);
804 sync_parameters(CHANGE_EDL);
805 // GUI updated in TrackCanvas, after current_operations are reset
808 void MWindow::insert_effects_cwindow(Track *dest_track)
810 if(!dest_track) return;
812 undo->update_undo_before();
815 double length = dest_track->get_length();
817 if(edl->local_session->get_selectionend() >
818 edl->local_session->get_selectionstart())
820 start = edl->local_session->get_selectionstart();
821 length = edl->local_session->get_selectionend() -
822 edl->local_session->get_selectionstart();
825 for(int i = 0; i < session->drag_pluginservers->total; i++)
827 PluginServer *plugin = session->drag_pluginservers->values[i];
830 insert_effect(plugin->title,
840 undo->update_undo_after(_("insert effect"), LOAD_EDITS | LOAD_PATCHES);
842 sync_parameters(CHANGE_EDL);
852 void MWindow::insert_effect(char *title,
853 SharedLocation *shared_location,
856 int single_standalone)
858 Track *current = edl->tracks->first;
859 SharedLocation shared_location_local;
860 shared_location_local.copy_from(shared_location);
862 for( ; current; current = NEXT)
864 if(current->data_type == data_type &&
868 &shared_location_local,
877 if(plugin_type == PLUGIN_STANDALONE && single_standalone)
879 plugin_type = PLUGIN_SHAREDPLUGIN;
880 shared_location_local.module = edl->tracks->number_of(current);
881 shared_location_local.plugin = current->plugin_set.total - 1;
890 void MWindow::insert_effect(char *title,
891 SharedLocation *shared_location,
893 PluginSet *plugin_set,
898 KeyFrame *default_keyframe = 0;
899 PluginServer *server = 0;
906 // Get default keyframe
907 if(plugin_type == PLUGIN_STANDALONE)
909 default_keyframe = new KeyFrame;
910 server = new PluginServer(*scan_plugindb(title, track->data_type));
912 server->open_plugin(0, preferences, edl, 0);
913 server->save_data(default_keyframe);
918 // Insert plugin object
919 track->insert_effect(title,
930 if(plugin_type == PLUGIN_STANDALONE)
932 server->close_plugin();
934 delete default_keyframe;
938 int MWindow::modify_edithandles()
940 undo->update_undo_before();
941 edl->modify_edithandles(session->drag_start,
942 session->drag_position,
943 session->drag_handle,
944 edl->session->edit_handle_mode[session->drag_button],
945 edl->session->labels_follow_edits,
946 edl->session->plugins_follow_edits,
947 edl->session->autos_follow_edits);
949 finish_modify_handles();
952 //printf("MWindow::modify_handles 1\n");
956 int MWindow::modify_pluginhandles()
958 undo->update_undo_before();
960 edl->modify_pluginhandles(session->drag_start,
961 session->drag_position,
962 session->drag_handle,
963 edl->session->edit_handle_mode[session->drag_button],
964 edl->session->labels_follow_edits,
965 edl->session->autos_follow_edits,
966 session->trim_edits);
968 finish_modify_handles();
974 // Common to edithandles and plugin handles
975 void MWindow::finish_modify_handles()
977 int edit_mode = edl->session->edit_handle_mode[session->drag_button];
979 if((session->drag_handle == 1 && edit_mode != MOVE_NO_EDITS) ||
980 (session->drag_handle == 0 && edit_mode == MOVE_ONE_EDIT))
982 edl->local_session->set_selectionstart(session->drag_position);
983 edl->local_session->set_selectionend(session->drag_position);
986 if(edit_mode != MOVE_NO_EDITS)
988 edl->local_session->set_selectionstart(session->drag_start);
989 edl->local_session->set_selectionend(session->drag_start);
992 if(edl->local_session->get_selectionstart(1) < 0)
994 edl->local_session->set_selectionstart(0);
995 edl->local_session->set_selectionend(0);
997 undo->update_undo_after(_("drag handle"), LOAD_EDITS | LOAD_TIMEBAR);
1001 sync_parameters(CHANGE_EDL);
1002 update_plugin_guis();
1003 gui->update(1, 2, 1, 1, 1, 1, 0);
1004 cwindow->update(1, 0, 0, 0, 1);
1007 void MWindow::match_output_size(Track *track)
1009 undo->update_undo_before();
1010 track->track_w = edl->session->output_w;
1011 track->track_h = edl->session->output_h;
1013 undo->update_undo_after(_("match output size"), LOAD_ALL);
1016 sync_parameters(CHANGE_EDL);
1020 void MWindow::move_edits(ArrayList<Edit*> *edits,
1025 undo->update_undo_before();
1027 edl->tracks->move_edits(edits,
1030 edl->session->labels_follow_edits,
1031 edl->session->plugins_follow_edits,
1032 edl->session->autos_follow_edits,
1036 undo->update_undo_after(_("move edit"), LOAD_ALL);
1039 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1044 update_plugin_guis();
1046 1, // 1 for incremental drawing. 2 for full refresh
1054 void MWindow::move_effect(Plugin *plugin, Track *track, int64_t position)
1056 undo->update_undo_before();
1057 edl->tracks->move_effect(plugin, track, position);
1059 undo->update_undo_after(_("paste effect"), LOAD_ALL);
1062 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1063 CHANGE_EDL, edl, 1);
1065 update_plugin_guis();
1066 gui->update(1, 1, // 1 for incremental drawing. 2 for full refresh
1070 void MWindow::move_effect(Plugin *plugin, PluginSet *plugin_set, int64_t position)
1072 undo->update_undo_before();
1073 edl->tracks->move_effect(plugin, plugin_set, position);
1075 undo->update_undo_after(_("move effect"), LOAD_ALL);
1078 cwindow->playback_engine->que->send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);
1079 update_plugin_guis();
1080 gui->update(1, 1, // 1 for incremental drawing. 2 for full refresh
1084 void MWindow::move_plugins_up(PluginSet *plugin_set)
1087 undo->update_undo_before();
1088 plugin_set->track->move_plugins_up(plugin_set);
1091 undo->update_undo_after(_("move effect up"), LOAD_ALL);
1094 1, // 1 for incremental drawing. 2 for full refresh
1100 sync_parameters(CHANGE_EDL);
1103 void MWindow::move_plugins_down(PluginSet *plugin_set)
1105 undo->update_undo_before();
1107 plugin_set->track->move_plugins_down(plugin_set);
1110 undo->update_undo_after(_("move effect down"), LOAD_ALL);
1113 1, // 1 for incremental drawing. 2 for full refresh
1119 sync_parameters(CHANGE_EDL);
1122 void MWindow::move_track_down(Track *track)
1124 undo->update_undo_before();
1125 edl->tracks->move_track_down(track);
1127 undo->update_undo_after(_("move track down"), LOAD_ALL);
1130 gui->update(1, 1, 0, 0, 1, 0, 0);
1131 sync_parameters(CHANGE_EDL);
1135 void MWindow::move_tracks_down()
1137 undo->update_undo_before();
1138 edl->tracks->move_tracks_down();
1140 undo->update_undo_after(_("move tracks down"), LOAD_ALL);
1143 gui->update(1, 1, 0, 0, 1, 0, 0);
1144 sync_parameters(CHANGE_EDL);
1148 void MWindow::move_track_up(Track *track)
1150 undo->update_undo_before();
1151 edl->tracks->move_track_up(track);
1153 undo->update_undo_after(_("move track up"), LOAD_ALL);
1155 gui->update(1, 1, 0, 0, 1, 0, 0);
1156 sync_parameters(CHANGE_EDL);
1160 void MWindow::move_tracks_up()
1162 undo->update_undo_before();
1163 edl->tracks->move_tracks_up();
1165 undo->update_undo_after(_("move tracks up"), LOAD_ALL);
1167 gui->update(1, 1, 0, 0, 1, 0, 0);
1168 sync_parameters(CHANGE_EDL);
1172 void MWindow::mute_selection()
1174 double start = edl->local_session->get_selectionstart();
1175 double end = edl->local_session->get_selectionend();
1178 undo->update_undo_before();
1182 edl->session->plugins_follow_edits,
1183 edl->session->autos_follow_edits);
1184 edl->local_session->set_selectionend(end);
1185 edl->local_session->set_selectionstart(start);
1186 edl->paste_silence(start,
1189 edl->session->plugins_follow_edits,
1190 edl->session->autos_follow_edits);
1192 undo->update_undo_after(_("mute"), LOAD_EDITS);
1195 update_plugin_guis();
1196 gui->update(1, 2, 1, 1, 1, 1, 0);
1197 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1206 void MWindow::overwrite(EDL *source)
1210 double src_start = source->local_session->get_selectionstart();
1211 double overwrite_len = source->local_session->get_selectionend() - src_start;
1212 double dst_start = edl->local_session->get_selectionstart();
1213 double dst_len = edl->local_session->get_selectionend() - dst_start;
1215 undo->update_undo_before();
1216 if (!EQUIV(dst_len, 0) && (dst_len < overwrite_len))
1218 // in/out points or selection present and shorter than overwrite range
1219 // shorten the copy range
1220 overwrite_len = dst_len;
1223 source->copy(src_start,
1224 src_start + overwrite_len,
1232 // HACK around paste_edl get_start/endselection on its own
1233 // so we need to clear only when not using both io points
1234 // FIXME: need to write simple overwrite_edl to be used for overwrite function
1235 if (edl->local_session->get_inpoint() < 0 ||
1236 edl->local_session->get_outpoint() < 0)
1237 edl->clear(dst_start,
1238 dst_start + overwrite_len,
1244 dst_start + overwrite_len,
1250 edl->local_session->set_selectionstart(dst_start + overwrite_len);
1251 edl->local_session->set_selectionend(dst_start + overwrite_len);
1254 undo->update_undo_after(_("overwrite"), LOAD_EDITS);
1257 update_plugin_guis();
1258 gui->update(1, 1, 1, 1, 0, 1, 0);
1259 sync_parameters(CHANGE_EDL);
1262 // For splice and overwrite
1263 int MWindow::paste(double start,
1272 // Want to insert with assets shared with the master EDL.
1283 // For editing using insertion point
1284 void MWindow::paste()
1286 double start = edl->local_session->get_selectionstart();
1287 //double end = edl->local_session->get_selectionend();
1288 int64_t len = gui->get_clipboard()->clipboard_len(SECONDARY_SELECTION);
1292 char *string = new char[len + 1];
1294 undo->update_undo_before();
1297 gui->get_clipboard()->from_clipboard(string,
1299 BC_PRIMARY_SELECTION);
1301 file.read_from_string(string);
1310 edl->session->labels_follow_edits,
1311 edl->session->plugins_follow_edits,
1312 edl->session->autos_follow_edits,
1325 undo->update_undo_after(_("paste"), LOAD_EDITS | LOAD_TIMEBAR);
1327 update_plugin_guis();
1328 gui->update(1, 2, 1, 1, 0, 1, 0);
1329 awindow->gui->async_update_assets();
1330 sync_parameters(CHANGE_EDL);
1335 int MWindow::paste_assets(double position, Track *dest_track, int overwrite)
1339 undo->update_undo_before();
1343 if(session->drag_assets->total)
1345 load_assets(session->drag_assets,
1350 edl->session->labels_follow_edits,
1351 edl->session->plugins_follow_edits,
1352 edl->session->autos_follow_edits,
1358 if(session->drag_clips->total)
1360 paste_edls(session->drag_clips,
1364 edl->session->labels_follow_edits,
1365 edl->session->plugins_follow_edits,
1366 edl->session->autos_follow_edits,
1374 undo->update_undo_after(_("paste assets"), LOAD_EDITS);
1383 sync_parameters(CHANGE_EDL);
1387 void MWindow::load_assets(ArrayList<Indexable*> *new_assets,
1391 RecordLabels *labels,
1397 const int debug = 0;
1398 if(debug) printf("MWindow::load_assets %d\n", __LINE__);
1399 if(position < 0) position = edl->local_session->get_selectionstart();
1401 ArrayList<EDL*> new_edls;
1402 for(int i = 0; i < new_assets->total; i++)
1404 Indexable *indexable = new_assets->get(i);
1405 if(indexable->is_asset)
1407 remove_asset_from_caches((Asset*)indexable);
1409 EDL *new_edl = new EDL;
1410 new_edl->create_objects();
1411 new_edl->copy_session(edl);
1412 new_edls.append(new_edl);
1415 if(indexable->is_asset)
1417 if(debug) printf("MWindow::load_assets %d\n", __LINE__);
1418 if(debug) ((Asset*)indexable)->dump();
1419 asset_to_edl(new_edl, (Asset*)indexable);
1422 edl_to_nested(new_edl, (EDL*)indexable);
1423 if(debug) printf("MWindow::load_assets %d\n", __LINE__);
1428 for(RecordLabel *label = labels->first; label; label = label->next)
1430 new_edl->labels->toggle_label(label->position, label->position);
1434 if(debug) printf("MWindow::load_assets %d\n", __LINE__);
1436 paste_edls(&new_edls,
1444 if(debug) printf("MWindow::load_assets %d\n", __LINE__);
1448 for(int i = 0; i < new_edls.size(); i++)
1449 new_edls.get(i)->Garbage::remove_user();
1451 if(debug) printf("MWindow::load_assets %d\n", __LINE__);
1454 int MWindow::paste_automation()
1456 int64_t len = gui->get_clipboard()->clipboard_len(SECONDARY_SELECTION);
1460 undo->update_undo_before();
1461 char *string = new char[len + 1];
1462 gui->get_clipboard()->from_clipboard(string,
1464 BC_PRIMARY_SELECTION);
1466 file.read_from_string(string);
1468 edl->tracks->clear_automation(edl->local_session->get_selectionstart(),
1469 edl->local_session->get_selectionend());
1470 edl->tracks->paste_automation(edl->local_session->get_selectionstart(),
1474 edl->session->typeless_keyframes);
1476 undo->update_undo_after(_("paste keyframes"), LOAD_AUTOMATION);
1481 update_plugin_guis();
1482 gui->draw_overlays(1);
1483 sync_parameters(CHANGE_PARAMS);
1484 gui->update_patchbay();
1485 cwindow->update(1, 0, 0);
1491 int MWindow::paste_default_keyframe()
1493 int64_t len = gui->get_clipboard()->clipboard_len(SECONDARY_SELECTION);
1497 undo->update_undo_before();
1498 char *string = new char[len + 1];
1499 gui->get_clipboard()->from_clipboard(string,
1501 BC_PRIMARY_SELECTION);
1503 file.read_from_string(string);
1504 edl->tracks->paste_automation(edl->local_session->get_selectionstart(),
1508 edl->session->typeless_keyframes);
1509 // edl->tracks->paste_default_keyframe(&file);
1510 undo->update_undo_after(_("paste default keyframe"), LOAD_AUTOMATION);
1514 update_plugin_guis();
1515 gui->draw_overlays(1);
1516 sync_parameters(CHANGE_PARAMS);
1517 gui->update_patchbay();
1518 cwindow->update(1, 0, 0);
1527 // Insert edls with project deletion and index file generation.
1528 int MWindow::paste_edls(ArrayList<EDL*> *new_edls,
1531 double current_position,
1538 ArrayList<Track*> destination_tracks;
1539 int need_new_tracks = 0;
1542 if(!new_edls->total) return 0;
1545 // double original_length = edl->tracks->total_playable_length();
1546 // double original_preview_end = edl->local_session->preview_end;
1549 // Delete current project
1550 if(load_mode == LOADMODE_REPLACE ||
1551 load_mode == LOADMODE_REPLACE_CONCATENATE)
1555 edl->save_defaults(defaults);
1559 edl->Garbage::remove_user();
1563 edl->create_objects();
1565 edl->copy_session(new_edls->values[0]);
1567 gui->mainmenu->update_toggles(0);
1570 gui->unlock_window();
1572 gwindow->gui->update_toggles(1);
1574 gui->lock_window("MWindow::paste_edls");
1577 // Insert labels for certain modes constitutively
1581 // Force reset of preview
1582 // original_length = 0;
1583 // original_preview_end = -1;
1589 // Create new tracks in master EDL
1590 if(load_mode == LOADMODE_REPLACE ||
1591 load_mode == LOADMODE_REPLACE_CONCATENATE ||
1592 load_mode == LOADMODE_NEW_TRACKS)
1595 need_new_tracks = 1;
1596 for(int i = 0; i < new_edls->total; i++)
1598 EDL *new_edl = new_edls->values[i];
1599 for(Track *current = new_edl->tracks->first;
1603 if(current->data_type == TRACK_VIDEO)
1605 edl->tracks->add_video_track(0, 0);
1606 if(current->draw) edl->tracks->last->draw = 1;
1607 destination_tracks.append(edl->tracks->last);
1610 if(current->data_type == TRACK_AUDIO)
1612 edl->tracks->add_audio_track(0, 0);
1613 destination_tracks.append(edl->tracks->last);
1616 if(current->data_type == TRACK_SUBTITLE)
1618 edl->tracks->add_subttl_track(0, 0);
1619 destination_tracks.append(edl->tracks->last);
1621 edl->session->highlighted_track = edl->tracks->total() - 1;
1624 // Base track count on first EDL only for concatenation
1625 if(load_mode == LOADMODE_REPLACE_CONCATENATE) break;
1630 // Recycle existing tracks of master EDL
1631 if(load_mode == LOADMODE_CONCATENATE ||
1632 load_mode == LOADMODE_PASTE ||
1633 load_mode == LOADMODE_NESTED)
1637 // The point of this is to shift forward labels after the selection so they can
1638 // then be shifted back to their original locations without recursively
1639 // shifting back every paste.
1640 if((load_mode == LOADMODE_PASTE ||
1641 load_mode == LOADMODE_NESTED) &&
1642 edl->session->labels_follow_edits)
1643 edl->labels->clear(edl->local_session->get_selectionstart(),
1644 edl->local_session->get_selectionend(),
1647 Track *current = first_track ? first_track : edl->tracks->first;
1648 for( ; current; current = NEXT)
1652 destination_tracks.append(current);
1663 int destination_track = 0;
1664 double *paste_position = new double[destination_tracks.total];
1670 // Iterate through the edls
1671 for(int i = 0; i < new_edls->total; i++)
1674 EDL *new_edl = new_edls->values[i];
1675 double edl_length = new_edl->local_session->clipboard_length ?
1676 new_edl->local_session->clipboard_length :
1677 new_edl->tracks->total_length();
1678 // printf("MWindow::paste_edls 2 %f %f\n",
1679 // new_edl->local_session->clipboard_length,
1680 // new_edl->tracks->total_length());
1687 // Convert EDL to master rates
1688 new_edl->resample(new_edl->session->sample_rate,
1689 edl->session->sample_rate,
1691 new_edl->resample(new_edl->session->frame_rate,
1692 edl->session->frame_rate,
1699 // Add assets and prepare index files
1700 for(Asset *new_asset = new_edl->assets->first;
1702 new_asset = new_asset->next)
1704 mainindexes->add_next_asset(0, new_asset);
1706 // Capture index file status from mainindex test
1707 edl->update_assets(new_edl);
1712 // Get starting point of insertion. Need this to paste labels.
1715 case LOADMODE_REPLACE:
1716 case LOADMODE_NEW_TRACKS:
1717 current_position = 0;
1720 case LOADMODE_CONCATENATE:
1721 case LOADMODE_REPLACE_CONCATENATE:
1722 destination_track = 0;
1723 if(destination_tracks.total)
1724 current_position = destination_tracks.values[0]->get_length();
1726 current_position = 0;
1729 case LOADMODE_PASTE:
1730 case LOADMODE_NESTED:
1731 destination_track = 0;
1734 for(int j = 0; j < destination_tracks.total; j++)
1736 paste_position[j] = (current_position >= 0) ?
1738 edl->local_session->get_selectionstart();
1743 case LOADMODE_RESOURCESONLY:
1744 edl->add_clip(new_edl);
1754 if(load_mode != LOADMODE_RESOURCESONLY)
1757 //printf("MWindow::paste_edls %f %f\n", current_position, edl_length);
1758 if(load_mode == LOADMODE_PASTE ||
1759 load_mode == LOADMODE_NESTED)
1760 edl->labels->insert_labels(new_edl->labels,
1761 destination_tracks.total ? paste_position[0] : 0.0,
1765 edl->labels->insert_labels(new_edl->labels,
1771 for(Track *new_track = new_edl->tracks->first;
1773 new_track = new_track->next)
1775 // Get destination track of same type as new_track
1777 k < destination_tracks.total &&
1778 destination_tracks.values[destination_track]->data_type != new_track->data_type;
1779 k++, destination_track++)
1781 if(destination_track >= destination_tracks.total - 1)
1782 destination_track = 0;
1785 // Insert data into destination track
1786 if(destination_track < destination_tracks.total &&
1787 destination_tracks.values[destination_track]->data_type == new_track->data_type)
1789 Track *track = destination_tracks.values[destination_track];
1791 // Replace default keyframes if first EDL and new tracks were created.
1792 // This means data copied from one track and pasted to another won't retain
1793 // the camera position unless it's a keyframe. If it did, previous data in the
1794 // track might get unknowingly corrupted. Ideally we would detect when differing
1795 // default keyframes existed and create discrete keyframes for both.
1796 int replace_default = (i == 0) && need_new_tracks;
1798 //printf("MWindow::paste_edls 1 %d\n", replace_default);
1799 // Insert new track at current position
1802 case LOADMODE_REPLACE_CONCATENATE:
1803 case LOADMODE_CONCATENATE:
1804 current_position = track->get_length();
1807 case LOADMODE_PASTE:
1808 case LOADMODE_NESTED:
1809 current_position = paste_position[destination_track];
1810 paste_position[destination_track] += new_track->get_length();
1814 track->clear(current_position,
1815 current_position + new_track->get_length(),
1825 track->insert_track(new_track,
1834 // Get next destination track
1835 destination_track++;
1836 if(destination_track >= destination_tracks.total)
1837 destination_track = 0;
1841 if(load_mode == LOADMODE_PASTE ||
1842 load_mode == LOADMODE_NESTED)
1843 current_position += edl_length;
1847 // Move loading of clips and vwindow to the end - this fixes some
1848 // strange issue, for index not being shown
1849 // Assume any paste operation from the same EDL won't contain any clips.
1850 // If it did it would duplicate every clip here.
1851 for(int i = 0; i < new_edls->total; i++)
1853 EDL *new_edl = new_edls->values[i];
1855 for(int j = 0; j < new_edl->clips.total; j++)
1857 edl->add_clip(new_edl->clips.values[j]);
1860 if(new_edl->total_vwindow_edls())
1862 // if(edl->vwindow_edl)
1863 // edl->vwindow_edl->Garbage::remove_user();
1864 // edl->vwindow_edl = new EDL(edl);
1865 // edl->vwindow_edl->create_objects();
1866 // edl->vwindow_edl->copy_all(new_edl->vwindow_edl);
1868 for(int j = 0; j < new_edl->total_vwindow_edls(); j++)
1870 EDL *vwindow_edl = new EDL(edl);
1871 vwindow_edl->create_objects();
1872 vwindow_edl->copy_all(new_edl->get_vwindow_edl(j));
1873 edl->append_vwindow_edl(vwindow_edl, 0);
1879 if(paste_position) delete [] paste_position;
1882 // This is already done in load_filenames and everything else that uses paste_edls
1883 // update_project(load_mode);
1885 // Fix preview range
1886 // if(EQUIV(original_length, original_preview_end))
1888 // edl->local_session->preview_end = edl->tracks->total_playable_length();
1892 // Start examining next batch of index files
1893 mainindexes->start_build();
1896 // Don't save a backup after loading since the loaded file is on disk already.
1903 void MWindow::paste_silence()
1905 double start = edl->local_session->get_selectionstart();
1906 double end = edl->local_session->get_selectionend();
1907 undo->update_undo_before();
1908 edl->paste_silence(start,
1910 edl->session->labels_follow_edits,
1911 edl->session->plugins_follow_edits,
1912 edl->session->autos_follow_edits);
1915 undo->update_undo_after(_("silence"), LOAD_EDITS | LOAD_TIMEBAR);
1917 update_plugin_guis();
1919 gui->update(1, 2, 1, 1, 1, 1, 0);
1920 cwindow->update(1, 0, 0, 0, 1);
1921 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1927 void MWindow::detach_transition(Transition *transition)
1929 undo->update_undo_before();
1930 hide_plugin(transition, 1);
1931 int is_video = (transition->edit->track->data_type == TRACK_VIDEO);
1932 transition->edit->detach_transition();
1934 undo->update_undo_after(_("detach transition"), LOAD_ALL);
1936 if(is_video) restart_brender();
1944 sync_parameters(CHANGE_EDL);
1947 void MWindow::detach_transitions()
1949 gui->lock_window("MWindow::detach_transitions 1");
1951 undo->update_undo_before();
1952 double start = edl->local_session->get_selectionstart();
1953 double end = edl->local_session->get_selectionend();
1954 edl->tracks->clear_transitions(start, end);
1957 undo->update_undo_after(_("detach transitions"), LOAD_EDITS);
1959 sync_parameters(CHANGE_EDL);
1960 gui->update(0, 1, 0, 0, 0, 0, 0);
1961 gui->unlock_window();
1964 void MWindow::paste_transition()
1966 // Only the first transition gets dropped.
1967 PluginServer *server = session->drag_pluginservers->values[0];
1969 undo->update_undo_before();
1971 strcpy(edl->session->default_atransition, server->title);
1973 strcpy(edl->session->default_vtransition, server->title);
1975 edl->tracks->paste_transition(server, session->edit_highlighted);
1977 undo->update_undo_after(_("transition"), LOAD_EDITS);
1979 if(server->video) restart_brender();
1980 sync_parameters(CHANGE_ALL);
1983 void MWindow::paste_transitions(int track_type, char *title)
1985 gui->lock_window("MWindow::detach_transitions 1");
1987 undo->update_undo_before();
1988 double start = edl->local_session->get_selectionstart();
1989 double end = edl->local_session->get_selectionend();
1990 edl->tracks->paste_transitions(start, end, track_type, title);
1993 undo->update_undo_after(_("attach transitions"), LOAD_EDITS);
1995 sync_parameters(CHANGE_EDL);
1996 gui->update(0, 1, 0, 0, 0, 0, 0);
1997 gui->unlock_window();
2000 void MWindow::paste_transition_cwindow(Track *dest_track)
2002 PluginServer *server = session->drag_pluginservers->values[0];
2003 undo->update_undo_before();
2004 edl->tracks->paste_video_transition(server, 1);
2006 undo->update_undo_after(_("transition"), LOAD_EDITS);
2008 gui->update(0, 1, 0, 0, 0, 0, 0);
2009 sync_parameters(CHANGE_ALL);
2012 void MWindow::paste_audio_transition()
2014 PluginServer *server = scan_plugindb(edl->session->default_atransition,
2018 char string[BCTEXTLEN];
2019 sprintf(string, _("No default transition %s found."), edl->session->default_atransition);
2020 gui->show_message(string);
2024 undo->update_undo_before();
2025 edl->tracks->paste_audio_transition(server);
2027 undo->update_undo_after(_("transition"), LOAD_EDITS);
2029 sync_parameters(CHANGE_EDL);
2030 gui->update(0, 1, 0, 0, 0, 0, 0);
2033 void MWindow::paste_video_transition()
2035 PluginServer *server = scan_plugindb(edl->session->default_vtransition,
2039 char string[BCTEXTLEN];
2040 sprintf(string, _("No default transition %s found."), edl->session->default_vtransition);
2041 gui->show_message(string);
2045 undo->update_undo_before();
2047 edl->tracks->paste_video_transition(server);
2049 undo->update_undo_after(_("transition"), LOAD_EDITS);
2051 sync_parameters(CHANGE_EDL);
2053 gui->update(0, 1, 0, 0, 0, 0, 0);
2056 void MWindow::shuffle_edits()
2058 gui->lock_window("MWindow::shuffle_edits 1");
2060 undo->update_undo_before();
2061 double start = edl->local_session->get_selectionstart();
2062 double end = edl->local_session->get_selectionend();
2064 edl->tracks->shuffle_edits(start, end);
2067 undo->update_undo_after(_("shuffle edits"), LOAD_EDITS | LOAD_TIMEBAR);
2069 sync_parameters(CHANGE_EDL);
2071 gui->update(0, 1, 1, 0, 0, 0, 0);
2072 gui->unlock_window();
2075 void MWindow::reverse_edits()
2077 gui->lock_window("MWindow::reverse_edits 1");
2079 undo->update_undo_before();
2080 double start = edl->local_session->get_selectionstart();
2081 double end = edl->local_session->get_selectionend();
2083 edl->tracks->reverse_edits(start, end);
2086 undo->update_undo_after(_("reverse edits"), LOAD_EDITS | LOAD_TIMEBAR);
2088 sync_parameters(CHANGE_EDL);
2090 gui->update(0, 1, 1, 0, 0, 0, 0);
2091 gui->unlock_window();
2094 void MWindow::align_edits()
2096 gui->lock_window("MWindow::align_edits 1");
2098 undo->update_undo_before();
2099 double start = edl->local_session->get_selectionstart();
2100 double end = edl->local_session->get_selectionend();
2102 edl->tracks->align_edits(start, end);
2105 undo->update_undo_after(_("align edits"), LOAD_EDITS | LOAD_TIMEBAR);
2107 sync_parameters(CHANGE_EDL);
2109 gui->update(0, 1, 1, 0, 0, 0, 0);
2110 gui->unlock_window();
2113 void MWindow::set_edit_length(double length)
2115 gui->lock_window("MWindow::detach_transitions 1");
2117 undo->update_undo_before();
2118 double start = edl->local_session->get_selectionstart();
2119 double end = edl->local_session->get_selectionend();
2121 edl->tracks->set_edit_length(start, end, length);
2124 undo->update_undo_after(_("edit length"), LOAD_EDITS | LOAD_TIMEBAR);
2126 sync_parameters(CHANGE_EDL);
2128 gui->update(0, 1, 1, 0, 0, 0, 0);
2129 gui->unlock_window();
2133 void MWindow::set_transition_length(Transition *transition, double length)
2135 gui->lock_window("MWindow::detach_transitions 1");
2137 undo->update_undo_before();
2138 //double start = edl->local_session->get_selectionstart();
2139 //double end = edl->local_session->get_selectionend();
2141 edl->tracks->set_transition_length(transition, length);
2144 undo->update_undo_after(_("transition length"), LOAD_EDITS);
2146 edl->session->default_transition_length = length;
2147 sync_parameters(CHANGE_PARAMS);
2148 gui->update(0, 1, 0, 0, 0, 0, 0);
2149 gui->unlock_window();
2152 void MWindow::set_transition_length(double length)
2154 gui->lock_window("MWindow::detach_transitions 1");
2156 undo->update_undo_before();
2157 double start = edl->local_session->get_selectionstart();
2158 double end = edl->local_session->get_selectionend();
2160 edl->tracks->set_transition_length(start, end, length);
2163 undo->update_undo_after(_("transition length"), LOAD_EDITS);
2165 edl->session->default_transition_length = length;
2166 sync_parameters(CHANGE_PARAMS);
2168 gui->update(0, 1, 0, 0, 0, 0, 0);
2169 gui->unlock_window();
2173 void MWindow::redo_entry(BC_WindowBase *calling_window_gui)
2176 calling_window_gui->unlock_window();
2178 cwindow->playback_engine->que->send_command(STOP,
2182 cwindow->playback_engine->interrupt_playback(0);
2184 for(int i = 0; i < vwindows.size(); i++)
2186 if(vwindows.get(i)->is_running())
2188 vwindows.get(i)->playback_engine->que->send_command(STOP,
2192 vwindows.get(i)->playback_engine->interrupt_playback(0);
2196 cwindow->gui->lock_window("MWindow::redo_entry");
2197 for(int i = 0; i < vwindows.size(); i++)
2199 if(vwindows.get(i)->is_running())
2201 if (calling_window_gui != vwindows.get(i)->gui)
2203 vwindows.get(i)->gui->lock_window("MWindow::redo_entry 2");
2212 update_plugin_states();
2213 update_plugin_guis();
2215 gui->update(1, 2, 1, 1, 1, 1, 1);
2216 cwindow->update(1, 1, 1, 1, 1);
2218 if (calling_window_gui != cwindow->gui)
2219 cwindow->gui->unlock_window();
2220 if (calling_window_gui != gui)
2221 gui->unlock_window();
2224 for(int i = 0; i < vwindows.size(); i++)
2226 if(vwindows.get(i)->is_running())
2228 if (calling_window_gui != vwindows.get(i)->gui)
2230 vwindows.get(i)->gui->unlock_window();
2235 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
2243 void MWindow::resize_track(Track *track, int w, int h)
2245 undo->update_undo_before();
2246 // We have to move all maskpoints so they do not move in relation to image areas
2247 ((MaskAutos*)track->automation->autos[AUTOMATION_MASK])->translate_masks(
2248 (w - track->track_w) / 2,
2249 (h - track->track_h) / 2);
2252 undo->update_undo_after(_("resize track"), LOAD_ALL);
2256 sync_parameters(CHANGE_EDL);
2260 void MWindow::set_inpoint(int is_mwindow)
2262 undo->update_undo_before();
2263 edl->set_inpoint(edl->local_session->get_selectionstart(1));
2265 undo->update_undo_after(_("in point"), LOAD_TIMEBAR);
2269 gui->lock_window("MWindow::set_inpoint 1");
2271 gui->update_timebar(1);
2274 gui->unlock_window();
2279 cwindow->gui->lock_window("MWindow::set_inpoint 2");
2281 cwindow->gui->timebar->update(1);
2284 cwindow->gui->unlock_window();
2288 void MWindow::set_outpoint(int is_mwindow)
2290 undo->update_undo_before();
2291 edl->set_outpoint(edl->local_session->get_selectionend(1));
2293 undo->update_undo_after(_("out point"), LOAD_TIMEBAR);
2297 gui->lock_window("MWindow::set_outpoint 1");
2299 gui->update_timebar(1);
2302 gui->unlock_window();
2307 cwindow->gui->lock_window("MWindow::set_outpoint 2");
2309 cwindow->gui->timebar->update(1);
2312 cwindow->gui->unlock_window();
2316 void MWindow::splice(EDL *source)
2320 undo->update_undo_before();
2321 source->copy(source->local_session->get_selectionstart(),
2322 source->local_session->get_selectionend(),
2333 double start = edl->local_session->get_selectionstart();
2334 //double end = edl->local_session->get_selectionend();
2335 double source_start = source->local_session->get_selectionstart();
2336 double source_end = source->local_session->get_selectionend();
2341 edl->session->labels_follow_edits,
2342 edl->session->plugins_follow_edits,
2343 edl->session->autos_follow_edits);
2345 // Position at end of clip
2346 edl->local_session->set_selectionstart(start +
2349 edl->local_session->set_selectionend(start +
2354 undo->update_undo_after(_("splice"), LOAD_EDITS | LOAD_TIMEBAR);
2355 update_plugin_guis();
2357 gui->update(1, 1, 1, 1, 0, 1, 0);
2358 sync_parameters(CHANGE_EDL);
2361 void MWindow::to_clip()
2366 gui->lock_window("MWindow::to_clip 1");
2367 start = edl->local_session->get_selectionstart();
2368 end = edl->local_session->get_selectionend();
2370 if(EQUIV(end, start))
2373 end = edl->tracks->total_length();
2376 // Don't copy all since we don't want the clips twice.
2387 EDL *new_edl = new EDL(edl);
2388 new_edl->create_objects();
2389 new_edl->load_xml(&file, LOAD_ALL);
2390 sprintf(new_edl->local_session->clip_title, _("Clip %d"), session->clip_number++);
2391 char string[BCTEXTLEN];
2392 Units::totext(string,
2394 edl->session->time_format,
2395 edl->session->sample_rate,
2396 edl->session->frame_rate,
2397 edl->session->frames_per_foot);
2399 sprintf(new_edl->local_session->clip_notes, _("%s\nCreated from main window"), string);
2401 new_edl->local_session->set_selectionstart(0);
2402 new_edl->local_session->set_selectionend(0);
2404 gui->unlock_window();
2406 awindow->clip_edit->create_clip(new_edl);
2408 gui->lock_window("MWindow::to_clip 2");
2410 gui->unlock_window();
2413 int MWindow::toggle_label(int is_mwindow)
2415 double position1, position2;
2416 undo->update_undo_before();
2418 if(cwindow->playback_engine->is_playing_back)
2420 position1 = position2 =
2421 cwindow->playback_engine->get_tracking_position();
2425 position1 = edl->local_session->get_selectionstart(1);
2426 position2 = edl->local_session->get_selectionend(1);
2429 position1 = edl->align_to_frame(position1, 0);
2430 position2 = edl->align_to_frame(position2, 0);
2432 //printf("MWindow::toggle_label 1\n");
2434 edl->labels->toggle_label(position1, position2);
2439 gui->lock_window("MWindow::toggle_label 1");
2441 gui->update_timebar(0);
2442 gui->activate_timeline();
2446 gui->unlock_window();
2451 cwindow->gui->lock_window("MWindow::toggle_label 2");
2453 cwindow->gui->timebar->update(1);
2456 cwindow->gui->unlock_window();
2459 undo->update_undo_after(_("label"), LOAD_TIMEBAR);
2463 void MWindow::trim_selection()
2465 undo->update_undo_before();
2468 edl->trim_selection(edl->local_session->get_selectionstart(),
2469 edl->local_session->get_selectionend(),
2470 edl->session->labels_follow_edits,
2471 edl->session->plugins_follow_edits,
2472 edl->session->autos_follow_edits);
2475 undo->update_undo_after(_("trim selection"), LOAD_EDITS | LOAD_TIMEBAR);
2476 update_plugin_guis();
2477 gui->update(1, 2, 1, 1, 1, 1, 0);
2478 cwindow->update(1, 0, 0, 0, 1);
2480 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
2488 void MWindow::undo_entry(BC_WindowBase *calling_window_gui)
2490 calling_window_gui->unlock_window();
2492 cwindow->playback_engine->que->send_command(STOP,
2496 cwindow->playback_engine->interrupt_playback(0);
2498 //printf("MWindow::undo_entry %d %d\n", __LINE__, vwindows.size());
2499 for(int i = 0; i < vwindows.size(); i++)
2501 if(vwindows.get(i)->is_running())
2503 vwindows.get(i)->playback_engine->que->send_command(STOP,
2507 vwindows.get(i)->playback_engine->interrupt_playback(0);
2511 cwindow->gui->lock_window("MWindow::undo_entry 1");
2512 for(int i = 0; i < vwindows.size(); i++)
2514 if(vwindows.get(i)->is_running())
2516 if (calling_window_gui != vwindows.get(i)->gui)
2518 vwindows.get(i)->gui->lock_window("MWindow::undo_entry 4");
2522 gui->lock_window("MWindow::undo_entry 2");
2528 update_plugin_states();
2529 update_plugin_guis();
2533 gui->update(1, 2, 1, 1, 1, 1, 1);
2535 gui->unlock_window();
2537 cwindow->update(1, 1, 1, 1, 1);
2539 cwindow->gui->unlock_window();
2541 for(int i = 0; i < vwindows.size(); i++)
2543 if(vwindows.get(i)->is_running())
2545 if (calling_window_gui != vwindows.get(i)->gui)
2547 vwindows.get(i)->gui->unlock_window();
2552 if (calling_window_gui != gui)
2553 gui->unlock_window();
2556 awindow->gui->async_update_assets();
2558 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
2562 calling_window_gui->lock_window("MWindow::undo_entry 4");
2567 void MWindow::new_folder(const char *new_folder)
2569 undo->update_undo_before();
2570 edl->new_folder(new_folder);
2571 undo->update_undo_after(_("new folder"), LOAD_ALL);
2572 awindow->gui->async_update_assets();
2575 void MWindow::delete_folder(char *folder)
2577 // undo->update_undo_after(_("delete folder"), LOAD_ALL);
2580 void MWindow::select_point(double position)
2582 edl->local_session->set_selectionstart(position);
2583 edl->local_session->set_selectionend(position);
2586 cwindow->update(1, 0, 0, 0, 1);
2589 update_plugin_guis();
2590 gui->update_patchbay();
2591 gui->hide_cursor(0);
2592 gui->draw_cursor(0);
2593 gui->mainclock->update(edl->local_session->get_selectionstart(1));
2594 gui->zoombar->update();
2595 gui->update_timebar(0);
2596 gui->flash_canvas(0);
2603 void MWindow::map_audio(int pattern)
2605 undo->update_undo_before();
2606 remap_audio(pattern);
2607 undo->update_undo_after(
2608 pattern == MWindow::AUDIO_1_TO_1 ? _("map 1:1") : _("map 5.1:2"),
2610 sync_parameters(CHANGE_PARAMS);
2611 gui->update(0, 1, 0, 0, 1, 0, 0);
2614 void MWindow::remap_audio(int pattern)
2616 int current_channel = 0;
2617 int current_track = 0;
2618 for(Track *current = edl->tracks->first; current; current = NEXT)
2620 if(current->data_type == TRACK_AUDIO &&
2623 Autos *pan_autos = current->automation->autos[AUTOMATION_PAN];
2624 PanAuto *pan_auto = (PanAuto*)pan_autos->get_auto_for_editing(-1);
2626 for(int i = 0; i < MAXCHANNELS; i++)
2628 pan_auto->values[i] = 0.0;
2631 if(pattern == MWindow::AUDIO_1_TO_1)
2633 pan_auto->values[current_channel] = 1.0;
2636 if(pattern == MWindow::AUDIO_5_1_TO_2)
2638 switch(current_track)
2641 pan_auto->values[0] = 0.5;
2642 pan_auto->values[1] = 0.5;
2645 pan_auto->values[0] = 1;
2648 pan_auto->values[1] = 1;
2651 pan_auto->values[0] = 1;
2654 pan_auto->values[1] = 1;
2657 pan_auto->values[0] = 0.5;
2658 pan_auto->values[1] = 0.5;
2663 BC_Pan::calculate_stick_position(edl->session->audio_channels,
2664 edl->session->achannel_positions,
2669 pan_auto->handle_y);
2673 if(current_channel >= edl->session->audio_channels)
2674 current_channel = 0;
2679 void MWindow::cut_commercials()
2681 undo->update_undo_before();
2682 commercials->scan_media();
2685 undo->update_undo_after(_("cut ads"), LOAD_EDITS | LOAD_TIMEBAR);
2688 update_plugin_guis();
2689 gui->update(1, 2, 1, 1, 1, 1, 0);
2690 cwindow->update(1, 0, 0, 0, 1);
2691 cwindow->playback_engine->que->
2692 send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);