4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5 * Copyright (C) 2003-2016 Cinelerra CV contributors
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "awindowgui.h"
25 #include "bcsignals.h"
27 #include "cplayback.h"
29 #include "cwindowgui.h"
30 #include "editpanel.h"
32 #include "edlsession.h"
36 #include "localsession.h"
37 #include "mainclock.h"
38 #include "mainsession.h"
40 #include "manualgoto.h"
42 #include "meterpanel.h"
44 #include "mwindowgui.h"
45 #include "playbackengine.h"
46 #include "preferences.h"
47 #include "scopewindow.h"
50 #include "trackcanvas.h"
51 #include "transportque.h"
52 #include "vwindowgui.h"
57 EditPanel::EditPanel(MWindow *mwindow,
58 BC_WindowBase *subwindow,
65 int use_splice, // Extra buttons
83 this->window_id = window_id;
84 this->editing_mode = editing_mode;
85 this->use_editing_mode = use_editing_mode;
86 this->use_keyframe = use_keyframe;
87 this->use_splice = use_splice;
88 this->use_overwrite = use_overwrite;
89 this->use_copy = use_copy;
90 this->use_paste = use_paste;
91 this->use_undo = use_undo;
92 this->mwindow = mwindow;
93 this->subwindow = subwindow;
94 this->use_fit = use_fit;
95 this->use_labels = use_labels;
96 this->use_locklabels = use_locklabels;
97 this->use_toclip = use_toclip;
98 this->use_meters = use_meters;
99 this->use_cut = use_cut;
100 this->use_commercial = use_commercial;
101 this->use_goto = use_goto;
102 this->use_clk2play = use_clk2play;
103 this->use_scope = use_scope;
104 this->use_gang_tracks = use_gang_tracks;
105 this->use_timecode = use_timecode;
117 this->commercial = 0;
120 this->labelbutton = 0;
125 this->gang_tracks = 0;
128 this->meter_panel = 0;
133 this->span_keyframe = 0;
135 this->click2play = 0;
137 this->scope_dialog = 0;
141 EditPanel::~EditPanel()
146 void EditPanel::set_meters(MeterPanel *meter_panel)
148 this->meter_panel = meter_panel;
152 void EditPanel::update()
154 int new_editing_mode = mwindow->edl->session->editing_mode;
155 if( arrow ) arrow->update(new_editing_mode == EDITING_ARROW);
156 if( ibeam ) ibeam->update(new_editing_mode == EDITING_IBEAM);
157 if( keyframe ) keyframe->update(mwindow->edl->session->auto_keyframes);
158 if( span_keyframe ) span_keyframe->update(mwindow->edl->session->span_keyframes);
159 if( locklabels ) locklabels->set_value(mwindow->edl->session->labels_follow_edits);
161 int value = !is_vwindow() ?
162 mwindow->edl->session->cwindow_click2play :
163 mwindow->edl->session->vwindow_click2play ;
164 click2play->set_value(value);
166 if( gang_tracks ) gang_tracks->update(mwindow->edl->local_session->gang_tracks);
169 meters->update(mwindow->edl->session->cwindow_meter);
170 mwindow->cwindow->gui->update_meters();
173 meters->update(mwindow->edl->session->vwindow_meter);
179 int EditPanel::calculate_w(MWindow *mwindow, int use_keyframe, int total_buttons)
181 int button_w = xS(24); // mwindow->theme->get_image_set("meters")[0]->get_w();
182 int result = button_w * total_buttons;
184 result += 2*(button_w + mwindow->theme->toggle_margin);
188 int EditPanel::calculate_h(MWindow *mwindow)
190 return mwindow->theme->get_image_set("meters")[0]->get_h();
193 void EditPanel::create_buttons()
197 if( use_editing_mode ) {
198 arrow = new ArrowButton(mwindow, this, x1, y1);
199 subwindow->add_subwindow(arrow);
200 x1 += arrow->get_w();
201 ibeam = new IBeamButton(mwindow, this, x1, y1);
202 subwindow->add_subwindow(ibeam);
203 x1 += ibeam->get_w();
204 x1 += mwindow->theme->toggle_margin;
208 keyframe = new KeyFrameButton(mwindow, this, x1, y1);
209 subwindow->add_subwindow(keyframe);
210 x1 += keyframe->get_w();
211 span_keyframe = new SpanKeyFrameButton(mwindow, this, x1, y1);
212 subwindow->add_subwindow(span_keyframe);
213 x1 += span_keyframe->get_w();
216 if( use_locklabels ) {
217 locklabels = new LockLabelsButton(mwindow, this, x1, y1);
218 subwindow->add_subwindow(locklabels);
219 x1 += locklabels->get_w();
222 if( use_keyframe || use_locklabels )
223 x1 += mwindow->theme->toggle_margin;
226 inpoint = new EditInPoint(mwindow, this, x1, y1);
227 subwindow->add_subwindow(inpoint);
228 x1 += inpoint->get_w();
229 outpoint = new EditOutPoint(mwindow, this, x1, y1);
230 subwindow->add_subwindow(outpoint);
231 x1 += outpoint->get_w();
234 splice = new EditSplice(mwindow, this, x1, y1);
235 subwindow->add_subwindow(splice);
236 x1 += splice->get_w();
239 if( use_overwrite ) {
240 overwrite = new EditOverwrite(mwindow, this, x1, y1);
241 subwindow->add_subwindow(overwrite);
242 x1 += overwrite->get_w();
246 clip = new EditToClip(mwindow, this, x1, y1);
247 subwindow->add_subwindow(clip);
252 cut = new EditCut(mwindow, this, x1, y1);
253 subwindow->add_subwindow(cut);
258 copy = new EditCopy(mwindow, this, x1, y1);
259 subwindow->add_subwindow(copy);
264 paste = new EditPaste(mwindow, this, x1, y1);
265 subwindow->add_subwindow(paste);
266 x1 += paste->get_w();
270 labelbutton = new EditLabelbutton(mwindow, this, x1, y1);
271 subwindow->add_subwindow(labelbutton);
272 x1 += labelbutton->get_w();
273 prevlabel = new EditPrevLabel(mwindow, this, x1, y1);
274 subwindow->add_subwindow(prevlabel);
275 x1 += prevlabel->get_w();
276 nextlabel = new EditNextLabel(mwindow, this, x1, y1);
277 subwindow->add_subwindow(nextlabel);
278 x1 += nextlabel->get_w();
281 // all windows except VWindow since it's only implemented in MWindow.
283 prevedit = new EditPrevEdit(mwindow, this, x1, y1);
284 subwindow->add_subwindow(prevedit);
285 x1 += prevedit->get_w();
286 nextedit = new EditNextEdit(mwindow, this, x1, y1);
287 subwindow->add_subwindow(nextedit);
288 x1 += nextedit->get_w();
292 fit = new EditFit(mwindow, this, x1, y1);
293 subwindow->add_subwindow(fit);
295 fit_autos = new EditFitAutos(mwindow, this, x1, y1);
296 subwindow->add_subwindow(fit_autos);
297 x1 += fit_autos->get_w();
301 undo = new EditUndo(mwindow, this, x1, y1);
302 subwindow->add_subwindow(undo);
304 redo = new EditRedo(mwindow, this, x1, y1);
305 subwindow->add_subwindow(redo);
310 mangoto = new EditManualGoto(mwindow, this, x1, y1);
311 subwindow->add_subwindow(mangoto);
312 x1 += mangoto->get_w();
316 click2play = new EditClick2Play(mwindow, this, x1, y1+yS(3));
317 subwindow->add_subwindow(click2play);
318 x1 += click2play->get_w();
322 scope = new EditPanelScope(mwindow, this, x1, y1-yS(1));
323 subwindow->add_subwindow(scope);
324 x1 += scope->get_w();
325 scope_dialog = new EditPanelScopeDialog(mwindow, this);
329 timecode = new EditPanelTimecode(mwindow, this, x1, y1);
330 subwindow->add_subwindow(timecode);
331 x1 += timecode->get_w();
334 if( use_gang_tracks ) {
335 gang_tracks = new EditPanelGangTracks(mwindow, this, x1, y1-yS(1));
336 subwindow->add_subwindow(gang_tracks);
337 x1 += gang_tracks->get_w();
342 meters = new MeterShow(mwindow, meter_panel, x1, y1);
343 subwindow->add_subwindow(meters);
344 x1 += meters->get_w();
347 printf("EditPanel::create_objects: meter_panel == 0\n");
350 if( use_commercial ) {
351 commercial = new EditCommercial(mwindow, this, x1, y1);
352 subwindow->add_subwindow(commercial);
353 x1 += commercial->get_w();
357 void EditPanel::reposition_buttons(int x, int y)
363 if( use_editing_mode ) {
364 arrow->reposition_window(x1, y1);
365 x1 += arrow->get_w();
366 ibeam->reposition_window(x1, y1);
367 x1 += ibeam->get_w();
368 x1 += mwindow->theme->toggle_margin;
372 keyframe->reposition_window(x1, y1);
373 x1 += keyframe->get_w();
374 span_keyframe->reposition_window(x1, y1);
375 x1 += span_keyframe->get_w();
378 if( use_locklabels ) {
379 locklabels->reposition_window(x1,y1);
380 x1 += locklabels->get_w();
383 if( use_keyframe || use_locklabels )
384 x1 += mwindow->theme->toggle_margin;
386 inpoint->reposition_window(x1, y1);
387 x1 += inpoint->get_w();
388 outpoint->reposition_window(x1, y1);
389 x1 += outpoint->get_w();
391 splice->reposition_window(x1, y1);
392 x1 += splice->get_w();
394 if( use_overwrite ) {
395 overwrite->reposition_window(x1, y1);
396 x1 += overwrite->get_w();
399 clip->reposition_window(x1, y1);
403 cut->reposition_window(x1, y1);
407 copy->reposition_window(x1, y1);
411 paste->reposition_window(x1, y1);
412 x1 += paste->get_w();
416 labelbutton->reposition_window(x1, y1);
417 x1 += labelbutton->get_w();
418 prevlabel->reposition_window(x1, y1);
419 x1 += prevlabel->get_w();
420 nextlabel->reposition_window(x1, y1);
421 x1 += nextlabel->get_w();
425 prevedit->reposition_window(x1, y1);
426 x1 += prevedit->get_w();
430 nextedit->reposition_window(x1, y1);
431 x1 += nextedit->get_w();
435 fit->reposition_window(x1, y1);
437 fit_autos->reposition_window(x1, y1);
438 x1 += fit_autos->get_w();
442 undo->reposition_window(x1, y1);
444 redo->reposition_window(x1, y1);
449 mangoto->reposition_window(x1, y1);
450 x1 += mangoto->get_w();
453 click2play->reposition_window(x1, y1+yS(3));
454 x1 += click2play->get_w();
457 scope->reposition_window(x1, y1-yS(1));
458 x1 += scope->get_w();
461 timecode->reposition_window(x1, y1);
462 x1 += timecode->get_w();
466 meters->reposition_window(x1, y1);
467 x1 += meters->get_w();
471 void EditPanel::create_objects()
476 int EditPanel::get_w()
482 EditLabelbutton::EditLabelbutton(MWindow *mwindow, EditPanel *panel, int x, int y)
483 : BC_Button(x, y, mwindow->theme->get_image_set("labelbutton"))
485 this->mwindow = mwindow;
487 set_tooltip(_("Toggle label at current position ( l )"));
488 // *** CONTEXT_HELP ***
489 context_help_set_keyword("Labels");
492 EditLabelbutton::~EditLabelbutton()
495 int EditLabelbutton::keypress_event()
497 if( get_keypress() == 'l' && !alt_down() )
498 return handle_event();
499 return context_help_check_and_show();
501 int EditLabelbutton::handle_event()
503 panel->panel_toggle_label();
508 EditNextLabel::EditNextLabel(MWindow *mwindow,
509 EditPanel *panel, int x, int y)
510 : BC_Button(x, y, mwindow->theme->get_image_set("nextlabel"))
512 this->mwindow = mwindow;
514 set_tooltip(_("Next label ( ctrl -> )"));
515 // *** CONTEXT_HELP ***
516 context_help_set_keyword("Labels");
518 EditNextLabel::~EditNextLabel()
521 int EditNextLabel::keypress_event()
524 int key = get_keypress();
525 if( (key == RIGHT || key == '.') && !alt_down() ) {
526 panel->panel_next_label(0);
529 if( key == '>' && alt_down() ) {
530 panel->panel_next_label(1);
534 return context_help_check_and_show();
536 int EditNextLabel::handle_event()
538 int cut = ctrl_down() && alt_down();
539 panel->panel_next_label(cut);
544 EditPrevLabel::EditPrevLabel(MWindow *mwindow,
545 EditPanel *panel, int x, int y)
546 : BC_Button(x, y, mwindow->theme->get_image_set("prevlabel"))
548 this->mwindow = mwindow;
550 set_tooltip(_("Previous label ( ctrl <- )"));
551 // *** CONTEXT_HELP ***
552 context_help_set_keyword("Labels");
554 EditPrevLabel::~EditPrevLabel()
557 int EditPrevLabel::keypress_event()
560 int key = get_keypress();
561 if( (key == LEFT || key == ',') && !alt_down() ) {
562 panel->panel_prev_label(0);
565 if( key == '<' && alt_down() ) {
566 panel->panel_prev_label(1);
570 return context_help_check_and_show();
572 int EditPrevLabel::handle_event()
574 int cut = ctrl_down() && alt_down();
575 panel->panel_prev_label(cut);
580 EditPrevEdit::EditPrevEdit(MWindow *mwindow,
581 EditPanel *panel, int x, int y)
582 : BC_Button(x, y, mwindow->theme->get_image_set("prevedit"))
584 this->mwindow = mwindow;
586 set_tooltip(_("Previous edit (alt <- )"));
587 // *** CONTEXT_HELP ***
588 context_help_set_keyword("Snapping while Cutting and Dragging");
590 EditPrevEdit::~EditPrevEdit()
593 int EditPrevEdit::keypress_event()
596 int key = get_keypress();
597 if( (key == LEFT || key == ',') && !ctrl_down() ) {
598 panel->panel_prev_edit(0);
601 if( key == ',' && ctrl_down() ) {
602 panel->panel_prev_edit(1);
606 return context_help_check_and_show();
608 int EditPrevEdit::handle_event()
610 int cut = ctrl_down() && alt_down();
611 panel->panel_prev_edit(cut);
616 EditNextEdit::EditNextEdit(MWindow *mwindow,
617 EditPanel *panel, int x, int y)
618 : BC_Button(x, y, mwindow->theme->get_image_set("nextedit"))
620 this->mwindow = mwindow;
622 set_tooltip(_("Next edit ( alt -> )"));
623 // *** CONTEXT_HELP ***
624 context_help_set_keyword("Snapping while Cutting and Dragging");
626 EditNextEdit::~EditNextEdit()
629 int EditNextEdit::keypress_event()
632 int key = get_keypress();
633 if( (key == RIGHT || key == '.') && !ctrl_down() ) {
634 panel->panel_next_edit(0);
637 if( key == '.' && ctrl_down() ) {
638 panel->panel_next_edit(1);
642 return context_help_check_and_show();
644 int EditNextEdit::handle_event()
646 int cut = ctrl_down() && alt_down();
647 panel->panel_next_edit(cut);
652 EditCopy::EditCopy(MWindow *mwindow, EditPanel *panel, int x, int y)
653 : BC_Button(x, y, mwindow->theme->get_image_set("copy"))
655 this->mwindow = mwindow;
657 set_tooltip(_("Copy ( c )"));
658 // *** CONTEXT_HELP ***
659 context_help_set_keyword("Cut and Paste Editing");
661 EditCopy::~EditCopy()
665 int EditCopy::keypress_event()
667 if( alt_down() ) return context_help_check_and_show();
668 if( (get_keypress() == 'c' && !ctrl_down()) ||
669 (panel->is_vwindow() && get_keypress() == 'C') ) {
670 return handle_event();
672 return context_help_check_and_show();
674 int EditCopy::handle_event()
676 panel->panel_copy_selection();
680 //overwrite_selection
681 EditOverwrite::EditOverwrite(MWindow *mwindow, EditPanel *panel, int x, int y)
682 : BC_Button(x, y, mwindow->theme->overwrite_data)
684 this->mwindow = mwindow;
686 set_tooltip(_("Overwrite ( b )"));
687 // *** CONTEXT_HELP ***
688 context_help_set_keyword("Two Screen Editing");
690 EditOverwrite::~EditOverwrite()
693 int EditOverwrite::handle_event()
695 panel->panel_overwrite_selection();
698 int EditOverwrite::keypress_event()
700 if( alt_down() ) return context_help_check_and_show();
701 if( get_keypress() == 'b' ||
702 (panel->is_vwindow() && get_keypress() == 'B') ) {
706 return context_help_check_and_show();
711 EditInPoint::EditInPoint(MWindow *mwindow, EditPanel *panel, int x, int y)
712 : BC_Button(x, y, mwindow->theme->get_image_set("inbutton"))
714 this->mwindow = mwindow;
716 set_tooltip(_("In point ( [ or < )"));
717 // *** CONTEXT_HELP ***
718 context_help_set_keyword("In\\/Out Points");
720 EditInPoint::~EditInPoint()
723 int EditInPoint::handle_event()
725 panel->panel_set_inpoint();
728 int EditInPoint::keypress_event()
730 int key = get_keypress();
733 panel->panel_unset_inoutpoint();
737 else if( !alt_down() ) {
738 if( key == '[' || key == '<' ) {
739 panel->panel_set_inpoint();
743 return context_help_check_and_show();
748 EditOutPoint::EditOutPoint(MWindow *mwindow, EditPanel *panel, int x, int y)
749 : BC_Button(x, y, mwindow->theme->get_image_set("outbutton"))
751 this->mwindow = mwindow;
753 set_tooltip(_("Out point ( ] or > )"));
754 // *** CONTEXT_HELP ***
755 context_help_set_keyword("In\\/Out Points");
757 EditOutPoint::~EditOutPoint()
760 int EditOutPoint::handle_event()
762 panel->panel_set_outpoint();
765 int EditOutPoint::keypress_event()
767 int key = get_keypress();
770 panel->panel_unset_inoutpoint();
774 else if( !alt_down() ) {
775 if( key == ']' || key == '>' ) {
776 panel->panel_set_outpoint();
780 return context_help_check_and_show();
784 EditSplice::EditSplice(MWindow *mwindow, EditPanel *panel, int x, int y)
785 : BC_Button(x, y, mwindow->theme->splice_data)
787 this->mwindow = mwindow;
789 set_tooltip(_("Splice ( v )"));
790 // *** CONTEXT_HELP ***
791 context_help_set_keyword("Two Screen Editing");
793 EditSplice::~EditSplice()
796 int EditSplice::handle_event()
798 panel->panel_splice_selection();
801 int EditSplice::keypress_event()
803 if( alt_down() ) return context_help_check_and_show();
804 if( (get_keypress() == 'v' && !ctrl_down()) ||
805 (panel->is_vwindow() && get_keypress() == 'V') ) {
809 return context_help_check_and_show();
813 EditToClip::EditToClip(MWindow *mwindow, EditPanel *panel, int x, int y)
814 : BC_Button(x, y, mwindow->theme->get_image_set("toclip"))
816 this->mwindow = mwindow;
818 set_tooltip(_("To clip ( i )"));
819 // *** CONTEXT_HELP ***
820 context_help_set_keyword("Two Screen Editing");
822 EditToClip::~EditToClip()
825 int EditToClip::handle_event()
827 panel->panel_to_clip();
831 int EditToClip::keypress_event()
833 if( alt_down() ) return context_help_check_and_show();
834 if( get_keypress() == 'i' ||
835 (panel->is_vwindow() && get_keypress() == 'I') ) {
839 return context_help_check_and_show();
843 EditCut::EditCut(MWindow *mwindow, EditPanel *panel, int x, int y)
844 : BC_Button(x, y, mwindow->theme->get_image_set("cut"))
846 this->mwindow = mwindow;
848 set_tooltip(_("Split | Cut ( x )"));
849 // *** CONTEXT_HELP ***
850 context_help_set_keyword("Cut and Paste Editing");
855 int EditCut::keypress_event()
857 if( ctrl_down() || shift_down() || alt_down() )
858 return context_help_check_and_show();
859 if( get_keypress() == 'x' )
860 return handle_event();
861 return context_help_check_and_show();
864 int EditCut::handle_event()
871 EditPaste::EditPaste(MWindow *mwindow, EditPanel *panel, int x, int y)
872 : BC_Button(x, y, mwindow->theme->get_image_set("paste"))
874 this->mwindow = mwindow;
876 set_tooltip(_("Paste ( v )"));
877 // *** CONTEXT_HELP ***
878 context_help_set_keyword("Cut and Paste Editing");
880 EditPaste::~EditPaste()
884 int EditPaste::keypress_event()
886 if( get_keypress() == 'v' && !ctrl_down() )
887 return handle_event();
888 return context_help_check_and_show();
890 int EditPaste::handle_event()
892 panel->panel_paste();
897 EditFit::EditFit(MWindow *mwindow, EditPanel *panel, int x, int y)
898 : BC_Button(x, y, mwindow->theme->get_image_set("fit"))
900 this->mwindow = mwindow;
902 set_tooltip(_("Fit selection to display ( f )"));
903 // *** CONTEXT_HELP ***
904 context_help_set_keyword("Transport and Buttons Bar");
909 int EditFit::keypress_event()
911 if( !alt_down() && get_keypress() == 'f' ) {
915 return context_help_check_and_show();
917 int EditFit::handle_event()
919 panel->panel_fit_selection();
924 EditFitAutos::EditFitAutos(MWindow *mwindow, EditPanel *panel, int x, int y)
925 : BC_Button(x, y, mwindow->theme->get_image_set("fitautos"))
927 this->mwindow = mwindow;
929 set_tooltip(_("Fit all autos to display ( Alt + f )"));
930 // *** CONTEXT_HELP ***
931 context_help_set_keyword("Using Autos");
933 EditFitAutos::~EditFitAutos()
936 int EditFitAutos::keypress_event()
938 if( get_keypress() == 'f' && alt_down() ) {
939 panel->panel_fit_autos(!ctrl_down() ? 1 : 0);
942 return context_help_check_and_show();
944 int EditFitAutos::handle_event()
946 panel->panel_fit_autos(1);
951 ArrowButton::ArrowButton(MWindow *mwindow, EditPanel *panel, int x, int y)
953 mwindow->theme->get_image_set("arrow"),
954 mwindow->edl->session->editing_mode == EDITING_ARROW,
957 this->mwindow = mwindow;
959 set_tooltip(_("Drag and drop editing mode"));
960 // *** CONTEXT_HELP ***
961 context_help_set_keyword("Drag and Drop Editing");
964 int ArrowButton::handle_event()
967 panel->ibeam->update(0);
968 panel->panel_set_editing_mode(EDITING_ARROW);
969 // Nothing after this
973 IBeamButton::IBeamButton(MWindow *mwindow, EditPanel *panel, int x, int y)
975 mwindow->theme->get_image_set("ibeam"),
976 mwindow->edl->session->editing_mode == EDITING_IBEAM,
979 this->mwindow = mwindow;
981 set_tooltip(_("Cut and paste editing mode"));
982 // *** CONTEXT_HELP ***
983 context_help_set_keyword("Cut and Paste Editing");
986 int IBeamButton::handle_event()
989 panel->arrow->update(0);
990 panel->panel_set_editing_mode(EDITING_IBEAM);
991 // Nothing after this
996 KeyFrameButton::KeyFrameButton(MWindow *mwindow, EditPanel *panel, int x, int y)
998 mwindow->theme->get_image_set("autokeyframe"),
999 mwindow->edl->session->auto_keyframes,
1002 this->mwindow = mwindow;
1003 this->panel = panel;
1004 set_tooltip(_("Generate keyframes while tweeking (j)"));
1005 // *** CONTEXT_HELP ***
1006 context_help_set_keyword("Generate Keyframes while Tweaking");
1009 int KeyFrameButton::handle_event()
1011 panel->panel_set_auto_keyframes(get_value());
1015 int KeyFrameButton::keypress_event()
1017 int key = get_keypress();
1018 if( key == 'j' && !ctrl_down() && !shift_down() && !alt_down() ) {
1019 int value = get_value() ? 0 : 1;
1021 panel->panel_set_auto_keyframes(value);
1024 return context_help_check_and_show();
1027 //set_span_keyframes
1028 SpanKeyFrameButton::SpanKeyFrameButton(MWindow *mwindow, EditPanel *panel, int x, int y)
1030 mwindow->theme->get_image_set("spankeyframe"),
1031 mwindow->edl->session->span_keyframes,
1034 this->mwindow = mwindow;
1035 this->panel = panel;
1036 set_tooltip(_("Allow keyframe spanning"));
1037 // *** CONTEXT_HELP ***
1038 context_help_set_keyword("Allow Keyframe Spanning");
1041 int SpanKeyFrameButton::handle_event()
1043 panel->panel_set_span_keyframes(get_value());
1047 //set_labels_follow_edits
1048 LockLabelsButton::LockLabelsButton(MWindow *mwindow, EditPanel *panel, int x, int y)
1050 mwindow->theme->get_image_set("locklabels"),
1051 mwindow->edl->session->labels_follow_edits,
1054 this->mwindow = mwindow;
1055 this->panel = panel;
1056 set_tooltip(_("Lock labels from moving with edits"));
1057 // *** CONTEXT_HELP ***
1058 context_help_set_keyword("Labels");
1061 int LockLabelsButton::handle_event()
1063 panel->panel_set_labels_follow_edits(get_value());
1069 EditManualGoto::EditManualGoto(MWindow *mwindow, EditPanel *panel, int x, int y)
1070 : BC_Button(x, y, mwindow->theme->get_image_set("goto"))
1072 this->mwindow = mwindow;
1073 this->panel = panel;
1074 mangoto = new ManualGoto(mwindow, panel);
1075 set_tooltip(_("Manual goto ( g )"));
1076 // *** CONTEXT_HELP ***
1077 context_help_set_keyword("Transport and Buttons Bar");
1079 EditManualGoto::~EditManualGoto()
1083 int EditManualGoto::handle_event()
1089 int EditManualGoto::keypress_event()
1091 if( get_keypress() == 'g' ) {
1095 return context_help_check_and_show();
1099 EditClick2Play::EditClick2Play(MWindow *mwindow, EditPanel *panel, int x, int y)
1100 : BC_Toggle(x, y, mwindow->theme->get_image_set("playpatch_data"),
1101 !panel->is_vwindow() ?
1102 mwindow->edl->session->cwindow_click2play :
1103 mwindow->edl->session->vwindow_click2play)
1105 this->mwindow = mwindow;
1106 this->panel = panel;
1107 set_tooltip(_("Click to play (p)"));
1108 // *** CONTEXT_HELP ***
1109 context_help_set_keyword("Click to Play in Viewer and Compositor");
1111 int EditClick2Play::handle_event()
1113 int value = get_value();
1114 panel->set_click_to_play(value);
1117 int EditClick2Play::keypress_event()
1119 int key = get_keypress();
1120 if( key == 'p' && !ctrl_down() && !shift_down() && !alt_down() ) {
1121 int value = get_value() ? 0 : 1;
1123 panel->set_click_to_play(value);
1126 return context_help_check_and_show();
1130 EditCommercial::EditCommercial(MWindow *mwindow, EditPanel *panel, int x, int y)
1131 : BC_Button(x, y, mwindow->theme->get_image_set("commercial"))
1133 this->mwindow = mwindow;
1134 this->panel = panel;
1135 set_tooltip(_("Commercial ( shift A )"));
1136 // *** CONTEXT_HELP ***
1137 context_help_set_keyword("The commercial DB");
1139 EditCommercial::~EditCommercial()
1142 int EditCommercial::keypress_event()
1144 if( ctrl_down() || !shift_down() || alt_down() )
1145 return context_help_check_and_show();
1146 if( get_keypress() == 'A' )
1147 return handle_event();
1148 return context_help_check_and_show();
1151 int EditCommercial::handle_event()
1153 int have_mwindow_lock = mwindow->gui->get_window_lock();
1154 if( have_mwindow_lock )
1155 mwindow->gui->unlock_window();
1156 mwindow->commit_commercial();
1157 if( !mwindow->put_commercial() ) {
1158 mwindow->gui->lock_window("EditCommercial::handle_event 1");
1160 if( !have_mwindow_lock )
1161 mwindow->gui->unlock_window();
1162 mwindow->activate_commercial();
1165 mwindow->undo_commercial();
1166 if( have_mwindow_lock )
1167 mwindow->gui->lock_window("EditCommercial::handle_event 2");
1172 EditUndo::EditUndo(MWindow *mwindow, EditPanel *panel, int x, int y)
1173 : BC_Button(x, y, mwindow->theme->get_image_set("undo"))
1175 this->mwindow = mwindow;
1176 this->panel = panel;
1177 set_tooltip(_("Undo ( z or Ctrl-z)"));
1178 // *** CONTEXT_HELP ***
1179 context_help_set_keyword("Transport and Buttons Bar");
1181 EditUndo::~EditUndo()
1184 int EditUndo::keypress_event()
1186 if( ctrl_down() || shift_down() || alt_down() )
1187 return context_help_check_and_show();
1188 if( get_keypress() == 'z' )
1189 return handle_event();
1190 return context_help_check_and_show();
1192 int EditUndo::handle_event()
1194 mwindow->undo_entry(panel->subwindow);
1198 EditRedo::EditRedo(MWindow *mwindow, EditPanel *panel, int x, int y)
1199 : BC_Button(x, y, mwindow->theme->get_image_set("redo"))
1201 this->mwindow = mwindow;
1202 this->panel = panel;
1203 set_tooltip(_("Redo ( shift Z )"));
1204 // *** CONTEXT_HELP ***
1205 context_help_set_keyword("Transport and Buttons Bar");
1207 EditRedo::~EditRedo()
1210 int EditRedo::keypress_event()
1212 if( ctrl_down() || !shift_down() || alt_down() )
1213 return context_help_check_and_show();
1214 if( get_keypress() == 'Z' )
1215 return handle_event();
1216 return context_help_check_and_show();
1218 int EditRedo::handle_event()
1220 mwindow->redo_entry(panel->subwindow);
1225 EditPanelScopeDialog::EditPanelScopeDialog(MWindow *mwindow, EditPanel *panel)
1228 this->mwindow = mwindow;
1229 this->panel = panel;
1231 gui_lock = new Mutex("EditPanelScopeDialog::gui_lock");
1234 EditPanelScopeDialog::~EditPanelScopeDialog()
1240 void EditPanelScopeDialog::handle_close_event(int result)
1244 void EditPanelScopeDialog::handle_done_event(int result)
1246 gui_lock->lock("EditPanelScopeDialog::handle_done_event");
1250 panel->subwindow->lock_window("EditPanelScopeDialog::handle_done_event");
1251 panel->scope->update(0);
1252 panel->subwindow->unlock_window();
1255 BC_Window* EditPanelScopeDialog::new_gui()
1257 EditPanelScopeGUI *gui = new EditPanelScopeGUI(mwindow, this);
1258 gui->create_objects();
1263 void EditPanelScopeDialog::process(VFrame *output_frame)
1265 if( panel->scope_dialog ) {
1266 panel->scope_dialog->gui_lock->lock("EditPanelScopeDialog::process");
1267 if( panel->scope_dialog->scope_gui ) {
1268 EditPanelScopeGUI *gui = panel->scope_dialog->scope_gui;
1269 gui->process(output_frame);
1271 panel->scope_dialog->gui_lock->unlock();
1275 EditPanelScopeGUI::EditPanelScopeGUI(MWindow *mwindow, EditPanelScopeDialog *dialog)
1276 : ScopeGUI(mwindow->theme,
1277 mwindow->session->scope_x, mwindow->session->scope_y,
1278 mwindow->session->scope_w, mwindow->session->scope_h,
1279 mwindow->get_cpus())
1281 this->mwindow = mwindow;
1282 this->dialog = dialog;
1285 EditPanelScopeGUI::~EditPanelScopeGUI()
1289 void EditPanelScopeGUI::create_objects()
1291 MainSession *session = mwindow->session;
1292 use_hist = session->use_hist;
1293 use_wave = session->use_wave;
1294 use_vector = session->use_vector;
1295 use_hist_parade = session->use_hist_parade;
1296 use_wave_parade = session->use_wave_parade;
1297 use_wave_gain = session->use_wave_gain;
1298 use_vect_gain = session->use_vect_gain;
1299 use_smooth = session->use_smooth;
1300 use_refresh = session->use_refresh;
1301 use_release = session->use_release;
1302 use_graticule = session->use_graticule;
1303 ScopeGUI::create_objects();
1306 void EditPanelScopeGUI::toggle_event()
1308 MainSession *session = mwindow->session;
1309 session->use_hist = use_hist;
1310 session->use_wave = use_wave;
1311 session->use_vector = use_vector;
1312 session->use_hist_parade = use_hist_parade;
1313 session->use_wave_parade = use_wave_parade;
1314 session->use_wave_gain = use_wave_gain;
1315 session->use_vect_gain = use_vect_gain;
1316 session->use_smooth = use_smooth;
1317 session->use_refresh = use_refresh;
1318 session->use_release = use_release;
1319 session->use_graticule = use_graticule;
1322 int EditPanelScopeGUI::translation_event()
1324 ScopeGUI::translation_event();
1325 MainSession *session = mwindow->session;
1326 session->scope_x = get_x();
1327 session->scope_y = get_y();
1331 int EditPanelScopeGUI::resize_event(int w, int h)
1333 ScopeGUI::resize_event(w, h);
1334 MainSession *session = mwindow->session;
1335 session->scope_w = w;
1336 session->scope_h = h;
1340 EditPanelScope::EditPanelScope(MWindow *mwindow, EditPanel *panel, int x, int y)
1341 : BC_Toggle(x, y, mwindow->theme ?
1342 mwindow->theme->get_image_set("scope_toggle") : 0, 0)
1344 this->mwindow = mwindow;
1345 this->panel = panel;
1346 set_tooltip(_("View scope"));
1347 // *** CONTEXT_HELP ***
1348 context_help_set_keyword("Videoscope");
1351 EditPanelScope::~EditPanelScope()
1355 void EditPanelScopeGUI::update_scope()
1358 if( dialog->panel->is_cwindow() ) {
1359 CWindowGUI *cgui = (CWindowGUI *)dialog->panel->subwindow;
1360 canvas = cgui->canvas;
1362 else if( dialog->panel->is_vwindow() ) {
1363 VWindowGUI *vgui = (VWindowGUI *)dialog->panel->subwindow;
1364 canvas = vgui->canvas;
1366 if( canvas && canvas->refresh_frame )
1367 process(canvas->refresh_frame);
1370 int EditPanelScope::handle_event()
1373 int v = get_value();
1375 panel->scope_dialog->start();
1377 panel->scope_dialog->close_window();
1378 lock_window("EditPanelScope::handle_event");
1382 const char *EditPanelGangTracks::gang_tips[TOTAL_GANGS] = {
1383 N_("Currently: Gang None\n Click to: Gang Channels"),
1384 N_("Currently: Gang Channels\n Click to: Gang Media"),
1385 N_("Currently: Gang Media\n Click to: Gang None"),
1388 EditPanelGangTracks::EditPanelGangTracks(MWindow *mwindow, EditPanel *panel,
1390 : BC_Button(x, y, get_images(mwindow))
1392 this->mwindow = mwindow;
1393 this->panel = panel;
1394 int gang = mwindow->edl->local_session->gang_tracks;
1395 set_tooltip(_(gang_tips[gang]));
1396 // *** CONTEXT_HELP ***
1397 context_help_set_keyword("Displaying tracks: Ganged mode");
1400 EditPanelGangTracks::~EditPanelGangTracks()
1404 VFrame **EditPanelGangTracks::gang_images[TOTAL_GANGS];
1406 VFrame **EditPanelGangTracks::get_images(MWindow *mwindow)
1408 gang_images[GANG_NONE] = mwindow->theme->get_image_set("gang0");
1409 gang_images[GANG_MEDIA] = mwindow->theme->get_image_set("gang1");
1410 gang_images[GANG_CHANNELS] = mwindow->theme->get_image_set("gang2");
1411 int gang = mwindow->edl->local_session->gang_tracks;
1412 return gang_images[gang];
1415 void EditPanelGangTracks::update(int gang)
1417 set_images(gang_images[gang]);
1419 set_tooltip(_(gang_tips[gang]));
1422 int EditPanelGangTracks::handle_event()
1424 int gang = mwindow->edl->local_session->gang_tracks;
1425 if( !shift_down() ) {
1426 if( ++gang > GANG_MEDIA ) gang = GANG_NONE;
1429 if( --gang < GANG_NONE ) gang = GANG_MEDIA;
1432 panel->panel_set_gang_tracks(gang);
1437 EditPanelTimecode::EditPanelTimecode(MWindow *mwindow,
1438 EditPanel *panel, int x, int y)
1439 : BC_Button(x, y, mwindow->theme->get_image_set("clapperbutton"))
1441 this->mwindow = mwindow;
1442 this->panel = panel;
1444 set_tooltip(_("Set Timecode"));
1445 // *** CONTEXT_HELP ***
1446 context_help_set_keyword("Align Timecodes");
1449 EditPanelTimecode::~EditPanelTimecode()
1454 int EditPanelTimecode::handle_event()
1457 tc_dialog = new EditPanelTcDialog(mwindow, panel);
1459 get_pop_cursor(px, py, 0);
1460 tc_dialog->start_dialog(px, py);
1464 EditPanelTcDialog::EditPanelTcDialog(MWindow *mwindow, EditPanel *panel)
1467 this->mwindow = mwindow;
1468 this->panel = panel;
1473 EditPanelTcDialog::~EditPanelTcDialog()
1478 #define TCW_W xS(200)
1479 #define TCW_H yS(120)
1481 void EditPanelTcDialog::start_dialog(int px, int py)
1483 this->px = px - TCW_W/2;
1484 this->py = py - TCW_H/2;
1488 BC_Window *EditPanelTcDialog::new_gui()
1490 tc_gui = new EditPanelTcWindow(this, px, py);
1491 tc_gui->create_objects();
1492 double timecode = mwindow->get_timecode_offset();
1493 tc_gui->update(timecode);
1494 tc_gui->show_window();
1498 void EditPanelTcDialog::handle_done_event(int result)
1500 if( result ) return;
1501 double ofs = tc_gui->get_timecode();
1502 mwindow->set_timecode_offset(ofs);
1505 EditPanelTcWindow::EditPanelTcWindow(EditPanelTcDialog *tc_dialog, int x, int y)
1506 : BC_Window(_(PROGRAM_NAME ": Timecode"), x, y,
1507 TCW_W, TCW_H, TCW_W, TCW_H, 0, 0, 1)
1509 this->tc_dialog = tc_dialog;
1510 // *** CONTEXT_HELP ***
1511 context_help_set_keyword("Align Timecodes");
1514 EditPanelTcWindow::~EditPanelTcWindow()
1518 double EditPanelTcWindow::get_timecode()
1520 int hrs = atoi(hours->get_text());
1521 int mins = atoi(minutes->get_text());
1522 int secs = atoi(seconds->get_text());
1523 int frms = atoi(frames->get_text());
1524 double frame_rate = tc_dialog->mwindow->edl->session->frame_rate;
1525 double timecode = hrs*3600 + mins*60 + secs + frms/frame_rate;
1529 void EditPanelTcWindow::update(double timecode)
1531 if( timecode < 0 ) timecode = 0;
1532 int64_t pos = timecode;
1534 int mins = pos/60 - hrs*60;
1535 int secs = pos - hrs*3600 - mins*60;
1536 double frame_rate = tc_dialog->mwindow->edl->session->frame_rate;
1537 int frms = (timecode-pos) * frame_rate;
1539 minutes->update(mins);
1540 seconds->update(secs);
1541 frames->update(frms);
1544 void EditPanelTcWindow::create_objects()
1546 lock_window("EditPanelTcWindow::create_objects");
1547 int x = xS(20), y = yS(5);
1548 BC_Title *title = new BC_Title(x - 2, y, _("hour min sec frms"), SMALLFONT);
1549 add_subwindow(title); y += title->get_h() + xS(3);
1550 hours = new EditPanelTcInt(this, x, y, xS(26), 99, "%02i");
1551 add_subwindow(hours); x += hours->get_w() + xS(4);
1552 minutes = new EditPanelTcInt(this, x, y, xS(26), 59, "%02i");
1553 add_subwindow(minutes); x += minutes->get_w() + xS(4);
1554 seconds = new EditPanelTcInt(this, x, y, xS(26), 60, "%02i");
1555 add_subwindow(seconds); x += seconds->get_w() + xS(4);
1556 frames = new EditPanelTcInt(this, x, y, xS(34), 999, "%03i");
1557 add_subwindow(frames); x += frames->get_w() + xS(16);
1558 add_subwindow(new EditPanelTcReset(this, x, y));
1559 double timecode = tc_dialog->mwindow->get_timecode_offset();
1561 add_subwindow(new BC_OKButton(this));
1562 add_subwindow(new BC_CancelButton(this));
1566 EditPanelTcReset::EditPanelTcReset(EditPanelTcWindow *window, int x, int y)
1567 : BC_Button(x, y, window->tc_dialog->mwindow->theme->get_image_set("reset_button"))
1569 this->window = window;
1572 int EditPanelTcReset::handle_event()
1579 EditPanelTcInt::EditPanelTcInt(EditPanelTcWindow *window, int x, int y, int w,
1580 int max, const char *format)
1581 : BC_TextBox(x, y, w, 1, "")
1583 this->window = window;
1585 this->format = format;
1587 for( int m=max; (m/=10)>0; ++digits );
1590 EditPanelTcInt::~EditPanelTcInt()
1594 int EditPanelTcInt::handle_event()
1596 int v = atoi(get_text());
1599 char string[BCSTRLEN];
1600 sprintf(string, format, v);
1601 BC_TextBox::update(string);
1606 void EditPanelTcInt::update(int v)
1608 char text[BCTEXTLEN];
1609 if( v > max ) v = max;
1610 sprintf(text, format, v);
1611 BC_TextBox::update(text);
1614 int EditPanelTcInt::keypress_event()
1616 if( get_keypress() == 'h' && alt_down() ) {
1617 context_help_show("Align Timecodes");
1621 if( (int)strlen(get_text()) >= digits )
1622 BC_TextBox::update("");
1623 int key = get_keypress();
1625 case TAB: case LEFTTAB:
1626 case LEFT: case RIGHT:
1627 case HOME: case END:
1630 case '0': case '1': case '2': case '3': case '4':
1631 case '5': case '6': case '7': case '8': case '9':
1632 return BC_TextBox::keypress_event();