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
52 this->editing_mode = editing_mode;
53 this->use_editing_mode = use_editing_mode;
54 this->use_keyframe = use_keyframe;
55 this->use_splice = use_splice;
56 this->use_overwrite = use_overwrite;
58 this->use_extract = 0;
59 this->use_copy = use_copy;
60 this->use_paste = use_paste;
61 this->use_undo = use_undo;
62 this->mwindow = mwindow;
63 this->subwindow = subwindow;
64 this->use_fit = use_fit;
65 this->use_labels = use_labels;
66 this->use_locklabels = use_locklabels;
67 this->use_toclip = use_toclip;
68 this->use_meters = use_meters;
69 this->is_mwindow = is_mwindow;
70 this->use_cut = use_cut;
74 this->meter_panel = 0;
83 EditPanel::~EditPanel()
87 void EditPanel::set_meters(MeterPanel *meter_panel)
89 this->meter_panel = meter_panel;
93 void EditPanel::update()
95 int new_editing_mode = mwindow->edl->session->editing_mode;
96 if(arrow) arrow->update(new_editing_mode == EDITING_ARROW);
97 if(ibeam) ibeam->update(new_editing_mode == EDITING_IBEAM);
98 if(keyframe) keyframe->update(mwindow->edl->session->auto_keyframes);
99 if(locklabels) locklabels->set_value(mwindow->edl->session->labels_follow_edits);
103 void EditPanel::delete_buttons()
107 if(arrow) delete arrow;
108 if(ibeam) delete ibeam;
117 if(inpoint) delete inpoint;
118 if(outpoint) delete outpoint;
119 if(use_copy) delete copy;
120 if(use_splice) delete splice;
121 if(use_overwrite) delete overwrite;
122 if(use_lift) delete lift;
123 if(use_extract) delete extract;
125 if(copy) delete copy;
126 if(use_paste) delete paste;
147 void EditPanel::create_buttons()
155 subwindow->add_subwindow(arrow = new ArrowButton(mwindow, this, x1, y1));
156 x1 += arrow->get_w();
157 subwindow->add_subwindow(ibeam = new IBeamButton(mwindow, this, x1, y1));
158 x1 += ibeam->get_w();
159 x1 += mwindow->theme->toggle_margin;
164 subwindow->add_subwindow(keyframe = new KeyFrameButton(mwindow, x1, y1));
165 x1 += keyframe->get_w();
170 subwindow->add_subwindow(locklabels = new LockLabelsButton(mwindow,
173 x1 += locklabels->get_w();
175 if(use_keyframe || use_locklabels)
176 x1 += mwindow->theme->toggle_margin;
179 subwindow->add_subwindow(inpoint = new EditInPoint(mwindow, this, x1, y1));
180 x1 += inpoint->get_w();
181 subwindow->add_subwindow(outpoint = new EditOutPoint(mwindow, this, x1, y1));
182 x1 += outpoint->get_w();
185 subwindow->add_subwindow(splice = new EditSplice(mwindow, this, x1, y1));
186 x1 += splice->get_w();
190 subwindow->add_subwindow(overwrite = new EditOverwrite(mwindow, this, x1, y1));
191 x1 += overwrite->get_w();
195 subwindow->add_subwindow(lift = new EditLift(mwindow, this, x1, y1));
200 subwindow->add_subwindow(extract = new EditExtract(mwindow, this, x1, y1));
201 x1 += extract->get_w();
205 subwindow->add_subwindow(clip = new EditToClip(mwindow, this, x1, y1));
211 subwindow->add_subwindow(cut = new EditCut(mwindow, this, x1, y1));
216 subwindow->add_subwindow(copy = new EditCopy(mwindow, this, x1, y1));
221 subwindow->add_subwindow(paste = new EditPaste(mwindow, this, x1, y1));
222 x1 += paste->get_w();
229 printf("EditPanel::create_objects: meter_panel == 0\n");
231 subwindow->add_subwindow(meters = new MeterShow(mwindow, meter_panel, x1, y1));
232 x1 += meters->get_w();
237 subwindow->add_subwindow(labelbutton = new EditLabelbutton(mwindow,
241 x1 += labelbutton->get_w();
242 subwindow->add_subwindow(prevlabel = new EditPrevLabel(mwindow,
247 x1 += prevlabel->get_w();
248 subwindow->add_subwindow(nextlabel = new EditNextLabel(mwindow,
253 x1 += nextlabel->get_w();
258 subwindow->add_subwindow(fit = new EditFit(mwindow, this, x1, y1));
260 subwindow->add_subwindow(fit_autos = new EditFitAutos(mwindow, this, x1, y1));
261 x1 += fit_autos->get_w();
266 subwindow->add_subwindow(undo = new EditUndo(mwindow, this, x1, y1));
268 subwindow->add_subwindow(redo = new EditRedo(mwindow, this, x1, y1));
271 subwindow->add_subwindow(mangoto = new EditManualGoto(mwindow, this, x1, y1));
272 x1 += mangoto->get_w();
279 void EditPanel::toggle_label()
281 mwindow->toggle_label(is_mwindow);
284 void EditPanel::prev_label()
286 int shift_down = subwindow->shift_down();
289 mwindow->gui->unlock_window();
292 subwindow->unlock_window();
294 mwindow->gui->mbuttons->transport->handle_transport(STOP, 1, 0, 0);
297 subwindow->lock_window("EditPanel::prev_label 1");
299 mwindow->gui->lock_window("EditPanel::prev_label 2");
301 mwindow->prev_label(shift_down);
304 mwindow->gui->unlock_window();
307 void EditPanel::next_label()
309 int shift_down = subwindow->shift_down();
312 mwindow->gui->unlock_window();
315 subwindow->unlock_window();
317 mwindow->gui->mbuttons->transport->handle_transport(STOP, 1, 0, 0);
320 subwindow->lock_window("EditPanel::next_label 1");
322 mwindow->gui->lock_window("EditPanel::next_label 2");
324 mwindow->next_label(shift_down);
327 mwindow->gui->unlock_window();
333 void EditPanel::reposition_buttons(int x, int y)
341 arrow->reposition_window(x1, y1);
342 x1 += arrow->get_w();
343 ibeam->reposition_window(x1, y1);
344 x1 += ibeam->get_w();
345 x1 += mwindow->theme->toggle_margin;
350 keyframe->reposition_window(x1, y1);
351 x1 += keyframe->get_w();
356 locklabels->reposition_window(x1,y1);
357 x1 += locklabels->get_w();
360 if(use_keyframe || use_locklabels)
361 x1 += mwindow->theme->toggle_margin;
363 inpoint->reposition_window(x1, y1);
364 x1 += inpoint->get_w();
365 outpoint->reposition_window(x1, y1);
366 x1 += outpoint->get_w();
369 splice->reposition_window(x1, y1);
370 x1 += splice->get_w();
374 overwrite->reposition_window(x1, y1);
375 x1 += overwrite->get_w();
379 lift->reposition_window(x1, y1);
384 extract->reposition_window(x1, y1);
385 x1 += extract->get_w();
389 clip->reposition_window(x1, y1);
394 cut->reposition_window(x1, y1);
399 copy->reposition_window(x1, y1);
404 paste->reposition_window(x1, y1);
405 x1 += paste->get_w();
410 meters->reposition_window(x1, y1);
411 x1 += meters->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();
426 fit->reposition_window(x1, y1);
428 fit_autos->reposition_window(x1, y1);
429 x1 += fit_autos->get_w();
434 undo->reposition_window(x1, y1);
436 redo->reposition_window(x1, y1);
440 mangoto->reposition_window(x1, y1);
441 x1 += mangoto->get_w();
446 int EditPanel::create_objects()
452 int EditPanel::get_w()
458 void EditPanel::copy_selection()
463 void EditPanel::splice_selection()
467 void EditPanel::overwrite_selection()
471 void EditPanel::set_inpoint()
473 mwindow->set_inpoint(1);
476 void EditPanel::set_outpoint()
478 mwindow->set_outpoint(1);
481 void EditPanel::clear_inpoint()
483 mwindow->delete_inpoint();
486 void EditPanel::clear_outpoint()
488 mwindow->delete_outpoint();
491 void EditPanel::to_clip()
497 EditInPoint::EditInPoint(MWindow *mwindow, EditPanel *panel, int x, int y)
498 : BC_Button(x, y, mwindow->theme->get_image_set("inbutton"))
500 this->mwindow = mwindow;
502 set_tooltip(_("In point ( [ )"));
504 EditInPoint::~EditInPoint()
507 int EditInPoint::handle_event()
509 panel->set_inpoint();
512 int EditInPoint::keypress_event()
514 if(get_keypress() == '[')
516 panel->set_inpoint();
522 EditOutPoint::EditOutPoint(MWindow *mwindow, EditPanel *panel, int x, int y)
523 : BC_Button(x, y, mwindow->theme->get_image_set("outbutton"))
525 this->mwindow = mwindow;
527 set_tooltip(_("Out point ( ] )"));
529 EditOutPoint::~EditOutPoint()
532 int EditOutPoint::handle_event()
534 panel->set_outpoint();
537 int EditOutPoint::keypress_event()
539 if(get_keypress() == ']')
541 panel->set_outpoint();
548 EditNextLabel::EditNextLabel(MWindow *mwindow,
553 : BC_Button(x, y, mwindow->theme->get_image_set("nextlabel"))
555 this->mwindow = mwindow;
557 this->is_mwindow = is_mwindow;
558 set_tooltip(_("Next label ( ctrl -> )"));
560 EditNextLabel::~EditNextLabel()
563 int EditNextLabel::keypress_event()
565 if(get_keypress() == RIGHT && ctrl_down())
566 return handle_event();
569 int EditNextLabel::handle_event()
575 EditPrevLabel::EditPrevLabel(MWindow *mwindow,
580 : BC_Button(x, y, mwindow->theme->get_image_set("prevlabel"))
582 this->mwindow = mwindow;
584 this->is_mwindow = is_mwindow;
585 set_tooltip(_("Previous label ( ctrl <- )"));
587 EditPrevLabel::~EditPrevLabel()
590 int EditPrevLabel::keypress_event()
592 if(get_keypress() == LEFT && ctrl_down())
593 return handle_event();
596 int EditPrevLabel::handle_event()
602 EditLift::EditLift(MWindow *mwindow, EditPanel *panel, int x, int y)
603 : BC_Button(x, y, mwindow->theme->lift_data)
605 this->mwindow = mwindow;
607 set_tooltip(_("Lift"));
609 EditLift::~EditLift()
612 int EditLift::handle_event()
617 EditOverwrite::EditOverwrite(MWindow *mwindow, EditPanel *panel, int x, int y)
618 : BC_Button(x, y, mwindow->theme->overwrite_data)
620 this->mwindow = mwindow;
622 set_tooltip(_("Overwrite ( b )"));
624 EditOverwrite::~EditOverwrite()
627 int EditOverwrite::handle_event()
629 panel->overwrite_selection();
632 int EditOverwrite::keypress_event()
634 if(get_keypress() == 'b')
642 EditExtract::EditExtract(MWindow *mwindow, EditPanel *panel, int x, int y)
643 : BC_Button(x, y, mwindow->theme->extract_data)
645 this->mwindow = mwindow;
647 set_tooltip(_("Extract"));
649 EditExtract::~EditExtract()
652 int EditExtract::handle_event()
654 // mwindow->extract_selection();
658 EditToClip::EditToClip(MWindow *mwindow, EditPanel *panel, int x, int y)
659 : BC_Button(x, y, mwindow->theme->get_image_set("toclip"))
661 this->mwindow = mwindow;
663 set_tooltip(_("To clip ( i )"));
665 EditToClip::~EditToClip()
668 int EditToClip::handle_event()
674 int EditToClip::keypress_event()
676 if(get_keypress() == 'i')
684 EditManualGoto::EditManualGoto(MWindow *mwindow, EditPanel *panel, int x, int y)
685 : BC_Button(x, y, mwindow->theme->get_image_set("goto"))
687 this->mwindow = mwindow;
689 mangoto = new ManualGoto(mwindow, panel->subwindow);
690 set_tooltip(_("Manual goto ( g )"));
692 EditManualGoto::~EditManualGoto()
696 int EditManualGoto::handle_event()
698 mangoto->open_window();
702 int EditManualGoto::keypress_event()
704 if(get_keypress() == 'g')
713 EditSplice::EditSplice(MWindow *mwindow, EditPanel *panel, int x, int y)
714 : BC_Button(x, y, mwindow->theme->splice_data)
716 this->mwindow = mwindow;
718 set_tooltip(_("Splice ( v )"));
720 EditSplice::~EditSplice()
723 int EditSplice::handle_event()
725 panel->splice_selection();
728 int EditSplice::keypress_event()
730 if(get_keypress() == 'v')
738 EditCut::EditCut(MWindow *mwindow, EditPanel *panel, int x, int y)
739 : BC_Button(x, y, mwindow->theme->get_image_set("cut"))
741 this->mwindow = mwindow;
743 set_tooltip(_("Cut ( x )"));
748 int EditCut::keypress_event()
750 if(get_keypress() == 'x')
751 return handle_event();
755 int EditCut::handle_event()
757 if(!panel->is_mwindow) mwindow->gui->lock_window("EditCut::handle_event");
759 if(!panel->is_mwindow) mwindow->gui->unlock_window();
763 EditCopy::EditCopy(MWindow *mwindow, EditPanel *panel, int x, int y)
764 : BC_Button(x, y, mwindow->theme->get_image_set("copy"))
766 this->mwindow = mwindow;
768 set_tooltip(_("Copy ( c )"));
770 EditCopy::~EditCopy()
774 int EditCopy::keypress_event()
776 if(get_keypress() == 'c')
777 return handle_event();
780 int EditCopy::handle_event()
782 panel->copy_selection();
786 EditAppend::EditAppend(MWindow *mwindow, EditPanel *panel, int x, int y)
787 : BC_Button(x, y, mwindow->theme->append_data)
789 this->mwindow = mwindow;
791 set_tooltip(_("Append to end of track"));
793 EditAppend::~EditAppend()
798 int EditAppend::handle_event()
804 EditInsert::EditInsert(MWindow *mwindow, EditPanel *panel, int x, int y)
805 : BC_Button(x, y, mwindow->theme->insert_data)
807 this->mwindow = mwindow;
809 set_tooltip(_("Insert before beginning of track"));
811 EditInsert::~EditInsert()
816 int EditInsert::handle_event()
823 EditPaste::EditPaste(MWindow *mwindow, EditPanel *panel, int x, int y)
824 : BC_Button(x, y, mwindow->theme->get_image_set("paste"))
826 this->mwindow = mwindow;
828 set_tooltip(_("Paste ( v )"));
830 EditPaste::~EditPaste()
834 int EditPaste::keypress_event()
836 if(get_keypress() == 'v')
837 return handle_event();
840 int EditPaste::handle_event()
842 if(!panel->is_mwindow) mwindow->gui->lock_window("EditPaste::handle_event");
844 if(!panel->is_mwindow) mwindow->gui->unlock_window();
850 EditTransition::EditTransition(MWindow *mwindow, EditPanel *panel, int x, int y)
851 : BC_Button(x, y, mwindow->theme->transition_data)
853 this->mwindow = mwindow;
855 set_tooltip(_("Set transition"));
857 EditTransition::~EditTransition()
860 int EditTransition::handle_event()
865 EditPresentation::EditPresentation(MWindow *mwindow, EditPanel *panel, int x, int y)
866 : BC_Button(x, y, mwindow->theme->presentation_data)
868 this->mwindow = mwindow;
870 set_tooltip(_("Set presentation up to current position"));
872 EditPresentation::~EditPresentation()
875 int EditPresentation::handle_event()
880 EditUndo::EditUndo(MWindow *mwindow, EditPanel *panel, int x, int y)
881 : BC_Button(x, y, mwindow->theme->get_image_set("undo"))
883 this->mwindow = mwindow;
885 set_tooltip(_("Undo ( z )"));
887 EditUndo::~EditUndo()
890 int EditUndo::keypress_event()
892 if(get_keypress() == 'z')
893 return handle_event();
896 int EditUndo::handle_event()
898 mwindow->undo_entry(panel->subwindow);
902 EditRedo::EditRedo(MWindow *mwindow, EditPanel *panel, int x, int y)
903 : BC_Button(x, y, mwindow->theme->get_image_set("redo"))
905 this->mwindow = mwindow;
907 set_tooltip(_("Redo ( shift Z )"));
909 EditRedo::~EditRedo()
912 int EditRedo::keypress_event()
914 if(get_keypress() == 'Z')
915 return handle_event();
918 int EditRedo::handle_event()
920 mwindow->redo_entry(panel->subwindow);
928 EditLabelbutton::EditLabelbutton(MWindow *mwindow, EditPanel *panel, int x, int y)
929 : BC_Button(x, y, mwindow->theme->get_image_set("labelbutton"))
931 this->mwindow = mwindow;
933 set_tooltip(_("Toggle label at current position ( l )"));
936 EditLabelbutton::~EditLabelbutton()
939 int EditLabelbutton::keypress_event()
941 if(get_keypress() == 'l')
942 return handle_event();
945 int EditLabelbutton::handle_event()
947 panel->toggle_label();
957 EditFit::EditFit(MWindow *mwindow, EditPanel *panel, int x, int y)
958 : BC_Button(x, y, mwindow->theme->get_image_set("fit"))
960 this->mwindow = mwindow;
962 set_tooltip(_("Fit selection to display ( f )"));
967 int EditFit::keypress_event()
969 if(!alt_down() && get_keypress() == 'f')
976 int EditFit::handle_event()
978 mwindow->fit_selection();
990 EditFitAutos::EditFitAutos(MWindow *mwindow, EditPanel *panel, int x, int y)
991 : BC_Button(x, y, mwindow->theme->get_image_set("fitautos"))
993 this->mwindow = mwindow;
995 set_tooltip(_("Fit all autos to display ( Alt + f )"));
997 EditFitAutos::~EditFitAutos()
1000 int EditFitAutos::keypress_event()
1002 if(!ctrl_down() && alt_down() && get_keypress() == 'f')
1004 mwindow->fit_autos(1);
1007 if(ctrl_down() && alt_down() && get_keypress() == 'f')
1009 mwindow->fit_autos(0);
1014 int EditFitAutos::handle_event()
1016 mwindow->fit_autos(1);
1032 ArrowButton::ArrowButton(MWindow *mwindow, EditPanel *panel, int x, int y)
1035 mwindow->theme->get_image_set("arrow"),
1036 mwindow->edl->session->editing_mode == EDITING_ARROW,
1042 this->mwindow = mwindow;
1043 this->panel = panel;
1044 set_tooltip(_("Drag and drop editing mode"));
1047 int ArrowButton::handle_event()
1050 panel->ibeam->update(0);
1051 mwindow->set_editing_mode(EDITING_ARROW);
1052 // Nothing after this
1057 IBeamButton::IBeamButton(MWindow *mwindow, EditPanel *panel, int x, int y)
1060 mwindow->theme->get_image_set("ibeam"),
1061 mwindow->edl->session->editing_mode == EDITING_IBEAM,
1067 this->mwindow = mwindow;
1068 this->panel = panel;
1069 set_tooltip(_("Cut and paste editing mode"));
1072 int IBeamButton::handle_event()
1075 panel->arrow->update(0);
1076 mwindow->set_editing_mode(EDITING_IBEAM);
1077 // Nothing after this
1081 KeyFrameButton::KeyFrameButton(MWindow *mwindow, int x, int y)
1084 mwindow->theme->get_image_set("autokeyframe"),
1085 mwindow->edl->session->auto_keyframes,
1091 this->mwindow = mwindow;
1092 set_tooltip(_("Generate keyframes while tweeking"));
1095 int KeyFrameButton::handle_event()
1097 mwindow->set_auto_keyframes(get_value());
1102 LockLabelsButton::LockLabelsButton(MWindow *mwindow, int x, int y)
1105 mwindow->theme->get_image_set("locklabels"),
1106 mwindow->edl->session->labels_follow_edits,
1112 this->mwindow = mwindow;
1113 set_tooltip(_("Lock labels from moving"));
1116 int LockLabelsButton::handle_event()
1118 mwindow->set_labels_follow_edits(get_value());
1125 // c-file-style: "linux"