4 * Copyright (C) 2008-2014 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "automation.h"
28 #include "condition.h"
30 #include "cplayback.h"
32 #include "cwindowgui.h"
33 #include "cwindowtool.h"
35 #include "edlsession.h"
36 #include "floatauto.h"
37 #include "floatautos.h"
40 #include "localsession.h"
41 #include "mainsession.h"
44 #include "maskautos.h"
47 #include "mwindowgui.h"
50 #include "trackcanvas.h"
51 #include "transportque.h"
54 CWindowTool::CWindowTool(MWindow *mwindow, CWindowGUI *gui)
57 this->mwindow = mwindow;
61 current_tool = CWINDOW_NONE;
63 input_lock = new Condition(0, "CWindowTool::input_lock");
64 output_lock = new Condition(1, "CWindowTool::output_lock");
65 tool_gui_lock = new Mutex("CWindowTool::tool_gui_lock");
68 CWindowTool::~CWindowTool()
79 void CWindowTool::start_tool(int operation)
81 CWindowToolGUI *new_gui = 0;
84 //printf("CWindowTool::start_tool 1\n");
85 if(current_tool != operation)
87 current_tool = operation;
91 new_gui = new CWindowEyedropGUI(mwindow, this);
94 new_gui = new CWindowCropGUI(mwindow, this);
97 new_gui = new CWindowCameraGUI(mwindow, this);
99 case CWINDOW_PROJECTOR:
100 new_gui = new CWindowProjectorGUI(mwindow, this);
103 new_gui = new CWindowMaskGUI(mwindow, this);
106 new_gui = new CWindowRulerGUI(mwindow, this);
114 //printf("CWindowTool::start_tool 1\n");
120 // Wait for previous tool GUI to finish
121 output_lock->lock("CWindowTool::start_tool");
122 this->tool_gui = new_gui;
123 tool_gui->create_objects();
125 if(mwindow->edl->session->tool_window &&
126 mwindow->session->show_cwindow) tool_gui->show_window();
127 tool_gui->lock_window("CWindowTool::start_tool 1");
129 tool_gui->unlock_window();
132 // Signal thread to run next tool GUI
133 input_lock->unlock();
135 //printf("CWindowTool::start_tool 1\n");
140 tool_gui->lock_window("CWindowTool::start_tool");
142 tool_gui->unlock_window();
145 //printf("CWindowTool::start_tool 2\n");
150 void CWindowTool::stop_tool()
154 tool_gui->lock_window("CWindowTool::stop_tool");
155 tool_gui->set_done(0);
156 tool_gui->unlock_window();
160 void CWindowTool::show_tool()
162 if(tool_gui && mwindow->edl->session->tool_window)
164 tool_gui->lock_window("CWindowTool::show_tool");
165 tool_gui->show_window();
166 tool_gui->unlock_window();
170 void CWindowTool::hide_tool()
172 if(tool_gui && mwindow->edl->session->tool_window)
174 tool_gui->lock_window("CWindowTool::show_tool");
175 tool_gui->hide_window();
176 tool_gui->unlock_window();
181 void CWindowTool::run()
185 input_lock->lock("CWindowTool::run");
188 tool_gui->run_window();
189 tool_gui_lock->lock("CWindowTool::run");
192 tool_gui_lock->unlock();
194 output_lock->unlock();
198 void CWindowTool::update_show_window()
202 tool_gui->lock_window("CWindowTool::update_show_window");
204 if(mwindow->edl->session->tool_window)
207 tool_gui->show_window();
210 tool_gui->hide_window();
213 tool_gui->unlock_window();
217 void CWindowTool::raise_window()
221 gui->unlock_window();
222 tool_gui->lock_window("CWindowTool::raise_window");
223 tool_gui->raise_window();
224 tool_gui->unlock_window();
225 gui->lock_window("CWindowTool::raise_window");
229 void CWindowTool::update_values()
231 tool_gui_lock->lock("CWindowTool::update_values");
234 tool_gui->lock_window("CWindowTool::update_values");
237 tool_gui->unlock_window();
239 tool_gui_lock->unlock();
248 CWindowToolGUI::CWindowToolGUI(MWindow *mwindow,
254 mwindow->session->ctool_x,
255 mwindow->session->ctool_y,
264 this->mwindow = mwindow;
265 this->thread = thread;
266 current_operation = 0;
269 CWindowToolGUI::~CWindowToolGUI()
273 int CWindowToolGUI::close_event()
277 mwindow->edl->session->tool_window = 0;
282 thread->gui->lock_window("CWindowToolGUI::close_event");
283 thread->gui->composite_panel->set_operation(mwindow->edl->session->cwindow_operation);
284 thread->gui->flush();
285 thread->gui->unlock_window();
287 lock_window("CWindowToolGUI::close_event");
291 int CWindowToolGUI::keypress_event()
293 if(get_keypress() == 'w' || get_keypress() == 'W')
294 return close_event();
298 int CWindowToolGUI::translation_event()
300 mwindow->session->ctool_x = get_x();
301 mwindow->session->ctool_y = get_y();
310 CWindowCoord::CWindowCoord(CWindowToolGUI *gui, int x, int y, float value, int log_increment = 0)
311 : BC_TumbleTextBox(gui, (float)value, (float)-65536, (float)65536, x, y, 100)
314 set_log_floatincrement(log_increment);
317 CWindowCoord::CWindowCoord(CWindowToolGUI *gui, int x, int y, int value)
318 : BC_TumbleTextBox(gui, (int64_t)value, (int64_t)-65536, (int64_t)65536, x, y, 100)
322 int CWindowCoord::handle_event()
324 gui->event_caller = this;
330 CWindowCropOK::CWindowCropOK(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
331 : BC_GenericButton(x, y, _("Do it"))
333 this->mwindow = mwindow;
336 int CWindowCropOK::handle_event()
338 mwindow->crop_video();
343 int CWindowCropOK::keypress_event()
345 if(get_keypress() == 0xd)
359 CWindowCropGUI::CWindowCropGUI(MWindow *mwindow, CWindowTool *thread)
360 : CWindowToolGUI(mwindow,
362 _(PROGRAM_NAME ": Crop"),
369 CWindowCropGUI::~CWindowCropGUI()
373 void CWindowCropGUI::create_objects()
378 lock_window("CWindowCropGUI::create_objects");
380 int pad = MAX(BC_TextBox::calculate_h(this, MEDIUMFONT, 1, 1),
381 BC_Title::calculate_h(this, "X")) + 5;
382 add_subwindow(title = new BC_Title(x, y, "X1:"));
383 column1 = MAX(column1, title->get_w());
385 add_subwindow(title = new BC_Title(x, y, _("W:")));
386 column1 = MAX(column1, title->get_w());
388 add_subwindow(new CWindowCropOK(mwindow, thread->tool_gui, x, y));
392 x1 = new CWindowCoord(thread->tool_gui, x, y,
393 mwindow->edl->session->crop_x1);
394 x1->create_objects();
396 width = new CWindowCoord(thread->tool_gui, x, y,
397 mwindow->edl->session->crop_x2 - mwindow->edl->session->crop_x1);
398 width->create_objects();
401 x += x1->get_w() + 10;
404 add_subwindow(title = new BC_Title(x, y, "Y1:"));
405 column2 = MAX(column2, title->get_w());
407 add_subwindow(title = new BC_Title(x, y, _("H:")));
408 column2 = MAX(column2, title->get_w());
413 y1 = new CWindowCoord(thread->tool_gui, x, y,
414 mwindow->edl->session->crop_y1);
415 y1->create_objects();
417 height = new CWindowCoord(thread->tool_gui, x, y,
418 mwindow->edl->session->crop_y2 - mwindow->edl->session->crop_y1);
419 height->create_objects();
423 void CWindowCropGUI::handle_event()
426 new_x1 = atol(x1->get_text());
427 new_y1 = atol(y1->get_text());
428 if(new_x1 != mwindow->edl->session->crop_x1)
430 mwindow->edl->session->crop_x2 = new_x1 +
431 mwindow->edl->session->crop_x2 -
432 mwindow->edl->session->crop_x1;
433 mwindow->edl->session->crop_x1 = new_x1;
435 if(new_y1 != mwindow->edl->session->crop_y1)
437 mwindow->edl->session->crop_y2 = new_y1 +
438 mwindow->edl->session->crop_y2 -
439 mwindow->edl->session->crop_y1;
440 mwindow->edl->session->crop_y1 = atol(y1->get_text());
442 mwindow->edl->session->crop_x2 = atol(width->get_text()) +
443 mwindow->edl->session->crop_x1;
444 mwindow->edl->session->crop_y2 = atol(height->get_text()) +
445 mwindow->edl->session->crop_y1;
447 mwindow->cwindow->gui->lock_window("CWindowCropGUI::handle_event");
448 mwindow->cwindow->gui->canvas->draw_refresh();
449 mwindow->cwindow->gui->unlock_window();
452 void CWindowCropGUI::update()
454 x1->update((int64_t)mwindow->edl->session->crop_x1);
455 y1->update((int64_t)mwindow->edl->session->crop_y1);
456 width->update((int64_t)mwindow->edl->session->crop_x2 -
457 mwindow->edl->session->crop_x1);
458 height->update((int64_t)mwindow->edl->session->crop_y2 -
459 mwindow->edl->session->crop_y1);
463 CWindowEyedropGUI::CWindowEyedropGUI(MWindow *mwindow, CWindowTool *thread)
464 : CWindowToolGUI(mwindow,
466 _(PROGRAM_NAME ": Color"),
472 CWindowEyedropGUI::~CWindowEyedropGUI()
476 void CWindowEyedropGUI::create_objects()
478 int margin = mwindow->theme->widget_border;
482 lock_window("CWindowEyedropGUI::create_objects");
483 BC_Title *title1, *title2, *title3, *title4, *title5, *title6, *title7;
484 add_subwindow(title7 = new BC_Title(x, y, _("Radius:")));
485 y += BC_TextBox::calculate_h(this, MEDIUMFONT, 1, 1) + margin;
487 add_subwindow(title1 = new BC_Title(x, y, _("Red:")));
488 y += title1->get_h() + margin;
489 add_subwindow(title2 = new BC_Title(x, y, _("Green:")));
490 y += title2->get_h() + margin;
491 add_subwindow(title3 = new BC_Title(x, y, _("Blue:")));
492 y += title3->get_h() + margin;
494 add_subwindow(title4 = new BC_Title(x, y, "Y:"));
495 y += title4->get_h() + margin;
496 add_subwindow(title5 = new BC_Title(x, y, "U:"));
497 y += title5->get_h() + margin;
498 add_subwindow(title6 = new BC_Title(x, y, "V:"));
501 radius = new CWindowCoord(this, x2, title7->get_y(),
502 mwindow->edl->session->eyedrop_radius);
503 radius->create_objects();
504 radius->set_boundaries((int64_t)0, (int64_t)255);
507 add_subwindow(red = new BC_Title(x2, title1->get_y(), "0"));
508 add_subwindow(green = new BC_Title(x2, title2->get_y(), "0"));
509 add_subwindow(blue = new BC_Title(x2, title3->get_y(), "0"));
511 add_subwindow(this->y = new BC_Title(x2, title4->get_y(), "0"));
512 add_subwindow(this->u = new BC_Title(x2, title5->get_y(), "0"));
513 add_subwindow(this->v = new BC_Title(x2, title6->get_y(), "0"));
515 y = title6->get_y() + this->v->get_h() + margin;
516 add_subwindow(sample = new BC_SubWindow(x, y, 50, 50));
521 void CWindowEyedropGUI::update()
523 radius->update((int64_t)mwindow->edl->session->eyedrop_radius);
525 red->update(mwindow->edl->local_session->red);
526 green->update(mwindow->edl->local_session->green);
527 blue->update(mwindow->edl->local_session->blue);
530 YUV::rgb_to_yuv_f(mwindow->edl->local_session->red,
531 mwindow->edl->local_session->green,
532 mwindow->edl->local_session->blue,
540 int red = (int)(CLIP(mwindow->edl->local_session->red, 0, 1) * 0xff);
541 int green = (int)(CLIP(mwindow->edl->local_session->green, 0, 1) * 0xff);
542 int blue = (int)(CLIP(mwindow->edl->local_session->blue, 0, 1) * 0xff);
543 sample->set_color((red << 16) | (green << 8) | blue);
544 sample->draw_box(0, 0, sample->get_w(), sample->get_h());
545 sample->set_color(BLACK);
546 sample->draw_rectangle(0, 0, sample->get_w(), sample->get_h());
550 void CWindowEyedropGUI::handle_event()
552 int new_radius = atoi(radius->get_text());
553 if(new_radius != mwindow->edl->session->eyedrop_radius)
555 CWindowGUI *gui = mwindow->cwindow->gui;
556 if(gui->eyedrop_visible)
558 gui->lock_window("CWindowEyedropGUI::handle_event");
561 gui->canvas->do_eyedrop(rerender, 0, 1);
564 mwindow->edl->session->eyedrop_radius = new_radius;
566 if(gui->eyedrop_visible)
570 gui->canvas->do_eyedrop(rerender, 0, 1);
571 gui->unlock_window();
578 /* Buttons to control Keyframe-Curve-Mode for Projector or Camera */
580 // Configuration for all possible Keyframe Curve Mode toggles
582 FloatAuto::t_mode mode;
588 const _CVD Camera_Crv_Smooth =
592 N_("\"smooth\" Curve on current Camera Keyframes")
594 const _CVD Camera_Crv_Linear =
598 N_("\"linear\" Curve on current Camera Keyframes")
600 const _CVD Projector_Crv_Smooth =
604 N_("\"smooth\" Curve on current Projector Keyframes")
606 const _CVD Projector_Crv_Linear =
610 N_("\"linear\" Curve on current Projector Keyframes")
613 // Implementation Class für Keyframe Curve Mode buttons
615 // This button reflects the state of the "current" keyframe
616 // (the nearest keyframe on the left) for all three automation
617 // lines together. Clicking on this button (re)sets the curve
618 // mode for the three "current" keyframes simultanously, but
619 // never creates a new keyframe.
621 class CWindowCurveToggle : public BC_Toggle
624 CWindowCurveToggle(_CVD mode, MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
625 void check_toggle_state(FloatAuto *x, FloatAuto *y, FloatAuto *z);
634 CWindowCurveToggle::CWindowCurveToggle(_CVD mode, MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
635 : BC_Toggle(x, y, mwindow->theme->get_image_set(mode.icon_id), false),
639 this->mwindow = mwindow;
640 set_tooltip(_(cfg.tooltip));
643 void CWindowCurveToggle::check_toggle_state(FloatAuto *x, FloatAuto *y, FloatAuto *z)
645 // the toggle state is only set to ON if all
646 // three automation lines have the same curve mode.
647 // For mixed states the toggle stays off.
648 set_value( x->curve_mode == this->cfg.mode &&
649 y->curve_mode == this->cfg.mode &&
650 z->curve_mode == this->cfg.mode
651 ,true // redraw to show new state
655 int CWindowCurveToggle::handle_event()
657 FloatAuto *x=0, *y=0, *z=0;
658 Track *track = mwindow->cwindow->calculate_affected_track();
661 { mwindow->cwindow->calculate_affected_autos(&x, &y, &z,
662 track, cfg.use_camera, 0,0,0); // don't create new keyframe
664 if(x) x->change_curve_mode(cfg.mode);
665 if(y) y->change_curve_mode(cfg.mode);
666 if(z) z->change_curve_mode(cfg.mode);
669 gui->update_preview();
676 CWindowCameraGUI::CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread)
677 : CWindowToolGUI(mwindow,
679 _(PROGRAM_NAME ": Camera"),
684 CWindowCameraGUI::~CWindowCameraGUI()
688 void CWindowCameraGUI::create_objects()
690 int x = 10, y = 10, x1;
691 Track *track = mwindow->cwindow->calculate_affected_track();
692 FloatAuto *x_auto = 0;
693 FloatAuto *y_auto = 0;
694 FloatAuto *z_auto = 0;
698 lock_window("CWindowCameraGUI::create_objects");
701 mwindow->cwindow->calculate_affected_autos(&x_auto,
702 &y_auto, &z_auto, track, 1, 0, 0, 0);
705 add_subwindow(title = new BC_Title(x, y, "X:"));
707 this->x = new CWindowCoord(this, x, y,
708 x_auto ? x_auto->get_value() : (float)0);
709 this->x->create_objects();
714 add_subwindow(title = new BC_Title(x, y, "Y:"));
716 this->y = new CWindowCoord(this, x, y,
717 y_auto ? y_auto->get_value() : (float)0);
718 this->y->create_objects();
721 add_subwindow(title = new BC_Title(x, y, "Z:"));
723 this->z = new CWindowCoord(this, x, y,
724 z_auto ? z_auto->get_value() : (float)1);
725 this->z->create_objects();
726 this->z->set_increment(0.01);
730 add_subwindow(button = new CWindowCameraLeft(mwindow, this, x1, y));
731 x1 += button->get_w();
732 add_subwindow(button = new CWindowCameraCenter(mwindow, this, x1, y));
733 x1 += button->get_w();
734 add_subwindow(button = new CWindowCameraRight(mwindow, this, x1, y));
736 y += button->get_h();
738 add_subwindow(button = new CWindowCameraTop(mwindow, this, x1, y));
739 x1 += button->get_w();
740 add_subwindow(button = new CWindowCameraMiddle(mwindow, this, x1, y));
741 x1 += button->get_w();
742 add_subwindow(button = new CWindowCameraBottom(mwindow, this, x1, y));
743 // additional Buttons to control the curve mode of the "current" keyframe
744 x1 += button->get_w() + 15;
745 add_subwindow(this->t_smooth = new CWindowCurveToggle(Camera_Crv_Smooth, mwindow, this, x1, y));
746 x1 += button->get_w();
747 add_subwindow(this->t_linear = new CWindowCurveToggle(Camera_Crv_Linear, mwindow, this, x1, y));
749 // fill in current auto keyframe values, set toggle states.
754 void CWindowCameraGUI::update_preview()
756 mwindow->restart_brender();
757 mwindow->sync_parameters(CHANGE_PARAMS);
759 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
763 mwindow->gui->lock_window("CWindowCameraGUI::update_preview");
764 mwindow->gui->draw_overlays(1);
765 mwindow->gui->unlock_window();
766 mwindow->cwindow->gui->lock_window("CWindowCameraGUI::update_preview");
767 mwindow->cwindow->gui->canvas->draw_refresh();
768 mwindow->cwindow->gui->unlock_window();
772 void CWindowCameraGUI::handle_event()
774 FloatAuto *x_auto = 0;
775 FloatAuto *y_auto = 0;
776 FloatAuto *z_auto = 0;
777 Track *track = mwindow->cwindow->calculate_affected_track();
780 mwindow->undo->update_undo_before(_("camera"), this);
781 if(event_caller == x)
783 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
784 track->automation->autos[AUTOMATION_CAMERA_X],
788 x_auto->set_value(atof(x->get_text()));
794 if(event_caller == y)
796 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
797 track->automation->autos[AUTOMATION_CAMERA_Y],
801 y_auto->set_value(atof(y->get_text()));
807 if(event_caller == z)
809 z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
810 track->automation->autos[AUTOMATION_CAMERA_Z],
814 float zoom = atof(z->get_text());
815 if(zoom > 100.) zoom = 100.;
817 if(zoom < 0.01) zoom = 0.01;
818 // Doesn't allow user to enter from scratch
819 // if(zoom != atof(z->get_text()))
822 z_auto->set_value(zoom);
823 mwindow->gui->lock_window("CWindowCameraGUI::handle_event");
824 mwindow->gui->draw_overlays(1);
825 mwindow->gui->unlock_window();
831 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
835 void CWindowCameraGUI::update()
837 FloatAuto *x_auto = 0;
838 FloatAuto *y_auto = 0;
839 FloatAuto *z_auto = 0;
840 Track *track = mwindow->cwindow->calculate_affected_track();
844 mwindow->cwindow->calculate_affected_autos(&x_auto,
855 x->update(x_auto->get_value());
857 y->update(y_auto->get_value());
859 float value = z_auto->get_value();
861 thread->gui->composite_panel->cpanel_zoom->update(value);
864 if( x_auto && y_auto && z_auto )
866 t_smooth->check_toggle_state(x_auto, y_auto, z_auto);
867 t_linear->check_toggle_state(x_auto, y_auto, z_auto);
874 CWindowCameraLeft::CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
875 : BC_Button(x, y, mwindow->theme->get_image_set("left_justify"))
878 this->mwindow = mwindow;
879 set_tooltip(_("Left justify"));
881 int CWindowCameraLeft::handle_event()
883 FloatAuto *x_auto = 0;
884 FloatAuto *z_auto = 0;
885 Track *track = mwindow->cwindow->calculate_affected_track();
888 mwindow->cwindow->calculate_affected_autos(&x_auto,
901 track->get_source_dimensions(
902 mwindow->edl->local_session->get_selectionstart(1),
908 mwindow->undo->update_undo_before(_("camera"), 0);
910 (double)track->track_w / z_auto->get_value() / 2 -
912 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
914 gui->update_preview();
922 CWindowCameraCenter::CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
923 : BC_Button(x, y, mwindow->theme->get_image_set("center_justify"))
926 this->mwindow = mwindow;
927 set_tooltip(_("Center horizontal"));
929 int CWindowCameraCenter::handle_event()
931 FloatAuto *x_auto = 0;
932 Track *track = mwindow->cwindow->calculate_affected_track();
934 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
935 track->automation->autos[AUTOMATION_CAMERA_X],
940 mwindow->undo->update_undo_before(_("camera"), 0);
941 x_auto->set_value(0);
943 gui->update_preview();
944 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
951 CWindowCameraRight::CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
952 : BC_Button(x, y, mwindow->theme->get_image_set("right_justify"))
955 this->mwindow = mwindow;
956 set_tooltip(_("Right justify"));
958 int CWindowCameraRight::handle_event()
960 FloatAuto *x_auto = 0;
961 FloatAuto *z_auto = 0;
962 Track *track = mwindow->cwindow->calculate_affected_track();
965 mwindow->cwindow->calculate_affected_autos(&x_auto,
978 track->get_source_dimensions(
979 mwindow->edl->local_session->get_selectionstart(1),
985 mwindow->undo->update_undo_before(_("camera"), 0);
986 x_auto->set_value( -((double)track->track_w / z_auto->get_value() / 2 -
989 gui->update_preview();
990 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
998 CWindowCameraTop::CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
999 : BC_Button(x, y, mwindow->theme->get_image_set("top_justify"))
1002 this->mwindow = mwindow;
1003 set_tooltip(_("Top justify"));
1005 int CWindowCameraTop::handle_event()
1007 FloatAuto *y_auto = 0;
1008 FloatAuto *z_auto = 0;
1009 Track *track = mwindow->cwindow->calculate_affected_track();
1012 mwindow->cwindow->calculate_affected_autos(0,
1022 if(y_auto && z_auto)
1025 track->get_source_dimensions(
1026 mwindow->edl->local_session->get_selectionstart(1),
1032 mwindow->undo->update_undo_before(_("camera"), 0);
1033 y_auto->set_value((double)track->track_h / z_auto->get_value() / 2 -
1036 gui->update_preview();
1037 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1045 CWindowCameraMiddle::CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1046 : BC_Button(x, y, mwindow->theme->get_image_set("middle_justify"))
1049 this->mwindow = mwindow;
1050 set_tooltip(_("Center vertical"));
1052 int CWindowCameraMiddle::handle_event()
1054 FloatAuto *y_auto = 0;
1055 Track *track = mwindow->cwindow->calculate_affected_track();
1057 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1058 track->automation->autos[AUTOMATION_CAMERA_Y], 1);
1062 mwindow->undo->update_undo_before(_("camera"), 0);
1063 y_auto->set_value(0);
1065 gui->update_preview();
1066 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1073 CWindowCameraBottom::CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1074 : BC_Button(x, y, mwindow->theme->get_image_set("bottom_justify"))
1077 this->mwindow = mwindow;
1078 set_tooltip(_("Bottom justify"));
1080 int CWindowCameraBottom::handle_event()
1082 FloatAuto *y_auto = 0;
1083 FloatAuto *z_auto = 0;
1084 Track *track = mwindow->cwindow->calculate_affected_track();
1087 mwindow->cwindow->calculate_affected_autos(0,
1097 if(y_auto && z_auto)
1100 track->get_source_dimensions(
1101 mwindow->edl->local_session->get_selectionstart(1),
1107 mwindow->undo->update_undo_before(_("camera"), 0);
1108 y_auto->set_value(-((double)track->track_h / z_auto->get_value() / 2 -
1111 gui->update_preview();
1112 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1120 CWindowProjectorGUI::CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread)
1121 : CWindowToolGUI(mwindow,
1123 _(PROGRAM_NAME ": Projector"),
1128 CWindowProjectorGUI::~CWindowProjectorGUI()
1131 void CWindowProjectorGUI::create_objects()
1133 int x = 10, y = 10, x1;
1134 Track *track = mwindow->cwindow->calculate_affected_track();
1135 FloatAuto *x_auto = 0;
1136 FloatAuto *y_auto = 0;
1137 FloatAuto *z_auto = 0;
1141 lock_window("CWindowProjectorGUI::create_objects");
1144 mwindow->cwindow->calculate_affected_autos(&x_auto,
1154 add_subwindow(title = new BC_Title(x, y, "X:"));
1155 x += title->get_w();
1156 this->x = new CWindowCoord(this, x, y,
1157 x_auto ? x_auto->get_value() : (float)0);
1158 this->x->create_objects();
1161 add_subwindow(title = new BC_Title(x, y, "Y:"));
1162 x += title->get_w();
1163 this->y = new CWindowCoord(this, x, y,
1164 y_auto ? y_auto->get_value() : (float)0);
1165 this->y->create_objects();
1168 add_subwindow(title = new BC_Title(x, y, "Z:"));
1169 x += title->get_w();
1170 this->z = new CWindowCoord(this, x, y,
1171 z_auto ? z_auto->get_value() : (float)1);
1172 this->z->create_objects();
1173 this->z->set_increment(0.01);
1177 add_subwindow(button = new CWindowProjectorLeft(mwindow, this, x1, y));
1178 x1 += button->get_w();
1179 add_subwindow(button = new CWindowProjectorCenter(mwindow, this, x1, y));
1180 x1 += button->get_w();
1181 add_subwindow(button = new CWindowProjectorRight(mwindow, this, x1, y));
1183 y += button->get_h();
1185 add_subwindow(button = new CWindowProjectorTop(mwindow, this, x1, y));
1186 x1 += button->get_w();
1187 add_subwindow(button = new CWindowProjectorMiddle(mwindow, this, x1, y));
1188 x1 += button->get_w();
1189 add_subwindow(button = new CWindowProjectorBottom(mwindow, this, x1, y));
1191 // additional Buttons to control the curve mode of the "current" keyframe
1192 x1 += button->get_w() + 15;
1193 add_subwindow(this->t_smooth = new CWindowCurveToggle(Projector_Crv_Smooth, mwindow, this, x1, y));
1194 x1 += button->get_w();
1195 add_subwindow(this->t_linear = new CWindowCurveToggle(Projector_Crv_Linear, mwindow, this, x1, y));
1197 // fill in current auto keyframe values, set toggle states.
1202 void CWindowProjectorGUI::update_preview()
1204 mwindow->restart_brender();
1205 mwindow->sync_parameters(CHANGE_PARAMS);
1206 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1210 // TODO: really need to lock the main window??
1211 mwindow->gui->lock_window("CWindowProjectorGUI::update_preview");
1212 mwindow->gui->draw_overlays(1);
1213 mwindow->gui->unlock_window();
1214 mwindow->cwindow->gui->lock_window("CWindowProjectorGUI::update_preview");
1215 mwindow->cwindow->gui->canvas->draw_refresh();
1216 mwindow->cwindow->gui->unlock_window();
1219 void CWindowProjectorGUI::handle_event()
1221 FloatAuto *x_auto = 0;
1222 FloatAuto *y_auto = 0;
1223 FloatAuto *z_auto = 0;
1224 Track *track = mwindow->cwindow->calculate_affected_track();
1228 mwindow->undo->update_undo_before(_("projector"), this);
1229 if(event_caller == x)
1231 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1232 track->automation->autos[AUTOMATION_PROJECTOR_X],
1236 x_auto->set_value(atof(x->get_text()));
1242 if(event_caller == y)
1244 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1245 track->automation->autos[AUTOMATION_PROJECTOR_Y],
1249 y_auto->set_value(atof(y->get_text()));
1255 if(event_caller == z)
1257 z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1258 track->automation->autos[AUTOMATION_PROJECTOR_Z],
1262 float zoom = atof(z->get_text());
1263 if(zoom > 100.) zoom = 100.;
1264 else if(zoom < 0.01) zoom = 0.01;
1265 // if (zoom != atof(z->get_text()))
1267 z_auto->set_value(zoom);
1269 mwindow->gui->lock_window("CWindowProjectorGUI::handle_event");
1270 mwindow->gui->draw_overlays(1);
1271 mwindow->gui->unlock_window();
1277 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1281 void CWindowProjectorGUI::update()
1283 FloatAuto *x_auto = 0;
1284 FloatAuto *y_auto = 0;
1285 FloatAuto *z_auto = 0;
1286 Track *track = mwindow->cwindow->calculate_affected_track();
1290 mwindow->cwindow->calculate_affected_autos(&x_auto,
1301 x->update(x_auto->get_value());
1303 y->update(y_auto->get_value());
1305 float value = z_auto->get_value();
1307 thread->gui->composite_panel->cpanel_zoom->update(value);
1310 if( x_auto && y_auto && z_auto )
1312 t_smooth->check_toggle_state(x_auto, y_auto, z_auto);
1313 t_linear->check_toggle_state(x_auto, y_auto, z_auto);
1317 CWindowProjectorLeft::CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1318 : BC_Button(x, y, mwindow->theme->get_image_set("left_justify"))
1321 this->mwindow = mwindow;
1322 set_tooltip(_("Left justify"));
1324 int CWindowProjectorLeft::handle_event()
1326 FloatAuto *x_auto = 0;
1327 FloatAuto *z_auto = 0;
1328 Track *track = mwindow->cwindow->calculate_affected_track();
1331 mwindow->cwindow->calculate_affected_autos(&x_auto,
1340 if(x_auto && z_auto)
1342 mwindow->undo->update_undo_before(_("projector"), 0);
1343 x_auto->set_value( (double)track->track_w * z_auto->get_value() / 2 -
1344 (double)mwindow->edl->session->output_w / 2 );
1346 gui->update_preview();
1347 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1354 CWindowProjectorCenter::CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1355 : BC_Button(x, y, mwindow->theme->get_image_set("center_justify"))
1358 this->mwindow = mwindow;
1359 set_tooltip(_("Center horizontal"));
1361 int CWindowProjectorCenter::handle_event()
1363 FloatAuto *x_auto = 0;
1364 Track *track = mwindow->cwindow->calculate_affected_track();
1366 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1367 track->automation->autos[AUTOMATION_PROJECTOR_X],
1372 mwindow->undo->update_undo_before(_("projector"), 0);
1373 x_auto->set_value(0);
1375 gui->update_preview();
1376 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1383 CWindowProjectorRight::CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1384 : BC_Button(x, y, mwindow->theme->get_image_set("right_justify"))
1387 this->mwindow = mwindow;
1388 set_tooltip(_("Right justify"));
1390 int CWindowProjectorRight::handle_event()
1392 FloatAuto *x_auto = 0;
1393 FloatAuto *z_auto = 0;
1394 Track *track = mwindow->cwindow->calculate_affected_track();
1397 mwindow->cwindow->calculate_affected_autos(&x_auto,
1407 if(x_auto && z_auto)
1409 mwindow->undo->update_undo_before(_("projector"), 0);
1410 x_auto->set_value( -((double)track->track_w * z_auto->get_value() / 2 -
1411 (double)mwindow->edl->session->output_w / 2));
1413 gui->update_preview();
1414 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1421 CWindowProjectorTop::CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1422 : BC_Button(x, y, mwindow->theme->get_image_set("top_justify"))
1425 this->mwindow = mwindow;
1426 set_tooltip(_("Top justify"));
1428 int CWindowProjectorTop::handle_event()
1430 FloatAuto *y_auto = 0;
1431 FloatAuto *z_auto = 0;
1432 Track *track = mwindow->cwindow->calculate_affected_track();
1435 mwindow->cwindow->calculate_affected_autos(0,
1445 if(y_auto && z_auto)
1447 mwindow->undo->update_undo_before(_("projector"), 0);
1448 y_auto->set_value( (double)track->track_h * z_auto->get_value() / 2 -
1449 (double)mwindow->edl->session->output_h / 2 );
1451 gui->update_preview();
1452 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1459 CWindowProjectorMiddle::CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1460 : BC_Button(x, y, mwindow->theme->get_image_set("middle_justify"))
1463 this->mwindow = mwindow;
1464 set_tooltip(_("Center vertical"));
1466 int CWindowProjectorMiddle::handle_event()
1468 FloatAuto *y_auto = 0;
1469 Track *track = mwindow->cwindow->calculate_affected_track();
1471 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1472 track->automation->autos[AUTOMATION_PROJECTOR_Y], 1);
1476 mwindow->undo->update_undo_before(_("projector"), 0);
1477 y_auto->set_value(0);
1479 gui->update_preview();
1480 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1487 CWindowProjectorBottom::CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1488 : BC_Button(x, y, mwindow->theme->get_image_set("bottom_justify"))
1491 this->mwindow = mwindow;
1492 set_tooltip(_("Bottom justify"));
1494 int CWindowProjectorBottom::handle_event()
1496 FloatAuto *y_auto = 0;
1497 FloatAuto *z_auto = 0;
1498 Track *track = mwindow->cwindow->calculate_affected_track();
1501 mwindow->cwindow->calculate_affected_autos(0,
1511 if(y_auto && z_auto)
1513 mwindow->undo->update_undo_before(_("projector"), 0);
1514 y_auto->set_value( -((double)track->track_h * z_auto->get_value() / 2 -
1515 (double)mwindow->edl->session->output_h / 2));
1517 gui->update_preview();
1518 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1525 CWindowMaskMode::CWindowMaskMode(MWindow *mwindow,
1526 CWindowToolGUI *gui, int x, int y, const char *text)
1527 : BC_PopupMenu(x, y, 220, text, 1)
1529 this->mwindow = mwindow;
1533 void CWindowMaskMode::create_objects()
1535 add_item(new BC_MenuItem(mode_to_text(MASK_MULTIPLY_ALPHA)));
1536 add_item(new BC_MenuItem(mode_to_text(MASK_SUBTRACT_ALPHA)));
1539 char* CWindowMaskMode::mode_to_text(int mode)
1543 case MASK_MULTIPLY_ALPHA:
1544 return _("Multiply alpha");
1547 case MASK_SUBTRACT_ALPHA:
1548 return _("Subtract alpha");
1552 return _("Subtract alpha");
1555 int CWindowMaskMode::text_to_mode(char *text)
1557 if(!strcasecmp(text, _("Multiply alpha")))
1558 return MASK_MULTIPLY_ALPHA;
1560 if(!strcasecmp(text, _("Subtract alpha")))
1561 return MASK_SUBTRACT_ALPHA;
1563 return MASK_SUBTRACT_ALPHA;
1566 int CWindowMaskMode::handle_event()
1573 // Get existing keyframe
1574 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1577 mwindow->undo->update_undo_before(_("mask mode"), 0);
1578 #ifdef USE_KEYFRAME_SPANNING
1579 // Create temp keyframe
1580 MaskAuto temp_keyframe(mwindow->edl, autos);
1581 temp_keyframe.copy_data(keyframe);
1583 temp_keyframe.mode = text_to_mode(get_text());
1584 // Commit change to span of keyframes
1585 autos->update_parameter(&temp_keyframe);
1587 ((MaskAuto*)autos->default_auto)->mode =
1588 text_to_mode(get_text());
1590 mwindow->undo->update_undo_after(_("mask mode"), LOAD_AUTOMATION);
1593 //printf("CWindowMaskMode::handle_event 1\n");
1594 gui->update_preview();
1605 CWindowMaskDelete::CWindowMaskDelete(MWindow *mwindow,
1606 CWindowToolGUI *gui,
1609 : BC_GenericButton(x, y, _("Delete"))
1611 this->mwindow = mwindow;
1615 int CWindowMaskDelete::handle_event()
1622 int total_points = 0;
1624 // Get existing keyframe
1625 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1629 mwindow->undo->update_undo_before(_("mask delete"), 0);
1631 #ifdef USE_KEYFRAME_SPANNING
1632 // Create temp keyframe
1633 MaskAuto temp_keyframe(mwindow->edl, autos);
1634 temp_keyframe.copy_data(keyframe);
1636 SubMask *submask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
1637 for(int i = mwindow->cwindow->gui->affected_point;
1638 i < submask->points.total - 1;
1641 *submask->points.values[i] = *submask->points.values[i + 1];
1644 if(submask->points.total)
1646 submask->points.remove_object(
1647 submask->points.values[submask->points.total - 1]);
1649 total_points = submask->points.total;
1651 // Commit change to span of keyframes
1652 ((MaskAutos*)track->automation->autos[AUTOMATION_MASK])->update_parameter(&temp_keyframe);
1654 for(MaskAuto *current = (MaskAuto*)autos->default_auto;
1657 SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
1659 for(int i = mwindow->cwindow->gui->affected_point;
1660 i < submask->points.total - 1;
1663 *submask->points.values[i] = *submask->points.values[i + 1];
1666 if(submask->points.total)
1668 submask->points.remove_object(
1669 submask->points.values[submask->points.total - 1]);
1671 total_points = submask->points.total;
1673 if(current == (MaskAuto*)autos->default_auto)
1674 current = (MaskAuto*)autos->first;
1676 current = (MaskAuto*)NEXT;
1679 if( mwindow->cwindow->gui->affected_point >= total_points )
1680 mwindow->cwindow->gui->affected_point =
1681 total_points > 0 ? total_points-1 : 0;
1684 gui->update_preview();
1685 mwindow->undo->update_undo_after(_("mask delete"), LOAD_AUTOMATION);
1692 int CWindowMaskDelete::keypress_event()
1694 if(get_keypress() == BACKSPACE ||
1695 get_keypress() == DELETE)
1696 return handle_event();
1701 // CWindowMaskCycleNext::CWindowMaskCycleNext(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1702 // : BC_GenericButton(x, y, _("Cycle next"))
1704 // this->mwindow = mwindow;
1707 // int CWindowMaskCycleNext::handle_event()
1709 // MaskAuto *keyframe;
1710 // MaskAutos *autos;
1712 // MaskPoint *point;
1714 // ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1718 // // Should apply to all keyframes
1719 // if(keyframe && mask->points.total)
1721 // temp = mask->points.values[0];
1723 // for(int i = 0; i < mask->points.total - 1; i++)
1725 // mask->points.values[i] = mask->points.values[i + 1];
1727 // mask->points.values[mask->points.total - 1] = temp;
1729 // mwindow->cwindow->gui->affected_point--;
1730 // if(mwindow->cwindow->gui->affected_point < 0)
1731 // mwindow->cwindow->gui->affected_point = mask->points.total - 1;
1734 // gui->update_preview();
1740 // CWindowMaskCyclePrev::CWindowMaskCyclePrev(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1741 // : BC_GenericButton(x, y, _("Cycle prev"))
1743 // this->mwindow = mwindow;
1746 // int CWindowMaskCyclePrev::handle_event()
1748 // MaskAuto *keyframe;
1749 // MaskAutos *autos;
1751 // MaskPoint *point;
1753 // ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1755 // // Should apply to all keyframes
1757 // if(keyframe && mask->points.total)
1759 // temp = mask->points.values[mask->points.total - 1];
1761 // for(int i = mask->points.total - 1; i > 0; i--)
1763 // mask->points.values[i] = mask->points.values[i - 1];
1765 // mask->points.values[0] = temp;
1767 // mwindow->cwindow->gui->affected_point++;
1768 // if(mwindow->cwindow->gui->affected_point >= mask->points.total)
1769 // mwindow->cwindow->gui->affected_point = 0;
1772 // gui->update_preview();
1778 CWindowMaskNumber::CWindowMaskNumber(MWindow *mwindow,
1779 CWindowToolGUI *gui,
1782 : BC_TumbleTextBox(gui,
1783 (int64_t)mwindow->edl->session->cwindow_mask,
1785 (int64_t)SUBMASKS - 1,
1790 this->mwindow = mwindow;
1794 CWindowMaskNumber::~CWindowMaskNumber()
1798 int CWindowMaskNumber::handle_event()
1800 mwindow->edl->session->cwindow_mask = atol(get_text());
1802 gui->update_preview();
1807 CWindowMaskAffectedPoint::CWindowMaskAffectedPoint(MWindow *mwindow,
1808 CWindowToolGUI *gui, int x, int y)
1809 : BC_TumbleTextBox(gui,
1810 (int64_t)mwindow->cwindow->gui->affected_point,
1811 (int64_t)0, INT64_MAX, x, y, 100)
1813 this->mwindow = mwindow;
1817 CWindowMaskAffectedPoint::~CWindowMaskAffectedPoint()
1821 int CWindowMaskAffectedPoint::handle_event()
1823 int total_points = 0;
1824 int affected_point = atol(get_text());
1825 Track *track = mwindow->cwindow->calculate_affected_track();
1827 MaskAutos *autos = (MaskAutos*)track->automation->autos[AUTOMATION_MASK];
1828 MaskAuto *keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(autos, 0);
1830 SubMask *mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
1831 total_points = mask->points.size();
1834 int active_point = affected_point;
1835 if( affected_point >= total_points )
1836 affected_point = total_points - 1;
1837 else if( affected_point < 0 )
1839 if( active_point != affected_point )
1840 update((int64_t)affected_point);
1841 mwindow->cwindow->gui->affected_point = affected_point;
1843 gui->update_preview();
1851 CWindowMaskFeather::CWindowMaskFeather(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1852 : BC_TumbleTextBox(gui,
1860 this->mwindow = mwindow;
1863 CWindowMaskFeather::~CWindowMaskFeather()
1866 int CWindowMaskFeather::handle_event()
1873 #ifdef USE_KEYFRAME_SPANNING
1879 mwindow->undo->update_undo_before(_("mask feather"), this);
1881 // Get existing keyframe
1882 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe,
1883 mask, point, create_it);
1887 #ifdef USE_KEYFRAME_SPANNING
1888 // Create temp keyframe
1889 MaskAuto temp_keyframe(mwindow->edl, autos);
1890 temp_keyframe.copy_data(keyframe);
1892 temp_keyframe.feather = atof(get_text());
1893 // Commit change to span of keyframes
1894 autos->update_parameter(&temp_keyframe);
1896 keyframe->feather = atof(get_text());
1899 gui->update_preview();
1902 mwindow->undo->update_undo_after(_("mask feather"), LOAD_AUTOMATION);
1907 CWindowMaskValue::CWindowMaskValue(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1917 this->mwindow = mwindow;
1921 CWindowMaskValue::~CWindowMaskValue()
1925 int CWindowMaskValue::handle_event()
1932 #ifdef USE_KEYFRAME_SPANNING
1938 mwindow->undo->update_undo_before(_("mask value"), this);
1939 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe,
1940 mask, point, create_it);
1944 #ifdef USE_KEYFRAME_SPANNING
1945 // Create temp keyframe
1946 MaskAuto temp_keyframe(mwindow->edl, autos);
1947 temp_keyframe.copy_data(keyframe);
1949 temp_keyframe.value = get_value();
1950 // Commit change to span of keyframes
1951 autos->update_parameter(&temp_keyframe);
1953 keyframe->value = get_value();
1957 gui->update_preview();
1958 mwindow->undo->update_undo_after(_("mask value"), LOAD_AUTOMATION);
1963 CWindowMaskBeforePlugins::CWindowMaskBeforePlugins(CWindowToolGUI *gui, int x, int y)
1967 _("Apply mask before plugins"))
1972 int CWindowMaskBeforePlugins::handle_event()
1979 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 1);
1982 keyframe->apply_before_plugins = get_value();
1983 gui->update_preview();
1989 CWindowDisableOpenGLMasking::CWindowDisableOpenGLMasking(CWindowToolGUI *gui, int x, int y)
1990 : BC_CheckBox(x, y, 1, _("Disable OpenGL masking"))
1995 int CWindowDisableOpenGLMasking::handle_event()
2002 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 1);
2005 keyframe->disable_opengl_masking = get_value();
2006 gui->update_preview();
2019 CWindowMaskGUI::CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread)
2020 : CWindowToolGUI(mwindow,
2022 _(PROGRAM_NAME ": Mask"),
2026 this->mwindow = mwindow;
2027 this->thread = thread;
2032 CWindowMaskGUI::~CWindowMaskGUI()
2034 lock_window("CWindowMaskGUI::~CWindowMaskGUI");
2036 delete active_point;
2041 void CWindowMaskGUI::create_objects()
2043 int x = 10, y = 10, margin = mwindow->theme->widget_border;
2044 //MaskAuto *keyframe = 0;
2045 //Track *track = mwindow->cwindow->calculate_affected_track();
2047 // keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->autos[AUTOMATION_MASK], 0);
2049 lock_window("CWindowMaskGUI::create_objects");
2051 add_subwindow(title = new BC_Title(x, y, _("Mode:")));
2052 add_subwindow(mode = new CWindowMaskMode(mwindow,
2053 this, x + title->get_w() + margin, y, ""));
2054 mode->create_objects();
2055 y += mode->get_h() + margin;
2056 add_subwindow(title = new BC_Title(x, y, _("Value:")));
2057 add_subwindow(value = new CWindowMaskValue(mwindow, this, x + title->get_w() + margin, y));
2058 y += value->get_h() + margin;
2059 add_subwindow(delete_point = new CWindowMaskDelete(mwindow, this, x, y));
2060 int x1 = x + delete_point->get_w() + 2*margin;
2061 add_subwindow(title = new BC_Title(x1, y, _("Point:")));
2062 x1 += title->get_w() + margin;
2063 active_point = new CWindowMaskAffectedPoint(mwindow, this, x1, y);
2064 active_point->create_objects();
2065 y += delete_point->get_h() + margin;
2066 add_subwindow(title = new BC_Title(x, y, _("Mask number:")));
2067 number = new CWindowMaskNumber(mwindow,
2068 this, x + title->get_w() + margin, y);
2069 number->create_objects();
2070 y += number->get_h() + margin;
2071 add_subwindow(title = new BC_Title(x, y, _("Feather:")));
2072 feather = new CWindowMaskFeather(mwindow,
2073 this, x + title->get_w() + margin, y);
2074 feather->create_objects();
2075 y += feather->get_h() + margin;
2076 add_subwindow(title = new BC_Title(x, y, "X:"));
2077 x += title->get_w() + margin;
2078 this->x = new CWindowCoord(this, x, y, (float)0.0);
2079 this->x->create_objects();
2080 x += this->x->get_w() + margin;
2081 add_subwindow(title = new BC_Title(x, y, "Y:"));
2082 x += title->get_w() + margin;
2083 this->y = new CWindowCoord(this, x, y, (float)0.0);
2084 this->y->create_objects();
2087 y += this->y->get_h() + margin;
2088 add_subwindow(title = new BC_Title(x, y, _("Press Shift to move an end point")));
2089 y += title->get_h() + margin;
2090 add_subwindow(title = new BC_Title(x, y, _("Press Ctrl to move a control point")));
2091 y += title->get_h() + margin;
2092 add_subwindow(title = new BC_Title(x, y, _("Press Alt to translate the mask")));
2095 add_subwindow(this->apply_before_plugins = new CWindowMaskBeforePlugins(this, 10, y));
2096 y += this->apply_before_plugins->get_h() + margin;
2097 add_subwindow(this->disable_opengl_masking = new CWindowDisableOpenGLMasking(this, 10, y));
2103 void CWindowMaskGUI::get_keyframe(Track* &track,
2105 MaskAuto* &keyframe,
2113 track = mwindow->cwindow->calculate_affected_track();
2116 autos = (MaskAutos*)track->automation->autos[AUTOMATION_MASK];
2117 keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(
2123 mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
2130 if(mwindow->cwindow->gui->affected_point < mask->points.total &&
2131 mwindow->cwindow->gui->affected_point >= 0)
2133 point = mask->points.values[mwindow->cwindow->gui->affected_point];
2138 void CWindowMaskGUI::update()
2145 //printf("CWindowMaskGUI::update 1\n");
2146 get_keyframe(track, autos, keyframe, mask, point, 0);
2148 double position = mwindow->edl->local_session->get_selectionstart(1);
2149 position = mwindow->edl->align_to_frame(position, 0);
2152 int64_t position_i = track->to_units(position, 0);
2156 x->update(point->x);
2157 y->update(point->y);
2162 feather->update((int64_t)autos->get_feather(position_i, PLAY_FORWARD));
2163 value->update((int64_t)autos->get_value(position_i, PLAY_FORWARD));
2164 apply_before_plugins->update((int64_t)keyframe->apply_before_plugins);
2165 disable_opengl_masking->update((int64_t)keyframe->disable_opengl_masking);
2169 //printf("CWindowMaskGUI::update 1\n");
2170 active_point->update((int64_t)mwindow->cwindow->gui->affected_point);
2171 number->update((int64_t)mwindow->edl->session->cwindow_mask);
2173 //printf("CWindowMaskGUI::update 1\n");
2176 #ifdef USE_KEYFRAME_SPANNING
2178 CWindowMaskMode::mode_to_text(keyframe->mode));
2181 CWindowMaskMode::mode_to_text(((MaskAuto*)autos->default_auto)->mode));
2184 //printf("CWindowMaskGUI::update 2\n");
2187 void CWindowMaskGUI::handle_event()
2194 get_keyframe(track, autos, keyframe, mask, point, 0);
2196 mwindow->undo->update_undo_before(_("mask point"), this);
2200 #ifdef USE_KEYFRAME_SPANNING
2201 // Create temp keyframe
2202 MaskAuto temp_keyframe(mwindow->edl, autos);
2203 temp_keyframe.copy_data(keyframe);
2204 // Get affected point in temp keyframe
2205 mask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
2206 if(mwindow->cwindow->gui->affected_point < mask->points.total &&
2207 mwindow->cwindow->gui->affected_point >= 0)
2209 point = mask->points.values[mwindow->cwindow->gui->affected_point];
2214 point->x = atof(x->get_text());
2215 point->y = atof(y->get_text());
2216 // Commit to spanned keyframes
2217 autos->update_parameter(&temp_keyframe);
2220 point->x = atof(x->get_text());
2221 point->y = atof(y->get_text());
2226 mwindow->undo->update_undo_after(_("mask point"), LOAD_AUTOMATION);
2229 void CWindowMaskGUI::update_preview()
2231 mwindow->restart_brender();
2232 mwindow->sync_parameters(CHANGE_PARAMS);
2233 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
2237 mwindow->cwindow->gui->lock_window("CWindowMaskGUI::update_preview");
2238 mwindow->cwindow->gui->canvas->draw_refresh();
2239 mwindow->cwindow->gui->unlock_window();
2243 CWindowRulerGUI::CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread)
2244 : CWindowToolGUI(mwindow,
2246 _(PROGRAM_NAME ": Ruler"),
2252 CWindowRulerGUI::~CWindowRulerGUI()
2256 void CWindowRulerGUI::create_objects()
2261 lock_window("CWindowRulerGUI::create_objects");
2262 add_subwindow(title = new BC_Title(x, y, _("Current:")));
2263 add_subwindow(current = new BC_Title(x + title->get_w() + 10, y, ""));
2264 y += title->get_h() + 5;
2266 add_subwindow(title = new BC_Title(x, y, _("Point 1:")));
2267 add_subwindow(point1 = new BC_Title(x + title->get_w() + 10, y, ""));
2268 y += title->get_h() + 5;
2270 add_subwindow(title = new BC_Title(x, y, _("Point 2:")));
2271 add_subwindow(point2 = new BC_Title(x + title->get_w() + 10, y, ""));
2272 y += title->get_h() + 5;
2274 add_subwindow(title = new BC_Title(x, y, _("Distance:")));
2275 add_subwindow(distance = new BC_Title(x + title->get_w() + 10, y, ""));
2276 y += title->get_h() + 5;
2277 add_subwindow(title = new BC_Title(x, y, _("Angle:")));
2278 add_subwindow(angle = new BC_Title(x + title->get_w() + 10, y, ""));
2279 y += title->get_h() + 10;
2280 char string[BCTEXTLEN];
2281 sprintf(string, _("Press Ctrl to lock ruler to the\nnearest 45%c angle."), 0xb0);
2282 add_subwindow(title = new BC_Title(x,
2285 y += title->get_h() + 10;
2286 sprintf(string, _("Press Alt to translate the ruler."));
2287 add_subwindow(title = new BC_Title(x,
2294 void CWindowRulerGUI::update()
2296 double distance_value =
2297 sqrt(SQR(mwindow->edl->session->ruler_x2 - mwindow->edl->session->ruler_x1) +
2298 SQR(mwindow->edl->session->ruler_y2 - mwindow->edl->session->ruler_y1));
2299 double angle_value = atan((mwindow->edl->session->ruler_y2 - mwindow->edl->session->ruler_y1) /
2300 (mwindow->edl->session->ruler_x2 - mwindow->edl->session->ruler_x1)) *
2305 if(EQUIV(distance_value, 0.0))
2315 char string[BCTEXTLEN];
2316 sprintf(string, "%d, %d",
2317 mwindow->session->cwindow_output_x,
2318 mwindow->session->cwindow_output_y);
2319 current->update(string);
2320 sprintf(string, "%.0f, %.0f",
2321 mwindow->edl->session->ruler_x1,
2322 mwindow->edl->session->ruler_y1);
2323 point1->update(string);
2324 sprintf(string, "%.0f, %.0f",
2325 mwindow->edl->session->ruler_x2,
2326 mwindow->edl->session->ruler_y2);
2327 point2->update(string);
2329 sprintf(string, _("%0.01f pixels"), distance_value);
2330 distance->update(string);
2331 sprintf(string, "%0.02f %c", angle_value, 0xb0);
2332 angle->update(string);
2335 void CWindowRulerGUI::handle_event()