1 #include "automation.h"
2 #include "bezierauto.h"
3 #include "bezierautos.h"
7 #include "cwindowgui.h"
8 #include "cwindowtool.h"
10 #include "edlsession.h"
11 #include "floatauto.h"
12 #include "floatautos.h"
14 #include "localsession.h"
15 #include "mainsession.h"
17 #include "maskautos.h"
19 #include "mwindowgui.h"
22 #include "trackcanvas.h"
23 #include "transportque.h"
26 #define _(String) gettext(String)
27 #define gettext_noop(String) String
28 #define N_(String) gettext_noop (String)
30 CWindowTool::CWindowTool(MWindow *mwindow, CWindowGUI *gui)
33 this->mwindow = mwindow;
37 current_tool = CWINDOW_NONE;
39 input_lock = new Mutex;
41 output_lock = new Mutex;
44 CWindowTool::~CWindowTool()
54 void CWindowTool::start_tool(int operation)
56 CWindowToolGUI *new_gui = 0;
59 //printf("CWindowTool::start_tool 1\n");
60 if(current_tool != operation)
62 current_tool = operation;
66 new_gui = new CWindowCropGUI(mwindow, this);
69 new_gui = new CWindowCameraGUI(mwindow, this);
71 case CWINDOW_PROJECTOR:
72 new_gui = new CWindowProjectorGUI(mwindow, this);
75 new_gui = new CWindowMaskGUI(mwindow, this);
83 //printf("CWindowTool::start_tool 1\n");
90 this->tool_gui = new_gui;
91 tool_gui->create_objects();
94 //printf("CWindowTool::start_tool 1\n");
99 tool_gui->lock_window();
101 tool_gui->unlock_window();
104 //printf("CWindowTool::start_tool 2\n");
109 void CWindowTool::stop_tool()
113 tool_gui->lock_window();
114 tool_gui->set_done(0);
115 tool_gui->unlock_window();
119 void CWindowTool::run()
126 tool_gui->run_window();
130 output_lock->unlock();
134 void CWindowTool::update_show_window()
138 tool_gui->lock_window();
140 if(mwindow->edl->session->tool_window)
143 tool_gui->show_window();
146 tool_gui->hide_window();
149 tool_gui->unlock_window();
153 void CWindowTool::update_values()
157 //printf("CWindowTool::update_values 1\n");
158 tool_gui->lock_window();
161 tool_gui->unlock_window();
162 //printf("CWindowTool::update_values 2\n");
172 CWindowToolGUI::CWindowToolGUI(MWindow *mwindow,
178 mwindow->session->ctool_x,
179 mwindow->session->ctool_y,
188 this->mwindow = mwindow;
189 this->thread = thread;
190 current_operation = 0;
193 CWindowToolGUI::~CWindowToolGUI()
197 int CWindowToolGUI::close_event()
201 mwindow->edl->session->tool_window = 0;
202 thread->gui->lock_window();
203 thread->gui->composite_panel->set_operation(mwindow->edl->session->cwindow_operation);
204 thread->gui->flush();
205 thread->gui->unlock_window();
209 int CWindowToolGUI::keypress_event()
211 if(get_keypress() == 'w' || get_keypress() == 'W')
212 return close_event();
216 int CWindowToolGUI::translation_event()
218 mwindow->session->ctool_x = get_x();
219 mwindow->session->ctool_y = get_y();
228 CWindowCoord::CWindowCoord(CWindowToolGUI *gui, int x, int y, float value)
229 : BC_TumbleTextBox(gui,
240 CWindowCoord::CWindowCoord(CWindowToolGUI *gui, int x, int y, int value)
241 : BC_TumbleTextBox(gui,
251 int CWindowCoord::handle_event()
253 gui->event_caller = this;
259 CWindowCropOK::CWindowCropOK(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
260 : BC_GenericButton(x, y, _("Do it"))
262 this->mwindow = mwindow;
265 int CWindowCropOK::handle_event()
267 mwindow->crop_video();
272 int CWindowCropOK::keypress_event()
274 if(get_keypress() == 0xd)
288 CWindowCropGUI::CWindowCropGUI(MWindow *mwindow, CWindowTool *thread)
289 : CWindowToolGUI(mwindow,
291 PROGRAM_NAME ": Crop",
298 CWindowCropGUI::~CWindowCropGUI()
302 void CWindowCropGUI::create_objects()
305 BC_TumbleTextBox *textbox;
308 add_subwindow(title = new BC_Title(x, y, _("X1:")));
310 x1 = new CWindowCoord(thread->tool_gui, x, y, mwindow->edl->session->crop_x1);
311 x1->create_objects();
312 x += x1->get_w() + 10;
314 add_subwindow(title = new BC_Title(x, y, _("Y1:")));
316 y1 = new CWindowCoord(thread->tool_gui, x, y, mwindow->edl->session->crop_y1);
317 y1->create_objects();
318 y += y1->get_h() + 5;
321 add_subwindow(title = new BC_Title(x, y, _("X2:")));
323 x2 = new CWindowCoord(thread->tool_gui, x, y, mwindow->edl->session->crop_x2);
324 x2->create_objects();
325 x += x2->get_w() + 10;
327 add_subwindow(title = new BC_Title(x, y, _("Y2:")));
329 y2 = new CWindowCoord(thread->tool_gui, x, y, mwindow->edl->session->crop_y2);
330 y2->create_objects();
331 y += y2->get_h() + 5;
333 add_subwindow(new CWindowCropOK(mwindow, thread->tool_gui, x, y));
335 if(mwindow->edl->session->tool_window) show_window();
339 void CWindowCropGUI::handle_event()
341 mwindow->edl->session->crop_x1 = atol(x1->get_text());
342 mwindow->edl->session->crop_y1 = atol(y1->get_text());
343 mwindow->edl->session->crop_x2 = atol(x2->get_text());
344 mwindow->edl->session->crop_y2 = atol(y2->get_text());
345 mwindow->cwindow->gui->lock_window();
346 mwindow->cwindow->gui->canvas->draw_refresh();
347 mwindow->cwindow->gui->unlock_window();
350 void CWindowCropGUI::update()
352 x1->update((int64_t)mwindow->edl->session->crop_x1);
353 y1->update((int64_t)mwindow->edl->session->crop_y1);
354 x2->update((int64_t)mwindow->edl->session->crop_x2);
355 y2->update((int64_t)mwindow->edl->session->crop_y2);
369 CWindowCameraGUI::CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread)
370 : CWindowToolGUI(mwindow,
372 PROGRAM_NAME ": Camera",
377 CWindowCameraGUI::~CWindowCameraGUI()
381 void CWindowCameraGUI::create_objects()
383 int x = 10, y = 10, x1;
384 Track *track = mwindow->cwindow->calculate_affected_track();
385 BezierAuto *keyframe = 0;
386 FloatAuto *zoom_keyframe = 0;
392 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(
393 track->automation->camera_autos,
395 zoom_keyframe = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
396 track->automation->czoom_autos,
400 add_subwindow(title = new BC_Title(x, y, _("X:")));
402 this->x = new CWindowCoord(this,
405 keyframe ? keyframe->center_x : (float)0);
406 this->x->create_objects();
409 add_subwindow(title = new BC_Title(x, y, _("Y:")));
411 this->y = new CWindowCoord(this,
414 keyframe ? keyframe->center_y : (float)0);
415 this->y->create_objects();
418 add_subwindow(title = new BC_Title(x, y, _("Z:")));
420 this->z = new CWindowCoord(this,
423 zoom_keyframe ? zoom_keyframe->value : (float)1);
424 this->z->create_objects();
428 add_subwindow(button = new CWindowCameraLeft(mwindow, this, x1, y));
429 x1 += button->get_w();
430 add_subwindow(button = new CWindowCameraCenter(mwindow, this, x1, y));
431 x1 += button->get_w();
432 add_subwindow(button = new CWindowCameraRight(mwindow, this, x1, y));
434 y += button->get_h();
436 add_subwindow(button = new CWindowCameraTop(mwindow, this, x1, y));
437 x1 += button->get_w();
438 add_subwindow(button = new CWindowCameraMiddle(mwindow, this, x1, y));
439 x1 += button->get_w();
440 add_subwindow(button = new CWindowCameraBottom(mwindow, this, x1, y));
444 if(mwindow->edl->session->tool_window) show_window();
448 void CWindowCameraGUI::update_preview()
450 //printf("CWindowCameraGUI::update_preview 1\n");
451 mwindow->restart_brender();
452 mwindow->sync_parameters(CHANGE_PARAMS);
454 //printf("CWindowCameraGUI::update_preview 1\n");
455 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
459 //printf("CWindowCameraGUI::update_preview 1\n");
460 mwindow->cwindow->gui->lock_window();
461 //printf("CWindowCameraGUI::update_preview 1\n");
462 mwindow->cwindow->gui->canvas->draw_refresh();
463 //printf("CWindowCameraGUI::update_preview 2\n");
464 mwindow->cwindow->gui->unlock_window();
465 //printf("CWindowCameraGUI::update_preview 3\n");
469 void CWindowCameraGUI::handle_event()
471 BezierAuto *keyframe = 0;
472 FloatAuto *zoom_keyframe = 0;
473 Track *track = mwindow->cwindow->calculate_affected_track();
476 if(event_caller == z)
477 zoom_keyframe = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
478 track->automation->czoom_autos,
481 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(
482 track->automation->camera_autos,
488 keyframe->center_x = atof(x->get_text());
489 keyframe->center_y = atof(y->get_text());
495 zoom_keyframe->value = atof(z->get_text());
496 mwindow->gui->lock_window();
497 mwindow->gui->canvas->draw_overlays();
498 mwindow->gui->canvas->flash();
499 mwindow->gui->unlock_window();
504 void CWindowCameraGUI::update()
506 BezierAuto *keyframe = 0;
507 FloatAuto *zoom_keyframe = 0;
508 Track *track = mwindow->cwindow->calculate_affected_track();
512 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(
513 track->automation->camera_autos,
515 zoom_keyframe = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
516 track->automation->czoom_autos,
522 x->update(keyframe->center_x);
523 y->update(keyframe->center_y);
528 z->update(zoom_keyframe->value);
532 BezierAuto* CWindowCameraGUI::get_keyframe()
534 BezierAuto *keyframe = 0;
535 Track *track = mwindow->cwindow->calculate_affected_track();
537 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->camera_autos);
543 CWindowCameraLeft::CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
544 : BC_Button(x, y, mwindow->theme->left_justify)
547 this->mwindow = mwindow;
548 set_tooltip(_("Left justify"));
550 int CWindowCameraLeft::handle_event()
552 BezierAuto *keyframe = 0;
553 Track *track = mwindow->cwindow->calculate_affected_track();
555 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->camera_autos);
560 track->get_source_dimensions(mwindow->edl->local_session->selectionstart,
567 (double)track->track_w / keyframe->center_z / 2 -
570 gui->update_preview();
578 CWindowCameraCenter::CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
579 : BC_Button(x, y, mwindow->theme->center_justify)
582 this->mwindow = mwindow;
583 set_tooltip(_("Center horizontal"));
585 int CWindowCameraCenter::handle_event()
587 BezierAuto *keyframe = 0;
588 Track *track = mwindow->cwindow->calculate_affected_track();
590 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->camera_autos);
594 keyframe->center_x = 0;
596 gui->update_preview();
603 CWindowCameraRight::CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
604 : BC_Button(x, y, mwindow->theme->right_justify)
607 this->mwindow = mwindow;
608 set_tooltip(_("Right justify"));
610 int CWindowCameraRight::handle_event()
612 BezierAuto *keyframe = 0;
613 Track *track = mwindow->cwindow->calculate_affected_track();
615 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->camera_autos);
620 track->get_source_dimensions(mwindow->edl->local_session->selectionstart,
626 keyframe->center_x = -((double)track->track_w / keyframe->center_z / 2 -
629 gui->update_preview();
637 CWindowCameraTop::CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
638 : BC_Button(x, y, mwindow->theme->top_justify)
641 this->mwindow = mwindow;
642 set_tooltip(_("Top justify"));
644 int CWindowCameraTop::handle_event()
646 BezierAuto *keyframe = 0;
647 Track *track = mwindow->cwindow->calculate_affected_track();
649 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->camera_autos);
654 track->get_source_dimensions(mwindow->edl->local_session->selectionstart,
660 keyframe->center_y = (double)track->track_h / keyframe->center_z / 2 -
663 gui->update_preview();
671 CWindowCameraMiddle::CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
672 : BC_Button(x, y, mwindow->theme->middle_justify)
675 this->mwindow = mwindow;
676 set_tooltip(_("Center vertical"));
678 int CWindowCameraMiddle::handle_event()
680 BezierAuto *keyframe = 0;
681 Track *track = mwindow->cwindow->calculate_affected_track();
683 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->camera_autos);
687 keyframe->center_y = 0;
689 gui->update_preview();
696 CWindowCameraBottom::CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
697 : BC_Button(x, y, mwindow->theme->bottom_justify)
700 this->mwindow = mwindow;
701 set_tooltip(_("Bottom justify"));
703 int CWindowCameraBottom::handle_event()
705 BezierAuto *keyframe = 0;
706 Track *track = mwindow->cwindow->calculate_affected_track();
708 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->camera_autos);
713 track->get_source_dimensions(mwindow->edl->local_session->selectionstart,
719 keyframe->center_y = -((double)track->track_h / keyframe->center_z / 2 -
722 gui->update_preview();
745 CWindowProjectorGUI::CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread)
746 : CWindowToolGUI(mwindow,
748 PROGRAM_NAME ": Projector",
753 CWindowProjectorGUI::~CWindowProjectorGUI()
756 void CWindowProjectorGUI::create_objects()
758 int x = 10, y = 10, x1;
759 Track *track = mwindow->cwindow->calculate_affected_track();
760 BezierAuto *keyframe = 0;
761 FloatAuto *zoom_keyframe = 0;
767 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(
768 track->automation->projector_autos,
770 zoom_keyframe = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
771 track->automation->pzoom_autos,
775 add_subwindow(title = new BC_Title(x, y, _("X:")));
777 this->x = new CWindowCoord(this,
780 keyframe ? keyframe->center_x : (float)0);
781 this->x->create_objects();
784 add_subwindow(title = new BC_Title(x, y, _("Y:")));
786 this->y = new CWindowCoord(this,
789 keyframe ? keyframe->center_y : (float)0);
790 this->y->create_objects();
793 add_subwindow(title = new BC_Title(x, y, _("Z:")));
795 this->z = new CWindowCoord(this,
798 zoom_keyframe ? zoom_keyframe->value : (float)1);
799 this->z->create_objects();
803 add_subwindow(button = new CWindowProjectorLeft(mwindow, this, x1, y));
804 x1 += button->get_w();
805 add_subwindow(button = new CWindowProjectorCenter(mwindow, this, x1, y));
806 x1 += button->get_w();
807 add_subwindow(button = new CWindowProjectorRight(mwindow, this, x1, y));
809 y += button->get_h();
811 add_subwindow(button = new CWindowProjectorTop(mwindow, this, x1, y));
812 x1 += button->get_w();
813 add_subwindow(button = new CWindowProjectorMiddle(mwindow, this, x1, y));
814 x1 += button->get_w();
815 add_subwindow(button = new CWindowProjectorBottom(mwindow, this, x1, y));
818 if(mwindow->edl->session->tool_window) show_window();
822 void CWindowProjectorGUI::update_preview()
824 mwindow->restart_brender();
825 mwindow->sync_parameters(CHANGE_PARAMS);
826 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
830 mwindow->cwindow->gui->lock_window();
831 mwindow->cwindow->gui->canvas->draw_refresh();
832 mwindow->cwindow->gui->unlock_window();
835 void CWindowProjectorGUI::handle_event()
837 BezierAuto *keyframe = 0;
838 FloatAuto *zoom_keyframe = 0;
839 Track *track = mwindow->cwindow->calculate_affected_track();
843 if(event_caller == z)
844 zoom_keyframe = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
845 track->automation->pzoom_autos,
848 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(
849 track->automation->projector_autos,
855 keyframe->center_x = atof(x->get_text());
856 keyframe->center_y = atof(y->get_text());
857 keyframe->center_z = atof(z->get_text());
863 zoom_keyframe->value = atof(z->get_text());
864 mwindow->gui->lock_window();
865 mwindow->gui->canvas->draw_overlays();
866 mwindow->gui->canvas->flash();
867 mwindow->gui->unlock_window();
872 void CWindowProjectorGUI::update()
874 BezierAuto *keyframe = 0;
875 FloatAuto *zoom_keyframe = 0;
876 Track *track = mwindow->cwindow->calculate_affected_track();
880 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(
881 track->automation->projector_autos,
883 zoom_keyframe = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
884 track->automation->pzoom_autos,
890 x->update(keyframe->center_x);
891 y->update(keyframe->center_y);
896 z->update(zoom_keyframe->value);
900 BezierAuto* CWindowProjectorGUI::get_keyframe()
902 BezierAuto *keyframe = 0;
903 Track *track = mwindow->cwindow->calculate_affected_track();
905 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->projector_autos);
946 CWindowProjectorLeft::CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
947 : BC_Button(x, y, mwindow->theme->left_justify)
950 this->mwindow = mwindow;
951 set_tooltip(_("Left justify"));
953 int CWindowProjectorLeft::handle_event()
955 BezierAuto *keyframe = 0;
956 Track *track = mwindow->cwindow->calculate_affected_track();
958 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->projector_autos);
962 keyframe->center_x = (double)track->track_w * keyframe->center_z / 2 -
963 (double)mwindow->edl->session->output_w / 2;
965 gui->update_preview();
972 CWindowProjectorCenter::CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
973 : BC_Button(x, y, mwindow->theme->center_justify)
976 this->mwindow = mwindow;
977 set_tooltip(_("Center horizontal"));
979 int CWindowProjectorCenter::handle_event()
981 BezierAuto *keyframe = 0;
982 Track *track = mwindow->cwindow->calculate_affected_track();
984 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->projector_autos);
988 keyframe->center_x = 0;
990 gui->update_preview();
997 CWindowProjectorRight::CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
998 : BC_Button(x, y, mwindow->theme->right_justify)
1001 this->mwindow = mwindow;
1002 set_tooltip(_("Right justify"));
1004 int CWindowProjectorRight::handle_event()
1006 BezierAuto *keyframe = 0;
1007 Track *track = mwindow->cwindow->calculate_affected_track();
1009 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->projector_autos);
1013 keyframe->center_x = -((double)track->track_w * keyframe->center_z / 2 -
1014 (double)mwindow->edl->session->output_w / 2);
1016 gui->update_preview();
1023 CWindowProjectorTop::CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1024 : BC_Button(x, y, mwindow->theme->top_justify)
1027 this->mwindow = mwindow;
1028 set_tooltip(_("Top justify"));
1030 int CWindowProjectorTop::handle_event()
1032 BezierAuto *keyframe = 0;
1033 Track *track = mwindow->cwindow->calculate_affected_track();
1035 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->projector_autos);
1039 keyframe->center_y = (double)track->track_h * keyframe->center_z / 2 -
1040 (double)mwindow->edl->session->output_h / 2;
1042 gui->update_preview();
1049 CWindowProjectorMiddle::CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1050 : BC_Button(x, y, mwindow->theme->middle_justify)
1053 this->mwindow = mwindow;
1054 set_tooltip(_("Center vertical"));
1056 int CWindowProjectorMiddle::handle_event()
1058 BezierAuto *keyframe = 0;
1059 Track *track = mwindow->cwindow->calculate_affected_track();
1061 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->projector_autos);
1065 keyframe->center_y = 0;
1067 gui->update_preview();
1074 CWindowProjectorBottom::CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1075 : BC_Button(x, y, mwindow->theme->bottom_justify)
1078 this->mwindow = mwindow;
1079 set_tooltip(_("Bottom justify"));
1081 int CWindowProjectorBottom::handle_event()
1083 BezierAuto *keyframe = 0;
1084 Track *track = mwindow->cwindow->calculate_affected_track();
1086 keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->projector_autos);
1090 keyframe->center_y = -((double)track->track_h * keyframe->center_z / 2 -
1091 (double)mwindow->edl->session->output_h / 2);
1093 gui->update_preview();
1106 CWindowMaskMode::CWindowMaskMode(MWindow *mwindow,
1107 CWindowToolGUI *gui,
1117 this->mwindow = mwindow;
1121 void CWindowMaskMode::create_objects()
1123 add_item(new BC_MenuItem(mode_to_text(MASK_MULTIPLY_ALPHA)));
1124 add_item(new BC_MenuItem(mode_to_text(MASK_SUBTRACT_ALPHA)));
1127 char* CWindowMaskMode::mode_to_text(int mode)
1131 case MASK_MULTIPLY_ALPHA:
1132 return _("Multiply alpha");
1135 case MASK_SUBTRACT_ALPHA:
1136 return _("Subtract alpha");
1140 return _("Subtract alpha");
1143 int CWindowMaskMode::text_to_mode(char *text)
1145 if(!strcasecmp(text, _("Multiply alpha")))
1146 return MASK_MULTIPLY_ALPHA;
1148 if(!strcasecmp(text, _("Subtract alpha")))
1149 return MASK_SUBTRACT_ALPHA;
1151 return MASK_SUBTRACT_ALPHA;
1154 int CWindowMaskMode::handle_event()
1160 ((CWindowMaskGUI*)gui)->get_keyframe(track,
1168 ((MaskAuto*)track->automation->mask_autos->default_auto)->mode =
1169 text_to_mode(get_text());
1172 //printf("CWindowMaskMode::handle_event 1\n");
1173 gui->update_preview();
1184 CWindowMaskDelete::CWindowMaskDelete(MWindow *mwindow,
1185 CWindowToolGUI *gui,
1188 : BC_GenericButton(x, y, _("Delete"))
1190 this->mwindow = mwindow;
1194 int CWindowMaskDelete::handle_event()
1197 Track *track = mwindow->cwindow->calculate_affected_track();
1204 MaskAutos *mask_autos = track->automation->mask_autos;
1205 for(MaskAuto *current = (MaskAuto*)mask_autos->default_auto;
1208 SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
1212 for(int i = mwindow->cwindow->gui->affected_point;
1213 i < submask->points.total - 1;
1216 *submask->points.values[i] = *submask->points.values[i + 1];
1219 if(submask->points.total)
1221 submask->points.remove_object(
1222 submask->points.values[submask->points.total - 1]);
1226 if(current == (MaskAuto*)mask_autos->default_auto)
1227 current = (MaskAuto*)mask_autos->first;
1229 current = (MaskAuto*)NEXT;
1232 gui->update_preview();
1236 // ((CWindowMaskGUI*)gui)->get_keyframe(track,
1242 // Need to apply to every keyframe
1246 // for(int i = mwindow->cwindow->gui->affected_point;
1247 // i < mask->points.total - 1;
1250 // *mask->points.values[i] = *mask->points.values[i + 1];
1253 // if(mask->points.total)
1255 // mask->points.remove_object(mask->points.values[mask->points.total - 1]);
1259 // gui->update_preview();
1265 int CWindowMaskDelete::keypress_event()
1267 if(get_keypress() == BACKSPACE ||
1268 get_keypress() == DELETE)
1269 return handle_event();
1274 CWindowMaskCycleNext::CWindowMaskCycleNext(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1275 : BC_GenericButton(x, y, _("Cycle next"))
1277 this->mwindow = mwindow;
1280 int CWindowMaskCycleNext::handle_event()
1286 ((CWindowMaskGUI*)gui)->get_keyframe(track,
1294 // Should apply to all keyframes
1295 if(keyframe && mask->points.total)
1297 temp = mask->points.values[0];
1299 for(int i = 0; i < mask->points.total - 1; i++)
1301 mask->points.values[i] = mask->points.values[i + 1];
1303 mask->points.values[mask->points.total - 1] = temp;
1305 mwindow->cwindow->gui->affected_point--;
1306 if(mwindow->cwindow->gui->affected_point < 0)
1307 mwindow->cwindow->gui->affected_point = mask->points.total - 1;
1310 gui->update_preview();
1316 CWindowMaskCyclePrev::CWindowMaskCyclePrev(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1317 : BC_GenericButton(x, y, _("Cycle prev"))
1319 this->mwindow = mwindow;
1322 int CWindowMaskCyclePrev::handle_event()
1328 ((CWindowMaskGUI*)gui)->get_keyframe(track,
1334 // Should apply to all keyframes
1336 if(keyframe && mask->points.total)
1338 temp = mask->points.values[mask->points.total - 1];
1340 for(int i = mask->points.total - 1; i > 0; i--)
1342 mask->points.values[i] = mask->points.values[i - 1];
1344 mask->points.values[0] = temp;
1346 mwindow->cwindow->gui->affected_point++;
1347 if(mwindow->cwindow->gui->affected_point >= mask->points.total)
1348 mwindow->cwindow->gui->affected_point = 0;
1351 gui->update_preview();
1357 CWindowMaskNumber::CWindowMaskNumber(MWindow *mwindow,
1358 CWindowToolGUI *gui,
1361 : BC_TumbleTextBox(gui,
1362 (int64_t)mwindow->edl->session->cwindow_mask,
1364 (int64_t)SUBMASKS - 1,
1369 this->mwindow = mwindow;
1373 CWindowMaskNumber::~CWindowMaskNumber()
1377 int CWindowMaskNumber::handle_event()
1379 mwindow->edl->session->cwindow_mask = atol(get_text());
1381 gui->update_preview();
1389 CWindowMaskFeather::CWindowMaskFeather(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1390 : BC_TumbleTextBox(gui,
1398 this->mwindow = mwindow;
1401 CWindowMaskFeather::~CWindowMaskFeather()
1404 int CWindowMaskFeather::handle_event()
1410 ((CWindowMaskGUI*)gui)->get_keyframe(track,
1416 keyframe->feather = atof(get_text());
1417 gui->update_preview();
1421 CWindowMaskValue::CWindowMaskValue(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1431 this->mwindow = mwindow;
1435 CWindowMaskValue::~CWindowMaskValue()
1439 int CWindowMaskValue::handle_event()
1445 ((CWindowMaskGUI*)gui)->get_keyframe(track,
1451 keyframe->value = get_value();
1452 gui->update_preview();
1466 CWindowMaskGUI::CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread)
1467 : CWindowToolGUI(mwindow,
1469 PROGRAM_NAME ": Mask",
1473 this->mwindow = mwindow;
1474 this->thread = thread;
1476 CWindowMaskGUI::~CWindowMaskGUI()
1482 void CWindowMaskGUI::create_objects()
1484 //printf("CWindowMaskGUI::create_objects 1\n");
1486 MaskAuto *keyframe = 0;
1487 Track *track = mwindow->cwindow->calculate_affected_track();
1489 keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->mask_autos, 0);
1490 //printf("CWindowMaskGUI::create_objects 1\n");
1493 add_subwindow(title = new BC_Title(x, y, _("Mode:")));
1494 add_subwindow(mode = new CWindowMaskMode(mwindow,
1499 //printf("CWindowMaskGUI::create_objects 1\n");
1500 mode->create_objects();
1502 add_subwindow(new BC_Title(x, y, _("Value:")));
1503 add_subwindow(value = new CWindowMaskValue(mwindow, this, x + 50, y));
1505 add_subwindow(delete_point = new CWindowMaskDelete(mwindow, this, x, y));
1507 // add_subwindow(next_point = new CWindowMaskCycleNext(mwindow, this, x, y));
1509 // add_subwindow(prev_point = new CWindowMaskCyclePrev(mwindow, this, x, y));
1511 add_subwindow(new BC_Title(x, y, _("Mask number:")));
1512 number = new CWindowMaskNumber(mwindow,
1516 //printf("CWindowMaskGUI::create_objects 1\n");
1517 number->create_objects();
1519 add_subwindow(new BC_Title(x, y, _("Feather:")));
1520 feather = new CWindowMaskFeather(mwindow,
1524 feather->create_objects();
1526 add_subwindow(title = new BC_Title(x, y, _("X:")));
1527 x += title->get_w();
1528 this->x = new CWindowCoord(this,
1532 this->x->create_objects();
1534 add_subwindow(title = new BC_Title(x, y, _("Y:")));
1535 x += title->get_w();
1536 this->y = new CWindowCoord(this,
1540 this->y->create_objects();
1541 //printf("CWindowMaskGUI::create_objects 1\n");
1544 if(mwindow->edl->session->tool_window) show_window();
1546 //printf("CWindowMaskGUI::create_objects 2\n");
1549 void CWindowMaskGUI::get_keyframe(Track* &track,
1550 MaskAuto* &keyframe,
1556 track = mwindow->cwindow->calculate_affected_track();
1558 keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->mask_autos, create_it);
1563 mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
1570 if(mwindow->cwindow->gui->affected_point < mask->points.total &&
1571 mwindow->cwindow->gui->affected_point >= 0)
1573 point = mask->points.values[mwindow->cwindow->gui->affected_point];
1578 void CWindowMaskGUI::update()
1584 //printf("CWindowMaskGUI::update 1\n");
1591 //printf("CWindowMaskGUI::update 1\n");
1594 x->update(point->x);
1595 y->update(point->y);
1597 //printf("CWindowMaskGUI::update 1\n");
1601 feather->update((int64_t)keyframe->feather);
1602 value->update((int64_t)keyframe->value);
1604 //printf("CWindowMaskGUI::update 1\n");
1606 number->update((int64_t)mwindow->edl->session->cwindow_mask);
1608 //printf("CWindowMaskGUI::update 1\n");
1612 CWindowMaskMode::mode_to_text(((MaskAuto*)track->automation->mask_autos->default_auto)->mode));
1614 //printf("CWindowMaskGUI::update 2\n");
1617 void CWindowMaskGUI::handle_event()
1631 point->x = atof(x->get_text());
1632 point->y = atof(y->get_text());
1638 void CWindowMaskGUI::update_preview()
1640 mwindow->restart_brender();
1641 mwindow->sync_parameters(CHANGE_PARAMS);
1642 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1646 mwindow->cwindow->gui->lock_window();
1647 mwindow->cwindow->gui->canvas->draw_refresh();
1648 mwindow->cwindow->gui->unlock_window();