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"
41 #include "filesystem.h"
43 #include "floatauto.h"
46 #include "levelwindow.h"
48 #include "localsession.h"
49 #include "mainclock.h"
51 #include "mainsession.h"
53 #include "menuattacheffect.h"
54 #include "menuattachtransition.h"
55 #include "menuaeffects.h"
56 #include "menueditlength.h"
57 #include "menutransitionlength.h"
58 #include "menuveffects.h"
59 #include "mixersalign.h"
60 #include "mwindowgui.h"
64 #include "playbackengine.h"
65 #include "preferences.h"
67 #include "preferencesthread.h"
72 #include "setformat.h"
75 #include "trackcanvas.h"
77 #include "transition.h"
78 #include "transportque.h"
81 #include "exportedl.h"
86 MainMenu::MainMenu(MWindow *mwindow, MWindowGUI *gui, int w)
90 this->mwindow = mwindow;
97 void MainMenu::create_objects()
99 BC_Menu *viewmenu, *windowmenu, *settingsmenu, *trackmenu;
100 PreferencesMenuitem *preferences;
102 add_menu(filemenu = new BC_Menu(_("File")));
103 filemenu->add_item(new_project = new NewProject(mwindow));
104 new_project->create_objects();
107 filemenu->add_item(load_file = new Load(mwindow, this));
108 load_file->create_objects();
109 filemenu->add_item(load_recent = new LoadRecent(mwindow, this));
110 load_recent->create_objects();
112 // new and load can be undone so no need to prompt save
113 Save *save; // affected by saveas
114 filemenu->add_item(save = new Save(mwindow));
116 filemenu->add_item(saveas = new SaveAs(mwindow));
117 save->create_objects(saveas);
118 saveas->set_mainmenu(this);
119 SaveProject *save_project;
120 filemenu->add_item(save_project = new SaveProject(mwindow));
122 filemenu->add_item(record_menu_item = new RecordMenuItem(mwindow));
124 filemenu->add_item(new ChannelScan(mwindow));
126 #ifdef HAVE_COMMERCIAL
127 if( mwindow->has_commercials() )
128 filemenu->add_item(new DbWindowScan(mwindow));
130 filemenu->add_item(new SubttlSWin(mwindow));
132 filemenu->add_item(render = new RenderItem(mwindow));
133 filemenu->add_item(new ExportEDLItem(mwindow));
134 filemenu->add_item(new BatchRenderMenuItem(mwindow));
135 filemenu->add_item(new CreateBD_MenuItem(mwindow));
136 filemenu->add_item(new CreateDVD_MenuItem(mwindow));
137 filemenu->add_item(new BC_MenuItem("-"));
138 filemenu->add_item(quit_program = new Quit(mwindow));
139 quit_program->create_objects(save);
140 filemenu->add_item(dump_menu = new MainDumpsMenu(mwindow));
141 dump_menu->create_objects();
142 filemenu->add_item(new LoadBackup(mwindow));
143 filemenu->add_item(new SaveBackup(mwindow));
146 add_menu(editmenu = new BC_Menu(_("Edit")));
147 editmenu->add_item(undo = new Undo(mwindow));
148 editmenu->add_item(redo = new Redo(mwindow));
149 editmenu->add_item(new BC_MenuItem("-"));
150 editmenu->add_item(new Cut(mwindow));
151 editmenu->add_item(new Copy(mwindow));
152 editmenu->add_item(new Paste(mwindow));
153 editmenu->add_item(new PasteSilence(mwindow));
154 editmenu->add_item(clear_menu = new EditClearMenu(mwindow));
155 clear_menu->create_objects();
156 editmenu->add_item(new TrimSelection(mwindow));
157 editmenu->add_item(new SelectAll(mwindow));
158 editmenu->add_item(new BC_MenuItem("-"));
159 editmenu->add_item(new MenuEditShuffle(mwindow));
160 editmenu->add_item(new MenuEditReverse(mwindow));
161 editmenu->add_item(new MenuEditLength(mwindow));
162 editmenu->add_item(new MenuEditAlign(mwindow));
163 editmenu->add_item(new MenuTransitionLength(mwindow));
164 editmenu->add_item(new DetachTransitions(mwindow));
165 editmenu->add_item(new BC_MenuItem("-"));
166 editmenu->add_item(new CutCommercials(mwindow));
167 editmenu->add_item(new PasteSubttl(mwindow));
169 BC_Menu *keyframemenu;
170 add_menu(keyframemenu = new BC_Menu(_("Keyframes")));
171 keyframemenu->add_item(new CutKeyframes(mwindow));
172 keyframemenu->add_item(new CopyKeyframes(mwindow));
173 keyframemenu->add_item(new PasteKeyframes(mwindow));
174 keyframemenu->add_item(new ClearKeyframes(mwindow));
175 keyframemenu->add_item(new StraightenKeyframes(mwindow));
176 keyframemenu->add_item(new BendKeyframes(mwindow));
177 keyframemenu->add_item(keyframe_curve_type = new KeyframeCurveType(mwindow));
178 keyframe_curve_type->create_objects();
179 keyframe_curve_type->update(mwindow->edl->local_session->floatauto_type);
180 keyframemenu->add_item(new BC_MenuItem("-"));
181 keyframemenu->add_item(new CopyDefaultKeyframe(mwindow));
182 keyframemenu->add_item(new PasteDefaultKeyframe(mwindow));
187 add_menu(audiomenu = new BC_Menu(_("Audio")));
188 audiomenu->add_item(new AddAudioTrack(mwindow));
189 audiomenu->add_item(new DefaultATransition(mwindow));
190 audiomenu->add_item(new MapAudio1(mwindow));
191 audiomenu->add_item(new MapAudio2(mwindow));
192 audiomenu->add_item(new MenuAttachTransition(mwindow, TRACK_AUDIO));
193 audiomenu->add_item(new MenuAttachEffect(mwindow, TRACK_AUDIO));
194 audiomenu->add_item(aeffects = new MenuAEffects(mwindow));
196 add_menu(videomenu = new BC_Menu(_("Video")));
197 videomenu->add_item(new AddVideoTrack(mwindow));
198 videomenu->add_item(new DefaultVTransition(mwindow));
199 videomenu->add_item(new MenuAttachTransition(mwindow, TRACK_VIDEO));
200 videomenu->add_item(new MenuAttachEffect(mwindow, TRACK_VIDEO));
201 videomenu->add_item(veffects = new MenuVEffects(mwindow));
203 add_menu(trackmenu = new BC_Menu(_("Tracks")));
204 trackmenu->add_item(new MoveTracksUp(mwindow));
205 trackmenu->add_item(new MoveTracksDown(mwindow));
206 trackmenu->add_item(new DeleteTracks(mwindow));
207 trackmenu->add_item(new DeleteFirstTrack(mwindow));
208 trackmenu->add_item(new DeleteLastTrack(mwindow));
209 trackmenu->add_item(new ConcatenateTracks(mwindow));
210 AppendTracks *append_tracks;
211 trackmenu->add_item(append_tracks = new AppendTracks(mwindow));
212 append_tracks->create_objects();
213 trackmenu->add_item(new AddSubttlTrack(mwindow));
215 add_menu(settingsmenu = new BC_Menu(_("Settings")));
217 settingsmenu->add_item(new SetFormat(mwindow));
218 settingsmenu->add_item(preferences = new PreferencesMenuitem(mwindow));
219 ProxyMenuItem *proxy;
220 settingsmenu->add_item(proxy = new ProxyMenuItem(mwindow));
221 proxy->create_objects();
222 ConvertMenuItem *convert;
223 settingsmenu->add_item(convert = new ConvertMenuItem(mwindow));
224 convert->create_objects();
225 mwindow->preferences_thread = preferences->thread;
226 settingsmenu->add_item(cursor_on_frames = new CursorOnFrames(mwindow));
227 settingsmenu->add_item(labels_follow_edits = new LabelsFollowEdits(mwindow));
228 settingsmenu->add_item(plugins_follow_edits = new PluginsFollowEdits(mwindow));
229 settingsmenu->add_item(keyframes_follow_edits = new KeyframesFollowEdits(mwindow));
230 settingsmenu->add_item(typeless_keyframes = new TypelessKeyframes(mwindow));
231 settingsmenu->add_item(new BC_MenuItem("-"));
232 settingsmenu->add_item(new SaveSettingsNow(mwindow));
233 settingsmenu->add_item(loop_playback = new LoopPlayback(mwindow));
234 settingsmenu->add_item(brender_active = new SetBRenderActive(mwindow));
235 // set scrubbing speed
236 // ScrubSpeed *scrub_speed;
237 // settingsmenu->add_item(scrub_speed = new ScrubSpeed(mwindow));
238 // if(mwindow->edl->session->scrub_speed == .5)
239 // scrub_speed->set_text(_("Fast Shuttle"));
246 add_menu(viewmenu = new BC_Menu(_("View")));
247 viewmenu->add_item(show_assets = new ShowAssets(mwindow, "0"));
248 viewmenu->add_item(show_titles = new ShowTitles(mwindow, "1"));
249 viewmenu->add_item(show_transitions = new ShowTransitions(mwindow, "2"));
250 viewmenu->add_item(fade_automation = new ShowAutomation(mwindow, _("Fade"), "3", AUTOMATION_FADE));
251 viewmenu->add_item(mute_automation = new ShowAutomation(mwindow, _("Mute"), "4", AUTOMATION_MUTE));
252 viewmenu->add_item(mode_automation = new ShowAutomation(mwindow, _("Overlay mode"), "5", AUTOMATION_MODE));
253 viewmenu->add_item(pan_automation = new ShowAutomation(mwindow, _("Pan"), "6", AUTOMATION_PAN));
254 viewmenu->add_item(plugin_automation = new PluginAutomation(mwindow, "7"));
255 viewmenu->add_item(mask_automation = new ShowAutomation(mwindow, _("Mask"), "8", AUTOMATION_MASK));
256 viewmenu->add_item(speed_automation = new ShowAutomation(mwindow, _("Speed"), "9", AUTOMATION_SPEED));
258 camera_x = new ShowAutomation(mwindow, _("Camera X"), "Ctrl-Shift-X", AUTOMATION_CAMERA_X);
259 camera_x->set_ctrl(); camera_x->set_shift(); viewmenu->add_item(camera_x);
260 camera_y = new ShowAutomation(mwindow, _("Camera Y"), "Ctrl-Shift-Y", AUTOMATION_CAMERA_Y);
261 camera_y->set_ctrl(); camera_y->set_shift(); viewmenu->add_item(camera_y);
262 camera_z = new ShowAutomation(mwindow, _("Camera Z"), "Ctrl-Shift-Z", AUTOMATION_CAMERA_Z);
263 camera_z->set_ctrl(); camera_z->set_shift(); viewmenu->add_item(camera_z);
264 project_x = new ShowAutomation(mwindow, _("Projector X"), "Alt-Shift-X", AUTOMATION_PROJECTOR_X);
265 project_x->set_alt(); project_x->set_shift(); viewmenu->add_item(project_x);
266 project_y = new ShowAutomation(mwindow, _("Projector Y"), "Alt-Shift-Y", AUTOMATION_PROJECTOR_Y);
267 project_y->set_alt(); project_y->set_shift(); viewmenu->add_item(project_y);
268 project_z = new ShowAutomation(mwindow, _("Projector Z"), "Alt-Shift-Z", AUTOMATION_PROJECTOR_Z);
269 project_z->set_alt(); project_z->set_shift(); viewmenu->add_item(project_z);
271 add_menu(windowmenu = new BC_Menu(_("Window")));
272 windowmenu->add_item(show_vwindow = new ShowVWindow(mwindow));
273 windowmenu->add_item(show_awindow = new ShowAWindow(mwindow));
274 windowmenu->add_item(show_cwindow = new ShowCWindow(mwindow));
275 windowmenu->add_item(show_gwindow = new ShowGWindow(mwindow));
276 windowmenu->add_item(show_lwindow = new ShowLWindow(mwindow));
277 windowmenu->add_item(new BC_MenuItem("-"));
278 windowmenu->add_item(split_x = new SplitX(mwindow));
279 windowmenu->add_item(split_y = new SplitY(mwindow));
280 windowmenu->add_item(mixer_items = new MixerItems(mwindow));
281 mixer_items->create_objects();
282 windowmenu->add_item(new TileWindows(mwindow,_("Tile left"),0));
283 windowmenu->add_item(new TileWindows(mwindow,_("Tile right"),1));
284 windowmenu->add_item(new BC_MenuItem("-"));
286 windowmenu->add_item(new TileWindows(mwindow,_("Default positions"),-1,_("Ctrl-P"),'p'));
287 windowmenu->add_item(load_layout = new LoadLayout(mwindow, _("Load layout..."),LAYOUT_LOAD));
288 load_layout->create_objects();
289 windowmenu->add_item(save_layout = new LoadLayout(mwindow, _("Save layout..."),LAYOUT_SAVE));
290 save_layout->create_objects();
293 int MainMenu::load_defaults(BC_Hash *defaults)
295 init_loads(defaults);
296 init_aeffects(defaults);
297 init_veffects(defaults);
301 void MainMenu::update_toggles(int use_lock)
303 if(use_lock) lock_window("MainMenu::update_toggles");
304 labels_follow_edits->set_checked(mwindow->edl->session->labels_follow_edits);
305 plugins_follow_edits->set_checked(mwindow->edl->session->plugins_follow_edits);
306 keyframes_follow_edits->set_checked(mwindow->edl->session->autos_follow_edits);
307 typeless_keyframes->set_checked(mwindow->edl->session->typeless_keyframes);
308 cursor_on_frames->set_checked(mwindow->edl->session->cursor_on_frames);
309 loop_playback->set_checked(mwindow->edl->local_session->loop_playback);
311 show_assets->set_checked(mwindow->edl->session->show_assets);
312 show_titles->set_checked(mwindow->edl->session->show_titles);
313 show_transitions->set_checked(mwindow->edl->session->auto_conf->transitions);
314 fade_automation->update_toggle();
315 mute_automation->update_toggle();
316 pan_automation->update_toggle();
317 camera_x->update_toggle();
318 camera_y->update_toggle();
319 camera_z->update_toggle();
320 project_x->update_toggle();
321 project_y->update_toggle();
322 project_z->update_toggle();
323 plugin_automation->set_checked(mwindow->edl->session->auto_conf->plugins);
324 mode_automation->update_toggle();
325 mask_automation->update_toggle();
326 speed_automation->update_toggle();
327 split_x->set_checked(mwindow->gui->pane[TOP_RIGHT_PANE] != 0);
328 split_y->set_checked(mwindow->gui->pane[BOTTOM_LEFT_PANE] != 0);
330 if(use_lock) mwindow->gui->unlock_window();
333 int MainMenu::save_defaults(BC_Hash *defaults)
335 save_loads(defaults);
336 save_aeffects(defaults);
337 save_veffects(defaults);
347 quit_program->handle_event();
355 // ================================== load most recent
357 int MainMenu::init_aeffects(BC_Hash *defaults)
359 total_aeffects = defaults->get((char*)"TOTAL_AEFFECTS", 0);
361 char string[BCTEXTLEN], title[BCTEXTLEN];
362 if(total_aeffects) audiomenu->add_item(new BC_MenuItem("-"));
364 for(int i = 0; i < total_aeffects; i++)
366 sprintf(string, "AEFFECTRECENT%d", i);
367 defaults->get(string, title);
368 audiomenu->add_item(aeffect[i] = new MenuAEffectItem(aeffects, title));
373 int MainMenu::init_veffects(BC_Hash *defaults)
375 total_veffects = defaults->get((char*)"TOTAL_VEFFECTS", 0);
377 char string[BCTEXTLEN], title[BCTEXTLEN];
378 if(total_veffects) videomenu->add_item(new BC_MenuItem("-"));
380 for(int i = 0; i < total_veffects; i++)
382 sprintf(string, "VEFFECTRECENT%d", i);
383 defaults->get(string, title);
384 videomenu->add_item(veffect[i] = new MenuVEffectItem(veffects, title));
389 void MainMenu::init_loads(BC_Hash *defaults)
391 // total_loads for legacy xml
392 int total_loads = defaults->get((char*)"TOTAL_LOADS", 0);
393 int loads_total = defaults->get((char*)"LOADS_TOTAL", 0);
394 if( loads_total < total_loads ) loads_total = total_loads;
396 char string[BCTEXTLEN], path[BCTEXTLEN];
398 //printf("MainMenu::init_loads 2\n");
400 for( int i=0; i<loads_total; ++i ) {
401 sprintf(string, "LOADPREVIOUS%d", i);
402 //printf("MainMenu::init_loads 3\n");
403 defaults->get(string, path);
404 if( load.size() < TOTAL_LOADS )
405 load.append(new LoadRecentItem(path));
409 // ============================ save most recent
411 int MainMenu::save_aeffects(BC_Hash *defaults)
413 defaults->update((char*)"TOTAL_AEFFECTS", total_aeffects);
414 char string[BCTEXTLEN];
415 for(int i = 0; i < total_aeffects; i++)
417 sprintf(string, "AEFFECTRECENT%d", i);
418 defaults->update(string, aeffect[i]->get_text());
423 int MainMenu::save_veffects(BC_Hash *defaults)
425 defaults->update((char*)"TOTAL_VEFFECTS", total_veffects);
426 char string[BCTEXTLEN];
427 for(int i = 0; i < total_veffects; i++)
429 sprintf(string, "VEFFECTRECENT%d", i);
430 defaults->update(string, veffect[i]->get_text());
435 int MainMenu::save_loads(BC_Hash *defaults)
437 // legacy to prevent segv, older code cant tolerate total_loads>10
438 int loads_total = load.size();
439 int total_loads = MIN(10, loads_total);
440 defaults->update((char*)"LOADS_TOTAL", loads_total);
441 defaults->update((char*)"TOTAL_LOADS", total_loads);
442 char string[BCTEXTLEN];
443 for( int i=0; i<loads_total; ++i ) {
444 sprintf(string, "LOADPREVIOUS%d", i);
445 defaults->update(string, load[i]->path);
450 // =================================== add most recent
452 int MainMenu::add_aeffect(char *title)
454 // add bar for first effect
455 if(total_aeffects == 0)
457 audiomenu->add_item(new BC_MenuItem("-"));
460 // test for existing copy of effect
461 for(int i = 0; i < total_aeffects; i++)
463 if(!strcmp(aeffect[i]->get_text(), title)) // already exists
464 { // swap for top effect
465 for(int j = i; j > 0; j--) // move preceeding effects down
467 aeffect[j]->set_text(aeffect[j - 1]->get_text());
469 aeffect[0]->set_text(title);
474 // add another blank effect
475 if(total_aeffects < TOTAL_EFFECTS)
478 aeffect[total_aeffects] = new MenuAEffectItem(aeffects, (char*)""));
483 for(int i = total_aeffects - 1; i > 0; i--)
485 // set menu item text
486 aeffect[i]->set_text(aeffect[i - 1]->get_text());
489 // set up the new effect
490 aeffect[0]->set_text(title);
494 int MainMenu::add_veffect(char *title)
496 // add bar for first effect
497 if(total_veffects == 0)
499 videomenu->add_item(new BC_MenuItem("-"));
502 // test for existing copy of effect
503 for(int i = 0; i < total_veffects; i++)
505 if(!strcmp(veffect[i]->get_text(), title)) // already exists
506 { // swap for top effect
507 for(int j = i; j > 0; j--) // move preceeding effects down
509 veffect[j]->set_text(veffect[j - 1]->get_text());
511 veffect[0]->set_text(title);
516 // add another blank effect
517 if(total_veffects < TOTAL_EFFECTS)
519 videomenu->add_item(veffect[total_veffects] =
520 new MenuVEffectItem(veffects, (char*)""));
525 for(int i = total_veffects - 1; i > 0; i--)
527 // set menu item text
528 veffect[i]->set_text(veffect[i - 1]->get_text());
531 // set up the new effect
532 veffect[0]->set_text(title);
536 int MainMenu::add_load(char *path)
538 return load.add_load(path);
543 // ================================== menu items
545 MainDumpsSubMenu::MainDumpsSubMenu(BC_MenuItem *menu_item)
548 this->menu_item = menu_item;
550 MainDumpsSubMenu::~MainDumpsSubMenu()
555 MainDumpsMenu::MainDumpsMenu(MWindow *mwindow)
556 : BC_MenuItem(_("Dumps..."))
558 this->mwindow = mwindow;
559 this->dumps_menu = 0;
561 MainDumpsMenu::~MainDumpsMenu()
565 void MainDumpsMenu::create_objects()
567 add_submenu(dumps_menu = new MainDumpsSubMenu(this));
568 // dumps_menu->add_item(new DumpCICache(mwindow));
569 dumps_menu->add_item(new DumpEDL(mwindow));
570 dumps_menu->add_item(new DumpPlugins(mwindow));
571 dumps_menu->add_item(new DumpAssets(mwindow));
572 dumps_menu->add_item(new DumpUndo(mwindow));
576 DumpCICache::DumpCICache(MWindow *mwindow)
577 : BC_MenuItem(_("Dump CICache"))
578 { this->mwindow = mwindow; }
580 int DumpCICache::handle_event()
582 // mwindow->cache->dump();
586 DumpEDL::DumpEDL(MWindow *mwindow)
587 : BC_MenuItem(_("Dump EDL"))
589 this->mwindow = mwindow;
592 int DumpEDL::handle_event()
598 DumpPlugins::DumpPlugins(MWindow *mwindow)
599 : BC_MenuItem(_("Dump Plugins"))
601 this->mwindow = mwindow;
604 int DumpPlugins::handle_event()
606 mwindow->dump_plugins();
610 DumpAssets::DumpAssets(MWindow *mwindow)
611 : BC_MenuItem(_("Dump Assets"))
612 { this->mwindow = mwindow; }
614 int DumpAssets::handle_event()
616 mwindow->edl->assets->dump();
620 DumpUndo::DumpUndo(MWindow *mwindow)
621 : BC_MenuItem(_("Dump Undo"))
623 this->mwindow = mwindow;
626 int DumpUndo::handle_event()
628 mwindow->dump_undo();
632 // ================================================= edit
634 Undo::Undo(MWindow *mwindow) : BC_MenuItem(_("Undo"), "z", 'z')
636 this->mwindow = mwindow;
638 int Undo::handle_event()
640 if( mwindow->session->current_operation == NO_OPERATION )
641 mwindow->undo_entry(mwindow->gui);
644 int Undo::update_caption(const char *new_caption)
646 char string[BCTEXTLEN];
647 sprintf(string, _("Undo %s"), new_caption);
653 Redo::Redo(MWindow *mwindow) : BC_MenuItem(_("Redo"), _("Shift-Z"), 'Z')
656 this->mwindow = mwindow;
659 int Redo::handle_event()
661 if( mwindow->session->current_operation == NO_OPERATION )
662 mwindow->redo_entry(mwindow->gui);
665 int Redo::update_caption(const char *new_caption)
667 char string[BCTEXTLEN];
668 sprintf(string, _("Redo %s"), new_caption);
673 CutKeyframes::CutKeyframes(MWindow *mwindow)
674 : BC_MenuItem(_("Cut keyframes"), _("Shift-X"), 'X')
677 this->mwindow = mwindow;
680 int CutKeyframes::handle_event()
682 if( mwindow->session->current_operation == NO_OPERATION )
683 mwindow->cut_automation();
687 CopyKeyframes::CopyKeyframes(MWindow *mwindow)
688 : BC_MenuItem(_("Copy keyframes"), _("Shift-C"), 'C')
691 this->mwindow = mwindow;
694 int CopyKeyframes::handle_event()
696 if( mwindow->session->current_operation == NO_OPERATION )
697 mwindow->copy_automation();
701 PasteKeyframes::PasteKeyframes(MWindow *mwindow)
702 : BC_MenuItem(_("Paste keyframes"), _("Shift-V"), 'V')
705 this->mwindow = mwindow;
708 int PasteKeyframes::handle_event()
710 if( mwindow->session->current_operation == NO_OPERATION )
711 mwindow->paste_automation();
715 ClearKeyframes::ClearKeyframes(MWindow *mwindow)
716 : BC_MenuItem(_("Clear keyframes"), _("Shift-Del"), DELETE)
719 this->mwindow = mwindow;
722 int ClearKeyframes::handle_event()
724 if( mwindow->session->current_operation == NO_OPERATION )
725 mwindow->clear_automation();
731 StraightenKeyframes::StraightenKeyframes(MWindow *mwindow)
732 : BC_MenuItem(_("Change to linear"))
734 this->mwindow = mwindow;
737 int StraightenKeyframes::handle_event()
739 mwindow->set_automation_mode(FloatAuto::LINEAR);
746 BendKeyframes::BendKeyframes(MWindow *mwindow)
747 : BC_MenuItem(_("Change to smooth"))
749 this->mwindow = mwindow;
752 int BendKeyframes::handle_event()
754 mwindow->set_automation_mode(FloatAuto::SMOOTH);
760 KeyframeCurveType::KeyframeCurveType(MWindow *mwindow)
761 : BC_MenuItem(_("Create curve type..."))
763 this->mwindow = mwindow;
764 this->curve_menu = 0;
766 KeyframeCurveType::~KeyframeCurveType()
770 void KeyframeCurveType::create_objects()
772 add_submenu(curve_menu = new KeyframeCurveTypeMenu(this));
773 for( int i=FloatAuto::SMOOTH; i<=FloatAuto::FREE; ++i ) {
774 KeyframeCurveTypeItem *curve_type_item = new KeyframeCurveTypeItem(i, this);
775 curve_menu->add_submenuitem(curve_type_item);
779 void KeyframeCurveType::update(int curve_type)
781 for( int i=0; i<curve_menu->total_items(); ++i ) {
782 KeyframeCurveTypeItem *curve_type_item = (KeyframeCurveTypeItem *)curve_menu->get_item(i);
783 curve_type_item->set_checked(curve_type_item->type == curve_type);
787 int KeyframeCurveType::handle_event()
792 KeyframeCurveTypeMenu::KeyframeCurveTypeMenu(KeyframeCurveType *menu_item)
795 this->menu_item = menu_item;
797 KeyframeCurveTypeMenu::~KeyframeCurveTypeMenu()
801 KeyframeCurveTypeItem::KeyframeCurveTypeItem(int type, KeyframeCurveType *main_item)
802 : BC_MenuItem(FloatAuto::curve_name(type))
805 this->main_item = main_item;
807 KeyframeCurveTypeItem::~KeyframeCurveTypeItem()
811 int KeyframeCurveTypeItem::handle_event()
813 main_item->update(type);
814 main_item->mwindow->set_keyframe_type(type);
819 CutDefaultKeyframe::CutDefaultKeyframe(MWindow *mwindow)
820 : BC_MenuItem(_("Cut default keyframe"), _("Alt-x"), 'x')
823 this->mwindow = mwindow;
826 int CutDefaultKeyframe::handle_event()
828 if( mwindow->session->current_operation == NO_OPERATION )
829 mwindow->cut_default_keyframe();
833 CopyDefaultKeyframe::CopyDefaultKeyframe(MWindow *mwindow)
834 : BC_MenuItem(_("Copy default keyframe"), _("Alt-c"), 'c')
837 this->mwindow = mwindow;
840 int CopyDefaultKeyframe::handle_event()
842 if( mwindow->session->current_operation == NO_OPERATION )
843 mwindow->copy_default_keyframe();
847 PasteDefaultKeyframe::PasteDefaultKeyframe(MWindow *mwindow)
848 : BC_MenuItem(_("Paste default keyframe"), _("Alt-v"), 'v')
851 this->mwindow = mwindow;
854 int PasteDefaultKeyframe::handle_event()
856 if( mwindow->session->current_operation == NO_OPERATION )
857 mwindow->paste_default_keyframe();
861 ClearDefaultKeyframe::ClearDefaultKeyframe(MWindow *mwindow)
862 : BC_MenuItem(_("Clear default keyframe"), _("Alt-Del"), DELETE)
865 this->mwindow = mwindow;
868 int ClearDefaultKeyframe::handle_event()
870 if( mwindow->session->current_operation == NO_OPERATION )
871 mwindow->clear_default_keyframe();
875 Cut::Cut(MWindow *mwindow)
876 : BC_MenuItem(_("Split | Cut"), "x", 'x')
878 this->mwindow = mwindow;
881 int Cut::handle_event()
883 if( mwindow->session->current_operation == NO_OPERATION )
888 Copy::Copy(MWindow *mwindow)
889 : BC_MenuItem(_("Copy"), "c", 'c')
891 this->mwindow = mwindow;
894 int Copy::handle_event()
896 if( mwindow->session->current_operation == NO_OPERATION )
901 Paste::Paste(MWindow *mwindow)
902 : BC_MenuItem(_("Paste"), "v", 'v')
904 this->mwindow = mwindow;
907 int Paste::handle_event()
909 if( mwindow->session->current_operation == NO_OPERATION )
914 EditClearSubMenu::EditClearSubMenu(BC_MenuItem *menu_item)
917 this->menu_item = menu_item;
919 EditClearSubMenu::~EditClearSubMenu()
923 EditClearMenu::EditClearMenu(MWindow *mwindow)
924 : BC_MenuItem(_("Clear..."))
926 this->mwindow = mwindow;
927 this->clear_sub_menu = 0;
929 EditClearMenu::~EditClearMenu()
933 void EditClearMenu::create_objects()
935 add_submenu(clear_sub_menu = new EditClearSubMenu(this));
936 clear_sub_menu->add_item(new Clear(mwindow));
937 clear_sub_menu->add_item(new MuteSelection(mwindow));
938 clear_sub_menu->add_item(new ClearSelect(mwindow));
939 clear_sub_menu->add_item(new ClearLabels(mwindow));
940 clear_sub_menu->add_item(new ClearHardEdges(mwindow));
943 Clear::Clear(MWindow *mwindow)
944 : BC_MenuItem(_("Clear"), _("Del"), DELETE)
946 this->mwindow = mwindow;
949 int Clear::handle_event()
951 if( mwindow->session->current_operation == NO_OPERATION ) {
952 mwindow->cwindow->gui->lock_window("Clear::handle_event");
953 mwindow->clear_entry();
954 mwindow->cwindow->gui->unlock_window();
959 PasteSilence::PasteSilence(MWindow *mwindow)
960 : BC_MenuItem(_("Paste silence"), _("Shift-Space"), ' ')
962 this->mwindow = mwindow;
966 int PasteSilence::handle_event()
968 if( mwindow->session->current_operation == NO_OPERATION )
969 mwindow->paste_silence();
973 SelectAll::SelectAll(MWindow *mwindow)
974 : BC_MenuItem(_("Select All"), "a", 'a')
976 this->mwindow = mwindow;
979 int SelectAll::handle_event()
981 if( mwindow->session->current_operation == NO_OPERATION )
982 mwindow->select_all();
986 ClearHardEdges::ClearHardEdges(MWindow *mwindow) : BC_MenuItem(_("Clear Hard Edges"))
988 this->mwindow = mwindow;
991 int ClearHardEdges::handle_event()
993 mwindow->clear_hard_edges();
997 ClearLabels::ClearLabels(MWindow *mwindow) : BC_MenuItem(_("Clear labels"))
999 this->mwindow = mwindow;
1002 int ClearLabels::handle_event()
1004 mwindow->clear_labels();
1008 ClearSelect::ClearSelect(MWindow *mwindow) : BC_MenuItem(_("Clear Select"),"Ctrl-Shift-A",'A')
1012 this->mwindow = mwindow;
1015 int ClearSelect::handle_event()
1017 mwindow->clear_select();
1021 CutCommercials::CutCommercials(MWindow *mwindow) : BC_MenuItem(_("Cut ads"))
1023 this->mwindow = mwindow;
1026 int CutCommercials::handle_event()
1028 mwindow->cut_commercials();
1032 DetachTransitions::DetachTransitions(MWindow *mwindow)
1033 : BC_MenuItem(_("Detach transitions"))
1035 this->mwindow = mwindow;
1038 int DetachTransitions::handle_event()
1040 mwindow->detach_transitions();
1044 MuteSelection::MuteSelection(MWindow *mwindow)
1045 : BC_MenuItem(_("Mute Region"), "m", 'm')
1047 this->mwindow = mwindow;
1050 int MuteSelection::handle_event()
1052 if( mwindow->session->current_operation == NO_OPERATION )
1053 mwindow->mute_selection();
1058 TrimSelection::TrimSelection(MWindow *mwindow)
1059 : BC_MenuItem(_("Trim Selection"))
1061 this->mwindow = mwindow;
1064 int TrimSelection::handle_event()
1066 mwindow->trim_selection();
1081 // ============================================= audio
1083 AddAudioTrack::AddAudioTrack(MWindow *mwindow)
1084 : BC_MenuItem(_("Add track"), "t", 't')
1086 this->mwindow = mwindow;
1089 int AddAudioTrack::handle_event()
1091 if( mwindow->session->current_operation == NO_OPERATION )
1092 mwindow->add_audio_track_entry(0, 0);
1096 DeleteAudioTrack::DeleteAudioTrack(MWindow *mwindow)
1097 : BC_MenuItem(_("Delete track"))
1099 this->mwindow = mwindow;
1102 int DeleteAudioTrack::handle_event()
1107 DefaultATransition::DefaultATransition(MWindow *mwindow)
1108 : BC_MenuItem(_("Default Transition"), "u", 'u')
1110 this->mwindow = mwindow;
1113 int DefaultATransition::handle_event()
1115 if( mwindow->session->current_operation == NO_OPERATION )
1116 mwindow->paste_audio_transition();
1121 MapAudio1::MapAudio1(MWindow *mwindow)
1122 : BC_MenuItem(_("Map 1:1"))
1124 this->mwindow = mwindow;
1127 int MapAudio1::handle_event()
1129 mwindow->map_audio(MWindow::AUDIO_1_TO_1);
1133 MapAudio2::MapAudio2(MWindow *mwindow)
1134 : BC_MenuItem(_("Map 5.1:2"))
1136 this->mwindow = mwindow;
1139 int MapAudio2::handle_event()
1141 mwindow->map_audio(MWindow::AUDIO_5_1_TO_2);
1148 // ============================================= video
1151 AddVideoTrack::AddVideoTrack(MWindow *mwindow)
1152 : BC_MenuItem(_("Add track"), _("Shift-T"), 'T')
1155 this->mwindow = mwindow;
1158 int AddVideoTrack::handle_event()
1160 if( mwindow->session->current_operation == NO_OPERATION )
1161 mwindow->add_video_track_entry();
1166 DeleteVideoTrack::DeleteVideoTrack(MWindow *mwindow)
1167 : BC_MenuItem(_("Delete track"))
1169 this->mwindow = mwindow;
1172 int DeleteVideoTrack::handle_event()
1179 ResetTranslation::ResetTranslation(MWindow *mwindow)
1180 : BC_MenuItem(_("Reset Translation"))
1182 this->mwindow = mwindow;
1185 int ResetTranslation::handle_event()
1192 DefaultVTransition::DefaultVTransition(MWindow *mwindow)
1193 : BC_MenuItem(_("Default Transition"), _("Shift-U"), 'U')
1196 this->mwindow = mwindow;
1199 int DefaultVTransition::handle_event()
1201 if( mwindow->session->current_operation == NO_OPERATION )
1202 mwindow->paste_video_transition();
1219 // ============================================ settings
1221 DeleteTracks::DeleteTracks(MWindow *mwindow)
1222 : BC_MenuItem(_("Delete tracks"))
1224 this->mwindow = mwindow;
1227 int DeleteTracks::handle_event()
1229 mwindow->delete_tracks();
1233 DeleteFirstTrack::DeleteFirstTrack(MWindow *mwindow)
1234 : BC_MenuItem(_("Delete first track"), "Shift-D", 'D')
1237 this->mwindow = mwindow;
1240 int DeleteFirstTrack::handle_event()
1242 if( mwindow->session->current_operation == NO_OPERATION ) {
1243 Track *track = mwindow->edl->tracks->first;
1244 if( track ) mwindow->delete_track(track);
1249 DeleteLastTrack::DeleteLastTrack(MWindow *mwindow)
1250 : BC_MenuItem(_("Delete last track"), "Ctrl-Shift-D", 'D')
1254 this->mwindow = mwindow;
1257 int DeleteLastTrack::handle_event()
1259 if( mwindow->session->current_operation == NO_OPERATION ) {
1260 Track *track = mwindow->edl->tracks->last;
1261 if( track ) mwindow->delete_track(track);
1266 MoveTracksUp::MoveTracksUp(MWindow *mwindow)
1267 : BC_MenuItem(_("Move tracks up"), _("Shift-Up"), UP)
1269 this->mwindow = mwindow;
1273 int MoveTracksUp::handle_event()
1275 if( mwindow->session->current_operation == NO_OPERATION )
1276 mwindow->move_tracks_up();
1280 MoveTracksDown::MoveTracksDown(MWindow *mwindow)
1281 : BC_MenuItem(_("Move tracks down"), _("Shift-Down"), DOWN)
1283 set_shift(); this->mwindow = mwindow;
1286 int MoveTracksDown::handle_event()
1288 if( mwindow->session->current_operation == NO_OPERATION )
1289 mwindow->move_tracks_down();
1296 ConcatenateTracks::ConcatenateTracks(MWindow *mwindow)
1297 : BC_MenuItem(_("Concatenate tracks"))
1300 this->mwindow = mwindow;
1303 int ConcatenateTracks::handle_event()
1305 mwindow->concatenate_tracks();
1313 LoopPlayback::LoopPlayback(MWindow *mwindow)
1314 : BC_MenuItem(_("Loop Playback"), _("Shift-L"), 'L')
1316 this->mwindow = mwindow;
1317 set_checked(mwindow->edl->local_session->loop_playback);
1321 int LoopPlayback::handle_event()
1323 if( mwindow->session->current_operation == NO_OPERATION ) {
1324 mwindow->toggle_loop_playback();
1325 set_checked(mwindow->edl->local_session->loop_playback);
1332 // ============================================= subtitle
1335 AddSubttlTrack::AddSubttlTrack(MWindow *mwindow)
1336 : BC_MenuItem(_("Add subttl"), _("Shift-Y"), 'Y')
1339 this->mwindow = mwindow;
1342 int AddSubttlTrack::handle_event()
1344 if( mwindow->session->current_operation == NO_OPERATION )
1345 mwindow->add_subttl_track_entry();
1349 PasteSubttl::PasteSubttl(MWindow *mwindow)
1350 : BC_MenuItem(_("paste subttl"), "y", 'y')
1352 this->mwindow = mwindow;
1355 int PasteSubttl::handle_event()
1357 if( mwindow->session->current_operation == NO_OPERATION )
1358 mwindow->gui->swindow->paste_subttl();
1363 SetBRenderActive::SetBRenderActive(MWindow *mwindow)
1364 : BC_MenuItem(_("Toggle background rendering"),_("Shift-G"),'G')
1366 this->mwindow = mwindow;
1370 int SetBRenderActive::handle_event()
1372 if( mwindow->session->current_operation == NO_OPERATION ) {
1373 int v = mwindow->brender_active ? 0 : 1;
1375 mwindow->set_brender_active(v);
1381 LabelsFollowEdits::LabelsFollowEdits(MWindow *mwindow)
1382 : BC_MenuItem(_("Edit labels"))
1384 this->mwindow = mwindow;
1385 set_checked(mwindow->edl->session->labels_follow_edits);
1388 int LabelsFollowEdits::handle_event()
1390 set_checked(get_checked() ^ 1);
1391 mwindow->set_labels_follow_edits(get_checked());
1398 PluginsFollowEdits::PluginsFollowEdits(MWindow *mwindow)
1399 : BC_MenuItem(_("Edit effects"))
1401 this->mwindow = mwindow;
1402 set_checked(mwindow->edl->session->plugins_follow_edits);
1405 int PluginsFollowEdits::handle_event()
1407 set_checked(get_checked() ^ 1);
1408 mwindow->edl->session->plugins_follow_edits = get_checked();
1415 KeyframesFollowEdits::KeyframesFollowEdits(MWindow *mwindow)
1416 : BC_MenuItem(_("Keyframes follow edits"))
1418 this->mwindow = mwindow;
1419 set_checked(mwindow->edl->session->autos_follow_edits);
1422 int KeyframesFollowEdits::handle_event()
1424 mwindow->edl->session->autos_follow_edits ^= 1;
1425 set_checked(!get_checked());
1430 CursorOnFrames::CursorOnFrames(MWindow *mwindow)
1431 : BC_MenuItem(_("Align cursor on frames"),_("Ctrl-a"),'a')
1433 this->mwindow = mwindow;
1434 set_checked(mwindow->edl->session->cursor_on_frames);
1438 int CursorOnFrames::handle_event()
1440 mwindow->edl->session->cursor_on_frames = !mwindow->edl->session->cursor_on_frames;
1441 set_checked(mwindow->edl->session->cursor_on_frames);
1446 TypelessKeyframes::TypelessKeyframes(MWindow *mwindow)
1447 : BC_MenuItem(_("Typeless keyframes"))
1449 this->mwindow = mwindow;
1450 set_checked(mwindow->edl->session->typeless_keyframes);
1453 int TypelessKeyframes::handle_event()
1455 mwindow->edl->session->typeless_keyframes = !mwindow->edl->session->typeless_keyframes;
1456 set_checked(mwindow->edl->session->typeless_keyframes);
1461 ScrubSpeed::ScrubSpeed(MWindow *mwindow)
1462 : BC_MenuItem(_("Slow Shuttle"))
1464 this->mwindow = mwindow;
1467 int ScrubSpeed::handle_event()
1469 if(mwindow->edl->session->scrub_speed == .5)
1471 mwindow->edl->session->scrub_speed = 2;
1472 set_text(_("Slow Shuttle"));
1476 mwindow->edl->session->scrub_speed = .5;
1477 set_text(_("Fast Shuttle"));
1482 SaveSettingsNow::SaveSettingsNow(MWindow *mwindow)
1483 : BC_MenuItem(_("Save settings now"),_("Ctrl-s"),'s')
1485 this->mwindow = mwindow;
1489 int SaveSettingsNow::handle_event()
1491 mwindow->save_defaults();
1492 mwindow->save_backup();
1493 mwindow->gui->show_message(_("Saved settings."));
1499 // ============================================ window
1505 ShowVWindow::ShowVWindow(MWindow *mwindow)
1506 : BC_MenuItem(_("Show Viewer"))
1508 this->mwindow = mwindow;
1509 set_checked(mwindow->session->show_vwindow);
1511 int ShowVWindow::handle_event()
1513 mwindow->show_vwindow();
1517 ShowAWindow::ShowAWindow(MWindow *mwindow)
1518 : BC_MenuItem(_("Show Resources"))
1520 this->mwindow = mwindow;
1521 set_checked(mwindow->session->show_awindow);
1523 int ShowAWindow::handle_event()
1525 mwindow->show_awindow();
1529 ShowCWindow::ShowCWindow(MWindow *mwindow)
1530 : BC_MenuItem(_("Show Compositor"))
1532 this->mwindow = mwindow;
1533 set_checked(mwindow->session->show_cwindow);
1535 int ShowCWindow::handle_event()
1537 mwindow->show_cwindow();
1542 ShowGWindow::ShowGWindow(MWindow *mwindow)
1543 : BC_MenuItem(_("Show Overlays"), _("Ctrl-0"), '0')
1545 this->mwindow = mwindow;
1547 set_checked(mwindow->session->show_gwindow);
1549 int ShowGWindow::handle_event()
1551 if( mwindow->session->current_operation == NO_OPERATION ) {
1552 if( !mwindow->session->show_gwindow )
1553 mwindow->show_gwindow();
1555 mwindow->hide_gwindow();
1556 set_checked(mwindow->session->show_gwindow);
1562 ShowLWindow::ShowLWindow(MWindow *mwindow)
1563 : BC_MenuItem(_("Show Levels"))
1565 this->mwindow = mwindow;
1566 set_checked(mwindow->session->show_lwindow);
1568 int ShowLWindow::handle_event()
1570 mwindow->show_lwindow();
1574 TileWindows::TileWindows(MWindow *mwindow, const char *item_title, int config,
1575 const char *hot_keytext, int hot_key)
1576 : BC_MenuItem(item_title, hot_keytext, hot_key)
1578 this->mwindow = mwindow;
1579 this->config = config;
1580 if( hot_key ) set_ctrl(1);
1582 int TileWindows::handle_event()
1584 if( mwindow->session->current_operation == NO_OPERATION ) {
1585 int window_config = config >= 0 ? config :
1586 mwindow->session->window_config;
1587 if( mwindow->tile_windows(window_config) ) {
1588 mwindow->restart_status = 1;
1589 mwindow->gui->set_done(0);
1595 SplitX::SplitX(MWindow *mwindow)
1596 : BC_MenuItem(_("Split X pane"), _("Ctrl-1"), '1')
1598 this->mwindow = mwindow;
1600 set_checked(mwindow->gui->pane[TOP_RIGHT_PANE] != 0);
1602 int SplitX::handle_event()
1604 if( mwindow->session->current_operation == NO_OPERATION )
1609 SplitY::SplitY(MWindow *mwindow)
1610 : BC_MenuItem(_("Split Y pane"), _("Ctrl-2"), '2')
1612 this->mwindow = mwindow;
1614 set_checked(mwindow->gui->pane[BOTTOM_LEFT_PANE] != 0);
1616 int SplitY::handle_event()
1618 if( mwindow->session->current_operation == NO_OPERATION )
1624 MixerItems::MixerItems(MWindow *mwindow)
1625 : BC_MenuItem(_("Mixers..."))
1627 this->mwindow = mwindow;
1630 void MixerItems::create_objects()
1632 BC_SubMenu *mixer_submenu = new BC_SubMenu();
1633 add_submenu(mixer_submenu);
1634 mixer_submenu->add_submenuitem(new MixerViewer(mwindow));
1635 mixer_submenu->add_submenuitem(new TileMixers(mwindow));
1636 mixer_submenu->add_submenuitem(new AlignMixers(mwindow));
1639 MixerViewer::MixerViewer(MWindow *mwindow)
1640 : BC_MenuItem(_("Mixer Viewer"), _("Shift-M"), 'M')
1642 this->mwindow = mwindow;
1646 int MixerViewer::handle_event()
1648 mwindow->start_mixer();
1652 TileMixers::TileMixers(MWindow *mwindow)
1653 : BC_MenuItem(_("Tile mixers"), "Alt-t", 't')
1655 this->mwindow = mwindow;
1659 int TileMixers::handle_event()
1661 mwindow->tile_mixers();
1665 AlignMixers::AlignMixers(MWindow *mwindow)
1666 : BC_MenuItem(_("Align mixers"))
1668 this->mwindow = mwindow;
1671 int AlignMixers::handle_event()
1674 mwindow->gui->get_abs_cursor(wx, wy);
1675 mwindow->mixers_align->start_dialog(wx, wy);
1680 LoadLayoutItem::LoadLayoutItem(LoadLayout *load_layout, const char *text, int idx, int hotkey)
1681 : BC_MenuItem(text, "", hotkey)
1684 this->load_layout = load_layout;
1686 char hot_txt[BCSTRLEN];
1687 sprintf(hot_txt, _("Ctrl-Shift+F%d"), hotkey-KEY_F1+1);
1688 set_ctrl(); set_shift();
1689 set_hotkey_text(hot_txt);
1694 int LoadLayoutItem::handle_event()
1696 // key_press hotkey skips over activate_submenu
1697 load_layout->update();
1698 MWindow *mwindow = load_layout->mwindow;
1699 switch( load_layout->action ) {
1701 mwindow->load_layout(layout_file);
1705 mwindow->gui->get_abs_cursor(wx, wy);
1706 load_layout->layout_dialog->start_confirm_dialog(wx, wy, idx);
1712 LoadLayout::LoadLayout(MWindow *mwindow, const char *text, int action)
1715 this->mwindow = mwindow;
1716 this->action = action;
1717 this->layout_dialog = new LoadLayoutDialog(this);
1720 LoadLayout::~LoadLayout()
1722 delete layout_dialog;
1725 void LoadLayout::create_objects()
1727 BC_SubMenu *layout_submenu = new BC_SubMenu();
1728 add_submenu(layout_submenu);
1730 for( int i=0; i<LAYOUTS_MAX; ++i ) {
1731 char text[BCSTRLEN];
1732 sprintf(text, _("Layout %d"), i+1);
1733 LoadLayoutItem *item = new LoadLayoutItem(this, text, i,
1734 action==LAYOUT_LOAD ? KEY_F1+i : 0);
1735 layout_submenu->add_submenuitem(item);
1739 int LoadLayout::activate_submenu()
1742 return BC_MenuItem::activate_submenu();
1745 void LoadLayout::update()
1748 fs.set_filter("layout*_rc");
1749 int ret = fs.update(File::get_config_path());
1750 int sz = !ret ? fs.dir_list.size() : 0;
1751 BC_SubMenu *layout_submenu = get_submenu();
1753 for( int i=0; i<LAYOUTS_MAX; ++i ) {
1754 LoadLayoutItem* item = (LoadLayoutItem *)
1755 layout_submenu->get_item(i);
1756 char layout_text[BCSTRLEN]; layout_text[0] = 0;
1757 int n = sz, id = i+1;
1759 char *np = fs.dir_list[n]->name;
1760 char *cp = strrchr(np, '_'), *bp = 0;
1761 int no = strtol(np+6, &bp, 10);
1762 if( no != id || !bp ) continue;
1763 if( bp == cp ) { n = -1; break; }
1764 if( *bp++ == '_' && bp < cp && !strcmp(cp, "_rc") ) {
1765 int k = cp - bp; char *tp = layout_text;
1766 if( k > LAYOUT_NAME_LEN ) k = LAYOUT_NAME_LEN;
1767 while( --k >= 0 ) *tp++ = *bp++;
1772 strcpy(item->layout_text, layout_text);
1773 char *lp = item->layout_file;
1774 int k = sprintf(lp, LAYOUT_FILE, id);
1775 if( n >= 0 && layout_text[0] )
1776 sprintf(lp + k-2, "%s_rc", layout_text);
1778 sprintf(layout_text, _("Layout %d"), id);
1779 item->set_text(layout_text);
1783 LoadLayoutDialog::LoadLayoutDialog(LoadLayout *load_layout)
1785 this->load_layout = load_layout;
1791 LoadLayoutDialog::~LoadLayoutDialog()
1796 void LoadLayoutDialog::handle_done_event(int result)
1798 if( result ) return;
1799 char layout_file[BCSTRLEN];
1800 BC_SubMenu *layout_submenu = load_layout->get_submenu();
1801 LoadLayoutItem* item =
1802 (LoadLayoutItem *) layout_submenu->get_item(idx);
1803 snprintf(layout_file, sizeof(layout_file), "%s", item->layout_file);
1804 load_layout->mwindow->delete_layout(layout_file);
1805 int k = sprintf(layout_file, LAYOUT_FILE, idx+1);
1806 const char *text = lgui->name_text->get_text();
1808 snprintf(layout_file + k-2, sizeof(layout_file)-k+2, "%s_rc", text);
1809 load_layout->mwindow->save_layout(layout_file);
1812 void LoadLayoutDialog::handle_close_event(int result)
1817 BC_Window *LoadLayoutDialog::new_gui()
1819 lgui = new LoadLayoutConfirm(this, wx, wy);
1820 lgui->create_objects();
1824 void LoadLayoutDialog::start_confirm_dialog(int wx, int wy, int idx)
1827 this->wx = wx; this->wy = wy;
1832 LoadLayoutNameText::LoadLayoutNameText(LoadLayoutConfirm *confirm,
1833 int x, int y, int w, const char *text)
1834 : BC_TextBox(x, y, w, 1, text)
1836 this->confirm = confirm;
1839 LoadLayoutNameText::~LoadLayoutNameText()
1843 int LoadLayoutNameText::handle_event()
1845 const char *text = get_text();
1846 int len = strlen(text), k = 0;
1847 char new_text[BCTEXTLEN];
1848 for( int i=0; i<len; ++i ) {
1850 if( (ch>='A' && ch<='Z') || (ch>='a' && ch<='z') ||
1851 (ch>='0' && ch<='9') || ch=='_' )
1854 new_text[k] = 0; len = k;
1855 int i = len - LAYOUT_NAME_LEN;
1858 while( i < len ) new_text[k++] = new_text[i++];
1865 LoadLayoutConfirm::LoadLayoutConfirm(LoadLayoutDialog *layout_dialog, int x, int y)
1866 : BC_Window(_(PROGRAM_NAME ": Layout"), x, y, xS(300),yS(140), xS(300),yS(140), 0)
1868 this->layout_dialog = layout_dialog;
1871 LoadLayoutConfirm::~LoadLayoutConfirm()
1875 void LoadLayoutConfirm::create_objects()
1877 int xs10 = xS(10), xs20 = xS(20);
1879 lock_window("LoadLayoutConfirm::create_objects");
1880 int x = xs10, y = ys10;
1881 BC_SubMenu *layout_submenu = layout_dialog->load_layout->get_submenu();
1882 LoadLayoutItem *item = (LoadLayoutItem *)
1883 layout_submenu->get_item(layout_dialog->idx);
1885 add_subwindow(title = new BC_Title(x, y, _("Layout Name:")));
1886 int x1 = x + title->get_w() + xs10;
1887 add_subwindow(title = new BC_Title(x1, y, item->get_text()));
1888 y += title->get_h() + ys10;
1889 add_subwindow(name_text = new LoadLayoutNameText(this,
1890 x, y, get_w()-x-xs20, item->layout_text));
1891 y += name_text->get_h();
1893 char legend[BCTEXTLEN];
1894 sprintf(legend, _("a-z,A-Z,0-9_ only, %dch max"), LAYOUT_NAME_LEN);
1895 add_subwindow(title = new BC_Title(x1, y, legend));
1896 add_subwindow(new BC_OKButton(this));
1897 add_subwindow(new BC_CancelButton(this));
1902 LoadRecentItem::LoadRecentItem(const char *path)
1904 this->path = cstrdup(path);
1907 LoadRecentItem::~LoadRecentItem()
1912 int LoadRecentItems::add_load(char *path)
1914 // test for existing copy
1916 char name[BCTEXTLEN], text[BCTEXTLEN];
1917 fs.extract_name(name, path);
1918 int loads_total = size();
1919 int ret = 0, k = loads_total;
1920 LoadRecentItem *load_item = 0;
1922 for( int i=0; !ret && i<loads_total; ++i ) {
1924 fs.extract_name(text, load_item->path);
1925 if( strcmp(name, text) ) continue;
1926 k = i; ret = 1; // already exists, move to top
1928 if( !ret ) { // adding a new one
1929 while( loads_total >= TOTAL_LOADS )
1930 remove_object_number(--loads_total);
1931 insert(new LoadRecentItem(path), 0);
1933 else if( k > 0 ) { // cycle loads
1934 while( --k >= 0 ) set(k+1, get(k));
1940 LoadRecentItems::LoadRecentItems()
1944 LoadRecentItems::~LoadRecentItems()
1946 remove_all_objects();
1949 LoadRecent::LoadRecent(MWindow *mwindow, MainMenu *main_menu)
1950 : BC_MenuItem(_("Load Recent..."))
1952 this->mwindow = mwindow;
1953 this->main_menu = main_menu;
1956 LoadRecent::~LoadRecent()
1960 void LoadRecent::create_objects()
1962 add_submenu(submenu = new LoadRecentSubMenu(this));
1965 LoadPrevious *LoadRecent::get_next_item()
1967 int k = total_items++;
1968 if( k < submenu->total_items() )
1969 return (LoadPrevious *)submenu->get_item(k);
1970 LoadPrevious *load_prev = new LoadPrevious(mwindow, main_menu->load_file);
1971 submenu->add_item(load_prev);
1975 int LoadRecent::activate_submenu()
1979 if( total_items > 0 ) {
1980 LoadPrevious *load_prev = get_next_item();
1981 load_prev->set_text("-");
1982 load_prev->set_path("");
1985 while( total_items < submenu->total_items() )
1986 submenu->del_item(0);
1987 return BC_MenuItem::activate_submenu();
1990 void LoadRecent::scan_items(int use_xml)
1993 int loads_total = main_menu->load.size();
1994 for( int i=0; i<loads_total; ++i ) {
1995 LoadRecentItem *recent = main_menu->load[i];
1996 char name[BCTEXTLEN];
1997 fs.extract_name(name, recent->path);
1998 const char *cp = strrchr(name, '.');
1999 if( !cp || strcasecmp(cp+1,"xml") ? use_xml : !use_xml ) continue;
2000 LoadPrevious *load_prev = get_next_item();
2001 load_prev->set_text(name);
2002 load_prev->set_path(recent->path);
2006 LoadRecentSubMenu::LoadRecentSubMenu(LoadRecent *load_recent)
2009 this->load_recent = load_recent;
2012 LoadRecentSubMenu::~LoadRecentSubMenu()