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"
31 #include "cplayback.h"
34 #include "cwindowgui.h"
37 #include "edlsession.h"
38 #include "filesystem.h"
40 #include "floatauto.h"
41 #include "floatautos.h"
43 #include "gwindowgui.h"
45 #include "keyframes.h"
48 #include "levelwindow.h"
49 #include "localsession.h"
50 #include "mainclock.h"
51 #include "maincursor.h"
52 #include "mainerror.h"
53 #include "mainindexes.h"
55 #include "mainsession.h"
57 #include "maskautos.h"
59 #include "mwindowgui.h"
63 #include "playbackengine.h"
64 #include "pluginset.h"
65 #include "recordlabel.h"
66 #include "samplescroll.h"
67 #include "trackcanvas.h"
69 #include "trackscroll.h"
71 #include "transition.h"
72 #include "transportque.h"
74 #include "undostackitem.h"
75 #include "vplayback.h"
77 #include "vwindowgui.h"
80 #include "automation.h"
81 #include "maskautos.h"
85 void MWindow::add_audio_track_entry(int above, Track *dst)
88 add_audio_track(above, dst);
90 undo_after(_("add track"), LOAD_ALL);
93 gui->update(1, NORMAL_DRAW, 0, 0, 1, 0, 0);
94 gui->activate_timeline();
95 cwindow->refresh_frame(CHANGE_EDL);
98 void MWindow::add_video_track_entry(Track *dst)
101 add_video_track(1, dst);
102 undo_after(_("add track"), LOAD_ALL);
106 gui->update(1, NORMAL_DRAW, 0, 0, 1, 0, 0);
107 gui->activate_timeline();
108 cwindow->refresh_frame(CHANGE_EDL);
112 void MWindow::add_subttl_track_entry(Track *dst)
115 add_subttl_track(1, dst);
116 undo_after(_("add track"), LOAD_ALL);
120 gui->update(1, NORMAL_DRAW, 0, 0, 1, 0, 0);
121 gui->activate_timeline();
122 cwindow->refresh_frame(CHANGE_EDL);
127 int MWindow::add_audio_track(int above, Track *dst)
129 edl->tracks->add_audio_track(above, dst);
130 edl->tracks->update_y_pixels(theme);
135 int MWindow::add_video_track(int above, Track *dst)
137 edl->tracks->add_video_track(above, dst);
138 edl->tracks->update_y_pixels(theme);
143 int MWindow::add_subttl_track(int above, Track *dst)
145 edl->tracks->add_subttl_track(above, dst);
146 edl->tracks->update_y_pixels(theme);
151 void MWindow::asset_to_all()
153 if( !session->drag_assets->size() ) return;
154 Indexable *indexable = session->drag_assets->get(0);
156 // if( indexable->have_video() )
163 w = indexable->get_w();
164 h = indexable->get_h();
165 double new_framerate = session->drag_assets->get(0)->get_frame_rate();
166 double old_framerate = edl->session->frame_rate;
167 int old_samplerate = edl->session->sample_rate;
168 int new_samplerate = session->drag_assets->get(0)->get_sample_rate();
171 if( indexable->have_video() ) {
172 edl->session->output_w = w;
173 edl->session->output_h = h;
174 edl->session->frame_rate = new_framerate;
176 edl->session->aspect_w,
177 edl->session->aspect_h,
180 for( Track *current=edl->tracks->first; current; current=NEXT ) {
181 if( current->data_type == TRACK_VIDEO /* &&
182 current->record */ ) {
183 current->track_w = w;
184 current->track_h = h;
189 if( ((edl->session->output_w % 4) ||
190 (edl->session->output_h % 4)) &&
191 edl->session->playback_config->vconfig->driver == PLAYBACK_X11_GL ) {
192 MainError::show_error(
193 _("This project's dimensions are not multiples of 4 so\n"
194 "it can't be rendered by OpenGL."));
198 if( defaults->get("AUTOASPECT", 0) ) {
200 edl->session->aspect_w,
201 edl->session->aspect_h,
206 if( indexable->have_audio() ) {
207 edl->session->sample_rate = new_samplerate;
208 edl->resample(old_framerate, new_framerate, TRACK_VIDEO);
209 edl->resample(old_samplerate, new_samplerate, TRACK_AUDIO);
214 undo_after(_("asset to all"), LOAD_ALL);
216 gui->update(1, FORCE_REDRAW, 1, 1, 1, 1, 0);
217 sync_parameters(CHANGE_ALL);
221 void MWindow::asset_to_size()
223 if( !session->drag_assets->size() ) return;
224 Indexable *indexable = session->drag_assets->get(0);
226 if( indexable->have_video() ) {
231 w = indexable->get_w();
232 h = indexable->get_h();
233 edl->session->output_w = w;
234 edl->session->output_h = h;
236 if( ((edl->session->output_w % 4) ||
237 (edl->session->output_h % 4)) &&
238 edl->session->playback_config->vconfig->driver == PLAYBACK_X11_GL ) {
239 MainError::show_error(
240 _("This project's dimensions are not multiples of 4 so\n"
241 "it can't be rendered by OpenGL."));
245 if( defaults->get("AUTOASPECT", 0) ) {
246 create_aspect_ratio(edl->session->aspect_w,
247 edl->session->aspect_h,
254 undo_after(_("asset to size"), LOAD_ALL);
256 sync_parameters(CHANGE_ALL);
261 void MWindow::asset_to_rate()
263 if( session->drag_assets->size() &&
264 session->drag_assets->get(0)->have_video() ) {
265 double new_framerate = session->drag_assets->get(0)->get_frame_rate();
266 double old_framerate = edl->session->frame_rate;
269 edl->session->frame_rate = new_framerate;
270 edl->resample(old_framerate, new_framerate, TRACK_VIDEO);
274 undo_after(_("asset to rate"), LOAD_ALL);
276 gui->update(1, FORCE_REDRAW, 1, 1, 1, 1, 0);
277 sync_parameters(CHANGE_ALL);
282 void MWindow::clear_entry()
289 undo_after(_("clear"), LOAD_EDITS | LOAD_TIMEBAR);
292 update_plugin_guis();
293 gui->update(1, FORCE_REDRAW, 1, 1, 1, 1, 0);
294 cwindow->update(1, 0, 0, 0, 1);
295 cwindow->refresh_frame(CHANGE_EDL);
298 void MWindow::clear(int clear_handle)
300 double start = edl->local_session->get_selectionstart();
301 double end = edl->local_session->get_selectionend();
302 if( clear_handle || !EQUIV(start, end) ) {
305 edl->session->labels_follow_edits,
306 edl->session->plugins_follow_edits,
307 edl->session->autos_follow_edits);
311 void MWindow::update_gui(int changed_edl)
314 update_plugin_guis();
316 gui->update(1, FORCE_REDRAW, 1, 1, 1, 1, 0);
317 cwindow->update(1, 0, 0, 0, 1);
318 cwindow->refresh_frame(CHANGE_EDL);
321 gui->draw_overlays(1);
322 sync_parameters(CHANGE_PARAMS);
323 gui->update_patchbay();
324 cwindow->update(1, 0, 0);
328 void MWindow::set_automation_mode(int mode)
332 edl->tracks->set_automation_mode(
333 edl->local_session->get_selectionstart(),
334 edl->local_session->get_selectionend(),
336 int changed_edl = speed_after(1);
338 char string[BCSTRLEN];
339 sprintf(string,"set %s", FloatAuto::curve_name(mode));
341 !changed_edl ? LOAD_AUTOMATION :
342 LOAD_AUTOMATION + LOAD_EDITS + LOAD_TIMEBAR);
343 update_gui(changed_edl);
346 void MWindow::clear_automation()
350 edl->tracks->clear_automation(edl->local_session->get_selectionstart(),
351 edl->local_session->get_selectionend());
352 int changed_edl = speed_after(1);
354 undo_after(_("clear keyframes"),
355 !changed_edl ? LOAD_AUTOMATION :
356 LOAD_AUTOMATION + LOAD_EDITS + LOAD_TIMEBAR);
357 update_gui(changed_edl);
360 int MWindow::clear_default_keyframe()
364 edl->tracks->clear_default_keyframe();
365 int changed_edl = speed_after(1);
367 undo_after(_("clear default keyframe"),
368 !changed_edl ? LOAD_AUTOMATION :
369 LOAD_AUTOMATION + LOAD_EDITS + LOAD_TIMEBAR);
370 update_gui(changed_edl);
374 void MWindow::clear_labels()
377 clear_labels(edl->local_session->get_selectionstart(),
378 edl->local_session->get_selectionend());
379 undo_after(_("clear labels"), LOAD_TIMEBAR);
381 gui->update_timebar(1);
382 cwindow->update(0, 0, 0, 0, 1);
386 int MWindow::clear_labels(double start, double end)
390 end = edl->tracks->total_length();
392 edl->labels->clear(start, end, 0);
396 void MWindow::clear_hard_edges()
399 clear_hard_edges(edl->local_session->get_selectionstart(),
400 edl->local_session->get_selectionend());
403 undo_after(_("clear hard edges"), LOAD_EDITS);
405 gui->update(1, NORMAL_DRAW, 0, 0, 1, 0, 0);
406 cwindow->refresh_frame(CHANGE_EDL);
409 int MWindow::clear_hard_edges(double start, double end)
413 end = edl->tracks->total_length();
415 edl->clear_hard_edges(start, end);
419 void MWindow::clear_select()
421 edl->tracks->clear_selected_edits();
422 gui->draw_overlays(1);
425 void MWindow::concatenate_tracks()
428 edl->tracks->concatenate_tracks(edl->session->plugins_follow_edits,
429 edl->session->autos_follow_edits);
431 undo_after(_("concatenate tracks"), LOAD_EDITS);
434 gui->update(1, NORMAL_DRAW, 0, 0, 1, 0, 0);
435 cwindow->refresh_frame(CHANGE_EDL);
439 int MWindow::copy_flags(int copy_flags)
441 if( !edl->session->labels_follow_edits )
442 copy_flags &= ~COPY_LABELS;
443 if( !edl->session->autos_follow_edits )
444 copy_flags &= ~COPY_AUTOS;
445 if( !edl->session->plugins_follow_edits )
446 copy_flags &= ~COPY_PLUGINS;
452 copy(edl->local_session->get_selectionstart(),
453 edl->local_session->get_selectionend());
456 int MWindow::copy(double start, double end)
458 if( start == end ) return 1;
461 edl->copy(copy_flags(), start, end, &file, "", 1);
462 const char *file_string = file.string();
463 long file_length = strlen(file_string);
464 gui->to_clipboard(file_string, file_length, BC_PRIMARY_SELECTION);
465 gui->to_clipboard(file_string, file_length, SECONDARY_SELECTION);
470 int MWindow::copy_automation()
473 double start = edl->local_session->get_selectionstart();
474 double end = edl->local_session->get_selectionend();
475 edl->tracks->copy_automation(start, end, &file, 0, 1);
476 const char *file_string = file.string();
477 long file_length = strlen(file_string);
478 gui->to_clipboard(file_string, file_length, BC_PRIMARY_SELECTION);
479 gui->to_clipboard(file_string, file_length, SECONDARY_SELECTION);
483 int MWindow::copy_default_keyframe()
486 double start = edl->local_session->get_selectionstart();
487 double end = edl->local_session->get_selectionend();
488 edl->tracks->copy_automation(start, end, &file, 1, 0);
489 const char *file_string = file.string();
490 long file_length = strlen(file_string);
491 gui->to_clipboard(file_string, file_length, BC_PRIMARY_SELECTION);
492 gui->to_clipboard(file_string, file_length, SECONDARY_SELECTION);
496 // Uses cropping coordinates in edl session to crop and translate video.
497 // We modify the projector since camera automation depends on the track size.
498 void MWindow::crop_video(int mode)
501 // Clamp EDL crop region
502 if( edl->session->crop_x1 > edl->session->crop_x2 ) {
503 edl->session->crop_x1 ^= edl->session->crop_x2;
504 edl->session->crop_x2 ^= edl->session->crop_x1;
505 edl->session->crop_x1 ^= edl->session->crop_x2;
507 if( edl->session->crop_y1 > edl->session->crop_y2 ) {
508 edl->session->crop_y1 ^= edl->session->crop_y2;
509 edl->session->crop_y2 ^= edl->session->crop_y1;
510 edl->session->crop_y1 ^= edl->session->crop_y2;
513 case CROP_REFORMAT: {
514 float ctr_x = edl->session->output_w / 2.;
515 float ctr_y = edl->session->output_h / 2.;
516 float new_x = (edl->session->crop_x1 + edl->session->crop_x2) / 2.;
517 float new_y = (edl->session->crop_y1 + edl->session->crop_y2) / 2.;
518 float dx = -(new_x - ctr_x), dy = -(new_y - ctr_y);
519 edl->tracks->translate_projector(dx, dy, 1);
521 edl->session->output_w = edl->session->crop_x2 - edl->session->crop_x1;
522 edl->session->output_h = edl->session->crop_y2 - edl->session->crop_y1;
523 edl->session->crop_x1 = edl->session->crop_y1 = 0;
524 edl->session->crop_x2 = edl->session->output_w;
525 edl->session->crop_y2 = edl->session->output_h;
528 float old_w = edl->session->output_w;
529 float old_h = edl->session->output_h;
530 float new_w = edl->session->crop_x2 - edl->session->crop_x1;
531 float new_h = edl->session->crop_y2 - edl->session->crop_y1;
532 if( !new_w ) new_w = 1;
533 if( !new_h ) new_h = 1;
534 float xzoom = old_w / new_w, yzoom = old_h / new_h;
535 float new_z = bmin(xzoom, yzoom);
536 float new_x = (edl->session->crop_x1 + edl->session->crop_x2) / 2.;
537 float new_y = (edl->session->crop_y1 + edl->session->crop_y2) / 2.;
538 edl->tracks->crop_resize(new_x, new_y, new_z);
540 edl->session->crop_x1 = 0;
541 edl->session->crop_y1 = 0;
542 edl->session->crop_x2 = edl->session->output_w;
543 edl->session->crop_y2 = edl->session->output_h;
546 float old_w = edl->session->output_w;
547 float old_h = edl->session->output_h;
548 float new_w = edl->session->crop_x2 - edl->session->crop_x1;
549 float new_h = edl->session->crop_y2 - edl->session->crop_y1;
550 if( !new_w ) new_w = 1;
551 if( !new_h ) new_h = 1;
552 float xzoom = old_w / new_w, yzoom = old_h / new_h;
553 float new_z = bmin(xzoom, yzoom);
555 float new_x = (edl->session->crop_x1 + edl->session->crop_x2) / 2.;
556 float new_y = (edl->session->crop_y1 + edl->session->crop_y2) / 2.;
557 edl->tracks->crop_shrink(new_x, new_y, new_z);
561 // Recalculate aspect ratio
562 if( defaults->get("AUTOASPECT", 0) ) {
563 create_aspect_ratio(edl->session->aspect_w,
564 edl->session->aspect_h,
565 edl->session->output_w,
566 edl->session->output_h);
569 undo_after(_("crop"), LOAD_ALL);
572 cwindow->refresh_frame(CHANGE_ALL);
578 double start = edl->local_session->get_selectionstart();
579 double end = edl->local_session->get_selectionend();
580 if( EQUIV(start,end) )
586 void MWindow::blade(double position)
589 edl->blade(position);
592 undo_after(_("blade"), LOAD_EDITS | LOAD_TIMEBAR);
594 update_plugin_guis();
595 gui->update(1, FORCE_REDRAW, 1, 1, 1, 1, 0);
596 cwindow->update(1, 0, 0, 0, 1);
597 awindow->gui->async_update_assets();
598 cwindow->refresh_frame(CHANGE_EDL);
601 void MWindow::cut(double start, double end, double new_position)
605 edl->clear(start, end,
606 edl->session->labels_follow_edits,
607 edl->session->plugins_follow_edits,
608 edl->session->autos_follow_edits);
612 undo_after(_("split | cut"), LOAD_EDITS | LOAD_TIMEBAR);
613 if( new_position >= 0 ) {
614 edl->local_session->set_selectionstart(new_position);
615 edl->local_session->set_selectionend(new_position);
618 update_plugin_guis();
619 gui->update(1, FORCE_REDRAW, 1, 1, 1, 1, 0);
620 cwindow->update(1, 0, 0, 0, 1);
621 awindow->gui->async_update_assets();
622 cwindow->refresh_frame(CHANGE_EDL);
625 void MWindow::cut_left_edit()
627 double start_pos = edl->local_session->get_selectionstart(1);
628 double position = edl->prev_edit(start_pos);
629 if( position < start_pos )
630 cut(position, start_pos, position);
633 void MWindow::cut_right_edit()
635 double end_pos = edl->local_session->get_selectionend(1);
636 double position = edl->next_edit(end_pos);
637 if( end_pos < position )
638 cut(end_pos, position, end_pos);
641 void MWindow::cut_left_label()
643 double start_pos = edl->local_session->get_selectionstart(1);
644 Label *left_label = edl->labels->prev_label(start_pos);
645 if( !left_label ) return;
646 double position = left_label->position;
647 if( position < start_pos )
648 cut(position, start_pos, position);
651 void MWindow::cut_right_label()
653 double end_pos = edl->local_session->get_selectionend(1);
654 Label *right_label = edl->labels->next_label(end_pos);
655 if( !right_label ) return;
656 double position = right_label->position;
657 if( end_pos < position )
658 cut(end_pos, position, end_pos);
661 int MWindow::cut_automation()
666 edl->tracks->clear_automation(edl->local_session->get_selectionstart(),
667 edl->local_session->get_selectionend());
668 int changed_edl = speed_after(1);
670 undo_after(_("cut keyframes"),
671 !changed_edl ? LOAD_AUTOMATION :
672 LOAD_AUTOMATION + LOAD_EDITS + LOAD_TIMEBAR);
673 update_gui(changed_edl);
677 int MWindow::cut_default_keyframe()
682 copy_default_keyframe();
683 edl->tracks->clear_default_keyframe();
684 int changed_edl = speed_after(1);
686 undo_after(_("cut default keyframe"),
687 !changed_edl ? LOAD_AUTOMATION :
688 LOAD_AUTOMATION + LOAD_EDITS + LOAD_TIMEBAR);
689 update_gui(changed_edl);
694 void MWindow::delete_tracks()
697 edl->tracks->delete_tracks();
698 undo_after(_("delete tracks"), LOAD_ALL);
702 update_plugin_states();
704 gui->update(1, NORMAL_DRAW, 1, 0, 1, 0, 0);
705 cwindow->refresh_frame(CHANGE_EDL);
708 void MWindow::delete_track(Track *track)
711 edl->tracks->delete_track(track);
712 undo_after(_("delete track"), LOAD_ALL);
715 update_plugin_states();
717 gui->update(1, NORMAL_DRAW, 1, 0, 1, 0, 0);
718 cwindow->refresh_frame(CHANGE_EDL);
723 // Insert data from clipboard
724 void MWindow::insert(double position, FileXML *file,
725 int edit_labels, int edit_plugins, int edit_autos,
726 EDL *parent_edl, Track *first_track, int overwrite)
728 // For clipboard pasting make the new edl use a separate session
729 // from the master EDL. Then it can be resampled to the master rates.
730 // For splice, overwrite, and dragging need same session to get the assets.
731 EDL *edl = new EDL(parent_edl);
732 ArrayList<EDL*> new_edls;
733 uint32_t load_flags = LOAD_ALL;
736 new_edls.append(edl);
737 edl->create_objects();
742 if( parent_edl ) load_flags &= ~LOAD_SESSION;
743 if( !edl->session->autos_follow_edits ) load_flags &= ~LOAD_AUTOMATION;
744 if( !edl->session->labels_follow_edits ) load_flags &= ~LOAD_TIMEBAR;
746 edl->load_xml(file, load_flags);
749 //printf("MWindow::insert %f\n", edl->local_session->clipboard_length);
753 paste_edls(&new_edls, LOADMODE_PASTE, first_track, position,
754 edit_labels, edit_plugins, edit_autos, overwrite);
755 // if( vwindow->edl )
756 // printf("MWindow::insert 5 %f %f\n",
757 // vwindow->edl->local_session->in_point,
758 // vwindow->edl->local_session->out_point);
759 new_edls.remove_all();
760 edl->Garbage::remove_user();
761 //printf("MWindow::insert 6 %p\n", vwindow->get_edl());
764 void MWindow::insert_effects_canvas(double start,
767 Track *dest_track = session->track_highlighted;
768 if( !dest_track ) return;
772 for( int i=0; i<session->drag_pluginservers->total; ++i ) {
773 PluginServer *plugin = session->drag_pluginservers->values[i];
774 insert_effect(plugin->title, 0, dest_track,
775 i == 0 ? session->pluginset_highlighted : 0,
776 start, length, PLUGIN_STANDALONE);
780 undo_after(_("insert effect"), LOAD_EDITS | LOAD_PATCHES);
782 sync_parameters(CHANGE_EDL);
783 // GUI updated in TrackCanvas, after current_operations are reset
786 void MWindow::insert_effects_cwindow(Track *dest_track)
788 if( !dest_track ) return;
793 double length = dest_track->get_length();
795 if( edl->local_session->get_selectionend() >
796 edl->local_session->get_selectionstart() ) {
797 start = edl->local_session->get_selectionstart();
798 length = edl->local_session->get_selectionend() -
799 edl->local_session->get_selectionstart();
802 for( int i=0; i<session->drag_pluginservers->total; ++i ) {
803 PluginServer *plugin = session->drag_pluginservers->values[i];
804 insert_effect(plugin->title, 0, dest_track, 0,
805 start, length, PLUGIN_STANDALONE);
809 undo_after(_("insert effect"), LOAD_EDITS | LOAD_PATCHES);
811 sync_parameters(CHANGE_EDL);
812 gui->update(1, NORMAL_DRAW, 0, 0, 1, 0, 0);
815 void MWindow::insert_effect(char *title,
816 SharedLocation *shared_location,
819 int single_standalone)
821 Track *current = edl->tracks->first;
822 SharedLocation shared_location_local;
823 shared_location_local.copy_from(shared_location);
825 for( ; current; current=NEXT ) {
826 if( current->data_type == data_type &&
828 insert_effect(title, &shared_location_local,
829 current, 0, 0, 0, plugin_type);
832 if( plugin_type == PLUGIN_STANDALONE && single_standalone ) {
833 plugin_type = PLUGIN_SHAREDPLUGIN;
834 shared_location_local.module = edl->tracks->number_of(current);
835 shared_location_local.plugin = current->plugin_set.total - 1;
844 void MWindow::insert_effect(char *title,
845 SharedLocation *shared_location,
847 PluginSet *plugin_set,
852 KeyFrame *default_keyframe = 0;
853 PluginServer *server = 0;
854 // Get default keyframe
855 if( plugin_type == PLUGIN_STANDALONE ) {
856 default_keyframe = new KeyFrame;
857 server = new PluginServer(*scan_plugindb(title, track->data_type));
859 server->open_plugin(0, preferences, edl, 0);
860 server->save_data(default_keyframe);
862 // Insert plugin object
863 track->insert_effect(title, shared_location,
864 default_keyframe, plugin_set,
865 start, length, plugin_type);
868 if( plugin_type == PLUGIN_STANDALONE ) {
869 server->close_plugin();
871 delete default_keyframe;
875 int MWindow::modify_edithandles()
878 int handle_mode = edl->session->edit_handle_mode[session->drag_button];
879 edl->modify_edithandles(session->drag_start,
880 session->drag_position, session->drag_handle, handle_mode,
881 edl->session->labels_follow_edits,
882 edl->session->plugins_follow_edits,
883 edl->session->autos_follow_edits,
884 session->drag_edit->group_id);
885 finish_modify_handles();
886 //printf("MWindow::modify_handles 1\n");
890 int MWindow::modify_pluginhandles()
894 edl->modify_pluginhandles(session->drag_start,
895 session->drag_position,
896 session->drag_handle,
897 edl->session->edit_handle_mode[session->drag_button],
898 edl->session->labels_follow_edits,
899 edl->session->autos_follow_edits,
900 session->trim_edits);
902 finish_modify_handles();
908 // Common to edithandles and plugin handles
909 void MWindow::finish_modify_handles()
911 int edit_mode = edl->session->edit_handle_mode[session->drag_button];
912 double position = -1;
913 switch( edit_mode ) {
915 position = !session->drag_handle ?
916 session->drag_start : session->drag_position;
920 position = session->drag_position;
924 position = session->drag_start;
927 if( position >= 0 ) {
928 edl->local_session->set_selectionstart(position);
929 edl->local_session->set_selectionend(position);
931 undo_after(_("drag handle"), LOAD_EDITS | LOAD_TIMEBAR);
935 sync_parameters(CHANGE_EDL);
936 update_plugin_guis();
937 gui->update(1, FORCE_REDRAW, 1, 1, 1, 1, 0);
938 // label list can be modified
939 awindow->gui->async_update_assets();
940 cwindow->update(1, 0, 0, 0, 1);
943 void MWindow::match_output_size(Track *track)
946 track->track_w = edl->session->output_w;
947 track->track_h = edl->session->output_h;
949 undo_after(_("match output size"), LOAD_ALL);
952 sync_parameters(CHANGE_EDL);
956 void MWindow::delete_edit(Edit *edit, const char *msg, int collapse)
958 ArrayList<Edit*> edits;
960 delete_edits(&edits, msg, collapse);
963 void MWindow::delete_edits(ArrayList<Edit*> *edits, const char *msg, int collapse)
965 if( !edits->size() ) return;
967 if( edl->session->labels_follow_edits )
968 edl->delete_edit_labels(edits, collapse);
969 edl->delete_edits(edits, collapse);
972 undo_after(msg, LOAD_EDITS);
975 cwindow->refresh_frame(CHANGE_EDL);
976 update_plugin_guis();
977 gui->update(1, NORMAL_DRAW, 1, 0, 0, 0, 0);
980 void MWindow::delete_edits(int collapse)
982 ArrayList<Edit*> edits;
983 edl->tracks->get_selected_edits(&edits);
984 delete_edits(&edits,_("del edit"), collapse);
987 // collapse - delete from timeline, not collapse replace with silence
988 // packed - omit unselected from selection, unpacked - replace unselected with silence
989 void MWindow::cut_selected_edits(int collapse, int packed)
991 selected_edits_to_clipboard(packed);
992 ArrayList<Edit*> edits;
993 edl->tracks->get_selected_edits(&edits);
994 delete_edits(&edits, _("cut edit"), collapse);
998 void MWindow::move_edits(ArrayList<Edit*> *edits,
999 Track *track, double position, int mode)
1002 // lockout timebar labels update
1003 // labels can be deleted with tooltip repeater running
1004 cwindow->gui->lock_window("Tracks::move_edits");
1005 edl->tracks->move_edits(edits, track, position,
1006 edl->session->labels_follow_edits,
1007 edl->session->plugins_follow_edits,
1008 edl->session->autos_follow_edits, mode);
1009 cwindow->gui->timebar->update(1);
1010 cwindow->gui->unlock_window();
1013 undo_after(_("move edit"), LOAD_ALL);
1016 cwindow->refresh_frame(CHANGE_EDL);
1018 update_plugin_guis();
1019 gui->update(1, NORMAL_DRAW, 1, 0, 0, 0, 0);
1022 void MWindow::selected_edits_to_clipboard(int packed)
1024 EDL *new_edl = edl->selected_edits_to_clip(packed, 0, 0,
1025 edl->session->labels_follow_edits,
1026 edl->session->autos_follow_edits,
1027 edl->session->plugins_follow_edits);
1028 if( !new_edl ) return;
1030 new_edl->copy(COPY_EDL, &file, "", 1);
1031 const char *file_string = file.string();
1032 long file_length = strlen(file_string);
1033 gui->to_clipboard(file_string, file_length, BC_PRIMARY_SELECTION);
1034 gui->to_clipboard(file_string, file_length, SECONDARY_SELECTION);
1035 new_edl->remove_user();
1038 void MWindow::paste_clipboard(Track *first_track, double position, int overwrite,
1039 int edit_edits, int edit_labels, int edit_autos, int edit_plugins)
1041 int64_t len = gui->clipboard_len(BC_PRIMARY_SELECTION);
1043 char *string = new char[len];
1044 gui->from_clipboard(string, len, BC_PRIMARY_SELECTION);
1046 file.read_from_string(string);
1048 EDL *clip = new EDL();
1049 clip->create_objects();
1050 if( !clip->load_xml(&file, LOAD_ALL) ) {
1052 edl->paste_edits(clip, first_track, position, overwrite,
1053 edit_edits, edit_labels, edit_autos, edit_plugins);
1055 undo_after(_("paste clip"), LOAD_ALL);
1057 cwindow->refresh_frame(CHANGE_EDL);
1059 update_plugin_guis();
1060 gui->update(1, NORMAL_DRAW, 1, 0, 0, 0, 0);
1062 clip->remove_user();
1065 void MWindow::move_group(EDL *group, Track *first_track, double position, int overwrite)
1068 // lockout timebar labels update
1069 // labels can be deleted with tooltip repeater running
1070 cwindow->gui->lock_window("Tracks::move_group");
1072 ArrayList<Edit *>edits;
1073 edl->tracks->get_selected_edits(&edits);
1074 if( edl->session->labels_follow_edits )
1075 edl->delete_edit_labels(&edits, 0);
1076 edl->delete_edits(&edits, 0);
1077 edl->paste_edits(group, first_track, position, overwrite, 1,
1078 edl->session->labels_follow_edits,
1079 edl->session->autos_follow_edits,
1080 edl->session->plugins_follow_edits);
1081 cwindow->gui->timebar->update(1);
1082 cwindow->gui->unlock_window();
1083 // big debate over whether to do this, must either clear selected, or no tweaking
1084 // edl->tracks->clear_selected_edits();
1087 undo_after(_("move group"), LOAD_ALL);
1089 cwindow->refresh_frame(CHANGE_EDL);
1091 update_plugin_guis();
1092 gui->update(1, NORMAL_DRAW, 1, 0, 0, 0, 0);
1095 void MWindow::move_effect(Plugin *plugin, Track *track, int64_t position)
1098 edl->tracks->move_effect(plugin, track, position);
1100 undo_after(_("paste effect"), LOAD_ALL);
1103 cwindow->refresh_frame(CHANGE_EDL);
1104 update_plugin_guis();
1105 gui->update(1, NORMAL_DRAW, 0, 0, 0, 0, 0);
1108 void MWindow::move_effect(Plugin *plugin, PluginSet *plugin_set, int64_t position)
1111 edl->tracks->move_effect(plugin, plugin_set, position);
1113 undo_after(_("move effect"), LOAD_ALL);
1116 cwindow->refresh_frame(CHANGE_EDL);
1117 update_plugin_guis();
1118 gui->update(1, NORMAL_DRAW, 0, 0, 0, 0, 0);
1121 void MWindow::move_plugins_up(PluginSet *plugin_set)
1125 plugin_set->track->move_plugins_up(plugin_set);
1128 undo_after(_("move effect up"), LOAD_ALL);
1130 gui->update(1, NORMAL_DRAW, 0, 0, 0, 0, 0);
1131 sync_parameters(CHANGE_EDL);
1134 void MWindow::move_plugins_down(PluginSet *plugin_set)
1138 plugin_set->track->move_plugins_down(plugin_set);
1141 undo_after(_("move effect down"), LOAD_ALL);
1143 gui->update(1, NORMAL_DRAW, 0, 0, 0, 0, 0);
1144 sync_parameters(CHANGE_EDL);
1147 void MWindow::move_track_down(Track *track)
1150 edl->tracks->move_track_down(track);
1152 undo_after(_("move track down"), LOAD_ALL);
1155 gui->update(1, NORMAL_DRAW, 0, 0, 1, 0, 0);
1156 sync_parameters(CHANGE_EDL);
1160 void MWindow::move_tracks_down()
1163 edl->tracks->move_tracks_down();
1165 undo_after(_("move tracks down"), LOAD_ALL);
1168 gui->update(1, NORMAL_DRAW, 0, 0, 1, 0, 0);
1169 sync_parameters(CHANGE_EDL);
1173 void MWindow::move_track_up(Track *track)
1176 edl->tracks->move_track_up(track);
1178 undo_after(_("move track up"), LOAD_ALL);
1180 gui->update(1, NORMAL_DRAW, 0, 0, 1, 0, 0);
1181 sync_parameters(CHANGE_EDL);
1185 void MWindow::move_tracks_up()
1188 edl->tracks->move_tracks_up();
1190 undo_after(_("move tracks up"), LOAD_ALL);
1192 gui->update(1, NORMAL_DRAW, 0, 0, 1, 0, 0);
1193 sync_parameters(CHANGE_EDL);
1197 void MWindow::mute_selection()
1199 double start = edl->local_session->get_selectionstart();
1200 double end = edl->local_session->get_selectionend();
1201 if( start != end ) {
1203 edl->clear(start, end, 0,
1204 edl->session->plugins_follow_edits,
1205 edl->session->autos_follow_edits);
1206 edl->local_session->set_selectionend(end);
1207 edl->local_session->set_selectionstart(start);
1208 edl->paste_silence(start, end, 0,
1209 edl->session->plugins_follow_edits,
1210 edl->session->autos_follow_edits);
1213 undo_after(_("mute"), LOAD_EDITS);
1216 update_plugin_guis();
1217 gui->update(1, FORCE_REDRAW, 1, 1, 1, 1, 0);
1218 cwindow->refresh_frame(CHANGE_EDL);
1223 void MWindow::overwrite(EDL *source, int all)
1227 LocalSession *src = source->local_session;
1228 double src_start = all ? 0 :
1229 src->inpoint_valid() ? src->get_inpoint() :
1230 src->outpoint_valid() ? 0 :
1231 src->get_selectionstart();
1232 double src_end = all ? source->tracks->total_length() :
1233 src->outpoint_valid() ? src->get_outpoint() :
1234 src->inpoint_valid() ? source->tracks->total_length() :
1235 src->get_selectionend();
1236 double overwrite_len = src_end - src_start;
1237 double dst_start = edl->local_session->get_selectionstart();
1238 double dst_len = edl->local_session->get_selectionend() - dst_start;
1241 if( !EQUIV(dst_len, 0) && (dst_len < overwrite_len) ) {
1242 // in/out points or selection present and shorter than overwrite range
1243 // shorten the copy range
1244 overwrite_len = dst_len;
1247 source->copy(copy_flags(), src_start, src_start + overwrite_len, &file, "", 1);
1249 // HACK around paste_edl get_start/endselection on its own
1250 // so we need to clear only when not using both io points
1251 // FIXME: need to write simple overwrite_edl to be used for overwrite function
1252 if( edl->local_session->get_inpoint() < 0 ||
1253 edl->local_session->get_outpoint() < 0 )
1254 edl->clear(dst_start, dst_start + overwrite_len, 0, 0, 0);
1256 paste(dst_start, dst_start + overwrite_len, &file, 0, 0, 0, 0, 0);
1258 edl->local_session->set_selectionstart(dst_start + overwrite_len);
1259 edl->local_session->set_selectionend(dst_start + overwrite_len);
1262 undo_after(_("overwrite"), LOAD_EDITS);
1265 update_plugin_guis();
1266 gui->update(1, NORMAL_DRAW, 1, 1, 0, 1, 0);
1267 sync_parameters(CHANGE_EDL);
1270 // For splice and overwrite
1271 int MWindow::paste(double start, double end, FileXML *file,
1272 int edit_labels, int edit_plugins, int edit_autos,
1273 Track *first_track, int overwrite)
1277 // Want to insert with assets shared with the master EDL.
1279 edit_labels, edit_plugins, edit_autos,
1280 edl, first_track, overwrite);
1285 // For editing using insertion point
1286 void MWindow::paste()
1288 paste(edl->local_session->get_selectionstart(), 0, 1, 0);
1291 void MWindow::paste(double start, Track *first_track, int clear_selection, int overwrite)
1293 //double end = edl->local_session->get_selectionend();
1294 int64_t len = gui->clipboard_len(BC_PRIMARY_SELECTION);
1297 char *string = new char[len];
1299 gui->from_clipboard(string, len, BC_PRIMARY_SELECTION);
1301 file.read_from_string(string);
1302 if( clear_selection ) clear(0);
1304 insert(start, &file,
1305 edl->session->labels_follow_edits,
1306 edl->session->plugins_follow_edits,
1307 edl->session->autos_follow_edits,
1308 0, first_track, overwrite);
1315 undo_after(_("paste"), LOAD_EDITS | LOAD_TIMEBAR);
1317 update_plugin_guis();
1318 gui->update(1, FORCE_REDRAW, 1, 1, 0, 1, 0);
1319 awindow->gui->async_update_assets();
1320 sync_parameters(CHANGE_EDL);
1325 int MWindow::paste_assets(double position, Track *dest_track, int overwrite)
1330 if( session->drag_assets->total ) {
1331 load_assets(session->drag_assets,
1332 position, LOADMODE_PASTE, dest_track, 0,
1333 edl->session->labels_follow_edits,
1334 edl->session->plugins_follow_edits,
1335 edl->session->autos_follow_edits,
1340 if( session->drag_clips->total ) {
1341 paste_edls(session->drag_clips,
1342 LOADMODE_PASTE, dest_track, position,
1343 edl->session->labels_follow_edits,
1344 edl->session->plugins_follow_edits,
1345 edl->session->autos_follow_edits,
1352 undo_after(_("paste assets"), LOAD_EDITS);
1354 gui->update(1, FORCE_REDRAW, 1, 0, 0, 1, 0);
1355 sync_parameters(CHANGE_EDL);
1359 void MWindow::load_assets(ArrayList<Indexable*> *new_assets,
1360 double position, int load_mode, Track *first_track, RecordLabels *labels,
1361 int edit_labels, int edit_plugins, int edit_autos, int overwrite)
1363 if( load_mode == LOADMODE_RESOURCESONLY )
1364 load_mode = LOADMODE_ASSETSONLY;
1365 const int debug = 0;
1366 if( debug ) printf("MWindow::load_assets %d\n", __LINE__);
1368 position = edl->local_session->get_selectionstart();
1370 ArrayList<EDL*> new_edls;
1371 for( int i=0; i<new_assets->total; ++i ) {
1372 Indexable *indexable = new_assets->get(i);
1373 if( indexable->is_asset ) {
1374 remove_asset_from_caches((Asset*)indexable);
1376 EDL *new_edl = new EDL;
1377 new_edl->create_objects();
1378 new_edl->copy_session(edl);
1379 if( !indexable->is_asset ) {
1380 EDL *nested_edl = (EDL*)indexable;
1381 new_edl->create_nested(nested_edl);
1382 new_edl->set_path(indexable->path);
1385 Asset *asset = (Asset*)indexable;
1386 asset_to_edl(new_edl, asset);
1388 new_edls.append(new_edl);
1391 for( RecordLabel *label=labels->first; label; label=label->next ) {
1392 new_edl->labels->toggle_label(label->position, label->position);
1396 if( debug ) printf("MWindow::load_assets %d\n", __LINE__);
1398 paste_edls(&new_edls, load_mode, first_track, position,
1399 edit_labels, edit_plugins, edit_autos, overwrite);
1400 if( debug ) printf("MWindow::load_assets %d\n", __LINE__);
1403 for( int i=0; i<new_edls.size(); ++i )
1404 new_edls.get(i)->Garbage::remove_user();
1406 if( debug ) printf("MWindow::load_assets %d\n", __LINE__);
1409 int MWindow::paste_automation()
1411 int64_t len = gui->clipboard_len(BC_PRIMARY_SELECTION);
1416 char *string = new char[len];
1417 gui->from_clipboard(string, len, BC_PRIMARY_SELECTION);
1419 file.read_from_string(string);
1421 double start = edl->local_session->get_selectionstart();
1422 double end = edl->local_session->get_selectionend();
1423 edl->tracks->clear_automation(start, end);
1424 edl->tracks->paste_automation(start, &file, 0, 1,
1425 edl->session->typeless_keyframes);
1426 int changed_edl = speed_after(1);
1428 undo_after(_("paste keyframes"),
1429 !changed_edl ? LOAD_AUTOMATION :
1430 LOAD_AUTOMATION + LOAD_EDITS + LOAD_TIMEBAR);
1431 update_gui(changed_edl);
1437 int MWindow::paste_default_keyframe()
1439 int64_t len = gui->clipboard_len(BC_PRIMARY_SELECTION);
1444 char *string = new char[len];
1445 gui->from_clipboard(string, len, BC_PRIMARY_SELECTION);
1447 file.read_from_string(string);
1449 double start = edl->local_session->get_selectionstart();
1450 edl->tracks->paste_automation(start, &file, 1, 0,
1451 edl->session->typeless_keyframes);
1452 // edl->tracks->paste_default_keyframe(&file);
1453 int changed_edl = speed_after(1);
1454 undo_after(_("paste default keyframe"),
1455 !changed_edl ? LOAD_AUTOMATION :
1456 LOAD_AUTOMATION + LOAD_EDITS + LOAD_TIMEBAR);
1458 update_gui(changed_edl);
1465 // Insert edls with project deletion and index file generation.
1466 int MWindow::paste_edls(ArrayList<EDL*> *new_edls, int load_mode,
1467 Track *first_track, double current_position,
1468 int edit_labels, int edit_plugins, int edit_autos,
1472 ArrayList<Track*> destination_tracks;
1473 int need_new_tracks = 0;
1476 if( !new_edls->total ) return 0;
1479 // double original_length = edl->tracks->total_length();
1480 // double original_preview_end = edl->local_session->preview_end;
1483 // Delete current project
1484 if( load_mode == LOADMODE_REPLACE ||
1485 load_mode == LOADMODE_REPLACE_CONCATENATE ) {
1487 edl->save_defaults(defaults);
1489 edl->Garbage::remove_user();
1491 edl->create_objects();
1492 edl->copy_session(new_edls->values[0]);
1493 edl->copy_mixers(new_edls->values[0]);
1494 gui->mainmenu->update_toggles(0);
1495 gui->unlock_window();
1496 gwindow->gui->update_toggles(1);
1497 gui->lock_window("MWindow::paste_edls");
1499 // Insert labels for certain modes constitutively
1503 // Force reset of preview
1504 // original_length = 0;
1505 // original_preview_end = -1;
1511 // Create new tracks in master EDL
1512 if( load_mode == LOADMODE_REPLACE ||
1513 load_mode == LOADMODE_REPLACE_CONCATENATE ||
1514 load_mode == LOADMODE_NEW_TRACKS ) {
1516 need_new_tracks = 1;
1517 for( int i=0; i<new_edls->total; ++i ) {
1518 EDL *new_edl = new_edls->values[i];
1519 for( Track *current=new_edl->tracks->first; current; current=NEXT ) {
1520 switch( current->data_type ) {
1522 edl->tracks->add_video_track(0, 0);
1523 if( current->draw ) edl->tracks->last->draw = 1;
1526 edl->tracks->add_audio_track(0, 0);
1528 case TRACK_SUBTITLE:
1529 edl->tracks->add_subttl_track(0, 0);
1534 // re-label only if not already labeled
1535 if( new_edl->local_session->asset2edl )
1536 strcpy(current->title, edl->tracks->last->title);
1537 destination_tracks.append(edl->tracks->last);
1540 // Base track count on first EDL only for concatenation
1541 if( load_mode == LOADMODE_REPLACE_CONCATENATE ) break;
1543 edl->session->highlighted_track = edl->tracks->total() - 1;
1546 // Recycle existing tracks of master EDL
1547 if( load_mode == LOADMODE_CONCATENATE ||
1548 load_mode == LOADMODE_PASTE ||
1549 load_mode == LOADMODE_NESTED ) {
1550 Track *current = first_track ? first_track : edl->tracks->first;
1551 for( ; current; current=NEXT ) {
1552 if( current->record ) {
1553 destination_tracks.append(current);
1559 int destination_track = 0;
1560 double *paste_position = new double[destination_tracks.total];
1562 // Iterate through the edls
1563 for( int i=0; i<new_edls->total; ++i ) {
1565 EDL *new_edl = new_edls->values[i];
1566 double edl_length = new_edl->local_session->clipboard_length ?
1567 new_edl->local_session->clipboard_length :
1568 new_edl->tracks->total_length();
1569 // printf("MWindow::paste_edls 2 %f %f\n",
1570 // new_edl->local_session->clipboard_length,
1571 // new_edl->tracks->total_length());
1575 // Convert EDL to master rates
1576 new_edl->resample(new_edl->session->sample_rate,
1577 edl->session->sample_rate,
1579 new_edl->resample(new_edl->session->frame_rate,
1580 edl->session->frame_rate,
1583 // Add assets and prepare index files
1584 for( Asset *new_asset=new_edl->assets->first;
1585 new_asset; new_asset=new_asset->next ) {
1586 mainindexes->add_next_asset(0, new_asset);
1588 // Capture index file status from mainindex test
1589 edl->update_assets(new_edl);
1591 // Get starting point of insertion. Need this to paste labels.
1592 switch( load_mode ) {
1593 case LOADMODE_REPLACE:
1594 current_position = 0;
1596 case LOADMODE_NEW_TRACKS:
1598 current_position = 0;
1601 case LOADMODE_CONCATENATE:
1602 case LOADMODE_REPLACE_CONCATENATE:
1603 destination_track = 0;
1604 if( destination_tracks.total )
1605 current_position = destination_tracks.values[0]->get_length();
1607 current_position = 0;
1610 case LOADMODE_PASTE:
1611 case LOADMODE_NESTED:
1612 destination_track = 0;
1614 for( int j=0; j<destination_tracks.total; ++j ) {
1615 paste_position[j] = (current_position >= 0) ?
1617 edl->local_session->get_selectionstart();
1622 case LOADMODE_RESOURCESONLY:
1623 edl->add_clip(new_edl);
1627 if( load_mode != LOADMODE_RESOURCESONLY &&
1628 load_mode != LOADMODE_ASSETSONLY ) {
1631 if( load_mode == LOADMODE_PASTE || load_mode == LOADMODE_NESTED )
1632 edl->labels->insert_labels(new_edl->labels,
1633 destination_tracks.total ? paste_position[0] : 0.0,
1636 edl->labels->insert_labels(new_edl->labels, current_position,
1639 double total_length = new_edl->tracks->total_length();
1640 for( Track *new_track=new_edl->tracks->first;
1641 new_track; new_track=new_track->next ) {
1642 // Get destination track of same type as new_track
1644 k < destination_tracks.total &&
1645 destination_tracks.values[destination_track]->data_type != new_track->data_type;
1646 ++k, ++destination_track ) {
1647 if( destination_track >= destination_tracks.total - 1 )
1648 destination_track = 0;
1651 // Insert data into destination track
1652 if( destination_track < destination_tracks.total &&
1653 destination_tracks.values[destination_track]->data_type == new_track->data_type ) {
1654 Track *track = destination_tracks.values[destination_track];
1656 // Replace default keyframes if first EDL and new tracks were created.
1657 // This means data copied from one track and pasted to another won't retain
1658 // the camera position unless it's a keyframe. If it did, previous data in the
1659 // track might get unknowingly corrupted. Ideally we would detect when differing
1660 // default keyframes existed and create discrete keyframes for both.
1661 int replace_default = (i == 0) && need_new_tracks;
1663 //printf("MWindow::paste_edls 1 %d\n", replace_default);
1664 // Insert new track at current position
1665 switch( load_mode ) {
1666 case LOADMODE_REPLACE_CONCATENATE:
1667 case LOADMODE_CONCATENATE:
1668 current_position = track->get_length();
1671 case LOADMODE_PASTE:
1672 case LOADMODE_NESTED:
1673 current_position = paste_position[destination_track];
1674 paste_position[destination_track] += new_track->get_length();
1678 double length = overwrite >= 0 ?
1679 new_track->get_length() : total_length;
1680 track->clear(current_position,
1681 current_position + length,
1683 edit_labels, edit_plugins, edit_autos,
1687 track->insert_track(new_track, current_position, replace_default,
1688 edit_plugins, edit_autos, edl_length);
1692 // Get next destination track
1693 destination_track++;
1694 if( destination_track >= destination_tracks.total )
1695 destination_track = 0;
1699 if( load_mode == LOADMODE_PASTE ||
1700 load_mode == LOADMODE_NESTED )
1701 current_position += edl_length;
1705 // Move loading of clips and vwindow to the end - this fixes some
1706 // strange issue, for index not being shown
1707 // Assume any paste operation from the same EDL won't contain any clips.
1708 // If it did it would duplicate every clip here.
1709 for( int i=0; i<new_edls->total; ++i ) {
1710 EDL *new_edl = new_edls->get(i);
1712 for( int j=0; j<new_edl->clips.size(); ++j ) {
1713 edl->add_clip(new_edl->clips[j]);
1715 for( int j=0; j<new_edl->nested_edls.size(); ++j ) {
1716 edl->nested_edls.get_nested(new_edl->nested_edls[j]);
1719 if( new_edl->total_vwindow_edls() ) {
1720 // if( edl->vwindow_edl )
1721 // edl->vwindow_edl->Garbage::remove_user();
1722 // edl->vwindow_edl = new EDL(edl);
1723 // edl->vwindow_edl->create_objects();
1724 // edl->vwindow_edl->copy_all(new_edl->vwindow_edl);
1726 for( int j=0; j<new_edl->total_vwindow_edls(); ++j ) {
1727 EDL *vwindow_edl = new EDL(edl);
1728 vwindow_edl->create_objects();
1729 vwindow_edl->copy_all(new_edl->get_vwindow_edl(j));
1730 edl->append_vwindow_edl(vwindow_edl, 0);
1735 if( paste_position ) delete [] paste_position;
1737 // This is already done in load_filenames and everything else that uses paste_edls
1738 // update_project(load_mode);
1740 // Fix preview range
1741 // if( EQUIV(original_length, original_preview_end) )
1743 // edl->local_session->preview_end = edl->tracks->total_length();
1746 // Start examining next batch of index files
1747 mainindexes->start_build();
1749 // Don't save a backup after loading since the loaded file is on disk already.
1754 void MWindow::paste_silence()
1756 double start = edl->local_session->get_selectionstart();
1757 double end = edl->local_session->get_selectionend();
1758 if( EQUIV(start, end) ) {
1759 if( edl->session->frame_rate > 0 )
1760 end += 1./edl->session->frame_rate;
1762 undo_before(_("silence"), this);
1763 edl->paste_silence(start, end,
1764 edl->session->labels_follow_edits,
1765 edl->session->plugins_follow_edits,
1766 edl->session->autos_follow_edits);
1769 undo_after(_("silence"), LOAD_EDITS | LOAD_TIMEBAR);
1771 update_plugin_guis();
1773 gui->update(1, FORCE_REDRAW, 1, 1, 1, 1, 0);
1774 cwindow->update(1, 0, 0, 0, 1);
1775 cwindow->refresh_frame(CHANGE_EDL);
1778 void MWindow::detach_transition(Transition *transition)
1781 hide_plugin(transition, 1);
1782 int is_video = (transition->edit->track->data_type == TRACK_VIDEO);
1783 transition->edit->detach_transition();
1785 undo_after(_("detach transition"), LOAD_ALL);
1787 if( is_video ) restart_brender();
1788 gui->update(0, NORMAL_DRAW, 0, 0, 0, 0, 0);
1789 sync_parameters(CHANGE_EDL);
1792 void MWindow::detach_transitions()
1794 gui->lock_window("MWindow::detach_transitions 1");
1797 double start = edl->local_session->get_selectionstart();
1798 double end = edl->local_session->get_selectionend();
1799 edl->tracks->clear_transitions(start, end);
1802 undo_after(_("detach transitions"), LOAD_EDITS);
1804 sync_parameters(CHANGE_EDL);
1805 gui->update(0, NORMAL_DRAW, 0, 0, 0, 0, 0);
1806 gui->unlock_window();
1809 void MWindow::paste_transition()
1811 // Only the first transition gets dropped.
1812 PluginServer *server = session->drag_pluginservers->values[0];
1815 edl->tracks->paste_transition(server, session->edit_highlighted);
1817 undo_after(_("transition"), LOAD_EDITS);
1819 if( server->video ) restart_brender();
1820 sync_parameters(CHANGE_ALL);
1823 void MWindow::paste_transitions(int track_type, char *title)
1825 gui->lock_window("MWindow::detach_transitions 1");
1828 double start = edl->local_session->get_selectionstart();
1829 double end = edl->local_session->get_selectionend();
1830 edl->tracks->paste_transitions(start, end, track_type, title);
1832 undo_after(_("attach transitions"), LOAD_EDITS);
1834 sync_parameters(CHANGE_EDL);
1835 gui->update(0, NORMAL_DRAW, 0, 0, 0, 0, 0);
1836 gui->unlock_window();
1839 void MWindow::paste_transition_cwindow(Track *dest_track)
1841 PluginServer *server = session->drag_pluginservers->values[0];
1843 edl->tracks->paste_video_transition(server, 1);
1845 undo_after(_("transition"), LOAD_EDITS);
1847 gui->update(0, NORMAL_DRAW, 0, 0, 0, 0, 0);
1848 sync_parameters(CHANGE_ALL);
1851 void MWindow::paste_audio_transition()
1853 PluginServer *server = scan_plugindb(edl->session->default_atransition,
1856 char string[BCTEXTLEN];
1857 sprintf(string, _("No default transition %s found."), edl->session->default_atransition);
1858 gui->show_message(string);
1863 edl->tracks->paste_audio_transition(server);
1865 undo_after(_("transition"), LOAD_EDITS);
1867 sync_parameters(CHANGE_EDL);
1868 gui->update(0, NORMAL_DRAW, 0, 0, 0, 0, 0);
1871 void MWindow::paste_video_transition()
1873 PluginServer *server = scan_plugindb(edl->session->default_vtransition,
1876 char string[BCTEXTLEN];
1877 sprintf(string, _("No default transition %s found."), edl->session->default_vtransition);
1878 gui->show_message(string);
1884 edl->tracks->paste_video_transition(server);
1886 undo_after(_("transition"), LOAD_EDITS);
1888 sync_parameters(CHANGE_EDL);
1890 gui->update(0, NORMAL_DRAW, 0, 0, 0, 0, 0);
1893 void MWindow::shuffle_edits()
1895 gui->lock_window("MWindow::shuffle_edits 1");
1898 double start = edl->local_session->get_selectionstart();
1899 double end = edl->local_session->get_selectionend();
1901 edl->tracks->shuffle_edits(start, end);
1904 undo_after(_("shuffle edits"), LOAD_EDITS | LOAD_TIMEBAR);
1906 sync_parameters(CHANGE_EDL);
1908 gui->update(0, NORMAL_DRAW, 1, 0, 0, 0, 0);
1909 gui->unlock_window();
1912 void MWindow::reverse_edits()
1914 gui->lock_window("MWindow::reverse_edits 1");
1917 double start = edl->local_session->get_selectionstart();
1918 double end = edl->local_session->get_selectionend();
1920 edl->tracks->reverse_edits(start, end);
1923 undo_after(_("reverse edits"), LOAD_EDITS | LOAD_TIMEBAR);
1925 sync_parameters(CHANGE_EDL);
1927 gui->update(0, NORMAL_DRAW, 1, 0, 0, 0, 0);
1928 gui->unlock_window();
1931 void MWindow::align_edits()
1933 gui->lock_window("MWindow::align_edits 1");
1936 double start = edl->local_session->get_selectionstart();
1937 double end = edl->local_session->get_selectionend();
1939 edl->tracks->align_edits(start, end);
1942 undo_after(_("align edits"), LOAD_EDITS | LOAD_TIMEBAR);
1944 sync_parameters(CHANGE_EDL);
1946 gui->update(0, NORMAL_DRAW, 1, 0, 0, 0, 0);
1947 gui->unlock_window();
1950 void MWindow::set_edit_length(double length)
1952 gui->lock_window("MWindow::set_edit_length 1");
1955 double start = edl->local_session->get_selectionstart();
1956 double end = edl->local_session->get_selectionend();
1958 edl->tracks->set_edit_length(start, end, length);
1961 undo_after(_("edit length"), LOAD_EDITS | LOAD_TIMEBAR);
1963 sync_parameters(CHANGE_EDL);
1965 gui->update(0, NORMAL_DRAW, 1, 0, 0, 0, 0);
1966 gui->unlock_window();
1970 void MWindow::set_transition_length(Transition *transition, double length)
1972 gui->lock_window("MWindow::set_transition_length 1");
1975 //double start = edl->local_session->get_selectionstart();
1976 //double end = edl->local_session->get_selectionend();
1978 edl->tracks->set_transition_length(transition, length);
1981 undo_after(_("transition length"), LOAD_EDITS);
1983 edl->session->default_transition_length = length;
1984 sync_parameters(CHANGE_PARAMS);
1985 gui->update(0, NORMAL_DRAW, 0, 0, 0, 0, 0);
1986 gui->unlock_window();
1989 void MWindow::set_transition_length(double length)
1991 gui->lock_window("MWindow::set_transition_length 2");
1994 double start = edl->local_session->get_selectionstart();
1995 double end = edl->local_session->get_selectionend();
1997 edl->tracks->set_transition_length(start, end, length);
2000 undo_after(_("transition length"), LOAD_EDITS);
2002 edl->session->default_transition_length = length;
2003 sync_parameters(CHANGE_PARAMS);
2005 gui->update(0, NORMAL_DRAW, 0, 0, 0, 0, 0);
2006 gui->unlock_window();
2010 void MWindow::redo_entry(BC_WindowBase *calling_window_gui)
2012 calling_window_gui->unlock_window();
2014 if( undo->redo_load_flags() & LOAD_SESSION )
2017 cwindow->gui->lock_window("MWindow::redo_entry 1");
2018 for( int i=0; i<vwindows.size(); ++i ) {
2019 if( vwindows.get(i)->is_running() ) {
2020 if( calling_window_gui != vwindows.get(i)->gui ) {
2021 vwindows.get(i)->gui->lock_window("MWindow::redo_entry 2");
2025 gui->lock_window("MWindow::redo_entry 3");
2031 update_plugin_states();
2032 update_plugin_guis();
2034 gui->update(1, FORCE_REDRAW, 1, 1, 1, 1, 1);
2035 gui->update_proxy_toggle();
2036 gui->unlock_window();
2037 cwindow->gui->unlock_window();
2038 cwindow->update(1, 1, 1, 1, 1);
2040 for( int i=0; i < vwindows.size(); ++i ) {
2041 if( vwindows.get(i)->is_running() ) {
2042 if( calling_window_gui != vwindows.get(i)->gui ) {
2043 vwindows.get(i)->gui->unlock_window();
2048 awindow->gui->async_update_assets();
2050 cwindow->refresh_frame(CHANGE_ALL);
2051 calling_window_gui->lock_window("MWindow::redo_entry 4");
2055 void MWindow::resize_track(Track *track, int w, int h)
2058 // We have to move all maskpoints so they do not move in relation to image areas
2059 ((MaskAutos*)track->automation->autos[AUTOMATION_MASK])->translate_masks(
2060 (w - track->track_w) / 2,
2061 (h - track->track_h) / 2);
2064 undo_after(_("resize track"), LOAD_ALL);
2068 sync_parameters(CHANGE_EDL);
2072 void MWindow::set_inpoint()
2075 edl->set_inpoint(edl->local_session->get_selectionstart(1));
2077 undo_after(_("in point"), LOAD_TIMEBAR);
2078 gui->update_timebar(1);
2080 cwindow->gui->lock_window("MWindow::set_inpoint 2");
2081 cwindow->gui->timebar->update(1);
2082 cwindow->gui->unlock_window();
2085 void MWindow::set_outpoint()
2088 edl->set_outpoint(edl->local_session->get_selectionend(1));
2090 undo_after(_("out point"), LOAD_TIMEBAR);
2092 gui->update_timebar(1);
2093 cwindow->gui->lock_window("MWindow::set_outpoint 2");
2094 cwindow->gui->timebar->update(1);
2095 cwindow->gui->unlock_window();
2098 void MWindow::unset_inoutpoint()
2101 edl->unset_inoutpoint();
2103 undo_after(_("clear in/out"), LOAD_TIMEBAR);
2105 gui->update_timebar(1);
2106 cwindow->gui->lock_window("MWindow::unset_inoutpoint 2");
2107 cwindow->gui->timebar->update(1);
2108 cwindow->gui->unlock_window();
2111 void MWindow::splice(EDL *source, int all)
2114 LocalSession *src = source->local_session;
2117 double source_start = all ? 0 :
2118 src->inpoint_valid() ? src->get_inpoint() :
2119 src->outpoint_valid() ? 0 : src->get_selectionstart();
2120 double source_end = all ? source->tracks->total_length() :
2121 src->outpoint_valid() ? src->get_outpoint() :
2122 src->inpoint_valid() ? source->tracks->total_length() :
2123 src->get_selectionend();
2124 source->copy(COPY_EDL, source_start, source_end, &file, "", 1);
2126 double start = edl->local_session->get_selectionstart();
2127 //double end = edl->local_session->get_selectionend();
2129 paste(start, start, &file,
2130 edl->session->labels_follow_edits,
2131 edl->session->plugins_follow_edits,
2132 edl->session->autos_follow_edits,
2135 // Position at end of clip
2136 edl->local_session->set_selectionstart(start + source_end - source_start);
2137 edl->local_session->set_selectionend(start + source_end - source_start);
2140 undo_after(_("splice"), LOAD_EDITS | LOAD_TIMEBAR);
2141 update_plugin_guis();
2143 gui->update(1, NORMAL_DRAW, 1, 1, 0, 1, 0);
2144 sync_parameters(CHANGE_EDL);
2147 void MWindow::save_clip(EDL *new_edl, const char *txt)
2149 new_edl->local_session->set_selectionstart(0);
2150 new_edl->local_session->set_selectionend(0);
2151 sprintf(new_edl->local_session->clip_title, _("Clip %d"),
2152 session->clip_number++);
2153 char duration[BCTEXTLEN];
2154 Units::totext(duration, new_edl->tracks->total_length(),
2155 new_edl->session->time_format,
2156 new_edl->session->sample_rate,
2157 new_edl->session->frame_rate,
2158 new_edl->session->frames_per_foot);
2160 Track *track = new_edl->tracks->first;
2161 const char *path = edl->path;
2162 for( ; (!path || !*path) && track; track=track->next ) {
2163 if( !track->record ) continue;
2164 Edit *edit = track->edits->first;
2165 if( !edit ) continue;
2166 Indexable *indexable = edit->get_source();
2167 if( !indexable ) continue;
2168 path = indexable->path;
2171 time_t now; time(&now);
2172 struct tm dtm; localtime_r(&now, &dtm);
2173 char *cp = new_edl->local_session->clip_notes;
2174 int n, sz = sizeof(new_edl->local_session->clip_notes)-1;
2176 n = snprintf(cp, sz, "%s", txt);
2179 n = snprintf(cp, sz,
2180 "%02d/%02d/%02d %02d:%02d:%02d, +%s\n",
2181 dtm.tm_year+1900, dtm.tm_mon+1, dtm.tm_mday,
2182 dtm.tm_hour, dtm.tm_min, dtm.tm_sec, duration);
2184 if( path && *path ) {
2186 char title[BCTEXTLEN];
2187 fs.extract_name(title, path);
2188 n = snprintf(cp, sz, "%s", title);
2192 sprintf(new_edl->local_session->clip_icon,
2193 "clip_%02d%02d%02d-%02d%02d%02d.png",
2194 dtm.tm_year+1900, dtm.tm_mon+1, dtm.tm_mday,
2195 dtm.tm_hour, dtm.tm_min, dtm.tm_sec);
2196 new_edl->folder_no = AW_CLIP_FOLDER;
2197 edl->update_assets(new_edl);
2199 gui->get_abs_cursor(cur_x, cur_y, 0);
2200 gui->unlock_window();
2202 awindow->clip_edit->create_clip(new_edl, cur_x, cur_y);
2203 new_edl->remove_user();
2205 gui->lock_window("MWindow::save_clip");
2209 void MWindow::to_clip(EDL *edl, const char *txt, int all)
2212 LocalSession *src = edl->local_session;
2214 gui->lock_window("MWindow::to_clip 1");
2215 double start = all ? 0 :
2216 src->inpoint_valid() ? src->get_inpoint() :
2217 src->outpoint_valid() ? 0 : src->get_selectionstart();
2218 double end = all ? edl->tracks->total_length() :
2219 src->outpoint_valid() ? src->get_outpoint() :
2220 src->inpoint_valid() ? edl->tracks->total_length() :
2221 src->get_selectionend();
2222 if( EQUIV(end, start) ) {
2224 end = edl->tracks->total_length();
2227 // Don't copy all since we don't want the clips twice.
2228 edl->copy(copy_flags(), start, end, &file, "", 1);
2230 EDL *new_edl = new EDL(edl);
2231 new_edl->create_objects();
2232 new_edl->load_xml(&file, LOAD_ALL);
2233 save_clip(new_edl, txt);
2234 gui->unlock_window();
2237 int MWindow::toggle_label()
2239 double position1, position2;
2242 position1 = edl->local_session->get_selectionstart(1);
2243 position2 = edl->local_session->get_selectionend(1);
2244 position1 = edl->align_to_frame(position1, 0);
2245 position2 = edl->align_to_frame(position2, 0);
2247 edl->labels->toggle_label(position1, position2);
2250 gui->update_timebar(0);
2251 gui->activate_timeline();
2254 cwindow->gui->lock_window("MWindow::toggle_label 2");
2255 cwindow->gui->timebar->update(1);
2256 cwindow->gui->unlock_window();
2257 awindow->gui->async_update_assets();
2259 undo_after(_("label"), LOAD_TIMEBAR);
2263 void MWindow::trim_selection()
2268 edl->trim_selection(edl->local_session->get_selectionstart(),
2269 edl->local_session->get_selectionend(),
2270 edl->session->labels_follow_edits,
2271 edl->session->plugins_follow_edits,
2272 edl->session->autos_follow_edits);
2275 undo_after(_("trim selection"), LOAD_EDITS | LOAD_TIMEBAR);
2276 update_plugin_guis();
2277 gui->update(1, FORCE_REDRAW, 1, 1, 1, 1, 0);
2278 cwindow->update(1, 0, 0, 0, 1);
2279 awindow->gui->async_update_assets();
2281 cwindow->refresh_frame(CHANGE_EDL);
2285 void MWindow::undo_entry(BC_WindowBase *calling_window_gui)
2287 calling_window_gui->unlock_window();
2289 if( undo->undo_load_flags() & LOAD_SESSION )
2292 cwindow->gui->lock_window("MWindow::undo_entry 1");
2293 for( int i=0; i<vwindows.size(); ++i ) {
2294 if( vwindows.get(i)->is_running() ) {
2295 if( calling_window_gui != vwindows.get(i)->gui ) {
2296 vwindows.get(i)->gui->lock_window("MWindow::undo_entry 4");
2300 gui->lock_window("MWindow::undo_entry 2");
2306 update_plugin_states();
2307 update_plugin_guis();
2309 gui->update(1, FORCE_REDRAW, 1, 1, 1, 1, 1);
2310 gui->update_proxy_toggle();
2311 gui->unlock_window();
2312 cwindow->gui->unlock_window();
2313 cwindow->update(1, 1, 1, 1, 1);
2315 for( int i=0; i<vwindows.size(); ++i ) {
2316 if( vwindows.get(i)->is_running() ) {
2317 if( calling_window_gui != vwindows.get(i)->gui ) {
2318 vwindows.get(i)->gui->unlock_window();
2323 awindow->gui->async_update_assets();
2325 cwindow->refresh_frame(CHANGE_ALL);
2326 calling_window_gui->lock_window("MWindow::undo_entry 4");
2330 void MWindow::new_folder(const char *new_folder, int is_clips)
2333 if( edl->new_folder(new_folder, is_clips) ) {
2334 MainError::show_error(_("create new folder failed"));
2336 undo_after(_("new folder"), LOAD_ALL);
2337 awindow->gui->async_update_assets();
2340 void MWindow::delete_folder(char *folder)
2343 if( edl->delete_folder(folder) < 0 ) {
2344 MainError::show_error(_("delete folder failed"));
2346 undo_after(_("del folder"), LOAD_ALL);
2347 awindow->gui->async_update_assets();
2350 void MWindow::select_point(double position)
2352 gui->unlock_window();
2353 gui->stop_drawing();
2354 cwindow->stop_playback(0);
2355 gui->lock_window("MWindow::select_point");
2357 edl->local_session->set_selectionstart(position);
2358 edl->local_session->set_selectionend(position);
2361 cwindow->update(1, 0, 0, 0, 1);
2363 update_plugin_guis();
2364 gui->update_patchbay();
2365 gui->hide_cursor(0);
2366 gui->draw_cursor(0);
2367 gui->mainclock->update(edl->local_session->get_selectionstart(1));
2368 gui->zoombar->update();
2369 gui->update_timebar(0);
2370 gui->flash_canvas(0);
2377 void MWindow::map_audio(int pattern)
2380 remap_audio(pattern);
2382 pattern == MWindow::AUDIO_1_TO_1 ? _("map 1:1") : _("map 5.1:2"),
2384 sync_parameters(CHANGE_PARAMS);
2385 gui->update(0, NORMAL_DRAW, 0, 0, 1, 0, 0);
2388 void MWindow::remap_audio(int pattern)
2390 int current_channel = 0;
2391 int current_track = 0;
2392 for( Track *current=edl->tracks->first; current; current=NEXT ) {
2393 if( current->data_type == TRACK_AUDIO &&
2395 Autos *pan_autos = current->automation->autos[AUTOMATION_PAN];
2396 PanAuto *pan_auto = (PanAuto*)pan_autos->get_auto_for_editing(-1);
2398 for( int i=0; i < MAXCHANNELS; ++i ) {
2399 pan_auto->values[i] = 0.0;
2402 if( pattern == MWindow::AUDIO_1_TO_1 ) {
2403 pan_auto->values[current_channel] = 1.0;
2406 if( pattern == MWindow::AUDIO_5_1_TO_2 ) {
2407 switch( current_track ) {
2410 pan_auto->values[0] = 1;
2414 pan_auto->values[1] = 1;
2418 pan_auto->values[0] = 0.5;
2419 pan_auto->values[1] = 0.5;
2424 BC_Pan::calculate_stick_position(edl->session->audio_channels,
2425 edl->session->achannel_positions, pan_auto->values,
2426 MAX_PAN, PAN_RADIUS, pan_auto->handle_x, pan_auto->handle_y);
2430 if( current_channel >= edl->session->audio_channels )
2431 current_channel = 0;
2437 void MWindow::rescale_proxy(EDL *clip, int orig_scale, int new_scale)
2439 edl->rescale_proxy(orig_scale, new_scale);
2442 void MWindow::add_proxy(ArrayList<Indexable*> *orig_assets, ArrayList<Indexable*> *proxy_assets)
2444 edl->add_proxy(orig_assets, proxy_assets);
2447 void MWindow::start_convert(Asset *format_asset, const char *suffix,
2448 float beep, int remove_originals)
2450 if( !convert_render )
2451 convert_render = new ConvertRender(this, suffix);
2452 convert_render->set_format(format_asset);
2453 int found = convert_render->find_convertable_assets(edl);
2454 if( convert_render->needed_idxbls.size() > 0 )
2455 convert_render->start_convert(beep, remove_originals);
2456 else if( found > 0 )
2457 finish_convert(remove_originals);
2459 eprintf(_("No convertable assets found"));
2463 void MWindow::finish_convert(int remove_originals)
2465 gui->lock_window("MWindow::finish_convert");
2467 edl->replace_assets(
2468 convert_render->orig_idxbls,
2469 convert_render->orig_copies);
2470 if( remove_originals ) {
2471 remove_assets_from_project(0, 0, 0,
2472 &convert_render->orig_idxbls, 0);
2475 undo_after(_("convert"), LOAD_ALL);
2477 update_plugin_guis();
2478 gui->update(1, FORCE_REDRAW, 1, 1, 1, 1, 0);
2479 cwindow->update(1, 0, 0, 0, 1);
2480 awindow->gui->async_update_assets();
2481 cwindow->refresh_frame(CHANGE_EDL);
2482 gui->unlock_window();
2485 void MWindow::cut_commercials()
2487 #ifdef HAVE_COMMERCIAL
2489 commercials->scan_media();
2492 undo_after(_("cut ads"), LOAD_EDITS | LOAD_TIMEBAR);
2495 update_plugin_guis();
2496 gui->update(1, FORCE_REDRAW, 1, 1, 1, 1, 0);
2497 cwindow->update(1, 0, 0, 0, 1);
2498 cwindow->refresh_frame(CHANGE_EDL);
2502 int MWindow::normalize_speed(EDL *old_edl, EDL *new_edl)
2505 Track *old_track = old_edl->tracks->first;
2506 Track *new_track = new_edl->tracks->first;
2507 for( ; old_track && new_track; old_track=old_track->next, new_track=new_track->next ) {
2508 if( old_track->data_type != new_track->data_type ) continue;
2509 FloatAutos *old_speeds = (FloatAutos *)old_track->automation->autos[AUTOMATION_SPEED];
2510 FloatAutos *new_speeds = (FloatAutos *)new_track->automation->autos[AUTOMATION_SPEED];
2511 if( !old_speeds || !new_speeds ) continue;
2512 FloatAuto *old_speed = (FloatAuto *)old_speeds->first;
2513 FloatAuto *new_speed = (FloatAuto *)new_speeds->first;
2514 while( old_speed && new_speed && old_speed->equals(new_speed) ) {
2515 old_speed = (FloatAuto *)old_speed->next;
2516 new_speed = (FloatAuto *)new_speed->next;
2518 Edit *old_edit = old_track->edits->first;
2519 Edit *new_edit = new_track->edits->first;
2520 for( ; old_edit && new_edit; old_edit=old_edit->next, new_edit=new_edit->next ) {
2521 int64_t edit_start = old_edit->startproject, edit_end = edit_start + old_edit->length;
2522 if( old_speed || new_speed ) {
2523 double orig_start = old_speeds->automation_integral(0, edit_start, PLAY_FORWARD);
2524 double orig_end = old_speeds->automation_integral(0, edit_end, PLAY_FORWARD);
2525 edit_start = new_speeds->speed_position(orig_start);
2526 edit_end = new_speeds->speed_position(orig_end);
2529 new_edit->startproject = edit_start;
2530 new_edit->length = edit_end - edit_start;
2536 void MWindow::speed_before()
2539 speed_edl = new EDL;
2540 speed_edl->create_objects();
2542 speed_edl->copy_all(edl);
2545 int MWindow::speed_after(int done)
2550 result = normalize_speed(speed_edl, edl);
2552 speed_edl->remove_user();