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"
88 void MWindow::add_audio_track_entry(int above, Track *dst)
90 undo->update_undo_before();
91 add_audio_track(above, dst);
93 undo->update_undo_after(_("add track"), LOAD_ALL);
103 gui->activate_timeline();
105 // gui->get_scrollbars(0);
106 // gui->canvas->draw();
107 // gui->patchbay->update();
108 // gui->cursor->draw(1);
109 // gui->canvas->flash();
110 // gui->canvas->activate();
111 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
117 void MWindow::add_video_track_entry(Track *dst)
119 undo->update_undo_before();
120 add_video_track(1, dst);
121 undo->update_undo_after(_("add track"), LOAD_ALL);
125 gui->update(1, 1, 0, 0, 1, 0, 0);
126 gui->activate_timeline();
127 // gui->get_scrollbars(0);
128 // gui->canvas->draw();
129 // gui->patchbay->update();
130 // gui->cursor->draw(1);
131 // gui->canvas->flash();
132 // gui->canvas->activate();
133 cwindow->playback_engine->que->
134 send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);
138 void MWindow::add_subttl_track_entry(Track *dst)
140 undo->update_undo_before();
141 add_subttl_track(1, dst);
142 undo->update_undo_after(_("add track"), LOAD_ALL);
146 gui->update(1, 1, 0, 0, 1, 0, 0);
147 gui->activate_timeline();
148 // gui->get_scrollbars(0);
149 // gui->canvas->draw();
150 // gui->patchbay->update();
151 // gui->cursor->draw(1);
152 // gui->canvas->flash();
153 // gui->canvas->activate();
154 cwindow->playback_engine->que->
155 send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);
160 int MWindow::add_audio_track(int above, Track *dst)
162 edl->tracks->add_audio_track(above, dst);
163 edl->tracks->update_y_pixels(theme);
168 int MWindow::add_video_track(int above, Track *dst)
170 edl->tracks->add_video_track(above, dst);
171 edl->tracks->update_y_pixels(theme);
176 int MWindow::add_subttl_track(int above, Track *dst)
178 edl->tracks->add_subttl_track(above, dst);
179 edl->tracks->update_y_pixels(theme);
187 void MWindow::asset_to_all()
189 if(!session->drag_assets->size()) return;
190 Indexable *indexable = session->drag_assets->get(0);
192 // if(indexable->have_video())
196 undo->update_undo_before();
199 w = indexable->get_w();
200 h = indexable->get_h();
201 double new_framerate = session->drag_assets->get(0)->get_frame_rate();
202 double old_framerate = edl->session->frame_rate;
203 int old_samplerate = edl->session->sample_rate;
204 int new_samplerate = session->drag_assets->get(0)->get_sample_rate();
207 if(indexable->have_video())
209 edl->session->output_w = w;
210 edl->session->output_h = h;
211 edl->session->frame_rate = new_framerate;
212 create_aspect_ratio(edl->session->aspect_w,
213 edl->session->aspect_h,
217 for(Track *current = edl->tracks->first;
221 if(current->data_type == TRACK_VIDEO /* &&
224 current->track_w = w;
225 current->track_h = h;
230 if(((edl->session->output_w % 4) ||
231 (edl->session->output_h % 4)) &&
232 edl->session->playback_config->vconfig->driver == PLAYBACK_X11_GL)
234 MainError::show_error(
235 _("This project's dimensions are not multiples of 4 so\n"
236 "it can't be rendered by OpenGL."));
241 if(defaults->get("AUTOASPECT", 0))
243 create_aspect_ratio(edl->session->aspect_w,
244 edl->session->aspect_h,
250 if(indexable->have_audio())
252 edl->session->sample_rate = new_samplerate;
253 edl->resample(old_framerate, new_framerate, TRACK_VIDEO);
254 edl->resample(old_samplerate, new_samplerate, TRACK_AUDIO);
260 undo->update_undo_after(_("asset to all"), LOAD_ALL);
269 sync_parameters(CHANGE_ALL);
278 void MWindow::asset_to_size()
280 if(!session->drag_assets->size()) return;
281 Indexable *indexable = session->drag_assets->get(0);
283 if(indexable->have_video())
286 undo->update_undo_before();
289 w = indexable->get_w();
290 h = indexable->get_h();
293 edl->session->output_w = w;
294 edl->session->output_h = h;
296 if(((edl->session->output_w % 4) ||
297 (edl->session->output_h % 4)) &&
298 edl->session->playback_config->vconfig->driver == PLAYBACK_X11_GL)
300 MainError::show_error(
301 _("This project's dimensions are not multiples of 4 so\n"
302 "it can't be rendered by OpenGL."));
307 if(defaults->get("AUTOASPECT", 0))
309 create_aspect_ratio(edl->session->aspect_w,
310 edl->session->aspect_h,
317 undo->update_undo_after(_("asset to size"), LOAD_ALL);
319 sync_parameters(CHANGE_ALL);
324 void MWindow::asset_to_rate()
326 if(session->drag_assets->size() &&
327 session->drag_assets->get(0)->have_video())
329 double new_framerate = session->drag_assets->get(0)->get_frame_rate();
330 double old_framerate = edl->session->frame_rate;
331 undo->update_undo_before();
333 edl->session->frame_rate = new_framerate;
334 edl->resample(old_framerate, new_framerate, TRACK_VIDEO);
338 undo->update_undo_after(_("asset to rate"), LOAD_ALL);
347 sync_parameters(CHANGE_ALL);
353 void MWindow::clear_entry()
355 undo->update_undo_before();
360 undo->update_undo_after(_("clear"), LOAD_EDITS | LOAD_TIMEBAR);
363 update_plugin_guis();
364 gui->update(1, 2, 1, 1, 1, 1, 0);
365 cwindow->update(1, 0, 0, 0, 1);
366 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
372 void MWindow::clear(int clear_handle)
374 double start = edl->local_session->get_selectionstart();
375 double end = edl->local_session->get_selectionend();
376 if(clear_handle || !EQUIV(start, end))
380 edl->session->labels_follow_edits,
381 edl->session->plugins_follow_edits,
382 edl->session->autos_follow_edits);
386 void MWindow::set_automation_mode(int mode)
388 undo->update_undo_before();
389 edl->tracks->set_automation_mode(
390 edl->local_session->get_selectionstart(),
391 edl->local_session->get_selectionend(),
394 char string[BCSTRLEN];
395 sprintf(string,"set %s", FloatAuto::curve_name(mode));
396 undo->update_undo_after(string, LOAD_AUTOMATION);
399 update_plugin_guis();
400 gui->draw_overlays(1);
401 sync_parameters(CHANGE_PARAMS);
402 gui->update_patchbay();
403 cwindow->update(1, 0, 0);
406 void MWindow::clear_automation()
408 undo->update_undo_before();
409 edl->tracks->clear_automation(edl->local_session->get_selectionstart(),
410 edl->local_session->get_selectionend());
412 undo->update_undo_after(_("clear keyframes"), LOAD_AUTOMATION);
415 update_plugin_guis();
416 gui->draw_overlays(1);
417 sync_parameters(CHANGE_PARAMS);
418 gui->update_patchbay();
419 cwindow->update(1, 0, 0);
422 int MWindow::clear_default_keyframe()
424 undo->update_undo_before();
425 edl->tracks->clear_default_keyframe();
427 undo->update_undo_after(_("clear default keyframe"), LOAD_AUTOMATION);
430 gui->draw_overlays(1);
431 sync_parameters(CHANGE_PARAMS);
432 gui->update_patchbay();
433 cwindow->update(1, 0, 0);
438 void MWindow::clear_labels()
440 undo->update_undo_before();
441 clear_labels(edl->local_session->get_selectionstart(),
442 edl->local_session->get_selectionend());
443 undo->update_undo_after(_("clear labels"), LOAD_TIMEBAR);
445 gui->update_timebar(1);
446 cwindow->update(0, 0, 0, 0, 1);
450 int MWindow::clear_labels(double start, double end)
452 edl->labels->clear(start, end, 0);
456 void MWindow::concatenate_tracks()
458 undo->update_undo_before();
459 edl->tracks->concatenate_tracks(edl->session->plugins_follow_edits,
460 edl->session->autos_follow_edits);
462 undo->update_undo_after(_("concatenate tracks"), LOAD_EDITS);
465 gui->update(1, 1, 0, 0, 1, 0, 0);
466 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
475 copy(edl->local_session->get_selectionstart(),
476 edl->local_session->get_selectionend());
479 int MWindow::copy(double start, double end)
481 if(start == end) return 1;
483 //printf("MWindow::copy 1\n");
485 //printf("MWindow::copy 1\n");
494 //printf("MWindow::copy 1\n");
496 // File is now terminated and rewound
498 //printf("MWindow::copy 1\n");
499 const char *file_string = file.string();
500 long file_length = strlen(file_string);
501 gui->get_clipboard()->to_clipboard(file_string, file_length,
502 SECONDARY_SELECTION);
503 gui->get_clipboard()->to_clipboard(file_string, file_length,
504 BC_PRIMARY_SELECTION);
505 //printf("MWindow::copy\n%s\n", file.string);
506 //printf("MWindow::copy 2\n");
511 int MWindow::copy_automation()
514 edl->tracks->copy_automation(edl->local_session->get_selectionstart(),
515 edl->local_session->get_selectionend(),
519 const char *file_string = file.string();
520 long file_length = strlen(file_string);
521 gui->get_clipboard()->to_clipboard(file_string, file_length,
522 BC_PRIMARY_SELECTION);
523 gui->get_clipboard()->to_clipboard(file_string, file_length,
524 SECONDARY_SELECTION);
528 int MWindow::copy_default_keyframe()
531 edl->tracks->copy_automation(edl->local_session->get_selectionstart(),
532 edl->local_session->get_selectionend(),
536 const char *file_string = file.string();
537 long file_length = strlen(file_string);
538 gui->get_clipboard()->to_clipboard(file_string, file_length,
539 BC_PRIMARY_SELECTION);
540 gui->get_clipboard()->to_clipboard(file_string, file_length,
541 SECONDARY_SELECTION);
546 // Uses cropping coordinates in edl session to crop and translate video.
547 // We modify the projector since camera automation depends on the track size.
548 void MWindow::crop_video()
551 undo->update_undo_before();
552 // Clamp EDL crop region
553 if(edl->session->crop_x1 > edl->session->crop_x2)
555 edl->session->crop_x1 ^= edl->session->crop_x2;
556 edl->session->crop_x2 ^= edl->session->crop_x1;
557 edl->session->crop_x1 ^= edl->session->crop_x2;
559 if(edl->session->crop_y1 > edl->session->crop_y2)
561 edl->session->crop_y1 ^= edl->session->crop_y2;
562 edl->session->crop_y2 ^= edl->session->crop_y1;
563 edl->session->crop_y1 ^= edl->session->crop_y2;
566 float old_projector_x = (float)edl->session->output_w / 2;
567 float old_projector_y = (float)edl->session->output_h / 2;
568 float new_projector_x = (float)(edl->session->crop_x1 + edl->session->crop_x2) / 2;
569 float new_projector_y = (float)(edl->session->crop_y1 + edl->session->crop_y2) / 2;
570 float projector_offset_x = -(new_projector_x - old_projector_x);
571 float projector_offset_y = -(new_projector_y - old_projector_y);
573 edl->tracks->translate_projector(projector_offset_x, projector_offset_y);
575 edl->session->output_w = edl->session->crop_x2 - edl->session->crop_x1;
576 edl->session->output_h = edl->session->crop_y2 - edl->session->crop_y1;
577 edl->session->crop_x1 = 0;
578 edl->session->crop_y1 = 0;
579 edl->session->crop_x2 = edl->session->output_w;
580 edl->session->crop_y2 = edl->session->output_h;
582 // Recalculate aspect ratio
583 if(defaults->get("AUTOASPECT", 0))
585 create_aspect_ratio(edl->session->aspect_w,
586 edl->session->aspect_h,
587 edl->session->output_w,
588 edl->session->output_h);
591 undo->update_undo_after(_("crop"), LOAD_ALL);
594 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
603 undo->update_undo_before();
605 double start = edl->local_session->get_selectionstart();
606 double end = edl->local_session->get_selectionend();
611 edl->session->labels_follow_edits,
612 edl->session->plugins_follow_edits,
613 edl->session->autos_follow_edits);
618 undo->update_undo_after(_("cut"), LOAD_EDITS | LOAD_TIMEBAR);
621 update_plugin_guis();
622 gui->update(1, 2, 1, 1, 1, 1, 0);
623 cwindow->update(1, 0, 0, 0, 1);
624 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
630 int MWindow::cut_automation()
632 undo->update_undo_before();
636 edl->tracks->clear_automation(edl->local_session->get_selectionstart(),
637 edl->local_session->get_selectionend());
639 undo->update_undo_after(_("cut keyframes"), LOAD_AUTOMATION);
643 update_plugin_guis();
644 gui->draw_overlays(1);
645 sync_parameters(CHANGE_PARAMS);
646 gui->update_patchbay();
647 cwindow->update(1, 0, 0);
651 int MWindow::cut_default_keyframe()
654 undo->update_undo_before();
655 copy_default_keyframe();
656 edl->tracks->clear_default_keyframe();
657 undo->update_undo_after(_("cut default keyframe"), LOAD_AUTOMATION);
660 gui->draw_overlays(1);
661 sync_parameters(CHANGE_PARAMS);
662 gui->update_patchbay();
663 cwindow->update(1, 0, 0);
671 void MWindow::delete_inpoint()
673 edl->local_session->unset_inpoint();
677 void MWindow::delete_outpoint()
679 edl->local_session->unset_outpoint();
684 void MWindow::delete_track()
686 if (edl->tracks->last)
687 delete_track(edl->tracks->last);
690 void MWindow::delete_tracks()
692 undo->update_undo_before();
693 edl->tracks->delete_tracks();
694 undo->update_undo_after(_("delete tracks"), LOAD_ALL);
698 update_plugin_states();
700 gui->update(1, 1, 1, 0, 1, 0, 0);
701 cwindow->playback_engine->que->
702 send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);
705 void MWindow::delete_track(Track *track)
707 undo->update_undo_before();
708 edl->tracks->delete_track(track);
709 undo->update_undo_after(_("delete track"), LOAD_ALL);
712 update_plugin_states();
714 gui->update(1, 1, 1, 0, 1, 0, 0);
715 cwindow->playback_engine->que->
716 send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);
721 // Insert data from clipboard
722 void MWindow::insert(double position,
729 // For clipboard pasting make the new edl use a separate session
730 // from the master EDL. Then it can be resampled to the master rates.
731 // For splice, overwrite, and dragging need same session to get the assets.
732 EDL *edl = new EDL(parent_edl);
733 ArrayList<EDL*> new_edls;
734 uint32_t load_flags = LOAD_ALL;
737 new_edls.append(edl);
738 edl->create_objects();
743 if(parent_edl) load_flags &= ~LOAD_SESSION;
744 if(!edl->session->autos_follow_edits) load_flags &= ~LOAD_AUTOMATION;
745 if(!edl->session->labels_follow_edits) load_flags &= ~LOAD_TIMEBAR;
747 edl->load_xml(file, load_flags);
750 //printf("MWindow::insert %f\n", edl->local_session->clipboard_length);
754 paste_edls(&new_edls,
763 // printf("MWindow::insert 5 %f %f\n",
764 // vwindow->edl->local_session->in_point,
765 // vwindow->edl->local_session->out_point);
766 new_edls.remove_all();
767 edl->Garbage::remove_user();
768 //printf("MWindow::insert 6 %p\n", vwindow->get_edl());
771 void MWindow::insert_effects_canvas(double start,
774 Track *dest_track = session->track_highlighted;
775 if(!dest_track) return;
777 undo->update_undo_before();
779 for(int i = 0; i < session->drag_pluginservers->total; i++)
781 PluginServer *plugin = session->drag_pluginservers->values[i];
783 insert_effect(plugin->title,
786 i == 0 ? session->pluginset_highlighted : 0,
793 undo->update_undo_after(_("insert effect"), LOAD_EDITS | LOAD_PATCHES);
795 sync_parameters(CHANGE_EDL);
796 // GUI updated in TrackCanvas, after current_operations are reset
799 void MWindow::insert_effects_cwindow(Track *dest_track)
801 if(!dest_track) return;
803 undo->update_undo_before();
806 double length = dest_track->get_length();
808 if(edl->local_session->get_selectionend() >
809 edl->local_session->get_selectionstart())
811 start = edl->local_session->get_selectionstart();
812 length = edl->local_session->get_selectionend() -
813 edl->local_session->get_selectionstart();
816 for(int i = 0; i < session->drag_pluginservers->total; i++)
818 PluginServer *plugin = session->drag_pluginservers->values[i];
821 insert_effect(plugin->title,
831 undo->update_undo_after(_("insert effect"), LOAD_EDITS | LOAD_PATCHES);
833 sync_parameters(CHANGE_EDL);
843 void MWindow::insert_effect(char *title,
844 SharedLocation *shared_location,
847 int single_standalone)
849 Track *current = edl->tracks->first;
850 SharedLocation shared_location_local;
851 shared_location_local.copy_from(shared_location);
853 for( ; current; current = NEXT)
855 if(current->data_type == data_type &&
859 &shared_location_local,
868 if(plugin_type == PLUGIN_STANDALONE && single_standalone)
870 plugin_type = PLUGIN_SHAREDPLUGIN;
871 shared_location_local.module = edl->tracks->number_of(current);
872 shared_location_local.plugin = current->plugin_set.total - 1;
881 void MWindow::insert_effect(char *title,
882 SharedLocation *shared_location,
884 PluginSet *plugin_set,
889 KeyFrame *default_keyframe = 0;
890 PluginServer *server = 0;
897 // Get default keyframe
898 if(plugin_type == PLUGIN_STANDALONE)
900 default_keyframe = new KeyFrame;
901 server = new PluginServer(*scan_plugindb(title, track->data_type));
903 server->open_plugin(0, preferences, edl, 0);
904 server->save_data(default_keyframe);
909 // Insert plugin object
910 track->insert_effect(title,
921 if(plugin_type == PLUGIN_STANDALONE)
923 server->close_plugin();
925 delete default_keyframe;
929 int MWindow::modify_edithandles()
931 undo->update_undo_before();
932 edl->modify_edithandles(session->drag_start,
933 session->drag_position,
934 session->drag_handle,
935 edl->session->edit_handle_mode[session->drag_button],
936 edl->session->labels_follow_edits,
937 edl->session->plugins_follow_edits,
938 edl->session->autos_follow_edits);
940 finish_modify_handles();
943 //printf("MWindow::modify_handles 1\n");
947 int MWindow::modify_pluginhandles()
949 undo->update_undo_before();
951 edl->modify_pluginhandles(session->drag_start,
952 session->drag_position,
953 session->drag_handle,
954 edl->session->edit_handle_mode[session->drag_button],
955 edl->session->labels_follow_edits,
956 edl->session->autos_follow_edits,
957 session->trim_edits);
959 finish_modify_handles();
965 // Common to edithandles and plugin handles
966 void MWindow::finish_modify_handles()
968 int edit_mode = edl->session->edit_handle_mode[session->drag_button];
970 if((session->drag_handle == 1 && edit_mode != MOVE_NO_EDITS) ||
971 (session->drag_handle == 0 && edit_mode == MOVE_ONE_EDIT))
973 edl->local_session->set_selectionstart(session->drag_position);
974 edl->local_session->set_selectionend(session->drag_position);
977 if(edit_mode != MOVE_NO_EDITS)
979 edl->local_session->set_selectionstart(session->drag_start);
980 edl->local_session->set_selectionend(session->drag_start);
983 if(edl->local_session->get_selectionstart(1) < 0)
985 edl->local_session->set_selectionstart(0);
986 edl->local_session->set_selectionend(0);
988 undo->update_undo_after(_("drag handle"), LOAD_EDITS | LOAD_TIMEBAR);
992 sync_parameters(CHANGE_EDL);
993 update_plugin_guis();
994 gui->update(1, 2, 1, 1, 1, 1, 0);
995 cwindow->update(1, 0, 0, 0, 1);
998 void MWindow::match_output_size(Track *track)
1000 undo->update_undo_before();
1001 track->track_w = edl->session->output_w;
1002 track->track_h = edl->session->output_h;
1004 undo->update_undo_after(_("match output size"), LOAD_ALL);
1007 sync_parameters(CHANGE_EDL);
1011 void MWindow::move_edits(ArrayList<Edit*> *edits,
1016 undo->update_undo_before();
1018 edl->tracks->move_edits(edits,
1021 edl->session->labels_follow_edits,
1022 edl->session->plugins_follow_edits,
1023 edl->session->autos_follow_edits,
1027 undo->update_undo_after(_("move edit"), LOAD_ALL);
1030 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1035 update_plugin_guis();
1037 1, // 1 for incremental drawing. 2 for full refresh
1045 void MWindow::move_effect(Plugin *plugin, Track *track, int64_t position)
1047 undo->update_undo_before();
1048 edl->tracks->move_effect(plugin, track, position);
1050 undo->update_undo_after(_("paste effect"), LOAD_ALL);
1053 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1054 CHANGE_EDL, edl, 1);
1056 update_plugin_guis();
1057 gui->update(1, 1, // 1 for incremental drawing. 2 for full refresh
1061 void MWindow::move_effect(Plugin *plugin, PluginSet *plugin_set, int64_t position)
1063 undo->update_undo_before();
1064 edl->tracks->move_effect(plugin, plugin_set, position);
1066 undo->update_undo_after(_("move effect"), LOAD_ALL);
1069 cwindow->playback_engine->que->send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);
1070 update_plugin_guis();
1071 gui->update(1, 1, // 1 for incremental drawing. 2 for full refresh
1075 void MWindow::move_plugins_up(PluginSet *plugin_set)
1078 undo->update_undo_before();
1079 plugin_set->track->move_plugins_up(plugin_set);
1082 undo->update_undo_after(_("move effect up"), LOAD_ALL);
1085 1, // 1 for incremental drawing. 2 for full refresh
1091 sync_parameters(CHANGE_EDL);
1094 void MWindow::move_plugins_down(PluginSet *plugin_set)
1096 undo->update_undo_before();
1098 plugin_set->track->move_plugins_down(plugin_set);
1101 undo->update_undo_after(_("move effect down"), LOAD_ALL);
1104 1, // 1 for incremental drawing. 2 for full refresh
1110 sync_parameters(CHANGE_EDL);
1113 void MWindow::move_track_down(Track *track)
1115 undo->update_undo_before();
1116 edl->tracks->move_track_down(track);
1118 undo->update_undo_after(_("move track down"), LOAD_ALL);
1121 gui->update(1, 1, 0, 0, 1, 0, 0);
1122 sync_parameters(CHANGE_EDL);
1126 void MWindow::move_tracks_down()
1128 undo->update_undo_before();
1129 edl->tracks->move_tracks_down();
1131 undo->update_undo_after(_("move tracks down"), LOAD_ALL);
1134 gui->update(1, 1, 0, 0, 1, 0, 0);
1135 sync_parameters(CHANGE_EDL);
1139 void MWindow::move_track_up(Track *track)
1141 undo->update_undo_before();
1142 edl->tracks->move_track_up(track);
1144 undo->update_undo_after(_("move track up"), LOAD_ALL);
1146 gui->update(1, 1, 0, 0, 1, 0, 0);
1147 sync_parameters(CHANGE_EDL);
1151 void MWindow::move_tracks_up()
1153 undo->update_undo_before();
1154 edl->tracks->move_tracks_up();
1156 undo->update_undo_after(_("move tracks up"), LOAD_ALL);
1158 gui->update(1, 1, 0, 0, 1, 0, 0);
1159 sync_parameters(CHANGE_EDL);
1163 void MWindow::mute_selection()
1165 double start = edl->local_session->get_selectionstart();
1166 double end = edl->local_session->get_selectionend();
1169 undo->update_undo_before();
1173 edl->session->plugins_follow_edits,
1174 edl->session->autos_follow_edits);
1175 edl->local_session->set_selectionend(end);
1176 edl->local_session->set_selectionstart(start);
1177 edl->paste_silence(start,
1180 edl->session->plugins_follow_edits,
1181 edl->session->autos_follow_edits);
1183 undo->update_undo_after(_("mute"), LOAD_EDITS);
1186 update_plugin_guis();
1187 gui->update(1, 2, 1, 1, 1, 1, 0);
1188 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1197 void MWindow::overwrite(EDL *source)
1201 double src_start = source->local_session->get_selectionstart();
1202 double overwrite_len = source->local_session->get_selectionend() - src_start;
1203 double dst_start = edl->local_session->get_selectionstart();
1204 double dst_len = edl->local_session->get_selectionend() - dst_start;
1206 undo->update_undo_before();
1207 if (!EQUIV(dst_len, 0) && (dst_len < overwrite_len))
1209 // in/out points or selection present and shorter than overwrite range
1210 // shorten the copy range
1211 overwrite_len = dst_len;
1214 source->copy(src_start,
1215 src_start + overwrite_len,
1223 // HACK around paste_edl get_start/endselection on its own
1224 // so we need to clear only when not using both io points
1225 // FIXME: need to write simple overwrite_edl to be used for overwrite function
1226 if (edl->local_session->get_inpoint() < 0 ||
1227 edl->local_session->get_outpoint() < 0)
1228 edl->clear(dst_start,
1229 dst_start + overwrite_len,
1235 dst_start + overwrite_len,
1241 edl->local_session->set_selectionstart(dst_start + overwrite_len);
1242 edl->local_session->set_selectionend(dst_start + overwrite_len);
1245 undo->update_undo_after(_("overwrite"), LOAD_EDITS);
1248 update_plugin_guis();
1249 gui->update(1, 1, 1, 1, 0, 1, 0);
1250 sync_parameters(CHANGE_EDL);
1253 // For splice and overwrite
1254 int MWindow::paste(double start,
1263 // Want to insert with assets shared with the master EDL.
1274 // For editing using insertion point
1275 void MWindow::paste()
1277 double start = edl->local_session->get_selectionstart();
1278 //double end = edl->local_session->get_selectionend();
1279 int64_t len = gui->get_clipboard()->clipboard_len(SECONDARY_SELECTION);
1283 char *string = new char[len + 1];
1285 undo->update_undo_before();
1288 gui->get_clipboard()->from_clipboard(string,
1290 BC_PRIMARY_SELECTION);
1292 file.read_from_string(string);
1301 edl->session->labels_follow_edits,
1302 edl->session->plugins_follow_edits,
1303 edl->session->autos_follow_edits,
1316 undo->update_undo_after(_("paste"), LOAD_EDITS | LOAD_TIMEBAR);
1318 update_plugin_guis();
1319 gui->update(1, 2, 1, 1, 0, 1, 0);
1320 awindow->gui->async_update_assets();
1321 sync_parameters(CHANGE_EDL);
1326 int MWindow::paste_assets(double position, Track *dest_track, int overwrite)
1330 undo->update_undo_before();
1334 if(session->drag_assets->total)
1336 load_assets(session->drag_assets,
1341 edl->session->labels_follow_edits,
1342 edl->session->plugins_follow_edits,
1343 edl->session->autos_follow_edits,
1349 if(session->drag_clips->total)
1351 paste_edls(session->drag_clips,
1355 edl->session->labels_follow_edits,
1356 edl->session->plugins_follow_edits,
1357 edl->session->autos_follow_edits,
1365 undo->update_undo_after(_("paste assets"), LOAD_EDITS);
1374 sync_parameters(CHANGE_EDL);
1378 void MWindow::load_assets(ArrayList<Indexable*> *new_assets,
1382 RecordLabels *labels,
1388 const int debug = 0;
1389 if(debug) printf("MWindow::load_assets %d\n", __LINE__);
1390 if(position < 0) position = edl->local_session->get_selectionstart();
1392 ArrayList<EDL*> new_edls;
1393 for(int i = 0; i < new_assets->total; i++)
1395 Indexable *indexable = new_assets->get(i);
1396 if(indexable->is_asset)
1398 remove_asset_from_caches((Asset*)indexable);
1400 EDL *new_edl = new EDL;
1401 new_edl->create_objects();
1402 new_edl->copy_session(edl);
1403 new_edls.append(new_edl);
1406 if(indexable->is_asset)
1408 if(debug) printf("MWindow::load_assets %d\n", __LINE__);
1409 if(debug) ((Asset*)indexable)->dump();
1410 asset_to_edl(new_edl, (Asset*)indexable);
1413 edl_to_nested(new_edl, (EDL*)indexable);
1414 if(debug) printf("MWindow::load_assets %d\n", __LINE__);
1419 for(RecordLabel *label = labels->first; label; label = label->next)
1421 new_edl->labels->toggle_label(label->position, label->position);
1425 if(debug) printf("MWindow::load_assets %d\n", __LINE__);
1427 paste_edls(&new_edls,
1435 if(debug) printf("MWindow::load_assets %d\n", __LINE__);
1439 for(int i = 0; i < new_edls.size(); i++)
1440 new_edls.get(i)->Garbage::remove_user();
1442 if(debug) printf("MWindow::load_assets %d\n", __LINE__);
1445 int MWindow::paste_automation()
1447 int64_t len = gui->get_clipboard()->clipboard_len(SECONDARY_SELECTION);
1451 undo->update_undo_before();
1452 char *string = new char[len + 1];
1453 gui->get_clipboard()->from_clipboard(string,
1455 BC_PRIMARY_SELECTION);
1457 file.read_from_string(string);
1459 edl->tracks->clear_automation(edl->local_session->get_selectionstart(),
1460 edl->local_session->get_selectionend());
1461 edl->tracks->paste_automation(edl->local_session->get_selectionstart(),
1465 edl->session->typeless_keyframes);
1467 undo->update_undo_after(_("paste keyframes"), LOAD_AUTOMATION);
1472 update_plugin_guis();
1473 gui->draw_overlays(1);
1474 sync_parameters(CHANGE_PARAMS);
1475 gui->update_patchbay();
1476 cwindow->update(1, 0, 0);
1482 int MWindow::paste_default_keyframe()
1484 int64_t len = gui->get_clipboard()->clipboard_len(SECONDARY_SELECTION);
1488 undo->update_undo_before();
1489 char *string = new char[len + 1];
1490 gui->get_clipboard()->from_clipboard(string,
1492 BC_PRIMARY_SELECTION);
1494 file.read_from_string(string);
1495 edl->tracks->paste_automation(edl->local_session->get_selectionstart(),
1499 edl->session->typeless_keyframes);
1500 // edl->tracks->paste_default_keyframe(&file);
1501 undo->update_undo_after(_("paste default keyframe"), LOAD_AUTOMATION);
1505 update_plugin_guis();
1506 gui->draw_overlays(1);
1507 sync_parameters(CHANGE_PARAMS);
1508 gui->update_patchbay();
1509 cwindow->update(1, 0, 0);
1518 // Insert edls with project deletion and index file generation.
1519 int MWindow::paste_edls(ArrayList<EDL*> *new_edls,
1522 double current_position,
1529 ArrayList<Track*> destination_tracks;
1530 int need_new_tracks = 0;
1533 if(!new_edls->total) return 0;
1536 // double original_length = edl->tracks->total_playable_length();
1537 // double original_preview_end = edl->local_session->preview_end;
1540 // Delete current project
1541 if(load_mode == LOADMODE_REPLACE ||
1542 load_mode == LOADMODE_REPLACE_CONCATENATE)
1546 edl->save_defaults(defaults);
1550 edl->Garbage::remove_user();
1554 edl->create_objects();
1556 edl->copy_session(new_edls->values[0]);
1558 gui->mainmenu->update_toggles(0);
1561 gui->unlock_window();
1563 gwindow->gui->update_toggles(1);
1565 gui->lock_window("MWindow::paste_edls");
1568 // Insert labels for certain modes constitutively
1572 // Force reset of preview
1573 // original_length = 0;
1574 // original_preview_end = -1;
1580 // Create new tracks in master EDL
1581 if(load_mode == LOADMODE_REPLACE ||
1582 load_mode == LOADMODE_REPLACE_CONCATENATE ||
1583 load_mode == LOADMODE_NEW_TRACKS)
1586 need_new_tracks = 1;
1587 for(int i = 0; i < new_edls->total; i++)
1589 EDL *new_edl = new_edls->values[i];
1590 for(Track *current = new_edl->tracks->first;
1594 if(current->data_type == TRACK_VIDEO)
1596 edl->tracks->add_video_track(0, 0);
1597 if(current->draw) edl->tracks->last->draw = 1;
1598 destination_tracks.append(edl->tracks->last);
1601 if(current->data_type == TRACK_AUDIO)
1603 edl->tracks->add_audio_track(0, 0);
1604 destination_tracks.append(edl->tracks->last);
1607 if(current->data_type == TRACK_SUBTITLE)
1609 edl->tracks->add_subttl_track(0, 0);
1610 destination_tracks.append(edl->tracks->last);
1612 edl->session->highlighted_track = edl->tracks->total() - 1;
1615 // Base track count on first EDL only for concatenation
1616 if(load_mode == LOADMODE_REPLACE_CONCATENATE) break;
1621 // Recycle existing tracks of master EDL
1622 if(load_mode == LOADMODE_CONCATENATE ||
1623 load_mode == LOADMODE_PASTE ||
1624 load_mode == LOADMODE_NESTED)
1628 // The point of this is to shift forward labels after the selection so they can
1629 // then be shifted back to their original locations without recursively
1630 // shifting back every paste.
1631 if((load_mode == LOADMODE_PASTE ||
1632 load_mode == LOADMODE_NESTED) &&
1633 edl->session->labels_follow_edits)
1634 edl->labels->clear(edl->local_session->get_selectionstart(),
1635 edl->local_session->get_selectionend(),
1638 Track *current = first_track ? first_track : edl->tracks->first;
1639 for( ; current; current = NEXT)
1643 destination_tracks.append(current);
1654 int destination_track = 0;
1655 double *paste_position = new double[destination_tracks.total];
1661 // Iterate through the edls
1662 for(int i = 0; i < new_edls->total; i++)
1665 EDL *new_edl = new_edls->values[i];
1666 double edl_length = new_edl->local_session->clipboard_length ?
1667 new_edl->local_session->clipboard_length :
1668 new_edl->tracks->total_length();
1669 // printf("MWindow::paste_edls 2 %f %f\n",
1670 // new_edl->local_session->clipboard_length,
1671 // new_edl->tracks->total_length());
1678 // Convert EDL to master rates
1679 new_edl->resample(new_edl->session->sample_rate,
1680 edl->session->sample_rate,
1682 new_edl->resample(new_edl->session->frame_rate,
1683 edl->session->frame_rate,
1690 // Add assets and prepare index files
1691 for(Asset *new_asset = new_edl->assets->first;
1693 new_asset = new_asset->next)
1695 mainindexes->add_next_asset(0, new_asset);
1697 // Capture index file status from mainindex test
1698 edl->update_assets(new_edl);
1703 // Get starting point of insertion. Need this to paste labels.
1706 case LOADMODE_REPLACE:
1707 case LOADMODE_NEW_TRACKS:
1708 current_position = 0;
1711 case LOADMODE_CONCATENATE:
1712 case LOADMODE_REPLACE_CONCATENATE:
1713 destination_track = 0;
1714 if(destination_tracks.total)
1715 current_position = destination_tracks.values[0]->get_length();
1717 current_position = 0;
1720 case LOADMODE_PASTE:
1721 case LOADMODE_NESTED:
1722 destination_track = 0;
1725 for(int j = 0; j < destination_tracks.total; j++)
1727 paste_position[j] = (current_position >= 0) ?
1729 edl->local_session->get_selectionstart();
1734 case LOADMODE_RESOURCESONLY:
1735 edl->add_clip(new_edl);
1745 if(load_mode != LOADMODE_RESOURCESONLY)
1748 //printf("MWindow::paste_edls %f %f\n", current_position, edl_length);
1749 if(load_mode == LOADMODE_PASTE ||
1750 load_mode == LOADMODE_NESTED)
1751 edl->labels->insert_labels(new_edl->labels,
1752 destination_tracks.total ? paste_position[0] : 0.0,
1756 edl->labels->insert_labels(new_edl->labels,
1762 for(Track *new_track = new_edl->tracks->first;
1764 new_track = new_track->next)
1766 // Get destination track of same type as new_track
1768 k < destination_tracks.total &&
1769 destination_tracks.values[destination_track]->data_type != new_track->data_type;
1770 k++, destination_track++)
1772 if(destination_track >= destination_tracks.total - 1)
1773 destination_track = 0;
1776 // Insert data into destination track
1777 if(destination_track < destination_tracks.total &&
1778 destination_tracks.values[destination_track]->data_type == new_track->data_type)
1780 Track *track = destination_tracks.values[destination_track];
1782 // Replace default keyframes if first EDL and new tracks were created.
1783 // This means data copied from one track and pasted to another won't retain
1784 // the camera position unless it's a keyframe. If it did, previous data in the
1785 // track might get unknowingly corrupted. Ideally we would detect when differing
1786 // default keyframes existed and create discrete keyframes for both.
1787 int replace_default = (i == 0) && need_new_tracks;
1789 //printf("MWindow::paste_edls 1 %d\n", replace_default);
1790 // Insert new track at current position
1793 case LOADMODE_REPLACE_CONCATENATE:
1794 case LOADMODE_CONCATENATE:
1795 current_position = track->get_length();
1798 case LOADMODE_PASTE:
1799 case LOADMODE_NESTED:
1800 current_position = paste_position[destination_track];
1801 paste_position[destination_track] += new_track->get_length();
1805 track->clear(current_position,
1806 current_position + new_track->get_length(),
1816 track->insert_track(new_track,
1825 // Get next destination track
1826 destination_track++;
1827 if(destination_track >= destination_tracks.total)
1828 destination_track = 0;
1832 if(load_mode == LOADMODE_PASTE ||
1833 load_mode == LOADMODE_NESTED)
1834 current_position += edl_length;
1838 // Move loading of clips and vwindow to the end - this fixes some
1839 // strange issue, for index not being shown
1840 // Assume any paste operation from the same EDL won't contain any clips.
1841 // If it did it would duplicate every clip here.
1842 for(int i = 0; i < new_edls->total; i++)
1844 EDL *new_edl = new_edls->values[i];
1846 for(int j = 0; j < new_edl->clips.total; j++)
1848 edl->add_clip(new_edl->clips.values[j]);
1851 if(new_edl->total_vwindow_edls())
1853 // if(edl->vwindow_edl)
1854 // edl->vwindow_edl->Garbage::remove_user();
1855 // edl->vwindow_edl = new EDL(edl);
1856 // edl->vwindow_edl->create_objects();
1857 // edl->vwindow_edl->copy_all(new_edl->vwindow_edl);
1859 for(int j = 0; j < new_edl->total_vwindow_edls(); j++)
1861 EDL *vwindow_edl = new EDL(edl);
1862 vwindow_edl->create_objects();
1863 vwindow_edl->copy_all(new_edl->get_vwindow_edl(j));
1864 edl->append_vwindow_edl(vwindow_edl, 0);
1870 if(paste_position) delete [] paste_position;
1873 // This is already done in load_filenames and everything else that uses paste_edls
1874 // update_project(load_mode);
1876 // Fix preview range
1877 // if(EQUIV(original_length, original_preview_end))
1879 // edl->local_session->preview_end = edl->tracks->total_playable_length();
1883 // Start examining next batch of index files
1884 mainindexes->start_build();
1887 // Don't save a backup after loading since the loaded file is on disk already.
1894 void MWindow::paste_silence()
1896 double start = edl->local_session->get_selectionstart();
1897 double end = edl->local_session->get_selectionend();
1898 undo->update_undo_before();
1899 edl->paste_silence(start,
1901 edl->session->labels_follow_edits,
1902 edl->session->plugins_follow_edits,
1903 edl->session->autos_follow_edits);
1906 undo->update_undo_after(_("silence"), LOAD_EDITS | LOAD_TIMEBAR);
1908 update_plugin_guis();
1910 gui->update(1, 2, 1, 1, 1, 1, 0);
1911 cwindow->update(1, 0, 0, 0, 1);
1912 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1918 void MWindow::detach_transition(Transition *transition)
1920 undo->update_undo_before();
1921 hide_plugin(transition, 1);
1922 int is_video = (transition->edit->track->data_type == TRACK_VIDEO);
1923 transition->edit->detach_transition();
1925 undo->update_undo_after(_("detach transition"), LOAD_ALL);
1927 if(is_video) restart_brender();
1935 sync_parameters(CHANGE_EDL);
1938 void MWindow::detach_transitions()
1940 gui->lock_window("MWindow::detach_transitions 1");
1942 undo->update_undo_before();
1943 double start = edl->local_session->get_selectionstart();
1944 double end = edl->local_session->get_selectionend();
1945 edl->tracks->clear_transitions(start, end);
1948 undo->update_undo_after(_("detach transitions"), LOAD_EDITS);
1950 sync_parameters(CHANGE_EDL);
1951 gui->update(0, 1, 0, 0, 0, 0, 0);
1952 gui->unlock_window();
1955 void MWindow::paste_transition()
1957 // Only the first transition gets dropped.
1958 PluginServer *server = session->drag_pluginservers->values[0];
1960 undo->update_undo_before();
1962 strcpy(edl->session->default_atransition, server->title);
1964 strcpy(edl->session->default_vtransition, server->title);
1966 edl->tracks->paste_transition(server, session->edit_highlighted);
1968 undo->update_undo_after(_("transition"), LOAD_EDITS);
1970 if(server->video) restart_brender();
1971 sync_parameters(CHANGE_ALL);
1974 void MWindow::paste_transitions(int track_type, char *title)
1976 gui->lock_window("MWindow::detach_transitions 1");
1978 undo->update_undo_before();
1979 double start = edl->local_session->get_selectionstart();
1980 double end = edl->local_session->get_selectionend();
1981 edl->tracks->paste_transitions(start, end, track_type, title);
1984 undo->update_undo_after(_("attach transitions"), LOAD_EDITS);
1986 sync_parameters(CHANGE_EDL);
1987 gui->update(0, 1, 0, 0, 0, 0, 0);
1988 gui->unlock_window();
1991 void MWindow::paste_transition_cwindow(Track *dest_track)
1993 PluginServer *server = session->drag_pluginservers->values[0];
1994 undo->update_undo_before();
1995 edl->tracks->paste_video_transition(server, 1);
1997 undo->update_undo_after(_("transition"), LOAD_EDITS);
1999 gui->update(0, 1, 0, 0, 0, 0, 0);
2000 sync_parameters(CHANGE_ALL);
2003 void MWindow::paste_audio_transition()
2005 PluginServer *server = scan_plugindb(edl->session->default_atransition,
2009 char string[BCTEXTLEN];
2010 sprintf(string, _("No default transition %s found."), edl->session->default_atransition);
2011 gui->show_message(string);
2015 undo->update_undo_before();
2016 edl->tracks->paste_audio_transition(server);
2018 undo->update_undo_after(_("transition"), LOAD_EDITS);
2020 sync_parameters(CHANGE_EDL);
2021 gui->update(0, 1, 0, 0, 0, 0, 0);
2024 void MWindow::paste_video_transition()
2026 PluginServer *server = scan_plugindb(edl->session->default_vtransition,
2030 char string[BCTEXTLEN];
2031 sprintf(string, _("No default transition %s found."), edl->session->default_vtransition);
2032 gui->show_message(string);
2036 undo->update_undo_before();
2038 edl->tracks->paste_video_transition(server);
2040 undo->update_undo_after(_("transition"), LOAD_EDITS);
2042 sync_parameters(CHANGE_EDL);
2044 gui->update(0, 1, 0, 0, 0, 0, 0);
2047 void MWindow::shuffle_edits()
2049 gui->lock_window("MWindow::shuffle_edits 1");
2051 undo->update_undo_before();
2052 double start = edl->local_session->get_selectionstart();
2053 double end = edl->local_session->get_selectionend();
2055 edl->tracks->shuffle_edits(start, end);
2058 undo->update_undo_after(_("shuffle edits"), LOAD_EDITS | LOAD_TIMEBAR);
2060 sync_parameters(CHANGE_EDL);
2062 gui->update(0, 1, 1, 0, 0, 0, 0);
2063 gui->unlock_window();
2066 void MWindow::reverse_edits()
2068 gui->lock_window("MWindow::reverse_edits 1");
2070 undo->update_undo_before();
2071 double start = edl->local_session->get_selectionstart();
2072 double end = edl->local_session->get_selectionend();
2074 edl->tracks->reverse_edits(start, end);
2077 undo->update_undo_after(_("reverse edits"), LOAD_EDITS | LOAD_TIMEBAR);
2079 sync_parameters(CHANGE_EDL);
2081 gui->update(0, 1, 1, 0, 0, 0, 0);
2082 gui->unlock_window();
2085 void MWindow::align_edits()
2087 gui->lock_window("MWindow::align_edits 1");
2089 undo->update_undo_before();
2090 double start = edl->local_session->get_selectionstart();
2091 double end = edl->local_session->get_selectionend();
2093 edl->tracks->align_edits(start, end);
2096 undo->update_undo_after(_("align edits"), LOAD_EDITS | LOAD_TIMEBAR);
2098 sync_parameters(CHANGE_EDL);
2100 gui->update(0, 1, 1, 0, 0, 0, 0);
2101 gui->unlock_window();
2104 void MWindow::set_edit_length(double length)
2106 gui->lock_window("MWindow::detach_transitions 1");
2108 undo->update_undo_before();
2109 double start = edl->local_session->get_selectionstart();
2110 double end = edl->local_session->get_selectionend();
2112 edl->tracks->set_edit_length(start, end, length);
2115 undo->update_undo_after(_("edit length"), LOAD_EDITS | LOAD_TIMEBAR);
2117 sync_parameters(CHANGE_EDL);
2119 gui->update(0, 1, 1, 0, 0, 0, 0);
2120 gui->unlock_window();
2124 void MWindow::set_transition_length(Transition *transition, double length)
2126 gui->lock_window("MWindow::detach_transitions 1");
2128 undo->update_undo_before();
2129 //double start = edl->local_session->get_selectionstart();
2130 //double end = edl->local_session->get_selectionend();
2132 edl->tracks->set_transition_length(transition, length);
2135 undo->update_undo_after(_("transition length"), LOAD_EDITS);
2137 edl->session->default_transition_length = length;
2138 sync_parameters(CHANGE_PARAMS);
2139 gui->update(0, 1, 0, 0, 0, 0, 0);
2140 gui->unlock_window();
2143 void MWindow::set_transition_length(double length)
2145 gui->lock_window("MWindow::detach_transitions 1");
2147 undo->update_undo_before();
2148 double start = edl->local_session->get_selectionstart();
2149 double end = edl->local_session->get_selectionend();
2151 edl->tracks->set_transition_length(start, end, length);
2154 undo->update_undo_after(_("transition length"), LOAD_EDITS);
2156 edl->session->default_transition_length = length;
2157 sync_parameters(CHANGE_PARAMS);
2159 gui->update(0, 1, 0, 0, 0, 0, 0);
2160 gui->unlock_window();
2164 void MWindow::redo_entry(BC_WindowBase *calling_window_gui)
2167 calling_window_gui->unlock_window();
2169 cwindow->playback_engine->que->send_command(STOP,
2173 cwindow->playback_engine->interrupt_playback(0);
2175 for(int i = 0; i < vwindows.size(); i++)
2177 if(vwindows.get(i)->is_running())
2179 vwindows.get(i)->playback_engine->que->send_command(STOP,
2183 vwindows.get(i)->playback_engine->interrupt_playback(0);
2187 cwindow->gui->lock_window("MWindow::redo_entry");
2188 for(int i = 0; i < vwindows.size(); i++)
2190 if(vwindows.get(i)->is_running())
2192 if (calling_window_gui != vwindows.get(i)->gui)
2194 vwindows.get(i)->gui->lock_window("MWindow::redo_entry 2");
2203 update_plugin_states();
2204 update_plugin_guis();
2206 gui->update(1, 2, 1, 1, 1, 1, 1);
2207 cwindow->update(1, 1, 1, 1, 1);
2209 if (calling_window_gui != cwindow->gui)
2210 cwindow->gui->unlock_window();
2211 if (calling_window_gui != gui)
2212 gui->unlock_window();
2215 for(int i = 0; i < vwindows.size(); i++)
2217 if(vwindows.get(i)->is_running())
2219 if (calling_window_gui != vwindows.get(i)->gui)
2221 vwindows.get(i)->gui->unlock_window();
2226 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
2234 void MWindow::resize_track(Track *track, int w, int h)
2236 undo->update_undo_before();
2237 // We have to move all maskpoints so they do not move in relation to image areas
2238 ((MaskAutos*)track->automation->autos[AUTOMATION_MASK])->translate_masks(
2239 (w - track->track_w) / 2,
2240 (h - track->track_h) / 2);
2243 undo->update_undo_after(_("resize track"), LOAD_ALL);
2247 sync_parameters(CHANGE_EDL);
2251 void MWindow::set_inpoint(int is_mwindow)
2253 undo->update_undo_before();
2254 edl->set_inpoint(edl->local_session->get_selectionstart(1));
2256 undo->update_undo_after(_("in point"), LOAD_TIMEBAR);
2260 gui->lock_window("MWindow::set_inpoint 1");
2262 gui->update_timebar(1);
2265 gui->unlock_window();
2270 cwindow->gui->lock_window("MWindow::set_inpoint 2");
2272 cwindow->gui->timebar->update(1);
2275 cwindow->gui->unlock_window();
2279 void MWindow::set_outpoint(int is_mwindow)
2281 undo->update_undo_before();
2282 edl->set_outpoint(edl->local_session->get_selectionend(1));
2284 undo->update_undo_after(_("out point"), LOAD_TIMEBAR);
2288 gui->lock_window("MWindow::set_outpoint 1");
2290 gui->update_timebar(1);
2293 gui->unlock_window();
2298 cwindow->gui->lock_window("MWindow::set_outpoint 2");
2300 cwindow->gui->timebar->update(1);
2303 cwindow->gui->unlock_window();
2307 void MWindow::splice(EDL *source)
2311 undo->update_undo_before();
2312 source->copy(source->local_session->get_selectionstart(),
2313 source->local_session->get_selectionend(),
2324 double start = edl->local_session->get_selectionstart();
2325 //double end = edl->local_session->get_selectionend();
2326 double source_start = source->local_session->get_selectionstart();
2327 double source_end = source->local_session->get_selectionend();
2332 edl->session->labels_follow_edits,
2333 edl->session->plugins_follow_edits,
2334 edl->session->autos_follow_edits);
2336 // Position at end of clip
2337 edl->local_session->set_selectionstart(start +
2340 edl->local_session->set_selectionend(start +
2345 undo->update_undo_after(_("splice"), LOAD_EDITS | LOAD_TIMEBAR);
2346 update_plugin_guis();
2348 gui->update(1, 1, 1, 1, 0, 1, 0);
2349 sync_parameters(CHANGE_EDL);
2352 void MWindow::to_clip(EDL *edl, const char *txt)
2357 gui->lock_window("MWindow::to_clip 1");
2358 start = edl->local_session->get_selectionstart();
2359 end = edl->local_session->get_selectionend();
2361 if(EQUIV(end, start)) {
2363 end = edl->tracks->total_length();
2366 // Don't copy all since we don't want the clips twice.
2367 edl->copy(start, end, 0, 0, 0, &file, "", 1);
2369 EDL *new_edl = new EDL(edl);
2370 new_edl->create_objects();
2371 new_edl->load_xml(&file, LOAD_ALL);
2372 sprintf(new_edl->local_session->clip_title, _("Clip %d"), session->clip_number++);
2373 char duration[BCTEXTLEN];
2374 Units::totext(duration, end - start,
2375 edl->session->time_format,
2376 edl->session->sample_rate,
2377 edl->session->frame_rate,
2378 edl->session->frames_per_foot);
2380 const char *path = edl->path;
2381 Track *track=edl->tracks->first;
2382 for(; (!path || !*path) && track; track=track->next ) {
2383 if( !track->record ) continue;
2384 Edit *edit = track->edits->editof(start, PLAY_FORWARD, 0);
2385 if( !edit ) continue;
2386 Indexable *indexable = edit->get_source();
2387 if( !indexable ) continue;
2388 path = indexable->path;
2391 time_t now; time(&now);
2392 struct tm *tm = localtime(&now);
2393 char *cp = new_edl->local_session->clip_notes;
2394 int n, sz = sizeof(new_edl->local_session->clip_notes)-1;
2396 n = snprintf(cp, sz, "%s", txt);
2399 n = snprintf(cp, sz,
2400 "%02d/%02d/%02d %02d:%02d:%02d, +%s\n",
2401 tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
2402 tm->tm_hour, tm->tm_min, tm->tm_sec, duration);
2404 if( path && *path ) {
2406 char title[BCTEXTLEN];
2407 fs.extract_name(title, path);
2408 n = snprintf(cp, sz, "%s", title);
2413 new_edl->local_session->set_selectionstart(0);
2414 new_edl->local_session->set_selectionend(0);
2416 gui->unlock_window();
2418 awindow->clip_edit->create_clip(new_edl);
2420 gui->lock_window("MWindow::to_clip 2");
2422 gui->unlock_window();
2424 void MWindow::to_clip(const char *txt)
2429 int MWindow::toggle_label(int is_mwindow)
2431 double position1, position2;
2432 undo->update_undo_before();
2434 if(cwindow->playback_engine->is_playing_back)
2436 position1 = position2 =
2437 cwindow->playback_engine->get_tracking_position();
2441 position1 = edl->local_session->get_selectionstart(1);
2442 position2 = edl->local_session->get_selectionend(1);
2445 position1 = edl->align_to_frame(position1, 0);
2446 position2 = edl->align_to_frame(position2, 0);
2448 //printf("MWindow::toggle_label 1\n");
2450 edl->labels->toggle_label(position1, position2);
2455 gui->lock_window("MWindow::toggle_label 1");
2457 gui->update_timebar(0);
2458 gui->activate_timeline();
2462 gui->unlock_window();
2467 cwindow->gui->lock_window("MWindow::toggle_label 2");
2469 cwindow->gui->timebar->update(1);
2472 cwindow->gui->unlock_window();
2475 awindow->gui->async_update_assets();
2477 undo->update_undo_after(_("label"), LOAD_TIMEBAR);
2481 void MWindow::trim_selection()
2483 undo->update_undo_before();
2486 edl->trim_selection(edl->local_session->get_selectionstart(),
2487 edl->local_session->get_selectionend(),
2488 edl->session->labels_follow_edits,
2489 edl->session->plugins_follow_edits,
2490 edl->session->autos_follow_edits);
2493 undo->update_undo_after(_("trim selection"), LOAD_EDITS | LOAD_TIMEBAR);
2494 update_plugin_guis();
2495 gui->update(1, 2, 1, 1, 1, 1, 0);
2496 cwindow->update(1, 0, 0, 0, 1);
2498 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
2506 void MWindow::undo_entry(BC_WindowBase *calling_window_gui)
2508 calling_window_gui->unlock_window();
2510 cwindow->playback_engine->que->send_command(STOP,
2514 cwindow->playback_engine->interrupt_playback(0);
2516 //printf("MWindow::undo_entry %d %d\n", __LINE__, vwindows.size());
2517 for(int i = 0; i < vwindows.size(); i++)
2519 if(vwindows.get(i)->is_running())
2521 vwindows.get(i)->playback_engine->que->send_command(STOP,
2525 vwindows.get(i)->playback_engine->interrupt_playback(0);
2529 cwindow->gui->lock_window("MWindow::undo_entry 1");
2530 for(int i = 0; i < vwindows.size(); i++)
2532 if(vwindows.get(i)->is_running())
2534 if (calling_window_gui != vwindows.get(i)->gui)
2536 vwindows.get(i)->gui->lock_window("MWindow::undo_entry 4");
2540 gui->lock_window("MWindow::undo_entry 2");
2546 update_plugin_states();
2547 update_plugin_guis();
2551 gui->update(1, 2, 1, 1, 1, 1, 1);
2553 gui->unlock_window();
2555 cwindow->update(1, 1, 1, 1, 1);
2557 cwindow->gui->unlock_window();
2559 for(int i = 0; i < vwindows.size(); i++)
2561 if(vwindows.get(i)->is_running())
2563 if (calling_window_gui != vwindows.get(i)->gui)
2565 vwindows.get(i)->gui->unlock_window();
2570 if (calling_window_gui != gui)
2571 gui->unlock_window();
2574 awindow->gui->async_update_assets();
2576 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
2580 calling_window_gui->lock_window("MWindow::undo_entry 4");
2585 void MWindow::new_folder(const char *new_folder)
2587 undo->update_undo_before();
2588 edl->new_folder(new_folder);
2589 undo->update_undo_after(_("new folder"), LOAD_ALL);
2590 awindow->gui->async_update_assets();
2593 void MWindow::delete_folder(char *folder)
2595 // undo->update_undo_after(_("delete folder"), LOAD_ALL);
2598 void MWindow::select_point(double position)
2600 edl->local_session->set_selectionstart(position);
2601 edl->local_session->set_selectionend(position);
2604 cwindow->update(1, 0, 0, 0, 1);
2607 update_plugin_guis();
2608 gui->update_patchbay();
2609 gui->hide_cursor(0);
2610 gui->draw_cursor(0);
2611 gui->mainclock->update(edl->local_session->get_selectionstart(1));
2612 gui->zoombar->update();
2613 gui->update_timebar(0);
2614 gui->flash_canvas(0);
2621 void MWindow::map_audio(int pattern)
2623 undo->update_undo_before();
2624 remap_audio(pattern);
2625 undo->update_undo_after(
2626 pattern == MWindow::AUDIO_1_TO_1 ? _("map 1:1") : _("map 5.1:2"),
2628 sync_parameters(CHANGE_PARAMS);
2629 gui->update(0, 1, 0, 0, 1, 0, 0);
2632 void MWindow::remap_audio(int pattern)
2634 int current_channel = 0;
2635 int current_track = 0;
2636 for(Track *current = edl->tracks->first; current; current = NEXT)
2638 if(current->data_type == TRACK_AUDIO &&
2641 Autos *pan_autos = current->automation->autos[AUTOMATION_PAN];
2642 PanAuto *pan_auto = (PanAuto*)pan_autos->get_auto_for_editing(-1);
2644 for(int i = 0; i < MAXCHANNELS; i++)
2646 pan_auto->values[i] = 0.0;
2649 if(pattern == MWindow::AUDIO_1_TO_1)
2651 pan_auto->values[current_channel] = 1.0;
2654 if(pattern == MWindow::AUDIO_5_1_TO_2)
2656 switch(current_track)
2659 pan_auto->values[0] = 0.5;
2660 pan_auto->values[1] = 0.5;
2663 pan_auto->values[0] = 1;
2666 pan_auto->values[1] = 1;
2669 pan_auto->values[0] = 1;
2672 pan_auto->values[1] = 1;
2675 pan_auto->values[0] = 0.5;
2676 pan_auto->values[1] = 0.5;
2681 BC_Pan::calculate_stick_position(edl->session->audio_channels,
2682 edl->session->achannel_positions,
2687 pan_auto->handle_y);
2691 if(current_channel >= edl->session->audio_channels)
2692 current_channel = 0;
2697 void MWindow::cut_commercials()
2699 undo->update_undo_before();
2700 commercials->scan_media();
2703 undo->update_undo_after(_("cut ads"), LOAD_EDITS | LOAD_TIMEBAR);
2706 update_plugin_guis();
2707 gui->update(1, 2, 1, 1, 1, 1, 0);
2708 cwindow->update(1, 0, 0, 0, 1);
2709 cwindow->playback_engine->que->
2710 send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);