add bluray dv, misc fixes
[goodguy/history.git] / cinelerra-5.1 / cinelerra / mainmenu.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #include "assets.h"
23 #include "auto.h"
24 #include "batchrender.h"
25 #include "bcdisplayinfo.h"
26 #include "bchash.h"
27 #include "bcsignals.h"
28 #include "bdcreate.h"
29 #include "cache.h"
30 #include "channelinfo.h"
31 #include "cplayback.h"
32 #include "cropvideo.h"
33 #include "cwindow.h"
34 #include "cwindowgui.h"
35 #include "dbwindow.h"
36 #include "dvdcreate.h"
37 #include "edl.h"
38 #include "edlsession.h"
39 #include "filesystem.h"
40 #include "filexml.h"
41 #include "floatauto.h"
42 #include "keys.h"
43 #include "language.h"
44 #include "levelwindow.h"
45 #include "loadfile.h"
46 #include "localsession.h"
47 #include "mainclock.h"
48 #include "mainmenu.h"
49 #include "mainsession.h"
50 #include "mainundo.h"
51 #include "menuattacheffect.h"
52 #include "menuattachtransition.h"
53 #include "menuaeffects.h"
54 #include "menueditlength.h"
55 #include "menutransitionlength.h"
56 #include "menuveffects.h"
57 #include "mwindowgui.h"
58 #include "mwindow.h"
59 #include "new.h"
60 #include "patchbay.h"
61 #include "playbackengine.h"
62 #include "preferences.h"
63 #include "preferencesthread.h"
64 #include "quit.h"
65 #include "record.h"
66 #include "render.h"
67 #include "savefile.h"
68 #include "setformat.h"
69 #include "swindow.h"
70 #include "timebar.h"
71 #include "trackcanvas.h"
72 #include "tracks.h"
73 #include "transition.h"
74 #include "transportque.h"
75 #include "viewmenu.h"
76 #include "zoombar.h"
77 #include "exportedl.h"
78
79 #include <string.h>
80
81
82 MainMenu::MainMenu(MWindow *mwindow, MWindowGUI *gui, int w)
83  : BC_MenuBar(0, 0, w)
84 {
85         this->gui = gui;
86         this->mwindow = mwindow;
87 }
88
89 MainMenu::~MainMenu()
90 {
91 }
92
93 void MainMenu::create_objects()
94 {
95         BC_Menu *viewmenu, *windowmenu, *settingsmenu, *trackmenu;
96         PreferencesMenuitem *preferences;
97         total_loads = 0;
98
99         add_menu(filemenu = new BC_Menu(_("File")));
100         filemenu->add_item(new_project = new New(mwindow));
101         new_project->create_objects();
102
103 // file loaders
104         filemenu->add_item(load_file = new Load(mwindow, this));
105         load_file->create_objects();
106
107 // new and load can be undone so no need to prompt save
108         Save *save;                   //  affected by saveas
109         filemenu->add_item(save = new Save(mwindow));
110         SaveAs *saveas;
111         filemenu->add_item(saveas = new SaveAs(mwindow));
112         save->create_objects(saveas);
113         saveas->set_mainmenu(this);
114         filemenu->add_item(record_menu_item = new RecordMenuItem(mwindow));
115 #ifdef HAVE_DVB
116         filemenu->add_item(new ChannelScan(mwindow));
117 #endif
118         if( mwindow->has_commercials() )
119                 filemenu->add_item(new DbWindowScan(mwindow));
120         filemenu->add_item(new SubttlSWin(mwindow));
121
122         filemenu->add_item(render = new RenderItem(mwindow));
123         filemenu->add_item(new ExportEDLItem(mwindow));
124         filemenu->add_item(new BatchRenderMenuItem(mwindow));
125         filemenu->add_item(new CreateBD_MenuItem(mwindow));
126         filemenu->add_item(new CreateDVD_MenuItem(mwindow));
127         filemenu->add_item(new BC_MenuItem("-"));
128         filemenu->add_item(quit_program = new Quit(mwindow));
129         quit_program->create_objects(save);
130         filemenu->add_item(new DumpEDL(mwindow));
131         filemenu->add_item(new DumpPlugins(mwindow));
132         filemenu->add_item(new LoadBackup(mwindow));
133         filemenu->add_item(new SaveBackup(mwindow));
134
135         BC_Menu *editmenu;
136         add_menu(editmenu = new BC_Menu(_("Edit")));
137         editmenu->add_item(undo = new Undo(mwindow));
138         editmenu->add_item(redo = new Redo(mwindow));
139         editmenu->add_item(new BC_MenuItem("-"));
140         editmenu->add_item(new Cut(mwindow));
141         editmenu->add_item(new Copy(mwindow));
142         editmenu->add_item(new Paste(mwindow));
143         editmenu->add_item(new Clear(mwindow));
144         editmenu->add_item(new PasteSilence(mwindow));
145         editmenu->add_item(new MuteSelection(mwindow));
146         editmenu->add_item(new TrimSelection(mwindow));
147         editmenu->add_item(new SelectAll(mwindow));
148         editmenu->add_item(new BC_MenuItem("-"));
149         editmenu->add_item(new MenuEditShuffle(mwindow));
150         editmenu->add_item(new MenuEditReverse(mwindow));
151         editmenu->add_item(new MenuEditLength(mwindow));
152         editmenu->add_item(new MenuEditAlign(mwindow));
153         editmenu->add_item(new MenuTransitionLength(mwindow));
154         editmenu->add_item(new DetachTransitions(mwindow));
155         editmenu->add_item(new BC_MenuItem("-"));
156         editmenu->add_item(new ClearLabels(mwindow));
157         editmenu->add_item(new CutCommercials(mwindow));
158         editmenu->add_item(new PasteSubttl(mwindow));
159
160         BC_Menu *keyframemenu;
161         add_menu(keyframemenu = new BC_Menu(_("Keyframes")));
162         keyframemenu->add_item(new CutKeyframes(mwindow));
163         keyframemenu->add_item(new CopyKeyframes(mwindow));
164         keyframemenu->add_item(new PasteKeyframes(mwindow));
165         keyframemenu->add_item(new ClearKeyframes(mwindow));
166         keyframemenu->add_item(new StraightenKeyframes(mwindow));
167         keyframemenu->add_item(new BendKeyframes(mwindow));
168         keyframemenu->add_item(keyframe_curve_type = new KeyframeCurveType(mwindow));
169         keyframe_curve_type->create_objects();
170         keyframe_curve_type->update(mwindow->edl->local_session->floatauto_type);
171         keyframemenu->add_item(new BC_MenuItem("-"));
172         keyframemenu->add_item(new CopyDefaultKeyframe(mwindow));
173         keyframemenu->add_item(new PasteDefaultKeyframe(mwindow));
174
175
176
177
178         add_menu(audiomenu = new BC_Menu(_("Audio")));
179         audiomenu->add_item(new AddAudioTrack(mwindow));
180         audiomenu->add_item(new DefaultATransition(mwindow));
181         audiomenu->add_item(new MapAudio1(mwindow));
182         audiomenu->add_item(new MapAudio2(mwindow));
183         audiomenu->add_item(new MenuAttachTransition(mwindow, TRACK_AUDIO));
184         audiomenu->add_item(new MenuAttachEffect(mwindow, TRACK_AUDIO));
185         audiomenu->add_item(aeffects = new MenuAEffects(mwindow));
186
187         add_menu(videomenu = new BC_Menu(_("Video")));
188         videomenu->add_item(new AddVideoTrack(mwindow));
189         videomenu->add_item(new DefaultVTransition(mwindow));
190         videomenu->add_item(new MenuAttachTransition(mwindow, TRACK_VIDEO));
191         videomenu->add_item(new MenuAttachEffect(mwindow, TRACK_VIDEO));
192         videomenu->add_item(veffects = new MenuVEffects(mwindow));
193
194         add_menu(trackmenu = new BC_Menu(_("Tracks")));
195         trackmenu->add_item(new MoveTracksUp(mwindow));
196         trackmenu->add_item(new MoveTracksDown(mwindow));
197         trackmenu->add_item(new DeleteTracks(mwindow));
198         trackmenu->add_item(new DeleteTrack(mwindow));
199         trackmenu->add_item(new ConcatenateTracks(mwindow));
200         trackmenu->add_item(new AddSubttlTrack(mwindow));
201
202         add_menu(settingsmenu = new BC_Menu(_("Settings")));
203
204         settingsmenu->add_item(new SetFormat(mwindow));
205         settingsmenu->add_item(preferences = new PreferencesMenuitem(mwindow));
206         mwindow->preferences_thread = preferences->thread;
207         settingsmenu->add_item(labels_follow_edits = new LabelsFollowEdits(mwindow));
208         settingsmenu->add_item(plugins_follow_edits = new PluginsFollowEdits(mwindow));
209         settingsmenu->add_item(keyframes_follow_edits = new KeyframesFollowEdits(mwindow));
210         settingsmenu->add_item(cursor_on_frames = new CursorOnFrames(mwindow));
211         settingsmenu->add_item(typeless_keyframes = new TypelessKeyframes(mwindow));
212         settingsmenu->add_item(new BC_MenuItem("-"));
213         settingsmenu->add_item(new SaveSettingsNow(mwindow));
214         settingsmenu->add_item(loop_playback = new LoopPlayback(mwindow));
215         settingsmenu->add_item(new SetBRenderRange(mwindow));
216 // set scrubbing speed
217 //      ScrubSpeed *scrub_speed;
218 //      settingsmenu->add_item(scrub_speed = new ScrubSpeed(mwindow));
219 //      if(mwindow->edl->session->scrub_speed == .5)
220 //              scrub_speed->set_text(_("Fast Shuttle"));
221
222
223
224
225
226
227         add_menu(viewmenu = new BC_Menu(_("View")));
228         viewmenu->add_item(show_assets = new ShowAssets(mwindow, "0"));
229         viewmenu->add_item(show_titles = new ShowTitles(mwindow, "1"));
230         viewmenu->add_item(show_transitions = new ShowTransitions(mwindow, "2"));
231         viewmenu->add_item(fade_automation = new ShowAutomation(mwindow, _("Fade"), "3", AUTOMATION_FADE));
232         viewmenu->add_item(mute_automation = new ShowAutomation(mwindow, _("Mute"), "4", AUTOMATION_MUTE));
233         viewmenu->add_item(mode_automation = new ShowAutomation(mwindow, _("Overlay mode"), "5", AUTOMATION_MODE));
234         viewmenu->add_item(pan_automation = new ShowAutomation(mwindow, _("Pan"), "6", AUTOMATION_PAN));
235         viewmenu->add_item(plugin_automation = new PluginAutomation(mwindow, "7"));
236         viewmenu->add_item(mask_automation = new ShowAutomation(mwindow, _("Mask"), "8", AUTOMATION_MASK));
237         viewmenu->add_item(speed_automation = new ShowAutomation(mwindow, _("Speed"), "9", AUTOMATION_SPEED));
238         viewmenu->add_item(camera_x = new ShowAutomation(mwindow, _("Camera X"), "", AUTOMATION_CAMERA_X));
239         viewmenu->add_item(camera_y = new ShowAutomation(mwindow, _("Camera Y"), "", AUTOMATION_CAMERA_Y));
240         viewmenu->add_item(camera_z = new ShowAutomation(mwindow, _("Camera Z"), "", AUTOMATION_CAMERA_Z));
241         viewmenu->add_item(project_x = new ShowAutomation(mwindow, _("Projector X"), "", AUTOMATION_PROJECTOR_X));
242         viewmenu->add_item(project_y = new ShowAutomation(mwindow, _("Projector Y"), "", AUTOMATION_PROJECTOR_Y));
243         viewmenu->add_item(project_z = new ShowAutomation(mwindow, _("Projector Z"), "", AUTOMATION_PROJECTOR_Z));
244
245
246         add_menu(windowmenu = new BC_Menu(_("Window")));
247         windowmenu->add_item(show_vwindow = new ShowVWindow(mwindow));
248         windowmenu->add_item(show_awindow = new ShowAWindow(mwindow));
249         windowmenu->add_item(show_cwindow = new ShowCWindow(mwindow));
250         windowmenu->add_item(show_gwindow = new ShowGWindow(mwindow));
251         windowmenu->add_item(show_lwindow = new ShowLWindow(mwindow));
252         windowmenu->add_item(new BC_MenuItem("-"));
253         windowmenu->add_item(split_x = new SplitX(mwindow));
254         windowmenu->add_item(split_y = new SplitY(mwindow));
255         windowmenu->add_item(new TileWindows(mwindow,_("Default positions"),-1,_("Ctrl-P"),'p'));
256         windowmenu->add_item(new TileWindows(mwindow,_("Tile left"),0));
257         windowmenu->add_item(new TileWindows(mwindow,_("Tile right"),1));
258 }
259
260 int MainMenu::load_defaults(BC_Hash *defaults)
261 {
262         init_loads(defaults);
263         init_aeffects(defaults);
264         init_veffects(defaults);
265         return 0;
266 }
267
268 void MainMenu::update_toggles(int use_lock)
269 {
270         if(use_lock) lock_window("MainMenu::update_toggles");
271         labels_follow_edits->set_checked(mwindow->edl->session->labels_follow_edits);
272         plugins_follow_edits->set_checked(mwindow->edl->session->plugins_follow_edits);
273         keyframes_follow_edits->set_checked(mwindow->edl->session->autos_follow_edits);
274         typeless_keyframes->set_checked(mwindow->edl->session->typeless_keyframes);
275         cursor_on_frames->set_checked(mwindow->edl->session->cursor_on_frames);
276         loop_playback->set_checked(mwindow->edl->local_session->loop_playback);
277
278         show_assets->set_checked(mwindow->edl->session->show_assets);
279         show_titles->set_checked(mwindow->edl->session->show_titles);
280         show_transitions->set_checked(mwindow->edl->session->auto_conf->transitions);
281         fade_automation->update_toggle();
282         mute_automation->update_toggle();
283         pan_automation->update_toggle();
284         camera_x->update_toggle();
285         camera_y->update_toggle();
286         camera_z->update_toggle();
287         project_x->update_toggle();
288         project_y->update_toggle();
289         project_z->update_toggle();
290         plugin_automation->set_checked(mwindow->edl->session->auto_conf->plugins);
291         mode_automation->update_toggle();
292         mask_automation->update_toggle();
293         speed_automation->update_toggle();
294         split_x->set_checked(mwindow->gui->pane[TOP_RIGHT_PANE] != 0);
295         split_y->set_checked(mwindow->gui->pane[BOTTOM_LEFT_PANE] != 0);
296
297         if(use_lock) mwindow->gui->unlock_window();
298 }
299
300 int MainMenu::save_defaults(BC_Hash *defaults)
301 {
302         save_loads(defaults);
303         save_aeffects(defaults);
304         save_veffects(defaults);
305         return 0;
306 }
307
308
309
310
311
312 int MainMenu::quit()
313 {
314         quit_program->handle_event();
315         return 0;
316 }
317
318
319
320
321
322 // ================================== load most recent
323
324 int MainMenu::init_aeffects(BC_Hash *defaults)
325 {
326         total_aeffects = defaults->get((char*)"TOTAL_AEFFECTS", 0);
327
328         char string[BCTEXTLEN], title[BCTEXTLEN];
329         if(total_aeffects) audiomenu->add_item(new BC_MenuItem("-"));
330
331         for(int i = 0; i < total_aeffects; i++)
332         {
333                 sprintf(string, "AEFFECTRECENT%d", i);
334                 defaults->get(string, title);
335                 audiomenu->add_item(aeffect[i] = new MenuAEffectItem(aeffects, title));
336         }
337         return 0;
338 }
339
340 int MainMenu::init_veffects(BC_Hash *defaults)
341 {
342         total_veffects = defaults->get((char*)"TOTAL_VEFFECTS", 0);
343
344         char string[BCTEXTLEN], title[BCTEXTLEN];
345         if(total_veffects) videomenu->add_item(new BC_MenuItem("-"));
346
347         for(int i = 0; i < total_veffects; i++)
348         {
349                 sprintf(string, "VEFFECTRECENT%d", i);
350                 defaults->get(string, title);
351                 videomenu->add_item(veffect[i] = new MenuVEffectItem(veffects, title));
352         }
353         return 0;
354 }
355
356 void MainMenu::init_loads(BC_Hash *defaults)
357 {
358         total_loads = defaults->get((char*)"TOTAL_LOADS", 0);
359         if( !total_loads ) return;
360         filemenu->add_item(new BC_MenuItem("-"));
361
362         char string[BCTEXTLEN], path[BCTEXTLEN], filename[BCTEXTLEN];
363         FileSystem dir;
364 //printf("MainMenu::init_loads 2\n");
365
366         for(int i = 0; i < total_loads; i++) {
367                 sprintf(string, "LOADPREVIOUS%d", i);
368 //printf("MainMenu::init_loads 3\n");
369                 defaults->get(string, path);
370                 filemenu->add_item(load[i] = new LoadPrevious(mwindow, load_file));
371                 dir.extract_name(filename, path, 0);
372                 load[i]->set_text(filename);
373                 load[i]->set_path(path);
374         }
375 }
376
377 // ============================ save most recent
378
379 int MainMenu::save_aeffects(BC_Hash *defaults)
380 {
381         defaults->update((char*)"TOTAL_AEFFECTS", total_aeffects);
382         char string[BCTEXTLEN];
383         for(int i = 0; i < total_aeffects; i++)
384         {
385                 sprintf(string, "AEFFECTRECENT%d", i);
386                 defaults->update(string, aeffect[i]->get_text());
387         }
388         return 0;
389 }
390
391 int MainMenu::save_veffects(BC_Hash *defaults)
392 {
393         defaults->update((char*)"TOTAL_VEFFECTS", total_veffects);
394         char string[BCTEXTLEN];
395         for(int i = 0; i < total_veffects; i++)
396         {
397                 sprintf(string, "VEFFECTRECENT%d", i);
398                 defaults->update(string, veffect[i]->get_text());
399         }
400         return 0;
401 }
402
403 int MainMenu::save_loads(BC_Hash *defaults)
404 {
405         defaults->update((char*)"TOTAL_LOADS", total_loads);
406         char string[BCTEXTLEN];
407         for(int i = 0; i < total_loads; i++)
408         {
409                 sprintf(string, "LOADPREVIOUS%d", i);
410                 defaults->update(string, load[i]->path);
411         }
412         return 0;
413 }
414
415 // =================================== add most recent
416
417 int MainMenu::add_aeffect(char *title)
418 {
419 // add bar for first effect
420         if(total_aeffects == 0)
421         {
422                 audiomenu->add_item(new BC_MenuItem("-"));
423         }
424
425 // test for existing copy of effect
426         for(int i = 0; i < total_aeffects; i++)
427         {
428                 if(!strcmp(aeffect[i]->get_text(), title))     // already exists
429                 {                                // swap for top effect
430                         for(int j = i; j > 0; j--)   // move preceeding effects down
431                         {
432                                 aeffect[j]->set_text(aeffect[j - 1]->get_text());
433                         }
434                         aeffect[0]->set_text(title);
435                         return 1;
436                 }
437         }
438
439 // add another blank effect
440         if(total_aeffects < TOTAL_EFFECTS)
441         {
442                 audiomenu->add_item(
443                         aeffect[total_aeffects] = new MenuAEffectItem(aeffects, (char*)""));
444                 total_aeffects++;
445         }
446
447 // cycle effect down
448         for(int i = total_aeffects - 1; i > 0; i--)
449         {
450         // set menu item text
451                 aeffect[i]->set_text(aeffect[i - 1]->get_text());
452         }
453
454 // set up the new effect
455         aeffect[0]->set_text(title);
456         return 0;
457 }
458
459 int MainMenu::add_veffect(char *title)
460 {
461 // add bar for first effect
462         if(total_veffects == 0)
463         {
464                 videomenu->add_item(new BC_MenuItem("-"));
465         }
466
467 // test for existing copy of effect
468         for(int i = 0; i < total_veffects; i++)
469         {
470                 if(!strcmp(veffect[i]->get_text(), title))     // already exists
471                 {                                // swap for top effect
472                         for(int j = i; j > 0; j--)   // move preceeding effects down
473                         {
474                                 veffect[j]->set_text(veffect[j - 1]->get_text());
475                         }
476                         veffect[0]->set_text(title);
477                         return 1;
478                 }
479         }
480
481 // add another blank effect
482         if(total_veffects < TOTAL_EFFECTS)
483         {
484                 videomenu->add_item(veffect[total_veffects] =
485                         new MenuVEffectItem(veffects, (char*)""));
486                 total_veffects++;
487         }
488
489 // cycle effect down
490         for(int i = total_veffects - 1; i > 0; i--)
491         {
492 // set menu item text
493                 veffect[i]->set_text(veffect[i - 1]->get_text());
494         }
495
496 // set up the new effect
497         veffect[0]->set_text(title);
498         return 0;
499 }
500
501 int MainMenu::add_load(char *path)
502 {
503         if(total_loads == 0)
504 {
505                 filemenu->add_item(new BC_MenuItem("-"));
506         }
507
508 // test for existing copy
509         FileSystem fs;
510         char text[BCTEXTLEN], new_path[BCTEXTLEN];      // get text and path
511         fs.extract_name(text, path);
512         strcpy(new_path, path);
513
514         for(int i = 0; i < total_loads; i++)
515         {
516                 if(!strcmp(load[i]->get_text(), text))     // already exists
517                 {                                // swap for top load
518                         for(int j = i; j > 0; j--)   // move preceeding loads down
519                         {
520                                 load[j]->set_text(load[j - 1]->get_text());
521                                 load[j]->set_path(load[j - 1]->path);
522         }
523                         load[0]->set_text(text);
524                         load[0]->set_path(new_path);
525
526                         return 1;
527                 }
528         }
529
530 // add another load
531         if(total_loads < TOTAL_LOADS)
532         {
533                 filemenu->add_item(load[total_loads] = new LoadPrevious(mwindow, load_file));
534                 total_loads++;
535         }
536
537 // cycle loads down
538         for(int i = total_loads - 1; i > 0; i--)
539         {
540         // set menu item text
541                 load[i]->set_text(load[i - 1]->get_text());
542         // set filename
543                 load[i]->set_path(load[i - 1]->path);
544         }
545
546 // set up the new load
547         load[0]->set_text(text);
548         load[0]->set_path(new_path);
549         return 0;
550 }
551
552
553
554
555
556
557
558
559 // ================================== menu items
560
561
562 DumpCICache::DumpCICache(MWindow *mwindow)
563  : BC_MenuItem(_("Dump CICache"))
564 { this->mwindow = mwindow; }
565
566 int DumpCICache::handle_event()
567 {
568 //      mwindow->cache->dump();
569         return 1;
570 }
571
572 DumpEDL::DumpEDL(MWindow *mwindow)
573  : BC_MenuItem(_("Dump EDL"))
574 {
575         this->mwindow = mwindow;
576 }
577
578 int DumpEDL::handle_event()
579 {
580 //printf("DumpEDL::handle_event 1\n");
581         mwindow->dump_edl();
582 //printf("DumpEDL::handle_event 2\n");
583         return 1;
584 }
585
586 DumpPlugins::DumpPlugins(MWindow *mwindow)
587  : BC_MenuItem(_("Dump Plugins"))
588 {
589         this->mwindow = mwindow;
590 }
591
592 int DumpPlugins::handle_event()
593 {
594 //printf("DumpEDL::handle_event 1\n");
595         mwindow->dump_plugins();
596 //printf("DumpEDL::handle_event 2\n");
597         return 1;
598 }
599
600
601 DumpAssets::DumpAssets(MWindow *mwindow)
602  : BC_MenuItem(_("Dump Assets"))
603 { this->mwindow = mwindow; }
604
605 int DumpAssets::handle_event()
606 {
607         mwindow->assets->dump();
608         return 1;
609 }
610
611 // ================================================= edit
612
613 Undo::Undo(MWindow *mwindow) : BC_MenuItem(_("Undo"), "z", 'z')
614 {
615         this->mwindow = mwindow;
616 }
617 int Undo::handle_event()
618 {
619         mwindow->undo_entry(mwindow->gui);
620         return 1;
621 }
622 int Undo::update_caption(const char *new_caption)
623 {
624         char string[BCTEXTLEN];
625         sprintf(string, _("Undo %s"), new_caption);
626         set_text(string);
627         return 0;
628 }
629
630
631 Redo::Redo(MWindow *mwindow) : BC_MenuItem(_("Redo"), _("Shift-Z"), 'Z')
632 {
633         set_shift(1);
634         this->mwindow = mwindow;
635 }
636
637 int Redo::handle_event()
638 {
639         mwindow->redo_entry(mwindow->gui);
640
641         return 1;
642 }
643 int Redo::update_caption(const char *new_caption)
644 {
645         char string[BCTEXTLEN];
646         sprintf(string, _("Redo %s"), new_caption);
647         set_text(string);
648         return 0;
649 }
650
651 CutKeyframes::CutKeyframes(MWindow *mwindow)
652  : BC_MenuItem(_("Cut keyframes"), _("Shift-X"), 'X')
653 {
654         set_shift();
655         this->mwindow = mwindow;
656 }
657
658 int CutKeyframes::handle_event()
659 {
660         mwindow->cut_automation();
661         return 1;
662 }
663
664 CopyKeyframes::CopyKeyframes(MWindow *mwindow)
665  : BC_MenuItem(_("Copy keyframes"), _("Shift-C"), 'C')
666 {
667         set_shift();
668         this->mwindow = mwindow;
669 }
670
671 int CopyKeyframes::handle_event()
672 {
673         mwindow->copy_automation();
674         return 1;
675 }
676
677 PasteKeyframes::PasteKeyframes(MWindow *mwindow)
678  : BC_MenuItem(_("Paste keyframes"), _("Shift-V"), 'V')
679 {
680         set_shift();
681         this->mwindow = mwindow;
682 }
683
684 int PasteKeyframes::handle_event()
685 {
686         mwindow->paste_automation();
687         return 1;
688 }
689
690 ClearKeyframes::ClearKeyframes(MWindow *mwindow)
691  : BC_MenuItem(_("Clear keyframes"), _("Shift-Del"), DELETE)
692 {
693         set_shift();
694         this->mwindow = mwindow;
695 }
696
697 int ClearKeyframes::handle_event()
698 {
699         mwindow->clear_automation();
700         return 1;
701 }
702
703
704
705 StraightenKeyframes::StraightenKeyframes(MWindow *mwindow)
706  : BC_MenuItem(_("Change to linear"))
707 {
708         this->mwindow = mwindow;
709 }
710
711 int StraightenKeyframes::handle_event()
712 {
713         mwindow->set_automation_mode(FloatAuto::LINEAR);
714         return 1;
715 }
716
717
718
719
720 BendKeyframes::BendKeyframes(MWindow *mwindow)
721  : BC_MenuItem(_("Change to smooth"))
722 {
723         this->mwindow = mwindow;
724 }
725
726 int BendKeyframes::handle_event()
727 {
728         mwindow->set_automation_mode(FloatAuto::SMOOTH);
729         return 1;
730 }
731
732
733
734 KeyframeCurveType::KeyframeCurveType(MWindow *mwindow)
735  : BC_MenuItem(_("Create curve type..."))
736 {
737         this->mwindow = mwindow;
738         this->curve_menu = 0;
739 }
740 KeyframeCurveType::~KeyframeCurveType()
741 {
742 }
743
744 void KeyframeCurveType::create_objects()
745 {
746         add_submenu(curve_menu = new KeyframeCurveTypeMenu(this));
747         for( int i=FloatAuto::SMOOTH; i<=FloatAuto::FREE; ++i ) {
748                 KeyframeCurveTypeItem *curve_type_item = new KeyframeCurveTypeItem(i, this);
749                 curve_menu->add_submenuitem(curve_type_item);
750         }
751 }
752
753 void KeyframeCurveType::update(int curve_type)
754 {
755         for( int i=0; i<curve_menu->total_items(); ++i ) {
756                 KeyframeCurveTypeItem *curve_type_item = (KeyframeCurveTypeItem *)curve_menu->get_item(i);
757                 curve_type_item->set_checked(curve_type_item->type == curve_type);
758         }
759 }
760
761 int KeyframeCurveType::handle_event()
762 {
763         return 1;
764 }
765
766 KeyframeCurveTypeMenu::KeyframeCurveTypeMenu(KeyframeCurveType *menu_item)
767  : BC_SubMenu()
768 {
769         this->menu_item = menu_item;
770 }
771 KeyframeCurveTypeMenu::~KeyframeCurveTypeMenu()
772 {
773 }
774
775 KeyframeCurveTypeItem::KeyframeCurveTypeItem(int type, KeyframeCurveType *main_item)
776  : BC_MenuItem(FloatAuto::curve_name(type))
777 {
778         this->type = type;
779         this->main_item = main_item;
780 }
781 KeyframeCurveTypeItem::~KeyframeCurveTypeItem()
782 {
783 }
784
785 int KeyframeCurveTypeItem::handle_event()
786 {
787         main_item->update(type);
788         main_item->mwindow->set_keyframe_type(type);
789         return 1;
790 }
791
792
793 CutDefaultKeyframe::CutDefaultKeyframe(MWindow *mwindow)
794  : BC_MenuItem(_("Cut default keyframe"), _("Alt-X"), 'X')
795 {
796         set_alt();
797         this->mwindow = mwindow;
798 }
799
800 int CutDefaultKeyframe::handle_event()
801 {
802         mwindow->cut_default_keyframe();
803         return 1;
804 }
805
806 CopyDefaultKeyframe::CopyDefaultKeyframe(MWindow *mwindow)
807  : BC_MenuItem(_("Copy default keyframe"), _("Alt-c"), 'c')
808 {
809         set_alt();
810         this->mwindow = mwindow;
811 }
812
813 int CopyDefaultKeyframe::handle_event()
814 {
815         mwindow->copy_default_keyframe();
816         return 1;
817 }
818
819 PasteDefaultKeyframe::PasteDefaultKeyframe(MWindow *mwindow)
820  : BC_MenuItem(_("Paste default keyframe"), _("Alt-v"), 'v')
821 {
822         set_alt();
823         this->mwindow = mwindow;
824 }
825
826 int PasteDefaultKeyframe::handle_event()
827 {
828         mwindow->paste_default_keyframe();
829         return 1;
830 }
831
832 ClearDefaultKeyframe::ClearDefaultKeyframe(MWindow *mwindow)
833  : BC_MenuItem(_("Clear default keyframe"), _("Alt-Del"), DELETE)
834 {
835         set_alt();
836         this->mwindow = mwindow;
837 }
838
839 int ClearDefaultKeyframe::handle_event()
840 {
841         mwindow->clear_default_keyframe();
842         return 1;
843 }
844
845 Cut::Cut(MWindow *mwindow)
846  : BC_MenuItem(_("Cut"), "x", 'x')
847 {
848         this->mwindow = mwindow;
849 }
850
851 int Cut::handle_event()
852 {
853         mwindow->cut();
854         return 1;
855 }
856
857 Copy::Copy(MWindow *mwindow)
858  : BC_MenuItem(_("Copy"), "c", 'c')
859 {
860         this->mwindow = mwindow;
861 }
862
863 int Copy::handle_event()
864 {
865         mwindow->copy();
866         return 1;
867 }
868
869 Paste::Paste(MWindow *mwindow)
870  : BC_MenuItem(_("Paste"), "v", 'v')
871 {
872         this->mwindow = mwindow;
873 }
874
875 int Paste::handle_event()
876 {
877         mwindow->paste();
878         return 1;
879 }
880
881 Clear::Clear(MWindow *mwindow)
882  : BC_MenuItem(_("Clear"), _("Del"), DELETE)
883 {
884         this->mwindow = mwindow;
885 }
886
887 int Clear::handle_event()
888 {
889         mwindow->cwindow->gui->lock_window("Clear::handle_event");
890         mwindow->clear_entry();
891         mwindow->cwindow->gui->unlock_window();
892         return 1;
893 }
894
895 PasteSilence::PasteSilence(MWindow *mwindow)
896  : BC_MenuItem(_("Paste silence"), _("Shift-Space"), ' ')
897 {
898         this->mwindow = mwindow;
899         set_shift();
900 }
901
902 int PasteSilence::handle_event()
903 {
904         mwindow->paste_silence();
905         return 1;
906 }
907
908 SelectAll::SelectAll(MWindow *mwindow)
909  : BC_MenuItem(_("Select All"), "a", 'a')
910 {
911         this->mwindow = mwindow;
912 }
913
914 int SelectAll::handle_event()
915 {
916         mwindow->select_all();
917         return 1;
918 }
919
920 ClearLabels::ClearLabels(MWindow *mwindow) : BC_MenuItem(_("Clear labels"))
921 {
922         this->mwindow = mwindow;
923 }
924
925 int ClearLabels::handle_event()
926 {
927         mwindow->clear_labels();
928         return 1;
929 }
930
931 CutCommercials::CutCommercials(MWindow *mwindow) : BC_MenuItem(_("Cut ads"))
932 {
933         this->mwindow = mwindow;
934 }
935
936 int CutCommercials::handle_event()
937 {
938         mwindow->cut_commercials();
939         return 1;
940 }
941
942 DetachTransitions::DetachTransitions(MWindow *mwindow)
943  : BC_MenuItem(_("Detach transitions"))
944 {
945         this->mwindow = mwindow;
946 }
947
948 int DetachTransitions::handle_event()
949 {
950         mwindow->detach_transitions();
951         return 1;
952 }
953
954 MuteSelection::MuteSelection(MWindow *mwindow)
955  : BC_MenuItem(_("Mute Region"), "m", 'm')
956 {
957         this->mwindow = mwindow;
958 }
959
960 int MuteSelection::handle_event()
961 {
962         mwindow->mute_selection();
963         return 1;
964 }
965
966
967 TrimSelection::TrimSelection(MWindow *mwindow)
968  : BC_MenuItem(_("Trim Selection"))
969 {
970         this->mwindow = mwindow;
971 }
972
973 int TrimSelection::handle_event()
974 {
975         mwindow->trim_selection();
976         return 1;
977 }
978
979
980
981
982
983
984
985
986
987
988
989
990 // ============================================= audio
991
992 AddAudioTrack::AddAudioTrack(MWindow *mwindow)
993  : BC_MenuItem(_("Add track"), "t", 't')
994 {
995         this->mwindow = mwindow;
996 }
997
998 int AddAudioTrack::handle_event()
999 {
1000         mwindow->add_audio_track_entry(0, 0);
1001         return 1;
1002 }
1003
1004 DeleteAudioTrack::DeleteAudioTrack(MWindow *mwindow)
1005  : BC_MenuItem(_("Delete track"))
1006 {
1007         this->mwindow = mwindow;
1008 }
1009
1010 int DeleteAudioTrack::handle_event()
1011 {
1012         return 1;
1013 }
1014
1015 DefaultATransition::DefaultATransition(MWindow *mwindow)
1016  : BC_MenuItem(_("Default Transition"), "u", 'u')
1017 {
1018         this->mwindow = mwindow;
1019 }
1020
1021 int DefaultATransition::handle_event()
1022 {
1023         mwindow->paste_audio_transition();
1024         return 1;
1025 }
1026
1027
1028 MapAudio1::MapAudio1(MWindow *mwindow)
1029  : BC_MenuItem(_("Map 1:1"))
1030 {
1031         this->mwindow = mwindow;
1032 }
1033
1034 int MapAudio1::handle_event()
1035 {
1036         mwindow->map_audio(MWindow::AUDIO_1_TO_1);
1037         return 1;
1038 }
1039
1040 MapAudio2::MapAudio2(MWindow *mwindow)
1041  : BC_MenuItem(_("Map 5.1:2"))
1042 {
1043         this->mwindow = mwindow;
1044 }
1045
1046 int MapAudio2::handle_event()
1047 {
1048         mwindow->map_audio(MWindow::AUDIO_5_1_TO_2);
1049         return 1;
1050 }
1051
1052
1053
1054
1055 // ============================================= video
1056
1057
1058 AddVideoTrack::AddVideoTrack(MWindow *mwindow)
1059  : BC_MenuItem(_("Add track"), _("Shift-T"), 'T')
1060 {
1061         set_shift();
1062         this->mwindow = mwindow;
1063 }
1064
1065 int AddVideoTrack::handle_event()
1066 {
1067         mwindow->add_video_track_entry();
1068         return 1;
1069 }
1070
1071
1072 DeleteVideoTrack::DeleteVideoTrack(MWindow *mwindow)
1073  : BC_MenuItem(_("Delete track"))
1074 {
1075         this->mwindow = mwindow;
1076 }
1077
1078 int DeleteVideoTrack::handle_event()
1079 {
1080         return 1;
1081 }
1082
1083
1084
1085 ResetTranslation::ResetTranslation(MWindow *mwindow)
1086  : BC_MenuItem(_("Reset Translation"))
1087 {
1088         this->mwindow = mwindow;
1089 }
1090
1091 int ResetTranslation::handle_event()
1092 {
1093         return 1;
1094 }
1095
1096
1097
1098 DefaultVTransition::DefaultVTransition(MWindow *mwindow)
1099  : BC_MenuItem(_("Default Transition"), _("Shift-U"), 'U')
1100 {
1101         set_shift();
1102         this->mwindow = mwindow;
1103 }
1104
1105 int DefaultVTransition::handle_event()
1106 {
1107         mwindow->paste_video_transition();
1108         return 1;
1109 }
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124 // ============================================ settings
1125
1126 DeleteTracks::DeleteTracks(MWindow *mwindow)
1127  : BC_MenuItem(_("Delete tracks"))
1128 {
1129         this->mwindow = mwindow;
1130 }
1131
1132 int DeleteTracks::handle_event()
1133 {
1134         mwindow->delete_tracks();
1135         return 1;
1136 }
1137
1138 DeleteTrack::DeleteTrack(MWindow *mwindow)
1139  : BC_MenuItem(_("Delete last track"), "d", 'd')
1140 {
1141         this->mwindow = mwindow;
1142 }
1143
1144 int DeleteTrack::handle_event()
1145 {
1146         mwindow->delete_track();
1147         return 1;
1148 }
1149
1150 MoveTracksUp::MoveTracksUp(MWindow *mwindow)
1151  : BC_MenuItem(_("Move tracks up"), _("Shift-Up"), UP)
1152 {
1153         set_shift(); this->mwindow = mwindow;
1154 }
1155
1156 int MoveTracksUp::handle_event()
1157 {
1158         mwindow->move_tracks_up();
1159         return 1;
1160 }
1161
1162 MoveTracksDown::MoveTracksDown(MWindow *mwindow)
1163  : BC_MenuItem(_("Move tracks down"), _("Shift-Down"), DOWN)
1164 {
1165         set_shift(); this->mwindow = mwindow;
1166 }
1167
1168 int MoveTracksDown::handle_event()
1169 {
1170         mwindow->move_tracks_down();
1171         return 1;
1172 }
1173
1174
1175
1176
1177 ConcatenateTracks::ConcatenateTracks(MWindow *mwindow)
1178  : BC_MenuItem(_("Concatenate tracks"))
1179 {
1180         set_shift();
1181         this->mwindow = mwindow;
1182 }
1183
1184 int ConcatenateTracks::handle_event()
1185 {
1186         mwindow->concatenate_tracks();
1187         return 1;
1188 }
1189
1190
1191
1192
1193
1194 LoopPlayback::LoopPlayback(MWindow *mwindow)
1195  : BC_MenuItem(_("Loop Playback"), _("Shift-L"), 'L')
1196 {
1197         this->mwindow = mwindow;
1198         set_checked(mwindow->edl->local_session->loop_playback);
1199         set_shift();
1200 }
1201
1202 int LoopPlayback::handle_event()
1203 {
1204         mwindow->toggle_loop_playback();
1205         set_checked(mwindow->edl->local_session->loop_playback);
1206         return 1;
1207 }
1208
1209
1210
1211 // ============================================= subtitle
1212
1213
1214 AddSubttlTrack::AddSubttlTrack(MWindow *mwindow)
1215  : BC_MenuItem(_("Add subttl"), _("Shift-Y"), 'Y')
1216 {
1217         set_shift();
1218         this->mwindow = mwindow;
1219 }
1220
1221 int AddSubttlTrack::handle_event()
1222 {
1223         mwindow->add_subttl_track_entry();
1224         return 1;
1225 }
1226
1227 PasteSubttl::PasteSubttl(MWindow *mwindow)
1228  : BC_MenuItem(_("paste subttl"), "y", 'y')
1229 {
1230         this->mwindow = mwindow;
1231 }
1232
1233 int PasteSubttl::handle_event()
1234 {
1235         mwindow->gui->swindow->paste_subttl();
1236         return 1;
1237 }
1238
1239
1240
1241
1242
1243
1244 SetBRenderRange::SetBRenderRange(MWindow *mwindow)
1245  : BC_MenuItem(_("Set background rendering"))
1246 {
1247         this->mwindow = mwindow;
1248 }
1249
1250 int SetBRenderRange::handle_event()
1251 {
1252         mwindow->set_brender_range();
1253         return 1;
1254 }
1255
1256
1257
1258
1259
1260
1261
1262 LabelsFollowEdits::LabelsFollowEdits(MWindow *mwindow)
1263  : BC_MenuItem(_("Edit labels"))
1264 {
1265         this->mwindow = mwindow;
1266         set_checked(mwindow->edl->session->labels_follow_edits);
1267 }
1268
1269 int LabelsFollowEdits::handle_event()
1270 {
1271         set_checked(get_checked() ^ 1);
1272         mwindow->set_labels_follow_edits(get_checked());
1273         return 1;
1274 }
1275
1276
1277
1278
1279 PluginsFollowEdits::PluginsFollowEdits(MWindow *mwindow)
1280  : BC_MenuItem(_("Edit effects"))
1281 {
1282         this->mwindow = mwindow;
1283         set_checked(mwindow->edl->session->plugins_follow_edits);
1284 }
1285
1286 int PluginsFollowEdits::handle_event()
1287 {
1288         set_checked(get_checked() ^ 1);
1289         mwindow->edl->session->plugins_follow_edits = get_checked();
1290         return 1;
1291 }
1292
1293
1294
1295
1296 KeyframesFollowEdits::KeyframesFollowEdits(MWindow *mwindow)
1297  : BC_MenuItem(_("Keyframes follow edits"))
1298 {
1299         this->mwindow = mwindow;
1300         set_checked(mwindow->edl->session->autos_follow_edits);
1301 }
1302
1303 int KeyframesFollowEdits::handle_event()
1304 {
1305         mwindow->edl->session->autos_follow_edits ^= 1;
1306         set_checked(!get_checked());
1307         return 1;
1308 }
1309
1310
1311 CursorOnFrames::CursorOnFrames(MWindow *mwindow)
1312  : BC_MenuItem(_("Align cursor on frames"))
1313 {
1314         this->mwindow = mwindow;
1315         set_checked(mwindow->edl->session->cursor_on_frames);
1316 }
1317
1318 int CursorOnFrames::handle_event()
1319 {
1320         mwindow->edl->session->cursor_on_frames = !mwindow->edl->session->cursor_on_frames;
1321         set_checked(mwindow->edl->session->cursor_on_frames);
1322         return 1;
1323 }
1324
1325
1326 TypelessKeyframes::TypelessKeyframes(MWindow *mwindow)
1327  : BC_MenuItem(_("Typeless keyframes"))
1328 {
1329         this->mwindow = mwindow;
1330         set_checked(mwindow->edl->session->typeless_keyframes);
1331 }
1332
1333 int TypelessKeyframes::handle_event()
1334 {
1335         mwindow->edl->session->typeless_keyframes = !mwindow->edl->session->typeless_keyframes;
1336         set_checked(mwindow->edl->session->typeless_keyframes);
1337         return 1;
1338 }
1339
1340
1341 ScrubSpeed::ScrubSpeed(MWindow *mwindow) : BC_MenuItem(_("Slow Shuttle"))
1342 {
1343         this->mwindow = mwindow;
1344 }
1345
1346 int ScrubSpeed::handle_event()
1347 {
1348         if(mwindow->edl->session->scrub_speed == .5)
1349         {
1350                 mwindow->edl->session->scrub_speed = 2;
1351                 set_text(_("Slow Shuttle"));
1352         }
1353         else
1354         {
1355                 mwindow->edl->session->scrub_speed = .5;
1356                 set_text(_("Fast Shuttle"));
1357         }
1358         return 1;
1359 }
1360
1361 SaveSettingsNow::SaveSettingsNow(MWindow *mwindow) : BC_MenuItem(_("Save settings now"))
1362 {
1363         this->mwindow = mwindow;
1364 }
1365
1366 int SaveSettingsNow::handle_event()
1367 {
1368         mwindow->save_defaults();
1369         mwindow->save_backup();
1370         mwindow->gui->show_message(_("Saved settings."));
1371         return 1;
1372 }
1373
1374
1375
1376 // ============================================ window
1377
1378
1379
1380
1381
1382 ShowVWindow::ShowVWindow(MWindow *mwindow)
1383  : BC_MenuItem(_("Show Viewer"))
1384 {
1385         this->mwindow = mwindow;
1386         set_checked(mwindow->session->show_vwindow);
1387 }
1388 int ShowVWindow::handle_event()
1389 {
1390         mwindow->show_vwindow();
1391         return 1;
1392 }
1393
1394 ShowAWindow::ShowAWindow(MWindow *mwindow)
1395  : BC_MenuItem(_("Show Resources"))
1396 {
1397         this->mwindow = mwindow;
1398         set_checked(mwindow->session->show_awindow);
1399 }
1400 int ShowAWindow::handle_event()
1401 {
1402         mwindow->show_awindow();
1403         return 1;
1404 }
1405
1406 ShowCWindow::ShowCWindow(MWindow *mwindow)
1407  : BC_MenuItem(_("Show Compositor"))
1408 {
1409         this->mwindow = mwindow;
1410         set_checked(mwindow->session->show_cwindow);
1411 }
1412 int ShowCWindow::handle_event()
1413 {
1414         mwindow->show_cwindow();
1415         return 1;
1416 }
1417
1418
1419 ShowGWindow::ShowGWindow(MWindow *mwindow)
1420  : BC_MenuItem(_("Show Overlays"), _("Ctrl-0"), '0')
1421 {
1422         this->mwindow = mwindow;
1423         set_ctrl(1);
1424         set_checked(mwindow->session->show_gwindow);
1425 }
1426 int ShowGWindow::handle_event()
1427 {
1428         if( !mwindow->session->show_gwindow )
1429                 mwindow->show_gwindow();
1430         else
1431                 mwindow->hide_gwindow();
1432         set_checked(mwindow->session->show_gwindow);
1433         return 1;
1434 }
1435
1436
1437 ShowLWindow::ShowLWindow(MWindow *mwindow)
1438  : BC_MenuItem(_("Show Levels"))
1439 {
1440         this->mwindow = mwindow;
1441         set_checked(mwindow->session->show_lwindow);
1442 }
1443 int ShowLWindow::handle_event()
1444 {
1445         mwindow->show_lwindow();
1446         return 1;
1447 }
1448
1449 TileWindows::TileWindows(MWindow *mwindow, const char *item_title, int config,
1450                 const char *hot_keytext, int hot_key)
1451  : BC_MenuItem(item_title, hot_keytext, hot_key)
1452 {
1453         this->mwindow = mwindow;
1454         this->config = config;
1455         if( hot_key ) set_ctrl(1);
1456 }
1457 int TileWindows::handle_event()
1458 {
1459         int window_config = config >= 0 ? config :
1460                 mwindow->session->window_config;
1461         if( mwindow->tile_windows(window_config) ) {
1462                 mwindow->restart_status = 1;
1463                 mwindow->gui->set_done(0);
1464         }
1465         return 1;
1466 }
1467
1468 SplitX::SplitX(MWindow *mwindow)
1469  : BC_MenuItem(_("Split X pane"), _("Ctrl-1"), '1')
1470 {
1471         this->mwindow = mwindow;
1472         set_ctrl(1);
1473         set_checked(mwindow->gui->pane[TOP_RIGHT_PANE] != 0);
1474 }
1475 int SplitX::handle_event()
1476 {
1477         mwindow->split_x();
1478         return 1;
1479 }
1480
1481 SplitY::SplitY(MWindow *mwindow)
1482  : BC_MenuItem(_("Split Y pane"), _("Ctrl-2"), '2')
1483 {
1484         this->mwindow = mwindow;
1485         set_ctrl(1);
1486         set_checked(mwindow->gui->pane[BOTTOM_LEFT_PANE] != 0);
1487 }
1488 int SplitY::handle_event()
1489 {
1490         mwindow->split_y();
1491         return 1;
1492 }
1493
1494