2 #include "awindowgui.h"
9 #include "edlsession.h"
13 #include "localsession.h"
14 #include "mainclock.h"
17 #include "meterpanel.h"
19 #include "mwindowgui.h"
20 #include "playbackengine.h"
23 #include "trackcanvas.h"
24 #include "transportque.h"
26 #include "manualgoto.h"
30 EditPanel::EditPanel(MWindow *mwindow,
31 BC_WindowBase *subwindow,
37 int use_splice, // Extra buttons
51 this->editing_mode = editing_mode;
52 this->use_editing_mode = use_editing_mode;
53 this->use_keyframe = use_keyframe;
54 this->use_splice = use_splice;
55 this->use_overwrite = use_overwrite;
57 this->use_extract = 0;
58 this->use_copy = use_copy;
59 this->use_paste = use_paste;
60 this->use_undo = use_undo;
61 this->mwindow = mwindow;
62 this->subwindow = subwindow;
63 this->use_fit = use_fit;
64 this->use_labels = use_labels;
65 this->use_toclip = use_toclip;
66 this->use_meters = use_meters;
67 this->is_mwindow = is_mwindow;
68 this->use_cut = use_cut;
72 this->meter_panel = 0;
80 EditPanel::~EditPanel()
84 void EditPanel::set_meters(MeterPanel *meter_panel)
86 this->meter_panel = meter_panel;
90 void EditPanel::update()
92 int new_editing_mode = mwindow->edl->session->editing_mode;
93 if(arrow) arrow->update(new_editing_mode == EDITING_ARROW);
94 if(ibeam) ibeam->update(new_editing_mode == EDITING_IBEAM);
95 if(keyframe) keyframe->update(mwindow->edl->session->auto_keyframes);
99 void EditPanel::delete_buttons()
103 if(arrow) delete arrow;
104 if(ibeam) delete ibeam;
111 if(inpoint) delete inpoint;
112 if(outpoint) delete outpoint;
113 if(use_copy) delete copy;
114 if(use_splice) delete splice;
115 if(use_overwrite) delete overwrite;
116 if(use_lift) delete lift;
117 if(use_extract) delete extract;
119 if(copy) delete copy;
120 if(use_paste) delete paste;
141 void EditPanel::create_buttons()
149 subwindow->add_subwindow(arrow = new ArrowButton(mwindow, this, x1, y1));
150 x1 += arrow->get_w();
151 subwindow->add_subwindow(ibeam = new IBeamButton(mwindow, this, x1, y1));
152 x1 += ibeam->get_w();
157 subwindow->add_subwindow(keyframe = new KeyFrameButton(mwindow, x1, y1));
158 x1 += keyframe->get_w();
159 x1 += mwindow->theme->toggle_margin;
163 subwindow->add_subwindow(inpoint = new EditInPoint(mwindow, this, x1, y1));
164 x1 += inpoint->get_w();
165 subwindow->add_subwindow(outpoint = new EditOutPoint(mwindow, this, x1, y1));
166 x1 += outpoint->get_w();
169 subwindow->add_subwindow(splice = new EditSplice(mwindow, this, x1, y1));
170 x1 += splice->get_w();
174 subwindow->add_subwindow(overwrite = new EditOverwrite(mwindow, this, x1, y1));
175 x1 += overwrite->get_w();
179 subwindow->add_subwindow(lift = new EditLift(mwindow, this, x1, y1));
184 subwindow->add_subwindow(extract = new EditExtract(mwindow, this, x1, y1));
185 x1 += extract->get_w();
189 subwindow->add_subwindow(clip = new EditToClip(mwindow, this, x1, y1));
195 subwindow->add_subwindow(cut = new EditCut(mwindow, this, x1, y1));
200 subwindow->add_subwindow(copy = new EditCopy(mwindow, this, x1, y1));
205 subwindow->add_subwindow(paste = new EditPaste(mwindow, this, x1, y1));
206 x1 += paste->get_w();
213 printf("EditPanel::create_objects: meter_panel == 0\n");
215 subwindow->add_subwindow(meters = new MeterShow(mwindow, meter_panel, x1, y1));
216 x1 += meters->get_w();
221 subwindow->add_subwindow(labelbutton = new EditLabelbutton(mwindow,
225 x1 += labelbutton->get_w();
226 subwindow->add_subwindow(prevlabel = new EditPrevLabel(mwindow,
231 x1 += prevlabel->get_w();
232 subwindow->add_subwindow(nextlabel = new EditNextLabel(mwindow,
237 x1 += nextlabel->get_w();
242 subwindow->add_subwindow(fit = new EditFit(mwindow, this, x1, y1));
244 subwindow->add_subwindow(fit_autos = new EditFitAutos(mwindow, this, x1, y1));
245 x1 += fit_autos->get_w();
250 subwindow->add_subwindow(undo = new EditUndo(mwindow, this, x1, y1));
252 subwindow->add_subwindow(redo = new EditRedo(mwindow, this, x1, y1));
255 subwindow->add_subwindow(mangoto = new EditManualGoto(mwindow, this, x1, y1));
256 x1 += mangoto->get_w();
263 void EditPanel::toggle_label()
265 mwindow->toggle_label(is_mwindow);
268 void EditPanel::prev_label()
270 int shift_down = subwindow->shift_down();
273 mwindow->gui->unlock_window();
276 subwindow->unlock_window();
278 mwindow->gui->mbuttons->transport->handle_transport(STOP, 1, 0, 0);
281 subwindow->lock_window("EditPanel::prev_label 1");
283 mwindow->gui->lock_window("EditPanel::prev_label 2");
285 mwindow->prev_label(shift_down);
288 mwindow->gui->unlock_window();
291 void EditPanel::next_label()
293 int shift_down = subwindow->shift_down();
296 mwindow->gui->unlock_window();
299 subwindow->unlock_window();
301 mwindow->gui->mbuttons->transport->handle_transport(STOP, 1, 0, 0);
304 subwindow->lock_window("EditPanel::next_label 1");
306 mwindow->gui->lock_window("EditPanel::next_label 2");
308 mwindow->next_label(shift_down);
311 mwindow->gui->unlock_window();
317 void EditPanel::reposition_buttons(int x, int y)
325 arrow->reposition_window(x1, y1);
326 x1 += arrow->get_w();
327 ibeam->reposition_window(x1, y1);
328 x1 += ibeam->get_w();
333 keyframe->reposition_window(x1, y1);
334 x1 += keyframe->get_w();
335 x1 += mwindow->theme->toggle_margin;
338 inpoint->reposition_window(x1, y1);
339 x1 += inpoint->get_w();
340 outpoint->reposition_window(x1, y1);
341 x1 += outpoint->get_w();
344 splice->reposition_window(x1, y1);
345 x1 += splice->get_w();
349 overwrite->reposition_window(x1, y1);
350 x1 += overwrite->get_w();
354 lift->reposition_window(x1, y1);
359 extract->reposition_window(x1, y1);
360 x1 += extract->get_w();
364 clip->reposition_window(x1, y1);
369 cut->reposition_window(x1, y1);
374 copy->reposition_window(x1, y1);
379 paste->reposition_window(x1, y1);
380 x1 += paste->get_w();
385 meters->reposition_window(x1, y1);
386 x1 += meters->get_w();
391 labelbutton->reposition_window(x1, y1);
392 x1 += labelbutton->get_w();
393 prevlabel->reposition_window(x1, y1);
394 x1 += prevlabel->get_w();
395 nextlabel->reposition_window(x1, y1);
396 x1 += nextlabel->get_w();
401 fit->reposition_window(x1, y1);
403 fit_autos->reposition_window(x1, y1);
404 x1 += fit_autos->get_w();
409 undo->reposition_window(x1, y1);
411 redo->reposition_window(x1, y1);
415 mangoto->reposition_window(x1, y1);
416 x1 += mangoto->get_w();
421 int EditPanel::create_objects()
427 int EditPanel::get_w()
433 void EditPanel::copy_selection()
438 void EditPanel::splice_selection()
442 void EditPanel::overwrite_selection()
446 void EditPanel::set_inpoint()
448 mwindow->set_inpoint(1);
451 void EditPanel::set_outpoint()
453 mwindow->set_outpoint(1);
456 void EditPanel::clear_inpoint()
458 mwindow->delete_inpoint();
461 void EditPanel::clear_outpoint()
463 mwindow->delete_outpoint();
466 void EditPanel::to_clip()
472 EditInPoint::EditInPoint(MWindow *mwindow, EditPanel *panel, int x, int y)
473 : BC_Button(x, y, mwindow->theme->get_image_set("inbutton"))
475 this->mwindow = mwindow;
477 set_tooltip(_("In point ( [ )"));
479 EditInPoint::~EditInPoint()
482 int EditInPoint::handle_event()
484 panel->set_inpoint();
487 int EditInPoint::keypress_event()
489 if(get_keypress() == '[')
491 panel->set_inpoint();
497 EditOutPoint::EditOutPoint(MWindow *mwindow, EditPanel *panel, int x, int y)
498 : BC_Button(x, y, mwindow->theme->get_image_set("outbutton"))
500 this->mwindow = mwindow;
502 set_tooltip(_("Out point ( ] )"));
504 EditOutPoint::~EditOutPoint()
507 int EditOutPoint::handle_event()
509 panel->set_outpoint();
512 int EditOutPoint::keypress_event()
514 if(get_keypress() == ']')
516 panel->set_outpoint();
523 EditNextLabel::EditNextLabel(MWindow *mwindow,
528 : BC_Button(x, y, mwindow->theme->get_image_set("nextlabel"))
530 this->mwindow = mwindow;
532 this->is_mwindow = is_mwindow;
533 set_tooltip(_("Next label ( ctrl -> )"));
535 EditNextLabel::~EditNextLabel()
538 int EditNextLabel::keypress_event()
540 if(get_keypress() == RIGHT && ctrl_down())
541 return handle_event();
544 int EditNextLabel::handle_event()
550 EditPrevLabel::EditPrevLabel(MWindow *mwindow,
555 : BC_Button(x, y, mwindow->theme->get_image_set("prevlabel"))
557 this->mwindow = mwindow;
559 this->is_mwindow = is_mwindow;
560 set_tooltip(_("Previous label ( ctrl <- )"));
562 EditPrevLabel::~EditPrevLabel()
565 int EditPrevLabel::keypress_event()
567 if(get_keypress() == LEFT && ctrl_down())
568 return handle_event();
571 int EditPrevLabel::handle_event()
577 EditLift::EditLift(MWindow *mwindow, EditPanel *panel, int x, int y)
578 : BC_Button(x, y, mwindow->theme->lift_data)
580 this->mwindow = mwindow;
582 set_tooltip(_("Lift"));
584 EditLift::~EditLift()
587 int EditLift::handle_event()
592 EditOverwrite::EditOverwrite(MWindow *mwindow, EditPanel *panel, int x, int y)
593 : BC_Button(x, y, mwindow->theme->overwrite_data)
595 this->mwindow = mwindow;
597 set_tooltip(_("Overwrite ( b )"));
599 EditOverwrite::~EditOverwrite()
602 int EditOverwrite::handle_event()
604 panel->overwrite_selection();
607 int EditOverwrite::keypress_event()
609 if(get_keypress() == 'b')
617 EditExtract::EditExtract(MWindow *mwindow, EditPanel *panel, int x, int y)
618 : BC_Button(x, y, mwindow->theme->extract_data)
620 this->mwindow = mwindow;
622 set_tooltip(_("Extract"));
624 EditExtract::~EditExtract()
627 int EditExtract::handle_event()
629 // mwindow->extract_selection();
633 EditToClip::EditToClip(MWindow *mwindow, EditPanel *panel, int x, int y)
634 : BC_Button(x, y, mwindow->theme->get_image_set("toclip"))
636 this->mwindow = mwindow;
638 set_tooltip(_("To clip ( i )"));
640 EditToClip::~EditToClip()
643 int EditToClip::handle_event()
649 int EditToClip::keypress_event()
651 if(get_keypress() == 'i')
659 EditManualGoto::EditManualGoto(MWindow *mwindow, EditPanel *panel, int x, int y)
660 : BC_Button(x, y, mwindow->theme->get_image_set("goto"))
662 this->mwindow = mwindow;
664 mangoto = new ManualGoto(mwindow, panel->subwindow);
665 set_tooltip(_("Manual goto ( g )"));
667 EditManualGoto::~EditManualGoto()
671 int EditManualGoto::handle_event()
673 mangoto->open_window();
677 int EditManualGoto::keypress_event()
679 if(get_keypress() == 'g')
688 EditSplice::EditSplice(MWindow *mwindow, EditPanel *panel, int x, int y)
689 : BC_Button(x, y, mwindow->theme->splice_data)
691 this->mwindow = mwindow;
693 set_tooltip(_("Splice ( v )"));
695 EditSplice::~EditSplice()
698 int EditSplice::handle_event()
700 panel->splice_selection();
703 int EditSplice::keypress_event()
705 if(get_keypress() == 'v')
713 EditCut::EditCut(MWindow *mwindow, EditPanel *panel, int x, int y)
714 : BC_Button(x, y, mwindow->theme->get_image_set("cut"))
716 this->mwindow = mwindow;
718 set_tooltip(_("Cut ( x )"));
723 int EditCut::keypress_event()
725 if(get_keypress() == 'x')
726 return handle_event();
730 int EditCut::handle_event()
732 if(!panel->is_mwindow) mwindow->gui->lock_window("EditCut::handle_event");
734 if(!panel->is_mwindow) mwindow->gui->unlock_window();
738 EditCopy::EditCopy(MWindow *mwindow, EditPanel *panel, int x, int y)
739 : BC_Button(x, y, mwindow->theme->get_image_set("copy"))
741 this->mwindow = mwindow;
743 set_tooltip(_("Copy ( c )"));
745 EditCopy::~EditCopy()
749 int EditCopy::keypress_event()
751 if(get_keypress() == 'c')
752 return handle_event();
755 int EditCopy::handle_event()
757 panel->copy_selection();
761 EditAppend::EditAppend(MWindow *mwindow, EditPanel *panel, int x, int y)
762 : BC_Button(x, y, mwindow->theme->append_data)
764 this->mwindow = mwindow;
766 set_tooltip(_("Append to end of track"));
768 EditAppend::~EditAppend()
773 int EditAppend::handle_event()
779 EditInsert::EditInsert(MWindow *mwindow, EditPanel *panel, int x, int y)
780 : BC_Button(x, y, mwindow->theme->insert_data)
782 this->mwindow = mwindow;
784 set_tooltip(_("Insert before beginning of track"));
786 EditInsert::~EditInsert()
791 int EditInsert::handle_event()
798 EditPaste::EditPaste(MWindow *mwindow, EditPanel *panel, int x, int y)
799 : BC_Button(x, y, mwindow->theme->get_image_set("paste"))
801 this->mwindow = mwindow;
803 set_tooltip(_("Paste ( v )"));
805 EditPaste::~EditPaste()
809 int EditPaste::keypress_event()
811 if(get_keypress() == 'v')
812 return handle_event();
815 int EditPaste::handle_event()
817 if(!panel->is_mwindow) mwindow->gui->lock_window("EditPaste::handle_event");
819 if(!panel->is_mwindow) mwindow->gui->unlock_window();
825 EditTransition::EditTransition(MWindow *mwindow, EditPanel *panel, int x, int y)
826 : BC_Button(x, y, mwindow->theme->transition_data)
828 this->mwindow = mwindow;
830 set_tooltip(_("Set transition"));
832 EditTransition::~EditTransition()
835 int EditTransition::handle_event()
840 EditPresentation::EditPresentation(MWindow *mwindow, EditPanel *panel, int x, int y)
841 : BC_Button(x, y, mwindow->theme->presentation_data)
843 this->mwindow = mwindow;
845 set_tooltip(_("Set presentation up to current position"));
847 EditPresentation::~EditPresentation()
850 int EditPresentation::handle_event()
855 EditUndo::EditUndo(MWindow *mwindow, EditPanel *panel, int x, int y)
856 : BC_Button(x, y, mwindow->theme->get_image_set("undo"))
858 this->mwindow = mwindow;
860 set_tooltip(_("Undo ( z )"));
862 EditUndo::~EditUndo()
865 int EditUndo::keypress_event()
867 if(get_keypress() == 'z')
868 return handle_event();
871 int EditUndo::handle_event()
873 mwindow->undo_entry(panel->subwindow);
877 EditRedo::EditRedo(MWindow *mwindow, EditPanel *panel, int x, int y)
878 : BC_Button(x, y, mwindow->theme->get_image_set("redo"))
880 this->mwindow = mwindow;
882 set_tooltip(_("Redo ( shift Z )"));
884 EditRedo::~EditRedo()
887 int EditRedo::keypress_event()
889 if(get_keypress() == 'Z')
890 return handle_event();
893 int EditRedo::handle_event()
895 mwindow->redo_entry(panel->subwindow);
903 EditLabelbutton::EditLabelbutton(MWindow *mwindow, EditPanel *panel, int x, int y)
904 : BC_Button(x, y, mwindow->theme->get_image_set("labelbutton"))
906 this->mwindow = mwindow;
908 set_tooltip(_("Toggle label at current position ( l )"));
911 EditLabelbutton::~EditLabelbutton()
914 int EditLabelbutton::keypress_event()
916 if(get_keypress() == 'l')
917 return handle_event();
920 int EditLabelbutton::handle_event()
922 panel->toggle_label();
932 EditFit::EditFit(MWindow *mwindow, EditPanel *panel, int x, int y)
933 : BC_Button(x, y, mwindow->theme->get_image_set("fit"))
935 this->mwindow = mwindow;
937 set_tooltip(_("Fit selection to display ( f )"));
942 int EditFit::keypress_event()
944 if(!alt_down() && get_keypress() == 'f')
951 int EditFit::handle_event()
953 mwindow->fit_selection();
965 EditFitAutos::EditFitAutos(MWindow *mwindow, EditPanel *panel, int x, int y)
966 : BC_Button(x, y, mwindow->theme->get_image_set("fitautos"))
968 this->mwindow = mwindow;
970 set_tooltip(_("Fit all autos to display ( Alt + f )"));
972 EditFitAutos::~EditFitAutos()
975 int EditFitAutos::keypress_event()
977 if(!ctrl_down() && alt_down() && get_keypress() == 'f')
979 mwindow->fit_autos(1);
982 if(ctrl_down() && alt_down() && get_keypress() == 'f')
984 mwindow->fit_autos(0);
989 int EditFitAutos::handle_event()
991 mwindow->fit_autos(1);
1007 ArrowButton::ArrowButton(MWindow *mwindow, EditPanel *panel, int x, int y)
1010 mwindow->theme->get_image_set("arrow"),
1011 mwindow->edl->session->editing_mode == EDITING_ARROW,
1017 this->mwindow = mwindow;
1018 this->panel = panel;
1019 set_tooltip(_("Drag and drop editing mode"));
1022 int ArrowButton::handle_event()
1025 panel->ibeam->update(0);
1026 mwindow->set_editing_mode(EDITING_ARROW);
1027 // Nothing after this
1032 IBeamButton::IBeamButton(MWindow *mwindow, EditPanel *panel, int x, int y)
1035 mwindow->theme->get_image_set("ibeam"),
1036 mwindow->edl->session->editing_mode == EDITING_IBEAM,
1042 this->mwindow = mwindow;
1043 this->panel = panel;
1044 set_tooltip(_("Cut and paste editing mode"));
1047 int IBeamButton::handle_event()
1050 panel->arrow->update(0);
1051 mwindow->set_editing_mode(EDITING_IBEAM);
1052 // Nothing after this
1056 KeyFrameButton::KeyFrameButton(MWindow *mwindow, int x, int y)
1059 mwindow->theme->get_image_set("autokeyframe"),
1060 mwindow->edl->session->auto_keyframes,
1066 this->mwindow = mwindow;
1067 set_tooltip(_("Generate keyframes while tweeking"));
1070 int KeyFrameButton::handle_event()
1072 mwindow->set_auto_keyframes(get_value());