4 * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
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.
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.
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
24 #include "batchrender.h"
25 #include "bcdisplayinfo.h"
27 #include "bcsignals.h"
30 #include "channelinfo.h"
32 #include "cplayback.h"
33 #include "cropvideo.h"
35 #include "cwindowgui.h"
37 #include "dvdcreate.h"
39 #include "edlsession.h"
40 #include "exportedl.h"
42 #include "filesystem.h"
44 #include "floatauto.h"
47 #include "levelwindow.h"
49 #include "localsession.h"
50 #include "mainclock.h"
52 #include "mainsession.h"
54 #include "menuattacheffect.h"
55 #include "menuattachtransition.h"
56 #include "menuaeffects.h"
57 #include "menueditlength.h"
58 #include "menutransitionlength.h"
59 #include "menuveffects.h"
60 #include "mixersalign.h"
61 #include "mwindowgui.h"
65 #include "playbackengine.h"
66 #include "preferences.h"
68 #include "preferencesthread.h"
73 #include "setformat.h"
76 #include "trackcanvas.h"
78 #include "transition.h"
79 #include "transportque.h"
83 #include "zwindowgui.h"
88 MainMenu::MainMenu(MWindow *mwindow, MWindowGUI *gui, int w)
92 this->mwindow = mwindow;
93 // *** CONTEXT_HELP ***
94 context_help_set_keyword("Program Window");
101 void MainMenu::create_objects()
103 BC_Menu *viewmenu, *windowmenu, *settingsmenu, *trackmenu;
104 PreferencesMenuitem *preferences;
106 add_menu(filemenu = new BC_Menu(_("File")));
107 filemenu->add_item(new_project = new NewProject(mwindow));
108 new_project->create_objects();
111 filemenu->add_item(load_file = new Load(mwindow, this));
112 load_file->create_objects();
113 filemenu->add_item(load_recent = new LoadRecent(mwindow, this));
114 load_recent->create_objects();
116 // new and load can be undone so no need to prompt save
117 Save *save; // affected by saveas
118 filemenu->add_item(save = new Save(mwindow));
120 filemenu->add_item(saveas = new SaveAs(mwindow));
121 save->create_objects(saveas);
122 saveas->set_mainmenu(this);
123 filemenu->add_item(new SaveProject(mwindow));
124 filemenu->add_item(new SaveSession(mwindow));
126 filemenu->add_item(record_menu_item = new RecordMenuItem(mwindow));
128 filemenu->add_item(new ChannelScan(mwindow));
130 #ifdef HAVE_COMMERCIAL
131 if( mwindow->has_commercials() )
132 filemenu->add_item(new DbWindowScan(mwindow));
134 filemenu->add_item(new SubttlSWin(mwindow));
136 filemenu->add_item(render = new RenderItem(mwindow));
137 filemenu->add_item(new ExportEDLItem(mwindow));
138 filemenu->add_item(new BatchRenderMenuItem(mwindow));
139 filemenu->add_item(new CreateBD_MenuItem(mwindow));
140 filemenu->add_item(new CreateDVD_MenuItem(mwindow));
141 filemenu->add_item(new BC_MenuItem("-"));
142 filemenu->add_item(quit_program = new Quit(mwindow));
143 quit_program->create_objects(save);
144 filemenu->add_item(dump_menu = new MainDumpsMenu(mwindow));
145 dump_menu->create_objects();
146 filemenu->add_item(new LoadBackup(mwindow));
147 filemenu->add_item(new SaveBackup(mwindow));
150 add_menu(editmenu = new BC_Menu(_("Edit")));
151 editmenu->add_item(undo = new Undo(mwindow));
152 editmenu->add_item(redo = new Redo(mwindow));
153 editmenu->add_item(new BC_MenuItem("-"));
154 editmenu->add_item(new Cut(mwindow));
155 editmenu->add_item(new Copy(mwindow));
156 editmenu->add_item(new Paste(mwindow));
157 editmenu->add_item(new PasteSilence(mwindow));
158 editmenu->add_item(clear_menu = new EditClearMenu(mwindow));
159 clear_menu->create_objects();
160 editmenu->add_item(new TrimSelection(mwindow));
161 editmenu->add_item(new SelectAll(mwindow));
162 editmenu->add_item(new BC_MenuItem("-"));
163 editmenu->add_item(new MenuEditShuffle(mwindow));
164 editmenu->add_item(new MenuEditReverse(mwindow));
165 editmenu->add_item(new MenuEditLength(mwindow));
166 editmenu->add_item(new MenuEditAlign(mwindow));
167 editmenu->add_item(new MenuTransitionLength(mwindow));
168 editmenu->add_item(new DetachTransitions(mwindow));
169 editmenu->add_item(new BC_MenuItem("-"));
170 editmenu->add_item(new CutCommercials(mwindow));
171 editmenu->add_item(new PasteSubttl(mwindow));
173 BC_Menu *keyframemenu;
174 add_menu(keyframemenu = new BC_Menu(_("Keyframes")));
175 keyframemenu->add_item(new CutKeyframes(mwindow));
176 keyframemenu->add_item(new CopyKeyframes(mwindow));
177 keyframemenu->add_item(new PasteKeyframes(mwindow));
178 keyframemenu->add_item(new ClearKeyframes(mwindow));
179 keyframemenu->add_item(set_auto_curves = new SetAutomationCurveMode(mwindow));
180 set_auto_curves->create_objects();
181 keyframemenu->add_item(keyframe_curve_type = new KeyframeCurveType(mwindow));
182 keyframe_curve_type->create_objects();
183 keyframe_curve_type->update(mwindow->edl->local_session->floatauto_type);
184 keyframemenu->add_item(keyframe_create = new KeyframeCreate(mwindow));
185 keyframe_create->create_objects();
186 keyframemenu->add_item(new BC_MenuItem("-"));
187 keyframemenu->add_item(new CopyDefaultKeyframe(mwindow));
188 keyframemenu->add_item(new PasteDefaultKeyframe(mwindow));
193 add_menu(audiomenu = new BC_Menu(_("Audio")));
194 audiomenu->add_item(new AddAudioTrack(mwindow));
195 audiomenu->add_item(new DefaultATransition(mwindow));
196 audiomenu->add_item(new MapAudio1(mwindow));
197 audiomenu->add_item(new MapAudio2(mwindow));
198 audiomenu->add_item(new MenuAttachTransition(mwindow, TRACK_AUDIO));
199 audiomenu->add_item(new MenuAttachEffect(mwindow, TRACK_AUDIO));
200 audiomenu->add_item(aeffects = new MenuAEffects(mwindow));
202 add_menu(videomenu = new BC_Menu(_("Video")));
203 videomenu->add_item(new AddVideoTrack(mwindow));
204 videomenu->add_item(new DefaultVTransition(mwindow));
205 videomenu->add_item(new MenuAttachTransition(mwindow, TRACK_VIDEO));
206 videomenu->add_item(new MenuAttachEffect(mwindow, TRACK_VIDEO));
207 videomenu->add_item(veffects = new MenuVEffects(mwindow));
209 add_menu(trackmenu = new BC_Menu(_("Tracks")));
210 trackmenu->add_item(new MoveTracksUp(mwindow));
211 trackmenu->add_item(new MoveTracksDown(mwindow));
212 trackmenu->add_item(new RollTracksUp(mwindow));
213 trackmenu->add_item(new RollTracksDown(mwindow));
214 trackmenu->add_item(new DeleteTracks(mwindow));
215 trackmenu->add_item(new DeleteFirstTrack(mwindow));
216 trackmenu->add_item(new DeleteLastTrack(mwindow));
217 trackmenu->add_item(new ConcatenateTracks(mwindow));
218 trackmenu->add_item(new AlignTimecodes(mwindow));
219 AppendTracks *append_tracks;
220 trackmenu->add_item(append_tracks = new AppendTracks(mwindow));
221 append_tracks->create_objects();
222 trackmenu->add_item(new AddSubttlTrack(mwindow));
224 add_menu(settingsmenu = new BC_Menu(_("Settings")));
226 settingsmenu->add_item(new SetFormat(mwindow));
227 settingsmenu->add_item(preferences = new PreferencesMenuitem(mwindow));
228 settingsmenu->add_item(proxy = new ProxyMenuItem(mwindow));
229 proxy->create_objects();
230 ConvertMenuItem *convert;
231 settingsmenu->add_item(convert = new ConvertMenuItem(mwindow));
232 convert->create_objects();
233 mwindow->preferences_thread = preferences->thread;
234 settingsmenu->add_item(cursor_on_frames = new CursorOnFrames(mwindow));
235 settingsmenu->add_item(labels_follow_edits = new LabelsFollowEdits(mwindow));
236 settingsmenu->add_item(plugins_follow_edits = new PluginsFollowEdits(mwindow));
237 settingsmenu->add_item(keyframes_follow_edits = new KeyframesFollowEdits(mwindow));
238 settingsmenu->add_item(typeless_keyframes = new TypelessKeyframes(mwindow));
239 settingsmenu->add_item(new BC_MenuItem("-"));
240 settingsmenu->add_item(new SaveSettingsNow(mwindow));
241 settingsmenu->add_item(loop_playback = new LoopPlayback(mwindow));
242 settingsmenu->add_item(brender_active = new SetBRenderActive(mwindow));
243 // set scrubbing speed
244 // ScrubSpeed *scrub_speed;
245 // settingsmenu->add_item(scrub_speed = new ScrubSpeed(mwindow));
246 // if(mwindow->edl->session->scrub_speed == .5)
247 // scrub_speed->set_text(_("Fast Shuttle"));
254 add_menu(viewmenu = new BC_Menu(_("View")));
255 viewmenu->add_item(show_assets = new ShowAssets(mwindow, "0"));
256 viewmenu->add_item(show_titles = new ShowTitles(mwindow, "1"));
257 viewmenu->add_item(show_transitions = new ShowTransitions(mwindow, "2"));
258 viewmenu->add_item(fade_automation = new ShowAutomation(mwindow, _("Fade"), "3", AUTOMATION_FADE));
259 viewmenu->add_item(mute_automation = new ShowAutomation(mwindow, _("Mute"), "4", AUTOMATION_MUTE));
260 viewmenu->add_item(mode_automation = new ShowAutomation(mwindow, _("Overlay mode"), "5", AUTOMATION_MODE));
261 viewmenu->add_item(pan_automation = new ShowAutomation(mwindow, _("Pan"), "6", AUTOMATION_PAN));
262 viewmenu->add_item(plugin_automation = new PluginAutomation(mwindow, "7"));
263 viewmenu->add_item(mask_automation = new ShowAutomation(mwindow, _("Mask"), "8", AUTOMATION_MASK));
264 viewmenu->add_item(speed_automation = new ShowAutomation(mwindow, _("Speed"), "9", AUTOMATION_SPEED));
266 camera_x = new ShowAutomation(mwindow, _("Camera X"), "Ctrl-Shift-X", AUTOMATION_CAMERA_X);
267 camera_x->set_ctrl(); camera_x->set_shift(); viewmenu->add_item(camera_x);
268 camera_y = new ShowAutomation(mwindow, _("Camera Y"), "Ctrl-Shift-Y", AUTOMATION_CAMERA_Y);
269 camera_y->set_ctrl(); camera_y->set_shift(); viewmenu->add_item(camera_y);
270 camera_z = new ShowAutomation(mwindow, _("Camera Z"), "Ctrl-Shift-Z", AUTOMATION_CAMERA_Z);
271 camera_z->set_ctrl(); camera_z->set_shift(); viewmenu->add_item(camera_z);
272 project_x = new ShowAutomation(mwindow, _("Projector X"), "Alt-Shift-X", AUTOMATION_PROJECTOR_X);
273 project_x->set_alt(); project_x->set_shift(); viewmenu->add_item(project_x);
274 project_y = new ShowAutomation(mwindow, _("Projector Y"), "Alt-Shift-Y", AUTOMATION_PROJECTOR_Y);
275 project_y->set_alt(); project_y->set_shift(); viewmenu->add_item(project_y);
276 project_z = new ShowAutomation(mwindow, _("Projector Z"), "Alt-Shift-Z", AUTOMATION_PROJECTOR_Z);
277 project_z->set_alt(); project_z->set_shift(); viewmenu->add_item(project_z);
279 add_menu(windowmenu = new BC_Menu(_("Window")));
280 windowmenu->add_item(show_vwindow = new ShowVWindow(mwindow));
281 windowmenu->add_item(show_awindow = new ShowAWindow(mwindow));
282 windowmenu->add_item(show_cwindow = new ShowCWindow(mwindow));
283 windowmenu->add_item(show_gwindow = new ShowGWindow(mwindow));
284 windowmenu->add_item(show_lwindow = new ShowLWindow(mwindow));
285 windowmenu->add_item(new BC_MenuItem("-"));
286 windowmenu->add_item(split_x = new SplitX(mwindow));
287 windowmenu->add_item(split_y = new SplitY(mwindow));
288 windowmenu->add_item(mixer_items = new MixerItems(mwindow));
289 mixer_items->create_objects();
290 windowmenu->add_item(new TileWindows(mwindow,_("Tile left"),0));
291 windowmenu->add_item(new TileWindows(mwindow,_("Tile right"),1));
292 windowmenu->add_item(new BC_MenuItem("-"));
294 windowmenu->add_item(new TileWindows(mwindow,_("Default positions"),-1,_("Ctrl-P"),'p'));
295 windowmenu->add_item(load_layout = new LoadLayout(mwindow, _("Load layout..."),LAYOUT_LOAD));
296 load_layout->create_objects();
297 windowmenu->add_item(save_layout = new LoadLayout(mwindow, _("Save layout..."),LAYOUT_SAVE));
298 save_layout->create_objects();
301 int MainMenu::load_defaults(BC_Hash *defaults)
303 init_loads(defaults);
304 init_aeffects(defaults);
305 init_veffects(defaults);
309 void MainMenu::update_toggles(int use_lock)
311 if(use_lock) lock_window("MainMenu::update_toggles");
312 labels_follow_edits->set_checked(mwindow->edl->session->labels_follow_edits);
313 plugins_follow_edits->set_checked(mwindow->edl->session->plugins_follow_edits);
314 keyframes_follow_edits->set_checked(mwindow->edl->session->autos_follow_edits);
315 typeless_keyframes->set_checked(mwindow->edl->session->typeless_keyframes);
316 cursor_on_frames->set_checked(mwindow->edl->session->cursor_on_frames);
317 loop_playback->set_checked(mwindow->edl->local_session->loop_playback);
319 show_assets->set_checked(mwindow->edl->session->show_assets);
320 show_titles->set_checked(mwindow->edl->session->show_titles);
321 show_transitions->set_checked(mwindow->edl->session->auto_conf->transitions);
322 fade_automation->update_toggle();
323 mute_automation->update_toggle();
324 pan_automation->update_toggle();
325 camera_x->update_toggle();
326 camera_y->update_toggle();
327 camera_z->update_toggle();
328 project_x->update_toggle();
329 project_y->update_toggle();
330 project_z->update_toggle();
331 plugin_automation->set_checked(mwindow->edl->session->auto_conf->plugins);
332 mode_automation->update_toggle();
333 mask_automation->update_toggle();
334 speed_automation->update_toggle();
335 split_x->set_checked(mwindow->gui->pane[TOP_RIGHT_PANE] != 0);
336 split_y->set_checked(mwindow->gui->pane[BOTTOM_LEFT_PANE] != 0);
338 if(use_lock) mwindow->gui->unlock_window();
341 int MainMenu::save_defaults(BC_Hash *defaults)
343 save_loads(defaults);
344 save_aeffects(defaults);
345 save_veffects(defaults);
355 quit_program->handle_event();
363 // ================================== load most recent
365 int MainMenu::init_aeffects(BC_Hash *defaults)
367 total_aeffects = defaults->get((char*)"TOTAL_AEFFECTS", 0);
369 char string[BCTEXTLEN], title[BCTEXTLEN];
370 if(total_aeffects) audiomenu->add_item(new BC_MenuItem("-"));
372 for(int i = 0; i < total_aeffects; i++)
374 sprintf(string, "AEFFECTRECENT%d", i);
375 defaults->get(string, title);
376 audiomenu->add_item(aeffect[i] = new MenuAEffectItem(aeffects, title));
381 int MainMenu::init_veffects(BC_Hash *defaults)
383 total_veffects = defaults->get((char*)"TOTAL_VEFFECTS", 0);
385 char string[BCTEXTLEN], title[BCTEXTLEN];
386 if(total_veffects) videomenu->add_item(new BC_MenuItem("-"));
388 for(int i = 0; i < total_veffects; i++)
390 sprintf(string, "VEFFECTRECENT%d", i);
391 defaults->get(string, title);
392 videomenu->add_item(veffect[i] = new MenuVEffectItem(veffects, title));
397 void MainMenu::init_loads(BC_Hash *defaults)
399 // total_loads for legacy xml
400 int total_loads = defaults->get((char*)"TOTAL_LOADS", 0);
401 int loads_total = defaults->get((char*)"LOADS_TOTAL", 0);
402 if( loads_total < total_loads ) loads_total = total_loads;
404 char string[BCTEXTLEN], path[BCTEXTLEN];
406 //printf("MainMenu::init_loads 2\n");
408 for( int i=0; i<loads_total; ++i ) {
409 sprintf(string, "LOADPREVIOUS%d", i);
410 //printf("MainMenu::init_loads 3\n");
411 defaults->get(string, path);
412 if( load.size() < TOTAL_LOADS )
413 load.append(new LoadRecentItem(path));
417 // ============================ save most recent
419 int MainMenu::save_aeffects(BC_Hash *defaults)
421 defaults->update((char*)"TOTAL_AEFFECTS", total_aeffects);
422 char string[BCTEXTLEN];
423 for(int i = 0; i < total_aeffects; i++)
425 sprintf(string, "AEFFECTRECENT%d", i);
426 defaults->update(string, aeffect[i]->get_text());
431 int MainMenu::save_veffects(BC_Hash *defaults)
433 defaults->update((char*)"TOTAL_VEFFECTS", total_veffects);
434 char string[BCTEXTLEN];
435 for(int i = 0; i < total_veffects; i++)
437 sprintf(string, "VEFFECTRECENT%d", i);
438 defaults->update(string, veffect[i]->get_text());
443 int MainMenu::save_loads(BC_Hash *defaults)
445 // legacy to prevent segv, older code cant tolerate total_loads>10
446 int loads_total = load.size();
447 int total_loads = MIN(10, loads_total);
448 defaults->update((char*)"LOADS_TOTAL", loads_total);
449 defaults->update((char*)"TOTAL_LOADS", total_loads);
450 char string[BCTEXTLEN];
451 for( int i=0; i<loads_total; ++i ) {
452 sprintf(string, "LOADPREVIOUS%d", i);
453 defaults->update(string, load[i]->path);
458 // =================================== add most recent
460 int MainMenu::add_aeffect(char *title)
462 // add bar for first effect
463 if(total_aeffects == 0)
465 audiomenu->add_item(new BC_MenuItem("-"));
468 // test for existing copy of effect
469 for(int i = 0; i < total_aeffects; i++)
471 if(!strcmp(aeffect[i]->get_text(), title)) // already exists
472 { // swap for top effect
473 for(int j = i; j > 0; j--) // move preceeding effects down
475 aeffect[j]->set_text(aeffect[j - 1]->get_text());
477 aeffect[0]->set_text(title);
482 // add another blank effect
483 if(total_aeffects < TOTAL_EFFECTS)
486 aeffect[total_aeffects] = new MenuAEffectItem(aeffects, (char*)""));
491 for(int i = total_aeffects - 1; i > 0; i--)
493 // set menu item text
494 aeffect[i]->set_text(aeffect[i - 1]->get_text());
497 // set up the new effect
498 aeffect[0]->set_text(title);
502 int MainMenu::add_veffect(char *title)
504 // add bar for first effect
505 if(total_veffects == 0)
507 videomenu->add_item(new BC_MenuItem("-"));
510 // test for existing copy of effect
511 for(int i = 0; i < total_veffects; i++)
513 if(!strcmp(veffect[i]->get_text(), title)) // already exists
514 { // swap for top effect
515 for(int j = i; j > 0; j--) // move preceeding effects down
517 veffect[j]->set_text(veffect[j - 1]->get_text());
519 veffect[0]->set_text(title);
524 // add another blank effect
525 if(total_veffects < TOTAL_EFFECTS)
527 videomenu->add_item(veffect[total_veffects] =
528 new MenuVEffectItem(veffects, (char*)""));
533 for(int i = total_veffects - 1; i > 0; i--)
535 // set menu item text
536 veffect[i]->set_text(veffect[i - 1]->get_text());
539 // set up the new effect
540 veffect[0]->set_text(title);
544 int MainMenu::add_load(char *path)
546 return load.add_load(path);
551 // ================================== menu items
553 MainDumpsSubMenu::MainDumpsSubMenu(BC_MenuItem *menu_item)
556 this->menu_item = menu_item;
558 MainDumpsSubMenu::~MainDumpsSubMenu()
563 MainDumpsMenu::MainDumpsMenu(MWindow *mwindow)
564 : BC_MenuItem(_("Dumps..."))
566 this->mwindow = mwindow;
567 this->dumps_menu = 0;
569 MainDumpsMenu::~MainDumpsMenu()
573 void MainDumpsMenu::create_objects()
575 add_submenu(dumps_menu = new MainDumpsSubMenu(this));
576 // dumps_menu->add_item(new DumpCICache(mwindow));
577 dumps_menu->add_item(new DumpEDL(mwindow));
578 dumps_menu->add_item(new DumpPlugins(mwindow));
579 dumps_menu->add_item(new DumpAssets(mwindow));
580 dumps_menu->add_item(new DumpUndo(mwindow));
584 DumpCICache::DumpCICache(MWindow *mwindow)
585 : BC_MenuItem(_("Dump CICache"))
586 { this->mwindow = mwindow; }
588 int DumpCICache::handle_event()
590 // mwindow->cache->dump();
594 DumpEDL::DumpEDL(MWindow *mwindow)
595 : BC_MenuItem(_("Dump EDL"))
597 this->mwindow = mwindow;
600 int DumpEDL::handle_event()
606 DumpPlugins::DumpPlugins(MWindow *mwindow)
607 : BC_MenuItem(_("Dump Plugins"))
609 this->mwindow = mwindow;
612 int DumpPlugins::handle_event()
614 mwindow->dump_plugins();
618 DumpAssets::DumpAssets(MWindow *mwindow)
619 : BC_MenuItem(_("Dump Assets"))
620 { this->mwindow = mwindow; }
622 int DumpAssets::handle_event()
624 mwindow->edl->assets->dump();
628 DumpUndo::DumpUndo(MWindow *mwindow)
629 : BC_MenuItem(_("Dump Undo"))
631 this->mwindow = mwindow;
634 int DumpUndo::handle_event()
636 mwindow->dump_undo();
640 // ================================================= edit
642 Undo::Undo(MWindow *mwindow) : BC_MenuItem(_("Undo"), "z or Ctrl-z", 'z')
644 this->mwindow = mwindow;
646 int Undo::handle_event()
648 if( mwindow->session->current_operation == NO_OPERATION )
649 mwindow->undo_entry(mwindow->gui);
652 int Undo::update_caption(const char *new_caption)
654 char string[BCTEXTLEN];
655 sprintf(string, _("Undo %s"), new_caption);
661 Redo::Redo(MWindow *mwindow) : BC_MenuItem(_("Redo"), _("Shift-Z"), 'Z')
664 this->mwindow = mwindow;
667 int Redo::handle_event()
669 if( mwindow->session->current_operation == NO_OPERATION )
670 mwindow->redo_entry(mwindow->gui);
673 int Redo::update_caption(const char *new_caption)
675 char string[BCTEXTLEN];
676 sprintf(string, _("Redo %s"), new_caption);
681 CutKeyframes::CutKeyframes(MWindow *mwindow)
682 : BC_MenuItem(_("Cut keyframes"), _("Shift-X"), 'X')
685 this->mwindow = mwindow;
688 int CutKeyframes::handle_event()
690 if( mwindow->session->current_operation == NO_OPERATION )
691 mwindow->cut_automation();
695 CopyKeyframes::CopyKeyframes(MWindow *mwindow)
696 : BC_MenuItem(_("Copy keyframes"), _("Shift-C"), 'C')
699 this->mwindow = mwindow;
702 int CopyKeyframes::handle_event()
704 if( mwindow->session->current_operation == NO_OPERATION )
705 mwindow->copy_automation();
709 PasteKeyframes::PasteKeyframes(MWindow *mwindow)
710 : BC_MenuItem(_("Paste keyframes"), _("Shift-V"), 'V')
713 this->mwindow = mwindow;
716 int PasteKeyframes::handle_event()
718 if( mwindow->session->current_operation == NO_OPERATION )
719 mwindow->paste_automation();
723 ClearKeyframes::ClearKeyframes(MWindow *mwindow)
724 : BC_MenuItem(_("Clear keyframes"), _("Shift-Del"), DELETE)
727 this->mwindow = mwindow;
730 int ClearKeyframes::handle_event()
732 if( mwindow->session->current_operation == NO_OPERATION )
733 mwindow->clear_automation();
738 SetAutomationCurveItem::SetAutomationCurveItem(SetAutomationCurveMode *set_curve_mode, int id)
739 : BC_MenuItem(FloatAuto::curve_name(id))
741 this->set_curve_mode = set_curve_mode;
745 int SetAutomationCurveItem::handle_event()
747 set_curve_mode->mwindow->set_automation_mode((FloatAuto::t_mode)id);
751 SetAutoCurveModeMenu::SetAutoCurveModeMenu(SetAutomationCurveMode *curve_mode)
754 this->curve_mode = curve_mode;
757 SetAutomationCurveMode::SetAutomationCurveMode(MWindow *mwindow)
758 : BC_MenuItem(_("Set curve modes..."))
760 this->mwindow = mwindow;
764 void SetAutomationCurveMode::create_objects()
766 add_submenu(curve_mode_menu = new SetAutoCurveModeMenu(this));
767 for( int id=FloatAuto::SMOOTH; id<=FloatAuto::BUMP; ++id )
768 curve_mode_menu->add_item(new SetAutomationCurveItem(this, id));
772 KeyframeCurveType::KeyframeCurveType(MWindow *mwindow)
773 : BC_MenuItem(_("Create curve type..."))
775 this->mwindow = mwindow;
776 this->curve_menu = 0;
778 KeyframeCurveType::~KeyframeCurveType()
782 void KeyframeCurveType::create_objects()
784 add_submenu(curve_menu = new KeyframeCurveTypeMenu(this));
785 for( int i=FloatAuto::SMOOTH; i<=FloatAuto::BUMP; ++i ) {
786 KeyframeCurveTypeItem *curve_type_item = new KeyframeCurveTypeItem(i, this);
787 curve_menu->add_submenuitem(curve_type_item);
791 void KeyframeCurveType::update(int curve_type)
793 for( int i=0; i<curve_menu->total_items(); ++i ) {
794 KeyframeCurveTypeItem *curve_type_item = (KeyframeCurveTypeItem *)curve_menu->get_item(i);
795 curve_type_item->set_checked(curve_type_item->type == curve_type);
799 int KeyframeCurveType::handle_event()
804 KeyframeCurveTypeMenu::KeyframeCurveTypeMenu(KeyframeCurveType *menu_item)
807 this->menu_item = menu_item;
809 KeyframeCurveTypeMenu::~KeyframeCurveTypeMenu()
813 KeyframeCurveTypeItem::KeyframeCurveTypeItem(int type, KeyframeCurveType *main_item)
814 : BC_MenuItem(FloatAuto::curve_name(type))
817 this->main_item = main_item;
819 KeyframeCurveTypeItem::~KeyframeCurveTypeItem()
823 int KeyframeCurveTypeItem::handle_event()
825 main_item->update(type);
826 main_item->mwindow->set_keyframe_type(type);
831 KeyframeCreateItem::KeyframeCreateItem(KeyframeCreate *keyframe_create,
832 const char *text, int mask)
835 this->keyframe_create = keyframe_create;
839 int KeyframeCreateItem::handle_event()
841 MWindow *mwindow = keyframe_create->mwindow;
842 int mode = mwindow->edl->local_session->floatauto_type;
843 int mask = this->mask;
844 if( !mask ) { // visible
845 int *autos = mwindow->edl->session->auto_conf->autos;
846 int modes = (1<<AUTOMATION_FADE) + (1<<AUTOMATION_SPEED) +
847 (7<<AUTOMATION_CAMERA_X) + (7<<AUTOMATION_PROJECTOR_X);
848 for( int i=0; i<AUTOMATION_TOTAL; modes>>=1, ++i ) {
849 if( !(modes & 1) ) continue;
850 if( autos[i] ) mask |= (1<<i);
853 mwindow->create_keyframes(mask, mode);
857 KeyframeCreateMenu::KeyframeCreateMenu(KeyframeCreate *keyframe_create)
860 this->keyframe_create = keyframe_create;
863 KeyframeCreate::KeyframeCreate(MWindow *mwindow)
864 : BC_MenuItem(_("Create keyframes..."))
866 this->mwindow = mwindow;
867 keyframe_create_menu = 0;
870 void KeyframeCreate::create_objects()
872 add_submenu(keyframe_create_menu = new KeyframeCreateMenu(this));
873 keyframe_create_menu->add_item(new KeyframeCreateItem(this, _("Visible"), 0));
874 keyframe_create_menu->add_item(new KeyframeCreateItem(this, _("Fade"),
875 (1<<AUTOMATION_FADE)));
876 keyframe_create_menu->add_item(new KeyframeCreateItem(this, _("Speed"),
877 (1<<AUTOMATION_SPEED)));
878 keyframe_create_menu->add_item(new KeyframeCreateItem(this, _("Camera XYZ"),
879 (7<<AUTOMATION_CAMERA_X)));
880 keyframe_create_menu->add_item(new KeyframeCreateItem(this, _("Projector XYZ"),
881 (7<<AUTOMATION_PROJECTOR_X)));
882 keyframe_create_menu->add_item(new KeyframeCreateItem(this, _("Fade+Speed+XYZ"),
883 (1<<AUTOMATION_FADE) + (1<<AUTOMATION_SPEED) +
884 (7<<AUTOMATION_CAMERA_X) + (7<<AUTOMATION_PROJECTOR_X)));
888 CutDefaultKeyframe::CutDefaultKeyframe(MWindow *mwindow)
889 : BC_MenuItem(_("Cut default keyframe"), _("Alt-x"), 'x')
892 this->mwindow = mwindow;
895 int CutDefaultKeyframe::handle_event()
897 if( mwindow->session->current_operation == NO_OPERATION )
898 mwindow->cut_default_keyframe();
902 CopyDefaultKeyframe::CopyDefaultKeyframe(MWindow *mwindow)
903 : BC_MenuItem(_("Copy default keyframe"), _("Alt-c"), 'c')
906 this->mwindow = mwindow;
909 int CopyDefaultKeyframe::handle_event()
911 if( mwindow->session->current_operation == NO_OPERATION )
912 mwindow->copy_default_keyframe();
916 PasteDefaultKeyframe::PasteDefaultKeyframe(MWindow *mwindow)
917 : BC_MenuItem(_("Paste default keyframe"), _("Alt-v"), 'v')
920 this->mwindow = mwindow;
923 int PasteDefaultKeyframe::handle_event()
925 if( mwindow->session->current_operation == NO_OPERATION )
926 mwindow->paste_default_keyframe();
930 ClearDefaultKeyframe::ClearDefaultKeyframe(MWindow *mwindow)
931 : BC_MenuItem(_("Clear default keyframe"), _("Alt-Del"), DELETE)
934 this->mwindow = mwindow;
937 int ClearDefaultKeyframe::handle_event()
939 if( mwindow->session->current_operation == NO_OPERATION )
940 mwindow->clear_default_keyframe();
944 Cut::Cut(MWindow *mwindow)
945 : BC_MenuItem(_("Split | Cut"), "x", 'x')
947 this->mwindow = mwindow;
950 int Cut::handle_event()
952 if( mwindow->session->current_operation == NO_OPERATION )
957 Copy::Copy(MWindow *mwindow)
958 : BC_MenuItem(_("Copy"), "c", 'c')
960 this->mwindow = mwindow;
963 int Copy::handle_event()
965 if( mwindow->session->current_operation == NO_OPERATION )
970 Paste::Paste(MWindow *mwindow)
971 : BC_MenuItem(_("Paste"), "v", 'v')
973 this->mwindow = mwindow;
976 int Paste::handle_event()
978 if( mwindow->session->current_operation == NO_OPERATION )
983 EditClearSubMenu::EditClearSubMenu(BC_MenuItem *menu_item)
986 this->menu_item = menu_item;
988 EditClearSubMenu::~EditClearSubMenu()
992 EditClearMenu::EditClearMenu(MWindow *mwindow)
993 : BC_MenuItem(_("Clear..."))
995 this->mwindow = mwindow;
996 this->clear_sub_menu = 0;
998 EditClearMenu::~EditClearMenu()
1002 void EditClearMenu::create_objects()
1004 add_submenu(clear_sub_menu = new EditClearSubMenu(this));
1005 clear_sub_menu->add_item(new Clear(mwindow));
1006 clear_sub_menu->add_item(new MuteSelection(mwindow));
1007 clear_sub_menu->add_item(new ClearSelect(mwindow));
1008 clear_sub_menu->add_item(new ClearLabels(mwindow));
1009 clear_sub_menu->add_item(new ClearHardEdges(mwindow));
1012 Clear::Clear(MWindow *mwindow)
1013 : BC_MenuItem(_("Clear"), _("Del"), DELETE)
1015 this->mwindow = mwindow;
1018 int Clear::handle_event()
1020 if( mwindow->session->current_operation == NO_OPERATION ) {
1021 mwindow->clear_entry();
1026 PasteSilence::PasteSilence(MWindow *mwindow)
1027 : BC_MenuItem(_("Paste silence"), _("Shift-Space"), ' ')
1029 this->mwindow = mwindow;
1033 int PasteSilence::handle_event()
1035 if( mwindow->session->current_operation == NO_OPERATION )
1036 mwindow->paste_silence();
1040 SelectAll::SelectAll(MWindow *mwindow)
1041 : BC_MenuItem(_("Select All"), "a", 'a')
1043 this->mwindow = mwindow;
1046 int SelectAll::handle_event()
1048 if( mwindow->session->current_operation == NO_OPERATION )
1049 mwindow->select_all();
1053 ClearHardEdges::ClearHardEdges(MWindow *mwindow) : BC_MenuItem(_("Clear Hard Edges"))
1055 this->mwindow = mwindow;
1058 int ClearHardEdges::handle_event()
1060 mwindow->clear_hard_edges();
1064 ClearLabels::ClearLabels(MWindow *mwindow) : BC_MenuItem(_("Clear labels"))
1066 this->mwindow = mwindow;
1069 int ClearLabels::handle_event()
1071 mwindow->clear_labels();
1075 ClearSelect::ClearSelect(MWindow *mwindow) : BC_MenuItem(_("Clear Select"),"Ctrl-Shift-A",'A')
1079 this->mwindow = mwindow;
1082 int ClearSelect::handle_event()
1084 mwindow->clear_select();
1088 CutCommercials::CutCommercials(MWindow *mwindow) : BC_MenuItem(_("Cut ads"))
1090 this->mwindow = mwindow;
1093 int CutCommercials::handle_event()
1095 mwindow->cut_commercials();
1099 DetachTransitions::DetachTransitions(MWindow *mwindow)
1100 : BC_MenuItem(_("Detach transitions"))
1102 this->mwindow = mwindow;
1105 int DetachTransitions::handle_event()
1107 mwindow->detach_transitions();
1111 MuteSelection::MuteSelection(MWindow *mwindow)
1112 : BC_MenuItem(_("Mute Region"), "m", 'm')
1114 this->mwindow = mwindow;
1117 int MuteSelection::handle_event()
1119 if( mwindow->session->current_operation == NO_OPERATION )
1120 mwindow->mute_selection();
1125 TrimSelection::TrimSelection(MWindow *mwindow)
1126 : BC_MenuItem(_("Trim Selection"))
1128 this->mwindow = mwindow;
1131 int TrimSelection::handle_event()
1133 mwindow->trim_selection();
1148 // ============================================= audio
1150 AddAudioTrack::AddAudioTrack(MWindow *mwindow)
1151 : BC_MenuItem(_("Add track"), "t", 't')
1153 this->mwindow = mwindow;
1156 int AddAudioTrack::handle_event()
1158 if( mwindow->session->current_operation == NO_OPERATION )
1159 mwindow->add_audio_track_entry(0, 0);
1163 DeleteAudioTrack::DeleteAudioTrack(MWindow *mwindow)
1164 : BC_MenuItem(_("Delete track"))
1166 this->mwindow = mwindow;
1169 int DeleteAudioTrack::handle_event()
1174 DefaultATransition::DefaultATransition(MWindow *mwindow)
1175 : BC_MenuItem(_("Default Transition"), "u", 'u')
1177 this->mwindow = mwindow;
1180 int DefaultATransition::handle_event()
1182 if( mwindow->session->current_operation == NO_OPERATION )
1183 mwindow->paste_audio_transition();
1188 MapAudio1::MapAudio1(MWindow *mwindow)
1189 : BC_MenuItem(_("Map 1:1"))
1191 this->mwindow = mwindow;
1194 int MapAudio1::handle_event()
1196 mwindow->map_audio(MWindow::AUDIO_1_TO_1);
1200 MapAudio2::MapAudio2(MWindow *mwindow)
1201 : BC_MenuItem(_("Map 5.1:2"))
1203 this->mwindow = mwindow;
1206 int MapAudio2::handle_event()
1208 mwindow->map_audio(MWindow::AUDIO_5_1_TO_2);
1215 // ============================================= video
1218 AddVideoTrack::AddVideoTrack(MWindow *mwindow)
1219 : BC_MenuItem(_("Add track"), _("Shift-T"), 'T')
1222 this->mwindow = mwindow;
1225 int AddVideoTrack::handle_event()
1227 if( mwindow->session->current_operation == NO_OPERATION )
1228 mwindow->add_video_track_entry(1, 0);
1233 DeleteVideoTrack::DeleteVideoTrack(MWindow *mwindow)
1234 : BC_MenuItem(_("Delete track"))
1236 this->mwindow = mwindow;
1239 int DeleteVideoTrack::handle_event()
1246 ResetTranslation::ResetTranslation(MWindow *mwindow)
1247 : BC_MenuItem(_("Reset Translation"))
1249 this->mwindow = mwindow;
1252 int ResetTranslation::handle_event()
1259 DefaultVTransition::DefaultVTransition(MWindow *mwindow)
1260 : BC_MenuItem(_("Default Transition"), _("Shift-U"), 'U')
1263 this->mwindow = mwindow;
1266 int DefaultVTransition::handle_event()
1268 if( mwindow->session->current_operation == NO_OPERATION )
1269 mwindow->paste_video_transition();
1286 // ============================================ settings
1288 DeleteTracks::DeleteTracks(MWindow *mwindow)
1289 : BC_MenuItem(_("Delete tracks"))
1291 this->mwindow = mwindow;
1294 int DeleteTracks::handle_event()
1296 mwindow->delete_tracks();
1300 DeleteFirstTrack::DeleteFirstTrack(MWindow *mwindow)
1301 : BC_MenuItem(_("Delete first track"), "Shift-D", 'D')
1304 this->mwindow = mwindow;
1307 int DeleteFirstTrack::handle_event()
1309 if( mwindow->session->current_operation == NO_OPERATION ) {
1310 Track *track = mwindow->edl->tracks->first;
1311 if( track ) mwindow->delete_track(track);
1316 DeleteLastTrack::DeleteLastTrack(MWindow *mwindow)
1317 : BC_MenuItem(_("Delete last track"), "Ctrl-d", 'd')
1320 this->mwindow = mwindow;
1323 int DeleteLastTrack::handle_event()
1325 if( mwindow->session->current_operation == NO_OPERATION ) {
1326 Track *track = mwindow->edl->tracks->last;
1327 if( track ) mwindow->delete_track(track);
1332 MoveTracksUp::MoveTracksUp(MWindow *mwindow)
1333 : BC_MenuItem(_("Move tracks up"), _("Shift-Up"), UP)
1335 this->mwindow = mwindow;
1339 int MoveTracksUp::handle_event()
1341 if( mwindow->session->current_operation == NO_OPERATION )
1342 mwindow->move_tracks_up();
1346 MoveTracksDown::MoveTracksDown(MWindow *mwindow)
1347 : BC_MenuItem(_("Move tracks down"), _("Shift-Down"), DOWN)
1349 this->mwindow = mwindow;
1353 int MoveTracksDown::handle_event()
1355 if( mwindow->session->current_operation == NO_OPERATION )
1356 mwindow->move_tracks_down();
1361 RollTracksUp::RollTracksUp(MWindow *mwindow)
1362 : BC_MenuItem(_("Roll tracks up"), _("Ctrl-Shift-Up"), UP)
1364 this->mwindow = mwindow;
1369 int RollTracksUp::handle_event()
1371 if( mwindow->session->current_operation == NO_OPERATION )
1372 mwindow->roll_tracks_up();
1376 RollTracksDown::RollTracksDown(MWindow *mwindow)
1377 : BC_MenuItem(_("Roll tracks down"), _("Ctrl-Shift-Down"), DOWN)
1379 this->mwindow = mwindow;
1384 int RollTracksDown::handle_event()
1386 if( mwindow->session->current_operation == NO_OPERATION )
1387 mwindow->roll_tracks_down();
1394 ConcatenateTracks::ConcatenateTracks(MWindow *mwindow)
1395 : BC_MenuItem(_("Concatenate tracks"))
1398 this->mwindow = mwindow;
1401 int ConcatenateTracks::handle_event()
1403 mwindow->concatenate_tracks();
1411 LoopPlayback::LoopPlayback(MWindow *mwindow)
1412 : BC_MenuItem(_("Loop Playback"), _("Shift-L"), 'L')
1414 this->mwindow = mwindow;
1415 set_checked(mwindow->edl->local_session->loop_playback);
1419 int LoopPlayback::handle_event()
1421 if( mwindow->session->current_operation == NO_OPERATION ) {
1422 mwindow->toggle_loop_playback();
1423 set_checked(mwindow->edl->local_session->loop_playback);
1430 // ============================================= subtitle
1433 AddSubttlTrack::AddSubttlTrack(MWindow *mwindow)
1434 : BC_MenuItem(_("Add subttl"), _("Shift-Y"), 'Y')
1437 this->mwindow = mwindow;
1440 int AddSubttlTrack::handle_event()
1442 if( mwindow->session->current_operation == NO_OPERATION )
1443 mwindow->add_subttl_track_entry(1, 0);
1447 PasteSubttl::PasteSubttl(MWindow *mwindow)
1448 : BC_MenuItem(_("paste subttl"), "y", 'y')
1450 this->mwindow = mwindow;
1453 int PasteSubttl::handle_event()
1455 if( mwindow->session->current_operation == NO_OPERATION )
1456 mwindow->gui->swindow->paste_subttl();
1461 SetBRenderActive::SetBRenderActive(MWindow *mwindow)
1462 : BC_MenuItem(_("Toggle background rendering"),_("Shift-G"),'G')
1464 this->mwindow = mwindow;
1468 int SetBRenderActive::handle_event()
1470 if( mwindow->session->current_operation == NO_OPERATION ) {
1471 int v = mwindow->brender_active ? 0 : 1;
1473 mwindow->set_brender_active(v);
1479 LabelsFollowEdits::LabelsFollowEdits(MWindow *mwindow)
1480 : BC_MenuItem(_("Edit labels"))
1482 this->mwindow = mwindow;
1483 set_checked(mwindow->edl->session->labels_follow_edits);
1486 int LabelsFollowEdits::handle_event()
1488 set_checked(get_checked() ^ 1);
1489 mwindow->set_labels_follow_edits(get_checked());
1496 PluginsFollowEdits::PluginsFollowEdits(MWindow *mwindow)
1497 : BC_MenuItem(_("Edit effects"))
1499 this->mwindow = mwindow;
1500 set_checked(mwindow->edl->session->plugins_follow_edits);
1503 int PluginsFollowEdits::handle_event()
1505 set_checked(get_checked() ^ 1);
1506 mwindow->edl->session->plugins_follow_edits = get_checked();
1513 KeyframesFollowEdits::KeyframesFollowEdits(MWindow *mwindow)
1514 : BC_MenuItem(_("Keyframes follow edits"))
1516 this->mwindow = mwindow;
1517 set_checked(mwindow->edl->session->autos_follow_edits);
1520 int KeyframesFollowEdits::handle_event()
1522 mwindow->edl->session->autos_follow_edits ^= 1;
1523 set_checked(!get_checked());
1528 CursorOnFrames::CursorOnFrames(MWindow *mwindow)
1529 : BC_MenuItem(_("Align cursor on frames"),_("Ctrl-a"),'a')
1531 this->mwindow = mwindow;
1532 set_checked(mwindow->edl->session->cursor_on_frames);
1536 int CursorOnFrames::handle_event()
1538 mwindow->edl->session->cursor_on_frames = !mwindow->edl->session->cursor_on_frames;
1539 set_checked(mwindow->edl->session->cursor_on_frames);
1544 TypelessKeyframes::TypelessKeyframes(MWindow *mwindow)
1545 : BC_MenuItem(_("Typeless keyframes"))
1547 this->mwindow = mwindow;
1548 set_checked(mwindow->edl->session->typeless_keyframes);
1551 int TypelessKeyframes::handle_event()
1553 mwindow->edl->session->typeless_keyframes = !mwindow->edl->session->typeless_keyframes;
1554 set_checked(mwindow->edl->session->typeless_keyframes);
1559 ScrubSpeed::ScrubSpeed(MWindow *mwindow)
1560 : BC_MenuItem(_("Slow Shuttle"))
1562 this->mwindow = mwindow;
1565 int ScrubSpeed::handle_event()
1567 if(mwindow->edl->session->scrub_speed == .5)
1569 mwindow->edl->session->scrub_speed = 2;
1570 set_text(_("Slow Shuttle"));
1574 mwindow->edl->session->scrub_speed = .5;
1575 set_text(_("Fast Shuttle"));
1580 SaveSettingsNow::SaveSettingsNow(MWindow *mwindow)
1581 : BC_MenuItem(_("Save settings now"),_("Ctrl-Shift-S"),'S')
1583 this->mwindow = mwindow;
1588 int SaveSettingsNow::handle_event()
1590 mwindow->save_defaults();
1591 mwindow->save_backup();
1592 mwindow->gui->show_message(_("Saved settings."));
1598 // ============================================ window
1604 ShowVWindow::ShowVWindow(MWindow *mwindow)
1605 : BC_MenuItem(_("Show Viewer"))
1607 this->mwindow = mwindow;
1608 set_checked(mwindow->session->show_vwindow);
1610 int ShowVWindow::handle_event()
1612 if( mwindow->session->current_operation == NO_OPERATION ) {
1613 mwindow->gui->unlock_window();
1614 if( !mwindow->session->show_vwindow )
1615 mwindow->show_vwindow(1);
1617 mwindow->hide_vwindow(1);
1618 mwindow->gui->lock_window("ShowVWindow::handle_event");
1619 set_checked(mwindow->session->show_vwindow);
1624 ShowAWindow::ShowAWindow(MWindow *mwindow)
1625 : BC_MenuItem(_("Show Resources"))
1627 this->mwindow = mwindow;
1628 set_checked(mwindow->session->show_awindow);
1630 int ShowAWindow::handle_event()
1632 if( mwindow->session->current_operation == NO_OPERATION ) {
1633 mwindow->gui->unlock_window();
1634 if( !mwindow->session->show_awindow )
1635 mwindow->show_awindow();
1637 mwindow->hide_awindow();
1638 mwindow->gui->lock_window("ShowAWindow::handle_event");
1639 set_checked(mwindow->session->show_awindow);
1645 ShowCWindow::ShowCWindow(MWindow *mwindow)
1646 : BC_MenuItem(_("Show Compositor"))
1648 this->mwindow = mwindow;
1649 set_checked(mwindow->session->show_cwindow);
1651 int ShowCWindow::handle_event()
1653 if( mwindow->session->current_operation == NO_OPERATION ) {
1654 mwindow->gui->unlock_window();
1655 if( !mwindow->session->show_cwindow )
1656 mwindow->show_cwindow();
1658 mwindow->hide_cwindow();
1659 mwindow->gui->lock_window("ShowCWindow::handle_event");
1660 set_checked(mwindow->session->show_cwindow);
1666 ShowGWindow::ShowGWindow(MWindow *mwindow)
1667 : BC_MenuItem(_("Show Overlays"), _("Ctrl-0"), '0')
1669 this->mwindow = mwindow;
1671 set_checked(mwindow->session->show_gwindow);
1673 int ShowGWindow::handle_event()
1675 if( mwindow->session->current_operation == NO_OPERATION ) {
1676 mwindow->gui->unlock_window();
1677 if( !mwindow->session->show_gwindow )
1678 mwindow->show_gwindow();
1680 mwindow->hide_gwindow();
1681 mwindow->gui->lock_window("ShowGWindow::handle_event");
1682 set_checked(mwindow->session->show_gwindow);
1688 ShowLWindow::ShowLWindow(MWindow *mwindow)
1689 : BC_MenuItem(_("Show Levels"))
1691 this->mwindow = mwindow;
1692 set_checked(mwindow->session->show_lwindow);
1694 int ShowLWindow::handle_event()
1696 if( mwindow->session->current_operation == NO_OPERATION ) {
1698 mwindow->gui->unlock_window();
1699 if( !mwindow->session->show_lwindow )
1700 mwindow->show_lwindow();
1702 mwindow->hide_lwindow();
1703 mwindow->gui->lock_window("ShowLWindow::handle_event");
1704 set_checked(mwindow->session->show_lwindow);
1709 TileWindows::TileWindows(MWindow *mwindow, const char *item_title, int config,
1710 const char *hot_keytext, int hot_key)
1711 : BC_MenuItem(item_title, hot_keytext, hot_key)
1713 this->mwindow = mwindow;
1714 this->config = config;
1715 if( hot_key ) set_ctrl(1);
1717 int TileWindows::handle_event()
1719 if( mwindow->session->current_operation == NO_OPERATION ) {
1720 int window_config = config >= 0 ? config :
1721 mwindow->session->window_config;
1722 if( mwindow->tile_windows(window_config) ) {
1723 mwindow->restart_status = 1;
1724 mwindow->gui->set_done(0);
1730 SplitX::SplitX(MWindow *mwindow)
1731 : BC_MenuItem(_("Split X pane"), _("Ctrl-1"), '1')
1733 this->mwindow = mwindow;
1735 set_checked(mwindow->gui->pane[TOP_RIGHT_PANE] != 0);
1737 int SplitX::handle_event()
1739 if( mwindow->session->current_operation == NO_OPERATION )
1744 SplitY::SplitY(MWindow *mwindow)
1745 : BC_MenuItem(_("Split Y pane"), _("Ctrl-2"), '2')
1747 this->mwindow = mwindow;
1749 set_checked(mwindow->gui->pane[BOTTOM_LEFT_PANE] != 0);
1751 int SplitY::handle_event()
1753 if( mwindow->session->current_operation == NO_OPERATION )
1759 MixerItems::MixerItems(MWindow *mwindow)
1760 : BC_MenuItem(_("Mixers..."))
1762 this->mwindow = mwindow;
1765 void MixerItems::create_objects()
1767 BC_SubMenu *mixer_submenu = new BC_SubMenu();
1768 add_submenu(mixer_submenu);
1769 mixer_submenu->add_submenuitem(new MixerViewer(this));
1770 mixer_submenu->add_submenuitem(new DragTileMixers(this));
1771 mixer_submenu->add_submenuitem(new AlignMixers(this));
1772 mixer_submenu->add_submenuitem(new MixMasters(this));
1775 int MixerItems::activate_submenu()
1777 BC_SubMenu *mixer_submenu = (BC_SubMenu *)get_submenu();
1778 int k = mixer_submenu->total_items();
1780 MixerItem *mixer_item = (MixerItem *)mixer_submenu->get_item(k);
1781 if( mixer_item->idx < 0 ) continue;
1782 mixer_submenu->del_item(mixer_item);
1784 int n = mwindow->edl->mixers.size();
1785 for( int i=0; i<n; ++i ) {
1786 Mixer *mixer = mwindow->edl->mixers[i];
1787 if( !mixer ) continue;
1788 MixerItem *mixer_item = new MixerItem(this, mixer->title, mixer->idx);
1789 mixer_submenu->add_submenuitem(mixer_item);
1791 return BC_MenuItem::activate_submenu();
1794 MixerItem::MixerItem(MixerItems *mixer_items, const char *text, int idx)
1797 this->mixer_items = mixer_items;
1801 MixerItem::MixerItem(MixerItems *mixer_items, const char *text, const char *hotkey_text, int hotkey)
1802 : BC_MenuItem(text, hotkey_text, hotkey)
1804 this->mixer_items = mixer_items;
1808 int MixerItem::handle_event()
1810 if( idx < 0 ) return 0;
1811 MWindow *mwindow = mixer_items->mwindow;
1812 Mixer *mixer = mwindow->edl->mixers.get_mixer(idx);
1813 if( !mixer ) return 0;
1814 ZWindow *zwindow = mwindow->get_mixer(idx);
1816 zwindow = mwindow->get_mixer(mixer);
1817 if( !zwindow->zgui ) {
1818 zwindow->set_title(mixer->title);
1821 zwindow->zgui->lock_window("MixerItem::handle_event");
1822 zwindow->zgui->raise_window();
1823 zwindow->zgui->unlock_window();
1824 mwindow->refresh_mixers();
1828 MixerViewer::MixerViewer(MixerItems *mixer_items)
1829 : MixerItem(mixer_items, _("Mixer Viewer"), _("Shift-M"), 'M')
1834 int MixerViewer::handle_event()
1836 MWindow *mwindow = mixer_items->mwindow;
1837 mwindow->start_mixer();
1841 DragTileMixers::DragTileMixers(MixerItems *mixer_items)
1842 : MixerItem(mixer_items, _("Drag Tile mixers"), "Alt-t", 't')
1848 DragTileMixers::~DragTileMixers()
1853 int DragTileMixers::handle_event()
1856 MWindow *mwindow = mixer_items->mwindow;
1857 drag_box = new TileMixersDragBox(mwindow->gui);
1859 if( !drag_box->running() )
1860 drag_box->start(this);
1864 TileMixersDragBox::TileMixersDragBox(MWindowGUI *gui)
1870 void TileMixersDragBox::start(DragTileMixers *tile_mixers)
1872 this->tile_mixers = tile_mixers;
1876 int TileMixersDragBox::handle_done_event(int x0, int y0, int x1, int y1)
1878 MWindow *mwindow = tile_mixers->mixer_items->mwindow;
1879 if( x0 >= x1 || y0 >= y1 ) x0 = x1 = y0 = y1 = 0;
1880 mwindow->session->tile_mixers_x = x0;
1881 mwindow->session->tile_mixers_y = y0;
1882 mwindow->session->tile_mixers_w = x1 - x0;
1883 mwindow->session->tile_mixers_h = y1 - y0;
1884 mwindow->tile_mixers(x0, y0, x1, y1);
1889 AlignMixers::AlignMixers(MixerItems *mixer_items)
1890 : MixerItem(mixer_items, _("Align mixers"), "", 0)
1894 int AlignMixers::handle_event()
1896 MWindow *mwindow = mixer_items->mwindow;
1898 mwindow->gui->get_abs_cursor(wx, wy);
1899 mwindow->mixers_align->start_dialog(wx, wy);
1903 MixMasters::MixMasters(MixerItems *mixer_items)
1904 : MixerItem(mixer_items, _("Mix masters"), "", 0)
1908 int MixMasters::handle_event()
1910 MWindow *mwindow = mixer_items->mwindow;
1911 mwindow->mix_masters();
1916 AlignTimecodes::AlignTimecodes(MWindow *mwindow)
1917 : BC_MenuItem(_("Align Timecodes"))
1919 this->mwindow = mwindow;
1922 int AlignTimecodes::handle_event()
1924 mwindow->align_timecodes();
1929 LoadLayoutItem::LoadLayoutItem(LoadLayout *load_layout, const char *text, int idx, int hotkey)
1930 : BC_MenuItem(text, "", hotkey)
1933 this->load_layout = load_layout;
1935 char hot_txt[BCSTRLEN];
1936 sprintf(hot_txt, _("Ctrl-Shift+F%d"), hotkey-KEY_F1+1);
1937 set_ctrl(); set_shift();
1938 set_hotkey_text(hot_txt);
1943 int LoadLayoutItem::handle_event()
1945 // key_press hotkey skips over activate_submenu
1946 load_layout->update();
1947 MWindow *mwindow = load_layout->mwindow;
1948 switch( load_layout->action ) {
1950 mwindow->load_layout(layout_file);
1954 mwindow->gui->get_abs_cursor(wx, wy);
1955 load_layout->layout_dialog->start_confirm_dialog(wx, wy, idx);
1961 LoadLayout::LoadLayout(MWindow *mwindow, const char *text, int action)
1964 this->mwindow = mwindow;
1965 this->action = action;
1966 this->layout_dialog = new LoadLayoutDialog(this);
1969 LoadLayout::~LoadLayout()
1971 delete layout_dialog;
1974 void LoadLayout::create_objects()
1976 BC_SubMenu *layout_submenu = new BC_SubMenu();
1977 add_submenu(layout_submenu);
1979 for( int i=0; i<LAYOUTS_MAX; ++i ) {
1980 char text[BCSTRLEN];
1981 sprintf(text, _("Layout %d"), i+1);
1982 LoadLayoutItem *item = new LoadLayoutItem(this, text, i,
1983 action==LAYOUT_LOAD ? KEY_F1+i : 0);
1984 layout_submenu->add_submenuitem(item);
1988 int LoadLayout::activate_submenu()
1991 return BC_MenuItem::activate_submenu();
1994 void LoadLayout::update()
1997 fs.set_filter("layout*_rc");
1998 int ret = fs.update(File::get_config_path());
1999 int sz = !ret ? fs.dir_list.size() : 0;
2000 BC_SubMenu *layout_submenu = get_submenu();
2002 for( int i=0; i<LAYOUTS_MAX; ++i ) {
2003 LoadLayoutItem* item = (LoadLayoutItem *)
2004 layout_submenu->get_item(i);
2005 char layout_text[BCSTRLEN]; layout_text[0] = 0;
2006 int n = sz, id = i+1;
2008 char *np = fs.dir_list[n]->name;
2009 char *cp = strrchr(np, '_'), *bp = 0;
2010 int no = strtol(np+6, &bp, 10);
2011 if( no != id || !bp ) continue;
2012 if( bp == cp ) { n = -1; break; }
2013 if( *bp++ == '_' && bp < cp && !strcmp(cp, "_rc") ) {
2014 int k = cp - bp; char *tp = layout_text;
2015 if( k > LAYOUT_NAME_LEN ) k = LAYOUT_NAME_LEN;
2016 while( --k >= 0 ) *tp++ = *bp++;
2021 strcpy(item->layout_text, layout_text);
2022 char *lp = item->layout_file;
2023 int k = sprintf(lp, LAYOUT_FILE, id);
2024 if( n >= 0 && layout_text[0] )
2025 sprintf(lp + k-2, "%s_rc", layout_text);
2027 sprintf(layout_text, _("Layout %d"), id);
2028 item->set_text(layout_text);
2032 LoadLayoutDialog::LoadLayoutDialog(LoadLayout *load_layout)
2034 this->load_layout = load_layout;
2040 LoadLayoutDialog::~LoadLayoutDialog()
2045 void LoadLayoutDialog::handle_done_event(int result)
2047 if( result ) return;
2048 char layout_file[BCSTRLEN];
2049 BC_SubMenu *layout_submenu = load_layout->get_submenu();
2050 LoadLayoutItem* item =
2051 (LoadLayoutItem *) layout_submenu->get_item(idx);
2052 snprintf(layout_file, sizeof(layout_file), "%s", item->layout_file);
2053 load_layout->mwindow->delete_layout(layout_file);
2054 int k = sprintf(layout_file, LAYOUT_FILE, idx+1);
2055 const char *text = lgui->name_text->get_text();
2057 snprintf(layout_file + k-2, sizeof(layout_file)-k+2, "%s_rc", text);
2058 load_layout->mwindow->save_layout(layout_file);
2061 void LoadLayoutDialog::handle_close_event(int result)
2066 BC_Window *LoadLayoutDialog::new_gui()
2068 lgui = new LoadLayoutConfirm(this, wx, wy);
2069 lgui->create_objects();
2073 void LoadLayoutDialog::start_confirm_dialog(int wx, int wy, int idx)
2076 this->wx = wx; this->wy = wy;
2081 LoadLayoutNameText::LoadLayoutNameText(LoadLayoutConfirm *confirm,
2082 int x, int y, int w, const char *text)
2083 : BC_TextBox(x, y, w, 1, text)
2085 this->confirm = confirm;
2088 LoadLayoutNameText::~LoadLayoutNameText()
2092 int LoadLayoutNameText::handle_event()
2094 const char *text = get_text();
2095 int len = strlen(text), k = 0;
2096 char new_text[BCTEXTLEN];
2097 for( int i=0; i<len; ++i ) {
2099 if( (ch>='A' && ch<='Z') || (ch>='a' && ch<='z') ||
2100 (ch>='0' && ch<='9') || ch=='_' )
2103 new_text[k] = 0; len = k;
2104 int i = len - LAYOUT_NAME_LEN;
2107 while( i < len ) new_text[k++] = new_text[i++];
2114 LoadLayoutConfirm::LoadLayoutConfirm(LoadLayoutDialog *layout_dialog, int x, int y)
2115 : BC_Window(_(PROGRAM_NAME ": Layout"), x, y, xS(300),yS(140), xS(300),yS(140), 0)
2117 this->layout_dialog = layout_dialog;
2118 // *** CONTEXT_HELP ***
2119 context_help_set_keyword("Window Layouts");
2122 LoadLayoutConfirm::~LoadLayoutConfirm()
2126 void LoadLayoutConfirm::create_objects()
2128 int xs10 = xS(10), xs20 = xS(20);
2130 lock_window("LoadLayoutConfirm::create_objects");
2131 int x = xs10, y = ys10;
2132 BC_SubMenu *layout_submenu = layout_dialog->load_layout->get_submenu();
2133 LoadLayoutItem *item = (LoadLayoutItem *)
2134 layout_submenu->get_item(layout_dialog->idx);
2136 add_subwindow(title = new BC_Title(x, y, _("Layout Name:")));
2137 int x1 = x + title->get_w() + xs10;
2138 add_subwindow(title = new BC_Title(x1, y, item->get_text()));
2139 y += title->get_h() + ys10;
2140 add_subwindow(name_text = new LoadLayoutNameText(this,
2141 x, y, get_w()-x-xs20, item->layout_text));
2142 y += name_text->get_h();
2144 char legend[BCTEXTLEN];
2145 sprintf(legend, _("a-z,A-Z,0-9_ only, %dch max"), LAYOUT_NAME_LEN);
2146 add_subwindow(title = new BC_Title(x1, y, legend));
2147 add_subwindow(new BC_OKButton(this));
2148 add_subwindow(new BC_CancelButton(this));
2153 LoadRecentItem::LoadRecentItem(const char *path)
2155 this->path = cstrdup(path);
2158 LoadRecentItem::~LoadRecentItem()
2163 int LoadRecentItems::add_load(char *path)
2165 // test for existing copy
2167 char name[BCTEXTLEN], text[BCTEXTLEN];
2168 fs.extract_name(name, path);
2169 int loads_total = size();
2170 int ret = 0, k = loads_total;
2171 LoadRecentItem *load_item = 0;
2173 for( int i=0; !ret && i<loads_total; ++i ) {
2175 fs.extract_name(text, load_item->path);
2176 if( strcmp(name, text) ) continue;
2177 k = i; ret = 1; // already exists, move to top
2179 if( !ret ) { // adding a new one
2180 while( loads_total >= TOTAL_LOADS )
2181 remove_object_number(--loads_total);
2182 insert(new LoadRecentItem(path), 0);
2184 else if( k > 0 ) { // cycle loads
2185 while( --k >= 0 ) set(k+1, get(k));
2191 LoadRecentItems::LoadRecentItems()
2195 LoadRecentItems::~LoadRecentItems()
2197 remove_all_objects();
2200 LoadRecent::LoadRecent(MWindow *mwindow, MainMenu *main_menu)
2201 : BC_MenuItem(_("Load Recent..."))
2203 this->mwindow = mwindow;
2204 this->main_menu = main_menu;
2207 LoadRecent::~LoadRecent()
2211 void LoadRecent::create_objects()
2213 add_submenu(submenu = new LoadRecentSubMenu(this));
2216 LoadPrevious *LoadRecent::get_next_item()
2218 int k = total_items++;
2219 if( k < submenu->total_items() )
2220 return (LoadPrevious *)submenu->get_item(k);
2221 LoadPrevious *load_prev = new LoadPrevious(mwindow, main_menu->load_file);
2222 submenu->add_item(load_prev);
2226 int LoadRecent::activate_submenu()
2230 if( total_items > 0 ) {
2231 LoadPrevious *load_prev = get_next_item();
2232 load_prev->set_text("-");
2233 load_prev->set_path("");
2236 while( total_items < submenu->total_items() )
2237 submenu->del_item(0);
2238 return BC_MenuItem::activate_submenu();
2241 void LoadRecent::scan_items(int use_xml)
2244 int loads_total = main_menu->load.size();
2245 for( int i=0; i<loads_total; ++i ) {
2246 LoadRecentItem *recent = main_menu->load[i];
2247 char name[BCTEXTLEN];
2248 fs.extract_name(name, recent->path);
2249 const char *cp = strrchr(name, '.');
2250 if( !cp || strcasecmp(cp+1,"xml") ? use_xml : !use_xml ) continue;
2251 LoadPrevious *load_prev = get_next_item();
2252 load_prev->set_text(name);
2253 load_prev->set_path(recent->path);
2257 LoadRecentSubMenu::LoadRecentSubMenu(LoadRecent *load_recent)
2260 this->load_recent = load_recent;
2263 LoadRecentSubMenu::~LoadRecentSubMenu()