r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / mwindowedit.C
blob6a1a62f30467b48ac0e0cbbc8dc20ece6858c253
1 #include "assets.h"
2 #include "awindowgui.h"
3 #include "awindow.h"
4 #include "cache.h"
5 #include "clip.h"
6 #include "clipedit.h"
7 #include "cplayback.h"
8 #include "ctimebar.h"
9 #include "cwindow.h"
10 #include "cwindowgui.h"
11 #include "edl.h"
12 #include "edlsession.h"
13 #include "filexml.h"
14 #include "keyframe.h"
15 #include "labels.h"
16 #include "levelwindow.h"
17 #include "localsession.h"
18 #include "mainclock.h"
19 #include "mainindexes.h"
20 #include "mainmenu.h"
21 #include "mainsession.h"
22 #include "mainundo.h"
23 #include "mtimebar.h"
24 #include "mwindowgui.h"
25 #include "mwindow.h"
26 #include "patchbay.h"
27 #include "playbackengine.h"
28 #include "pluginset.h"
29 #include "recordlabel.h"
30 #include "samplescroll.h"
31 #include "trackcanvas.h"
32 #include "track.h"
33 #include "trackscroll.h"
34 #include "tracks.h"
35 #include "transition.h"
36 #include "transportque.h"
37 #include "units.h"
38 #include "vplayback.h"
39 #include "vwindow.h"
40 #include "vwindowgui.h"
41 #include "zoombar.h"
45 #include <string.h>
47 #include <libintl.h>
48 #define _(String) gettext(String)
49 #define gettext_noop(String) String
50 #define N_(String) gettext_noop (String)
55 void MWindow::add_audio_track_entry(int above, Track *dst)
57         undo->update_undo_before(_("add track"), LOAD_ALL);
58         add_audio_track(1, dst);
59         save_backup();
60         undo->update_undo_after();
62         restart_brender();
63         gui->get_scrollbars();
64         gui->canvas->draw();
65         gui->patchbay->update();
66         gui->cursor->draw();
67         gui->canvas->flash();
68         gui->canvas->activate();
69         cwindow->playback_engine->que->send_command(CURRENT_FRAME, 
70                                                         CHANGE_EDL,
71                                                         edl,
72                                                         1);
75 void MWindow::add_video_track_entry(Track *dst)
77         undo->update_undo_before(_("add track"), LOAD_ALL);
78         add_video_track(1, dst);
79         undo->update_undo_after();
81         restart_brender();
82         gui->get_scrollbars();
83         gui->canvas->draw();
84         gui->patchbay->update();
85         gui->cursor->draw();
86         gui->canvas->flash();
87         gui->canvas->activate();
88         cwindow->playback_engine->que->send_command(CURRENT_FRAME, 
89                                                         CHANGE_EDL,
90                                                         edl,
91                                                         1);
92         save_backup();
96 int MWindow::add_audio_track(int above, Track *dst)
98         edl->tracks->add_audio_track(above, dst);
99         edl->tracks->update_y_pixels(theme);
100         save_backup();
101         return 0;
104 int MWindow::add_video_track(int above, Track *dst)
106         edl->tracks->add_video_track(above, dst);
107         edl->tracks->update_y_pixels(theme);
108         save_backup();
109         return 0;
116 void MWindow::asset_to_size()
118         if(session->drag_assets->total &&
119                 session->drag_assets->values[0]->video_data)
120         {
121                 int w, h;
123                 w = session->drag_assets->values[0]->width;
124                 h = session->drag_assets->values[0]->height;
126                 undo->update_undo_before(_("asset to size"), LOAD_ALL);
127                 edl->session->output_w = w;
128                 edl->session->output_h = h;
129                 save_backup();
131                 undo->update_undo_after();
132                 restart_brender();
133                 sync_parameters(CHANGE_ALL);
134         }
139 void MWindow::clear_entry()
141         undo->update_undo_before(_("clear"), LOAD_EDITS | LOAD_TIMEBAR);
142         clear(1);
144         edl->optimize();
145         save_backup();
146         undo->update_undo_after();
148         restart_brender();
149         update_plugin_guis();
150         gui->update(1, 2, 1, 1, 1, 1, 0);
151         cwindow->update(1, 0, 0, 0, 1);
152         cwindow->playback_engine->que->send_command(CURRENT_FRAME, 
153                            CHANGE_EDL,
154                            edl,
155                            1);
158 void MWindow::clear(int clear_handle)
160         double start = edl->local_session->get_selectionstart();
161         double end = edl->local_session->get_selectionend();
162         if(clear_handle || !EQUIV(start, end))
163         {
164                 edl->clear(start, 
165                         end, 
166                         edl->session->labels_follow_edits, 
167                         edl->session->plugins_follow_edits);
168         }
171 void MWindow::clear_automation()
173         undo->update_undo_before(_("clear keyframes"), LOAD_AUTOMATION); 
174         edl->tracks->clear_automation(edl->local_session->get_selectionstart(), 
175                 edl->local_session->get_selectionend()); 
176         save_backup();
177         undo->update_undo_after(); 
179         restart_brender();
180         update_plugin_guis();
181         gui->canvas->draw_overlays();
182         gui->canvas->flash();
183         sync_parameters(CHANGE_PARAMS);
184         gui->patchbay->update();
185         cwindow->update(1, 0, 0);
188 int MWindow::clear_default_keyframe()
190         undo->update_undo_before(_("clear default keyframe"), LOAD_AUTOMATION); 
191         edl->tracks->clear_default_keyframe();
192         save_backup();
193         undo->update_undo_after();
194         
195         restart_brender();
196         gui->canvas->draw_overlays();
197         gui->canvas->flash();
198         sync_parameters(CHANGE_PARAMS);
199         gui->patchbay->update();
200         cwindow->update(1, 0, 0);
201         
202         return 0;
205 void MWindow::clear_labels()
207         undo->update_undo_before(_("clear"), LOAD_TIMEBAR);
208         clear_labels(edl->local_session->get_selectionstart(), 
209                 edl->local_session->get_selectionend()); 
210         undo->update_undo_after(); 
211         
212         gui->timebar->update();
213         cwindow->update(0, 0, 0, 0, 1);
214         save_backup();
217 int MWindow::clear_labels(double start, double end)
219         edl->labels->clear(start, end, 0);
220         return 0;
223 void MWindow::concatenate_tracks()
225         undo->update_undo_before(_("concatenate tracks"), LOAD_EDITS);
226         edl->tracks->concatenate_tracks(edl->session->plugins_follow_edits);
227         save_backup();
228         undo->update_undo_after();
230         restart_brender();
231         gui->update(1, 1, 0, 0, 1, 0, 0);
232         cwindow->playback_engine->que->send_command(CURRENT_FRAME, 
233                 CHANGE_EDL,
234                 edl,
235                 1);
239 void MWindow::copy()
241         copy(edl->local_session->get_selectionstart(), 
242                 edl->local_session->get_selectionend());
245 int MWindow::copy(double start, double end)
247         if(start == end) return 1;
249 //printf("MWindow::copy 1\n");
250         FileXML file;
251 //printf("MWindow::copy 1\n");
252         edl->copy(start, 
253                 end, 
254                 0,
255                 0,
256                 0,
257                 &file, 
258                 plugindb,
259                 "",
260                 1);
261 //printf("MWindow::copy 1\n");
263 // File is now terminated and rewound
265 //printf("MWindow::copy 1\n");
266         gui->get_clipboard()->to_clipboard(file.string, strlen(file.string), SECONDARY_SELECTION);
267 //printf("MWindow::copy\n%s\n", file.string);
268 //printf("MWindow::copy 2\n");
269         save_backup();
270         return 0;
273 int MWindow::copy_automation()
275         FileXML file;
276         edl->tracks->copy_automation(edl->local_session->get_selectionstart(), 
277                 edl->local_session->get_selectionend(),
278                 &file,
279                 0,
280                 0); 
281         gui->get_clipboard()->to_clipboard(file.string, 
282                 strlen(file.string), 
283                 SECONDARY_SELECTION);
284         return 0;
287 int MWindow::copy_default_keyframe()
289         FileXML file;
290         edl->tracks->copy_default_keyframe(&file);
291         gui->get_clipboard()->to_clipboard(file.string,
292                 strlen(file.string),
293                 SECONDARY_SELECTION);
294         return 0;
298 // Uses cropping coordinates in edl session to crop and translate video.
299 // We modify the projector since camera automation depends on the track size.
300 void MWindow::crop_video()
302         undo->update_undo_before(_("crop"), LOAD_ALL);
305         float old_projector_x = (float)edl->session->output_w / 2;
306         float old_projector_y = (float)edl->session->output_h / 2;
307         float new_projector_x = (float)(edl->session->crop_x1 + edl->session->crop_x2) / 2;
308         float new_projector_y = (float)(edl->session->crop_y1 + edl->session->crop_y2) / 2;
309         float projector_offset_x = -(new_projector_x - old_projector_x);
310         float projector_offset_y = -(new_projector_y - old_projector_y);
312         edl->tracks->translate_projector(projector_offset_x, projector_offset_y);
314         edl->session->output_w = edl->session->crop_x2 - edl->session->crop_x1;
315         edl->session->output_h = edl->session->crop_y2 - edl->session->crop_y1;
316         edl->session->crop_x1 = 0;
317         edl->session->crop_y1 = 0;
318         edl->session->crop_x2 = edl->session->output_w;
319         edl->session->crop_y2 = edl->session->output_h;
320         undo->update_undo_after();
322         restart_brender();
323         cwindow->playback_engine->que->send_command(CURRENT_FRAME,
324                 CHANGE_ALL,
325                 edl,
326                 1);
327         save_backup();
330 void MWindow::cut()
332         undo->update_undo_before(_("cut"), LOAD_EDITS | LOAD_TIMEBAR);
334         double start = edl->local_session->get_selectionstart();
335         double end = edl->local_session->get_selectionend();
337         copy(start, end);
338         edl->clear(start, 
339                 end,
340                 edl->session->labels_follow_edits, 
341                 edl->session->plugins_follow_edits);
344         edl->optimize();
345         save_backup();
346         undo->update_undo_after();
348         restart_brender();
349         update_plugin_guis();
350         gui->update(1, 2, 1, 1, 1, 1, 0);
351         cwindow->playback_engine->que->send_command(CURRENT_FRAME, 
352                                                         CHANGE_EDL,
353                                                         edl,
354                                                         1);
357 int MWindow::cut_automation()
359         undo->update_undo_before(_("cut keyframes"), LOAD_AUTOMATION);
360         
361         copy_automation();
363         edl->tracks->clear_automation(edl->local_session->get_selectionstart(), 
364                 edl->local_session->get_selectionend()); 
365         save_backup();
366         undo->update_undo_after(); 
369         restart_brender();
370         update_plugin_guis();
371         gui->canvas->draw_overlays();
372         gui->canvas->flash();
373         sync_parameters(CHANGE_PARAMS);
374         gui->patchbay->update();
375         cwindow->update(1, 0, 0);
376         return 0;
379 int MWindow::cut_default_keyframe()
381         undo->update_undo_before(_("cut default keyframe"), LOAD_AUTOMATION);
383         copy_default_keyframe();
384         edl->tracks->clear_default_keyframe();
385         undo->update_undo_after();
387         restart_brender();
388         gui->canvas->draw_overlays();
389         gui->canvas->flash();
390         sync_parameters(CHANGE_PARAMS);
391         gui->patchbay->update();
392         cwindow->update(1, 0, 0);
393         save_backup();
396         return 0;
399 void MWindow::delete_inpoint()
401         edl->local_session->in_point = -1;
402         save_backup();
405 void MWindow::delete_outpoint()
407         edl->local_session->out_point = -1;
408         save_backup();
411 void MWindow::delete_track()
413         undo->update_undo_before(_("delete track"), LOAD_ALL);
414         edl->tracks->delete_track();
415         undo->update_undo_after();
416         save_backup();
418         restart_brender();
419         update_plugin_states();
420         gui->update(1, 1, 1, 0, 1, 0, 0);
421         cwindow->playback_engine->que->send_command(CURRENT_FRAME, 
422                            CHANGE_EDL,
423                            edl,
424                            1);
427 void MWindow::delete_tracks()
429         undo->update_undo_before(_("delete tracks"), LOAD_ALL);
430         edl->tracks->delete_tracks();
431         undo->update_undo_after();
432         save_backup();
434         restart_brender();
435         update_plugin_states();
436         gui->update(1, 1, 1, 0, 1, 0, 0);
437         cwindow->playback_engine->que->send_command(CURRENT_FRAME, 
438                            CHANGE_EDL,
439                            edl,
440                            1);
441 //printf("MWindow::delete_tracks 5\n");
444 void MWindow::delete_track(Track *track)
446         undo->update_undo_before(_("delete track"), LOAD_ALL);
447         edl->tracks->delete_track(track);
448         undo->update_undo_after();
450         restart_brender();
451         update_plugin_states();
452         gui->update(1, 1, 1, 0, 1, 0, 0);
453         cwindow->playback_engine->que->send_command(CURRENT_FRAME, 
454                            CHANGE_EDL,
455                            edl,
456                            1);
457         save_backup();
460 void MWindow::detach_transition(Transition *transition)
462         undo->update_undo_before(_("detach transition"), LOAD_ALL);
463         hide_plugin(transition, 1);
464         int is_video = (transition->edit->track->data_type == TRACK_VIDEO);
465         transition->edit->detach_transition();
466         save_backup();
467         undo->update_undo_after();
469         if(is_video) restart_brender();
470         gui->update(0,
471                 1,
472                 0,
473                 0,
474                 0, 
475                 0,
476                 0);
477         sync_parameters(CHANGE_EDL);
484 // Insert data from clipboard
485 void MWindow::insert(double position, 
486         FileXML *file,
487         int edit_labels,
488         int edit_plugins,
489         EDL *parent_edl)
491 // For clipboard pasting make the new edl use a separate session 
492 // from the master EDL.  Then it can be resampled to the master rates.
493 // For splice, overwrite, and dragging need same session to get the assets.
494         EDL edl(parent_edl);
495         ArrayList<EDL*> new_edls;
496         uint32_t load_flags = LOAD_ALL;
498         new_edls.append(&edl);
499         edl.create_objects();
503         if(parent_edl) load_flags &= ~LOAD_SESSION;
504         if(!edl.session->autos_follow_edits) load_flags &= ~LOAD_AUTOMATION;
505         if(!edl.session->labels_follow_edits) load_flags &= ~LOAD_TIMEBAR;
506         edl.load_xml(plugindb, file, load_flags);
512         paste_edls(&new_edls, 
513                 LOAD_PASTE, 
514                 0, 
515                 position,
516                 edit_labels,
517                 edit_plugins);
518 // if(vwindow->edl)
519 // printf("MWindow::insert 5 %f %f\n", 
520 // vwindow->edl->local_session->in_point,
521 // vwindow->edl->local_session->out_point);
522         new_edls.remove_all();
523 //printf("MWindow::insert 6 %p\n", vwindow->get_edl());
526 void MWindow::insert_effects_canvas(double start,
527         double length)
529         Track *dest_track = session->track_highlighted;
530         if(!dest_track) return;
532         undo->update_undo_before(_("insert effect"), LOAD_EDITS | LOAD_PATCHES);
534         for(int i = 0; i < session->drag_pluginservers->total; i++)
535         {
536                 PluginServer *plugin = session->drag_pluginservers->values[i];
538                 insert_effect(plugin->title,
539                         0,
540                         dest_track,
541                         i == 0 ? session->pluginset_highlighted : 0,
542                         start,
543                         length,
544                         PLUGIN_STANDALONE);
545         }
547         save_backup();
548         undo->update_undo_after();
549         restart_brender();
550         sync_parameters(CHANGE_EDL);
551 // GUI updated in TrackCanvas, after current_operations are reset
554 void MWindow::insert_effects_cwindow(Track *dest_track)
556         if(!dest_track) return;
558         undo->update_undo_before(_("insert effect"), LOAD_EDITS | LOAD_PATCHES);
560         double start = 0;
561         double length = dest_track->get_length();
563         if(edl->local_session->get_selectionend() > 
564                 edl->local_session->get_selectionstart())
565         {
566                 start = edl->local_session->get_selectionstart();
567                 length = edl->local_session->get_selectionend() - 
568                         edl->local_session->get_selectionstart();
569         }
571         for(int i = 0; i < session->drag_pluginservers->total; i++)
572         {
573                 PluginServer *plugin = session->drag_pluginservers->values[i];
576                 insert_effect(plugin->title,
577                         0,
578                         dest_track,
579                         0,
580                         start,
581                         length,
582                         PLUGIN_STANDALONE);
583         }
585         save_backup();
586         undo->update_undo_after();
587         restart_brender();
588         sync_parameters(CHANGE_EDL);
589         gui->update(1,
590                 1,
591                 0,
592                 0,
593                 1,
594                 0,
595                 0);
600 void MWindow::insert_effect(char *title, 
601         SharedLocation *shared_location, 
602         Track *track,
603         PluginSet *plugin_set,
604         double start,
605         double length,
606         int plugin_type)
608         KeyFrame *default_keyframe = 0;
609         PluginServer *server = 0;
616 // Get default keyframe
617         if(plugin_type == PLUGIN_STANDALONE)
618         {
619                 default_keyframe = new KeyFrame;
620                 server = new PluginServer(*scan_plugindb(title));
622                 server->open_plugin(0, edl, 0);
623                 server->save_data(default_keyframe);
624         }
628 // Insert plugin object
629         track->insert_effect(title, 
630                 shared_location, 
631                 default_keyframe, 
632                 plugin_set,
633                 start,
634                 length,
635                 plugin_type);
637         track->optimize();
640         if(plugin_type == PLUGIN_STANDALONE)
641         {
642                 server->close_plugin();
643                 delete server;
644                 delete default_keyframe;
645         }
648 int MWindow::modify_edithandles()
650         undo->update_undo_before(_("drag handle"), LOAD_EDITS | LOAD_TIMEBAR);
656         edl->modify_edithandles(session->drag_start, 
657                 session->drag_position, 
658                 session->drag_handle, 
659                 edl->session->edit_handle_mode[session->drag_button],
660                 edl->session->labels_follow_edits, 
661                 edl->session->plugins_follow_edits);
663         finish_modify_handles();
666 //printf("MWindow::modify_handles 1\n");
667         return 0;
670 int MWindow::modify_pluginhandles()
672         undo->update_undo_before(_("drag handle"), LOAD_EDITS | LOAD_TIMEBAR);
674         edl->modify_pluginhandles(session->drag_start, 
675                 session->drag_position, 
676                 session->drag_handle, 
677                 edl->session->edit_handle_mode[session->drag_button],
678                 edl->session->labels_follow_edits);
680         finish_modify_handles();
682         return 0;
686 // Common to edithandles and plugin handles
687 void MWindow::finish_modify_handles()
689         int edit_mode = edl->session->edit_handle_mode[session->drag_button];
691 //printf("TrackCanvas::end_handle_selection 1\n");
692         if((session->drag_handle == 1 && edit_mode != MOVE_NO_EDITS) ||
693                 (session->drag_handle == 0 && edit_mode == MOVE_ONE_EDIT))
694         {
695                 edl->local_session->selectionstart = 
696                         edl->local_session->selectionend = 
697                         session->drag_position;
698         }
699         else
700         if(edit_mode != MOVE_NO_EDITS)
701         {
702                 edl->local_session->selectionstart = 
703                         edl->local_session->selectionend = 
704                         session->drag_start;
705         }
707 //printf("TrackCanvas::end_handle_selection 1\n");
708         if(edl->local_session->selectionstart < 0) 
709                 edl->local_session->selectionstart = 
710                         edl->local_session->selectionend = 0;
711 //printf("TrackCanvas::end_handle_selection 1\n");
713         save_backup();
714         undo->update_undo_after();
715         restart_brender();
716         sync_parameters(CHANGE_EDL);
717 //printf("TrackCanvas::end_handle_selection 1\n");
718         update_plugin_guis();
719         gui->update(1, 2, 1, 1, 1, 1, 0);
720         cwindow->update(1, 0, 0, 0, 1);
721 //printf("TrackCanvas::end_handle_selection 2\n");
726 void MWindow::match_output_size(Track *track)
728     undo->update_undo_before(_("match output size"), LOAD_ALL);
729         track->track_w = edl->session->output_w;
730         track->track_h = edl->session->output_h;
731         save_backup();
732         undo->update_undo_after();
734         restart_brender();
735         sync_parameters(CHANGE_EDL);
739 void MWindow::move_edits(ArrayList<Edit*> *edits, 
740                 Track *track,
741                 double position)
743         undo->update_undo_before(_("move edit"), LOAD_ALL);
745         edl->tracks->move_edits(edits, 
746                 track, 
747                 position,
748                 edl->session->labels_follow_edits, 
749                 edl->session->plugins_follow_edits);
751         save_backup();
752         undo->update_undo_after();
754         restart_brender();
755         cwindow->playback_engine->que->send_command(CURRENT_FRAME, 
756                 CHANGE_EDL,
757                 edl,
758                 1);
760         update_plugin_guis();
761         gui->update(1,
762                 1,      // 1 for incremental drawing.  2 for full refresh
763                 1,
764                 0,
765                 0, 
766                 0,
767                 0);
770 void MWindow::move_effect(Plugin *plugin,
771         PluginSet *dest_plugin_set,
772         Track *dest_track,
773         int64_t dest_position)
775         undo->update_undo_before(_("move effect"), LOAD_ALL);
777         edl->tracks->move_effect(plugin, 
778                 dest_plugin_set, 
779                 dest_track, 
780                 dest_position);
782         save_backup();
783         undo->update_undo_after();
785         restart_brender();
786         cwindow->playback_engine->que->send_command(CURRENT_FRAME, 
787                 CHANGE_EDL,
788                 edl,
789                 1);
791         update_plugin_guis();
792         gui->update(1,
793                 1,      // 1 for incremental drawing.  2 for full refresh
794                 0,
795                 0,
796                 0, 
797                 0,
798                 0);
801 void MWindow::move_plugins_up(PluginSet *plugin_set)
803         undo->update_undo_before(_("move effect up"), LOAD_ALL);
805         plugin_set->track->move_plugins_up(plugin_set);
807         save_backup();
808         undo->update_undo_after();
809         restart_brender();
810         gui->update(1,
811                 1,      // 1 for incremental drawing.  2 for full refresh
812                 0,
813                 0,
814                 0, 
815                 0,
816                 0);
817         sync_parameters(CHANGE_EDL);
820 void MWindow::move_plugins_down(PluginSet *plugin_set)
822         undo->update_undo_before(_("move effect down"), LOAD_ALL);
824         plugin_set->track->move_plugins_down(plugin_set);
826         save_backup();
827         undo->update_undo_after();
828         restart_brender();
829         gui->update(1,
830                 1,      // 1 for incremental drawing.  2 for full refresh
831                 0,
832                 0,
833                 0, 
834                 0,
835                 0);
836         sync_parameters(CHANGE_EDL);
839 void MWindow::move_track_down(Track *track)
841         undo->update_undo_before(_("move track down"), LOAD_ALL);
842         edl->tracks->move_track_down(track);
843         save_backup();
844         undo->update_undo_after();
846         restart_brender();
847         gui->update(1, 1, 0, 0, 1, 0, 0);
848         sync_parameters(CHANGE_EDL);
849         save_backup();
852 void MWindow::move_tracks_down()
854         undo->update_undo_before(_("move tracks down"), LOAD_ALL);
855         edl->tracks->move_tracks_down();
856         save_backup();
857         undo->update_undo_after();
859         restart_brender();
860         gui->update(1, 1, 0, 0, 1, 0, 0);
861         sync_parameters(CHANGE_EDL);
862         save_backup();
865 void MWindow::move_track_up(Track *track)
867         undo->update_undo_before(_("move track up"), LOAD_ALL);
868         edl->tracks->move_track_up(track);
869         save_backup();
870         undo->update_undo_after();
871         restart_brender();
872         gui->update(1, 1, 0, 0, 1, 0, 0);
873         sync_parameters(CHANGE_EDL);
874         save_backup();
877 void MWindow::move_tracks_up()
879         undo->update_undo_before(_("move tracks up"), LOAD_ALL);
880         edl->tracks->move_tracks_up();
881         save_backup();
882         undo->update_undo_after();
883         restart_brender();
884         gui->update(1, 1, 0, 0, 1, 0, 0);
885         sync_parameters(CHANGE_EDL);
889 void MWindow::mute_selection()
891         double start = edl->local_session->get_selectionstart();
892         double end = edl->local_session->get_selectionend();
893         if(start != end)
894         {
895                 undo->update_undo_before(_("mute"), LOAD_EDITS);
898                 edl->clear(start, 
899                         end, 
900                         0, 
901                         edl->session->plugins_follow_edits);
902                 edl->local_session->selectionend = end;
903                 edl->local_session->selectionstart = start;
904                 edl->paste_silence(start, end, 0, edl->session->plugins_follow_edits);
905                 save_backup();
906                 undo->update_undo_after();
908                 restart_brender();
909                 update_plugin_guis();
910                 gui->update(1, 2, 1, 1, 1, 1, 0);
911                 cwindow->playback_engine->que->send_command(CURRENT_FRAME, 
912                                                                 CHANGE_EDL,
913                                                                 edl,
914                                                                 1);
915         }
920 void MWindow::overwrite(EDL *source)
922         FileXML file;
923         source->copy(source->local_session->in_point, 
924                 source->local_session->out_point, 
925                 1,
926                 0,
927                 0,
928                 &file,
929                 plugindb,
930                 "",
931                 1);
932         undo->update_undo_before(_("overwrite"), LOAD_EDITS);
934         double start = edl->local_session->get_selectionstart();
935         double end = edl->local_session->get_selectionend();
936 // Calculate overwrite length from length of source
937         if(EQUIV(end, start))
938         {
939                 end = start + 
940                         source->local_session->out_point - 
941                         source->local_session->in_point;
942         }
945         paste(start, 
946                 end, 
947                 &file,
948                 0,
949                 0);
950         edl->local_session->selectionstart = 
951                 edl->local_session->selectionend =
952                 start + 
953                 source->local_session->out_point - 
954                 source->local_session->in_point;
955         save_backup();
956         undo->update_undo_after();
958         restart_brender();
959         update_plugin_guis();
960         gui->update(1, 1, 1, 1, 0, 1, 0);
961         sync_parameters(CHANGE_EDL);
964 // For splice and overwrite
965 int MWindow::paste(double start, 
966         double end, 
967         FileXML *file,
968         int edit_labels,
969         int edit_plugins)
971 //printf("MWindow::paste 1\n");
972         clear(0);
974 // Want to insert with assets shared with the master EDL.
975         insert(start, 
976                         file,
977                         edit_labels,
978                         edit_plugins,
979                         edl);
981 //printf("MWindow::paste 2\n");
982         return 0;
985 // For editing use insertion point position
986 void MWindow::paste()
988         double start = edl->local_session->get_selectionstart();
989         double end = edl->local_session->get_selectionend();
990         int64_t len = gui->get_clipboard()->clipboard_len(SECONDARY_SELECTION);
991         char *string = new char[len + 1];
993         gui->get_clipboard()->from_clipboard(string, 
994                 len, 
995                 SECONDARY_SELECTION);
996         FileXML file;
997         file.read_from_string(string);
1000         undo->update_undo_before(_("paste"), LOAD_EDITS | LOAD_TIMEBAR);
1002         clear(0);
1003         insert(start, 
1004                 &file, 
1005                 edl->session->labels_follow_edits, 
1006                 edl->session->plugins_follow_edits);
1007         edl->optimize();
1009         delete [] string;
1012         save_backup();
1015         undo->update_undo_after();
1016         restart_brender();
1017         update_plugin_guis();
1018         gui->update(1, 2, 1, 1, 0, 1, 0);
1019         awindow->gui->update_assets();
1020         sync_parameters(CHANGE_EDL);
1023 int MWindow::paste_assets(double position, Track *dest_track)
1025         int result = 0;
1027         undo->update_undo_before(_("paste assets"), LOAD_EDITS);
1031         if(session->drag_assets->total)
1032         {
1033                 load_assets(session->drag_assets, 
1034                         position, 
1035                         LOAD_PASTE,
1036                         dest_track, 
1037                         0,
1038                         edl->session->labels_follow_edits, 
1039                         edl->session->plugins_follow_edits);
1040                 result = 1;
1041         }
1044         if(session->drag_clips->total)
1045         {
1046                 paste_edls(session->drag_clips, 
1047                         LOAD_PASTE, 
1048                         dest_track,
1049                         position, 
1050                         edl->session->labels_follow_edits, 
1051                         edl->session->plugins_follow_edits);
1052                 result = 1;
1053         }
1056         save_backup();
1058         undo->update_undo_after();
1059         restart_brender();
1060         gui->update(1, 
1061                 2,
1062                 1,
1063                 0,
1064                 0,
1065                 1,
1066                 0);
1067         sync_parameters(CHANGE_EDL);
1068         return result;
1071 void MWindow::load_assets(ArrayList<Asset*> *new_assets, 
1072         double position, 
1073         int load_mode,
1074         Track *first_track,
1075         RecordLabels *labels,
1076         int edit_labels,
1077         int edit_plugins)
1079 //printf("MWindow::load_assets 1\n");
1080         if(position < 0) position = edl->local_session->get_selectionstart();
1082         ArrayList<EDL*> new_edls;
1083         for(int i = 0; i < new_assets->total; i++)
1084         {
1085                 EDL *new_edl = new EDL;
1086                 new_edl->create_objects();
1087                 new_edl->copy_session(edl);
1088                 new_edls.append(new_edl);
1091 //printf("MWindow::load_assets 2 %d %d\n", new_assets->values[i]->audio_length, new_assets->values[i]->video_length);
1092                 asset_to_edl(new_edl, new_assets->values[i]);
1095                 if(labels)
1096                         for(RecordLabel *label = labels->first; label; label = label->next)
1097                         {
1098                                 new_edl->labels->toggle_label(label->position, label->position);
1099                         }
1100         }
1101 //printf("MWindow::load_assets 3\n");
1103         paste_edls(&new_edls, 
1104                 load_mode, 
1105                 first_track,
1106                 position,
1107                 edit_labels,
1108                 edit_plugins);
1109 //printf("MWindow::load_assets 4\n");
1112         save_backup();
1113         new_edls.remove_all_objects();
1117 int MWindow::paste_automation()
1119         int64_t len = gui->get_clipboard()->clipboard_len(SECONDARY_SELECTION);
1121         char *string = new char[len + 1];
1122         gui->get_clipboard()->from_clipboard(string, 
1123                 len, 
1124                 SECONDARY_SELECTION);
1125         FileXML file;
1126         file.read_from_string(string);
1128         undo->update_undo_before(_("paste keyframes"), LOAD_AUTOMATION); 
1129         edl->tracks->clear_automation(edl->local_session->get_selectionstart(), 
1130                 edl->local_session->get_selectionend()); 
1131         edl->tracks->paste_automation(edl->local_session->get_selectionstart(), 
1132                 &file,
1133                 0); 
1134         save_backup();
1135         undo->update_undo_after(); 
1136         delete [] string;
1139         restart_brender();
1140         update_plugin_guis();
1141         gui->canvas->draw_overlays();
1142         gui->canvas->flash();
1143         sync_parameters(CHANGE_PARAMS);
1144         gui->patchbay->update();
1145         cwindow->update(1, 0, 0);
1147         return 0;
1150 int MWindow::paste_default_keyframe()
1152         int64_t len = gui->get_clipboard()->clipboard_len(SECONDARY_SELECTION);
1153         char *string = new char[len + 1];
1154         gui->get_clipboard()->from_clipboard(string, 
1155                 len, 
1156                 SECONDARY_SELECTION);
1157         FileXML file;
1158         file.read_from_string(string);
1159         undo->update_undo_before(_("paste default keyframe"), LOAD_AUTOMATION); 
1160         edl->tracks->paste_default_keyframe(&file); 
1161         undo->update_undo_after(); 
1164         restart_brender();
1165         update_plugin_guis();
1166         gui->canvas->draw_overlays();
1167         gui->canvas->flash();
1168         sync_parameters(CHANGE_PARAMS);
1169         gui->patchbay->update();
1170         cwindow->update(1, 0, 0);
1171         delete [] string;
1172         save_backup();
1174         return 0;
1178 // Insert edls with project deletion and index file generation.
1179 int MWindow::paste_edls(ArrayList<EDL*> *new_edls, 
1180         int load_mode, 
1181         Track *first_track,
1182         double current_position,
1183         int edit_labels,
1184         int edit_plugins)
1186         ArrayList<Track*> destination_tracks;
1187         int need_new_tracks = 0;
1189         if(!new_edls->total) return 0;
1190 //printf("MWindow::paste_edls 1\n");
1192 // Delete current project
1193         if(load_mode == LOAD_REPLACE ||
1194                 load_mode == LOAD_REPLACE_CONCATENATE)
1195         {
1196                 edl->save_defaults(defaults);
1197                 hide_plugins();
1198 // this has to be cleaned because patches[x]->track points nowhere 
1199 // after next call
1200                 patches->delete_all_patches();    
1201                 delete edl;
1202                 edl = new EDL;
1203                 edl->create_objects();
1204                 edl->copy_session(new_edls->values[0]);
1205                 gui->mainmenu->update_toggles();
1207 // Insert labels for certain modes constitutively
1208                 edit_labels = 1;
1209                 edit_plugins = 1;
1210         }
1211 //printf("MWindow::paste_edls 2\n");
1213 // Assume any paste operation from the same EDL won't contain any clips.
1214 // If it did it would duplicate every clip here.
1215         for(int i = 0; i < new_edls->total; i++)
1216         {
1217                 EDL *new_edl = new_edls->values[i];
1219                 for(int j = 0; j < new_edl->clips.total; j++)
1220                 {
1221                         edl->add_clip(new_edl->clips.values[j]);
1222                 }
1224                 if(new_edl->vwindow_edl)
1225                 {
1226                         if(edl->vwindow_edl) delete edl->vwindow_edl;
1227                         edl->vwindow_edl = new EDL(edl);
1228                         edl->vwindow_edl->create_objects();
1229                         edl->vwindow_edl->copy_all(new_edl->vwindow_edl);
1230                 }
1231         }
1232 //printf("MWindow::paste_edls 2\n");
1234 // Create new tracks in master EDL
1235         if(load_mode == LOAD_REPLACE || 
1236                 load_mode == LOAD_REPLACE_CONCATENATE ||
1237                 load_mode == LOAD_NEW_TRACKS)
1238         {
1239                 need_new_tracks = 1;
1240                 for(int i = 0; i < new_edls->total; i++)
1241                 {
1242                         EDL *new_edl = new_edls->values[i];
1243                         for(Track *current = new_edl->tracks->first;
1244                                 current;
1245                                 current = NEXT)
1246                         {
1247                                 if(current->data_type == TRACK_VIDEO)
1248                                 {
1249                                         edl->tracks->add_video_track(0, 0);
1250                                         if(current->draw) edl->tracks->last->draw = 1;
1251                                         destination_tracks.append(edl->tracks->last);
1252                                 }
1253                                 else
1254                                 if(current->data_type == TRACK_AUDIO)
1255                                 {
1256                                         edl->tracks->add_audio_track(0, 0);
1257                                         destination_tracks.append(edl->tracks->last);
1258                                 }
1259                                 edl->session->highlighted_track = edl->tracks->total() - 1;
1260                         }
1262 // Base track count on first EDL only for concatenation
1263                         if(load_mode == LOAD_REPLACE_CONCATENATE) break;
1264                 }
1265         }
1266         else
1267 // Recycle existing tracks of master EDL
1268         if(load_mode == LOAD_CONCATENATE || load_mode == LOAD_PASTE)
1269         {
1270 // The point of this is to shift forward labels after the selection so they can
1271 // then be shifted back to their original locations without recursively
1272 // shifting back every paste.
1273                 if(load_mode == LOAD_PASTE && edl->session->labels_follow_edits)
1274                         edl->labels->clear(edl->local_session->get_selectionstart(),
1275                                                 edl->local_session->get_selectionend(),
1276                                                 1);
1277         
1278                 Track *current = first_track ? first_track : edl->tracks->first;
1279                 for( ; current; current = NEXT)
1280                 {
1281                         if(current->record)
1282                         {
1283                                 destination_tracks.append(current);
1285 // This should be done in the caller so we don't get recursive clear disease.
1286 //                              if(load_mode == LOAD_PASTE)
1287 //                                      current->clear(edl->local_session->get_selectionstart(),
1288 //                                              edl->local_session->get_selectionend(),
1289 //                                              1,
1290 //                                              edl->session->labels_follow_edits, 
1291 //                                              edl->session->plugins_follow_edits,
1292 //                                              1);
1293                         }
1294                 }
1295         }
1298 //printf("MWindow::paste_edls 2\n");
1300         int destination_track = 0;
1301         double *paste_position = new double[destination_tracks.total];
1307 // Iterate through the edls
1308         for(int i = 0; i < new_edls->total; i++)
1309         {
1310                 EDL *new_edl = new_edls->values[i];
1311                 double edl_length = new_edl->local_session->clipboard_length ?
1312                         new_edl->local_session->clipboard_length :
1313                         new_edl->tracks->total_length();
1314 // printf("MWindow::paste_edls 2\n");
1315 // new_edl->dump();
1319 // Resample EDL to master rates
1320                 new_edl->resample(new_edl->session->sample_rate, 
1321                         edl->session->sample_rate, 
1322                         TRACK_AUDIO);
1323                 new_edl->resample(new_edl->session->frame_rate, 
1324                         edl->session->frame_rate, 
1325                         TRACK_VIDEO);
1329 //printf("MWindow::paste_edls 2 %d\n", new_edl->assets->total());
1330 // Add assets and prepare index files
1331                 edl->update_assets(new_edl);
1332                 for(Asset *new_asset = edl->assets->first;
1333                         new_asset;
1334                         new_asset = new_asset->next)
1335                 {
1336                         mainindexes->add_next_asset(new_asset);
1337                 }
1340 // Get starting point of insertion.  Need this to paste labels.
1341                 switch(load_mode)
1342                 {
1343                         case LOAD_REPLACE:
1344                         case LOAD_NEW_TRACKS:
1345                                 current_position = 0;
1346                                 break;
1348                         case LOAD_CONCATENATE:
1349                         case LOAD_REPLACE_CONCATENATE:
1350                                 destination_track = 0;
1351                                 if(destination_tracks.total)
1352                                         current_position = destination_tracks.values[0]->get_length();
1353                                 else
1354                                         current_position = 0;
1355                                 break;
1357                         case LOAD_PASTE:
1358                                 destination_track = 0;
1359                                 if(i == 0)
1360                                 {
1361                                         for(int j = 0; j < destination_tracks.total; j++)
1362                                         {
1363                                                 paste_position[j] = (current_position >= 0) ? 
1364                                                         current_position :
1365                                                         edl->local_session->get_selectionstart();
1366                                         }
1367                                 }
1368                                 break;
1370                         case LOAD_RESOURCESONLY:
1371                                 edl->add_clip(new_edl);
1372                                 break;
1373                 }
1378 // Insert edl
1379                 if(load_mode != LOAD_RESOURCESONLY)
1380                 {
1381 // Insert labels
1382 //printf("MWindow::paste_edls %f %f\n", current_position, edl_length);
1383                         if(load_mode == LOAD_PASTE)
1384                                 edl->labels->insert_labels(new_edl->labels, 
1385                                         destination_tracks.total ? paste_position[0] : 0.0,
1386                                         edl_length,
1387                                         edit_labels);
1388                         else
1389                                 edl->labels->insert_labels(new_edl->labels, 
1390                                         current_position,
1391                                         edl_length,
1392                                         edit_labels);
1394                         for(Track *new_track = new_edl->tracks->first; 
1395                                 new_track; 
1396                                 new_track = new_track->next)
1397                         {
1398 // Get destination track of same type as new_track
1399                                 for(int k = 0; 
1400                                         k < destination_tracks.total &&
1401                                         destination_tracks.values[destination_track]->data_type != new_track->data_type;
1402                                         k++, destination_track++)
1403                                 {
1404                                         if(destination_track >= destination_tracks.total - 1)
1405                                                 destination_track = 0;
1406                                 }
1408 // Insert data into destination track
1409                                 if(destination_track < destination_tracks.total &&
1410                                         destination_tracks.values[destination_track]->data_type == new_track->data_type)
1411                                 {
1412                                         Track *track = destination_tracks.values[destination_track];
1413 // Replace default keyframes if first EDL and new tracks were created
1414                                         int replace_default = (i == 0) && need_new_tracks;
1416 // Insert new track at current position
1417                                         switch(load_mode)
1418                                         {
1419                                                 case LOAD_REPLACE_CONCATENATE:
1420                                                 case LOAD_CONCATENATE:
1421                                                         current_position = track->get_length();
1422                                                         break;
1424                                                 case LOAD_PASTE:
1425                                                         current_position = paste_position[destination_track];
1426                                                         paste_position[destination_track] += new_track->get_length();
1427                                                         break;
1428                                         }
1430                                         track->insert_track(new_track, 
1431                                                 current_position, 
1432                                                 replace_default,
1433                                                 edit_plugins);
1434                                 }
1436 // Get next destination track
1437                                 destination_track++;
1438                                 if(destination_track >= destination_tracks.total)
1439                                         destination_track = 0;
1440                         }
1441                 }
1443                 if(load_mode == LOAD_PASTE)
1444                         current_position += edl_length;
1445         }
1446 //printf("MWindow::paste_edls 3\n");
1448         if(paste_position) delete [] paste_position;
1450 // This is already done in load_filenames and everything else that uses paste_edls
1451 //      update_project(load_mode);
1453 //printf("MWindow::paste_edls 5\n");
1455 // Start examining next batch of index files
1456         mainindexes->start_build();
1457 //printf("MWindow::paste_edls 6\n");
1459 // Don't save a backup after loading since the loaded file is on disk already.
1461         return 0;
1464 void MWindow::paste_silence()
1466         double start = edl->local_session->get_selectionstart();
1467         double end = edl->local_session->get_selectionend();
1468     undo->update_undo_before(_("silence"), LOAD_EDITS | LOAD_TIMEBAR);
1469         edl->paste_silence(start, 
1470                 end, 
1471                 edl->session->labels_follow_edits, 
1472                 edl->session->plugins_follow_edits);
1473         edl->optimize();
1474         save_backup();
1475         undo->update_undo_after();
1477         update_plugin_guis();
1478         restart_brender();
1479         gui->update(1, 2, 1, 1, 1, 1, 0);
1480         cwindow->update(1, 0, 0, 0, 1);
1481         cwindow->playback_engine->que->send_command(CURRENT_FRAME, 
1482                                                         CHANGE_EDL,
1483                                                         edl,
1484                                                         1);
1487 void MWindow::paste_transition()
1489     undo->update_undo_before(_("transition"), LOAD_EDITS);
1490 // Only the first transition gets dropped.
1491         PluginServer *server = session->drag_pluginservers->values[0];
1492         if(server->audio)
1493                 strcpy(edl->session->default_atransition, server->title);
1494         else
1495                 strcpy(edl->session->default_vtransition, server->title);
1497         edl->tracks->paste_transition(server, session->edit_highlighted);
1498         save_backup();
1499         undo->update_undo_after();
1501         if(server->video) restart_brender();
1502         sync_parameters(CHANGE_ALL);
1505 void MWindow::paste_transition_cwindow(Track *dest_track)
1507         undo->update_undo_before(_("transition"), LOAD_EDITS);
1508         PluginServer *server = session->drag_pluginservers->values[0];
1509         edl->tracks->paste_video_transition(server, 1);
1510         save_backup();
1511         restart_brender();
1512         gui->update(0, 1, 0, 0, 0, 0, 0);
1513         sync_parameters(CHANGE_ALL);
1516 void MWindow::paste_audio_transition()
1518         PluginServer *server = scan_plugindb(edl->session->default_atransition);
1519         if(!server)
1520         {
1521                 char string[BCTEXTLEN];
1522                 sprintf(string, _("No default transition %s found."), edl->session->default_atransition);
1523                 gui->show_message(string);
1524                 return;
1525         }
1527     undo->update_undo_before(_("paste transition"), LOAD_EDITS);
1528         edl->tracks->paste_audio_transition(server);
1529         save_backup();
1530         undo->update_undo_after();
1532         sync_parameters(CHANGE_ALL);
1533         gui->update(0, 1, 0, 0, 0, 0, 0);
1536 void MWindow::paste_video_transition()
1538         PluginServer *server = scan_plugindb(edl->session->default_vtransition);
1539         if(!server)
1540         {
1541                 char string[BCTEXTLEN];
1542                 sprintf(string, _("No default transition %s found."), edl->session->default_vtransition);
1543                 gui->show_message(string);
1544                 return;
1545         }
1548     undo->update_undo_before(_("paste transition"), LOAD_EDITS);
1549         edl->tracks->paste_video_transition(server);
1550         save_backup();
1551         undo->update_undo_after();
1553         sync_parameters(CHANGE_ALL);
1554         restart_brender();
1555         gui->update(0, 1, 0, 0, 0, 0, 0);
1558 void MWindow::redo_entry(int is_mwindow)
1560         if(is_mwindow)
1561                 gui->unlock_window();
1562         else
1563                 cwindow->gui->unlock_window();
1566         cwindow->playback_engine->que->send_command(STOP,
1567                 CHANGE_NONE, 
1568                 0,
1569                 0);
1570         vwindow->playback_engine->que->send_command(STOP,
1571                 CHANGE_NONE, 
1572                 0,
1573                 0);
1574         cwindow->playback_engine->interrupt_playback(0);
1575         vwindow->playback_engine->interrupt_playback(0);
1578         cwindow->gui->lock_window();
1579         gui->lock_window();
1581         undo->redo(); 
1583         save_backup();
1584         update_plugin_states();
1585         update_plugin_guis();
1586         restart_brender();
1587         gui->update(1, 2, 1, 1, 1, 1, 0);
1588         cwindow->update(1, 1, 1, 1, 1);
1590         if(is_mwindow)
1591                 cwindow->gui->unlock_window();
1592         else
1593                 gui->unlock_window();
1595         cwindow->playback_engine->que->send_command(CURRENT_FRAME, 
1596                            CHANGE_ALL,
1597                            edl,
1598                            1);
1599         
1603 void MWindow::resize_track(Track *track, int w, int h)
1605         undo->update_undo_before(_("resize track"), LOAD_ALL);
1606         track->track_w = w;
1607         track->track_h = h;
1608         undo->update_undo_after();
1609         save_backup();
1611         restart_brender();
1612         sync_parameters(CHANGE_EDL);
1616 void MWindow::set_inpoint(int is_mwindow)
1618         undo->update_undo_before(_("in point"), LOAD_TIMEBAR);
1619         edl->set_inpoint(edl->local_session->selectionstart);
1620         save_backup();
1621         undo->update_undo_after();
1624         if(!is_mwindow)
1625         {
1626                 gui->lock_window();
1627         }
1628         gui->timebar->update();
1629         gui->flush();
1630         if(!is_mwindow)
1631         {
1632                 gui->unlock_window();
1633         }
1635         if(is_mwindow)
1636         {
1637                 cwindow->gui->lock_window();
1638         }
1639         cwindow->gui->timebar->update();
1640         cwindow->gui->flush();
1641         if(is_mwindow)
1642         {
1643                 cwindow->gui->unlock_window();
1644         }
1647 void MWindow::set_outpoint(int is_mwindow)
1649         undo->update_undo_before(_("out point"), LOAD_TIMEBAR);
1650         edl->set_outpoint(edl->local_session->selectionend);
1651         save_backup();
1652         undo->update_undo_after();
1655         if(!is_mwindow)
1656         {
1657                 gui->lock_window();
1658         }
1659         gui->timebar->update();
1660         gui->flush();
1661         if(!is_mwindow)
1662         {
1663                 gui->unlock_window();
1664         }
1666         if(is_mwindow)
1667         {
1668                 cwindow->gui->lock_window();
1669         }
1670         cwindow->gui->timebar->update();
1671         cwindow->gui->flush();
1672         if(is_mwindow)
1673         {
1674                 cwindow->gui->unlock_window();
1675         }
1678 void MWindow::splice(EDL *source)
1680         FileXML file;
1682         source->copy(source->local_session->in_point, 
1683                 source->local_session->out_point, 
1684                 1,
1685                 0,
1686                 0,
1687                 &file,
1688                 plugindb,
1689                 "",
1690                 1);
1692         undo->update_undo_before(_("splice"), LOAD_EDITS | LOAD_TIMEBAR);
1695 //file.dump();
1696         double start = edl->local_session->get_selectionstart();
1697         double end = edl->local_session->get_selectionend();
1699         paste(start, 
1700                 start, 
1701                 &file,
1702                 edl->session->labels_follow_edits,
1703                 edl->session->plugins_follow_edits);
1705         edl->local_session->selectionstart = 
1706                 edl->local_session->selectionend =
1707                 start + 
1708                 source->local_session->out_point - 
1709                 source->local_session->in_point;
1711         save_backup();
1712         undo->update_undo_after();
1713         update_plugin_guis();
1714         restart_brender();
1715         gui->update(1, 1, 1, 1, 0, 1, 0);
1716         sync_parameters(CHANGE_EDL);
1719 void MWindow::to_clip()
1721         FileXML file;
1722         double start, end;
1723         
1724         start = edl->local_session->get_selectionstart();
1725         end = edl->local_session->get_selectionend();
1727         if(EQUIV(end, start)) 
1728         {
1729                 start = 0;
1730                 end = edl->tracks->total_length();
1731         }
1733 // Don't copy all since we don't want the clips twice.
1734         edl->copy(start, 
1735                 end, 
1736                 0,
1737                 0,
1738                 0,
1739                 &file,
1740                 plugindb,
1741                 "",
1742                 1);
1744 //printf("MWindow::to_clip 1 %s\n", edl->local_session->clip_title);
1746 //file.dump();
1749         EDL *new_edl = new EDL(edl);
1750         new_edl->create_objects();
1751         new_edl->load_xml(plugindb, &file, LOAD_ALL);
1752         sprintf(new_edl->local_session->clip_title, _("Clip %d\n"), session->clip_number++);
1754 //printf("VWindowEditing::to_clip 2 %d\n", edl->assets->total());
1755         awindow->clip_edit->create_clip(new_edl);
1756         save_backup();
1757 //printf("VWindowEditing::to_clip 3 %d\n", edl->assets->total());
1763 int MWindow::toggle_label(int is_mwindow)
1765         double position1, position2;
1767 //printf("MWindow::toggle_label 1\n");
1768         undo->update_undo_before(_("label"), LOAD_TIMEBAR);
1769 //printf("MWindow::toggle_label 1\n");
1771         if(cwindow->playback_engine->is_playing_back)
1772         {
1773                 position1 = position2 = 
1774                         cwindow->playback_engine->get_tracking_position();
1775         }
1776         else
1777         {
1778                 position1 = edl->local_session->selectionstart;
1779                 position2 = edl->local_session->selectionend;
1780         }
1782 //printf("MWindow::toggle_label 1 %f %f\n", position1,position2 );
1783         position1 = edl->align_to_frame(position1, 0);
1784         position2 = edl->align_to_frame(position2, 0);
1786 //printf("MWindow::toggle_label 1\n");
1787         edl->labels->toggle_label(position1, position2);
1788         save_backup();
1790 //printf("MWindow::toggle_label 1\n");
1791         if(!is_mwindow)
1792         {
1793                 gui->lock_window();
1794         }
1795         gui->timebar->update();
1796         gui->canvas->activate();
1797         gui->flush();
1798         if(!is_mwindow)
1799         {
1800                 gui->unlock_window();
1801         }
1803 //printf("MWindow::toggle_label 1\n");
1804         if(is_mwindow)
1805         {
1806                 cwindow->gui->lock_window();
1807         }
1808         cwindow->gui->timebar->update();
1809         cwindow->gui->flush();
1810         if(is_mwindow)
1811         {
1812                 cwindow->gui->unlock_window();
1813         }
1815 //printf("MWindow::toggle_label 1\n");
1816         undo->update_undo_after();
1817 //printf("MWindow::toggle_label 2\n");
1818         return 0;
1821 void MWindow::trim_selection()
1823         undo->update_undo_before(_("trim selection"), LOAD_EDITS);
1826         edl->trim_selection(edl->local_session->get_selectionstart(), 
1827                 edl->local_session->get_selectionend(), 
1828                 edl->session->labels_follow_edits, 
1829                 edl->session->plugins_follow_edits);
1831         save_backup();
1832         undo->update_undo_after();
1833         update_plugin_guis();
1834         gui->update(1, 2, 1, 1, 1, 1, 0);
1835         restart_brender();
1836         cwindow->playback_engine->que->send_command(CURRENT_FRAME, 
1837                                                         CHANGE_EDL,
1838                                                         edl,
1839                                                         1);
1844 void MWindow::undo_entry(int is_mwindow)
1846         if(is_mwindow)
1847                 gui->unlock_window();
1848         else
1849                 cwindow->gui->unlock_window();
1851         cwindow->playback_engine->que->send_command(STOP,
1852                 CHANGE_NONE, 
1853                 0,
1854                 0);
1855         vwindow->playback_engine->que->send_command(STOP,
1856                 CHANGE_NONE, 
1857                 0,
1858                 0);
1859         cwindow->playback_engine->interrupt_playback(0);
1860         vwindow->playback_engine->interrupt_playback(0);
1862         cwindow->gui->lock_window();
1863         gui->lock_window();
1865         undo->undo(); 
1867         save_backup();
1868         restart_brender();
1869         update_plugin_states();
1870         update_plugin_guis();
1871         gui->update(1, 2, 1, 1, 1, 1, 0);
1872         cwindow->update(1, 1, 1, 1, 1);
1874         if(is_mwindow)
1875                 cwindow->gui->unlock_window();
1876         else
1877                 gui->unlock_window();
1879         awindow->gui->lock_window();
1880         awindow->gui->update_assets();
1881         awindow->gui->flush();
1882         awindow->gui->unlock_window();
1883         cwindow->playback_engine->que->send_command(CURRENT_FRAME, 
1884                            CHANGE_ALL,
1885                            edl,
1886                            1);
1891 void MWindow::new_folder(char *new_folder)
1893         undo->update_undo_before(_("new folder"), LOAD_ALL);
1894         edl->new_folder(new_folder);
1895         undo->update_undo_after();
1896         awindow->gui->lock_window();
1897         awindow->gui->update_assets();
1898         awindow->gui->unlock_window();
1901 void MWindow::delete_folder(char *folder)
1903         undo->update_undo_before(_("new folder"), LOAD_ALL);
1904         undo->update_undo_after();
1907 void MWindow::select_point(double position)
1909         edl->local_session->selectionstart = 
1910                 edl->local_session->selectionend = position;
1911 // Que the CWindow
1912         cwindow->update(1, 0, 0, 0, 1);
1913         update_plugin_guis();
1914         gui->patchbay->update();
1915         gui->cursor->hide();
1916         gui->cursor->draw();
1917         gui->mainclock->update(edl->local_session->selectionstart);
1918         gui->zoombar->update();
1919         gui->canvas->flash();
1920         gui->flush();