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,
1156 double position, int load_mode, Track *first_track, RecordLabels *labels,
1157 int edit_labels, int edit_plugins, int edit_autos, int overwrite)
1159 if( load_mode == LOADMODE_RESOURCESONLY )
1160 load_mode = LOADMODE_ASSETSONLY;
1161 const int debug = 0;
1162 if( debug ) printf("MWindow::load_assets %d\n", __LINE__);
1163 if( position < 0 ) position = edl->local_session->get_selectionstart();
1165 ArrayList<EDL*> new_edls;
1166 for( int i = 0; i < new_assets->total; i++ ) {
1167 Indexable *indexable = new_assets->get(i);
1168 if( indexable->is_asset ) {
1169 remove_asset_from_caches((Asset*)indexable);
1171 EDL *new_edl = new EDL;
1172 new_edl->create_objects();
1173 new_edl->copy_session(edl);
1174 new_edls.append(new_edl);
1177 if( indexable->is_asset ) {
1178 if( debug ) printf("MWindow::load_assets %d\n", __LINE__);
1179 if( debug ) ((Asset*)indexable)->dump();
1180 asset_to_edl(new_edl, (Asset*)indexable);
1183 edl_to_nested(new_edl, (EDL*)indexable);
1184 if( debug ) printf("MWindow::load_assets %d\n", __LINE__);
1188 for( RecordLabel *label = labels->first; label; label = label->next ) {
1189 new_edl->labels->toggle_label(label->position, label->position);
1193 if( debug ) printf("MWindow::load_assets %d\n", __LINE__);
1195 paste_edls(&new_edls, load_mode, first_track, position,
1196 edit_labels, edit_plugins, edit_autos, overwrite);
1197 if( debug ) printf("MWindow::load_assets %d\n", __LINE__);
1200 for( int i = 0; i < new_edls.size(); i++ )
1201 new_edls.get(i)->Garbage::remove_user();
1203 if( debug ) printf("MWindow::load_assets %d\n", __LINE__);
1206 int MWindow::paste_automation()
1208 int64_t len = gui->get_clipboard()->clipboard_len(SECONDARY_SELECTION);
1211 undo->update_undo_before();
1212 char *string = new char[len + 1];
1213 gui->get_clipboard()->from_clipboard(string,
1215 BC_PRIMARY_SELECTION);
1217 file.read_from_string(string);
1219 double start = edl->local_session->get_selectionstart();
1220 double end = edl->local_session->get_selectionend();
1221 edl->tracks->clear_automation(start, end);
1222 edl->tracks->paste_automation(start, &file, 0, 1,
1223 edl->session->typeless_keyframes);
1225 undo->update_undo_after(_("paste keyframes"), LOAD_AUTOMATION);
1229 update_plugin_guis();
1230 gui->draw_overlays(1);
1231 sync_parameters(CHANGE_PARAMS);
1232 gui->update_patchbay();
1233 cwindow->update(1, 0, 0);
1239 int MWindow::paste_default_keyframe()
1241 int64_t len = gui->get_clipboard()->clipboard_len(SECONDARY_SELECTION);
1244 undo->update_undo_before();
1245 char *string = new char[len + 1];
1246 gui->get_clipboard()->from_clipboard(string,
1248 BC_PRIMARY_SELECTION);
1250 file.read_from_string(string);
1251 double start = edl->local_session->get_selectionstart();
1252 edl->tracks->paste_automation(start, &file, 1, 0,
1253 edl->session->typeless_keyframes);
1254 // edl->tracks->paste_default_keyframe(&file);
1255 undo->update_undo_after(_("paste default keyframe"), LOAD_AUTOMATION);
1258 update_plugin_guis();
1259 gui->draw_overlays(1);
1260 sync_parameters(CHANGE_PARAMS);
1261 gui->update_patchbay();
1262 cwindow->update(1, 0, 0);
1271 // Insert edls with project deletion and index file generation.
1272 int MWindow::paste_edls(ArrayList<EDL*> *new_edls, int load_mode,
1273 Track *first_track, double current_position,
1274 int edit_labels, int edit_plugins, int edit_autos,
1278 ArrayList<Track*> destination_tracks;
1279 int need_new_tracks = 0;
1282 if( !new_edls->total ) return 0;
1285 // double original_length = edl->tracks->total_playable_length();
1286 // double original_preview_end = edl->local_session->preview_end;
1289 // Delete current project
1290 if( load_mode == LOADMODE_REPLACE ||
1291 load_mode == LOADMODE_REPLACE_CONCATENATE ) {
1293 edl->save_defaults(defaults);
1295 edl->Garbage::remove_user();
1297 edl->create_objects();
1298 edl->copy_session(new_edls->values[0]);
1299 gui->mainmenu->update_toggles(0);
1300 gui->unlock_window();
1301 gwindow->gui->update_toggles(1);
1302 gui->lock_window("MWindow::paste_edls");
1304 // Insert labels for certain modes constitutively
1308 // Force reset of preview
1309 // original_length = 0;
1310 // original_preview_end = -1;
1316 // Create new tracks in master EDL
1317 if( load_mode == LOADMODE_REPLACE ||
1318 load_mode == LOADMODE_REPLACE_CONCATENATE ||
1319 load_mode == LOADMODE_NEW_TRACKS ) {
1321 need_new_tracks = 1;
1322 for( int i = 0; i < new_edls->total; i++ ) {
1323 EDL *new_edl = new_edls->values[i];
1324 for( Track *current = new_edl->tracks->first;
1327 if( current->data_type == TRACK_VIDEO ) {
1328 edl->tracks->add_video_track(0, 0);
1329 if( current->draw ) edl->tracks->last->draw = 1;
1330 destination_tracks.append(edl->tracks->last);
1333 if( current->data_type == TRACK_AUDIO ) {
1334 edl->tracks->add_audio_track(0, 0);
1335 destination_tracks.append(edl->tracks->last);
1338 if( current->data_type == TRACK_SUBTITLE ) {
1339 edl->tracks->add_subttl_track(0, 0);
1340 destination_tracks.append(edl->tracks->last);
1342 edl->session->highlighted_track = edl->tracks->total() - 1;
1345 // Base track count on first EDL only for concatenation
1346 if( load_mode == LOADMODE_REPLACE_CONCATENATE ) break;
1351 // Recycle existing tracks of master EDL
1352 if( load_mode == LOADMODE_CONCATENATE ||
1353 load_mode == LOADMODE_PASTE ||
1354 load_mode == LOADMODE_NESTED ) {
1357 // The point of this is to shift forward labels after the selection so they can
1358 // then be shifted back to their original locations without recursively
1359 // shifting back every paste.
1360 if( (load_mode == LOADMODE_PASTE || load_mode == LOADMODE_NESTED) &&
1361 edl->session->labels_follow_edits )
1362 edl->labels->clear(edl->local_session->get_selectionstart(),
1363 edl->local_session->get_selectionend(),
1366 Track *current = first_track ? first_track : edl->tracks->first;
1367 for( ; current; current = NEXT) {
1368 if( current->record ) {
1369 destination_tracks.append(current);
1376 int destination_track = 0;
1377 double *paste_position = new double[destination_tracks.total];
1379 // Iterate through the edls
1380 for( int i = 0; i < new_edls->total; i++ ) {
1382 EDL *new_edl = new_edls->values[i];
1383 double edl_length = new_edl->local_session->clipboard_length ?
1384 new_edl->local_session->clipboard_length :
1385 new_edl->tracks->total_length();
1386 // printf("MWindow::paste_edls 2 %f %f\n",
1387 // new_edl->local_session->clipboard_length,
1388 // new_edl->tracks->total_length());
1392 // Convert EDL to master rates
1393 new_edl->resample(new_edl->session->sample_rate,
1394 edl->session->sample_rate,
1396 new_edl->resample(new_edl->session->frame_rate,
1397 edl->session->frame_rate,
1400 // Add assets and prepare index files
1401 for( Asset *new_asset = new_edl->assets->first;
1403 new_asset = new_asset->next ) {
1404 mainindexes->add_next_asset(0, new_asset);
1406 // Capture index file status from mainindex test
1407 edl->update_assets(new_edl);
1409 // Get starting point of insertion. Need this to paste labels.
1410 switch( load_mode ) {
1411 case LOADMODE_REPLACE:
1412 case LOADMODE_NEW_TRACKS:
1413 current_position = 0;
1416 case LOADMODE_CONCATENATE:
1417 case LOADMODE_REPLACE_CONCATENATE:
1418 destination_track = 0;
1419 if( destination_tracks.total )
1420 current_position = destination_tracks.values[0]->get_length();
1422 current_position = 0;
1425 case LOADMODE_PASTE:
1426 case LOADMODE_NESTED:
1427 destination_track = 0;
1429 for( int j = 0; j < destination_tracks.total; j++ ) {
1430 paste_position[j] = (current_position >= 0) ?
1432 edl->local_session->get_selectionstart();
1437 case LOADMODE_RESOURCESONLY:
1438 edl->add_clip(new_edl);
1443 if( load_mode != LOADMODE_RESOURCESONLY &&
1444 load_mode != LOADMODE_ASSETSONLY ) {
1446 //printf("MWindow::paste_edls %f %f\n", current_position, edl_length);
1447 if( load_mode == LOADMODE_PASTE ||
1448 load_mode == LOADMODE_NESTED )
1449 edl->labels->insert_labels(new_edl->labels,
1450 destination_tracks.total ? paste_position[0] : 0.0,
1454 edl->labels->insert_labels(new_edl->labels,
1460 for( Track *new_track = new_edl->tracks->first;
1462 new_track = new_track->next ) {
1463 // Get destination track of same type as new_track
1465 k < destination_tracks.total &&
1466 destination_tracks.values[destination_track]->data_type != new_track->data_type;
1467 k++, destination_track++ ) {
1468 if( destination_track >= destination_tracks.total - 1 )
1469 destination_track = 0;
1472 // Insert data into destination track
1473 if( destination_track < destination_tracks.total &&
1474 destination_tracks.values[destination_track]->data_type == new_track->data_type ) {
1475 Track *track = destination_tracks.values[destination_track];
1477 // Replace default keyframes if first EDL and new tracks were created.
1478 // This means data copied from one track and pasted to another won't retain
1479 // the camera position unless it's a keyframe. If it did, previous data in the
1480 // track might get unknowingly corrupted. Ideally we would detect when differing
1481 // default keyframes existed and create discrete keyframes for both.
1482 int replace_default = (i == 0) && need_new_tracks;
1484 //printf("MWindow::paste_edls 1 %d\n", replace_default);
1485 // Insert new track at current position
1486 switch( load_mode ) {
1487 case LOADMODE_REPLACE_CONCATENATE:
1488 case LOADMODE_CONCATENATE:
1489 current_position = track->get_length();
1492 case LOADMODE_PASTE:
1493 case LOADMODE_NESTED:
1494 current_position = paste_position[destination_track];
1495 paste_position[destination_track] += new_track->get_length();
1499 track->clear(current_position,
1500 current_position + new_track->get_length(),
1502 edit_labels, edit_plugins, edit_autos,
1507 track->insert_track(new_track, current_position, replace_default,
1508 edit_plugins, edit_autos, edl_length);
1512 // Get next destination track
1513 destination_track++;
1514 if( destination_track >= destination_tracks.total )
1515 destination_track = 0;
1519 if( load_mode == LOADMODE_PASTE ||
1520 load_mode == LOADMODE_NESTED )
1521 current_position += edl_length;
1525 // Move loading of clips and vwindow to the end - this fixes some
1526 // strange issue, for index not being shown
1527 // Assume any paste operation from the same EDL won't contain any clips.
1528 // If it did it would duplicate every clip here.
1529 for( int i = 0; i < new_edls->total; i++ ) {
1530 EDL *new_edl = new_edls->values[i];
1532 for( int j = 0; j < new_edl->clips.total; j++ ) {
1533 edl->add_clip(new_edl->clips.values[j]);
1536 if( new_edl->total_vwindow_edls() ) {
1537 // if( edl->vwindow_edl )
1538 // edl->vwindow_edl->Garbage::remove_user();
1539 // edl->vwindow_edl = new EDL(edl);
1540 // edl->vwindow_edl->create_objects();
1541 // edl->vwindow_edl->copy_all(new_edl->vwindow_edl);
1543 for( int j = 0; j < new_edl->total_vwindow_edls(); j++ ) {
1544 EDL *vwindow_edl = new EDL(edl);
1545 vwindow_edl->create_objects();
1546 vwindow_edl->copy_all(new_edl->get_vwindow_edl(j));
1547 edl->append_vwindow_edl(vwindow_edl, 0);
1552 if( paste_position ) delete [] paste_position;
1554 // This is already done in load_filenames and everything else that uses paste_edls
1555 // update_project(load_mode);
1557 // Fix preview range
1558 // if( EQUIV(original_length, original_preview_end) )
1560 // edl->local_session->preview_end = edl->tracks->total_playable_length();
1563 // Start examining next batch of index files
1564 mainindexes->start_build();
1566 // Don't save a backup after loading since the loaded file is on disk already.
1571 void MWindow::paste_silence()
1573 double start = edl->local_session->get_selectionstart();
1574 double end = edl->local_session->get_selectionend();
1575 undo->update_undo_before();
1576 edl->paste_silence(start, end,
1577 edl->session->labels_follow_edits,
1578 edl->session->plugins_follow_edits,
1579 edl->session->autos_follow_edits);
1582 undo->update_undo_after(_("silence"), LOAD_EDITS | LOAD_TIMEBAR);
1584 update_plugin_guis();
1586 gui->update(1, 2, 1, 1, 1, 1, 0);
1587 cwindow->update(1, 0, 0, 0, 1);
1588 cwindow->playback_engine->que->
1589 send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);
1592 void MWindow::detach_transition(Transition *transition)
1594 undo->update_undo_before();
1595 hide_plugin(transition, 1);
1596 int is_video = (transition->edit->track->data_type == TRACK_VIDEO);
1597 transition->edit->detach_transition();
1599 undo->update_undo_after(_("detach transition"), LOAD_ALL);
1601 if( is_video ) restart_brender();
1602 gui->update(0, 1, 0, 0, 0, 0, 0);
1603 sync_parameters(CHANGE_EDL);
1606 void MWindow::detach_transitions()
1608 gui->lock_window("MWindow::detach_transitions 1");
1610 undo->update_undo_before();
1611 double start = edl->local_session->get_selectionstart();
1612 double end = edl->local_session->get_selectionend();
1613 edl->tracks->clear_transitions(start, end);
1616 undo->update_undo_after(_("detach transitions"), LOAD_EDITS);
1618 sync_parameters(CHANGE_EDL);
1619 gui->update(0, 1, 0, 0, 0, 0, 0);
1620 gui->unlock_window();
1623 void MWindow::paste_transition()
1625 // Only the first transition gets dropped.
1626 PluginServer *server = session->drag_pluginservers->values[0];
1628 undo->update_undo_before();
1630 strcpy(edl->session->default_atransition, server->title);
1632 strcpy(edl->session->default_vtransition, server->title);
1634 edl->tracks->paste_transition(server, session->edit_highlighted);
1636 undo->update_undo_after(_("transition"), LOAD_EDITS);
1638 if( server->video ) restart_brender();
1639 sync_parameters(CHANGE_ALL);
1642 void MWindow::paste_transitions(int track_type, char *title)
1644 gui->lock_window("MWindow::detach_transitions 1");
1646 undo->update_undo_before();
1647 double start = edl->local_session->get_selectionstart();
1648 double end = edl->local_session->get_selectionend();
1649 edl->tracks->paste_transitions(start, end, track_type, title);
1652 undo->update_undo_after(_("attach transitions"), LOAD_EDITS);
1654 sync_parameters(CHANGE_EDL);
1655 gui->update(0, 1, 0, 0, 0, 0, 0);
1656 gui->unlock_window();
1659 void MWindow::paste_transition_cwindow(Track *dest_track)
1661 PluginServer *server = session->drag_pluginservers->values[0];
1662 undo->update_undo_before();
1663 edl->tracks->paste_video_transition(server, 1);
1665 undo->update_undo_after(_("transition"), LOAD_EDITS);
1667 gui->update(0, 1, 0, 0, 0, 0, 0);
1668 sync_parameters(CHANGE_ALL);
1671 void MWindow::paste_audio_transition()
1673 PluginServer *server = scan_plugindb(edl->session->default_atransition,
1676 char string[BCTEXTLEN];
1677 sprintf(string, _("No default transition %s found."), edl->session->default_atransition);
1678 gui->show_message(string);
1682 undo->update_undo_before();
1683 edl->tracks->paste_audio_transition(server);
1685 undo->update_undo_after(_("transition"), LOAD_EDITS);
1687 sync_parameters(CHANGE_EDL);
1688 gui->update(0, 1, 0, 0, 0, 0, 0);
1691 void MWindow::paste_video_transition()
1693 PluginServer *server = scan_plugindb(edl->session->default_vtransition,
1696 char string[BCTEXTLEN];
1697 sprintf(string, _("No default transition %s found."), edl->session->default_vtransition);
1698 gui->show_message(string);
1702 undo->update_undo_before();
1704 edl->tracks->paste_video_transition(server);
1706 undo->update_undo_after(_("transition"), LOAD_EDITS);
1708 sync_parameters(CHANGE_EDL);
1710 gui->update(0, 1, 0, 0, 0, 0, 0);
1713 void MWindow::shuffle_edits()
1715 gui->lock_window("MWindow::shuffle_edits 1");
1717 undo->update_undo_before();
1718 double start = edl->local_session->get_selectionstart();
1719 double end = edl->local_session->get_selectionend();
1721 edl->tracks->shuffle_edits(start, end);
1724 undo->update_undo_after(_("shuffle edits"), LOAD_EDITS | LOAD_TIMEBAR);
1726 sync_parameters(CHANGE_EDL);
1728 gui->update(0, 1, 1, 0, 0, 0, 0);
1729 gui->unlock_window();
1732 void MWindow::reverse_edits()
1734 gui->lock_window("MWindow::reverse_edits 1");
1736 undo->update_undo_before();
1737 double start = edl->local_session->get_selectionstart();
1738 double end = edl->local_session->get_selectionend();
1740 edl->tracks->reverse_edits(start, end);
1743 undo->update_undo_after(_("reverse edits"), LOAD_EDITS | LOAD_TIMEBAR);
1745 sync_parameters(CHANGE_EDL);
1747 gui->update(0, 1, 1, 0, 0, 0, 0);
1748 gui->unlock_window();
1751 void MWindow::align_edits()
1753 gui->lock_window("MWindow::align_edits 1");
1755 undo->update_undo_before();
1756 double start = edl->local_session->get_selectionstart();
1757 double end = edl->local_session->get_selectionend();
1759 edl->tracks->align_edits(start, end);
1762 undo->update_undo_after(_("align edits"), LOAD_EDITS | LOAD_TIMEBAR);
1764 sync_parameters(CHANGE_EDL);
1766 gui->update(0, 1, 1, 0, 0, 0, 0);
1767 gui->unlock_window();
1770 void MWindow::set_edit_length(double length)
1772 gui->lock_window("MWindow::detach_transitions 1");
1774 undo->update_undo_before();
1775 double start = edl->local_session->get_selectionstart();
1776 double end = edl->local_session->get_selectionend();
1778 edl->tracks->set_edit_length(start, end, length);
1781 undo->update_undo_after(_("edit length"), LOAD_EDITS | LOAD_TIMEBAR);
1783 sync_parameters(CHANGE_EDL);
1785 gui->update(0, 1, 1, 0, 0, 0, 0);
1786 gui->unlock_window();
1790 void MWindow::set_transition_length(Transition *transition, double length)
1792 gui->lock_window("MWindow::detach_transitions 1");
1794 undo->update_undo_before();
1795 //double start = edl->local_session->get_selectionstart();
1796 //double end = edl->local_session->get_selectionend();
1798 edl->tracks->set_transition_length(transition, length);
1801 undo->update_undo_after(_("transition length"), LOAD_EDITS);
1803 edl->session->default_transition_length = length;
1804 sync_parameters(CHANGE_PARAMS);
1805 gui->update(0, 1, 0, 0, 0, 0, 0);
1806 gui->unlock_window();
1809 void MWindow::set_transition_length(double length)
1811 gui->lock_window("MWindow::detach_transitions 1");
1813 undo->update_undo_before();
1814 double start = edl->local_session->get_selectionstart();
1815 double end = edl->local_session->get_selectionend();
1817 edl->tracks->set_transition_length(start, end, length);
1820 undo->update_undo_after(_("transition length"), LOAD_EDITS);
1822 edl->session->default_transition_length = length;
1823 sync_parameters(CHANGE_PARAMS);
1825 gui->update(0, 1, 0, 0, 0, 0, 0);
1826 gui->unlock_window();
1830 void MWindow::redo_entry(BC_WindowBase *calling_window_gui)
1833 calling_window_gui->unlock_window();
1835 cwindow->playback_engine->que->
1836 send_command(STOP, CHANGE_NONE, 0, 0);
1837 cwindow->playback_engine->interrupt_playback(0);
1839 for( int i = 0; i < vwindows.size(); i++ ) {
1840 if( vwindows.get(i)->is_running() ) {
1841 vwindows.get(i)->playback_engine->que->
1842 send_command(STOP, CHANGE_NONE, 0, 0);
1843 vwindows.get(i)->playback_engine->interrupt_playback(0);
1847 cwindow->gui->lock_window("MWindow::redo_entry");
1848 for( int i = 0; i < vwindows.size(); i++ ) {
1849 if( vwindows.get(i)->is_running() ) {
1850 if( calling_window_gui != vwindows.get(i)->gui ) {
1851 vwindows.get(i)->gui->lock_window("MWindow::redo_entry 2");
1860 update_plugin_states();
1861 update_plugin_guis();
1863 gui->update(1, 2, 1, 1, 1, 1, 1);
1864 cwindow->update(1, 1, 1, 1, 1);
1866 if( calling_window_gui != cwindow->gui )
1867 cwindow->gui->unlock_window();
1868 if( calling_window_gui != gui )
1869 gui->unlock_window();
1872 for( int i = 0; i < vwindows.size(); i++ ) {
1873 if( vwindows.get(i)->is_running() ) {
1874 if( calling_window_gui != vwindows.get(i)->gui ) {
1875 vwindows.get(i)->gui->unlock_window();
1880 cwindow->playback_engine->que->
1881 send_command(CURRENT_FRAME, CHANGE_ALL, edl, 1);
1885 void MWindow::resize_track(Track *track, int w, int h)
1887 undo->update_undo_before();
1888 // We have to move all maskpoints so they do not move in relation to image areas
1889 ((MaskAutos*)track->automation->autos[AUTOMATION_MASK])->translate_masks(
1890 (w - track->track_w) / 2,
1891 (h - track->track_h) / 2);
1894 undo->update_undo_after(_("resize track"), LOAD_ALL);
1898 sync_parameters(CHANGE_EDL);
1902 void MWindow::set_inpoint(int is_mwindow)
1904 undo->update_undo_before();
1905 edl->set_inpoint(edl->local_session->get_selectionstart(1));
1907 undo->update_undo_after(_("in point"), LOAD_TIMEBAR);
1910 gui->lock_window("MWindow::set_inpoint 1");
1912 gui->update_timebar(1);
1914 gui->unlock_window();
1918 cwindow->gui->lock_window("MWindow::set_inpoint 2");
1920 cwindow->gui->timebar->update(1);
1922 cwindow->gui->unlock_window();
1926 void MWindow::set_outpoint(int is_mwindow)
1928 undo->update_undo_before();
1929 edl->set_outpoint(edl->local_session->get_selectionend(1));
1931 undo->update_undo_after(_("out point"), LOAD_TIMEBAR);
1934 gui->lock_window("MWindow::set_outpoint 1");
1936 gui->update_timebar(1);
1938 gui->unlock_window();
1942 cwindow->gui->lock_window("MWindow::set_outpoint 2");
1944 cwindow->gui->timebar->update(1);
1946 cwindow->gui->unlock_window();
1950 void MWindow::splice(EDL *source)
1954 undo->update_undo_before();
1955 double source_start = source->local_session->get_selectionstart();
1956 double source_end = source->local_session->get_selectionend();
1957 source->copy(source_start, source_end, 1, 0, 0, &file, "", 1);
1959 double start = edl->local_session->get_selectionstart();
1960 //double end = edl->local_session->get_selectionend();
1962 paste(start, start, &file,
1963 edl->session->labels_follow_edits,
1964 edl->session->plugins_follow_edits,
1965 edl->session->autos_follow_edits);
1967 // Position at end of clip
1968 edl->local_session->set_selectionstart(start + source_end - source_start);
1969 edl->local_session->set_selectionend(start + source_end - source_start);
1972 undo->update_undo_after(_("splice"), LOAD_EDITS | LOAD_TIMEBAR);
1973 update_plugin_guis();
1975 gui->update(1, 1, 1, 1, 0, 1, 0);
1976 sync_parameters(CHANGE_EDL);
1979 void MWindow::save_clip(EDL *new_edl, const char *txt)
1981 new_edl->local_session->set_selectionstart(0);
1982 new_edl->local_session->set_selectionend(0);
1983 sprintf(new_edl->local_session->clip_title, _("Clip %d"),
1984 session->clip_number++);
1985 char duration[BCTEXTLEN];
1986 Units::totext(duration, new_edl->tracks->total_length(),
1987 new_edl->session->time_format,
1988 new_edl->session->sample_rate,
1989 new_edl->session->frame_rate,
1990 new_edl->session->frames_per_foot);
1992 Track *track = new_edl->tracks->first;
1993 const char *path = edl->path;
1994 for( ; (!path || !*path) && track; track=track->next ) {
1995 if( !track->record ) continue;
1996 Edit *edit = track->edits->first;
1997 if( !edit ) continue;
1998 Indexable *indexable = edit->get_source();
1999 if( !indexable ) continue;
2000 path = indexable->path;
2003 time_t now; time(&now);
2004 struct tm *tm = localtime(&now);
2005 char *cp = new_edl->local_session->clip_notes;
2006 int n, sz = sizeof(new_edl->local_session->clip_notes)-1;
2008 n = snprintf(cp, sz, "%s", txt);
2011 n = snprintf(cp, sz,
2012 "%02d/%02d/%02d %02d:%02d:%02d, +%s\n",
2013 tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
2014 tm->tm_hour, tm->tm_min, tm->tm_sec, duration);
2016 if( path && *path ) {
2018 char title[BCTEXTLEN];
2019 fs.extract_name(title, path);
2020 n = snprintf(cp, sz, "%s", title);
2025 edl->update_assets(new_edl);
2027 gui->get_abs_cursor_xy(cur_x, cur_y, 0);
2028 gui->unlock_window();
2030 awindow->clip_edit->create_clip(new_edl, cur_x, cur_y);
2032 gui->lock_window("MWindow::save_clip");
2036 void MWindow::to_clip(EDL *edl, const char *txt)
2041 gui->lock_window("MWindow::to_clip 1");
2042 start = edl->local_session->get_selectionstart();
2043 end = edl->local_session->get_selectionend();
2045 if( EQUIV(end, start) ) {
2047 end = edl->tracks->total_length();
2050 // Don't copy all since we don't want the clips twice.
2051 edl->copy(start, end, 0, 0, 0, &file, "", 1);
2053 EDL *new_edl = new EDL(edl);
2054 new_edl->create_objects();
2055 new_edl->load_xml(&file, LOAD_ALL);
2056 save_clip(new_edl, txt);
2057 gui->unlock_window();
2060 int MWindow::toggle_label(int is_mwindow)
2062 double position1, position2;
2063 undo->update_undo_before();
2065 if( cwindow->playback_engine->is_playing_back ) {
2066 position1 = position2 =
2067 cwindow->playback_engine->get_tracking_position();
2070 position1 = edl->local_session->get_selectionstart(1);
2071 position2 = edl->local_session->get_selectionend(1);
2074 position1 = edl->align_to_frame(position1, 0);
2075 position2 = edl->align_to_frame(position2, 0);
2077 //printf("MWindow::toggle_label 1\n");
2079 edl->labels->toggle_label(position1, position2);
2083 gui->lock_window("MWindow::toggle_label 1");
2085 gui->update_timebar(0);
2086 gui->activate_timeline();
2089 gui->unlock_window();
2093 cwindow->gui->lock_window("MWindow::toggle_label 2");
2095 cwindow->gui->timebar->update(1);
2097 cwindow->gui->unlock_window();
2100 awindow->gui->async_update_assets();
2102 undo->update_undo_after(_("label"), LOAD_TIMEBAR);
2106 void MWindow::trim_selection()
2108 undo->update_undo_before();
2111 edl->trim_selection(edl->local_session->get_selectionstart(),
2112 edl->local_session->get_selectionend(),
2113 edl->session->labels_follow_edits,
2114 edl->session->plugins_follow_edits,
2115 edl->session->autos_follow_edits);
2118 undo->update_undo_after(_("trim selection"), LOAD_EDITS | LOAD_TIMEBAR);
2119 update_plugin_guis();
2120 gui->update(1, 2, 1, 1, 1, 1, 0);
2121 cwindow->update(1, 0, 0, 0, 1);
2123 cwindow->playback_engine->que->
2124 send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);
2128 void MWindow::undo_entry(BC_WindowBase *calling_window_gui)
2130 calling_window_gui->unlock_window();
2132 cwindow->playback_engine->que->
2133 send_command(STOP, CHANGE_NONE, 0, 0);
2134 cwindow->playback_engine->interrupt_playback(0);
2136 //printf("MWindow::undo_entry %d %d\n", __LINE__, vwindows.size());
2137 for( int i = 0; i < vwindows.size(); i++ ) {
2138 if( vwindows.get(i)->is_running() ) {
2139 vwindows.get(i)->playback_engine->que->
2140 send_command(STOP, CHANGE_NONE, 0, 0);
2141 vwindows.get(i)->playback_engine->interrupt_playback(0);
2145 cwindow->gui->lock_window("MWindow::undo_entry 1");
2146 for( int i = 0; i < vwindows.size(); i++ ) {
2147 if( vwindows.get(i)->is_running() ) {
2148 if( calling_window_gui != vwindows.get(i)->gui ) {
2149 vwindows.get(i)->gui->lock_window("MWindow::undo_entry 4");
2153 gui->lock_window("MWindow::undo_entry 2");
2159 update_plugin_states();
2160 update_plugin_guis();
2162 gui->update(1, 2, 1, 1, 1, 1, 1);
2163 gui->unlock_window();
2164 cwindow->update(1, 1, 1, 1, 1);
2165 cwindow->gui->unlock_window();
2167 for( int i = 0; i < vwindows.size(); i++ ) {
2168 if( vwindows.get(i)->is_running() ) {
2169 if( calling_window_gui != vwindows.get(i)->gui ) {
2170 vwindows.get(i)->gui->unlock_window();
2175 if( calling_window_gui != gui )
2176 gui->unlock_window();
2178 awindow->gui->async_update_assets();
2180 cwindow->playback_engine->que->
2181 send_command(CURRENT_FRAME, CHANGE_ALL, edl, 1);
2182 calling_window_gui->lock_window("MWindow::undo_entry 4");
2186 void MWindow::new_folder(const char *new_folder)
2188 undo->update_undo_before();
2189 edl->new_folder(new_folder);
2190 undo->update_undo_after(_("new folder"), LOAD_ALL);
2191 awindow->gui->async_update_assets();
2194 void MWindow::delete_folder(char *folder)
2196 // undo->update_undo_after(_("delete folder"), LOAD_ALL);
2199 void MWindow::select_point(double position)
2201 edl->local_session->set_selectionstart(position);
2202 edl->local_session->set_selectionend(position);
2205 cwindow->update(1, 0, 0, 0, 1);
2207 update_plugin_guis();
2208 gui->update_patchbay();
2209 gui->hide_cursor(0);
2210 gui->draw_cursor(0);
2211 gui->mainclock->update(edl->local_session->get_selectionstart(1));
2212 gui->zoombar->update();
2213 gui->update_timebar(0);
2214 gui->flash_canvas(0);
2221 void MWindow::map_audio(int pattern)
2223 undo->update_undo_before();
2224 remap_audio(pattern);
2225 undo->update_undo_after(
2226 pattern == MWindow::AUDIO_1_TO_1 ? _("map 1:1") : _("map 5.1:2"),
2228 sync_parameters(CHANGE_PARAMS);
2229 gui->update(0, 1, 0, 0, 1, 0, 0);
2232 void MWindow::remap_audio(int pattern)
2234 int current_channel = 0;
2235 int current_track = 0;
2236 for( Track *current = edl->tracks->first; current; current = NEXT ) {
2237 if( current->data_type == TRACK_AUDIO &&
2239 Autos *pan_autos = current->automation->autos[AUTOMATION_PAN];
2240 PanAuto *pan_auto = (PanAuto*)pan_autos->get_auto_for_editing(-1);
2242 for( int i = 0; i < MAXCHANNELS; i++ ) {
2243 pan_auto->values[i] = 0.0;
2246 if( pattern == MWindow::AUDIO_1_TO_1 ) {
2247 pan_auto->values[current_channel] = 1.0;
2250 if( pattern == MWindow::AUDIO_5_1_TO_2 ) {
2251 switch( current_track ) {
2253 pan_auto->values[0] = 0.5;
2254 pan_auto->values[1] = 0.5;
2257 pan_auto->values[0] = 1;
2260 pan_auto->values[1] = 1;
2263 pan_auto->values[0] = 1;
2266 pan_auto->values[1] = 1;
2269 pan_auto->values[0] = 0.5;
2270 pan_auto->values[1] = 0.5;
2275 BC_Pan::calculate_stick_position(edl->session->audio_channels,
2276 edl->session->achannel_positions, pan_auto->values,
2277 MAX_PAN, PAN_RADIUS, pan_auto->handle_x, pan_auto->handle_y);
2281 if( current_channel >= edl->session->audio_channels )
2282 current_channel = 0;
2287 void MWindow::cut_commercials()
2289 undo->update_undo_before();
2290 commercials->scan_media();
2293 undo->update_undo_after(_("cut ads"), LOAD_EDITS | LOAD_TIMEBAR);
2296 update_plugin_guis();
2297 gui->update(1, 2, 1, 1, 1, 1, 0);
2298 cwindow->update(1, 0, 0, 0, 1);
2299 cwindow->playback_engine->que->
2300 send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);