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 _("\"smooth\" Curve on current Camera Keyframes")
594 const _CVD Camera_Crv_Linear =
598 _("\"linear\" Curve on current Camera Keyframes")
600 const _CVD Projector_Crv_Smooth =
604 _("\"smooth\" Curve on current Projector Keyframes")
606 const _CVD Projector_Crv_Linear =
610 _("\"linear\" Curve on current Projector Keyframes")
614 // Implementation Class für Keyframe Curve Mode buttons
616 // This button reflects the state of the "current" keyframe
617 // (the nearest keyframe on the left) for all three automation
618 // lines together. Clicking on this button (re)sets the curve
619 // mode for the three "current" keyframes simultanously, but
620 // never creates a new keyframe.
622 class CWindowCurveToggle : public BC_Toggle
625 CWindowCurveToggle(_CVD mode, MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
626 void check_toggle_state(FloatAuto *x, FloatAuto *y, FloatAuto *z);
635 CWindowCurveToggle::CWindowCurveToggle(_CVD mode, MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
636 : BC_Toggle(x, y, mwindow->theme->get_image_set(mode.icon_id), false),
640 this->mwindow = mwindow;
641 set_tooltip(cfg.tooltip);
644 void CWindowCurveToggle::check_toggle_state(FloatAuto *x, FloatAuto *y, FloatAuto *z)
646 // the toggle state is only set to ON if all
647 // three automation lines have the same curve mode.
648 // For mixed states the toggle stays off.
649 set_value( x->curve_mode == this->cfg.mode &&
650 y->curve_mode == this->cfg.mode &&
651 z->curve_mode == this->cfg.mode
652 ,true // redraw to show new state
656 int CWindowCurveToggle::handle_event()
658 FloatAuto *x=0, *y=0, *z=0;
659 Track *track = mwindow->cwindow->calculate_affected_track();
662 { mwindow->cwindow->calculate_affected_autos(&x, &y, &z,
663 track, cfg.use_camera, 0,0,0); // don't create new keyframe
665 if(x) x->change_curve_mode(cfg.mode);
666 if(y) y->change_curve_mode(cfg.mode);
667 if(z) z->change_curve_mode(cfg.mode);
670 gui->update_preview();
677 CWindowCameraGUI::CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread)
678 : CWindowToolGUI(mwindow,
680 _(PROGRAM_NAME ": Camera"),
685 CWindowCameraGUI::~CWindowCameraGUI()
689 void CWindowCameraGUI::create_objects()
691 int x = 10, y = 10, x1;
692 Track *track = mwindow->cwindow->calculate_affected_track();
693 FloatAuto *x_auto = 0;
694 FloatAuto *y_auto = 0;
695 FloatAuto *z_auto = 0;
699 lock_window("CWindowCameraGUI::create_objects");
702 mwindow->cwindow->calculate_affected_autos(&x_auto,
703 &y_auto, &z_auto, track, 1, 0, 0, 0);
706 add_subwindow(title = new BC_Title(x, y, "X:"));
708 this->x = new CWindowCoord(this, x, y,
709 x_auto ? x_auto->get_value() : (float)0);
710 this->x->create_objects();
715 add_subwindow(title = new BC_Title(x, y, "Y:"));
717 this->y = new CWindowCoord(this, x, y,
718 y_auto ? y_auto->get_value() : (float)0);
719 this->y->create_objects();
722 add_subwindow(title = new BC_Title(x, y, "Z:"));
724 this->z = new CWindowCoord(this, x, y,
725 z_auto ? z_auto->get_value() : (float)1);
726 this->z->create_objects();
727 this->z->set_increment(0.01);
731 add_subwindow(button = new CWindowCameraLeft(mwindow, this, x1, y));
732 x1 += button->get_w();
733 add_subwindow(button = new CWindowCameraCenter(mwindow, this, x1, y));
734 x1 += button->get_w();
735 add_subwindow(button = new CWindowCameraRight(mwindow, this, x1, y));
737 y += button->get_h();
739 add_subwindow(button = new CWindowCameraTop(mwindow, this, x1, y));
740 x1 += button->get_w();
741 add_subwindow(button = new CWindowCameraMiddle(mwindow, this, x1, y));
742 x1 += button->get_w();
743 add_subwindow(button = new CWindowCameraBottom(mwindow, this, x1, y));
744 // additional Buttons to control the curve mode of the "current" keyframe
745 x1 += button->get_w() + 15;
746 add_subwindow(this->t_smooth = new CWindowCurveToggle(Camera_Crv_Smooth, mwindow, this, x1, y));
747 x1 += button->get_w();
748 add_subwindow(this->t_linear = new CWindowCurveToggle(Camera_Crv_Linear, mwindow, this, x1, y));
750 // fill in current auto keyframe values, set toggle states.
755 void CWindowCameraGUI::update_preview()
757 mwindow->restart_brender();
758 mwindow->sync_parameters(CHANGE_PARAMS);
760 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
764 mwindow->gui->lock_window("CWindowCameraGUI::update_preview");
765 mwindow->gui->draw_overlays(1);
766 mwindow->gui->unlock_window();
767 mwindow->cwindow->gui->lock_window("CWindowCameraGUI::update_preview");
768 mwindow->cwindow->gui->canvas->draw_refresh();
769 mwindow->cwindow->gui->unlock_window();
773 void CWindowCameraGUI::handle_event()
775 FloatAuto *x_auto = 0;
776 FloatAuto *y_auto = 0;
777 FloatAuto *z_auto = 0;
778 Track *track = mwindow->cwindow->calculate_affected_track();
781 mwindow->undo->update_undo_before(_("camera"), this);
782 if(event_caller == x)
784 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
785 track->automation->autos[AUTOMATION_CAMERA_X],
789 x_auto->set_value(atof(x->get_text()));
795 if(event_caller == y)
797 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
798 track->automation->autos[AUTOMATION_CAMERA_Y],
802 y_auto->set_value(atof(y->get_text()));
808 if(event_caller == z)
810 z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
811 track->automation->autos[AUTOMATION_CAMERA_Z],
815 float zoom = atof(z->get_text());
816 if(zoom > 10) zoom = 10;
818 if(zoom < 0) zoom = 0;
819 // Doesn't allow user to enter from scratch
820 // if(zoom != atof(z->get_text()))
823 z_auto->set_value(zoom);
824 mwindow->gui->lock_window("CWindowCameraGUI::handle_event");
825 mwindow->gui->draw_overlays(1);
826 mwindow->gui->unlock_window();
832 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
836 void CWindowCameraGUI::update()
838 FloatAuto *x_auto = 0;
839 FloatAuto *y_auto = 0;
840 FloatAuto *z_auto = 0;
841 Track *track = mwindow->cwindow->calculate_affected_track();
845 mwindow->cwindow->calculate_affected_autos(&x_auto,
856 x->update(x_auto->get_value());
858 y->update(y_auto->get_value());
860 z->update(z_auto->get_value());
862 if( x_auto && y_auto && z_auto )
864 t_smooth->check_toggle_state(x_auto, y_auto, z_auto);
865 t_linear->check_toggle_state(x_auto, y_auto, z_auto);
872 CWindowCameraLeft::CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
873 : BC_Button(x, y, mwindow->theme->get_image_set("left_justify"))
876 this->mwindow = mwindow;
877 set_tooltip(_("Left justify"));
879 int CWindowCameraLeft::handle_event()
881 FloatAuto *x_auto = 0;
882 FloatAuto *z_auto = 0;
883 Track *track = mwindow->cwindow->calculate_affected_track();
886 mwindow->cwindow->calculate_affected_autos(&x_auto,
899 track->get_source_dimensions(
900 mwindow->edl->local_session->get_selectionstart(1),
906 mwindow->undo->update_undo_before(_("camera"), 0);
908 (double)track->track_w / z_auto->get_value() / 2 -
910 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
912 gui->update_preview();
920 CWindowCameraCenter::CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
921 : BC_Button(x, y, mwindow->theme->get_image_set("center_justify"))
924 this->mwindow = mwindow;
925 set_tooltip(_("Center horizontal"));
927 int CWindowCameraCenter::handle_event()
929 FloatAuto *x_auto = 0;
930 Track *track = mwindow->cwindow->calculate_affected_track();
932 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
933 track->automation->autos[AUTOMATION_CAMERA_X],
938 mwindow->undo->update_undo_before(_("camera"), 0);
939 x_auto->set_value(0);
941 gui->update_preview();
942 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
949 CWindowCameraRight::CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
950 : BC_Button(x, y, mwindow->theme->get_image_set("right_justify"))
953 this->mwindow = mwindow;
954 set_tooltip(_("Right justify"));
956 int CWindowCameraRight::handle_event()
958 FloatAuto *x_auto = 0;
959 FloatAuto *z_auto = 0;
960 Track *track = mwindow->cwindow->calculate_affected_track();
963 mwindow->cwindow->calculate_affected_autos(&x_auto,
976 track->get_source_dimensions(
977 mwindow->edl->local_session->get_selectionstart(1),
983 mwindow->undo->update_undo_before(_("camera"), 0);
984 x_auto->set_value( -((double)track->track_w / z_auto->get_value() / 2 -
987 gui->update_preview();
988 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
996 CWindowCameraTop::CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
997 : BC_Button(x, y, mwindow->theme->get_image_set("top_justify"))
1000 this->mwindow = mwindow;
1001 set_tooltip(_("Top justify"));
1003 int CWindowCameraTop::handle_event()
1005 FloatAuto *y_auto = 0;
1006 FloatAuto *z_auto = 0;
1007 Track *track = mwindow->cwindow->calculate_affected_track();
1010 mwindow->cwindow->calculate_affected_autos(0,
1020 if(y_auto && z_auto)
1023 track->get_source_dimensions(
1024 mwindow->edl->local_session->get_selectionstart(1),
1030 mwindow->undo->update_undo_before(_("camera"), 0);
1031 y_auto->set_value((double)track->track_h / z_auto->get_value() / 2 -
1034 gui->update_preview();
1035 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1043 CWindowCameraMiddle::CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1044 : BC_Button(x, y, mwindow->theme->get_image_set("middle_justify"))
1047 this->mwindow = mwindow;
1048 set_tooltip(_("Center vertical"));
1050 int CWindowCameraMiddle::handle_event()
1052 FloatAuto *y_auto = 0;
1053 Track *track = mwindow->cwindow->calculate_affected_track();
1055 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1056 track->automation->autos[AUTOMATION_CAMERA_Y], 1);
1060 mwindow->undo->update_undo_before(_("camera"), 0);
1061 y_auto->set_value(0);
1063 gui->update_preview();
1064 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1071 CWindowCameraBottom::CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1072 : BC_Button(x, y, mwindow->theme->get_image_set("bottom_justify"))
1075 this->mwindow = mwindow;
1076 set_tooltip(_("Bottom justify"));
1078 int CWindowCameraBottom::handle_event()
1080 FloatAuto *y_auto = 0;
1081 FloatAuto *z_auto = 0;
1082 Track *track = mwindow->cwindow->calculate_affected_track();
1085 mwindow->cwindow->calculate_affected_autos(0,
1095 if(y_auto && z_auto)
1098 track->get_source_dimensions(
1099 mwindow->edl->local_session->get_selectionstart(1),
1105 mwindow->undo->update_undo_before(_("camera"), 0);
1106 y_auto->set_value(-((double)track->track_h / z_auto->get_value() / 2 -
1109 gui->update_preview();
1110 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1118 CWindowProjectorGUI::CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread)
1119 : CWindowToolGUI(mwindow,
1121 _(PROGRAM_NAME ": Projector"),
1126 CWindowProjectorGUI::~CWindowProjectorGUI()
1129 void CWindowProjectorGUI::create_objects()
1131 int x = 10, y = 10, x1;
1132 Track *track = mwindow->cwindow->calculate_affected_track();
1133 FloatAuto *x_auto = 0;
1134 FloatAuto *y_auto = 0;
1135 FloatAuto *z_auto = 0;
1139 lock_window("CWindowProjectorGUI::create_objects");
1142 mwindow->cwindow->calculate_affected_autos(&x_auto,
1152 add_subwindow(title = new BC_Title(x, y, "X:"));
1153 x += title->get_w();
1154 this->x = new CWindowCoord(this, x, y,
1155 x_auto ? x_auto->get_value() : (float)0);
1156 this->x->create_objects();
1159 add_subwindow(title = new BC_Title(x, y, "Y:"));
1160 x += title->get_w();
1161 this->y = new CWindowCoord(this, x, y,
1162 y_auto ? y_auto->get_value() : (float)0);
1163 this->y->create_objects();
1166 add_subwindow(title = new BC_Title(x, y, "Z:"));
1167 x += title->get_w();
1168 this->z = new CWindowCoord(this, x, y,
1169 z_auto ? z_auto->get_value() : (float)1);
1170 this->z->create_objects();
1171 this->z->set_increment(0.01);
1175 add_subwindow(button = new CWindowProjectorLeft(mwindow, this, x1, y));
1176 x1 += button->get_w();
1177 add_subwindow(button = new CWindowProjectorCenter(mwindow, this, x1, y));
1178 x1 += button->get_w();
1179 add_subwindow(button = new CWindowProjectorRight(mwindow, this, x1, y));
1181 y += button->get_h();
1183 add_subwindow(button = new CWindowProjectorTop(mwindow, this, x1, y));
1184 x1 += button->get_w();
1185 add_subwindow(button = new CWindowProjectorMiddle(mwindow, this, x1, y));
1186 x1 += button->get_w();
1187 add_subwindow(button = new CWindowProjectorBottom(mwindow, this, x1, y));
1189 // additional Buttons to control the curve mode of the "current" keyframe
1190 x1 += button->get_w() + 15;
1191 add_subwindow(this->t_smooth = new CWindowCurveToggle(Projector_Crv_Smooth, mwindow, this, x1, y));
1192 x1 += button->get_w();
1193 add_subwindow(this->t_linear = new CWindowCurveToggle(Projector_Crv_Linear, mwindow, this, x1, y));
1195 // fill in current auto keyframe values, set toggle states.
1200 void CWindowProjectorGUI::update_preview()
1202 mwindow->restart_brender();
1203 mwindow->sync_parameters(CHANGE_PARAMS);
1204 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1208 // TODO: really need to lock the main window??
1209 mwindow->gui->lock_window("CWindowProjectorGUI::update_preview");
1210 mwindow->gui->draw_overlays(1);
1211 mwindow->gui->unlock_window();
1212 mwindow->cwindow->gui->lock_window("CWindowProjectorGUI::update_preview");
1213 mwindow->cwindow->gui->canvas->draw_refresh();
1214 mwindow->cwindow->gui->unlock_window();
1217 void CWindowProjectorGUI::handle_event()
1219 FloatAuto *x_auto = 0;
1220 FloatAuto *y_auto = 0;
1221 FloatAuto *z_auto = 0;
1222 Track *track = mwindow->cwindow->calculate_affected_track();
1226 mwindow->undo->update_undo_before(_("projector"), this);
1227 if(event_caller == x)
1229 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1230 track->automation->autos[AUTOMATION_PROJECTOR_X],
1234 x_auto->set_value(atof(x->get_text()));
1240 if(event_caller == y)
1242 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1243 track->automation->autos[AUTOMATION_PROJECTOR_Y],
1247 y_auto->set_value(atof(y->get_text()));
1253 if(event_caller == z)
1255 z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1256 track->automation->autos[AUTOMATION_PROJECTOR_Z],
1260 float zoom = atof(z->get_text());
1261 if(zoom > 10000) zoom = 10000;
1263 if(zoom < 0) zoom = 0;
1264 // if (zoom != atof(z->get_text()))
1266 z_auto->set_value(zoom);
1268 mwindow->gui->lock_window("CWindowProjectorGUI::handle_event");
1269 mwindow->gui->draw_overlays(1);
1270 mwindow->gui->unlock_window();
1276 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1280 void CWindowProjectorGUI::update()
1282 FloatAuto *x_auto = 0;
1283 FloatAuto *y_auto = 0;
1284 FloatAuto *z_auto = 0;
1285 Track *track = mwindow->cwindow->calculate_affected_track();
1289 mwindow->cwindow->calculate_affected_autos(&x_auto,
1300 x->update(x_auto->get_value());
1302 y->update(y_auto->get_value());
1304 z->update(z_auto->get_value());
1306 if( x_auto && y_auto && z_auto )
1308 t_smooth->check_toggle_state(x_auto, y_auto, z_auto);
1309 t_linear->check_toggle_state(x_auto, y_auto, z_auto);
1313 CWindowProjectorLeft::CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1314 : BC_Button(x, y, mwindow->theme->get_image_set("left_justify"))
1317 this->mwindow = mwindow;
1318 set_tooltip(_("Left justify"));
1320 int CWindowProjectorLeft::handle_event()
1322 FloatAuto *x_auto = 0;
1323 FloatAuto *z_auto = 0;
1324 Track *track = mwindow->cwindow->calculate_affected_track();
1327 mwindow->cwindow->calculate_affected_autos(&x_auto,
1336 if(x_auto && z_auto)
1338 mwindow->undo->update_undo_before(_("projector"), 0);
1339 x_auto->set_value( (double)track->track_w * z_auto->get_value() / 2 -
1340 (double)mwindow->edl->session->output_w / 2 );
1342 gui->update_preview();
1343 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1350 CWindowProjectorCenter::CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1351 : BC_Button(x, y, mwindow->theme->get_image_set("center_justify"))
1354 this->mwindow = mwindow;
1355 set_tooltip(_("Center horizontal"));
1357 int CWindowProjectorCenter::handle_event()
1359 FloatAuto *x_auto = 0;
1360 Track *track = mwindow->cwindow->calculate_affected_track();
1362 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1363 track->automation->autos[AUTOMATION_PROJECTOR_X],
1368 mwindow->undo->update_undo_before(_("projector"), 0);
1369 x_auto->set_value(0);
1371 gui->update_preview();
1372 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1379 CWindowProjectorRight::CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1380 : BC_Button(x, y, mwindow->theme->get_image_set("right_justify"))
1383 this->mwindow = mwindow;
1384 set_tooltip(_("Right justify"));
1386 int CWindowProjectorRight::handle_event()
1388 FloatAuto *x_auto = 0;
1389 FloatAuto *z_auto = 0;
1390 Track *track = mwindow->cwindow->calculate_affected_track();
1393 mwindow->cwindow->calculate_affected_autos(&x_auto,
1403 if(x_auto && z_auto)
1405 mwindow->undo->update_undo_before(_("projector"), 0);
1406 x_auto->set_value( -((double)track->track_w * z_auto->get_value() / 2 -
1407 (double)mwindow->edl->session->output_w / 2));
1409 gui->update_preview();
1410 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1417 CWindowProjectorTop::CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1418 : BC_Button(x, y, mwindow->theme->get_image_set("top_justify"))
1421 this->mwindow = mwindow;
1422 set_tooltip(_("Top justify"));
1424 int CWindowProjectorTop::handle_event()
1426 FloatAuto *y_auto = 0;
1427 FloatAuto *z_auto = 0;
1428 Track *track = mwindow->cwindow->calculate_affected_track();
1431 mwindow->cwindow->calculate_affected_autos(0,
1441 if(y_auto && z_auto)
1443 mwindow->undo->update_undo_before(_("projector"), 0);
1444 y_auto->set_value( (double)track->track_h * z_auto->get_value() / 2 -
1445 (double)mwindow->edl->session->output_h / 2 );
1447 gui->update_preview();
1448 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1455 CWindowProjectorMiddle::CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1456 : BC_Button(x, y, mwindow->theme->get_image_set("middle_justify"))
1459 this->mwindow = mwindow;
1460 set_tooltip(_("Center vertical"));
1462 int CWindowProjectorMiddle::handle_event()
1464 FloatAuto *y_auto = 0;
1465 Track *track = mwindow->cwindow->calculate_affected_track();
1467 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1468 track->automation->autos[AUTOMATION_PROJECTOR_Y], 1);
1472 mwindow->undo->update_undo_before(_("projector"), 0);
1473 y_auto->set_value(0);
1475 gui->update_preview();
1476 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1483 CWindowProjectorBottom::CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1484 : BC_Button(x, y, mwindow->theme->get_image_set("bottom_justify"))
1487 this->mwindow = mwindow;
1488 set_tooltip(_("Bottom justify"));
1490 int CWindowProjectorBottom::handle_event()
1492 FloatAuto *y_auto = 0;
1493 FloatAuto *z_auto = 0;
1494 Track *track = mwindow->cwindow->calculate_affected_track();
1497 mwindow->cwindow->calculate_affected_autos(0,
1507 if(y_auto && z_auto)
1509 mwindow->undo->update_undo_before(_("projector"), 0);
1510 y_auto->set_value( -((double)track->track_h * z_auto->get_value() / 2 -
1511 (double)mwindow->edl->session->output_h / 2));
1513 gui->update_preview();
1514 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1521 CWindowMaskMode::CWindowMaskMode(MWindow *mwindow,
1522 CWindowToolGUI *gui, int x, int y, const char *text)
1523 : BC_PopupMenu(x, y, 220, text, 1)
1525 this->mwindow = mwindow;
1529 void CWindowMaskMode::create_objects()
1531 add_item(new BC_MenuItem(mode_to_text(MASK_MULTIPLY_ALPHA)));
1532 add_item(new BC_MenuItem(mode_to_text(MASK_SUBTRACT_ALPHA)));
1535 char* CWindowMaskMode::mode_to_text(int mode)
1539 case MASK_MULTIPLY_ALPHA:
1540 return _("Multiply alpha");
1543 case MASK_SUBTRACT_ALPHA:
1544 return _("Subtract alpha");
1548 return _("Subtract alpha");
1551 int CWindowMaskMode::text_to_mode(char *text)
1553 if(!strcasecmp(text, _("Multiply alpha")))
1554 return MASK_MULTIPLY_ALPHA;
1556 if(!strcasecmp(text, _("Subtract alpha")))
1557 return MASK_SUBTRACT_ALPHA;
1559 return MASK_SUBTRACT_ALPHA;
1562 int CWindowMaskMode::handle_event()
1569 // Get existing keyframe
1570 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1573 mwindow->undo->update_undo_before(_("mask mode"), 0);
1574 #ifdef USE_KEYFRAME_SPANNING
1575 // Create temp keyframe
1576 MaskAuto temp_keyframe(mwindow->edl, autos);
1577 temp_keyframe.copy_data(keyframe);
1579 temp_keyframe.mode = text_to_mode(get_text());
1580 // Commit change to span of keyframes
1581 autos->update_parameter(&temp_keyframe);
1583 ((MaskAuto*)autos->default_auto)->mode =
1584 text_to_mode(get_text());
1586 mwindow->undo->update_undo_after(_("mask mode"), LOAD_AUTOMATION);
1589 //printf("CWindowMaskMode::handle_event 1\n");
1590 gui->update_preview();
1601 CWindowMaskDelete::CWindowMaskDelete(MWindow *mwindow,
1602 CWindowToolGUI *gui,
1605 : BC_GenericButton(x, y, _("Delete"))
1607 this->mwindow = mwindow;
1611 int CWindowMaskDelete::handle_event()
1618 int total_points = 0;
1620 // Get existing keyframe
1621 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1625 mwindow->undo->update_undo_before(_("mask delete"), 0);
1627 #ifdef USE_KEYFRAME_SPANNING
1628 // Create temp keyframe
1629 MaskAuto temp_keyframe(mwindow->edl, autos);
1630 temp_keyframe.copy_data(keyframe);
1632 SubMask *submask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
1633 for(int i = mwindow->cwindow->gui->affected_point;
1634 i < submask->points.total - 1;
1637 *submask->points.values[i] = *submask->points.values[i + 1];
1640 if(submask->points.total)
1642 submask->points.remove_object(
1643 submask->points.values[submask->points.total - 1]);
1645 total_points = submask->points.total;
1647 // Commit change to span of keyframes
1648 ((MaskAutos*)track->automation->autos[AUTOMATION_MASK])->update_parameter(&temp_keyframe);
1650 for(MaskAuto *current = (MaskAuto*)autos->default_auto;
1653 SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
1655 for(int i = mwindow->cwindow->gui->affected_point;
1656 i < submask->points.total - 1;
1659 *submask->points.values[i] = *submask->points.values[i + 1];
1662 if(submask->points.total)
1664 submask->points.remove_object(
1665 submask->points.values[submask->points.total - 1]);
1667 total_points = submask->points.total;
1669 if(current == (MaskAuto*)autos->default_auto)
1670 current = (MaskAuto*)autos->first;
1672 current = (MaskAuto*)NEXT;
1675 if( mwindow->cwindow->gui->affected_point >= total_points )
1676 mwindow->cwindow->gui->affected_point =
1677 total_points > 0 ? total_points-1 : 0;
1680 gui->update_preview();
1681 mwindow->undo->update_undo_after(_("mask delete"), LOAD_AUTOMATION);
1688 int CWindowMaskDelete::keypress_event()
1690 if(get_keypress() == BACKSPACE ||
1691 get_keypress() == DELETE)
1692 return handle_event();
1697 // CWindowMaskCycleNext::CWindowMaskCycleNext(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1698 // : BC_GenericButton(x, y, _("Cycle next"))
1700 // this->mwindow = mwindow;
1703 // int CWindowMaskCycleNext::handle_event()
1705 // MaskAuto *keyframe;
1706 // MaskAutos *autos;
1708 // MaskPoint *point;
1710 // ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1714 // // Should apply to all keyframes
1715 // if(keyframe && mask->points.total)
1717 // temp = mask->points.values[0];
1719 // for(int i = 0; i < mask->points.total - 1; i++)
1721 // mask->points.values[i] = mask->points.values[i + 1];
1723 // mask->points.values[mask->points.total - 1] = temp;
1725 // mwindow->cwindow->gui->affected_point--;
1726 // if(mwindow->cwindow->gui->affected_point < 0)
1727 // mwindow->cwindow->gui->affected_point = mask->points.total - 1;
1730 // gui->update_preview();
1736 // CWindowMaskCyclePrev::CWindowMaskCyclePrev(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1737 // : BC_GenericButton(x, y, _("Cycle prev"))
1739 // this->mwindow = mwindow;
1742 // int CWindowMaskCyclePrev::handle_event()
1744 // MaskAuto *keyframe;
1745 // MaskAutos *autos;
1747 // MaskPoint *point;
1749 // ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1751 // // Should apply to all keyframes
1753 // if(keyframe && mask->points.total)
1755 // temp = mask->points.values[mask->points.total - 1];
1757 // for(int i = mask->points.total - 1; i > 0; i--)
1759 // mask->points.values[i] = mask->points.values[i - 1];
1761 // mask->points.values[0] = temp;
1763 // mwindow->cwindow->gui->affected_point++;
1764 // if(mwindow->cwindow->gui->affected_point >= mask->points.total)
1765 // mwindow->cwindow->gui->affected_point = 0;
1768 // gui->update_preview();
1774 CWindowMaskNumber::CWindowMaskNumber(MWindow *mwindow,
1775 CWindowToolGUI *gui,
1778 : BC_TumbleTextBox(gui,
1779 (int64_t)mwindow->edl->session->cwindow_mask,
1781 (int64_t)SUBMASKS - 1,
1786 this->mwindow = mwindow;
1790 CWindowMaskNumber::~CWindowMaskNumber()
1794 int CWindowMaskNumber::handle_event()
1796 mwindow->edl->session->cwindow_mask = atol(get_text());
1798 gui->update_preview();
1803 CWindowMaskAffectedPoint::CWindowMaskAffectedPoint(MWindow *mwindow,
1804 CWindowToolGUI *gui, int x, int y)
1805 : BC_TumbleTextBox(gui,
1806 (int64_t)mwindow->cwindow->gui->affected_point,
1807 (int64_t)0, INT64_MAX, x, y, 100)
1809 this->mwindow = mwindow;
1813 CWindowMaskAffectedPoint::~CWindowMaskAffectedPoint()
1817 int CWindowMaskAffectedPoint::handle_event()
1819 int total_points = 0;
1820 int affected_point = atol(get_text());
1821 Track *track = mwindow->cwindow->calculate_affected_track();
1823 MaskAutos *autos = (MaskAutos*)track->automation->autos[AUTOMATION_MASK];
1824 MaskAuto *keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(autos, 0);
1826 SubMask *mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
1827 total_points = mask->points.size();
1830 int active_point = affected_point;
1831 if( affected_point >= total_points )
1832 affected_point = total_points - 1;
1833 else if( affected_point < 0 )
1835 if( active_point != affected_point )
1836 update((int64_t)affected_point);
1837 mwindow->cwindow->gui->affected_point = affected_point;
1839 gui->update_preview();
1847 CWindowMaskFeather::CWindowMaskFeather(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1848 : BC_TumbleTextBox(gui,
1856 this->mwindow = mwindow;
1859 CWindowMaskFeather::~CWindowMaskFeather()
1862 int CWindowMaskFeather::handle_event()
1869 #ifdef USE_KEYFRAME_SPANNING
1875 mwindow->undo->update_undo_before(_("mask feather"), this);
1877 // Get existing keyframe
1878 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe,
1879 mask, point, create_it);
1883 #ifdef USE_KEYFRAME_SPANNING
1884 // Create temp keyframe
1885 MaskAuto temp_keyframe(mwindow->edl, autos);
1886 temp_keyframe.copy_data(keyframe);
1888 temp_keyframe.feather = atof(get_text());
1889 // Commit change to span of keyframes
1890 autos->update_parameter(&temp_keyframe);
1892 keyframe->feather = atof(get_text());
1895 gui->update_preview();
1898 mwindow->undo->update_undo_after(_("mask feather"), LOAD_AUTOMATION);
1903 CWindowMaskValue::CWindowMaskValue(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1913 this->mwindow = mwindow;
1917 CWindowMaskValue::~CWindowMaskValue()
1921 int CWindowMaskValue::handle_event()
1928 #ifdef USE_KEYFRAME_SPANNING
1934 mwindow->undo->update_undo_before(_("mask value"), this);
1935 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe,
1936 mask, point, create_it);
1940 #ifdef USE_KEYFRAME_SPANNING
1941 // Create temp keyframe
1942 MaskAuto temp_keyframe(mwindow->edl, autos);
1943 temp_keyframe.copy_data(keyframe);
1945 temp_keyframe.value = get_value();
1946 // Commit change to span of keyframes
1947 autos->update_parameter(&temp_keyframe);
1949 keyframe->value = get_value();
1953 gui->update_preview();
1954 mwindow->undo->update_undo_after(_("mask value"), LOAD_AUTOMATION);
1959 CWindowMaskBeforePlugins::CWindowMaskBeforePlugins(CWindowToolGUI *gui, int x, int y)
1963 _("Apply mask before plugins"))
1968 int CWindowMaskBeforePlugins::handle_event()
1975 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 1);
1978 keyframe->apply_before_plugins = get_value();
1979 gui->update_preview();
1985 CWindowDisableOpenGLMasking::CWindowDisableOpenGLMasking(CWindowToolGUI *gui, int x, int y)
1986 : BC_CheckBox(x, y, 1, _("Disable OpenGL masking"))
1991 int CWindowDisableOpenGLMasking::handle_event()
1998 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 1);
2001 keyframe->disable_opengl_masking = get_value();
2002 gui->update_preview();
2015 CWindowMaskGUI::CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread)
2016 : CWindowToolGUI(mwindow,
2018 _(PROGRAM_NAME ": Mask"),
2022 this->mwindow = mwindow;
2023 this->thread = thread;
2028 CWindowMaskGUI::~CWindowMaskGUI()
2030 lock_window("CWindowMaskGUI::~CWindowMaskGUI");
2032 delete active_point;
2037 void CWindowMaskGUI::create_objects()
2039 int x = 10, y = 10, margin = mwindow->theme->widget_border;
2040 //MaskAuto *keyframe = 0;
2041 //Track *track = mwindow->cwindow->calculate_affected_track();
2043 // keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->autos[AUTOMATION_MASK], 0);
2045 lock_window("CWindowMaskGUI::create_objects");
2047 add_subwindow(title = new BC_Title(x, y, _("Mode:")));
2048 add_subwindow(mode = new CWindowMaskMode(mwindow,
2049 this, x + title->get_w() + margin, y, ""));
2050 mode->create_objects();
2051 y += mode->get_h() + margin;
2052 add_subwindow(title = new BC_Title(x, y, _("Value:")));
2053 add_subwindow(value = new CWindowMaskValue(mwindow, this, x + title->get_w() + margin, y));
2054 y += value->get_h() + margin;
2055 add_subwindow(delete_point = new CWindowMaskDelete(mwindow, this, x, y));
2056 int x1 = x + delete_point->get_w() + 2*margin;
2057 add_subwindow(title = new BC_Title(x1, y, _("Point:")));
2058 x1 += title->get_w() + margin;
2059 active_point = new CWindowMaskAffectedPoint(mwindow, this, x1, y);
2060 active_point->create_objects();
2061 y += delete_point->get_h() + margin;
2062 add_subwindow(title = new BC_Title(x, y, _("Mask number:")));
2063 number = new CWindowMaskNumber(mwindow,
2064 this, x + title->get_w() + margin, y);
2065 number->create_objects();
2066 y += number->get_h() + margin;
2067 add_subwindow(title = new BC_Title(x, y, _("Feather:")));
2068 feather = new CWindowMaskFeather(mwindow,
2069 this, x + title->get_w() + margin, y);
2070 feather->create_objects();
2071 y += feather->get_h() + margin;
2072 add_subwindow(title = new BC_Title(x, y, "X:"));
2073 x += title->get_w() + margin;
2074 this->x = new CWindowCoord(this, x, y, (float)0.0);
2075 this->x->create_objects();
2076 x += this->x->get_w() + margin;
2077 add_subwindow(title = new BC_Title(x, y, "Y:"));
2078 x += title->get_w() + margin;
2079 this->y = new CWindowCoord(this, x, y, (float)0.0);
2080 this->y->create_objects();
2083 y += this->y->get_h() + margin;
2084 add_subwindow(title = new BC_Title(x, y, _("Press Shift to move an end point")));
2085 y += title->get_h() + margin;
2086 add_subwindow(title = new BC_Title(x, y, _("Press Ctrl to move a control point")));
2087 y += title->get_h() + margin;
2088 add_subwindow(title = new BC_Title(x, y, _("Press Alt to translate the mask")));
2091 add_subwindow(this->apply_before_plugins = new CWindowMaskBeforePlugins(this, 10, y));
2092 y += this->apply_before_plugins->get_h() + margin;
2093 add_subwindow(this->disable_opengl_masking = new CWindowDisableOpenGLMasking(this, 10, y));
2099 void CWindowMaskGUI::get_keyframe(Track* &track,
2101 MaskAuto* &keyframe,
2109 track = mwindow->cwindow->calculate_affected_track();
2112 autos = (MaskAutos*)track->automation->autos[AUTOMATION_MASK];
2113 keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(
2119 mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
2126 if(mwindow->cwindow->gui->affected_point < mask->points.total &&
2127 mwindow->cwindow->gui->affected_point >= 0)
2129 point = mask->points.values[mwindow->cwindow->gui->affected_point];
2134 void CWindowMaskGUI::update()
2141 //printf("CWindowMaskGUI::update 1\n");
2142 get_keyframe(track, autos, keyframe, mask, point, 0);
2144 double position = mwindow->edl->local_session->get_selectionstart(1);
2145 position = mwindow->edl->align_to_frame(position, 0);
2148 int64_t position_i = track->to_units(position, 0);
2152 x->update(point->x);
2153 y->update(point->y);
2158 feather->update((int64_t)autos->get_feather(position_i, PLAY_FORWARD));
2159 value->update((int64_t)autos->get_value(position_i, PLAY_FORWARD));
2160 apply_before_plugins->update((int64_t)keyframe->apply_before_plugins);
2161 disable_opengl_masking->update((int64_t)keyframe->disable_opengl_masking);
2165 //printf("CWindowMaskGUI::update 1\n");
2166 active_point->update((int64_t)mwindow->cwindow->gui->affected_point);
2167 number->update((int64_t)mwindow->edl->session->cwindow_mask);
2169 //printf("CWindowMaskGUI::update 1\n");
2172 #ifdef USE_KEYFRAME_SPANNING
2174 CWindowMaskMode::mode_to_text(keyframe->mode));
2177 CWindowMaskMode::mode_to_text(((MaskAuto*)autos->default_auto)->mode));
2180 //printf("CWindowMaskGUI::update 2\n");
2183 void CWindowMaskGUI::handle_event()
2190 get_keyframe(track, autos, keyframe, mask, point, 0);
2192 mwindow->undo->update_undo_before(_("mask point"), this);
2196 #ifdef USE_KEYFRAME_SPANNING
2197 // Create temp keyframe
2198 MaskAuto temp_keyframe(mwindow->edl, autos);
2199 temp_keyframe.copy_data(keyframe);
2200 // Get affected point in temp keyframe
2201 mask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
2202 if(mwindow->cwindow->gui->affected_point < mask->points.total &&
2203 mwindow->cwindow->gui->affected_point >= 0)
2205 point = mask->points.values[mwindow->cwindow->gui->affected_point];
2210 point->x = atof(x->get_text());
2211 point->y = atof(y->get_text());
2212 // Commit to spanned keyframes
2213 autos->update_parameter(&temp_keyframe);
2216 point->x = atof(x->get_text());
2217 point->y = atof(y->get_text());
2222 mwindow->undo->update_undo_after(_("mask point"), LOAD_AUTOMATION);
2225 void CWindowMaskGUI::update_preview()
2227 mwindow->restart_brender();
2228 mwindow->sync_parameters(CHANGE_PARAMS);
2229 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
2233 mwindow->cwindow->gui->lock_window("CWindowMaskGUI::update_preview");
2234 mwindow->cwindow->gui->canvas->draw_refresh();
2235 mwindow->cwindow->gui->unlock_window();
2239 CWindowRulerGUI::CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread)
2240 : CWindowToolGUI(mwindow,
2242 _(PROGRAM_NAME ": Ruler"),
2248 CWindowRulerGUI::~CWindowRulerGUI()
2252 void CWindowRulerGUI::create_objects()
2257 lock_window("CWindowRulerGUI::create_objects");
2258 add_subwindow(title = new BC_Title(x, y, _("Current:")));
2259 add_subwindow(current = new BC_Title(x + title->get_w() + 10, y, ""));
2260 y += title->get_h() + 5;
2262 add_subwindow(title = new BC_Title(x, y, _("Point 1:")));
2263 add_subwindow(point1 = new BC_Title(x + title->get_w() + 10, y, ""));
2264 y += title->get_h() + 5;
2266 add_subwindow(title = new BC_Title(x, y, _("Point 2:")));
2267 add_subwindow(point2 = new BC_Title(x + title->get_w() + 10, y, ""));
2268 y += title->get_h() + 5;
2270 add_subwindow(title = new BC_Title(x, y, _("Distance:")));
2271 add_subwindow(distance = new BC_Title(x + title->get_w() + 10, y, ""));
2272 y += title->get_h() + 5;
2273 add_subwindow(title = new BC_Title(x, y, _("Angle:")));
2274 add_subwindow(angle = new BC_Title(x + title->get_w() + 10, y, ""));
2275 y += title->get_h() + 10;
2276 char string[BCTEXTLEN];
2277 sprintf(string, _("Press Ctrl to lock ruler to the\nnearest 45%c angle."), 0xb0);
2278 add_subwindow(title = new BC_Title(x,
2281 y += title->get_h() + 10;
2282 sprintf(string, _("Press Alt to translate the ruler."));
2283 add_subwindow(title = new BC_Title(x,
2290 void CWindowRulerGUI::update()
2292 double distance_value =
2293 sqrt(SQR(mwindow->edl->session->ruler_x2 - mwindow->edl->session->ruler_x1) +
2294 SQR(mwindow->edl->session->ruler_y2 - mwindow->edl->session->ruler_y1));
2295 double angle_value = atan((mwindow->edl->session->ruler_y2 - mwindow->edl->session->ruler_y1) /
2296 (mwindow->edl->session->ruler_x2 - mwindow->edl->session->ruler_x1)) *
2301 if(EQUIV(distance_value, 0.0))
2311 char string[BCTEXTLEN];
2312 sprintf(string, "%d, %d",
2313 mwindow->session->cwindow_output_x,
2314 mwindow->session->cwindow_output_y);
2315 current->update(string);
2316 sprintf(string, "%.0f, %.0f",
2317 mwindow->edl->session->ruler_x1,
2318 mwindow->edl->session->ruler_y1);
2319 point1->update(string);
2320 sprintf(string, "%.0f, %.0f",
2321 mwindow->edl->session->ruler_x2,
2322 mwindow->edl->session->ruler_y2);
2323 point2->update(string);
2325 sprintf(string, _("%0.01f pixels"), distance_value);
2326 distance->update(string);
2327 sprintf(string, "%0.02f %c", angle_value, 0xb0);
2328 angle->update(string);
2331 void CWindowRulerGUI::handle_event()