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 *title0, *title1, *title2, *title3, *title4, *title5, *title6, *title7;
484 add_subwindow(title0 = new BC_Title(x, y,_("X,Y:")));
485 y += title0->get_h() + margin;
486 add_subwindow(title7 = new BC_Title(x, y, _("Radius:")));
487 y += BC_TextBox::calculate_h(this, MEDIUMFONT, 1, 1) + margin;
489 add_subwindow(title1 = new BC_Title(x, y, _("Red:")));
490 y += title1->get_h() + margin;
491 add_subwindow(title2 = new BC_Title(x, y, _("Green:")));
492 y += title2->get_h() + margin;
493 add_subwindow(title3 = new BC_Title(x, y, _("Blue:")));
494 y += title3->get_h() + margin;
496 add_subwindow(title4 = new BC_Title(x, y, "Y:"));
497 y += title4->get_h() + margin;
498 add_subwindow(title5 = new BC_Title(x, y, "U:"));
499 y += title5->get_h() + margin;
500 add_subwindow(title6 = new BC_Title(x, y, "V:"));
502 add_subwindow(current = new BC_Title(x2, title0->get_y(), ""));
504 radius = new CWindowCoord(this, x2, title7->get_y(),
505 mwindow->edl->session->eyedrop_radius);
506 radius->create_objects();
507 radius->set_boundaries((int64_t)0, (int64_t)255);
510 add_subwindow(red = new BC_Title(x2, title1->get_y(), "0"));
511 add_subwindow(green = new BC_Title(x2, title2->get_y(), "0"));
512 add_subwindow(blue = new BC_Title(x2, title3->get_y(), "0"));
514 add_subwindow(this->y = new BC_Title(x2, title4->get_y(), "0"));
515 add_subwindow(this->u = new BC_Title(x2, title5->get_y(), "0"));
516 add_subwindow(this->v = new BC_Title(x2, title6->get_y(), "0"));
518 y = title6->get_y() + this->v->get_h() + margin;
519 add_subwindow(sample = new BC_SubWindow(x, y, 50, 50));
524 void CWindowEyedropGUI::update()
526 char string[BCTEXTLEN];
527 sprintf(string, "%d, %d",
528 thread->gui->eyedrop_x,
529 thread->gui->eyedrop_y);
530 current->update(string);
532 radius->update((int64_t)mwindow->edl->session->eyedrop_radius);
534 red->update(mwindow->edl->local_session->red);
535 green->update(mwindow->edl->local_session->green);
536 blue->update(mwindow->edl->local_session->blue);
539 YUV::rgb_to_yuv_f(mwindow->edl->local_session->red,
540 mwindow->edl->local_session->green,
541 mwindow->edl->local_session->blue,
549 int red = (int)(CLIP(mwindow->edl->local_session->red, 0, 1) * 0xff);
550 int green = (int)(CLIP(mwindow->edl->local_session->green, 0, 1) * 0xff);
551 int blue = (int)(CLIP(mwindow->edl->local_session->blue, 0, 1) * 0xff);
552 sample->set_color((red << 16) | (green << 8) | blue);
553 sample->draw_box(0, 0, sample->get_w(), sample->get_h());
554 sample->set_color(BLACK);
555 sample->draw_rectangle(0, 0, sample->get_w(), sample->get_h());
559 void CWindowEyedropGUI::handle_event()
561 int new_radius = atoi(radius->get_text());
562 if(new_radius != mwindow->edl->session->eyedrop_radius)
564 CWindowGUI *gui = mwindow->cwindow->gui;
565 if(gui->eyedrop_visible)
567 gui->lock_window("CWindowEyedropGUI::handle_event");
570 gui->canvas->do_eyedrop(rerender, 0, 1);
573 mwindow->edl->session->eyedrop_radius = new_radius;
575 if(gui->eyedrop_visible)
579 gui->canvas->do_eyedrop(rerender, 0, 1);
580 gui->unlock_window();
587 /* Buttons to control Keyframe-Curve-Mode for Projector or Camera */
589 // Configuration for all possible Keyframe Curve Mode toggles
591 FloatAuto::t_mode mode;
597 const _CVD Camera_Crv_Smooth =
601 N_("\"smooth\" Curve on current Camera Keyframes")
603 const _CVD Camera_Crv_Linear =
607 N_("\"linear\" Curve on current Camera Keyframes")
609 const _CVD Projector_Crv_Smooth =
613 N_("\"smooth\" Curve on current Projector Keyframes")
615 const _CVD Projector_Crv_Linear =
619 N_("\"linear\" Curve on current Projector Keyframes")
622 // Implementation Class für Keyframe Curve Mode buttons
624 // This button reflects the state of the "current" keyframe
625 // (the nearest keyframe on the left) for all three automation
626 // lines together. Clicking on this button (re)sets the curve
627 // mode for the three "current" keyframes simultanously, but
628 // never creates a new keyframe.
630 class CWindowCurveToggle : public BC_Toggle
633 CWindowCurveToggle(_CVD mode, MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
634 void check_toggle_state(FloatAuto *x, FloatAuto *y, FloatAuto *z);
643 CWindowCurveToggle::CWindowCurveToggle(_CVD mode, MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
644 : BC_Toggle(x, y, mwindow->theme->get_image_set(mode.icon_id), false),
648 this->mwindow = mwindow;
649 set_tooltip(_(cfg.tooltip));
652 void CWindowCurveToggle::check_toggle_state(FloatAuto *x, FloatAuto *y, FloatAuto *z)
654 // the toggle state is only set to ON if all
655 // three automation lines have the same curve mode.
656 // For mixed states the toggle stays off.
657 set_value( x->curve_mode == this->cfg.mode &&
658 y->curve_mode == this->cfg.mode &&
659 z->curve_mode == this->cfg.mode
660 ,true // redraw to show new state
664 int CWindowCurveToggle::handle_event()
666 FloatAuto *x=0, *y=0, *z=0;
667 Track *track = mwindow->cwindow->calculate_affected_track();
670 { mwindow->cwindow->calculate_affected_autos(&x, &y, &z,
671 track, cfg.use_camera, 0,0,0); // don't create new keyframe
673 if(x) x->change_curve_mode(cfg.mode);
674 if(y) y->change_curve_mode(cfg.mode);
675 if(z) z->change_curve_mode(cfg.mode);
678 gui->update_preview();
685 CWindowCameraGUI::CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread)
686 : CWindowToolGUI(mwindow,
688 _(PROGRAM_NAME ": Camera"),
693 CWindowCameraGUI::~CWindowCameraGUI()
697 void CWindowCameraGUI::create_objects()
699 int x = 10, y = 10, x1;
700 Track *track = mwindow->cwindow->calculate_affected_track();
701 FloatAuto *x_auto = 0;
702 FloatAuto *y_auto = 0;
703 FloatAuto *z_auto = 0;
707 lock_window("CWindowCameraGUI::create_objects");
710 mwindow->cwindow->calculate_affected_autos(&x_auto,
711 &y_auto, &z_auto, track, 1, 0, 0, 0);
714 add_subwindow(title = new BC_Title(x, y, "X:"));
716 this->x = new CWindowCoord(this, x, y,
717 x_auto ? x_auto->get_value() : (float)0);
718 this->x->create_objects();
723 add_subwindow(title = new BC_Title(x, y, "Y:"));
725 this->y = new CWindowCoord(this, x, y,
726 y_auto ? y_auto->get_value() : (float)0);
727 this->y->create_objects();
730 add_subwindow(title = new BC_Title(x, y, "Z:"));
732 this->z = new CWindowCoord(this, x, y,
733 z_auto ? z_auto->get_value() : (float)1);
734 this->z->create_objects();
735 this->z->set_increment(0.01);
739 add_subwindow(button = new CWindowCameraLeft(mwindow, this, x1, y));
740 x1 += button->get_w();
741 add_subwindow(button = new CWindowCameraCenter(mwindow, this, x1, y));
742 x1 += button->get_w();
743 add_subwindow(button = new CWindowCameraRight(mwindow, this, x1, y));
745 y += button->get_h();
747 add_subwindow(button = new CWindowCameraTop(mwindow, this, x1, y));
748 x1 += button->get_w();
749 add_subwindow(button = new CWindowCameraMiddle(mwindow, this, x1, y));
750 x1 += button->get_w();
751 add_subwindow(button = new CWindowCameraBottom(mwindow, this, x1, y));
752 // additional Buttons to control the curve mode of the "current" keyframe
753 x1 += button->get_w() + 15;
754 add_subwindow(this->t_smooth = new CWindowCurveToggle(Camera_Crv_Smooth, mwindow, this, x1, y));
755 x1 += button->get_w();
756 add_subwindow(this->t_linear = new CWindowCurveToggle(Camera_Crv_Linear, mwindow, this, x1, y));
758 // fill in current auto keyframe values, set toggle states.
763 void CWindowCameraGUI::update_preview()
765 mwindow->restart_brender();
766 mwindow->sync_parameters(CHANGE_PARAMS);
768 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
772 mwindow->gui->lock_window("CWindowCameraGUI::update_preview");
773 mwindow->gui->draw_overlays(1);
774 mwindow->gui->unlock_window();
775 mwindow->cwindow->gui->lock_window("CWindowCameraGUI::update_preview");
776 mwindow->cwindow->gui->canvas->draw_refresh();
777 mwindow->cwindow->gui->unlock_window();
781 void CWindowCameraGUI::handle_event()
783 FloatAuto *x_auto = 0;
784 FloatAuto *y_auto = 0;
785 FloatAuto *z_auto = 0;
786 Track *track = mwindow->cwindow->calculate_affected_track();
789 mwindow->undo->update_undo_before(_("camera"), this);
790 if(event_caller == x)
792 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
793 track->automation->autos[AUTOMATION_CAMERA_X],
797 x_auto->set_value(atof(x->get_text()));
803 if(event_caller == y)
805 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
806 track->automation->autos[AUTOMATION_CAMERA_Y],
810 y_auto->set_value(atof(y->get_text()));
816 if(event_caller == z)
818 z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
819 track->automation->autos[AUTOMATION_CAMERA_Z],
823 float zoom = atof(z->get_text());
824 if(zoom > 100.) zoom = 100.;
826 if(zoom < 0.01) zoom = 0.01;
827 // Doesn't allow user to enter from scratch
828 // if(zoom != atof(z->get_text()))
831 z_auto->set_value(zoom);
832 mwindow->gui->lock_window("CWindowCameraGUI::handle_event");
833 mwindow->gui->draw_overlays(1);
834 mwindow->gui->unlock_window();
840 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
844 void CWindowCameraGUI::update()
846 FloatAuto *x_auto = 0;
847 FloatAuto *y_auto = 0;
848 FloatAuto *z_auto = 0;
849 Track *track = mwindow->cwindow->calculate_affected_track();
853 mwindow->cwindow->calculate_affected_autos(&x_auto,
864 x->update(x_auto->get_value());
866 y->update(y_auto->get_value());
868 float value = z_auto->get_value();
870 thread->gui->composite_panel->cpanel_zoom->update(value);
873 if( x_auto && y_auto && z_auto )
875 t_smooth->check_toggle_state(x_auto, y_auto, z_auto);
876 t_linear->check_toggle_state(x_auto, y_auto, z_auto);
883 CWindowCameraLeft::CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
884 : BC_Button(x, y, mwindow->theme->get_image_set("left_justify"))
887 this->mwindow = mwindow;
888 set_tooltip(_("Left justify"));
890 int CWindowCameraLeft::handle_event()
892 FloatAuto *x_auto = 0;
893 FloatAuto *z_auto = 0;
894 Track *track = mwindow->cwindow->calculate_affected_track();
897 mwindow->cwindow->calculate_affected_autos(&x_auto,
910 track->get_source_dimensions(
911 mwindow->edl->local_session->get_selectionstart(1),
917 mwindow->undo->update_undo_before(_("camera"), 0);
919 (double)track->track_w / z_auto->get_value() / 2 -
921 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
923 gui->update_preview();
931 CWindowCameraCenter::CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
932 : BC_Button(x, y, mwindow->theme->get_image_set("center_justify"))
935 this->mwindow = mwindow;
936 set_tooltip(_("Center horizontal"));
938 int CWindowCameraCenter::handle_event()
940 FloatAuto *x_auto = 0;
941 Track *track = mwindow->cwindow->calculate_affected_track();
943 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
944 track->automation->autos[AUTOMATION_CAMERA_X],
949 mwindow->undo->update_undo_before(_("camera"), 0);
950 x_auto->set_value(0);
952 gui->update_preview();
953 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
960 CWindowCameraRight::CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
961 : BC_Button(x, y, mwindow->theme->get_image_set("right_justify"))
964 this->mwindow = mwindow;
965 set_tooltip(_("Right justify"));
967 int CWindowCameraRight::handle_event()
969 FloatAuto *x_auto = 0;
970 FloatAuto *z_auto = 0;
971 Track *track = mwindow->cwindow->calculate_affected_track();
974 mwindow->cwindow->calculate_affected_autos(&x_auto,
987 track->get_source_dimensions(
988 mwindow->edl->local_session->get_selectionstart(1),
994 mwindow->undo->update_undo_before(_("camera"), 0);
995 x_auto->set_value( -((double)track->track_w / z_auto->get_value() / 2 -
998 gui->update_preview();
999 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1007 CWindowCameraTop::CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1008 : BC_Button(x, y, mwindow->theme->get_image_set("top_justify"))
1011 this->mwindow = mwindow;
1012 set_tooltip(_("Top justify"));
1014 int CWindowCameraTop::handle_event()
1016 FloatAuto *y_auto = 0;
1017 FloatAuto *z_auto = 0;
1018 Track *track = mwindow->cwindow->calculate_affected_track();
1021 mwindow->cwindow->calculate_affected_autos(0,
1031 if(y_auto && z_auto)
1034 track->get_source_dimensions(
1035 mwindow->edl->local_session->get_selectionstart(1),
1041 mwindow->undo->update_undo_before(_("camera"), 0);
1042 y_auto->set_value((double)track->track_h / z_auto->get_value() / 2 -
1045 gui->update_preview();
1046 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1054 CWindowCameraMiddle::CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1055 : BC_Button(x, y, mwindow->theme->get_image_set("middle_justify"))
1058 this->mwindow = mwindow;
1059 set_tooltip(_("Center vertical"));
1061 int CWindowCameraMiddle::handle_event()
1063 FloatAuto *y_auto = 0;
1064 Track *track = mwindow->cwindow->calculate_affected_track();
1066 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1067 track->automation->autos[AUTOMATION_CAMERA_Y], 1);
1071 mwindow->undo->update_undo_before(_("camera"), 0);
1072 y_auto->set_value(0);
1074 gui->update_preview();
1075 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1082 CWindowCameraBottom::CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1083 : BC_Button(x, y, mwindow->theme->get_image_set("bottom_justify"))
1086 this->mwindow = mwindow;
1087 set_tooltip(_("Bottom justify"));
1089 int CWindowCameraBottom::handle_event()
1091 FloatAuto *y_auto = 0;
1092 FloatAuto *z_auto = 0;
1093 Track *track = mwindow->cwindow->calculate_affected_track();
1096 mwindow->cwindow->calculate_affected_autos(0,
1106 if(y_auto && z_auto)
1109 track->get_source_dimensions(
1110 mwindow->edl->local_session->get_selectionstart(1),
1116 mwindow->undo->update_undo_before(_("camera"), 0);
1117 y_auto->set_value(-((double)track->track_h / z_auto->get_value() / 2 -
1120 gui->update_preview();
1121 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1129 CWindowProjectorGUI::CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread)
1130 : CWindowToolGUI(mwindow,
1132 _(PROGRAM_NAME ": Projector"),
1137 CWindowProjectorGUI::~CWindowProjectorGUI()
1140 void CWindowProjectorGUI::create_objects()
1142 int x = 10, y = 10, x1;
1143 Track *track = mwindow->cwindow->calculate_affected_track();
1144 FloatAuto *x_auto = 0;
1145 FloatAuto *y_auto = 0;
1146 FloatAuto *z_auto = 0;
1150 lock_window("CWindowProjectorGUI::create_objects");
1153 mwindow->cwindow->calculate_affected_autos(&x_auto,
1163 add_subwindow(title = new BC_Title(x, y, "X:"));
1164 x += title->get_w();
1165 this->x = new CWindowCoord(this, x, y,
1166 x_auto ? x_auto->get_value() : (float)0);
1167 this->x->create_objects();
1170 add_subwindow(title = new BC_Title(x, y, "Y:"));
1171 x += title->get_w();
1172 this->y = new CWindowCoord(this, x, y,
1173 y_auto ? y_auto->get_value() : (float)0);
1174 this->y->create_objects();
1177 add_subwindow(title = new BC_Title(x, y, "Z:"));
1178 x += title->get_w();
1179 this->z = new CWindowCoord(this, x, y,
1180 z_auto ? z_auto->get_value() : (float)1);
1181 this->z->create_objects();
1182 this->z->set_increment(0.01);
1186 add_subwindow(button = new CWindowProjectorLeft(mwindow, this, x1, y));
1187 x1 += button->get_w();
1188 add_subwindow(button = new CWindowProjectorCenter(mwindow, this, x1, y));
1189 x1 += button->get_w();
1190 add_subwindow(button = new CWindowProjectorRight(mwindow, this, x1, y));
1192 y += button->get_h();
1194 add_subwindow(button = new CWindowProjectorTop(mwindow, this, x1, y));
1195 x1 += button->get_w();
1196 add_subwindow(button = new CWindowProjectorMiddle(mwindow, this, x1, y));
1197 x1 += button->get_w();
1198 add_subwindow(button = new CWindowProjectorBottom(mwindow, this, x1, y));
1200 // additional Buttons to control the curve mode of the "current" keyframe
1201 x1 += button->get_w() + 15;
1202 add_subwindow(this->t_smooth = new CWindowCurveToggle(Projector_Crv_Smooth, mwindow, this, x1, y));
1203 x1 += button->get_w();
1204 add_subwindow(this->t_linear = new CWindowCurveToggle(Projector_Crv_Linear, mwindow, this, x1, y));
1206 // fill in current auto keyframe values, set toggle states.
1211 void CWindowProjectorGUI::update_preview()
1213 mwindow->restart_brender();
1214 mwindow->sync_parameters(CHANGE_PARAMS);
1215 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1219 // TODO: really need to lock the main window??
1220 mwindow->gui->lock_window("CWindowProjectorGUI::update_preview");
1221 mwindow->gui->draw_overlays(1);
1222 mwindow->gui->unlock_window();
1223 mwindow->cwindow->gui->lock_window("CWindowProjectorGUI::update_preview");
1224 mwindow->cwindow->gui->canvas->draw_refresh();
1225 mwindow->cwindow->gui->unlock_window();
1228 void CWindowProjectorGUI::handle_event()
1230 FloatAuto *x_auto = 0;
1231 FloatAuto *y_auto = 0;
1232 FloatAuto *z_auto = 0;
1233 Track *track = mwindow->cwindow->calculate_affected_track();
1237 mwindow->undo->update_undo_before(_("projector"), this);
1238 if(event_caller == x)
1240 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1241 track->automation->autos[AUTOMATION_PROJECTOR_X],
1245 x_auto->set_value(atof(x->get_text()));
1251 if(event_caller == y)
1253 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1254 track->automation->autos[AUTOMATION_PROJECTOR_Y],
1258 y_auto->set_value(atof(y->get_text()));
1264 if(event_caller == z)
1266 z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1267 track->automation->autos[AUTOMATION_PROJECTOR_Z],
1271 float zoom = atof(z->get_text());
1272 if(zoom > 100.) zoom = 100.;
1273 else if(zoom < 0.01) zoom = 0.01;
1274 // if (zoom != atof(z->get_text()))
1276 z_auto->set_value(zoom);
1278 mwindow->gui->lock_window("CWindowProjectorGUI::handle_event");
1279 mwindow->gui->draw_overlays(1);
1280 mwindow->gui->unlock_window();
1286 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1290 void CWindowProjectorGUI::update()
1292 FloatAuto *x_auto = 0;
1293 FloatAuto *y_auto = 0;
1294 FloatAuto *z_auto = 0;
1295 Track *track = mwindow->cwindow->calculate_affected_track();
1299 mwindow->cwindow->calculate_affected_autos(&x_auto,
1310 x->update(x_auto->get_value());
1312 y->update(y_auto->get_value());
1314 float value = z_auto->get_value();
1316 thread->gui->composite_panel->cpanel_zoom->update(value);
1319 if( x_auto && y_auto && z_auto )
1321 t_smooth->check_toggle_state(x_auto, y_auto, z_auto);
1322 t_linear->check_toggle_state(x_auto, y_auto, z_auto);
1326 CWindowProjectorLeft::CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1327 : BC_Button(x, y, mwindow->theme->get_image_set("left_justify"))
1330 this->mwindow = mwindow;
1331 set_tooltip(_("Left justify"));
1333 int CWindowProjectorLeft::handle_event()
1335 FloatAuto *x_auto = 0;
1336 FloatAuto *z_auto = 0;
1337 Track *track = mwindow->cwindow->calculate_affected_track();
1340 mwindow->cwindow->calculate_affected_autos(&x_auto,
1349 if(x_auto && z_auto)
1351 mwindow->undo->update_undo_before(_("projector"), 0);
1352 x_auto->set_value( (double)track->track_w * z_auto->get_value() / 2 -
1353 (double)mwindow->edl->session->output_w / 2 );
1355 gui->update_preview();
1356 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1363 CWindowProjectorCenter::CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1364 : BC_Button(x, y, mwindow->theme->get_image_set("center_justify"))
1367 this->mwindow = mwindow;
1368 set_tooltip(_("Center horizontal"));
1370 int CWindowProjectorCenter::handle_event()
1372 FloatAuto *x_auto = 0;
1373 Track *track = mwindow->cwindow->calculate_affected_track();
1375 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1376 track->automation->autos[AUTOMATION_PROJECTOR_X],
1381 mwindow->undo->update_undo_before(_("projector"), 0);
1382 x_auto->set_value(0);
1384 gui->update_preview();
1385 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1392 CWindowProjectorRight::CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1393 : BC_Button(x, y, mwindow->theme->get_image_set("right_justify"))
1396 this->mwindow = mwindow;
1397 set_tooltip(_("Right justify"));
1399 int CWindowProjectorRight::handle_event()
1401 FloatAuto *x_auto = 0;
1402 FloatAuto *z_auto = 0;
1403 Track *track = mwindow->cwindow->calculate_affected_track();
1406 mwindow->cwindow->calculate_affected_autos(&x_auto,
1416 if(x_auto && z_auto)
1418 mwindow->undo->update_undo_before(_("projector"), 0);
1419 x_auto->set_value( -((double)track->track_w * z_auto->get_value() / 2 -
1420 (double)mwindow->edl->session->output_w / 2));
1422 gui->update_preview();
1423 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1430 CWindowProjectorTop::CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1431 : BC_Button(x, y, mwindow->theme->get_image_set("top_justify"))
1434 this->mwindow = mwindow;
1435 set_tooltip(_("Top justify"));
1437 int CWindowProjectorTop::handle_event()
1439 FloatAuto *y_auto = 0;
1440 FloatAuto *z_auto = 0;
1441 Track *track = mwindow->cwindow->calculate_affected_track();
1444 mwindow->cwindow->calculate_affected_autos(0,
1454 if(y_auto && z_auto)
1456 mwindow->undo->update_undo_before(_("projector"), 0);
1457 y_auto->set_value( (double)track->track_h * z_auto->get_value() / 2 -
1458 (double)mwindow->edl->session->output_h / 2 );
1460 gui->update_preview();
1461 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1468 CWindowProjectorMiddle::CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1469 : BC_Button(x, y, mwindow->theme->get_image_set("middle_justify"))
1472 this->mwindow = mwindow;
1473 set_tooltip(_("Center vertical"));
1475 int CWindowProjectorMiddle::handle_event()
1477 FloatAuto *y_auto = 0;
1478 Track *track = mwindow->cwindow->calculate_affected_track();
1480 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1481 track->automation->autos[AUTOMATION_PROJECTOR_Y], 1);
1485 mwindow->undo->update_undo_before(_("projector"), 0);
1486 y_auto->set_value(0);
1488 gui->update_preview();
1489 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1496 CWindowProjectorBottom::CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1497 : BC_Button(x, y, mwindow->theme->get_image_set("bottom_justify"))
1500 this->mwindow = mwindow;
1501 set_tooltip(_("Bottom justify"));
1503 int CWindowProjectorBottom::handle_event()
1505 FloatAuto *y_auto = 0;
1506 FloatAuto *z_auto = 0;
1507 Track *track = mwindow->cwindow->calculate_affected_track();
1510 mwindow->cwindow->calculate_affected_autos(0,
1520 if(y_auto && z_auto)
1522 mwindow->undo->update_undo_before(_("projector"), 0);
1523 y_auto->set_value( -((double)track->track_h * z_auto->get_value() / 2 -
1524 (double)mwindow->edl->session->output_h / 2));
1526 gui->update_preview();
1527 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1534 CWindowMaskMode::CWindowMaskMode(MWindow *mwindow,
1535 CWindowToolGUI *gui, int x, int y, const char *text)
1536 : BC_PopupMenu(x, y, 220, text, 1)
1538 this->mwindow = mwindow;
1542 void CWindowMaskMode::create_objects()
1544 add_item(new BC_MenuItem(mode_to_text(MASK_MULTIPLY_ALPHA)));
1545 add_item(new BC_MenuItem(mode_to_text(MASK_SUBTRACT_ALPHA)));
1548 char* CWindowMaskMode::mode_to_text(int mode)
1552 case MASK_MULTIPLY_ALPHA:
1553 return _("Multiply alpha");
1556 case MASK_SUBTRACT_ALPHA:
1557 return _("Subtract alpha");
1561 return _("Subtract alpha");
1564 int CWindowMaskMode::text_to_mode(char *text)
1566 if(!strcasecmp(text, _("Multiply alpha")))
1567 return MASK_MULTIPLY_ALPHA;
1569 if(!strcasecmp(text, _("Subtract alpha")))
1570 return MASK_SUBTRACT_ALPHA;
1572 return MASK_SUBTRACT_ALPHA;
1575 int CWindowMaskMode::handle_event()
1582 // Get existing keyframe
1583 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1586 mwindow->undo->update_undo_before(_("mask mode"), 0);
1587 #ifdef USE_KEYFRAME_SPANNING
1588 // Create temp keyframe
1589 MaskAuto temp_keyframe(mwindow->edl, autos);
1590 temp_keyframe.copy_data(keyframe);
1592 temp_keyframe.mode = text_to_mode(get_text());
1593 // Commit change to span of keyframes
1594 autos->update_parameter(&temp_keyframe);
1596 ((MaskAuto*)autos->default_auto)->mode =
1597 text_to_mode(get_text());
1599 mwindow->undo->update_undo_after(_("mask mode"), LOAD_AUTOMATION);
1602 //printf("CWindowMaskMode::handle_event 1\n");
1603 gui->update_preview();
1614 CWindowMaskDelete::CWindowMaskDelete(MWindow *mwindow,
1615 CWindowToolGUI *gui,
1618 : BC_GenericButton(x, y, _("Delete"))
1620 this->mwindow = mwindow;
1624 int CWindowMaskDelete::handle_event()
1631 int total_points = 0;
1633 // Get existing keyframe
1634 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1638 mwindow->undo->update_undo_before(_("mask delete"), 0);
1640 #ifdef USE_KEYFRAME_SPANNING
1641 // Create temp keyframe
1642 MaskAuto temp_keyframe(mwindow->edl, autos);
1643 temp_keyframe.copy_data(keyframe);
1645 SubMask *submask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
1646 for(int i = mwindow->cwindow->gui->affected_point;
1647 i < submask->points.total - 1;
1650 *submask->points.values[i] = *submask->points.values[i + 1];
1653 if(submask->points.total)
1655 submask->points.remove_object(
1656 submask->points.values[submask->points.total - 1]);
1658 total_points = submask->points.total;
1660 // Commit change to span of keyframes
1661 ((MaskAutos*)track->automation->autos[AUTOMATION_MASK])->update_parameter(&temp_keyframe);
1663 for(MaskAuto *current = (MaskAuto*)autos->default_auto;
1666 SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
1668 for(int i = mwindow->cwindow->gui->affected_point;
1669 i < submask->points.total - 1;
1672 *submask->points.values[i] = *submask->points.values[i + 1];
1675 if(submask->points.total)
1677 submask->points.remove_object(
1678 submask->points.values[submask->points.total - 1]);
1680 total_points = submask->points.total;
1682 if(current == (MaskAuto*)autos->default_auto)
1683 current = (MaskAuto*)autos->first;
1685 current = (MaskAuto*)NEXT;
1688 if( mwindow->cwindow->gui->affected_point >= total_points )
1689 mwindow->cwindow->gui->affected_point =
1690 total_points > 0 ? total_points-1 : 0;
1693 gui->update_preview();
1694 mwindow->undo->update_undo_after(_("mask delete"), LOAD_AUTOMATION);
1701 int CWindowMaskDelete::keypress_event()
1703 if(get_keypress() == BACKSPACE ||
1704 get_keypress() == DELETE)
1705 return handle_event();
1710 // CWindowMaskCycleNext::CWindowMaskCycleNext(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1711 // : BC_GenericButton(x, y, _("Cycle next"))
1713 // this->mwindow = mwindow;
1716 // int CWindowMaskCycleNext::handle_event()
1718 // MaskAuto *keyframe;
1719 // MaskAutos *autos;
1721 // MaskPoint *point;
1723 // ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1727 // // Should apply to all keyframes
1728 // if(keyframe && mask->points.total)
1730 // temp = mask->points.values[0];
1732 // for(int i = 0; i < mask->points.total - 1; i++)
1734 // mask->points.values[i] = mask->points.values[i + 1];
1736 // mask->points.values[mask->points.total - 1] = temp;
1738 // mwindow->cwindow->gui->affected_point--;
1739 // if(mwindow->cwindow->gui->affected_point < 0)
1740 // mwindow->cwindow->gui->affected_point = mask->points.total - 1;
1743 // gui->update_preview();
1749 // CWindowMaskCyclePrev::CWindowMaskCyclePrev(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1750 // : BC_GenericButton(x, y, _("Cycle prev"))
1752 // this->mwindow = mwindow;
1755 // int CWindowMaskCyclePrev::handle_event()
1757 // MaskAuto *keyframe;
1758 // MaskAutos *autos;
1760 // MaskPoint *point;
1762 // ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1764 // // Should apply to all keyframes
1766 // if(keyframe && mask->points.total)
1768 // temp = mask->points.values[mask->points.total - 1];
1770 // for(int i = mask->points.total - 1; i > 0; i--)
1772 // mask->points.values[i] = mask->points.values[i - 1];
1774 // mask->points.values[0] = temp;
1776 // mwindow->cwindow->gui->affected_point++;
1777 // if(mwindow->cwindow->gui->affected_point >= mask->points.total)
1778 // mwindow->cwindow->gui->affected_point = 0;
1781 // gui->update_preview();
1787 CWindowMaskNumber::CWindowMaskNumber(MWindow *mwindow,
1788 CWindowToolGUI *gui,
1791 : BC_TumbleTextBox(gui,
1792 (int64_t)mwindow->edl->session->cwindow_mask,
1794 (int64_t)SUBMASKS - 1,
1799 this->mwindow = mwindow;
1803 CWindowMaskNumber::~CWindowMaskNumber()
1807 int CWindowMaskNumber::handle_event()
1809 mwindow->edl->session->cwindow_mask = atol(get_text());
1811 gui->update_preview();
1816 CWindowMaskAffectedPoint::CWindowMaskAffectedPoint(MWindow *mwindow,
1817 CWindowToolGUI *gui, int x, int y)
1818 : BC_TumbleTextBox(gui,
1819 (int64_t)mwindow->cwindow->gui->affected_point,
1820 (int64_t)0, INT64_MAX, x, y, 100)
1822 this->mwindow = mwindow;
1826 CWindowMaskAffectedPoint::~CWindowMaskAffectedPoint()
1830 int CWindowMaskAffectedPoint::handle_event()
1832 int total_points = 0;
1833 int affected_point = atol(get_text());
1834 Track *track = mwindow->cwindow->calculate_affected_track();
1836 MaskAutos *autos = (MaskAutos*)track->automation->autos[AUTOMATION_MASK];
1837 MaskAuto *keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(autos, 0);
1839 SubMask *mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
1840 total_points = mask->points.size();
1843 int active_point = affected_point;
1844 if( affected_point >= total_points )
1845 affected_point = total_points - 1;
1846 else if( affected_point < 0 )
1848 if( active_point != affected_point )
1849 update((int64_t)affected_point);
1850 mwindow->cwindow->gui->affected_point = affected_point;
1852 gui->update_preview();
1860 CWindowMaskFeather::CWindowMaskFeather(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1861 : BC_TumbleTextBox(gui,
1869 this->mwindow = mwindow;
1872 CWindowMaskFeather::~CWindowMaskFeather()
1875 int CWindowMaskFeather::handle_event()
1882 #ifdef USE_KEYFRAME_SPANNING
1888 mwindow->undo->update_undo_before(_("mask feather"), this);
1890 // Get existing keyframe
1891 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe,
1892 mask, point, create_it);
1896 #ifdef USE_KEYFRAME_SPANNING
1897 // Create temp keyframe
1898 MaskAuto temp_keyframe(mwindow->edl, autos);
1899 temp_keyframe.copy_data(keyframe);
1901 temp_keyframe.feather = atof(get_text());
1902 // Commit change to span of keyframes
1903 autos->update_parameter(&temp_keyframe);
1905 keyframe->feather = atof(get_text());
1908 gui->update_preview();
1911 mwindow->undo->update_undo_after(_("mask feather"), LOAD_AUTOMATION);
1916 CWindowMaskValue::CWindowMaskValue(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1926 this->mwindow = mwindow;
1930 CWindowMaskValue::~CWindowMaskValue()
1934 int CWindowMaskValue::handle_event()
1941 #ifdef USE_KEYFRAME_SPANNING
1947 mwindow->undo->update_undo_before(_("mask value"), this);
1948 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe,
1949 mask, point, create_it);
1953 #ifdef USE_KEYFRAME_SPANNING
1954 // Create temp keyframe
1955 MaskAuto temp_keyframe(mwindow->edl, autos);
1956 temp_keyframe.copy_data(keyframe);
1958 temp_keyframe.value = get_value();
1959 // Commit change to span of keyframes
1960 autos->update_parameter(&temp_keyframe);
1962 keyframe->value = get_value();
1966 gui->update_preview();
1967 mwindow->undo->update_undo_after(_("mask value"), LOAD_AUTOMATION);
1972 CWindowMaskBeforePlugins::CWindowMaskBeforePlugins(CWindowToolGUI *gui, int x, int y)
1976 _("Apply mask before plugins"))
1981 int CWindowMaskBeforePlugins::handle_event()
1988 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 1);
1991 keyframe->apply_before_plugins = get_value();
1992 gui->update_preview();
1998 CWindowDisableOpenGLMasking::CWindowDisableOpenGLMasking(CWindowToolGUI *gui, int x, int y)
1999 : BC_CheckBox(x, y, 1, _("Disable OpenGL masking"))
2004 int CWindowDisableOpenGLMasking::handle_event()
2011 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 1);
2014 keyframe->disable_opengl_masking = get_value();
2015 gui->update_preview();
2028 CWindowMaskGUI::CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread)
2029 : CWindowToolGUI(mwindow,
2031 _(PROGRAM_NAME ": Mask"),
2035 this->mwindow = mwindow;
2036 this->thread = thread;
2041 CWindowMaskGUI::~CWindowMaskGUI()
2043 lock_window("CWindowMaskGUI::~CWindowMaskGUI");
2045 delete active_point;
2050 void CWindowMaskGUI::create_objects()
2052 int x = 10, y = 10, margin = mwindow->theme->widget_border;
2053 //MaskAuto *keyframe = 0;
2054 //Track *track = mwindow->cwindow->calculate_affected_track();
2056 // keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->autos[AUTOMATION_MASK], 0);
2058 lock_window("CWindowMaskGUI::create_objects");
2060 add_subwindow(title = new BC_Title(x, y, _("Mode:")));
2061 add_subwindow(mode = new CWindowMaskMode(mwindow,
2062 this, x + title->get_w() + margin, y, ""));
2063 mode->create_objects();
2064 y += mode->get_h() + margin;
2065 add_subwindow(title = new BC_Title(x, y, _("Value:")));
2066 add_subwindow(value = new CWindowMaskValue(mwindow, this, x + title->get_w() + margin, y));
2067 y += value->get_h() + margin;
2068 add_subwindow(delete_point = new CWindowMaskDelete(mwindow, this, x, y));
2069 int x1 = x + delete_point->get_w() + 2*margin;
2070 add_subwindow(title = new BC_Title(x1, y, _("Point:")));
2071 x1 += title->get_w() + margin;
2072 active_point = new CWindowMaskAffectedPoint(mwindow, this, x1, y);
2073 active_point->create_objects();
2074 y += delete_point->get_h() + margin;
2075 add_subwindow(title = new BC_Title(x, y, _("Mask number:")));
2076 number = new CWindowMaskNumber(mwindow,
2077 this, x + title->get_w() + margin, y);
2078 number->create_objects();
2079 y += number->get_h() + margin;
2080 add_subwindow(title = new BC_Title(x, y, _("Feather:")));
2081 feather = new CWindowMaskFeather(mwindow,
2082 this, x + title->get_w() + margin, y);
2083 feather->create_objects();
2084 y += feather->get_h() + margin;
2085 add_subwindow(title = new BC_Title(x, y, "X:"));
2086 x += title->get_w() + margin;
2087 this->x = new CWindowCoord(this, x, y, (float)0.0);
2088 this->x->create_objects();
2089 x += this->x->get_w() + margin;
2090 add_subwindow(title = new BC_Title(x, y, "Y:"));
2091 x += title->get_w() + margin;
2092 this->y = new CWindowCoord(this, x, y, (float)0.0);
2093 this->y->create_objects();
2096 y += this->y->get_h() + margin;
2097 add_subwindow(title = new BC_Title(x, y, _("Press Shift to move an end point")));
2098 y += title->get_h() + margin;
2099 add_subwindow(title = new BC_Title(x, y, _("Press Ctrl to move a control point")));
2100 y += title->get_h() + margin;
2101 add_subwindow(title = new BC_Title(x, y, _("Press Alt to translate the mask")));
2104 add_subwindow(this->apply_before_plugins = new CWindowMaskBeforePlugins(this, 10, y));
2105 y += this->apply_before_plugins->get_h() + margin;
2106 add_subwindow(this->disable_opengl_masking = new CWindowDisableOpenGLMasking(this, 10, y));
2112 void CWindowMaskGUI::get_keyframe(Track* &track,
2114 MaskAuto* &keyframe,
2122 track = mwindow->cwindow->calculate_affected_track();
2125 autos = (MaskAutos*)track->automation->autos[AUTOMATION_MASK];
2126 keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(
2132 mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
2139 if(mwindow->cwindow->gui->affected_point < mask->points.total &&
2140 mwindow->cwindow->gui->affected_point >= 0)
2142 point = mask->points.values[mwindow->cwindow->gui->affected_point];
2147 void CWindowMaskGUI::update()
2154 //printf("CWindowMaskGUI::update 1\n");
2155 get_keyframe(track, autos, keyframe, mask, point, 0);
2157 double position = mwindow->edl->local_session->get_selectionstart(1);
2158 position = mwindow->edl->align_to_frame(position, 0);
2161 int64_t position_i = track->to_units(position, 0);
2165 x->update(point->x);
2166 y->update(point->y);
2171 feather->update((int64_t)autos->get_feather(position_i, PLAY_FORWARD));
2172 value->update((int64_t)autos->get_value(position_i, PLAY_FORWARD));
2173 apply_before_plugins->update((int64_t)keyframe->apply_before_plugins);
2174 disable_opengl_masking->update((int64_t)keyframe->disable_opengl_masking);
2178 //printf("CWindowMaskGUI::update 1\n");
2179 active_point->update((int64_t)mwindow->cwindow->gui->affected_point);
2180 number->update((int64_t)mwindow->edl->session->cwindow_mask);
2182 //printf("CWindowMaskGUI::update 1\n");
2185 #ifdef USE_KEYFRAME_SPANNING
2187 CWindowMaskMode::mode_to_text(keyframe->mode));
2190 CWindowMaskMode::mode_to_text(((MaskAuto*)autos->default_auto)->mode));
2193 //printf("CWindowMaskGUI::update 2\n");
2196 void CWindowMaskGUI::handle_event()
2203 get_keyframe(track, autos, keyframe, mask, point, 0);
2205 mwindow->undo->update_undo_before(_("mask point"), this);
2209 #ifdef USE_KEYFRAME_SPANNING
2210 // Create temp keyframe
2211 MaskAuto temp_keyframe(mwindow->edl, autos);
2212 temp_keyframe.copy_data(keyframe);
2213 // Get affected point in temp keyframe
2214 mask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
2215 if(mwindow->cwindow->gui->affected_point < mask->points.total &&
2216 mwindow->cwindow->gui->affected_point >= 0)
2218 point = mask->points.values[mwindow->cwindow->gui->affected_point];
2223 point->x = atof(x->get_text());
2224 point->y = atof(y->get_text());
2225 // Commit to spanned keyframes
2226 autos->update_parameter(&temp_keyframe);
2229 point->x = atof(x->get_text());
2230 point->y = atof(y->get_text());
2235 mwindow->undo->update_undo_after(_("mask point"), LOAD_AUTOMATION);
2238 void CWindowMaskGUI::update_preview()
2240 mwindow->restart_brender();
2241 mwindow->sync_parameters(CHANGE_PARAMS);
2242 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
2246 mwindow->cwindow->gui->lock_window("CWindowMaskGUI::update_preview");
2247 mwindow->cwindow->gui->canvas->draw_refresh();
2248 mwindow->cwindow->gui->unlock_window();
2252 CWindowRulerGUI::CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread)
2253 : CWindowToolGUI(mwindow,
2255 _(PROGRAM_NAME ": Ruler"),
2261 CWindowRulerGUI::~CWindowRulerGUI()
2265 void CWindowRulerGUI::create_objects()
2270 lock_window("CWindowRulerGUI::create_objects");
2271 add_subwindow(title = new BC_Title(x, y, _("Current:")));
2272 add_subwindow(current = new BC_Title(x + title->get_w() + 10, y, ""));
2273 y += title->get_h() + 5;
2275 add_subwindow(title = new BC_Title(x, y, _("Point 1:")));
2276 add_subwindow(point1 = new BC_Title(x + title->get_w() + 10, y, ""));
2277 y += title->get_h() + 5;
2279 add_subwindow(title = new BC_Title(x, y, _("Point 2:")));
2280 add_subwindow(point2 = new BC_Title(x + title->get_w() + 10, y, ""));
2281 y += title->get_h() + 5;
2283 add_subwindow(title = new BC_Title(x, y, _("Distance:")));
2284 add_subwindow(distance = new BC_Title(x + title->get_w() + 10, y, ""));
2285 y += title->get_h() + 5;
2286 add_subwindow(title = new BC_Title(x, y, _("Angle:")));
2287 add_subwindow(angle = new BC_Title(x + title->get_w() + 10, y, ""));
2288 y += title->get_h() + 10;
2289 char string[BCTEXTLEN];
2290 sprintf(string, _("Press Ctrl to lock ruler to the\nnearest 45%c angle."), 0xb0);
2291 add_subwindow(title = new BC_Title(x,
2294 y += title->get_h() + 10;
2295 sprintf(string, _("Press Alt to translate the ruler."));
2296 add_subwindow(title = new BC_Title(x,
2303 void CWindowRulerGUI::update()
2305 double distance_value =
2306 sqrt(SQR(mwindow->edl->session->ruler_x2 - mwindow->edl->session->ruler_x1) +
2307 SQR(mwindow->edl->session->ruler_y2 - mwindow->edl->session->ruler_y1));
2308 double angle_value = atan((mwindow->edl->session->ruler_y2 - mwindow->edl->session->ruler_y1) /
2309 (mwindow->edl->session->ruler_x2 - mwindow->edl->session->ruler_x1)) *
2314 if(EQUIV(distance_value, 0.0))
2324 char string[BCTEXTLEN];
2325 sprintf(string, "%d, %d",
2326 mwindow->session->cwindow_output_x,
2327 mwindow->session->cwindow_output_y);
2328 current->update(string);
2329 sprintf(string, "%.0f, %.0f",
2330 mwindow->edl->session->ruler_x1,
2331 mwindow->edl->session->ruler_y1);
2332 point1->update(string);
2333 sprintf(string, "%.0f, %.0f",
2334 mwindow->edl->session->ruler_x2,
2335 mwindow->edl->session->ruler_y2);
2336 point2->update(string);
2338 sprintf(string, _("%0.01f pixels"), distance_value);
2339 distance->update(string);
2340 sprintf(string, "%0.02f %c", angle_value, 0xb0);
2341 angle->update(string);
2344 void CWindowRulerGUI::handle_event()