3 * Copyright (C) 2008-2017 Adam Williams <broadcast at earthling dot net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "automation.h"
27 #include "condition.h"
29 #include "cplayback.h"
31 #include "cwindowgui.h"
32 #include "cwindowtool.h"
34 #include "edlsession.h"
35 #include "floatauto.h"
36 #include "floatautos.h"
39 #include "localsession.h"
40 #include "mainsession.h"
43 #include "maskautos.h"
46 #include "mwindowgui.h"
49 #include "trackcanvas.h"
50 #include "transportque.h"
53 CWindowTool::CWindowTool(MWindow *mwindow, CWindowGUI *gui)
56 this->mwindow = mwindow;
60 current_tool = CWINDOW_NONE;
62 input_lock = new Condition(0, "CWindowTool::input_lock");
63 output_lock = new Condition(1, "CWindowTool::output_lock");
64 tool_gui_lock = new Mutex("CWindowTool::tool_gui_lock");
67 CWindowTool::~CWindowTool()
78 void CWindowTool::start_tool(int operation)
80 CWindowToolGUI *new_gui = 0;
83 //printf("CWindowTool::start_tool 1\n");
84 if(current_tool != operation)
86 int previous_tool = current_tool;
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);
108 case CWINDOW_PROTECT:
109 mwindow->edl->session->tool_window = 0;
110 gui->composite_panel->operation[CWINDOW_TOOL_WINDOW]->update(0);
118 //printf("CWindowTool::start_tool 1\n");
124 // Wait for previous tool GUI to finish
125 output_lock->lock("CWindowTool::start_tool");
126 this->tool_gui = new_gui;
127 tool_gui->create_objects();
128 if( previous_tool == CWINDOW_PROTECT || previous_tool == CWINDOW_NONE ) {
129 mwindow->edl->session->tool_window = 1;
130 gui->composite_panel->operation[CWINDOW_TOOL_WINDOW]->update(1);
132 update_show_window();
134 // Signal thread to run next tool GUI
135 input_lock->unlock();
137 //printf("CWindowTool::start_tool 1\n");
142 tool_gui->lock_window("CWindowTool::start_tool");
144 tool_gui->unlock_window();
147 //printf("CWindowTool::start_tool 2\n");
152 void CWindowTool::stop_tool()
156 tool_gui->lock_window("CWindowTool::stop_tool");
157 tool_gui->set_done(0);
158 tool_gui->unlock_window();
162 void CWindowTool::show_tool()
164 if(tool_gui && mwindow->edl->session->tool_window)
166 tool_gui->lock_window("CWindowTool::show_tool");
167 tool_gui->show_window();
168 tool_gui->unlock_window();
172 void CWindowTool::hide_tool()
174 if(tool_gui && mwindow->edl->session->tool_window)
176 tool_gui->lock_window("CWindowTool::show_tool");
177 tool_gui->hide_window();
178 tool_gui->unlock_window();
183 void CWindowTool::run()
187 input_lock->lock("CWindowTool::run");
190 tool_gui->run_window();
191 tool_gui_lock->lock("CWindowTool::run");
194 tool_gui_lock->unlock();
196 output_lock->unlock();
200 void CWindowTool::update_show_window()
204 tool_gui->lock_window("CWindowTool::update_show_window");
206 if(mwindow->edl->session->tool_window)
209 tool_gui->show_window();
212 tool_gui->hide_window();
215 tool_gui->unlock_window();
219 void CWindowTool::raise_window()
223 gui->unlock_window();
224 tool_gui->lock_window("CWindowTool::raise_window");
225 tool_gui->raise_window();
226 tool_gui->unlock_window();
227 gui->lock_window("CWindowTool::raise_window");
231 void CWindowTool::update_values()
233 tool_gui_lock->lock("CWindowTool::update_values");
236 tool_gui->lock_window("CWindowTool::update_values");
239 tool_gui->unlock_window();
241 tool_gui_lock->unlock();
250 CWindowToolGUI::CWindowToolGUI(MWindow *mwindow,
256 mwindow->session->ctool_x,
257 mwindow->session->ctool_y,
266 this->mwindow = mwindow;
267 this->thread = thread;
268 current_operation = 0;
271 CWindowToolGUI::~CWindowToolGUI()
275 int CWindowToolGUI::close_event()
279 mwindow->edl->session->tool_window = 0;
284 thread->gui->lock_window("CWindowToolGUI::close_event");
285 thread->gui->composite_panel->set_operation(mwindow->edl->session->cwindow_operation);
286 thread->gui->flush();
287 thread->gui->unlock_window();
289 lock_window("CWindowToolGUI::close_event");
293 int CWindowToolGUI::keypress_event()
297 switch( get_keypress() ) {
300 return close_event();
313 resend_event(thread->gui);
320 int CWindowToolGUI::translation_event()
322 mwindow->session->ctool_x = get_x();
323 mwindow->session->ctool_y = get_y();
332 CWindowCoord::CWindowCoord(CWindowToolGUI *gui, int x, int y, float value, int log_increment = 0)
333 : BC_TumbleTextBox(gui, (float)value, (float)-65536, (float)65536, x, y, 100)
336 set_log_floatincrement(log_increment);
339 CWindowCoord::CWindowCoord(CWindowToolGUI *gui, int x, int y, int value)
340 : BC_TumbleTextBox(gui, (int64_t)value, (int64_t)-65536, (int64_t)65536, x, y, 100)
344 int CWindowCoord::handle_event()
346 gui->event_caller = this;
352 CWindowCropOK::CWindowCropOK(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
353 : BC_GenericButton(x, y, _("Do it"))
355 this->mwindow = mwindow;
358 int CWindowCropOK::handle_event()
360 mwindow->crop_video();
365 int CWindowCropOK::keypress_event()
367 if(get_keypress() == 0xd)
381 CWindowCropGUI::CWindowCropGUI(MWindow *mwindow, CWindowTool *thread)
382 : CWindowToolGUI(mwindow,
384 _(PROGRAM_NAME ": Crop"),
391 CWindowCropGUI::~CWindowCropGUI()
395 void CWindowCropGUI::create_objects()
400 lock_window("CWindowCropGUI::create_objects");
402 int pad = MAX(BC_TextBox::calculate_h(this, MEDIUMFONT, 1, 1),
403 BC_Title::calculate_h(this, "X")) + 5;
404 add_subwindow(title = new BC_Title(x, y, "X1:"));
405 column1 = MAX(column1, title->get_w());
407 add_subwindow(title = new BC_Title(x, y, _("W:")));
408 column1 = MAX(column1, title->get_w());
410 add_subwindow(new CWindowCropOK(mwindow, thread->tool_gui, x, y));
414 x1 = new CWindowCoord(thread->tool_gui, x, y,
415 mwindow->edl->session->crop_x1);
416 x1->create_objects();
418 width = new CWindowCoord(thread->tool_gui, x, y,
419 mwindow->edl->session->crop_x2 - mwindow->edl->session->crop_x1);
420 width->create_objects();
423 x += x1->get_w() + 10;
426 add_subwindow(title = new BC_Title(x, y, "Y1:"));
427 column2 = MAX(column2, title->get_w());
429 add_subwindow(title = new BC_Title(x, y, _("H:")));
430 column2 = MAX(column2, title->get_w());
435 y1 = new CWindowCoord(thread->tool_gui, x, y,
436 mwindow->edl->session->crop_y1);
437 y1->create_objects();
439 height = new CWindowCoord(thread->tool_gui, x, y,
440 mwindow->edl->session->crop_y2 - mwindow->edl->session->crop_y1);
441 height->create_objects();
445 void CWindowCropGUI::handle_event()
448 new_x1 = atol(x1->get_text());
449 new_y1 = atol(y1->get_text());
450 if(new_x1 != mwindow->edl->session->crop_x1)
452 mwindow->edl->session->crop_x2 = new_x1 +
453 mwindow->edl->session->crop_x2 -
454 mwindow->edl->session->crop_x1;
455 mwindow->edl->session->crop_x1 = new_x1;
457 if(new_y1 != mwindow->edl->session->crop_y1)
459 mwindow->edl->session->crop_y2 = new_y1 +
460 mwindow->edl->session->crop_y2 -
461 mwindow->edl->session->crop_y1;
462 mwindow->edl->session->crop_y1 = atol(y1->get_text());
464 mwindow->edl->session->crop_x2 = atol(width->get_text()) +
465 mwindow->edl->session->crop_x1;
466 mwindow->edl->session->crop_y2 = atol(height->get_text()) +
467 mwindow->edl->session->crop_y1;
469 mwindow->cwindow->gui->lock_window("CWindowCropGUI::handle_event");
470 mwindow->cwindow->gui->canvas->draw_refresh();
471 mwindow->cwindow->gui->unlock_window();
474 void CWindowCropGUI::update()
476 x1->update((int64_t)mwindow->edl->session->crop_x1);
477 y1->update((int64_t)mwindow->edl->session->crop_y1);
478 width->update((int64_t)mwindow->edl->session->crop_x2 -
479 mwindow->edl->session->crop_x1);
480 height->update((int64_t)mwindow->edl->session->crop_y2 -
481 mwindow->edl->session->crop_y1);
485 CWindowEyedropGUI::CWindowEyedropGUI(MWindow *mwindow, CWindowTool *thread)
486 : CWindowToolGUI(mwindow, thread, _(PROGRAM_NAME ": Color"), 220, 290)
490 CWindowEyedropGUI::~CWindowEyedropGUI()
494 void CWindowEyedropGUI::create_objects()
496 int margin = mwindow->theme->widget_border;
499 int x2 = 70, x3 = x2 + 60;
500 lock_window("CWindowEyedropGUI::create_objects");
501 BC_Title *title0, *title1, *title2, *title3, *title4, *title5, *title6, *title7;
502 add_subwindow(title0 = new BC_Title(x, y,_("X,Y:")));
503 y += title0->get_h() + margin;
504 add_subwindow(title7 = new BC_Title(x, y, _("Radius:")));
505 y += BC_TextBox::calculate_h(this, MEDIUMFONT, 1, 1) + margin;
507 add_subwindow(title1 = new BC_Title(x, y, _("Red:")));
508 y += title1->get_h() + margin;
509 add_subwindow(title2 = new BC_Title(x, y, _("Green:")));
510 y += title2->get_h() + margin;
511 add_subwindow(title3 = new BC_Title(x, y, _("Blue:")));
512 y += title3->get_h() + margin;
514 add_subwindow(title4 = new BC_Title(x, y, "Y:"));
515 y += title4->get_h() + margin;
516 add_subwindow(title5 = new BC_Title(x, y, "U:"));
517 y += title5->get_h() + margin;
518 add_subwindow(title6 = new BC_Title(x, y, "V:"));
520 add_subwindow(current = new BC_Title(x2, title0->get_y(), ""));
522 radius = new CWindowCoord(this, x2, title7->get_y(),
523 mwindow->edl->session->eyedrop_radius);
524 radius->create_objects();
525 radius->set_boundaries((int64_t)0, (int64_t)255);
527 add_subwindow(red = new BC_Title(x2, title1->get_y(), "0"));
528 add_subwindow(green = new BC_Title(x2, title2->get_y(), "0"));
529 add_subwindow(blue = new BC_Title(x2, title3->get_y(), "0"));
530 add_subwindow(rgb_hex = new BC_Title(x3, red->get_y(), "#000000"));
532 add_subwindow(this->y = new BC_Title(x2, title4->get_y(), "0"));
533 add_subwindow(this->u = new BC_Title(x2, title5->get_y(), "0"));
534 add_subwindow(this->v = new BC_Title(x2, title6->get_y(), "0"));
535 add_subwindow(yuv_hex = new BC_Title(x3, this->y->get_y(), "#000000"));
537 y = title6->get_y() + this->v->get_h() + 2*margin;
538 add_subwindow(sample = new BC_SubWindow(x, y, 50, 50));
539 y += sample->get_h() + margin;
540 add_subwindow(use_max = new CWindowEyedropCheckBox(mwindow, this, x, y));
545 void CWindowEyedropGUI::update()
547 char string[BCTEXTLEN];
548 sprintf(string, "%d, %d",
549 thread->gui->eyedrop_x,
550 thread->gui->eyedrop_y);
551 current->update(string);
553 radius->update((int64_t)mwindow->edl->session->eyedrop_radius);
555 LocalSession *local_session = mwindow->edl->local_session;
556 int use_max = local_session->use_max;
557 float r = use_max ? local_session->red_max : local_session->red;
558 float g = use_max ? local_session->green_max : local_session->green;
559 float b = use_max ? local_session->blue_max : local_session->blue;
560 this->red->update(r);
561 this->green->update(g);
562 this->blue->update(b);
564 int rx = 255*r + 0.5; bclamp(rx,0,255);
565 int gx = 255*g + 0.5; bclamp(gx,0,255);
566 int bx = 255*b + 0.5; bclamp(bx,0,255);
567 char rgb_text[BCSTRLEN];
568 sprintf(rgb_text, "#%02x%02x%02x", rx, gx, bx);
569 rgb_hex->update(rgb_text);
572 YUV::yuv.rgb_to_yuv_f(r, g, b, y, u, v);
574 this->u->update(u); u += 0.5;
575 this->v->update(v); v += 0.5;
577 int yx = 255*y + 0.5; bclamp(yx,0,255);
578 int ux = 255*u + 0.5; bclamp(ux,0,255);
579 int vx = 255*v + 0.5; bclamp(vx,0,255);
580 char yuv_text[BCSTRLEN];
581 sprintf(yuv_text, "#%02x%02x%02x", yx, ux, vx);
582 yuv_hex->update(yuv_text);
584 int rgb = (rx << 16) | (gx << 8) | (bx << 0);
585 sample->set_color(rgb);
586 sample->draw_box(0, 0, sample->get_w(), sample->get_h());
587 sample->set_color(BLACK);
588 sample->draw_rectangle(0, 0, sample->get_w(), sample->get_h());
592 void CWindowEyedropGUI::handle_event()
594 int new_radius = atoi(radius->get_text());
595 if(new_radius != mwindow->edl->session->eyedrop_radius)
597 CWindowGUI *gui = mwindow->cwindow->gui;
598 if(gui->eyedrop_visible)
600 gui->lock_window("CWindowEyedropGUI::handle_event");
603 gui->canvas->do_eyedrop(rerender, 0, 1);
606 mwindow->edl->session->eyedrop_radius = new_radius;
608 if(gui->eyedrop_visible)
612 gui->canvas->do_eyedrop(rerender, 0, 1);
613 gui->unlock_window();
620 /* Buttons to control Keyframe-Curve-Mode for Projector or Camera */
622 // Configuration for all possible Keyframe Curve Mode toggles
624 FloatAuto::t_mode mode;
630 const _CVD Camera_Crv_Smooth =
634 N_("\"smooth\" Curve on current Camera Keyframes")
636 const _CVD Camera_Crv_Linear =
640 N_("\"linear\" Curve on current Camera Keyframes")
642 const _CVD Projector_Crv_Smooth =
646 N_("\"smooth\" Curve on current Projector Keyframes")
648 const _CVD Projector_Crv_Linear =
652 N_("\"linear\" Curve on current Projector Keyframes")
655 // Implementation Class für Keyframe Curve Mode buttons
657 // This button reflects the state of the "current" keyframe
658 // (the nearest keyframe on the left) for all three automation
659 // lines together. Clicking on this button (re)sets the curve
660 // mode for the three "current" keyframes simultanously, but
661 // never creates a new keyframe.
663 class CWindowCurveToggle : public BC_Toggle
666 CWindowCurveToggle(_CVD mode, MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
667 void check_toggle_state(FloatAuto *x, FloatAuto *y, FloatAuto *z);
676 CWindowCurveToggle::CWindowCurveToggle(_CVD mode, MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
677 : BC_Toggle(x, y, mwindow->theme->get_image_set(mode.icon_id), false),
681 this->mwindow = mwindow;
682 set_tooltip(_(cfg.tooltip));
685 void CWindowCurveToggle::check_toggle_state(FloatAuto *x, FloatAuto *y, FloatAuto *z)
687 // the toggle state is only set to ON if all
688 // three automation lines have the same curve mode.
689 // For mixed states the toggle stays off.
690 set_value( x->curve_mode == this->cfg.mode &&
691 y->curve_mode == this->cfg.mode &&
692 z->curve_mode == this->cfg.mode
693 ,true // redraw to show new state
697 int CWindowCurveToggle::handle_event()
699 FloatAuto *x=0, *y=0, *z=0;
700 Track *track = mwindow->cwindow->calculate_affected_track();
703 { mwindow->cwindow->calculate_affected_autos(&x, &y, &z,
704 track, cfg.use_camera, 0,0,0); // don't create new keyframe
706 if(x) x->change_curve_mode(cfg.mode);
707 if(y) y->change_curve_mode(cfg.mode);
708 if(z) z->change_curve_mode(cfg.mode);
711 gui->update_preview();
718 CWindowEyedropCheckBox::CWindowEyedropCheckBox(MWindow *mwindow,
719 CWindowEyedropGUI *gui, int x, int y)
720 : BC_CheckBox(x, y, mwindow->edl->local_session->use_max, _("Use maximum"))
722 this->mwindow = mwindow;
726 int CWindowEyedropCheckBox::handle_event()
728 mwindow->edl->local_session->use_max = get_value();
735 CWindowCameraGUI::CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread)
736 : CWindowToolGUI(mwindow,
738 _(PROGRAM_NAME ": Camera"),
743 CWindowCameraGUI::~CWindowCameraGUI()
747 void CWindowCameraGUI::create_objects()
749 int x = 10, y = 10, x1;
750 Track *track = mwindow->cwindow->calculate_affected_track();
751 FloatAuto *x_auto = 0;
752 FloatAuto *y_auto = 0;
753 FloatAuto *z_auto = 0;
757 lock_window("CWindowCameraGUI::create_objects");
760 mwindow->cwindow->calculate_affected_autos(&x_auto,
761 &y_auto, &z_auto, track, 1, 0, 0, 0);
764 add_subwindow(title = new BC_Title(x, y, "X:"));
766 this->x = new CWindowCoord(this, x, y,
767 x_auto ? x_auto->get_value() : (float)0);
768 this->x->create_objects();
773 add_subwindow(title = new BC_Title(x, y, "Y:"));
775 this->y = new CWindowCoord(this, x, y,
776 y_auto ? y_auto->get_value() : (float)0);
777 this->y->create_objects();
780 add_subwindow(title = new BC_Title(x, y, "Z:"));
782 this->z = new CWindowCoord(this, x, y,
783 z_auto ? z_auto->get_value() : (float)1);
784 this->z->create_objects();
785 this->z->set_increment(0.01);
789 add_subwindow(button = new CWindowCameraLeft(mwindow, this, x1, y));
790 x1 += button->get_w();
791 add_subwindow(button = new CWindowCameraCenter(mwindow, this, x1, y));
792 x1 += button->get_w();
793 add_subwindow(button = new CWindowCameraRight(mwindow, this, x1, y));
795 y += button->get_h();
797 add_subwindow(button = new CWindowCameraTop(mwindow, this, x1, y));
798 x1 += button->get_w();
799 add_subwindow(button = new CWindowCameraMiddle(mwindow, this, x1, y));
800 x1 += button->get_w();
801 add_subwindow(button = new CWindowCameraBottom(mwindow, this, x1, y));
802 // additional Buttons to control the curve mode of the "current" keyframe
803 x1 += button->get_w() + 15;
804 add_subwindow(this->t_smooth = new CWindowCurveToggle(Camera_Crv_Smooth, mwindow, this, x1, y));
805 x1 += button->get_w();
806 add_subwindow(this->t_linear = new CWindowCurveToggle(Camera_Crv_Linear, mwindow, this, x1, y));
808 // fill in current auto keyframe values, set toggle states.
813 void CWindowCameraGUI::update_preview()
815 mwindow->gui->lock_window("CWindowCameraGUI::update_preview");
816 mwindow->restart_brender();
817 mwindow->gui->draw_overlays(1);
818 mwindow->sync_parameters(CHANGE_PARAMS);
819 mwindow->gui->unlock_window();
820 mwindow->cwindow->refresh_frame(CHANGE_NONE);
821 mwindow->cwindow->gui->lock_window("CWindowCameraGUI::update_preview");
822 mwindow->cwindow->gui->canvas->draw_refresh();
823 mwindow->cwindow->gui->unlock_window();
827 void CWindowCameraGUI::handle_event()
829 FloatAuto *x_auto = 0;
830 FloatAuto *y_auto = 0;
831 FloatAuto *z_auto = 0;
832 Track *track = mwindow->cwindow->calculate_affected_track();
835 mwindow->undo->update_undo_before(_("camera"), this);
836 if(event_caller == x)
838 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
839 track->automation->autos[AUTOMATION_CAMERA_X],
843 x_auto->set_value(atof(x->get_text()));
849 if(event_caller == y)
851 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
852 track->automation->autos[AUTOMATION_CAMERA_Y],
856 y_auto->set_value(atof(y->get_text()));
862 if(event_caller == z)
864 z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
865 track->automation->autos[AUTOMATION_CAMERA_Z],
869 float zoom = atof(z->get_text());
870 if(zoom > 100.) zoom = 100.;
872 if(zoom < 0.01) zoom = 0.01;
873 // Doesn't allow user to enter from scratch
874 // if(zoom != atof(z->get_text()))
877 z_auto->set_value(zoom);
878 mwindow->gui->lock_window("CWindowCameraGUI::handle_event");
879 mwindow->gui->draw_overlays(1);
880 mwindow->gui->unlock_window();
886 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
890 void CWindowCameraGUI::update()
892 FloatAuto *x_auto = 0;
893 FloatAuto *y_auto = 0;
894 FloatAuto *z_auto = 0;
895 Track *track = mwindow->cwindow->calculate_affected_track();
899 mwindow->cwindow->calculate_affected_autos(&x_auto,
910 x->update(x_auto->get_value());
912 y->update(y_auto->get_value());
914 float value = z_auto->get_value();
916 thread->gui->composite_panel->cpanel_zoom->update(value);
919 if( x_auto && y_auto && z_auto )
921 t_smooth->check_toggle_state(x_auto, y_auto, z_auto);
922 t_linear->check_toggle_state(x_auto, y_auto, z_auto);
929 CWindowCameraLeft::CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
930 : BC_Button(x, y, mwindow->theme->get_image_set("left_justify"))
933 this->mwindow = mwindow;
934 set_tooltip(_("Left justify"));
936 int CWindowCameraLeft::handle_event()
938 FloatAuto *x_auto = 0;
939 FloatAuto *z_auto = 0;
940 Track *track = mwindow->cwindow->calculate_affected_track();
943 mwindow->cwindow->calculate_affected_autos(&x_auto,
956 track->get_source_dimensions(
957 mwindow->edl->local_session->get_selectionstart(1),
963 mwindow->undo->update_undo_before(_("camera"), 0);
965 (double)track->track_w / z_auto->get_value() / 2 -
967 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
969 gui->update_preview();
977 CWindowCameraCenter::CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
978 : BC_Button(x, y, mwindow->theme->get_image_set("center_justify"))
981 this->mwindow = mwindow;
982 set_tooltip(_("Center horizontal"));
984 int CWindowCameraCenter::handle_event()
986 FloatAuto *x_auto = 0;
987 Track *track = mwindow->cwindow->calculate_affected_track();
989 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
990 track->automation->autos[AUTOMATION_CAMERA_X],
995 mwindow->undo->update_undo_before(_("camera"), 0);
996 x_auto->set_value(0);
998 gui->update_preview();
999 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1006 CWindowCameraRight::CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1007 : BC_Button(x, y, mwindow->theme->get_image_set("right_justify"))
1010 this->mwindow = mwindow;
1011 set_tooltip(_("Right justify"));
1013 int CWindowCameraRight::handle_event()
1015 FloatAuto *x_auto = 0;
1016 FloatAuto *z_auto = 0;
1017 Track *track = mwindow->cwindow->calculate_affected_track();
1020 mwindow->cwindow->calculate_affected_autos(&x_auto,
1030 if(x_auto && z_auto)
1033 track->get_source_dimensions(
1034 mwindow->edl->local_session->get_selectionstart(1),
1040 mwindow->undo->update_undo_before(_("camera"), 0);
1041 x_auto->set_value( -((double)track->track_w / z_auto->get_value() / 2 -
1044 gui->update_preview();
1045 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1053 CWindowCameraTop::CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1054 : BC_Button(x, y, mwindow->theme->get_image_set("top_justify"))
1057 this->mwindow = mwindow;
1058 set_tooltip(_("Top justify"));
1060 int CWindowCameraTop::handle_event()
1062 FloatAuto *y_auto = 0;
1063 FloatAuto *z_auto = 0;
1064 Track *track = mwindow->cwindow->calculate_affected_track();
1067 mwindow->cwindow->calculate_affected_autos(0,
1077 if(y_auto && z_auto)
1080 track->get_source_dimensions(
1081 mwindow->edl->local_session->get_selectionstart(1),
1087 mwindow->undo->update_undo_before(_("camera"), 0);
1088 y_auto->set_value((double)track->track_h / z_auto->get_value() / 2 -
1091 gui->update_preview();
1092 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1100 CWindowCameraMiddle::CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1101 : BC_Button(x, y, mwindow->theme->get_image_set("middle_justify"))
1104 this->mwindow = mwindow;
1105 set_tooltip(_("Center vertical"));
1107 int CWindowCameraMiddle::handle_event()
1109 FloatAuto *y_auto = 0;
1110 Track *track = mwindow->cwindow->calculate_affected_track();
1112 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1113 track->automation->autos[AUTOMATION_CAMERA_Y], 1);
1117 mwindow->undo->update_undo_before(_("camera"), 0);
1118 y_auto->set_value(0);
1120 gui->update_preview();
1121 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1128 CWindowCameraBottom::CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1129 : BC_Button(x, y, mwindow->theme->get_image_set("bottom_justify"))
1132 this->mwindow = mwindow;
1133 set_tooltip(_("Bottom justify"));
1135 int CWindowCameraBottom::handle_event()
1137 FloatAuto *y_auto = 0;
1138 FloatAuto *z_auto = 0;
1139 Track *track = mwindow->cwindow->calculate_affected_track();
1142 mwindow->cwindow->calculate_affected_autos(0,
1152 if(y_auto && z_auto)
1155 track->get_source_dimensions(
1156 mwindow->edl->local_session->get_selectionstart(1),
1162 mwindow->undo->update_undo_before(_("camera"), 0);
1163 y_auto->set_value(-((double)track->track_h / z_auto->get_value() / 2 -
1166 gui->update_preview();
1167 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1175 CWindowProjectorGUI::CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread)
1176 : CWindowToolGUI(mwindow,
1178 _(PROGRAM_NAME ": Projector"),
1183 CWindowProjectorGUI::~CWindowProjectorGUI()
1186 void CWindowProjectorGUI::create_objects()
1188 int x = 10, y = 10, x1;
1189 Track *track = mwindow->cwindow->calculate_affected_track();
1190 FloatAuto *x_auto = 0;
1191 FloatAuto *y_auto = 0;
1192 FloatAuto *z_auto = 0;
1196 lock_window("CWindowProjectorGUI::create_objects");
1199 mwindow->cwindow->calculate_affected_autos(&x_auto,
1209 add_subwindow(title = new BC_Title(x, y, "X:"));
1210 x += title->get_w();
1211 this->x = new CWindowCoord(this, x, y,
1212 x_auto ? x_auto->get_value() : (float)0);
1213 this->x->create_objects();
1216 add_subwindow(title = new BC_Title(x, y, "Y:"));
1217 x += title->get_w();
1218 this->y = new CWindowCoord(this, x, y,
1219 y_auto ? y_auto->get_value() : (float)0);
1220 this->y->create_objects();
1223 add_subwindow(title = new BC_Title(x, y, "Z:"));
1224 x += title->get_w();
1225 this->z = new CWindowCoord(this, x, y,
1226 z_auto ? z_auto->get_value() : (float)1);
1227 this->z->create_objects();
1228 this->z->set_increment(0.01);
1232 add_subwindow(button = new CWindowProjectorLeft(mwindow, this, x1, y));
1233 x1 += button->get_w();
1234 add_subwindow(button = new CWindowProjectorCenter(mwindow, this, x1, y));
1235 x1 += button->get_w();
1236 add_subwindow(button = new CWindowProjectorRight(mwindow, this, x1, y));
1238 y += button->get_h();
1240 add_subwindow(button = new CWindowProjectorTop(mwindow, this, x1, y));
1241 x1 += button->get_w();
1242 add_subwindow(button = new CWindowProjectorMiddle(mwindow, this, x1, y));
1243 x1 += button->get_w();
1244 add_subwindow(button = new CWindowProjectorBottom(mwindow, this, x1, y));
1246 // additional Buttons to control the curve mode of the "current" keyframe
1247 x1 += button->get_w() + 15;
1248 add_subwindow(this->t_smooth = new CWindowCurveToggle(Projector_Crv_Smooth, mwindow, this, x1, y));
1249 x1 += button->get_w();
1250 add_subwindow(this->t_linear = new CWindowCurveToggle(Projector_Crv_Linear, mwindow, this, x1, y));
1252 // fill in current auto keyframe values, set toggle states.
1257 void CWindowProjectorGUI::update_preview()
1259 mwindow->gui->lock_window("CWindowProjectorGUI::update_preview");
1260 mwindow->restart_brender();
1261 mwindow->sync_parameters(CHANGE_PARAMS);
1262 mwindow->gui->draw_overlays(1);
1263 mwindow->gui->unlock_window();
1264 mwindow->cwindow->refresh_frame(CHANGE_NONE);
1265 mwindow->cwindow->gui->lock_window("CWindowProjectorGUI::update_preview");
1266 mwindow->cwindow->gui->canvas->draw_refresh();
1267 mwindow->cwindow->gui->unlock_window();
1270 void CWindowProjectorGUI::handle_event()
1272 FloatAuto *x_auto = 0;
1273 FloatAuto *y_auto = 0;
1274 FloatAuto *z_auto = 0;
1275 Track *track = mwindow->cwindow->calculate_affected_track();
1279 mwindow->undo->update_undo_before(_("projector"), this);
1280 if(event_caller == x)
1282 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1283 track->automation->autos[AUTOMATION_PROJECTOR_X],
1287 x_auto->set_value(atof(x->get_text()));
1293 if(event_caller == y)
1295 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1296 track->automation->autos[AUTOMATION_PROJECTOR_Y],
1300 y_auto->set_value(atof(y->get_text()));
1306 if(event_caller == z)
1308 z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1309 track->automation->autos[AUTOMATION_PROJECTOR_Z],
1313 float zoom = atof(z->get_text());
1314 if(zoom > 100.) zoom = 100.;
1315 else if(zoom < 0.01) zoom = 0.01;
1316 // if (zoom != atof(z->get_text()))
1318 z_auto->set_value(zoom);
1320 mwindow->gui->lock_window("CWindowProjectorGUI::handle_event");
1321 mwindow->gui->draw_overlays(1);
1322 mwindow->gui->unlock_window();
1328 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1332 void CWindowProjectorGUI::update()
1334 FloatAuto *x_auto = 0;
1335 FloatAuto *y_auto = 0;
1336 FloatAuto *z_auto = 0;
1337 Track *track = mwindow->cwindow->calculate_affected_track();
1341 mwindow->cwindow->calculate_affected_autos(&x_auto,
1352 x->update(x_auto->get_value());
1354 y->update(y_auto->get_value());
1356 float value = z_auto->get_value();
1358 thread->gui->composite_panel->cpanel_zoom->update(value);
1361 if( x_auto && y_auto && z_auto )
1363 t_smooth->check_toggle_state(x_auto, y_auto, z_auto);
1364 t_linear->check_toggle_state(x_auto, y_auto, z_auto);
1368 CWindowProjectorLeft::CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1369 : BC_Button(x, y, mwindow->theme->get_image_set("left_justify"))
1372 this->mwindow = mwindow;
1373 set_tooltip(_("Left justify"));
1375 int CWindowProjectorLeft::handle_event()
1377 FloatAuto *x_auto = 0;
1378 FloatAuto *z_auto = 0;
1379 Track *track = mwindow->cwindow->calculate_affected_track();
1382 mwindow->cwindow->calculate_affected_autos(&x_auto,
1391 if(x_auto && z_auto)
1393 mwindow->undo->update_undo_before(_("projector"), 0);
1394 x_auto->set_value( (double)track->track_w * z_auto->get_value() / 2 -
1395 (double)mwindow->edl->session->output_w / 2 );
1397 gui->update_preview();
1398 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1405 CWindowProjectorCenter::CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1406 : BC_Button(x, y, mwindow->theme->get_image_set("center_justify"))
1409 this->mwindow = mwindow;
1410 set_tooltip(_("Center horizontal"));
1412 int CWindowProjectorCenter::handle_event()
1414 FloatAuto *x_auto = 0;
1415 Track *track = mwindow->cwindow->calculate_affected_track();
1417 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1418 track->automation->autos[AUTOMATION_PROJECTOR_X],
1423 mwindow->undo->update_undo_before(_("projector"), 0);
1424 x_auto->set_value(0);
1426 gui->update_preview();
1427 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1434 CWindowProjectorRight::CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1435 : BC_Button(x, y, mwindow->theme->get_image_set("right_justify"))
1438 this->mwindow = mwindow;
1439 set_tooltip(_("Right justify"));
1441 int CWindowProjectorRight::handle_event()
1443 FloatAuto *x_auto = 0;
1444 FloatAuto *z_auto = 0;
1445 Track *track = mwindow->cwindow->calculate_affected_track();
1448 mwindow->cwindow->calculate_affected_autos(&x_auto,
1458 if(x_auto && z_auto)
1460 mwindow->undo->update_undo_before(_("projector"), 0);
1461 x_auto->set_value( -((double)track->track_w * z_auto->get_value() / 2 -
1462 (double)mwindow->edl->session->output_w / 2));
1464 gui->update_preview();
1465 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1472 CWindowProjectorTop::CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1473 : BC_Button(x, y, mwindow->theme->get_image_set("top_justify"))
1476 this->mwindow = mwindow;
1477 set_tooltip(_("Top justify"));
1479 int CWindowProjectorTop::handle_event()
1481 FloatAuto *y_auto = 0;
1482 FloatAuto *z_auto = 0;
1483 Track *track = mwindow->cwindow->calculate_affected_track();
1486 mwindow->cwindow->calculate_affected_autos(0,
1496 if(y_auto && z_auto)
1498 mwindow->undo->update_undo_before(_("projector"), 0);
1499 y_auto->set_value( (double)track->track_h * z_auto->get_value() / 2 -
1500 (double)mwindow->edl->session->output_h / 2 );
1502 gui->update_preview();
1503 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1510 CWindowProjectorMiddle::CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1511 : BC_Button(x, y, mwindow->theme->get_image_set("middle_justify"))
1514 this->mwindow = mwindow;
1515 set_tooltip(_("Center vertical"));
1517 int CWindowProjectorMiddle::handle_event()
1519 FloatAuto *y_auto = 0;
1520 Track *track = mwindow->cwindow->calculate_affected_track();
1522 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1523 track->automation->autos[AUTOMATION_PROJECTOR_Y], 1);
1527 mwindow->undo->update_undo_before(_("projector"), 0);
1528 y_auto->set_value(0);
1530 gui->update_preview();
1531 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1538 CWindowProjectorBottom::CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1539 : BC_Button(x, y, mwindow->theme->get_image_set("bottom_justify"))
1542 this->mwindow = mwindow;
1543 set_tooltip(_("Bottom justify"));
1545 int CWindowProjectorBottom::handle_event()
1547 FloatAuto *y_auto = 0;
1548 FloatAuto *z_auto = 0;
1549 Track *track = mwindow->cwindow->calculate_affected_track();
1552 mwindow->cwindow->calculate_affected_autos(0,
1562 if(y_auto && z_auto)
1564 mwindow->undo->update_undo_before(_("projector"), 0);
1565 y_auto->set_value( -((double)track->track_h * z_auto->get_value() / 2 -
1566 (double)mwindow->edl->session->output_h / 2));
1568 gui->update_preview();
1569 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1576 CWindowMaskMode::CWindowMaskMode(MWindow *mwindow,
1577 CWindowToolGUI *gui, int x, int y, const char *text)
1578 : BC_PopupMenu(x, y, 220, text, 1)
1580 this->mwindow = mwindow;
1584 void CWindowMaskMode::create_objects()
1586 add_item(new BC_MenuItem(mode_to_text(MASK_MULTIPLY_ALPHA)));
1587 add_item(new BC_MenuItem(mode_to_text(MASK_SUBTRACT_ALPHA)));
1590 char* CWindowMaskMode::mode_to_text(int mode)
1594 case MASK_MULTIPLY_ALPHA:
1595 return _("Multiply alpha");
1598 case MASK_SUBTRACT_ALPHA:
1599 return _("Subtract alpha");
1603 return _("Subtract alpha");
1606 int CWindowMaskMode::text_to_mode(char *text)
1608 if(!strcasecmp(text, _("Multiply alpha")))
1609 return MASK_MULTIPLY_ALPHA;
1611 if(!strcasecmp(text, _("Subtract alpha")))
1612 return MASK_SUBTRACT_ALPHA;
1614 return MASK_SUBTRACT_ALPHA;
1617 int CWindowMaskMode::handle_event()
1624 // Get existing keyframe
1625 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1628 mwindow->undo->update_undo_before(_("mask mode"), 0);
1629 #ifdef USE_KEYFRAME_SPANNING
1630 // Create temp keyframe
1631 MaskAuto temp_keyframe(mwindow->edl, autos);
1632 temp_keyframe.copy_data(keyframe);
1634 temp_keyframe.mode = text_to_mode(get_text());
1635 // Commit change to span of keyframes
1636 autos->update_parameter(&temp_keyframe);
1638 ((MaskAuto*)autos->default_auto)->mode =
1639 text_to_mode(get_text());
1641 mwindow->undo->update_undo_after(_("mask mode"), LOAD_AUTOMATION);
1644 //printf("CWindowMaskMode::handle_event 1\n");
1645 gui->update_preview();
1656 CWindowMaskDelete::CWindowMaskDelete(MWindow *mwindow,
1657 CWindowToolGUI *gui,
1660 : BC_GenericButton(x, y, _("Delete"))
1662 this->mwindow = mwindow;
1666 int CWindowMaskDelete::handle_event()
1673 int total_points = 0;
1675 // Get existing keyframe
1676 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1680 mwindow->undo->update_undo_before(_("mask delete"), 0);
1682 #ifdef USE_KEYFRAME_SPANNING
1683 // Create temp keyframe
1684 MaskAuto temp_keyframe(mwindow->edl, autos);
1685 temp_keyframe.copy_data(keyframe);
1687 SubMask *submask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
1689 submask->points.remove_all_objects();
1691 for(int i = mwindow->cwindow->gui->affected_point;
1692 i < submask->points.total - 1;
1695 *submask->points.values[i] = *submask->points.values[i + 1];
1698 if(submask->points.total)
1700 submask->points.remove_object(
1701 submask->points.values[submask->points.total - 1]);
1703 total_points = submask->points.total;
1705 // Commit change to span of keyframes
1706 ((MaskAutos*)track->automation->autos[AUTOMATION_MASK])->update_parameter(&temp_keyframe);
1708 for(MaskAuto *current = (MaskAuto*)autos->default_auto;
1711 SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
1713 submask->points.remove_all_objects();
1715 for(int i = mwindow->cwindow->gui->affected_point;
1716 i < submask->points.total - 1;
1719 *submask->points.values[i] = *submask->points.values[i + 1];
1722 if(submask->points.total)
1724 submask->points.remove_object(
1725 submask->points.values[submask->points.total - 1]);
1727 total_points = submask->points.total;
1729 if(current == (MaskAuto*)autos->default_auto)
1730 current = (MaskAuto*)autos->first;
1732 current = (MaskAuto*)NEXT;
1735 if( mwindow->cwindow->gui->affected_point >= total_points )
1736 mwindow->cwindow->gui->affected_point =
1737 total_points > 0 ? total_points-1 : 0;
1740 gui->update_preview();
1741 mwindow->undo->update_undo_after(_("mask delete"), LOAD_AUTOMATION);
1748 int CWindowMaskDelete::keypress_event()
1750 if(get_keypress() == BACKSPACE ||
1751 get_keypress() == DELETE)
1752 return handle_event();
1757 // CWindowMaskCycleNext::CWindowMaskCycleNext(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1758 // : BC_GenericButton(x, y, _("Cycle next"))
1760 // this->mwindow = mwindow;
1763 // int CWindowMaskCycleNext::handle_event()
1765 // MaskAuto *keyframe;
1766 // MaskAutos *autos;
1768 // MaskPoint *point;
1770 // ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1774 // // Should apply to all keyframes
1775 // if(keyframe && mask->points.total)
1777 // temp = mask->points.values[0];
1779 // for(int i = 0; i < mask->points.total - 1; i++)
1781 // mask->points.values[i] = mask->points.values[i + 1];
1783 // mask->points.values[mask->points.total - 1] = temp;
1785 // mwindow->cwindow->gui->affected_point--;
1786 // if(mwindow->cwindow->gui->affected_point < 0)
1787 // mwindow->cwindow->gui->affected_point = mask->points.total - 1;
1790 // gui->update_preview();
1796 // CWindowMaskCyclePrev::CWindowMaskCyclePrev(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1797 // : BC_GenericButton(x, y, _("Cycle prev"))
1799 // this->mwindow = mwindow;
1802 // int CWindowMaskCyclePrev::handle_event()
1804 // MaskAuto *keyframe;
1805 // MaskAutos *autos;
1807 // MaskPoint *point;
1809 // ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1811 // // Should apply to all keyframes
1813 // if(keyframe && mask->points.total)
1815 // temp = mask->points.values[mask->points.total - 1];
1817 // for(int i = mask->points.total - 1; i > 0; i--)
1819 // mask->points.values[i] = mask->points.values[i - 1];
1821 // mask->points.values[0] = temp;
1823 // mwindow->cwindow->gui->affected_point++;
1824 // if(mwindow->cwindow->gui->affected_point >= mask->points.total)
1825 // mwindow->cwindow->gui->affected_point = 0;
1828 // gui->update_preview();
1834 CWindowMaskNumber::CWindowMaskNumber(MWindow *mwindow,
1835 CWindowToolGUI *gui,
1838 : BC_TumbleTextBox(gui,
1839 (int64_t)mwindow->edl->session->cwindow_mask,
1841 (int64_t)SUBMASKS - 1,
1846 this->mwindow = mwindow;
1850 CWindowMaskNumber::~CWindowMaskNumber()
1854 int CWindowMaskNumber::handle_event()
1856 mwindow->edl->session->cwindow_mask = atol(get_text());
1858 gui->update_preview();
1863 CWindowMaskAffectedPoint::CWindowMaskAffectedPoint(MWindow *mwindow,
1864 CWindowToolGUI *gui, int x, int y)
1865 : BC_TumbleTextBox(gui,
1866 (int64_t)mwindow->cwindow->gui->affected_point,
1867 (int64_t)0, INT64_MAX, x, y, 100)
1869 this->mwindow = mwindow;
1873 CWindowMaskAffectedPoint::~CWindowMaskAffectedPoint()
1877 int CWindowMaskAffectedPoint::handle_event()
1879 int total_points = 0;
1880 int affected_point = atol(get_text());
1881 Track *track = mwindow->cwindow->calculate_affected_track();
1883 MaskAutos *autos = (MaskAutos*)track->automation->autos[AUTOMATION_MASK];
1884 MaskAuto *keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(autos, 0);
1886 SubMask *mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
1887 total_points = mask->points.size();
1890 int active_point = affected_point;
1891 if( affected_point >= total_points )
1892 affected_point = total_points - 1;
1893 else if( affected_point < 0 )
1895 if( active_point != affected_point )
1896 update((int64_t)affected_point);
1897 mwindow->cwindow->gui->affected_point = affected_point;
1899 gui->update_preview();
1907 CWindowMaskFeather::CWindowMaskFeather(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1908 : BC_TumbleTextBox(gui,
1916 this->mwindow = mwindow;
1919 CWindowMaskFeather::~CWindowMaskFeather()
1922 int CWindowMaskFeather::handle_event()
1929 #ifdef USE_KEYFRAME_SPANNING
1935 mwindow->undo->update_undo_before(_("mask feather"), this);
1937 // Get existing keyframe
1938 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe,
1939 mask, point, create_it);
1943 #ifdef USE_KEYFRAME_SPANNING
1944 // Create temp keyframe
1945 MaskAuto temp_keyframe(mwindow->edl, autos);
1946 temp_keyframe.copy_data(keyframe);
1948 temp_keyframe.feather = atof(get_text());
1949 // Commit change to span of keyframes
1950 autos->update_parameter(&temp_keyframe);
1952 keyframe->feather = atof(get_text());
1955 gui->update_preview();
1958 mwindow->undo->update_undo_after(_("mask feather"), LOAD_AUTOMATION);
1963 CWindowMaskValue::CWindowMaskValue(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1973 this->mwindow = mwindow;
1977 CWindowMaskValue::~CWindowMaskValue()
1981 int CWindowMaskValue::handle_event()
1988 #ifdef USE_KEYFRAME_SPANNING
1994 mwindow->undo->update_undo_before(_("mask value"), this);
1995 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe,
1996 mask, point, create_it);
2000 #ifdef USE_KEYFRAME_SPANNING
2001 // Create temp keyframe
2002 MaskAuto temp_keyframe(mwindow->edl, autos);
2003 temp_keyframe.copy_data(keyframe);
2005 temp_keyframe.value = get_value();
2006 // Commit change to span of keyframes
2007 autos->update_parameter(&temp_keyframe);
2009 keyframe->value = get_value();
2013 gui->update_preview();
2014 mwindow->undo->update_undo_after(_("mask value"), LOAD_AUTOMATION);
2019 CWindowMaskBeforePlugins::CWindowMaskBeforePlugins(CWindowToolGUI *gui, int x, int y)
2023 _("Apply mask before plugins"))
2028 int CWindowMaskBeforePlugins::handle_event()
2035 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 1);
2038 keyframe->apply_before_plugins = get_value();
2039 gui->update_preview();
2045 CWindowDisableOpenGLMasking::CWindowDisableOpenGLMasking(CWindowToolGUI *gui, int x, int y)
2046 : BC_CheckBox(x, y, 1, _("Disable OpenGL masking"))
2051 int CWindowDisableOpenGLMasking::handle_event()
2058 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 1);
2061 keyframe->disable_opengl_masking = get_value();
2062 gui->update_preview();
2075 CWindowMaskGUI::CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread)
2076 : CWindowToolGUI(mwindow, thread,
2077 _(PROGRAM_NAME ": Mask"), 330, 320)
2079 this->mwindow = mwindow;
2080 this->thread = thread;
2085 CWindowMaskGUI::~CWindowMaskGUI()
2087 lock_window("CWindowMaskGUI::~CWindowMaskGUI");
2089 delete active_point;
2094 void CWindowMaskGUI::create_objects()
2096 int x = 10, y = 10, margin = mwindow->theme->widget_border;
2097 //MaskAuto *keyframe = 0;
2098 //Track *track = mwindow->cwindow->calculate_affected_track();
2100 // keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->autos[AUTOMATION_MASK], 0);
2102 lock_window("CWindowMaskGUI::create_objects");
2104 add_subwindow(title = new BC_Title(x, y, _("Mode:")));
2105 add_subwindow(mode = new CWindowMaskMode(mwindow,
2106 this, x + title->get_w() + margin, y, ""));
2107 mode->create_objects();
2108 y += mode->get_h() + margin;
2109 add_subwindow(title = new BC_Title(x, y, _("Value:")));
2110 add_subwindow(value = new CWindowMaskValue(mwindow, this, x + title->get_w() + margin, y));
2111 y += value->get_h() + margin;
2112 add_subwindow(delete_point = new CWindowMaskDelete(mwindow, this, x, y));
2113 int x1 = x + delete_point->get_w() + 2*margin;
2114 add_subwindow(title = new BC_Title(x1, y, _("Point:")));
2115 x1 += title->get_w() + margin;
2116 active_point = new CWindowMaskAffectedPoint(mwindow, this, x1, y);
2117 active_point->create_objects();
2118 y += delete_point->get_h() + margin;
2119 add_subwindow(title = new BC_Title(x, y, _("Mask number:")));
2120 number = new CWindowMaskNumber(mwindow,
2121 this, x + title->get_w() + margin, y);
2122 number->create_objects();
2123 y += number->get_h() + margin;
2124 add_subwindow(title = new BC_Title(x, y, _("Feather:")));
2125 feather = new CWindowMaskFeather(mwindow,
2126 this, x + title->get_w() + margin, y);
2127 feather->create_objects();
2128 y += feather->get_h() + margin;
2129 add_subwindow(title = new BC_Title(x, y, "X:"));
2130 x += title->get_w() + margin;
2131 this->x = new CWindowCoord(this, x, y, (float)0.0);
2132 this->x->create_objects();
2133 x += this->x->get_w() + margin;
2134 add_subwindow(title = new BC_Title(x, y, "Y:"));
2135 x += title->get_w() + margin;
2136 this->y = new CWindowCoord(this, x, y, (float)0.0);
2137 this->y->create_objects();
2140 y += this->y->get_h() + margin;
2141 add_subwindow(title = new BC_Title(x, y, _("Press Shift to move an end point")));
2142 y += title->get_h() + margin;
2143 add_subwindow(title = new BC_Title(x, y, _("Press Ctrl to move a control point")));
2144 y += title->get_h() + margin;
2145 add_subwindow(title = new BC_Title(x, y, _("Shift+click Delete to delete the mask")));
2146 y += title->get_h() + margin;
2147 add_subwindow(title = new BC_Title(x, y, _("Press Alt to translate the mask")));
2150 add_subwindow(this->apply_before_plugins = new CWindowMaskBeforePlugins(this, 10, y));
2151 y += this->apply_before_plugins->get_h() + margin;
2152 add_subwindow(this->disable_opengl_masking = new CWindowDisableOpenGLMasking(this, 10, y));
2158 void CWindowMaskGUI::get_keyframe(Track* &track,
2160 MaskAuto* &keyframe,
2168 track = mwindow->cwindow->calculate_affected_track();
2171 autos = (MaskAutos*)track->automation->autos[AUTOMATION_MASK];
2172 keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(
2178 mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
2185 if(mwindow->cwindow->gui->affected_point < mask->points.total &&
2186 mwindow->cwindow->gui->affected_point >= 0)
2188 point = mask->points.values[mwindow->cwindow->gui->affected_point];
2193 void CWindowMaskGUI::update()
2200 //printf("CWindowMaskGUI::update 1\n");
2201 get_keyframe(track, autos, keyframe, mask, point, 0);
2203 double position = mwindow->edl->local_session->get_selectionstart(1);
2204 position = mwindow->edl->align_to_frame(position, 0);
2207 int64_t position_i = track->to_units(position, 0);
2211 x->update(point->x);
2212 y->update(point->y);
2217 feather->update((int64_t)autos->get_feather(position_i, PLAY_FORWARD));
2218 value->update((int64_t)autos->get_value(position_i, PLAY_FORWARD));
2219 apply_before_plugins->update((int64_t)keyframe->apply_before_plugins);
2220 disable_opengl_masking->update((int64_t)keyframe->disable_opengl_masking);
2224 //printf("CWindowMaskGUI::update 1\n");
2225 active_point->update((int64_t)mwindow->cwindow->gui->affected_point);
2226 number->update((int64_t)mwindow->edl->session->cwindow_mask);
2228 //printf("CWindowMaskGUI::update 1\n");
2231 #ifdef USE_KEYFRAME_SPANNING
2233 CWindowMaskMode::mode_to_text(keyframe->mode));
2236 CWindowMaskMode::mode_to_text(((MaskAuto*)autos->default_auto)->mode));
2239 //printf("CWindowMaskGUI::update 2\n");
2242 void CWindowMaskGUI::handle_event()
2249 get_keyframe(track, autos, keyframe, mask, point, 0);
2251 mwindow->undo->update_undo_before(_("mask point"), this);
2255 #ifdef USE_KEYFRAME_SPANNING
2256 // Create temp keyframe
2257 MaskAuto temp_keyframe(mwindow->edl, autos);
2258 temp_keyframe.copy_data(keyframe);
2259 // Get affected point in temp keyframe
2260 mask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
2261 if(mwindow->cwindow->gui->affected_point < mask->points.total &&
2262 mwindow->cwindow->gui->affected_point >= 0)
2264 point = mask->points.values[mwindow->cwindow->gui->affected_point];
2269 point->x = atof(x->get_text());
2270 point->y = atof(y->get_text());
2271 // Commit to spanned keyframes
2272 autos->update_parameter(&temp_keyframe);
2275 point->x = atof(x->get_text());
2276 point->y = atof(y->get_text());
2281 mwindow->undo->update_undo_after(_("mask point"), LOAD_AUTOMATION);
2284 void CWindowMaskGUI::update_preview()
2286 mwindow->gui->lock_window("CWindowMaskGUI::update_preview");
2287 mwindow->restart_brender();
2288 mwindow->sync_parameters(CHANGE_PARAMS);
2289 mwindow->gui->draw_overlays(1);
2290 mwindow->gui->unlock_window();
2291 mwindow->cwindow->refresh_frame(CHANGE_NONE);
2292 mwindow->cwindow->gui->lock_window("CWindowMaskGUI::update_preview");
2293 mwindow->cwindow->gui->canvas->draw_refresh();
2294 mwindow->cwindow->gui->unlock_window();
2298 CWindowRulerGUI::CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread)
2299 : CWindowToolGUI(mwindow,
2301 _(PROGRAM_NAME ": Ruler"),
2307 CWindowRulerGUI::~CWindowRulerGUI()
2311 void CWindowRulerGUI::create_objects()
2313 int x = 10, y = 10, x1 = 100;
2316 lock_window("CWindowRulerGUI::create_objects");
2317 add_subwindow(title = new BC_Title(x, y, _("Current:")));
2318 add_subwindow(current = new BC_TextBox(x1, y, 200, 1, ""));
2319 y += title->get_h() + 5;
2320 add_subwindow(title = new BC_Title(x, y, _("Point 1:")));
2321 add_subwindow(point1 = new BC_TextBox(x1, y, 200, 1, ""));
2322 y += title->get_h() + 5;
2323 add_subwindow(title = new BC_Title(x, y, _("Point 2:")));
2324 add_subwindow(point2 = new BC_TextBox(x1, y, 200, 1, ""));
2325 y += title->get_h() + 5;
2326 add_subwindow(title = new BC_Title(x, y, _("Deltas:")));
2327 add_subwindow(deltas = new BC_TextBox(x1, y, 200, 1, ""));
2328 y += title->get_h() + 5;
2329 add_subwindow(title = new BC_Title(x, y, _("Distance:")));
2330 add_subwindow(distance = new BC_TextBox(x1, y, 200, 1, ""));
2331 y += title->get_h() + 5;
2332 add_subwindow(title = new BC_Title(x, y, _("Angle:")));
2333 add_subwindow(angle = new BC_TextBox(x1, y, 200, 1, ""));
2334 y += title->get_h() + 10;
2335 char string[BCTEXTLEN];
2337 _("Press Ctrl to lock ruler to the\nnearest 45%c%c angle."),
2338 0xc2, 0xb0); // degrees utf
2339 add_subwindow(title = new BC_Title(x,
2342 y += title->get_h() + 10;
2343 sprintf(string, _("Press Alt to translate the ruler."));
2344 add_subwindow(title = new BC_Title(x,
2351 void CWindowRulerGUI::update()
2353 char string[BCTEXTLEN];
2354 int cx = mwindow->session->cwindow_output_x;
2355 int cy = mwindow->session->cwindow_output_y;
2356 sprintf(string, "%d, %d", cx, cy);
2357 current->update(string);
2358 double x1 = mwindow->edl->session->ruler_x1;
2359 double y1 = mwindow->edl->session->ruler_y1;
2360 sprintf(string, "%.0f, %.0f", x1, y1);
2361 point1->update(string);
2362 double x2 = mwindow->edl->session->ruler_x2;
2363 double y2 = mwindow->edl->session->ruler_y2;
2364 sprintf(string, "%.0f, %.0f", x2, y2);
2365 point2->update(string);
2366 double dx = x2 - x1, dy = y2 - y1;
2367 sprintf(string, "%s%.0f, %s%.0f", (dx>=0? "+":""), dx, (dy>=0? "+":""), dy);
2368 deltas->update(string);
2369 double d = sqrt(dx*dx + dy*dy);
2370 sprintf(string, _("%0.01f pixels"), d);
2371 distance->update(string);
2372 double a = d > 0 ? (atan2(-dy, dx) * 180/M_PI) : 0.;
2373 sprintf(string, "%0.02f %c%c", a, 0xc2, 0xb0);
2374 angle->update(string);
2377 void CWindowRulerGUI::handle_event()