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"
37 #include "filesystem.h"
39 #include "floatauto.h"
40 #include "floatautos.h"
42 #include "gwindowgui.h"
46 #include "levelwindow.h"
47 #include "localsession.h"
48 #include "mainclock.h"
49 #include "maincursor.h"
50 #include "mainerror.h"
51 #include "mainindexes.h"
53 #include "mainsession.h"
55 #include "maskautos.h"
57 #include "mwindowgui.h"
61 #include "playbackengine.h"
62 #include "pluginset.h"
63 #include "recordlabel.h"
64 #include "samplescroll.h"
65 #include "trackcanvas.h"
67 #include "trackscroll.h"
69 #include "transition.h"
70 #include "transportque.h"
72 #include "undostackitem.h"
73 #include "vplayback.h"
75 #include "vwindowgui.h"
77 #include "automation.h"
78 #include "maskautos.h"
82 void MWindow::add_audio_track_entry(int above, Track *dst)
84 undo->update_undo_before();
85 add_audio_track(above, dst);
87 undo->update_undo_after(_("add track"), LOAD_ALL);
90 gui->update(1, 1, 0, 0, 1, 0, 0);
91 gui->activate_timeline();
93 // gui->get_scrollbars(0);
94 // gui->canvas->draw();
95 // gui->patchbay->update();
96 // gui->cursor->draw(1);
97 // gui->canvas->flash();
98 // gui->canvas->activate();
99 cwindow->playback_engine->que->
100 send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);
103 void MWindow::add_video_track_entry(Track *dst)
105 undo->update_undo_before();
106 add_video_track(1, dst);
107 undo->update_undo_after(_("add track"), LOAD_ALL);
111 gui->update(1, 1, 0, 0, 1, 0, 0);
112 gui->activate_timeline();
113 // gui->get_scrollbars(0);
114 // gui->canvas->draw();
115 // gui->patchbay->update();
116 // gui->cursor->draw(1);
117 // gui->canvas->flash();
118 // gui->canvas->activate();
119 cwindow->playback_engine->que->
120 send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);
124 void MWindow::add_subttl_track_entry(Track *dst)
126 undo->update_undo_before();
127 add_subttl_track(1, dst);
128 undo->update_undo_after(_("add track"), LOAD_ALL);
132 gui->update(1, 1, 0, 0, 1, 0, 0);
133 gui->activate_timeline();
134 // gui->get_scrollbars(0);
135 // gui->canvas->draw();
136 // gui->patchbay->update();
137 // gui->cursor->draw(1);
138 // gui->canvas->flash();
139 // gui->canvas->activate();
140 cwindow->playback_engine->que->
141 send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);
146 int MWindow::add_audio_track(int above, Track *dst)
148 edl->tracks->add_audio_track(above, dst);
149 edl->tracks->update_y_pixels(theme);
154 int MWindow::add_video_track(int above, Track *dst)
156 edl->tracks->add_video_track(above, dst);
157 edl->tracks->update_y_pixels(theme);
162 int MWindow::add_subttl_track(int above, Track *dst)
164 edl->tracks->add_subttl_track(above, dst);
165 edl->tracks->update_y_pixels(theme);
170 void MWindow::asset_to_all()
172 if( !session->drag_assets->size() ) return;
173 Indexable *indexable = session->drag_assets->get(0);
175 // if( indexable->have_video() )
179 undo->update_undo_before();
182 w = indexable->get_w();
183 h = indexable->get_h();
184 double new_framerate = session->drag_assets->get(0)->get_frame_rate();
185 double old_framerate = edl->session->frame_rate;
186 int old_samplerate = edl->session->sample_rate;
187 int new_samplerate = session->drag_assets->get(0)->get_sample_rate();
190 if( indexable->have_video() ) {
191 edl->session->output_w = w;
192 edl->session->output_h = h;
193 edl->session->frame_rate = new_framerate;
195 edl->session->aspect_w,
196 edl->session->aspect_h,
199 for( Track *current = edl->tracks->first; current; current = NEXT ) {
200 if( current->data_type == TRACK_VIDEO /* &&
201 current->record */ ) {
202 current->track_w = w;
203 current->track_h = h;
208 if( ((edl->session->output_w % 4) ||
209 (edl->session->output_h % 4)) &&
210 edl->session->playback_config->vconfig->driver == PLAYBACK_X11_GL ) {
211 MainError::show_error(
212 _("This project's dimensions are not multiples of 4 so\n"
213 "it can't be rendered by OpenGL."));
217 if( defaults->get("AUTOASPECT", 0) ) {
219 edl->session->aspect_w,
220 edl->session->aspect_h,
225 if( indexable->have_audio() ) {
226 edl->session->sample_rate = new_samplerate;
227 edl->resample(old_framerate, new_framerate, TRACK_VIDEO);
228 edl->resample(old_samplerate, new_samplerate, TRACK_AUDIO);
233 undo->update_undo_after(_("asset to all"), LOAD_ALL);
235 gui->update(1, 2, 1, 1, 1, 1, 0);
236 sync_parameters(CHANGE_ALL);
240 void MWindow::asset_to_size()
242 if( !session->drag_assets->size() ) return;
243 Indexable *indexable = session->drag_assets->get(0);
245 if( indexable->have_video() ) {
247 undo->update_undo_before();
250 w = indexable->get_w();
251 h = indexable->get_h();
252 edl->session->output_w = w;
253 edl->session->output_h = h;
255 if( ((edl->session->output_w % 4) ||
256 (edl->session->output_h % 4)) &&
257 edl->session->playback_config->vconfig->driver == PLAYBACK_X11_GL ) {
258 MainError::show_error(
259 _("This project's dimensions are not multiples of 4 so\n"
260 "it can't be rendered by OpenGL."));
264 if( defaults->get("AUTOASPECT", 0) ) {
265 create_aspect_ratio(edl->session->aspect_w,
266 edl->session->aspect_h,
273 undo->update_undo_after(_("asset to size"), LOAD_ALL);
275 sync_parameters(CHANGE_ALL);
280 void MWindow::asset_to_rate()
282 if( session->drag_assets->size() &&
283 session->drag_assets->get(0)->have_video() ) {
284 double new_framerate = session->drag_assets->get(0)->get_frame_rate();
285 double old_framerate = edl->session->frame_rate;
286 undo->update_undo_before();
288 edl->session->frame_rate = new_framerate;
289 edl->resample(old_framerate, new_framerate, TRACK_VIDEO);
293 undo->update_undo_after(_("asset to rate"), LOAD_ALL);
295 gui->update(1, 2, 1, 1, 1, 1, 0);
296 sync_parameters(CHANGE_ALL);
301 void MWindow::clear_entry()
303 undo->update_undo_before();
308 undo->update_undo_after(_("clear"), LOAD_EDITS | LOAD_TIMEBAR);
311 update_plugin_guis();
312 gui->update(1, 2, 1, 1, 1, 1, 0);
313 cwindow->update(1, 0, 0, 0, 1);
314 cwindow->playback_engine->que->
315 send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);
318 void MWindow::clear(int clear_handle)
320 double start = edl->local_session->get_selectionstart();
321 double end = edl->local_session->get_selectionend();
322 if( clear_handle || !EQUIV(start, end) ) {
325 edl->session->labels_follow_edits,
326 edl->session->plugins_follow_edits,
327 edl->session->autos_follow_edits);
331 void MWindow::set_automation_mode(int mode)
333 undo->update_undo_before();
334 edl->tracks->set_automation_mode(
335 edl->local_session->get_selectionstart(),
336 edl->local_session->get_selectionend(),
339 char string[BCSTRLEN];
340 sprintf(string,"set %s", FloatAuto::curve_name(mode));
341 undo->update_undo_after(string, LOAD_AUTOMATION);
344 update_plugin_guis();
345 gui->draw_overlays(1);
346 sync_parameters(CHANGE_PARAMS);
347 gui->update_patchbay();
348 cwindow->update(1, 0, 0);
351 void MWindow::clear_automation()
353 undo->update_undo_before();
354 edl->tracks->clear_automation(edl->local_session->get_selectionstart(),
355 edl->local_session->get_selectionend());
357 undo->update_undo_after(_("clear keyframes"), LOAD_AUTOMATION);
360 update_plugin_guis();
361 gui->draw_overlays(1);
362 sync_parameters(CHANGE_PARAMS);
363 gui->update_patchbay();
364 cwindow->update(1, 0, 0);
367 int MWindow::clear_default_keyframe()
369 undo->update_undo_before();
370 edl->tracks->clear_default_keyframe();
372 undo->update_undo_after(_("clear default keyframe"), LOAD_AUTOMATION);
375 gui->draw_overlays(1);
376 sync_parameters(CHANGE_PARAMS);
377 gui->update_patchbay();
378 cwindow->update(1, 0, 0);
383 void MWindow::clear_labels()
385 undo->update_undo_before();
386 clear_labels(edl->local_session->get_selectionstart(),
387 edl->local_session->get_selectionend());
388 undo->update_undo_after(_("clear labels"), LOAD_TIMEBAR);
390 gui->update_timebar(1);
391 cwindow->update(0, 0, 0, 0, 1);
395 int MWindow::clear_labels(double start, double end)
397 edl->labels->clear(start, end, 0);
401 void MWindow::concatenate_tracks()
403 undo->update_undo_before();
404 edl->tracks->concatenate_tracks(edl->session->plugins_follow_edits,
405 edl->session->autos_follow_edits);
407 undo->update_undo_after(_("concatenate tracks"), LOAD_EDITS);
410 gui->update(1, 1, 0, 0, 1, 0, 0);
411 cwindow->playback_engine->que->
412 send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);
418 copy(edl->local_session->get_selectionstart(),
419 edl->local_session->get_selectionend());
422 int MWindow::copy(double start, double end)
424 if( start == end ) return 1;
427 edl->copy(start, end, 0, 0, 0, &file, "", 1);
428 const char *file_string = file.string();
429 long file_length = strlen(file_string);
430 gui->get_clipboard()->to_clipboard(file_string, file_length,
431 SECONDARY_SELECTION);
432 gui->get_clipboard()->to_clipboard(file_string, file_length,
433 BC_PRIMARY_SELECTION);
438 int MWindow::copy_automation()
441 double start = edl->local_session->get_selectionstart();
442 double end = edl->local_session->get_selectionend();
443 edl->tracks->copy_automation(start, end, &file, 0, 1);
444 const char *file_string = file.string();
445 long file_length = strlen(file_string);
446 gui->get_clipboard()->to_clipboard(file_string, file_length,
447 BC_PRIMARY_SELECTION);
448 gui->get_clipboard()->to_clipboard(file_string, file_length,
449 SECONDARY_SELECTION);
453 int MWindow::copy_default_keyframe()
456 double start = edl->local_session->get_selectionstart();
457 double end = edl->local_session->get_selectionend();
458 edl->tracks->copy_automation(start, end, &file, 1, 0);
459 const char *file_string = file.string();
460 long file_length = strlen(file_string);
461 gui->get_clipboard()->to_clipboard(file_string, file_length,
462 BC_PRIMARY_SELECTION);
463 gui->get_clipboard()->to_clipboard(file_string, file_length,
464 SECONDARY_SELECTION);
469 // Uses cropping coordinates in edl session to crop and translate video.
470 // We modify the projector since camera automation depends on the track size.
471 void MWindow::crop_video()
474 undo->update_undo_before();
475 // Clamp EDL crop region
476 if( edl->session->crop_x1 > edl->session->crop_x2 ) {
477 edl->session->crop_x1 ^= edl->session->crop_x2;
478 edl->session->crop_x2 ^= edl->session->crop_x1;
479 edl->session->crop_x1 ^= edl->session->crop_x2;
481 if( edl->session->crop_y1 > edl->session->crop_y2 ) {
482 edl->session->crop_y1 ^= edl->session->crop_y2;
483 edl->session->crop_y2 ^= edl->session->crop_y1;
484 edl->session->crop_y1 ^= edl->session->crop_y2;
487 float old_projector_x = (float)edl->session->output_w / 2;
488 float old_projector_y = (float)edl->session->output_h / 2;
489 float new_projector_x = (float)(edl->session->crop_x1 + edl->session->crop_x2) / 2;
490 float new_projector_y = (float)(edl->session->crop_y1 + edl->session->crop_y2) / 2;
491 float projector_offset_x = -(new_projector_x - old_projector_x);
492 float projector_offset_y = -(new_projector_y - old_projector_y);
494 edl->tracks->translate_projector(projector_offset_x, projector_offset_y);
496 edl->session->output_w = edl->session->crop_x2 - edl->session->crop_x1;
497 edl->session->output_h = edl->session->crop_y2 - edl->session->crop_y1;
498 edl->session->crop_x1 = 0;
499 edl->session->crop_y1 = 0;
500 edl->session->crop_x2 = edl->session->output_w;
501 edl->session->crop_y2 = edl->session->output_h;
503 // Recalculate aspect ratio
504 if( defaults->get("AUTOASPECT", 0) ) {
505 create_aspect_ratio(edl->session->aspect_w,
506 edl->session->aspect_h,
507 edl->session->output_w,
508 edl->session->output_h);
511 undo->update_undo_after(_("crop"), LOAD_ALL);
514 cwindow->playback_engine->que->
515 send_command(CURRENT_FRAME, CHANGE_ALL, edl, 1);
521 undo->update_undo_before();
523 double start = edl->local_session->get_selectionstart();
524 double end = edl->local_session->get_selectionend();
527 edl->clear(start, end,
528 edl->session->labels_follow_edits,
529 edl->session->plugins_follow_edits,
530 edl->session->autos_follow_edits);
535 undo->update_undo_after(_("cut"), LOAD_EDITS | LOAD_TIMEBAR);
538 update_plugin_guis();
539 gui->update(1, 2, 1, 1, 1, 1, 0);
540 cwindow->update(1, 0, 0, 0, 1);
541 cwindow->playback_engine->que->
542 send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);
545 int MWindow::cut_automation()
547 undo->update_undo_before();
551 edl->tracks->clear_automation(edl->local_session->get_selectionstart(),
552 edl->local_session->get_selectionend());
554 undo->update_undo_after(_("cut keyframes"), LOAD_AUTOMATION);
558 update_plugin_guis();
559 gui->draw_overlays(1);
560 sync_parameters(CHANGE_PARAMS);
561 gui->update_patchbay();
562 cwindow->update(1, 0, 0);
566 int MWindow::cut_default_keyframe()
569 undo->update_undo_before();
570 copy_default_keyframe();
571 edl->tracks->clear_default_keyframe();
572 undo->update_undo_after(_("cut default keyframe"), LOAD_AUTOMATION);
575 gui->draw_overlays(1);
576 sync_parameters(CHANGE_PARAMS);
577 gui->update_patchbay();
578 cwindow->update(1, 0, 0);
586 void MWindow::delete_inpoint()
588 edl->local_session->unset_inpoint();
592 void MWindow::delete_outpoint()
594 edl->local_session->unset_outpoint();
599 void MWindow::delete_track()
601 if( edl->tracks->last )
602 delete_track(edl->tracks->last);
605 void MWindow::delete_tracks()
607 undo->update_undo_before();
608 edl->tracks->delete_tracks();
609 undo->update_undo_after(_("delete tracks"), LOAD_ALL);
613 update_plugin_states();
615 gui->update(1, 1, 1, 0, 1, 0, 0);
616 cwindow->playback_engine->que->
617 send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);
620 void MWindow::delete_track(Track *track)
622 undo->update_undo_before();
623 edl->tracks->delete_track(track);
624 undo->update_undo_after(_("delete track"), LOAD_ALL);
627 update_plugin_states();
629 gui->update(1, 1, 1, 0, 1, 0, 0);
630 cwindow->playback_engine->que->
631 send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);
636 // Insert data from clipboard
637 void MWindow::insert(double position, FileXML *file,
638 int edit_labels, int edit_plugins, int edit_autos,
641 // For clipboard pasting make the new edl use a separate session
642 // from the master EDL. Then it can be resampled to the master rates.
643 // For splice, overwrite, and dragging need same session to get the assets.
644 EDL *edl = new EDL(parent_edl);
645 ArrayList<EDL*> new_edls;
646 uint32_t load_flags = LOAD_ALL;
649 new_edls.append(edl);
650 edl->create_objects();
655 if( parent_edl ) load_flags &= ~LOAD_SESSION;
656 if( !edl->session->autos_follow_edits ) load_flags &= ~LOAD_AUTOMATION;
657 if( !edl->session->labels_follow_edits ) load_flags &= ~LOAD_TIMEBAR;
659 edl->load_xml(file, load_flags);
662 //printf("MWindow::insert %f\n", edl->local_session->clipboard_length);
666 paste_edls(&new_edls, LOADMODE_PASTE, 0, position,
667 edit_labels, edit_plugins, edit_autos, 0); // overwrite
668 // if( vwindow->edl )
669 // printf("MWindow::insert 5 %f %f\n",
670 // vwindow->edl->local_session->in_point,
671 // vwindow->edl->local_session->out_point);
672 new_edls.remove_all();
673 edl->Garbage::remove_user();
674 //printf("MWindow::insert 6 %p\n", vwindow->get_edl());
677 void MWindow::insert_effects_canvas(double start,
680 Track *dest_track = session->track_highlighted;
681 if( !dest_track ) return;
683 undo->update_undo_before();
685 for( int i = 0; i < session->drag_pluginservers->total; i++ ) {
686 PluginServer *plugin = session->drag_pluginservers->values[i];
687 insert_effect(plugin->title, 0, dest_track,
688 i == 0 ? session->pluginset_highlighted : 0,
689 start, length, PLUGIN_STANDALONE);
693 undo->update_undo_after(_("insert effect"), LOAD_EDITS | LOAD_PATCHES);
695 sync_parameters(CHANGE_EDL);
696 // GUI updated in TrackCanvas, after current_operations are reset
699 void MWindow::insert_effects_cwindow(Track *dest_track)
701 if( !dest_track ) return;
703 undo->update_undo_before();
706 double length = dest_track->get_length();
708 if( edl->local_session->get_selectionend() >
709 edl->local_session->get_selectionstart() ) {
710 start = edl->local_session->get_selectionstart();
711 length = edl->local_session->get_selectionend() -
712 edl->local_session->get_selectionstart();
715 for( int i = 0; i < session->drag_pluginservers->total; i++ ) {
716 PluginServer *plugin = session->drag_pluginservers->values[i];
717 insert_effect(plugin->title, 0, dest_track, 0,
718 start, length, PLUGIN_STANDALONE);
722 undo->update_undo_after(_("insert effect"), LOAD_EDITS | LOAD_PATCHES);
724 sync_parameters(CHANGE_EDL);
725 gui->update(1, 1, 0, 0, 1, 0, 0);
728 void MWindow::insert_effect(char *title,
729 SharedLocation *shared_location,
732 int single_standalone)
734 Track *current = edl->tracks->first;
735 SharedLocation shared_location_local;
736 shared_location_local.copy_from(shared_location);
738 for( ; current; current = NEXT) {
739 if( current->data_type == data_type &&
741 insert_effect(title, &shared_location_local,
742 current, 0, 0, 0, plugin_type);
745 if( plugin_type == PLUGIN_STANDALONE && single_standalone ) {
746 plugin_type = PLUGIN_SHAREDPLUGIN;
747 shared_location_local.module = edl->tracks->number_of(current);
748 shared_location_local.plugin = current->plugin_set.total - 1;
757 void MWindow::insert_effect(char *title,
758 SharedLocation *shared_location,
760 PluginSet *plugin_set,
765 KeyFrame *default_keyframe = 0;
766 PluginServer *server = 0;
767 // Get default keyframe
768 if( plugin_type == PLUGIN_STANDALONE ) {
769 default_keyframe = new KeyFrame;
770 server = new PluginServer(*scan_plugindb(title, track->data_type));
772 server->open_plugin(0, preferences, edl, 0);
773 server->save_data(default_keyframe);
775 // Insert plugin object
776 track->insert_effect(title, shared_location,
777 default_keyframe, plugin_set,
778 start, length, plugin_type);
781 if( plugin_type == PLUGIN_STANDALONE ) {
782 server->close_plugin();
784 delete default_keyframe;
788 int MWindow::modify_edithandles()
790 undo->update_undo_before();
791 edl->modify_edithandles(session->drag_start,
792 session->drag_position,
793 session->drag_handle,
794 edl->session->edit_handle_mode[session->drag_button],
795 edl->session->labels_follow_edits,
796 edl->session->plugins_follow_edits,
797 edl->session->autos_follow_edits);
799 finish_modify_handles();
800 //printf("MWindow::modify_handles 1\n");
804 int MWindow::modify_pluginhandles()
806 undo->update_undo_before();
808 edl->modify_pluginhandles(session->drag_start,
809 session->drag_position,
810 session->drag_handle,
811 edl->session->edit_handle_mode[session->drag_button],
812 edl->session->labels_follow_edits,
813 edl->session->autos_follow_edits,
814 session->trim_edits);
816 finish_modify_handles();
822 // Common to edithandles and plugin handles
823 void MWindow::finish_modify_handles()
825 int edit_mode = edl->session->edit_handle_mode[session->drag_button];
827 if( (session->drag_handle == 1 && edit_mode != MOVE_NO_EDITS) ||
828 (session->drag_handle == 0 && edit_mode == MOVE_ONE_EDIT) ) {
829 edl->local_session->set_selectionstart(session->drag_position);
830 edl->local_session->set_selectionend(session->drag_position);
833 if( edit_mode != MOVE_NO_EDITS ) {
834 edl->local_session->set_selectionstart(session->drag_start);
835 edl->local_session->set_selectionend(session->drag_start);
838 if( edl->local_session->get_selectionstart(1) < 0 ) {
839 edl->local_session->set_selectionstart(0);
840 edl->local_session->set_selectionend(0);
842 undo->update_undo_after(_("drag handle"), LOAD_EDITS | LOAD_TIMEBAR);
846 sync_parameters(CHANGE_EDL);
847 update_plugin_guis();
848 gui->update(1, 2, 1, 1, 1, 1, 0);
849 cwindow->update(1, 0, 0, 0, 1);
852 void MWindow::match_output_size(Track *track)
854 undo->update_undo_before();
855 track->track_w = edl->session->output_w;
856 track->track_h = edl->session->output_h;
858 undo->update_undo_after(_("match output size"), LOAD_ALL);
861 sync_parameters(CHANGE_EDL);
865 void MWindow::move_edits(ArrayList<Edit*> *edits,
870 undo->update_undo_before();
872 edl->tracks->move_edits(edits,
875 edl->session->labels_follow_edits,
876 edl->session->plugins_follow_edits,
877 edl->session->autos_follow_edits,
881 undo->update_undo_after(_("move edit"), LOAD_ALL);
884 cwindow->playback_engine->que->
885 send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);
887 update_plugin_guis();
888 gui->update(1, 1, // 1 for incremental drawing. 2 for full refresh
892 void MWindow::move_effect(Plugin *plugin, Track *track, int64_t position)
894 undo->update_undo_before();
895 edl->tracks->move_effect(plugin, track, position);
897 undo->update_undo_after(_("paste effect"), LOAD_ALL);
900 cwindow->playback_engine->que->
901 send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);
902 update_plugin_guis();
903 gui->update(1, 1, // 1 for incremental drawing. 2 for full refresh
907 void MWindow::move_effect(Plugin *plugin, PluginSet *plugin_set, int64_t position)
909 undo->update_undo_before();
910 edl->tracks->move_effect(plugin, plugin_set, position);
912 undo->update_undo_after(_("move effect"), LOAD_ALL);
915 cwindow->playback_engine->que->
916 send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);
917 update_plugin_guis();
918 gui->update(1, 1, // 1 for incremental drawing. 2 for full refresh
922 void MWindow::move_plugins_up(PluginSet *plugin_set)
925 undo->update_undo_before();
926 plugin_set->track->move_plugins_up(plugin_set);
929 undo->update_undo_after(_("move effect up"), LOAD_ALL);
931 gui->update(1, 1, // 1 for incremental drawing. 2 for full refresh
933 sync_parameters(CHANGE_EDL);
936 void MWindow::move_plugins_down(PluginSet *plugin_set)
938 undo->update_undo_before();
940 plugin_set->track->move_plugins_down(plugin_set);
943 undo->update_undo_after(_("move effect down"), LOAD_ALL);
945 gui->update(1, 1, // 1 for incremental drawing. 2 for full refresh
947 sync_parameters(CHANGE_EDL);
950 void MWindow::move_track_down(Track *track)
952 undo->update_undo_before();
953 edl->tracks->move_track_down(track);
955 undo->update_undo_after(_("move track down"), LOAD_ALL);
958 gui->update(1, 1, 0, 0, 1, 0, 0);
959 sync_parameters(CHANGE_EDL);
963 void MWindow::move_tracks_down()
965 undo->update_undo_before();
966 edl->tracks->move_tracks_down();
968 undo->update_undo_after(_("move tracks down"), LOAD_ALL);
971 gui->update(1, 1, 0, 0, 1, 0, 0);
972 sync_parameters(CHANGE_EDL);
976 void MWindow::move_track_up(Track *track)
978 undo->update_undo_before();
979 edl->tracks->move_track_up(track);
981 undo->update_undo_after(_("move track up"), LOAD_ALL);
983 gui->update(1, 1, 0, 0, 1, 0, 0);
984 sync_parameters(CHANGE_EDL);
988 void MWindow::move_tracks_up()
990 undo->update_undo_before();
991 edl->tracks->move_tracks_up();
993 undo->update_undo_after(_("move tracks up"), LOAD_ALL);
995 gui->update(1, 1, 0, 0, 1, 0, 0);
996 sync_parameters(CHANGE_EDL);
1000 void MWindow::mute_selection()
1002 double start = edl->local_session->get_selectionstart();
1003 double end = edl->local_session->get_selectionend();
1004 if( start != end ) {
1005 undo->update_undo_before();
1006 edl->clear(start, end, 0,
1007 edl->session->plugins_follow_edits,
1008 edl->session->autos_follow_edits);
1009 edl->local_session->set_selectionend(end);
1010 edl->local_session->set_selectionstart(start);
1011 edl->paste_silence(start, end, 0,
1012 edl->session->plugins_follow_edits,
1013 edl->session->autos_follow_edits);
1015 undo->update_undo_after(_("mute"), LOAD_EDITS);
1018 update_plugin_guis();
1019 gui->update(1, 2, 1, 1, 1, 1, 0);
1020 cwindow->playback_engine->que->
1021 send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);
1026 void MWindow::overwrite(EDL *source)
1030 double src_start = source->local_session->get_selectionstart();
1031 double overwrite_len = source->local_session->get_selectionend() - src_start;
1032 double dst_start = edl->local_session->get_selectionstart();
1033 double dst_len = edl->local_session->get_selectionend() - dst_start;
1035 undo->update_undo_before();
1036 if( !EQUIV(dst_len, 0) && (dst_len < overwrite_len) ) {
1037 // in/out points or selection present and shorter than overwrite range
1038 // shorten the copy range
1039 overwrite_len = dst_len;
1042 source->copy(src_start, src_start + overwrite_len,
1043 1, 0, 0, &file, "", 1);
1045 // HACK around paste_edl get_start/endselection on its own
1046 // so we need to clear only when not using both io points
1047 // FIXME: need to write simple overwrite_edl to be used for overwrite function
1048 if( edl->local_session->get_inpoint() < 0 ||
1049 edl->local_session->get_outpoint() < 0 )
1050 edl->clear(dst_start, dst_start + overwrite_len, 0, 0, 0);
1052 paste(dst_start, dst_start + overwrite_len,
1055 edl->local_session->set_selectionstart(dst_start + overwrite_len);
1056 edl->local_session->set_selectionend(dst_start + overwrite_len);
1059 undo->update_undo_after(_("overwrite"), LOAD_EDITS);
1062 update_plugin_guis();
1063 gui->update(1, 1, 1, 1, 0, 1, 0);
1064 sync_parameters(CHANGE_EDL);
1067 // For splice and overwrite
1068 int MWindow::paste(double start,
1077 // Want to insert with assets shared with the master EDL.
1079 edit_labels, edit_plugins, edit_autos,
1085 // For editing using insertion point
1086 void MWindow::paste()
1088 double start = edl->local_session->get_selectionstart();
1089 //double end = edl->local_session->get_selectionend();
1090 int64_t len = gui->get_clipboard()->clipboard_len(SECONDARY_SELECTION);
1093 char *string = new char[len + 1];
1094 undo->update_undo_before();
1095 gui->get_clipboard()->from_clipboard(string, len, BC_PRIMARY_SELECTION);
1097 file.read_from_string(string);
1100 insert(start, &file,
1101 edl->session->labels_follow_edits,
1102 edl->session->plugins_follow_edits,
1103 edl->session->autos_follow_edits,
1111 undo->update_undo_after(_("paste"), LOAD_EDITS | LOAD_TIMEBAR);
1113 update_plugin_guis();
1114 gui->update(1, 2, 1, 1, 0, 1, 0);
1115 awindow->gui->async_update_assets();
1116 sync_parameters(CHANGE_EDL);
1121 int MWindow::paste_assets(double position, Track *dest_track, int overwrite)
1124 undo->update_undo_before();
1126 if( session->drag_assets->total ) {
1127 load_assets(session->drag_assets,
1128 position, LOADMODE_PASTE, dest_track, 0,
1129 edl->session->labels_follow_edits,
1130 edl->session->plugins_follow_edits,
1131 edl->session->autos_follow_edits,
1136 if( session->drag_clips->total ) {
1137 paste_edls(session->drag_clips,
1138 LOADMODE_PASTE, dest_track, position,
1139 edl->session->labels_follow_edits,
1140 edl->session->plugins_follow_edits,
1141 edl->session->autos_follow_edits,
1148 undo->update_undo_after(_("paste assets"), LOAD_EDITS);
1150 gui->update(1, 2, 1, 0, 0, 1, 0);
1151 sync_parameters(CHANGE_EDL);
1155 void MWindow::load_assets(ArrayList<Indexable*> *new_assets,
1159 RecordLabels *labels,
1165 const int debug = 0;
1166 if( debug ) printf("MWindow::load_assets %d\n", __LINE__);
1167 if( position < 0 ) position = edl->local_session->get_selectionstart();
1169 ArrayList<EDL*> new_edls;
1170 for( int i = 0; i < new_assets->total; i++ ) {
1171 Indexable *indexable = new_assets->get(i);
1172 if( indexable->is_asset ) {
1173 remove_asset_from_caches((Asset*)indexable);
1175 EDL *new_edl = new EDL;
1176 new_edl->create_objects();
1177 new_edl->copy_session(edl);
1178 new_edls.append(new_edl);
1181 if( indexable->is_asset ) {
1182 if( debug ) printf("MWindow::load_assets %d\n", __LINE__);
1183 if( debug ) ((Asset*)indexable)->dump();
1184 asset_to_edl(new_edl, (Asset*)indexable);
1187 edl_to_nested(new_edl, (EDL*)indexable);
1188 if( debug ) printf("MWindow::load_assets %d\n", __LINE__);
1192 for( RecordLabel *label = labels->first; label; label = label->next ) {
1193 new_edl->labels->toggle_label(label->position, label->position);
1197 if( debug ) printf("MWindow::load_assets %d\n", __LINE__);
1199 paste_edls(&new_edls, load_mode, first_track, position,
1200 edit_labels, edit_plugins, edit_autos, overwrite);
1201 if( debug ) printf("MWindow::load_assets %d\n", __LINE__);
1204 for( int i = 0; i < new_edls.size(); i++ )
1205 new_edls.get(i)->Garbage::remove_user();
1207 if( debug ) printf("MWindow::load_assets %d\n", __LINE__);
1210 int MWindow::paste_automation()
1212 int64_t len = gui->get_clipboard()->clipboard_len(SECONDARY_SELECTION);
1215 undo->update_undo_before();
1216 char *string = new char[len + 1];
1217 gui->get_clipboard()->from_clipboard(string,
1219 BC_PRIMARY_SELECTION);
1221 file.read_from_string(string);
1223 double start = edl->local_session->get_selectionstart();
1224 double end = edl->local_session->get_selectionend();
1225 edl->tracks->clear_automation(start, end);
1226 edl->tracks->paste_automation(start, &file, 0, 1,
1227 edl->session->typeless_keyframes);
1229 undo->update_undo_after(_("paste keyframes"), LOAD_AUTOMATION);
1233 update_plugin_guis();
1234 gui->draw_overlays(1);
1235 sync_parameters(CHANGE_PARAMS);
1236 gui->update_patchbay();
1237 cwindow->update(1, 0, 0);
1243 int MWindow::paste_default_keyframe()
1245 int64_t len = gui->get_clipboard()->clipboard_len(SECONDARY_SELECTION);
1248 undo->update_undo_before();
1249 char *string = new char[len + 1];
1250 gui->get_clipboard()->from_clipboard(string,
1252 BC_PRIMARY_SELECTION);
1254 file.read_from_string(string);
1255 double start = edl->local_session->get_selectionstart();
1256 edl->tracks->paste_automation(start, &file, 1, 0,
1257 edl->session->typeless_keyframes);
1258 // edl->tracks->paste_default_keyframe(&file);
1259 undo->update_undo_after(_("paste default keyframe"), LOAD_AUTOMATION);
1262 update_plugin_guis();
1263 gui->draw_overlays(1);
1264 sync_parameters(CHANGE_PARAMS);
1265 gui->update_patchbay();
1266 cwindow->update(1, 0, 0);
1275 // Insert edls with project deletion and index file generation.
1276 int MWindow::paste_edls(ArrayList<EDL*> *new_edls, int load_mode,
1277 Track *first_track, double current_position,
1278 int edit_labels, int edit_plugins, int edit_autos,
1282 ArrayList<Track*> destination_tracks;
1283 int need_new_tracks = 0;
1286 if( !new_edls->total ) return 0;
1289 // double original_length = edl->tracks->total_playable_length();
1290 // double original_preview_end = edl->local_session->preview_end;
1293 // Delete current project
1294 if( load_mode == LOADMODE_REPLACE ||
1295 load_mode == LOADMODE_REPLACE_CONCATENATE ) {
1297 edl->save_defaults(defaults);
1299 edl->Garbage::remove_user();
1301 edl->create_objects();
1302 edl->copy_session(new_edls->values[0]);
1303 gui->mainmenu->update_toggles(0);
1304 gui->unlock_window();
1305 gwindow->gui->update_toggles(1);
1306 gui->lock_window("MWindow::paste_edls");
1308 // Insert labels for certain modes constitutively
1312 // Force reset of preview
1313 // original_length = 0;
1314 // original_preview_end = -1;
1320 // Create new tracks in master EDL
1321 if( load_mode == LOADMODE_REPLACE ||
1322 load_mode == LOADMODE_REPLACE_CONCATENATE ||
1323 load_mode == LOADMODE_NEW_TRACKS ) {
1325 need_new_tracks = 1;
1326 for( int i = 0; i < new_edls->total; i++ ) {
1327 EDL *new_edl = new_edls->values[i];
1328 for( Track *current = new_edl->tracks->first;
1331 if( current->data_type == TRACK_VIDEO ) {
1332 edl->tracks->add_video_track(0, 0);
1333 if( current->draw ) edl->tracks->last->draw = 1;
1334 destination_tracks.append(edl->tracks->last);
1337 if( current->data_type == TRACK_AUDIO ) {
1338 edl->tracks->add_audio_track(0, 0);
1339 destination_tracks.append(edl->tracks->last);
1342 if( current->data_type == TRACK_SUBTITLE ) {
1343 edl->tracks->add_subttl_track(0, 0);
1344 destination_tracks.append(edl->tracks->last);
1346 edl->session->highlighted_track = edl->tracks->total() - 1;
1349 // Base track count on first EDL only for concatenation
1350 if( load_mode == LOADMODE_REPLACE_CONCATENATE ) break;
1355 // Recycle existing tracks of master EDL
1356 if( load_mode == LOADMODE_CONCATENATE ||
1357 load_mode == LOADMODE_PASTE ||
1358 load_mode == LOADMODE_NESTED ) {
1361 // The point of this is to shift forward labels after the selection so they can
1362 // then be shifted back to their original locations without recursively
1363 // shifting back every paste.
1364 if( (load_mode == LOADMODE_PASTE || load_mode == LOADMODE_NESTED) &&
1365 edl->session->labels_follow_edits )
1366 edl->labels->clear(edl->local_session->get_selectionstart(),
1367 edl->local_session->get_selectionend(),
1370 Track *current = first_track ? first_track : edl->tracks->first;
1371 for( ; current; current = NEXT) {
1372 if( current->record ) {
1373 destination_tracks.append(current);
1380 int destination_track = 0;
1381 double *paste_position = new double[destination_tracks.total];
1383 // Iterate through the edls
1384 for( int i = 0; i < new_edls->total; i++ ) {
1386 EDL *new_edl = new_edls->values[i];
1387 double edl_length = new_edl->local_session->clipboard_length ?
1388 new_edl->local_session->clipboard_length :
1389 new_edl->tracks->total_length();
1390 // printf("MWindow::paste_edls 2 %f %f\n",
1391 // new_edl->local_session->clipboard_length,
1392 // new_edl->tracks->total_length());
1396 // Convert EDL to master rates
1397 new_edl->resample(new_edl->session->sample_rate,
1398 edl->session->sample_rate,
1400 new_edl->resample(new_edl->session->frame_rate,
1401 edl->session->frame_rate,
1404 // Add assets and prepare index files
1405 for( Asset *new_asset = new_edl->assets->first;
1407 new_asset = new_asset->next ) {
1408 mainindexes->add_next_asset(0, new_asset);
1410 // Capture index file status from mainindex test
1411 edl->update_assets(new_edl);
1413 // Get starting point of insertion. Need this to paste labels.
1414 switch( load_mode ) {
1415 case LOADMODE_REPLACE:
1416 case LOADMODE_NEW_TRACKS:
1417 current_position = 0;
1420 case LOADMODE_CONCATENATE:
1421 case LOADMODE_REPLACE_CONCATENATE:
1422 destination_track = 0;
1423 if( destination_tracks.total )
1424 current_position = destination_tracks.values[0]->get_length();
1426 current_position = 0;
1429 case LOADMODE_PASTE:
1430 case LOADMODE_NESTED:
1431 destination_track = 0;
1433 for( int j = 0; j < destination_tracks.total; j++ ) {
1434 paste_position[j] = (current_position >= 0) ?
1436 edl->local_session->get_selectionstart();
1441 case LOADMODE_RESOURCESONLY:
1442 edl->add_clip(new_edl);
1447 if( load_mode != LOADMODE_RESOURCESONLY ) {
1449 //printf("MWindow::paste_edls %f %f\n", current_position, edl_length);
1450 if( load_mode == LOADMODE_PASTE ||
1451 load_mode == LOADMODE_NESTED )
1452 edl->labels->insert_labels(new_edl->labels,
1453 destination_tracks.total ? paste_position[0] : 0.0,
1457 edl->labels->insert_labels(new_edl->labels,
1463 for( Track *new_track = new_edl->tracks->first;
1465 new_track = new_track->next ) {
1466 // Get destination track of same type as new_track
1468 k < destination_tracks.total &&
1469 destination_tracks.values[destination_track]->data_type != new_track->data_type;
1470 k++, destination_track++ ) {
1471 if( destination_track >= destination_tracks.total - 1 )
1472 destination_track = 0;
1475 // Insert data into destination track
1476 if( destination_track < destination_tracks.total &&
1477 destination_tracks.values[destination_track]->data_type == new_track->data_type ) {
1478 Track *track = destination_tracks.values[destination_track];
1480 // Replace default keyframes if first EDL and new tracks were created.
1481 // This means data copied from one track and pasted to another won't retain
1482 // the camera position unless it's a keyframe. If it did, previous data in the
1483 // track might get unknowingly corrupted. Ideally we would detect when differing
1484 // default keyframes existed and create discrete keyframes for both.
1485 int replace_default = (i == 0) && need_new_tracks;
1487 //printf("MWindow::paste_edls 1 %d\n", replace_default);
1488 // Insert new track at current position
1489 switch( load_mode ) {
1490 case LOADMODE_REPLACE_CONCATENATE:
1491 case LOADMODE_CONCATENATE:
1492 current_position = track->get_length();
1495 case LOADMODE_PASTE:
1496 case LOADMODE_NESTED:
1497 current_position = paste_position[destination_track];
1498 paste_position[destination_track] += new_track->get_length();
1502 track->clear(current_position,
1503 current_position + new_track->get_length(),
1505 edit_labels, edit_plugins, edit_autos,
1510 track->insert_track(new_track, current_position, replace_default,
1511 edit_plugins, edit_autos, edl_length);
1515 // Get next destination track
1516 destination_track++;
1517 if( destination_track >= destination_tracks.total )
1518 destination_track = 0;
1522 if( load_mode == LOADMODE_PASTE ||
1523 load_mode == LOADMODE_NESTED )
1524 current_position += edl_length;
1528 // Move loading of clips and vwindow to the end - this fixes some
1529 // strange issue, for index not being shown
1530 // Assume any paste operation from the same EDL won't contain any clips.
1531 // If it did it would duplicate every clip here.
1532 for( int i = 0; i < new_edls->total; i++ ) {
1533 EDL *new_edl = new_edls->values[i];
1535 for( int j = 0; j < new_edl->clips.total; j++ ) {
1536 edl->add_clip(new_edl->clips.values[j]);
1539 if( new_edl->total_vwindow_edls() ) {
1540 // if( edl->vwindow_edl )
1541 // edl->vwindow_edl->Garbage::remove_user();
1542 // edl->vwindow_edl = new EDL(edl);
1543 // edl->vwindow_edl->create_objects();
1544 // edl->vwindow_edl->copy_all(new_edl->vwindow_edl);
1546 for( int j = 0; j < new_edl->total_vwindow_edls(); j++ ) {
1547 EDL *vwindow_edl = new EDL(edl);
1548 vwindow_edl->create_objects();
1549 vwindow_edl->copy_all(new_edl->get_vwindow_edl(j));
1550 edl->append_vwindow_edl(vwindow_edl, 0);
1555 if( paste_position ) delete [] paste_position;
1557 // This is already done in load_filenames and everything else that uses paste_edls
1558 // update_project(load_mode);
1560 // Fix preview range
1561 // if( EQUIV(original_length, original_preview_end) )
1563 // edl->local_session->preview_end = edl->tracks->total_playable_length();
1566 // Start examining next batch of index files
1567 mainindexes->start_build();
1569 // Don't save a backup after loading since the loaded file is on disk already.
1574 void MWindow::paste_silence()
1576 double start = edl->local_session->get_selectionstart();
1577 double end = edl->local_session->get_selectionend();
1578 undo->update_undo_before();
1579 edl->paste_silence(start, end,
1580 edl->session->labels_follow_edits,
1581 edl->session->plugins_follow_edits,
1582 edl->session->autos_follow_edits);
1585 undo->update_undo_after(_("silence"), LOAD_EDITS | LOAD_TIMEBAR);
1587 update_plugin_guis();
1589 gui->update(1, 2, 1, 1, 1, 1, 0);
1590 cwindow->update(1, 0, 0, 0, 1);
1591 cwindow->playback_engine->que->
1592 send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);
1595 void MWindow::detach_transition(Transition *transition)
1597 undo->update_undo_before();
1598 hide_plugin(transition, 1);
1599 int is_video = (transition->edit->track->data_type == TRACK_VIDEO);
1600 transition->edit->detach_transition();
1602 undo->update_undo_after(_("detach transition"), LOAD_ALL);
1604 if( is_video ) restart_brender();
1605 gui->update(0, 1, 0, 0, 0, 0, 0);
1606 sync_parameters(CHANGE_EDL);
1609 void MWindow::detach_transitions()
1611 gui->lock_window("MWindow::detach_transitions 1");
1613 undo->update_undo_before();
1614 double start = edl->local_session->get_selectionstart();
1615 double end = edl->local_session->get_selectionend();
1616 edl->tracks->clear_transitions(start, end);
1619 undo->update_undo_after(_("detach transitions"), LOAD_EDITS);
1621 sync_parameters(CHANGE_EDL);
1622 gui->update(0, 1, 0, 0, 0, 0, 0);
1623 gui->unlock_window();
1626 void MWindow::paste_transition()
1628 // Only the first transition gets dropped.
1629 PluginServer *server = session->drag_pluginservers->values[0];
1631 undo->update_undo_before();
1633 strcpy(edl->session->default_atransition, server->title);
1635 strcpy(edl->session->default_vtransition, server->title);
1637 edl->tracks->paste_transition(server, session->edit_highlighted);
1639 undo->update_undo_after(_("transition"), LOAD_EDITS);
1641 if( server->video ) restart_brender();
1642 sync_parameters(CHANGE_ALL);
1645 void MWindow::paste_transitions(int track_type, char *title)
1647 gui->lock_window("MWindow::detach_transitions 1");
1649 undo->update_undo_before();
1650 double start = edl->local_session->get_selectionstart();
1651 double end = edl->local_session->get_selectionend();
1652 edl->tracks->paste_transitions(start, end, track_type, title);
1655 undo->update_undo_after(_("attach transitions"), LOAD_EDITS);
1657 sync_parameters(CHANGE_EDL);
1658 gui->update(0, 1, 0, 0, 0, 0, 0);
1659 gui->unlock_window();
1662 void MWindow::paste_transition_cwindow(Track *dest_track)
1664 PluginServer *server = session->drag_pluginservers->values[0];
1665 undo->update_undo_before();
1666 edl->tracks->paste_video_transition(server, 1);
1668 undo->update_undo_after(_("transition"), LOAD_EDITS);
1670 gui->update(0, 1, 0, 0, 0, 0, 0);
1671 sync_parameters(CHANGE_ALL);
1674 void MWindow::paste_audio_transition()
1676 PluginServer *server = scan_plugindb(edl->session->default_atransition,
1679 char string[BCTEXTLEN];
1680 sprintf(string, _("No default transition %s found."), edl->session->default_atransition);
1681 gui->show_message(string);
1685 undo->update_undo_before();
1686 edl->tracks->paste_audio_transition(server);
1688 undo->update_undo_after(_("transition"), LOAD_EDITS);
1690 sync_parameters(CHANGE_EDL);
1691 gui->update(0, 1, 0, 0, 0, 0, 0);
1694 void MWindow::paste_video_transition()
1696 PluginServer *server = scan_plugindb(edl->session->default_vtransition,
1699 char string[BCTEXTLEN];
1700 sprintf(string, _("No default transition %s found."), edl->session->default_vtransition);
1701 gui->show_message(string);
1705 undo->update_undo_before();
1707 edl->tracks->paste_video_transition(server);
1709 undo->update_undo_after(_("transition"), LOAD_EDITS);
1711 sync_parameters(CHANGE_EDL);
1713 gui->update(0, 1, 0, 0, 0, 0, 0);
1716 void MWindow::shuffle_edits()
1718 gui->lock_window("MWindow::shuffle_edits 1");
1720 undo->update_undo_before();
1721 double start = edl->local_session->get_selectionstart();
1722 double end = edl->local_session->get_selectionend();
1724 edl->tracks->shuffle_edits(start, end);
1727 undo->update_undo_after(_("shuffle edits"), LOAD_EDITS | LOAD_TIMEBAR);
1729 sync_parameters(CHANGE_EDL);
1731 gui->update(0, 1, 1, 0, 0, 0, 0);
1732 gui->unlock_window();
1735 void MWindow::reverse_edits()
1737 gui->lock_window("MWindow::reverse_edits 1");
1739 undo->update_undo_before();
1740 double start = edl->local_session->get_selectionstart();
1741 double end = edl->local_session->get_selectionend();
1743 edl->tracks->reverse_edits(start, end);
1746 undo->update_undo_after(_("reverse edits"), LOAD_EDITS | LOAD_TIMEBAR);
1748 sync_parameters(CHANGE_EDL);
1750 gui->update(0, 1, 1, 0, 0, 0, 0);
1751 gui->unlock_window();
1754 void MWindow::align_edits()
1756 gui->lock_window("MWindow::align_edits 1");
1758 undo->update_undo_before();
1759 double start = edl->local_session->get_selectionstart();
1760 double end = edl->local_session->get_selectionend();
1762 edl->tracks->align_edits(start, end);
1765 undo->update_undo_after(_("align edits"), LOAD_EDITS | LOAD_TIMEBAR);
1767 sync_parameters(CHANGE_EDL);
1769 gui->update(0, 1, 1, 0, 0, 0, 0);
1770 gui->unlock_window();
1773 void MWindow::set_edit_length(double length)
1775 gui->lock_window("MWindow::detach_transitions 1");
1777 undo->update_undo_before();
1778 double start = edl->local_session->get_selectionstart();
1779 double end = edl->local_session->get_selectionend();
1781 edl->tracks->set_edit_length(start, end, length);
1784 undo->update_undo_after(_("edit length"), LOAD_EDITS | LOAD_TIMEBAR);
1786 sync_parameters(CHANGE_EDL);
1788 gui->update(0, 1, 1, 0, 0, 0, 0);
1789 gui->unlock_window();
1793 void MWindow::set_transition_length(Transition *transition, double length)
1795 gui->lock_window("MWindow::detach_transitions 1");
1797 undo->update_undo_before();
1798 //double start = edl->local_session->get_selectionstart();
1799 //double end = edl->local_session->get_selectionend();
1801 edl->tracks->set_transition_length(transition, length);
1804 undo->update_undo_after(_("transition length"), LOAD_EDITS);
1806 edl->session->default_transition_length = length;
1807 sync_parameters(CHANGE_PARAMS);
1808 gui->update(0, 1, 0, 0, 0, 0, 0);
1809 gui->unlock_window();
1812 void MWindow::set_transition_length(double length)
1814 gui->lock_window("MWindow::detach_transitions 1");
1816 undo->update_undo_before();
1817 double start = edl->local_session->get_selectionstart();
1818 double end = edl->local_session->get_selectionend();
1820 edl->tracks->set_transition_length(start, end, length);
1823 undo->update_undo_after(_("transition length"), LOAD_EDITS);
1825 edl->session->default_transition_length = length;
1826 sync_parameters(CHANGE_PARAMS);
1828 gui->update(0, 1, 0, 0, 0, 0, 0);
1829 gui->unlock_window();
1833 void MWindow::redo_entry(BC_WindowBase *calling_window_gui)
1836 calling_window_gui->unlock_window();
1838 cwindow->playback_engine->que->
1839 send_command(STOP, CHANGE_NONE, 0, 0);
1840 cwindow->playback_engine->interrupt_playback(0);
1842 for( int i = 0; i < vwindows.size(); i++ ) {
1843 if( vwindows.get(i)->is_running() ) {
1844 vwindows.get(i)->playback_engine->que->
1845 send_command(STOP, CHANGE_NONE, 0, 0);
1846 vwindows.get(i)->playback_engine->interrupt_playback(0);
1850 cwindow->gui->lock_window("MWindow::redo_entry");
1851 for( int i = 0; i < vwindows.size(); i++ ) {
1852 if( vwindows.get(i)->is_running() ) {
1853 if( calling_window_gui != vwindows.get(i)->gui ) {
1854 vwindows.get(i)->gui->lock_window("MWindow::redo_entry 2");
1863 update_plugin_states();
1864 update_plugin_guis();
1866 gui->update(1, 2, 1, 1, 1, 1, 1);
1867 cwindow->update(1, 1, 1, 1, 1);
1869 if( calling_window_gui != cwindow->gui )
1870 cwindow->gui->unlock_window();
1871 if( calling_window_gui != gui )
1872 gui->unlock_window();
1875 for( int i = 0; i < vwindows.size(); i++ ) {
1876 if( vwindows.get(i)->is_running() ) {
1877 if( calling_window_gui != vwindows.get(i)->gui ) {
1878 vwindows.get(i)->gui->unlock_window();
1883 cwindow->playback_engine->que->
1884 send_command(CURRENT_FRAME, CHANGE_ALL, edl, 1);
1888 void MWindow::resize_track(Track *track, int w, int h)
1890 undo->update_undo_before();
1891 // We have to move all maskpoints so they do not move in relation to image areas
1892 ((MaskAutos*)track->automation->autos[AUTOMATION_MASK])->translate_masks(
1893 (w - track->track_w) / 2,
1894 (h - track->track_h) / 2);
1897 undo->update_undo_after(_("resize track"), LOAD_ALL);
1901 sync_parameters(CHANGE_EDL);
1905 void MWindow::set_inpoint(int is_mwindow)
1907 undo->update_undo_before();
1908 edl->set_inpoint(edl->local_session->get_selectionstart(1));
1910 undo->update_undo_after(_("in point"), LOAD_TIMEBAR);
1913 gui->lock_window("MWindow::set_inpoint 1");
1915 gui->update_timebar(1);
1917 gui->unlock_window();
1921 cwindow->gui->lock_window("MWindow::set_inpoint 2");
1923 cwindow->gui->timebar->update(1);
1925 cwindow->gui->unlock_window();
1929 void MWindow::set_outpoint(int is_mwindow)
1931 undo->update_undo_before();
1932 edl->set_outpoint(edl->local_session->get_selectionend(1));
1934 undo->update_undo_after(_("out point"), LOAD_TIMEBAR);
1937 gui->lock_window("MWindow::set_outpoint 1");
1939 gui->update_timebar(1);
1941 gui->unlock_window();
1945 cwindow->gui->lock_window("MWindow::set_outpoint 2");
1947 cwindow->gui->timebar->update(1);
1949 cwindow->gui->unlock_window();
1953 void MWindow::splice(EDL *source)
1957 undo->update_undo_before();
1958 double source_start = source->local_session->get_selectionstart();
1959 double source_end = source->local_session->get_selectionend();
1960 source->copy(source_start, source_end, 1, 0, 0, &file, "", 1);
1962 double start = edl->local_session->get_selectionstart();
1963 //double end = edl->local_session->get_selectionend();
1965 paste(start, start, &file,
1966 edl->session->labels_follow_edits,
1967 edl->session->plugins_follow_edits,
1968 edl->session->autos_follow_edits);
1970 // Position at end of clip
1971 edl->local_session->set_selectionstart(start + source_end - source_start);
1972 edl->local_session->set_selectionend(start + source_end - source_start);
1975 undo->update_undo_after(_("splice"), LOAD_EDITS | LOAD_TIMEBAR);
1976 update_plugin_guis();
1978 gui->update(1, 1, 1, 1, 0, 1, 0);
1979 sync_parameters(CHANGE_EDL);
1982 void MWindow::save_clip(EDL *new_edl, const char *txt)
1984 new_edl->local_session->set_selectionstart(0);
1985 new_edl->local_session->set_selectionend(0);
1986 sprintf(new_edl->local_session->clip_title, _("Clip %d"),
1987 session->clip_number++);
1988 char duration[BCTEXTLEN];
1989 Units::totext(duration, new_edl->tracks->total_length(),
1990 new_edl->session->time_format,
1991 new_edl->session->sample_rate,
1992 new_edl->session->frame_rate,
1993 new_edl->session->frames_per_foot);
1995 Track *track = new_edl->tracks->first;
1996 const char *path = edl->path;
1997 for( ; (!path || !*path) && track; track=track->next ) {
1998 if( !track->record ) continue;
1999 Edit *edit = track->edits->first;
2000 if( !edit ) continue;
2001 Indexable *indexable = edit->get_source();
2002 if( !indexable ) continue;
2003 path = indexable->path;
2006 time_t now; time(&now);
2007 struct tm *tm = localtime(&now);
2008 char *cp = new_edl->local_session->clip_notes;
2009 int n, sz = sizeof(new_edl->local_session->clip_notes)-1;
2011 n = snprintf(cp, sz, "%s", txt);
2014 n = snprintf(cp, sz,
2015 "%02d/%02d/%02d %02d:%02d:%02d, +%s\n",
2016 tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
2017 tm->tm_hour, tm->tm_min, tm->tm_sec, duration);
2019 if( path && *path ) {
2021 char title[BCTEXTLEN];
2022 fs.extract_name(title, path);
2023 n = snprintf(cp, sz, "%s", title);
2028 edl->update_assets(new_edl);
2029 gui->unlock_window();
2031 awindow->clip_edit->create_clip(new_edl);
2033 gui->lock_window("MWindow::save_clip");
2037 void MWindow::to_clip(EDL *edl, const char *txt)
2042 gui->lock_window("MWindow::to_clip 1");
2043 start = edl->local_session->get_selectionstart();
2044 end = edl->local_session->get_selectionend();
2046 if( EQUIV(end, start) ) {
2048 end = edl->tracks->total_length();
2051 // Don't copy all since we don't want the clips twice.
2052 edl->copy(start, end, 0, 0, 0, &file, "", 1);
2054 EDL *new_edl = new EDL(edl);
2055 new_edl->create_objects();
2056 new_edl->load_xml(&file, LOAD_ALL);
2057 save_clip(new_edl, txt);
2058 gui->unlock_window();
2061 int MWindow::toggle_label(int is_mwindow)
2063 double position1, position2;
2064 undo->update_undo_before();
2066 if( cwindow->playback_engine->is_playing_back ) {
2067 position1 = position2 =
2068 cwindow->playback_engine->get_tracking_position();
2071 position1 = edl->local_session->get_selectionstart(1);
2072 position2 = edl->local_session->get_selectionend(1);
2075 position1 = edl->align_to_frame(position1, 0);
2076 position2 = edl->align_to_frame(position2, 0);
2078 //printf("MWindow::toggle_label 1\n");
2080 edl->labels->toggle_label(position1, position2);
2084 gui->lock_window("MWindow::toggle_label 1");
2086 gui->update_timebar(0);
2087 gui->activate_timeline();
2090 gui->unlock_window();
2094 cwindow->gui->lock_window("MWindow::toggle_label 2");
2096 cwindow->gui->timebar->update(1);
2098 cwindow->gui->unlock_window();
2101 awindow->gui->async_update_assets();
2103 undo->update_undo_after(_("label"), LOAD_TIMEBAR);
2107 void MWindow::trim_selection()
2109 undo->update_undo_before();
2112 edl->trim_selection(edl->local_session->get_selectionstart(),
2113 edl->local_session->get_selectionend(),
2114 edl->session->labels_follow_edits,
2115 edl->session->plugins_follow_edits,
2116 edl->session->autos_follow_edits);
2119 undo->update_undo_after(_("trim selection"), LOAD_EDITS | LOAD_TIMEBAR);
2120 update_plugin_guis();
2121 gui->update(1, 2, 1, 1, 1, 1, 0);
2122 cwindow->update(1, 0, 0, 0, 1);
2124 cwindow->playback_engine->que->
2125 send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);
2129 void MWindow::undo_entry(BC_WindowBase *calling_window_gui)
2131 calling_window_gui->unlock_window();
2133 cwindow->playback_engine->que->
2134 send_command(STOP, CHANGE_NONE, 0, 0);
2135 cwindow->playback_engine->interrupt_playback(0);
2137 //printf("MWindow::undo_entry %d %d\n", __LINE__, vwindows.size());
2138 for( int i = 0; i < vwindows.size(); i++ ) {
2139 if( vwindows.get(i)->is_running() ) {
2140 vwindows.get(i)->playback_engine->que->
2141 send_command(STOP, CHANGE_NONE, 0, 0);
2142 vwindows.get(i)->playback_engine->interrupt_playback(0);
2146 cwindow->gui->lock_window("MWindow::undo_entry 1");
2147 for( int i = 0; i < vwindows.size(); i++ ) {
2148 if( vwindows.get(i)->is_running() ) {
2149 if( calling_window_gui != vwindows.get(i)->gui ) {
2150 vwindows.get(i)->gui->lock_window("MWindow::undo_entry 4");
2154 gui->lock_window("MWindow::undo_entry 2");
2160 update_plugin_states();
2161 update_plugin_guis();
2163 gui->update(1, 2, 1, 1, 1, 1, 1);
2164 gui->unlock_window();
2165 cwindow->update(1, 1, 1, 1, 1);
2166 cwindow->gui->unlock_window();
2168 for( int i = 0; i < vwindows.size(); i++ ) {
2169 if( vwindows.get(i)->is_running() ) {
2170 if( calling_window_gui != vwindows.get(i)->gui ) {
2171 vwindows.get(i)->gui->unlock_window();
2176 if( calling_window_gui != gui )
2177 gui->unlock_window();
2179 awindow->gui->async_update_assets();
2181 cwindow->playback_engine->que->
2182 send_command(CURRENT_FRAME, CHANGE_ALL, edl, 1);
2183 calling_window_gui->lock_window("MWindow::undo_entry 4");
2187 void MWindow::new_folder(const char *new_folder)
2189 undo->update_undo_before();
2190 edl->new_folder(new_folder);
2191 undo->update_undo_after(_("new folder"), LOAD_ALL);
2192 awindow->gui->async_update_assets();
2195 void MWindow::delete_folder(char *folder)
2197 // undo->update_undo_after(_("delete folder"), LOAD_ALL);
2200 void MWindow::select_point(double position)
2202 edl->local_session->set_selectionstart(position);
2203 edl->local_session->set_selectionend(position);
2206 cwindow->update(1, 0, 0, 0, 1);
2208 update_plugin_guis();
2209 gui->update_patchbay();
2210 gui->hide_cursor(0);
2211 gui->draw_cursor(0);
2212 gui->mainclock->update(edl->local_session->get_selectionstart(1));
2213 gui->zoombar->update();
2214 gui->update_timebar(0);
2215 gui->flash_canvas(0);
2222 void MWindow::map_audio(int pattern)
2224 undo->update_undo_before();
2225 remap_audio(pattern);
2226 undo->update_undo_after(
2227 pattern == MWindow::AUDIO_1_TO_1 ? _("map 1:1") : _("map 5.1:2"),
2229 sync_parameters(CHANGE_PARAMS);
2230 gui->update(0, 1, 0, 0, 1, 0, 0);
2233 void MWindow::remap_audio(int pattern)
2235 int current_channel = 0;
2236 int current_track = 0;
2237 for( Track *current = edl->tracks->first; current; current = NEXT ) {
2238 if( current->data_type == TRACK_AUDIO &&
2240 Autos *pan_autos = current->automation->autos[AUTOMATION_PAN];
2241 PanAuto *pan_auto = (PanAuto*)pan_autos->get_auto_for_editing(-1);
2243 for( int i = 0; i < MAXCHANNELS; i++ ) {
2244 pan_auto->values[i] = 0.0;
2247 if( pattern == MWindow::AUDIO_1_TO_1 ) {
2248 pan_auto->values[current_channel] = 1.0;
2251 if( pattern == MWindow::AUDIO_5_1_TO_2 ) {
2252 switch( current_track ) {
2254 pan_auto->values[0] = 0.5;
2255 pan_auto->values[1] = 0.5;
2258 pan_auto->values[0] = 1;
2261 pan_auto->values[1] = 1;
2264 pan_auto->values[0] = 1;
2267 pan_auto->values[1] = 1;
2270 pan_auto->values[0] = 0.5;
2271 pan_auto->values[1] = 0.5;
2276 BC_Pan::calculate_stick_position(edl->session->audio_channels,
2277 edl->session->achannel_positions, pan_auto->values,
2278 MAX_PAN, PAN_RADIUS, pan_auto->handle_x, pan_auto->handle_y);
2282 if( current_channel >= edl->session->audio_channels )
2283 current_channel = 0;
2288 void MWindow::cut_commercials()
2290 undo->update_undo_before();
2291 commercials->scan_media();
2294 undo->update_undo_after(_("cut ads"), LOAD_EDITS | LOAD_TIMEBAR);
2297 update_plugin_guis();
2298 gui->update(1, 2, 1, 1, 1, 1, 0);
2299 cwindow->update(1, 0, 0, 0, 1);
2300 cwindow->playback_engine->que->
2301 send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);