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()
272 mwindow->gui->unlock_window();
275 subwindow->unlock_window();
277 mwindow->gui->mbuttons->transport->handle_transport(STOP, 1);
280 subwindow->lock_window("EditPanel::prev_label 1");
282 mwindow->gui->lock_window("EditPanel::prev_label 2");
284 mwindow->prev_label();
287 mwindow->gui->unlock_window();
290 void EditPanel::next_label()
294 mwindow->gui->unlock_window();
297 subwindow->unlock_window();
299 mwindow->gui->mbuttons->transport->handle_transport(STOP, 1);
302 subwindow->lock_window("EditPanel::next_label 1");
304 mwindow->gui->lock_window("EditPanel::next_label 2");
306 mwindow->next_label();
309 mwindow->gui->unlock_window();
315 void EditPanel::reposition_buttons(int x, int y)
323 arrow->reposition_window(x1, y1);
324 x1 += arrow->get_w();
325 ibeam->reposition_window(x1, y1);
326 x1 += ibeam->get_w();
331 keyframe->reposition_window(x1, y1);
332 x1 += keyframe->get_w();
333 x1 += mwindow->theme->toggle_margin;
336 inpoint->reposition_window(x1, y1);
337 x1 += inpoint->get_w();
338 outpoint->reposition_window(x1, y1);
339 x1 += outpoint->get_w();
342 splice->reposition_window(x1, y1);
343 x1 += splice->get_w();
347 overwrite->reposition_window(x1, y1);
348 x1 += overwrite->get_w();
352 lift->reposition_window(x1, y1);
357 extract->reposition_window(x1, y1);
358 x1 += extract->get_w();
362 clip->reposition_window(x1, y1);
367 cut->reposition_window(x1, y1);
372 copy->reposition_window(x1, y1);
377 paste->reposition_window(x1, y1);
378 x1 += paste->get_w();
383 meters->reposition_window(x1, y1);
384 x1 += meters->get_w();
389 labelbutton->reposition_window(x1, y1);
390 x1 += labelbutton->get_w();
391 prevlabel->reposition_window(x1, y1);
392 x1 += prevlabel->get_w();
393 nextlabel->reposition_window(x1, y1);
394 x1 += nextlabel->get_w();
399 fit->reposition_window(x1, y1);
401 fit_autos->reposition_window(x1, y1);
402 x1 += fit_autos->get_w();
407 undo->reposition_window(x1, y1);
409 redo->reposition_window(x1, y1);
413 mangoto->reposition_window(x1, y1);
414 x1 += mangoto->get_w();
419 int EditPanel::create_objects()
425 int EditPanel::get_w()
431 void EditPanel::copy_selection()
436 void EditPanel::splice_selection()
440 void EditPanel::overwrite_selection()
444 void EditPanel::set_inpoint()
446 mwindow->set_inpoint(1);
449 void EditPanel::set_outpoint()
451 mwindow->set_outpoint(1);
454 void EditPanel::clear_inpoint()
456 mwindow->delete_inpoint();
459 void EditPanel::clear_outpoint()
461 mwindow->delete_outpoint();
464 void EditPanel::to_clip()
470 EditInPoint::EditInPoint(MWindow *mwindow, EditPanel *panel, int x, int y)
471 : BC_Button(x, y, mwindow->theme->get_image_set("inbutton"))
473 this->mwindow = mwindow;
475 set_tooltip(_("In point ( [ )"));
477 EditInPoint::~EditInPoint()
480 int EditInPoint::handle_event()
482 panel->set_inpoint();
485 int EditInPoint::keypress_event()
487 if(get_keypress() == '[')
489 panel->set_inpoint();
495 EditOutPoint::EditOutPoint(MWindow *mwindow, EditPanel *panel, int x, int y)
496 : BC_Button(x, y, mwindow->theme->get_image_set("outbutton"))
498 this->mwindow = mwindow;
500 set_tooltip(_("Out point ( ] )"));
502 EditOutPoint::~EditOutPoint()
505 int EditOutPoint::handle_event()
507 panel->set_outpoint();
510 int EditOutPoint::keypress_event()
512 if(get_keypress() == ']')
514 panel->set_outpoint();
521 EditNextLabel::EditNextLabel(MWindow *mwindow,
526 : BC_Button(x, y, mwindow->theme->get_image_set("nextlabel"))
528 this->mwindow = mwindow;
530 this->is_mwindow = is_mwindow;
531 set_tooltip(_("Next label ( ctrl -> )"));
533 EditNextLabel::~EditNextLabel()
536 int EditNextLabel::keypress_event()
538 if(get_keypress() == RIGHT && ctrl_down())
539 return handle_event();
542 int EditNextLabel::handle_event()
548 EditPrevLabel::EditPrevLabel(MWindow *mwindow,
553 : BC_Button(x, y, mwindow->theme->get_image_set("prevlabel"))
555 this->mwindow = mwindow;
557 this->is_mwindow = is_mwindow;
558 set_tooltip(_("Previous label ( ctrl <- )"));
560 EditPrevLabel::~EditPrevLabel()
563 int EditPrevLabel::keypress_event()
565 if(get_keypress() == LEFT && ctrl_down())
566 return handle_event();
569 int EditPrevLabel::handle_event()
575 EditLift::EditLift(MWindow *mwindow, EditPanel *panel, int x, int y)
576 : BC_Button(x, y, mwindow->theme->lift_data)
578 this->mwindow = mwindow;
580 set_tooltip(_("Lift"));
582 EditLift::~EditLift()
585 int EditLift::handle_event()
590 EditOverwrite::EditOverwrite(MWindow *mwindow, EditPanel *panel, int x, int y)
591 : BC_Button(x, y, mwindow->theme->overwrite_data)
593 this->mwindow = mwindow;
595 set_tooltip(_("Overwrite ( b )"));
597 EditOverwrite::~EditOverwrite()
600 int EditOverwrite::handle_event()
602 panel->overwrite_selection();
605 int EditOverwrite::keypress_event()
607 if(get_keypress() == 'b')
615 EditExtract::EditExtract(MWindow *mwindow, EditPanel *panel, int x, int y)
616 : BC_Button(x, y, mwindow->theme->extract_data)
618 this->mwindow = mwindow;
620 set_tooltip(_("Extract"));
622 EditExtract::~EditExtract()
625 int EditExtract::handle_event()
627 // mwindow->extract_selection();
631 EditToClip::EditToClip(MWindow *mwindow, EditPanel *panel, int x, int y)
632 : BC_Button(x, y, mwindow->theme->get_image_set("toclip"))
634 this->mwindow = mwindow;
636 set_tooltip(_("To clip ( i )"));
638 EditToClip::~EditToClip()
641 int EditToClip::handle_event()
647 int EditToClip::keypress_event()
649 if(get_keypress() == 'i')
657 EditManualGoto::EditManualGoto(MWindow *mwindow, EditPanel *panel, int x, int y)
658 : BC_Button(x, y, mwindow->theme->get_image_set("toclip"))
660 this->mwindow = mwindow;
662 mangoto = new ManualGoto(mwindow, panel->subwindow);
663 set_tooltip(_("Manual goto ( g )"));
665 EditManualGoto::~EditManualGoto()
669 int EditManualGoto::handle_event()
671 mangoto->open_window();
675 int EditManualGoto::keypress_event()
677 if(get_keypress() == 'g')
686 EditSplice::EditSplice(MWindow *mwindow, EditPanel *panel, int x, int y)
687 : BC_Button(x, y, mwindow->theme->splice_data)
689 this->mwindow = mwindow;
691 set_tooltip(_("Splice ( v )"));
693 EditSplice::~EditSplice()
696 int EditSplice::handle_event()
698 panel->splice_selection();
701 int EditSplice::keypress_event()
703 if(get_keypress() == 'v')
711 EditCut::EditCut(MWindow *mwindow, EditPanel *panel, int x, int y)
712 : BC_Button(x, y, mwindow->theme->get_image_set("cut"))
714 this->mwindow = mwindow;
716 set_tooltip(_("Cut ( x )"));
721 int EditCut::keypress_event()
723 if(get_keypress() == 'x')
724 return handle_event();
728 int EditCut::handle_event()
730 if(!panel->is_mwindow) mwindow->gui->lock_window("EditCut::handle_event");
732 if(!panel->is_mwindow) mwindow->gui->unlock_window();
736 EditCopy::EditCopy(MWindow *mwindow, EditPanel *panel, int x, int y)
737 : BC_Button(x, y, mwindow->theme->get_image_set("copy"))
739 this->mwindow = mwindow;
741 set_tooltip(_("Copy ( c )"));
743 EditCopy::~EditCopy()
747 int EditCopy::keypress_event()
749 if(get_keypress() == 'c')
750 return handle_event();
753 int EditCopy::handle_event()
755 panel->copy_selection();
759 EditAppend::EditAppend(MWindow *mwindow, EditPanel *panel, int x, int y)
760 : BC_Button(x, y, mwindow->theme->append_data)
762 this->mwindow = mwindow;
764 set_tooltip(_("Append to end of track"));
766 EditAppend::~EditAppend()
771 int EditAppend::handle_event()
777 EditInsert::EditInsert(MWindow *mwindow, EditPanel *panel, int x, int y)
778 : BC_Button(x, y, mwindow->theme->insert_data)
780 this->mwindow = mwindow;
782 set_tooltip(_("Insert before beginning of track"));
784 EditInsert::~EditInsert()
789 int EditInsert::handle_event()
796 EditPaste::EditPaste(MWindow *mwindow, EditPanel *panel, int x, int y)
797 : BC_Button(x, y, mwindow->theme->get_image_set("paste"))
799 this->mwindow = mwindow;
801 set_tooltip(_("Paste ( v )"));
803 EditPaste::~EditPaste()
807 int EditPaste::keypress_event()
809 if(get_keypress() == 'v')
810 return handle_event();
813 int EditPaste::handle_event()
815 if(!panel->is_mwindow) mwindow->gui->lock_window("EditPaste::handle_event");
817 if(!panel->is_mwindow) mwindow->gui->unlock_window();
823 EditTransition::EditTransition(MWindow *mwindow, EditPanel *panel, int x, int y)
824 : BC_Button(x, y, mwindow->theme->transition_data)
826 this->mwindow = mwindow;
828 set_tooltip(_("Set transition"));
830 EditTransition::~EditTransition()
833 int EditTransition::handle_event()
838 EditPresentation::EditPresentation(MWindow *mwindow, EditPanel *panel, int x, int y)
839 : BC_Button(x, y, mwindow->theme->presentation_data)
841 this->mwindow = mwindow;
843 set_tooltip(_("Set presentation up to current position"));
845 EditPresentation::~EditPresentation()
848 int EditPresentation::handle_event()
853 EditUndo::EditUndo(MWindow *mwindow, EditPanel *panel, int x, int y)
854 : BC_Button(x, y, mwindow->theme->get_image_set("undo"))
856 this->mwindow = mwindow;
858 set_tooltip(_("Undo ( z )"));
860 EditUndo::~EditUndo()
863 int EditUndo::keypress_event()
865 if(get_keypress() == 'z')
866 return handle_event();
869 int EditUndo::handle_event()
871 mwindow->undo_entry(panel->subwindow);
875 EditRedo::EditRedo(MWindow *mwindow, EditPanel *panel, int x, int y)
876 : BC_Button(x, y, mwindow->theme->get_image_set("redo"))
878 this->mwindow = mwindow;
880 set_tooltip(_("Redo ( shift Z )"));
882 EditRedo::~EditRedo()
885 int EditRedo::keypress_event()
887 if(get_keypress() == 'Z')
888 return handle_event();
891 int EditRedo::handle_event()
893 mwindow->redo_entry(panel->subwindow);
901 EditLabelbutton::EditLabelbutton(MWindow *mwindow, EditPanel *panel, int x, int y)
902 : BC_Button(x, y, mwindow->theme->get_image_set("labelbutton"))
904 this->mwindow = mwindow;
906 set_tooltip(_("Toggle label at current position ( l )"));
909 EditLabelbutton::~EditLabelbutton()
912 int EditLabelbutton::keypress_event()
914 if(get_keypress() == 'l')
915 return handle_event();
918 int EditLabelbutton::handle_event()
920 panel->toggle_label();
930 EditFit::EditFit(MWindow *mwindow, EditPanel *panel, int x, int y)
931 : BC_Button(x, y, mwindow->theme->get_image_set("fit"))
933 this->mwindow = mwindow;
935 set_tooltip(_("Fit selection to display ( f )"));
940 int EditFit::keypress_event()
942 if(!alt_down() && get_keypress() == 'f')
949 int EditFit::handle_event()
951 mwindow->fit_selection();
963 EditFitAutos::EditFitAutos(MWindow *mwindow, EditPanel *panel, int x, int y)
964 : BC_Button(x, y, mwindow->theme->get_image_set("fitautos"))
966 this->mwindow = mwindow;
968 set_tooltip(_("Fit autos to display ( Alt + f )"));
970 EditFitAutos::~EditFitAutos()
973 int EditFitAutos::keypress_event()
975 if(alt_down() && get_keypress() == 'f')
982 int EditFitAutos::handle_event()
984 mwindow->fit_autos();
1000 ArrowButton::ArrowButton(MWindow *mwindow, EditPanel *panel, int x, int y)
1003 mwindow->theme->get_image_set("arrow"),
1004 mwindow->edl->session->editing_mode == EDITING_ARROW,
1010 this->mwindow = mwindow;
1011 this->panel = panel;
1012 set_tooltip(_("Drag and drop editing mode"));
1015 int ArrowButton::handle_event()
1018 panel->ibeam->update(0);
1019 mwindow->set_editing_mode(EDITING_ARROW);
1020 // Nothing after this
1025 IBeamButton::IBeamButton(MWindow *mwindow, EditPanel *panel, int x, int y)
1028 mwindow->theme->get_image_set("ibeam"),
1029 mwindow->edl->session->editing_mode == EDITING_IBEAM,
1035 this->mwindow = mwindow;
1036 this->panel = panel;
1037 set_tooltip(_("Cut and paste editing mode"));
1040 int IBeamButton::handle_event()
1043 panel->arrow->update(0);
1044 mwindow->set_editing_mode(EDITING_IBEAM);
1045 // Nothing after this
1049 KeyFrameButton::KeyFrameButton(MWindow *mwindow, int x, int y)
1052 mwindow->theme->get_image_set("autokeyframe"),
1053 mwindow->edl->session->auto_keyframes,
1059 this->mwindow = mwindow;
1060 set_tooltip(_("Generate keyframes while tweeking"));
1063 int KeyFrameButton::handle_event()
1065 mwindow->set_auto_keyframes(get_value());