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 > 10) zoom = 10;
817 if(zoom < 0) zoom = 0;
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 z->update(z_auto->get_value());
861 if( x_auto && y_auto && z_auto )
863 t_smooth->check_toggle_state(x_auto, y_auto, z_auto);
864 t_linear->check_toggle_state(x_auto, y_auto, z_auto);
871 CWindowCameraLeft::CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
872 : BC_Button(x, y, mwindow->theme->get_image_set("left_justify"))
875 this->mwindow = mwindow;
876 set_tooltip(_("Left justify"));
878 int CWindowCameraLeft::handle_event()
880 FloatAuto *x_auto = 0;
881 FloatAuto *z_auto = 0;
882 Track *track = mwindow->cwindow->calculate_affected_track();
885 mwindow->cwindow->calculate_affected_autos(&x_auto,
898 track->get_source_dimensions(
899 mwindow->edl->local_session->get_selectionstart(1),
905 mwindow->undo->update_undo_before(_("camera"), 0);
907 (double)track->track_w / z_auto->get_value() / 2 -
909 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
911 gui->update_preview();
919 CWindowCameraCenter::CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
920 : BC_Button(x, y, mwindow->theme->get_image_set("center_justify"))
923 this->mwindow = mwindow;
924 set_tooltip(_("Center horizontal"));
926 int CWindowCameraCenter::handle_event()
928 FloatAuto *x_auto = 0;
929 Track *track = mwindow->cwindow->calculate_affected_track();
931 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
932 track->automation->autos[AUTOMATION_CAMERA_X],
937 mwindow->undo->update_undo_before(_("camera"), 0);
938 x_auto->set_value(0);
940 gui->update_preview();
941 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
948 CWindowCameraRight::CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
949 : BC_Button(x, y, mwindow->theme->get_image_set("right_justify"))
952 this->mwindow = mwindow;
953 set_tooltip(_("Right justify"));
955 int CWindowCameraRight::handle_event()
957 FloatAuto *x_auto = 0;
958 FloatAuto *z_auto = 0;
959 Track *track = mwindow->cwindow->calculate_affected_track();
962 mwindow->cwindow->calculate_affected_autos(&x_auto,
975 track->get_source_dimensions(
976 mwindow->edl->local_session->get_selectionstart(1),
982 mwindow->undo->update_undo_before(_("camera"), 0);
983 x_auto->set_value( -((double)track->track_w / z_auto->get_value() / 2 -
986 gui->update_preview();
987 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
995 CWindowCameraTop::CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
996 : BC_Button(x, y, mwindow->theme->get_image_set("top_justify"))
999 this->mwindow = mwindow;
1000 set_tooltip(_("Top justify"));
1002 int CWindowCameraTop::handle_event()
1004 FloatAuto *y_auto = 0;
1005 FloatAuto *z_auto = 0;
1006 Track *track = mwindow->cwindow->calculate_affected_track();
1009 mwindow->cwindow->calculate_affected_autos(0,
1019 if(y_auto && z_auto)
1022 track->get_source_dimensions(
1023 mwindow->edl->local_session->get_selectionstart(1),
1029 mwindow->undo->update_undo_before(_("camera"), 0);
1030 y_auto->set_value((double)track->track_h / z_auto->get_value() / 2 -
1033 gui->update_preview();
1034 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1042 CWindowCameraMiddle::CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1043 : BC_Button(x, y, mwindow->theme->get_image_set("middle_justify"))
1046 this->mwindow = mwindow;
1047 set_tooltip(_("Center vertical"));
1049 int CWindowCameraMiddle::handle_event()
1051 FloatAuto *y_auto = 0;
1052 Track *track = mwindow->cwindow->calculate_affected_track();
1054 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1055 track->automation->autos[AUTOMATION_CAMERA_Y], 1);
1059 mwindow->undo->update_undo_before(_("camera"), 0);
1060 y_auto->set_value(0);
1062 gui->update_preview();
1063 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1070 CWindowCameraBottom::CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1071 : BC_Button(x, y, mwindow->theme->get_image_set("bottom_justify"))
1074 this->mwindow = mwindow;
1075 set_tooltip(_("Bottom justify"));
1077 int CWindowCameraBottom::handle_event()
1079 FloatAuto *y_auto = 0;
1080 FloatAuto *z_auto = 0;
1081 Track *track = mwindow->cwindow->calculate_affected_track();
1084 mwindow->cwindow->calculate_affected_autos(0,
1094 if(y_auto && z_auto)
1097 track->get_source_dimensions(
1098 mwindow->edl->local_session->get_selectionstart(1),
1104 mwindow->undo->update_undo_before(_("camera"), 0);
1105 y_auto->set_value(-((double)track->track_h / z_auto->get_value() / 2 -
1108 gui->update_preview();
1109 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1117 CWindowProjectorGUI::CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread)
1118 : CWindowToolGUI(mwindow,
1120 _(PROGRAM_NAME ": Projector"),
1125 CWindowProjectorGUI::~CWindowProjectorGUI()
1128 void CWindowProjectorGUI::create_objects()
1130 int x = 10, y = 10, x1;
1131 Track *track = mwindow->cwindow->calculate_affected_track();
1132 FloatAuto *x_auto = 0;
1133 FloatAuto *y_auto = 0;
1134 FloatAuto *z_auto = 0;
1138 lock_window("CWindowProjectorGUI::create_objects");
1141 mwindow->cwindow->calculate_affected_autos(&x_auto,
1151 add_subwindow(title = new BC_Title(x, y, "X:"));
1152 x += title->get_w();
1153 this->x = new CWindowCoord(this, x, y,
1154 x_auto ? x_auto->get_value() : (float)0);
1155 this->x->create_objects();
1158 add_subwindow(title = new BC_Title(x, y, "Y:"));
1159 x += title->get_w();
1160 this->y = new CWindowCoord(this, x, y,
1161 y_auto ? y_auto->get_value() : (float)0);
1162 this->y->create_objects();
1165 add_subwindow(title = new BC_Title(x, y, "Z:"));
1166 x += title->get_w();
1167 this->z = new CWindowCoord(this, x, y,
1168 z_auto ? z_auto->get_value() : (float)1);
1169 this->z->create_objects();
1170 this->z->set_increment(0.01);
1174 add_subwindow(button = new CWindowProjectorLeft(mwindow, this, x1, y));
1175 x1 += button->get_w();
1176 add_subwindow(button = new CWindowProjectorCenter(mwindow, this, x1, y));
1177 x1 += button->get_w();
1178 add_subwindow(button = new CWindowProjectorRight(mwindow, this, x1, y));
1180 y += button->get_h();
1182 add_subwindow(button = new CWindowProjectorTop(mwindow, this, x1, y));
1183 x1 += button->get_w();
1184 add_subwindow(button = new CWindowProjectorMiddle(mwindow, this, x1, y));
1185 x1 += button->get_w();
1186 add_subwindow(button = new CWindowProjectorBottom(mwindow, this, x1, y));
1188 // additional Buttons to control the curve mode of the "current" keyframe
1189 x1 += button->get_w() + 15;
1190 add_subwindow(this->t_smooth = new CWindowCurveToggle(Projector_Crv_Smooth, mwindow, this, x1, y));
1191 x1 += button->get_w();
1192 add_subwindow(this->t_linear = new CWindowCurveToggle(Projector_Crv_Linear, mwindow, this, x1, y));
1194 // fill in current auto keyframe values, set toggle states.
1199 void CWindowProjectorGUI::update_preview()
1201 mwindow->restart_brender();
1202 mwindow->sync_parameters(CHANGE_PARAMS);
1203 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1207 // TODO: really need to lock the main window??
1208 mwindow->gui->lock_window("CWindowProjectorGUI::update_preview");
1209 mwindow->gui->draw_overlays(1);
1210 mwindow->gui->unlock_window();
1211 mwindow->cwindow->gui->lock_window("CWindowProjectorGUI::update_preview");
1212 mwindow->cwindow->gui->canvas->draw_refresh();
1213 mwindow->cwindow->gui->unlock_window();
1216 void CWindowProjectorGUI::handle_event()
1218 FloatAuto *x_auto = 0;
1219 FloatAuto *y_auto = 0;
1220 FloatAuto *z_auto = 0;
1221 Track *track = mwindow->cwindow->calculate_affected_track();
1225 mwindow->undo->update_undo_before(_("projector"), this);
1226 if(event_caller == x)
1228 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1229 track->automation->autos[AUTOMATION_PROJECTOR_X],
1233 x_auto->set_value(atof(x->get_text()));
1239 if(event_caller == y)
1241 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1242 track->automation->autos[AUTOMATION_PROJECTOR_Y],
1246 y_auto->set_value(atof(y->get_text()));
1252 if(event_caller == z)
1254 z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1255 track->automation->autos[AUTOMATION_PROJECTOR_Z],
1259 float zoom = atof(z->get_text());
1260 if(zoom > 10000) zoom = 10000;
1262 if(zoom < 0) zoom = 0;
1263 // if (zoom != atof(z->get_text()))
1265 z_auto->set_value(zoom);
1267 mwindow->gui->lock_window("CWindowProjectorGUI::handle_event");
1268 mwindow->gui->draw_overlays(1);
1269 mwindow->gui->unlock_window();
1275 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1279 void CWindowProjectorGUI::update()
1281 FloatAuto *x_auto = 0;
1282 FloatAuto *y_auto = 0;
1283 FloatAuto *z_auto = 0;
1284 Track *track = mwindow->cwindow->calculate_affected_track();
1288 mwindow->cwindow->calculate_affected_autos(&x_auto,
1299 x->update(x_auto->get_value());
1301 y->update(y_auto->get_value());
1303 z->update(z_auto->get_value());
1305 if( x_auto && y_auto && z_auto )
1307 t_smooth->check_toggle_state(x_auto, y_auto, z_auto);
1308 t_linear->check_toggle_state(x_auto, y_auto, z_auto);
1312 CWindowProjectorLeft::CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1313 : BC_Button(x, y, mwindow->theme->get_image_set("left_justify"))
1316 this->mwindow = mwindow;
1317 set_tooltip(_("Left justify"));
1319 int CWindowProjectorLeft::handle_event()
1321 FloatAuto *x_auto = 0;
1322 FloatAuto *z_auto = 0;
1323 Track *track = mwindow->cwindow->calculate_affected_track();
1326 mwindow->cwindow->calculate_affected_autos(&x_auto,
1335 if(x_auto && z_auto)
1337 mwindow->undo->update_undo_before(_("projector"), 0);
1338 x_auto->set_value( (double)track->track_w * z_auto->get_value() / 2 -
1339 (double)mwindow->edl->session->output_w / 2 );
1341 gui->update_preview();
1342 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1349 CWindowProjectorCenter::CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1350 : BC_Button(x, y, mwindow->theme->get_image_set("center_justify"))
1353 this->mwindow = mwindow;
1354 set_tooltip(_("Center horizontal"));
1356 int CWindowProjectorCenter::handle_event()
1358 FloatAuto *x_auto = 0;
1359 Track *track = mwindow->cwindow->calculate_affected_track();
1361 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1362 track->automation->autos[AUTOMATION_PROJECTOR_X],
1367 mwindow->undo->update_undo_before(_("projector"), 0);
1368 x_auto->set_value(0);
1370 gui->update_preview();
1371 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1378 CWindowProjectorRight::CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1379 : BC_Button(x, y, mwindow->theme->get_image_set("right_justify"))
1382 this->mwindow = mwindow;
1383 set_tooltip(_("Right justify"));
1385 int CWindowProjectorRight::handle_event()
1387 FloatAuto *x_auto = 0;
1388 FloatAuto *z_auto = 0;
1389 Track *track = mwindow->cwindow->calculate_affected_track();
1392 mwindow->cwindow->calculate_affected_autos(&x_auto,
1402 if(x_auto && z_auto)
1404 mwindow->undo->update_undo_before(_("projector"), 0);
1405 x_auto->set_value( -((double)track->track_w * z_auto->get_value() / 2 -
1406 (double)mwindow->edl->session->output_w / 2));
1408 gui->update_preview();
1409 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1416 CWindowProjectorTop::CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1417 : BC_Button(x, y, mwindow->theme->get_image_set("top_justify"))
1420 this->mwindow = mwindow;
1421 set_tooltip(_("Top justify"));
1423 int CWindowProjectorTop::handle_event()
1425 FloatAuto *y_auto = 0;
1426 FloatAuto *z_auto = 0;
1427 Track *track = mwindow->cwindow->calculate_affected_track();
1430 mwindow->cwindow->calculate_affected_autos(0,
1440 if(y_auto && z_auto)
1442 mwindow->undo->update_undo_before(_("projector"), 0);
1443 y_auto->set_value( (double)track->track_h * z_auto->get_value() / 2 -
1444 (double)mwindow->edl->session->output_h / 2 );
1446 gui->update_preview();
1447 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1454 CWindowProjectorMiddle::CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1455 : BC_Button(x, y, mwindow->theme->get_image_set("middle_justify"))
1458 this->mwindow = mwindow;
1459 set_tooltip(_("Center vertical"));
1461 int CWindowProjectorMiddle::handle_event()
1463 FloatAuto *y_auto = 0;
1464 Track *track = mwindow->cwindow->calculate_affected_track();
1466 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1467 track->automation->autos[AUTOMATION_PROJECTOR_Y], 1);
1471 mwindow->undo->update_undo_before(_("projector"), 0);
1472 y_auto->set_value(0);
1474 gui->update_preview();
1475 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1482 CWindowProjectorBottom::CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1483 : BC_Button(x, y, mwindow->theme->get_image_set("bottom_justify"))
1486 this->mwindow = mwindow;
1487 set_tooltip(_("Bottom justify"));
1489 int CWindowProjectorBottom::handle_event()
1491 FloatAuto *y_auto = 0;
1492 FloatAuto *z_auto = 0;
1493 Track *track = mwindow->cwindow->calculate_affected_track();
1496 mwindow->cwindow->calculate_affected_autos(0,
1506 if(y_auto && z_auto)
1508 mwindow->undo->update_undo_before(_("projector"), 0);
1509 y_auto->set_value( -((double)track->track_h * z_auto->get_value() / 2 -
1510 (double)mwindow->edl->session->output_h / 2));
1512 gui->update_preview();
1513 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1520 CWindowMaskMode::CWindowMaskMode(MWindow *mwindow,
1521 CWindowToolGUI *gui, int x, int y, const char *text)
1522 : BC_PopupMenu(x, y, 220, text, 1)
1524 this->mwindow = mwindow;
1528 void CWindowMaskMode::create_objects()
1530 add_item(new BC_MenuItem(mode_to_text(MASK_MULTIPLY_ALPHA)));
1531 add_item(new BC_MenuItem(mode_to_text(MASK_SUBTRACT_ALPHA)));
1534 char* CWindowMaskMode::mode_to_text(int mode)
1538 case MASK_MULTIPLY_ALPHA:
1539 return _("Multiply alpha");
1542 case MASK_SUBTRACT_ALPHA:
1543 return _("Subtract alpha");
1547 return _("Subtract alpha");
1550 int CWindowMaskMode::text_to_mode(char *text)
1552 if(!strcasecmp(text, _("Multiply alpha")))
1553 return MASK_MULTIPLY_ALPHA;
1555 if(!strcasecmp(text, _("Subtract alpha")))
1556 return MASK_SUBTRACT_ALPHA;
1558 return MASK_SUBTRACT_ALPHA;
1561 int CWindowMaskMode::handle_event()
1568 // Get existing keyframe
1569 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1572 mwindow->undo->update_undo_before(_("mask mode"), 0);
1573 #ifdef USE_KEYFRAME_SPANNING
1574 // Create temp keyframe
1575 MaskAuto temp_keyframe(mwindow->edl, autos);
1576 temp_keyframe.copy_data(keyframe);
1578 temp_keyframe.mode = text_to_mode(get_text());
1579 // Commit change to span of keyframes
1580 autos->update_parameter(&temp_keyframe);
1582 ((MaskAuto*)autos->default_auto)->mode =
1583 text_to_mode(get_text());
1585 mwindow->undo->update_undo_after(_("mask mode"), LOAD_AUTOMATION);
1588 //printf("CWindowMaskMode::handle_event 1\n");
1589 gui->update_preview();
1600 CWindowMaskDelete::CWindowMaskDelete(MWindow *mwindow,
1601 CWindowToolGUI *gui,
1604 : BC_GenericButton(x, y, _("Delete"))
1606 this->mwindow = mwindow;
1610 int CWindowMaskDelete::handle_event()
1617 int total_points = 0;
1619 // Get existing keyframe
1620 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1624 mwindow->undo->update_undo_before(_("mask delete"), 0);
1626 #ifdef USE_KEYFRAME_SPANNING
1627 // Create temp keyframe
1628 MaskAuto temp_keyframe(mwindow->edl, autos);
1629 temp_keyframe.copy_data(keyframe);
1631 SubMask *submask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
1632 for(int i = mwindow->cwindow->gui->affected_point;
1633 i < submask->points.total - 1;
1636 *submask->points.values[i] = *submask->points.values[i + 1];
1639 if(submask->points.total)
1641 submask->points.remove_object(
1642 submask->points.values[submask->points.total - 1]);
1644 total_points = submask->points.total;
1646 // Commit change to span of keyframes
1647 ((MaskAutos*)track->automation->autos[AUTOMATION_MASK])->update_parameter(&temp_keyframe);
1649 for(MaskAuto *current = (MaskAuto*)autos->default_auto;
1652 SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
1654 for(int i = mwindow->cwindow->gui->affected_point;
1655 i < submask->points.total - 1;
1658 *submask->points.values[i] = *submask->points.values[i + 1];
1661 if(submask->points.total)
1663 submask->points.remove_object(
1664 submask->points.values[submask->points.total - 1]);
1666 total_points = submask->points.total;
1668 if(current == (MaskAuto*)autos->default_auto)
1669 current = (MaskAuto*)autos->first;
1671 current = (MaskAuto*)NEXT;
1674 if( mwindow->cwindow->gui->affected_point >= total_points )
1675 mwindow->cwindow->gui->affected_point =
1676 total_points > 0 ? total_points-1 : 0;
1679 gui->update_preview();
1680 mwindow->undo->update_undo_after(_("mask delete"), LOAD_AUTOMATION);
1687 int CWindowMaskDelete::keypress_event()
1689 if(get_keypress() == BACKSPACE ||
1690 get_keypress() == DELETE)
1691 return handle_event();
1696 // CWindowMaskCycleNext::CWindowMaskCycleNext(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1697 // : BC_GenericButton(x, y, _("Cycle next"))
1699 // this->mwindow = mwindow;
1702 // int CWindowMaskCycleNext::handle_event()
1704 // MaskAuto *keyframe;
1705 // MaskAutos *autos;
1707 // MaskPoint *point;
1709 // ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1713 // // Should apply to all keyframes
1714 // if(keyframe && mask->points.total)
1716 // temp = mask->points.values[0];
1718 // for(int i = 0; i < mask->points.total - 1; i++)
1720 // mask->points.values[i] = mask->points.values[i + 1];
1722 // mask->points.values[mask->points.total - 1] = temp;
1724 // mwindow->cwindow->gui->affected_point--;
1725 // if(mwindow->cwindow->gui->affected_point < 0)
1726 // mwindow->cwindow->gui->affected_point = mask->points.total - 1;
1729 // gui->update_preview();
1735 // CWindowMaskCyclePrev::CWindowMaskCyclePrev(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1736 // : BC_GenericButton(x, y, _("Cycle prev"))
1738 // this->mwindow = mwindow;
1741 // int CWindowMaskCyclePrev::handle_event()
1743 // MaskAuto *keyframe;
1744 // MaskAutos *autos;
1746 // MaskPoint *point;
1748 // ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1750 // // Should apply to all keyframes
1752 // if(keyframe && mask->points.total)
1754 // temp = mask->points.values[mask->points.total - 1];
1756 // for(int i = mask->points.total - 1; i > 0; i--)
1758 // mask->points.values[i] = mask->points.values[i - 1];
1760 // mask->points.values[0] = temp;
1762 // mwindow->cwindow->gui->affected_point++;
1763 // if(mwindow->cwindow->gui->affected_point >= mask->points.total)
1764 // mwindow->cwindow->gui->affected_point = 0;
1767 // gui->update_preview();
1773 CWindowMaskNumber::CWindowMaskNumber(MWindow *mwindow,
1774 CWindowToolGUI *gui,
1777 : BC_TumbleTextBox(gui,
1778 (int64_t)mwindow->edl->session->cwindow_mask,
1780 (int64_t)SUBMASKS - 1,
1785 this->mwindow = mwindow;
1789 CWindowMaskNumber::~CWindowMaskNumber()
1793 int CWindowMaskNumber::handle_event()
1795 mwindow->edl->session->cwindow_mask = atol(get_text());
1797 gui->update_preview();
1802 CWindowMaskAffectedPoint::CWindowMaskAffectedPoint(MWindow *mwindow,
1803 CWindowToolGUI *gui, int x, int y)
1804 : BC_TumbleTextBox(gui,
1805 (int64_t)mwindow->cwindow->gui->affected_point,
1806 (int64_t)0, INT64_MAX, x, y, 100)
1808 this->mwindow = mwindow;
1812 CWindowMaskAffectedPoint::~CWindowMaskAffectedPoint()
1816 int CWindowMaskAffectedPoint::handle_event()
1818 int total_points = 0;
1819 int affected_point = atol(get_text());
1820 Track *track = mwindow->cwindow->calculate_affected_track();
1822 MaskAutos *autos = (MaskAutos*)track->automation->autos[AUTOMATION_MASK];
1823 MaskAuto *keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(autos, 0);
1825 SubMask *mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
1826 total_points = mask->points.size();
1829 int active_point = affected_point;
1830 if( affected_point >= total_points )
1831 affected_point = total_points - 1;
1832 else if( affected_point < 0 )
1834 if( active_point != affected_point )
1835 update((int64_t)affected_point);
1836 mwindow->cwindow->gui->affected_point = affected_point;
1838 gui->update_preview();
1846 CWindowMaskFeather::CWindowMaskFeather(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1847 : BC_TumbleTextBox(gui,
1855 this->mwindow = mwindow;
1858 CWindowMaskFeather::~CWindowMaskFeather()
1861 int CWindowMaskFeather::handle_event()
1868 #ifdef USE_KEYFRAME_SPANNING
1874 mwindow->undo->update_undo_before(_("mask feather"), this);
1876 // Get existing keyframe
1877 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe,
1878 mask, point, create_it);
1882 #ifdef USE_KEYFRAME_SPANNING
1883 // Create temp keyframe
1884 MaskAuto temp_keyframe(mwindow->edl, autos);
1885 temp_keyframe.copy_data(keyframe);
1887 temp_keyframe.feather = atof(get_text());
1888 // Commit change to span of keyframes
1889 autos->update_parameter(&temp_keyframe);
1891 keyframe->feather = atof(get_text());
1894 gui->update_preview();
1897 mwindow->undo->update_undo_after(_("mask feather"), LOAD_AUTOMATION);
1902 CWindowMaskValue::CWindowMaskValue(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1912 this->mwindow = mwindow;
1916 CWindowMaskValue::~CWindowMaskValue()
1920 int CWindowMaskValue::handle_event()
1927 #ifdef USE_KEYFRAME_SPANNING
1933 mwindow->undo->update_undo_before(_("mask value"), this);
1934 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe,
1935 mask, point, create_it);
1939 #ifdef USE_KEYFRAME_SPANNING
1940 // Create temp keyframe
1941 MaskAuto temp_keyframe(mwindow->edl, autos);
1942 temp_keyframe.copy_data(keyframe);
1944 temp_keyframe.value = get_value();
1945 // Commit change to span of keyframes
1946 autos->update_parameter(&temp_keyframe);
1948 keyframe->value = get_value();
1952 gui->update_preview();
1953 mwindow->undo->update_undo_after(_("mask value"), LOAD_AUTOMATION);
1958 CWindowMaskBeforePlugins::CWindowMaskBeforePlugins(CWindowToolGUI *gui, int x, int y)
1962 _("Apply mask before plugins"))
1967 int CWindowMaskBeforePlugins::handle_event()
1974 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 1);
1977 keyframe->apply_before_plugins = get_value();
1978 gui->update_preview();
1984 CWindowDisableOpenGLMasking::CWindowDisableOpenGLMasking(CWindowToolGUI *gui, int x, int y)
1985 : BC_CheckBox(x, y, 1, _("Disable OpenGL masking"))
1990 int CWindowDisableOpenGLMasking::handle_event()
1997 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 1);
2000 keyframe->disable_opengl_masking = get_value();
2001 gui->update_preview();
2014 CWindowMaskGUI::CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread)
2015 : CWindowToolGUI(mwindow,
2017 _(PROGRAM_NAME ": Mask"),
2021 this->mwindow = mwindow;
2022 this->thread = thread;
2027 CWindowMaskGUI::~CWindowMaskGUI()
2029 lock_window("CWindowMaskGUI::~CWindowMaskGUI");
2031 delete active_point;
2036 void CWindowMaskGUI::create_objects()
2038 int x = 10, y = 10, margin = mwindow->theme->widget_border;
2039 //MaskAuto *keyframe = 0;
2040 //Track *track = mwindow->cwindow->calculate_affected_track();
2042 // keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->autos[AUTOMATION_MASK], 0);
2044 lock_window("CWindowMaskGUI::create_objects");
2046 add_subwindow(title = new BC_Title(x, y, _("Mode:")));
2047 add_subwindow(mode = new CWindowMaskMode(mwindow,
2048 this, x + title->get_w() + margin, y, ""));
2049 mode->create_objects();
2050 y += mode->get_h() + margin;
2051 add_subwindow(title = new BC_Title(x, y, _("Value:")));
2052 add_subwindow(value = new CWindowMaskValue(mwindow, this, x + title->get_w() + margin, y));
2053 y += value->get_h() + margin;
2054 add_subwindow(delete_point = new CWindowMaskDelete(mwindow, this, x, y));
2055 int x1 = x + delete_point->get_w() + 2*margin;
2056 add_subwindow(title = new BC_Title(x1, y, _("Point:")));
2057 x1 += title->get_w() + margin;
2058 active_point = new CWindowMaskAffectedPoint(mwindow, this, x1, y);
2059 active_point->create_objects();
2060 y += delete_point->get_h() + margin;
2061 add_subwindow(title = new BC_Title(x, y, _("Mask number:")));
2062 number = new CWindowMaskNumber(mwindow,
2063 this, x + title->get_w() + margin, y);
2064 number->create_objects();
2065 y += number->get_h() + margin;
2066 add_subwindow(title = new BC_Title(x, y, _("Feather:")));
2067 feather = new CWindowMaskFeather(mwindow,
2068 this, x + title->get_w() + margin, y);
2069 feather->create_objects();
2070 y += feather->get_h() + margin;
2071 add_subwindow(title = new BC_Title(x, y, "X:"));
2072 x += title->get_w() + margin;
2073 this->x = new CWindowCoord(this, x, y, (float)0.0);
2074 this->x->create_objects();
2075 x += this->x->get_w() + margin;
2076 add_subwindow(title = new BC_Title(x, y, "Y:"));
2077 x += title->get_w() + margin;
2078 this->y = new CWindowCoord(this, x, y, (float)0.0);
2079 this->y->create_objects();
2082 y += this->y->get_h() + margin;
2083 add_subwindow(title = new BC_Title(x, y, _("Press Shift to move an end point")));
2084 y += title->get_h() + margin;
2085 add_subwindow(title = new BC_Title(x, y, _("Press Ctrl to move a control point")));
2086 y += title->get_h() + margin;
2087 add_subwindow(title = new BC_Title(x, y, _("Press Alt to translate the mask")));
2090 add_subwindow(this->apply_before_plugins = new CWindowMaskBeforePlugins(this, 10, y));
2091 y += this->apply_before_plugins->get_h() + margin;
2092 add_subwindow(this->disable_opengl_masking = new CWindowDisableOpenGLMasking(this, 10, y));
2098 void CWindowMaskGUI::get_keyframe(Track* &track,
2100 MaskAuto* &keyframe,
2108 track = mwindow->cwindow->calculate_affected_track();
2111 autos = (MaskAutos*)track->automation->autos[AUTOMATION_MASK];
2112 keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(
2118 mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
2125 if(mwindow->cwindow->gui->affected_point < mask->points.total &&
2126 mwindow->cwindow->gui->affected_point >= 0)
2128 point = mask->points.values[mwindow->cwindow->gui->affected_point];
2133 void CWindowMaskGUI::update()
2140 //printf("CWindowMaskGUI::update 1\n");
2141 get_keyframe(track, autos, keyframe, mask, point, 0);
2143 double position = mwindow->edl->local_session->get_selectionstart(1);
2144 position = mwindow->edl->align_to_frame(position, 0);
2147 int64_t position_i = track->to_units(position, 0);
2151 x->update(point->x);
2152 y->update(point->y);
2157 feather->update((int64_t)autos->get_feather(position_i, PLAY_FORWARD));
2158 value->update((int64_t)autos->get_value(position_i, PLAY_FORWARD));
2159 apply_before_plugins->update((int64_t)keyframe->apply_before_plugins);
2160 disable_opengl_masking->update((int64_t)keyframe->disable_opengl_masking);
2164 //printf("CWindowMaskGUI::update 1\n");
2165 active_point->update((int64_t)mwindow->cwindow->gui->affected_point);
2166 number->update((int64_t)mwindow->edl->session->cwindow_mask);
2168 //printf("CWindowMaskGUI::update 1\n");
2171 #ifdef USE_KEYFRAME_SPANNING
2173 CWindowMaskMode::mode_to_text(keyframe->mode));
2176 CWindowMaskMode::mode_to_text(((MaskAuto*)autos->default_auto)->mode));
2179 //printf("CWindowMaskGUI::update 2\n");
2182 void CWindowMaskGUI::handle_event()
2189 get_keyframe(track, autos, keyframe, mask, point, 0);
2191 mwindow->undo->update_undo_before(_("mask point"), this);
2195 #ifdef USE_KEYFRAME_SPANNING
2196 // Create temp keyframe
2197 MaskAuto temp_keyframe(mwindow->edl, autos);
2198 temp_keyframe.copy_data(keyframe);
2199 // Get affected point in temp keyframe
2200 mask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
2201 if(mwindow->cwindow->gui->affected_point < mask->points.total &&
2202 mwindow->cwindow->gui->affected_point >= 0)
2204 point = mask->points.values[mwindow->cwindow->gui->affected_point];
2209 point->x = atof(x->get_text());
2210 point->y = atof(y->get_text());
2211 // Commit to spanned keyframes
2212 autos->update_parameter(&temp_keyframe);
2215 point->x = atof(x->get_text());
2216 point->y = atof(y->get_text());
2221 mwindow->undo->update_undo_after(_("mask point"), LOAD_AUTOMATION);
2224 void CWindowMaskGUI::update_preview()
2226 mwindow->restart_brender();
2227 mwindow->sync_parameters(CHANGE_PARAMS);
2228 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
2232 mwindow->cwindow->gui->lock_window("CWindowMaskGUI::update_preview");
2233 mwindow->cwindow->gui->canvas->draw_refresh();
2234 mwindow->cwindow->gui->unlock_window();
2238 CWindowRulerGUI::CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread)
2239 : CWindowToolGUI(mwindow,
2241 _(PROGRAM_NAME ": Ruler"),
2247 CWindowRulerGUI::~CWindowRulerGUI()
2251 void CWindowRulerGUI::create_objects()
2256 lock_window("CWindowRulerGUI::create_objects");
2257 add_subwindow(title = new BC_Title(x, y, _("Current:")));
2258 add_subwindow(current = new BC_Title(x + title->get_w() + 10, y, ""));
2259 y += title->get_h() + 5;
2261 add_subwindow(title = new BC_Title(x, y, _("Point 1:")));
2262 add_subwindow(point1 = new BC_Title(x + title->get_w() + 10, y, ""));
2263 y += title->get_h() + 5;
2265 add_subwindow(title = new BC_Title(x, y, _("Point 2:")));
2266 add_subwindow(point2 = new BC_Title(x + title->get_w() + 10, y, ""));
2267 y += title->get_h() + 5;
2269 add_subwindow(title = new BC_Title(x, y, _("Distance:")));
2270 add_subwindow(distance = new BC_Title(x + title->get_w() + 10, y, ""));
2271 y += title->get_h() + 5;
2272 add_subwindow(title = new BC_Title(x, y, _("Angle:")));
2273 add_subwindow(angle = new BC_Title(x + title->get_w() + 10, y, ""));
2274 y += title->get_h() + 10;
2275 char string[BCTEXTLEN];
2276 sprintf(string, _("Press Ctrl to lock ruler to the\nnearest 45%c angle."), 0xb0);
2277 add_subwindow(title = new BC_Title(x,
2280 y += title->get_h() + 10;
2281 sprintf(string, _("Press Alt to translate the ruler."));
2282 add_subwindow(title = new BC_Title(x,
2289 void CWindowRulerGUI::update()
2291 double distance_value =
2292 sqrt(SQR(mwindow->edl->session->ruler_x2 - mwindow->edl->session->ruler_x1) +
2293 SQR(mwindow->edl->session->ruler_y2 - mwindow->edl->session->ruler_y1));
2294 double angle_value = atan((mwindow->edl->session->ruler_y2 - mwindow->edl->session->ruler_y1) /
2295 (mwindow->edl->session->ruler_x2 - mwindow->edl->session->ruler_x1)) *
2300 if(EQUIV(distance_value, 0.0))
2310 char string[BCTEXTLEN];
2311 sprintf(string, "%d, %d",
2312 mwindow->session->cwindow_output_x,
2313 mwindow->session->cwindow_output_y);
2314 current->update(string);
2315 sprintf(string, "%.0f, %.0f",
2316 mwindow->edl->session->ruler_x1,
2317 mwindow->edl->session->ruler_y1);
2318 point1->update(string);
2319 sprintf(string, "%.0f, %.0f",
2320 mwindow->edl->session->ruler_x2,
2321 mwindow->edl->session->ruler_y2);
2322 point2->update(string);
2324 sprintf(string, _("%0.01f pixels"), distance_value);
2325 distance->update(string);
2326 sprintf(string, "%0.02f %c", angle_value, 0xb0);
2327 angle->update(string);
2330 void CWindowRulerGUI::handle_event()