1 #include "automation.h"
2 #include "bezierauto.h"
3 #include "bezierautos.h"
8 #include "cwindowgui.h"
9 #include "cwindowtool.h"
11 #include "edlsession.h"
12 #include "floatauto.h"
13 #include "floatautos.h"
16 #include "localsession.h"
17 #include "mainsession.h"
19 #include "maskautos.h"
21 #include "mwindowgui.h"
24 #include "trackcanvas.h"
25 #include "transportque.h"
28 CWindowTool::CWindowTool(MWindow *mwindow, CWindowGUI *gui)
31 this->mwindow = mwindow;
35 current_tool = CWINDOW_NONE;
37 input_lock = new Condition(0, "CWindowTool::input_lock");
38 output_lock = new Condition(1, "CWindowTool::output_lock");
39 tool_gui_lock = new Mutex("CWindowTool::tool_gui_lock");
42 CWindowTool::~CWindowTool()
53 void CWindowTool::start_tool(int operation)
55 CWindowToolGUI *new_gui = 0;
58 //printf("CWindowTool::start_tool 1\n");
59 if(current_tool != operation)
61 current_tool = operation;
65 new_gui = new CWindowCropGUI(mwindow, this);
68 new_gui = new CWindowCameraGUI(mwindow, this);
70 case CWINDOW_PROJECTOR:
71 new_gui = new CWindowProjectorGUI(mwindow, this);
74 new_gui = new CWindowMaskGUI(mwindow, this);
82 //printf("CWindowTool::start_tool 1\n");
88 // Wait for previous tool GUI to finish
89 output_lock->lock("CWindowTool::start_tool");
90 this->tool_gui = new_gui;
91 tool_gui->create_objects();
92 // Signal thread to run next tool GUI
95 //printf("CWindowTool::start_tool 1\n");
100 tool_gui->lock_window("CWindowTool::start_tool");
102 tool_gui->unlock_window();
105 //printf("CWindowTool::start_tool 2\n");
110 void CWindowTool::stop_tool()
114 tool_gui->lock_window("CWindowTool::stop_tool");
115 tool_gui->set_done(0);
116 tool_gui->unlock_window();
120 void CWindowTool::run()
124 input_lock->lock("CWindowTool::run");
127 tool_gui->run_window();
128 tool_gui_lock->lock("CWindowTool::run");
131 tool_gui_lock->unlock();
133 output_lock->unlock();
137 void CWindowTool::update_show_window()
141 tool_gui->lock_window("CWindowTool::update_show_window");
143 if(mwindow->edl->session->tool_window)
146 tool_gui->show_window();
149 tool_gui->hide_window();
152 tool_gui->unlock_window();
156 void CWindowTool::update_values()
158 tool_gui_lock->lock("CWindowTool::update_values");
161 tool_gui->lock_window("CWindowTool::update_values");
164 tool_gui->unlock_window();
166 tool_gui_lock->unlock();
175 CWindowToolGUI::CWindowToolGUI(MWindow *mwindow,
181 mwindow->session->ctool_x,
182 mwindow->session->ctool_y,
191 this->mwindow = mwindow;
192 this->thread = thread;
193 current_operation = 0;
196 CWindowToolGUI::~CWindowToolGUI()
200 int CWindowToolGUI::close_event()
204 mwindow->edl->session->tool_window = 0;
205 thread->gui->lock_window("CWindowToolGUI::close_event");
206 thread->gui->composite_panel->set_operation(mwindow->edl->session->cwindow_operation);
207 thread->gui->flush();
208 thread->gui->unlock_window();
212 int CWindowToolGUI::keypress_event()
214 if(get_keypress() == 'w' || get_keypress() == 'W')
215 return close_event();
219 int CWindowToolGUI::translation_event()
221 mwindow->session->ctool_x = get_x();
222 mwindow->session->ctool_y = get_y();
231 CWindowCoord::CWindowCoord(CWindowToolGUI *gui, int x, int y, float value)
232 : BC_TumbleTextBox(gui,
243 CWindowCoord::CWindowCoord(CWindowToolGUI *gui, int x, int y, int value)
244 : BC_TumbleTextBox(gui,
254 int CWindowCoord::handle_event()
256 gui->event_caller = this;
262 CWindowCropOK::CWindowCropOK(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
263 : BC_GenericButton(x, y, _("Do it"))
265 this->mwindow = mwindow;
268 int CWindowCropOK::handle_event()
270 mwindow->crop_video();
275 int CWindowCropOK::keypress_event()
277 if(get_keypress() == 0xd)
291 CWindowCropGUI::CWindowCropGUI(MWindow *mwindow, CWindowTool *thread)
292 : CWindowToolGUI(mwindow,
294 PROGRAM_NAME ": Crop",
301 CWindowCropGUI::~CWindowCropGUI()
305 void CWindowCropGUI::create_objects()
308 BC_TumbleTextBox *textbox;
311 add_subwindow(title = new BC_Title(x, y, _("X1:")));
313 x1 = new CWindowCoord(thread->tool_gui, x, y, mwindow->edl->session->crop_x1);
314 x1->create_objects();
315 x += x1->get_w() + 10;
317 add_subwindow(title = new BC_Title(x, y, _("Y1:")));
319 y1 = new CWindowCoord(thread->tool_gui, x, y, mwindow->edl->session->crop_y1);
320 y1->create_objects();
321 y += y1->get_h() + 5;
324 add_subwindow(title = new BC_Title(x, y, _("X2:")));
326 x2 = new CWindowCoord(thread->tool_gui, x, y, mwindow->edl->session->crop_x2);
327 x2->create_objects();
328 x += x2->get_w() + 10;
330 add_subwindow(title = new BC_Title(x, y, _("Y2:")));
332 y2 = new CWindowCoord(thread->tool_gui, x, y, mwindow->edl->session->crop_y2);
333 y2->create_objects();
334 y += y2->get_h() + 5;
336 add_subwindow(new CWindowCropOK(mwindow, thread->tool_gui, x, y));
338 if(mwindow->edl->session->tool_window) show_window();
342 void CWindowCropGUI::handle_event()
344 mwindow->edl->session->crop_x1 = atol(x1->get_text());
345 mwindow->edl->session->crop_y1 = atol(y1->get_text());
346 mwindow->edl->session->crop_x2 = atol(x2->get_text());
347 mwindow->edl->session->crop_y2 = atol(y2->get_text());
348 mwindow->cwindow->gui->lock_window("CWindowCropGUI::handle_event");
349 mwindow->cwindow->gui->canvas->draw_refresh();
350 mwindow->cwindow->gui->unlock_window();
353 void CWindowCropGUI::update()
355 x1->update((int64_t)mwindow->edl->session->crop_x1);
356 y1->update((int64_t)mwindow->edl->session->crop_y1);
357 x2->update((int64_t)mwindow->edl->session->crop_x2);
358 y2->update((int64_t)mwindow->edl->session->crop_y2);
372 CWindowCameraGUI::CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread)
373 : CWindowToolGUI(mwindow,
375 PROGRAM_NAME ": Camera",
380 CWindowCameraGUI::~CWindowCameraGUI()
384 void CWindowCameraGUI::create_objects()
386 int x = 10, y = 10, x1;
387 Track *track = mwindow->cwindow->calculate_affected_track();
388 BezierAuto *keyframe = 0;
389 FloatAuto *zoom_keyframe = 0;
395 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(
396 track->automation->camera_autos,
398 zoom_keyframe = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
399 track->automation->czoom_autos,
403 add_subwindow(title = new BC_Title(x, y, _("X:")));
405 this->x = new CWindowCoord(this,
408 keyframe ? keyframe->center_x : (float)0);
409 this->x->create_objects();
412 add_subwindow(title = new BC_Title(x, y, _("Y:")));
414 this->y = new CWindowCoord(this,
417 keyframe ? keyframe->center_y : (float)0);
418 this->y->create_objects();
421 add_subwindow(title = new BC_Title(x, y, _("Z:")));
423 this->z = new CWindowCoord(this,
426 zoom_keyframe ? zoom_keyframe->value : (float)1);
427 this->z->create_objects();
431 add_subwindow(button = new CWindowCameraLeft(mwindow, this, x1, y));
432 x1 += button->get_w();
433 add_subwindow(button = new CWindowCameraCenter(mwindow, this, x1, y));
434 x1 += button->get_w();
435 add_subwindow(button = new CWindowCameraRight(mwindow, this, x1, y));
437 y += button->get_h();
439 add_subwindow(button = new CWindowCameraTop(mwindow, this, x1, y));
440 x1 += button->get_w();
441 add_subwindow(button = new CWindowCameraMiddle(mwindow, this, x1, y));
442 x1 += button->get_w();
443 add_subwindow(button = new CWindowCameraBottom(mwindow, this, x1, y));
447 if(mwindow->edl->session->tool_window) show_window();
451 void CWindowCameraGUI::update_preview()
453 mwindow->restart_brender();
454 mwindow->sync_parameters(CHANGE_PARAMS);
456 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
460 mwindow->cwindow->gui->lock_window("CWindowCameraGUI::update_preview");
461 mwindow->cwindow->gui->canvas->draw_refresh();
462 mwindow->cwindow->gui->unlock_window();
466 void CWindowCameraGUI::handle_event()
468 BezierAuto *keyframe = 0;
469 FloatAuto *zoom_keyframe = 0;
470 Track *track = mwindow->cwindow->calculate_affected_track();
473 if(event_caller == z)
474 zoom_keyframe = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
475 track->automation->czoom_autos,
478 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(
479 track->automation->camera_autos,
485 keyframe->center_x = atof(x->get_text());
486 keyframe->center_y = atof(y->get_text());
492 float zoom = atof(z->get_text());
493 if(zoom > 10) zoom = 10;
495 if(zoom < 0) zoom = 0;
496 // Doesn't allow user to enter from scratch
497 // if(zoom != atof(z->get_text()))
500 zoom_keyframe->value = zoom;
501 mwindow->gui->lock_window("CWindowCameraGUI::handle_event");
502 mwindow->gui->canvas->draw_overlays();
503 mwindow->gui->canvas->flash();
504 mwindow->gui->unlock_window();
509 void CWindowCameraGUI::update()
511 BezierAuto *keyframe = 0;
512 FloatAuto *zoom_keyframe = 0;
513 Track *track = mwindow->cwindow->calculate_affected_track();
517 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(
518 track->automation->camera_autos,
520 zoom_keyframe = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
521 track->automation->czoom_autos,
527 x->update(keyframe->center_x);
528 y->update(keyframe->center_y);
533 z->update(zoom_keyframe->value);
537 BezierAuto* CWindowCameraGUI::get_keyframe()
539 BezierAuto *keyframe = 0;
540 Track *track = mwindow->cwindow->calculate_affected_track();
542 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->camera_autos);
548 CWindowCameraLeft::CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
549 : BC_Button(x, y, mwindow->theme->left_justify)
552 this->mwindow = mwindow;
553 set_tooltip(_("Left justify"));
555 int CWindowCameraLeft::handle_event()
557 BezierAuto *keyframe = 0;
558 FloatAuto *zoom_keyframe = 0;
559 Track *track = mwindow->cwindow->calculate_affected_track();
562 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->camera_autos, 1);
563 zoom_keyframe = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->czoom_autos, 0);
569 track->get_source_dimensions(mwindow->edl->local_session->selectionstart,
576 (double)track->track_w / zoom_keyframe->value / 2 -
579 gui->update_preview();
587 CWindowCameraCenter::CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
588 : BC_Button(x, y, mwindow->theme->center_justify)
591 this->mwindow = mwindow;
592 set_tooltip(_("Center horizontal"));
594 int CWindowCameraCenter::handle_event()
596 BezierAuto *keyframe = 0;
597 Track *track = mwindow->cwindow->calculate_affected_track();
599 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->camera_autos);
603 keyframe->center_x = 0;
605 gui->update_preview();
612 CWindowCameraRight::CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
613 : BC_Button(x, y, mwindow->theme->right_justify)
616 this->mwindow = mwindow;
617 set_tooltip(_("Right justify"));
619 int CWindowCameraRight::handle_event()
621 BezierAuto *keyframe = 0;
622 FloatAuto *zoom_keyframe = 0;
623 Track *track = mwindow->cwindow->calculate_affected_track();
626 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->camera_autos, 1);
627 zoom_keyframe = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->czoom_autos, 0);
633 track->get_source_dimensions(mwindow->edl->local_session->selectionstart,
639 keyframe->center_x = -((double)track->track_w / zoom_keyframe->value / 2 -
642 gui->update_preview();
650 CWindowCameraTop::CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
651 : BC_Button(x, y, mwindow->theme->top_justify)
654 this->mwindow = mwindow;
655 set_tooltip(_("Top justify"));
657 int CWindowCameraTop::handle_event()
659 BezierAuto *keyframe = 0;
660 FloatAuto *zoom_keyframe = 0;
661 Track *track = mwindow->cwindow->calculate_affected_track();
664 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->camera_autos, 1);
665 zoom_keyframe = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->czoom_autos, 0);
671 track->get_source_dimensions(mwindow->edl->local_session->selectionstart,
677 keyframe->center_y = (double)track->track_h / zoom_keyframe->value / 2 -
680 gui->update_preview();
688 CWindowCameraMiddle::CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
689 : BC_Button(x, y, mwindow->theme->middle_justify)
692 this->mwindow = mwindow;
693 set_tooltip(_("Center vertical"));
695 int CWindowCameraMiddle::handle_event()
697 BezierAuto *keyframe = 0;
698 Track *track = mwindow->cwindow->calculate_affected_track();
700 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->camera_autos);
704 keyframe->center_y = 0;
706 gui->update_preview();
713 CWindowCameraBottom::CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
714 : BC_Button(x, y, mwindow->theme->bottom_justify)
717 this->mwindow = mwindow;
718 set_tooltip(_("Bottom justify"));
720 int CWindowCameraBottom::handle_event()
722 BezierAuto *keyframe = 0;
723 FloatAuto *zoom_keyframe = 0;
724 Track *track = mwindow->cwindow->calculate_affected_track();
727 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->camera_autos, 1);
728 zoom_keyframe = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->czoom_autos, 0);
734 track->get_source_dimensions(mwindow->edl->local_session->selectionstart,
740 keyframe->center_y = -((double)track->track_h / zoom_keyframe->value / 2 -
743 gui->update_preview();
766 CWindowProjectorGUI::CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread)
767 : CWindowToolGUI(mwindow,
769 PROGRAM_NAME ": Projector",
774 CWindowProjectorGUI::~CWindowProjectorGUI()
777 void CWindowProjectorGUI::create_objects()
779 int x = 10, y = 10, x1;
780 Track *track = mwindow->cwindow->calculate_affected_track();
781 BezierAuto *keyframe = 0;
782 FloatAuto *zoom_keyframe = 0;
788 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(
789 track->automation->projector_autos,
791 zoom_keyframe = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
792 track->automation->pzoom_autos,
796 add_subwindow(title = new BC_Title(x, y, _("X:")));
798 this->x = new CWindowCoord(this,
801 keyframe ? keyframe->center_x : (float)0);
802 this->x->create_objects();
805 add_subwindow(title = new BC_Title(x, y, _("Y:")));
807 this->y = new CWindowCoord(this,
810 keyframe ? keyframe->center_y : (float)0);
811 this->y->create_objects();
814 add_subwindow(title = new BC_Title(x, y, _("Z:")));
816 this->z = new CWindowCoord(this,
819 zoom_keyframe ? zoom_keyframe->value : (float)1);
820 this->z->create_objects();
824 add_subwindow(button = new CWindowProjectorLeft(mwindow, this, x1, y));
825 x1 += button->get_w();
826 add_subwindow(button = new CWindowProjectorCenter(mwindow, this, x1, y));
827 x1 += button->get_w();
828 add_subwindow(button = new CWindowProjectorRight(mwindow, this, x1, y));
830 y += button->get_h();
832 add_subwindow(button = new CWindowProjectorTop(mwindow, this, x1, y));
833 x1 += button->get_w();
834 add_subwindow(button = new CWindowProjectorMiddle(mwindow, this, x1, y));
835 x1 += button->get_w();
836 add_subwindow(button = new CWindowProjectorBottom(mwindow, this, x1, y));
839 if(mwindow->edl->session->tool_window) show_window();
843 void CWindowProjectorGUI::update_preview()
845 mwindow->restart_brender();
846 mwindow->sync_parameters(CHANGE_PARAMS);
847 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
851 mwindow->cwindow->gui->lock_window("CWindowProjectorGUI::update_preview");
852 mwindow->cwindow->gui->canvas->draw_refresh();
853 mwindow->cwindow->gui->unlock_window();
856 void CWindowProjectorGUI::handle_event()
858 BezierAuto *keyframe = 0;
859 FloatAuto *zoom_keyframe = 0;
860 Track *track = mwindow->cwindow->calculate_affected_track();
864 if(event_caller == z)
865 zoom_keyframe = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
866 track->automation->pzoom_autos,
869 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(
870 track->automation->projector_autos,
876 keyframe->center_x = atof(x->get_text());
877 keyframe->center_y = atof(y->get_text());
883 float zoom = atof(z->get_text());
884 if(zoom > 10000) zoom = 10000;
886 if(zoom < 0) zoom = 0;
887 // if (zoom != atof(z->get_text()))
889 zoom_keyframe->value = zoom;
890 mwindow->gui->lock_window("CWindowProjectorGUI::handle_event");
891 mwindow->gui->canvas->draw_overlays();
892 mwindow->gui->canvas->flash();
893 mwindow->gui->unlock_window();
898 void CWindowProjectorGUI::update()
900 BezierAuto *keyframe = 0;
901 FloatAuto *zoom_keyframe = 0;
902 Track *track = mwindow->cwindow->calculate_affected_track();
906 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(
907 track->automation->projector_autos,
909 zoom_keyframe = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
910 track->automation->pzoom_autos,
916 x->update(keyframe->center_x);
917 y->update(keyframe->center_y);
922 z->update(zoom_keyframe->value);
926 BezierAuto* CWindowProjectorGUI::get_keyframe()
928 BezierAuto *keyframe = 0;
929 Track *track = mwindow->cwindow->calculate_affected_track();
931 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->projector_autos);
972 CWindowProjectorLeft::CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
973 : BC_Button(x, y, mwindow->theme->left_justify)
976 this->mwindow = mwindow;
977 set_tooltip(_("Left justify"));
979 int CWindowProjectorLeft::handle_event()
981 BezierAuto *keyframe = 0;
982 FloatAuto *zoom_keyframe = 0;
983 Track *track = mwindow->cwindow->calculate_affected_track();
986 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->projector_autos, 1);
987 zoom_keyframe = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->pzoom_autos, 0);
991 keyframe->center_x = (double)track->track_w * zoom_keyframe->value / 2 -
992 (double)mwindow->edl->session->output_w / 2;
994 gui->update_preview();
1001 CWindowProjectorCenter::CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1002 : BC_Button(x, y, mwindow->theme->center_justify)
1005 this->mwindow = mwindow;
1006 set_tooltip(_("Center horizontal"));
1008 int CWindowProjectorCenter::handle_event()
1010 BezierAuto *keyframe = 0;
1011 Track *track = mwindow->cwindow->calculate_affected_track();
1013 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->projector_autos);
1017 keyframe->center_x = 0;
1019 gui->update_preview();
1026 CWindowProjectorRight::CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1027 : BC_Button(x, y, mwindow->theme->right_justify)
1030 this->mwindow = mwindow;
1031 set_tooltip(_("Right justify"));
1033 int CWindowProjectorRight::handle_event()
1035 BezierAuto *keyframe = 0;
1036 FloatAuto *zoom_keyframe = 0;
1037 Track *track = mwindow->cwindow->calculate_affected_track();
1040 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->projector_autos, 1);
1041 zoom_keyframe = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->pzoom_autos, 0);
1046 keyframe->center_x = -((double)track->track_w * zoom_keyframe->value / 2 -
1047 (double)mwindow->edl->session->output_w / 2);
1049 gui->update_preview();
1056 CWindowProjectorTop::CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1057 : BC_Button(x, y, mwindow->theme->top_justify)
1060 this->mwindow = mwindow;
1061 set_tooltip(_("Top justify"));
1063 int CWindowProjectorTop::handle_event()
1065 BezierAuto *keyframe = 0;
1066 FloatAuto *zoom_keyframe = 0;
1067 Track *track = mwindow->cwindow->calculate_affected_track();
1070 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->projector_autos, 1);
1071 zoom_keyframe = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->pzoom_autos, 0);
1076 keyframe->center_y = (double)track->track_h * zoom_keyframe->value / 2 -
1077 (double)mwindow->edl->session->output_h / 2;
1079 gui->update_preview();
1086 CWindowProjectorMiddle::CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1087 : BC_Button(x, y, mwindow->theme->middle_justify)
1090 this->mwindow = mwindow;
1091 set_tooltip(_("Center vertical"));
1093 int CWindowProjectorMiddle::handle_event()
1095 BezierAuto *keyframe = 0;
1096 Track *track = mwindow->cwindow->calculate_affected_track();
1098 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->projector_autos);
1102 keyframe->center_y = 0;
1104 gui->update_preview();
1111 CWindowProjectorBottom::CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1112 : BC_Button(x, y, mwindow->theme->bottom_justify)
1115 this->mwindow = mwindow;
1116 set_tooltip(_("Bottom justify"));
1118 int CWindowProjectorBottom::handle_event()
1120 BezierAuto *keyframe = 0;
1121 FloatAuto *zoom_keyframe = 0;
1122 Track *track = mwindow->cwindow->calculate_affected_track();
1125 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->projector_autos, 1);
1126 zoom_keyframe = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->pzoom_autos, 0);
1131 keyframe->center_y = -((double)track->track_h * zoom_keyframe->value / 2 -
1132 (double)mwindow->edl->session->output_h / 2);
1134 gui->update_preview();
1147 CWindowMaskMode::CWindowMaskMode(MWindow *mwindow,
1148 CWindowToolGUI *gui,
1158 this->mwindow = mwindow;
1162 void CWindowMaskMode::create_objects()
1164 add_item(new BC_MenuItem(mode_to_text(MASK_MULTIPLY_ALPHA)));
1165 add_item(new BC_MenuItem(mode_to_text(MASK_SUBTRACT_ALPHA)));
1168 char* CWindowMaskMode::mode_to_text(int mode)
1172 case MASK_MULTIPLY_ALPHA:
1173 return _("Multiply alpha");
1176 case MASK_SUBTRACT_ALPHA:
1177 return _("Subtract alpha");
1181 return _("Subtract alpha");
1184 int CWindowMaskMode::text_to_mode(char *text)
1186 if(!strcasecmp(text, _("Multiply alpha")))
1187 return MASK_MULTIPLY_ALPHA;
1189 if(!strcasecmp(text, _("Subtract alpha")))
1190 return MASK_SUBTRACT_ALPHA;
1192 return MASK_SUBTRACT_ALPHA;
1195 int CWindowMaskMode::handle_event()
1201 ((CWindowMaskGUI*)gui)->get_keyframe(track,
1209 ((MaskAuto*)track->automation->mask_autos->default_auto)->mode =
1210 text_to_mode(get_text());
1213 //printf("CWindowMaskMode::handle_event 1\n");
1214 gui->update_preview();
1225 CWindowMaskDelete::CWindowMaskDelete(MWindow *mwindow,
1226 CWindowToolGUI *gui,
1229 : BC_GenericButton(x, y, _("Delete"))
1231 this->mwindow = mwindow;
1235 int CWindowMaskDelete::handle_event()
1238 Track *track = mwindow->cwindow->calculate_affected_track();
1245 MaskAutos *mask_autos = track->automation->mask_autos;
1246 for(MaskAuto *current = (MaskAuto*)mask_autos->default_auto;
1249 SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
1253 for(int i = mwindow->cwindow->gui->affected_point;
1254 i < submask->points.total - 1;
1257 *submask->points.values[i] = *submask->points.values[i + 1];
1260 if(submask->points.total)
1262 submask->points.remove_object(
1263 submask->points.values[submask->points.total - 1]);
1267 if(current == (MaskAuto*)mask_autos->default_auto)
1268 current = (MaskAuto*)mask_autos->first;
1270 current = (MaskAuto*)NEXT;
1273 gui->update_preview();
1277 // ((CWindowMaskGUI*)gui)->get_keyframe(track,
1283 // Need to apply to every keyframe
1287 // for(int i = mwindow->cwindow->gui->affected_point;
1288 // i < mask->points.total - 1;
1291 // *mask->points.values[i] = *mask->points.values[i + 1];
1294 // if(mask->points.total)
1296 // mask->points.remove_object(mask->points.values[mask->points.total - 1]);
1300 // gui->update_preview();
1306 int CWindowMaskDelete::keypress_event()
1308 if(get_keypress() == BACKSPACE ||
1309 get_keypress() == DELETE)
1310 return handle_event();
1315 CWindowMaskCycleNext::CWindowMaskCycleNext(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1316 : BC_GenericButton(x, y, _("Cycle next"))
1318 this->mwindow = mwindow;
1321 int CWindowMaskCycleNext::handle_event()
1327 ((CWindowMaskGUI*)gui)->get_keyframe(track,
1335 // Should apply to all keyframes
1336 if(keyframe && mask->points.total)
1338 temp = mask->points.values[0];
1340 for(int i = 0; i < mask->points.total - 1; i++)
1342 mask->points.values[i] = mask->points.values[i + 1];
1344 mask->points.values[mask->points.total - 1] = temp;
1346 mwindow->cwindow->gui->affected_point--;
1347 if(mwindow->cwindow->gui->affected_point < 0)
1348 mwindow->cwindow->gui->affected_point = mask->points.total - 1;
1351 gui->update_preview();
1357 CWindowMaskCyclePrev::CWindowMaskCyclePrev(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1358 : BC_GenericButton(x, y, _("Cycle prev"))
1360 this->mwindow = mwindow;
1363 int CWindowMaskCyclePrev::handle_event()
1369 ((CWindowMaskGUI*)gui)->get_keyframe(track,
1375 // Should apply to all keyframes
1377 if(keyframe && mask->points.total)
1379 temp = mask->points.values[mask->points.total - 1];
1381 for(int i = mask->points.total - 1; i > 0; i--)
1383 mask->points.values[i] = mask->points.values[i - 1];
1385 mask->points.values[0] = temp;
1387 mwindow->cwindow->gui->affected_point++;
1388 if(mwindow->cwindow->gui->affected_point >= mask->points.total)
1389 mwindow->cwindow->gui->affected_point = 0;
1392 gui->update_preview();
1398 CWindowMaskNumber::CWindowMaskNumber(MWindow *mwindow,
1399 CWindowToolGUI *gui,
1402 : BC_TumbleTextBox(gui,
1403 (int64_t)mwindow->edl->session->cwindow_mask,
1405 (int64_t)SUBMASKS - 1,
1410 this->mwindow = mwindow;
1414 CWindowMaskNumber::~CWindowMaskNumber()
1418 int CWindowMaskNumber::handle_event()
1420 mwindow->edl->session->cwindow_mask = atol(get_text());
1422 gui->update_preview();
1430 CWindowMaskFeather::CWindowMaskFeather(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1431 : BC_TumbleTextBox(gui,
1439 this->mwindow = mwindow;
1442 CWindowMaskFeather::~CWindowMaskFeather()
1445 int CWindowMaskFeather::handle_event()
1451 ((CWindowMaskGUI*)gui)->get_keyframe(track,
1457 keyframe->feather = atof(get_text());
1458 gui->update_preview();
1462 CWindowMaskValue::CWindowMaskValue(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1472 this->mwindow = mwindow;
1476 CWindowMaskValue::~CWindowMaskValue()
1480 int CWindowMaskValue::handle_event()
1486 ((CWindowMaskGUI*)gui)->get_keyframe(track,
1492 keyframe->value = get_value();
1493 gui->update_preview();
1507 CWindowMaskGUI::CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread)
1508 : CWindowToolGUI(mwindow,
1510 PROGRAM_NAME ": Mask",
1514 this->mwindow = mwindow;
1515 this->thread = thread;
1517 CWindowMaskGUI::~CWindowMaskGUI()
1523 void CWindowMaskGUI::create_objects()
1525 //printf("CWindowMaskGUI::create_objects 1\n");
1527 MaskAuto *keyframe = 0;
1528 Track *track = mwindow->cwindow->calculate_affected_track();
1530 keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->mask_autos, 0);
1531 //printf("CWindowMaskGUI::create_objects 1\n");
1534 add_subwindow(title = new BC_Title(x, y, _("Mode:")));
1535 add_subwindow(mode = new CWindowMaskMode(mwindow,
1540 //printf("CWindowMaskGUI::create_objects 1\n");
1541 mode->create_objects();
1543 add_subwindow(new BC_Title(x, y, _("Value:")));
1544 add_subwindow(value = new CWindowMaskValue(mwindow, this, x + 50, y));
1546 add_subwindow(delete_point = new CWindowMaskDelete(mwindow, this, x, y));
1548 // add_subwindow(next_point = new CWindowMaskCycleNext(mwindow, this, x, y));
1550 // add_subwindow(prev_point = new CWindowMaskCyclePrev(mwindow, this, x, y));
1552 add_subwindow(new BC_Title(x, y, _("Mask number:")));
1553 number = new CWindowMaskNumber(mwindow,
1557 //printf("CWindowMaskGUI::create_objects 1\n");
1558 number->create_objects();
1560 add_subwindow(new BC_Title(x, y, _("Feather:")));
1561 feather = new CWindowMaskFeather(mwindow,
1565 feather->create_objects();
1567 add_subwindow(title = new BC_Title(x, y, _("X:")));
1568 x += title->get_w();
1569 this->x = new CWindowCoord(this,
1573 this->x->create_objects();
1575 add_subwindow(title = new BC_Title(x, y, _("Y:")));
1576 x += title->get_w();
1577 this->y = new CWindowCoord(this,
1581 this->y->create_objects();
1582 //printf("CWindowMaskGUI::create_objects 1\n");
1585 if(mwindow->edl->session->tool_window) show_window();
1587 //printf("CWindowMaskGUI::create_objects 2\n");
1590 void CWindowMaskGUI::get_keyframe(Track* &track,
1591 MaskAuto* &keyframe,
1597 track = mwindow->cwindow->calculate_affected_track();
1599 keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->mask_autos, create_it);
1604 mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
1611 if(mwindow->cwindow->gui->affected_point < mask->points.total &&
1612 mwindow->cwindow->gui->affected_point >= 0)
1614 point = mask->points.values[mwindow->cwindow->gui->affected_point];
1619 void CWindowMaskGUI::update()
1625 //printf("CWindowMaskGUI::update 1\n");
1632 //printf("CWindowMaskGUI::update 1\n");
1635 x->update(point->x);
1636 y->update(point->y);
1638 //printf("CWindowMaskGUI::update 1\n");
1642 feather->update((int64_t)keyframe->feather);
1643 value->update((int64_t)keyframe->value);
1645 //printf("CWindowMaskGUI::update 1\n");
1647 number->update((int64_t)mwindow->edl->session->cwindow_mask);
1649 //printf("CWindowMaskGUI::update 1\n");
1653 CWindowMaskMode::mode_to_text(((MaskAuto*)track->automation->mask_autos->default_auto)->mode));
1655 //printf("CWindowMaskGUI::update 2\n");
1658 void CWindowMaskGUI::handle_event()
1672 point->x = atof(x->get_text());
1673 point->y = atof(y->get_text());
1679 void CWindowMaskGUI::update_preview()
1681 mwindow->restart_brender();
1682 mwindow->sync_parameters(CHANGE_PARAMS);
1683 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1687 mwindow->cwindow->gui->lock_window("CWindowMaskGUI::update_preview");
1688 mwindow->cwindow->gui->canvas->draw_refresh();
1689 mwindow->cwindow->gui->unlock_window();