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->lock_window("CWindowCameraGUI::update");
917 thread->gui->composite_panel->cpanel_zoom->update(value);
918 thread->gui->unlock_window();
921 if( x_auto && y_auto && z_auto )
923 t_smooth->check_toggle_state(x_auto, y_auto, z_auto);
924 t_linear->check_toggle_state(x_auto, y_auto, z_auto);
931 CWindowCameraLeft::CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
932 : BC_Button(x, y, mwindow->theme->get_image_set("left_justify"))
935 this->mwindow = mwindow;
936 set_tooltip(_("Left justify"));
938 int CWindowCameraLeft::handle_event()
940 FloatAuto *x_auto = 0;
941 FloatAuto *z_auto = 0;
942 Track *track = mwindow->cwindow->calculate_affected_track();
945 mwindow->cwindow->calculate_affected_autos(&x_auto,
958 track->get_source_dimensions(
959 mwindow->edl->local_session->get_selectionstart(1),
965 mwindow->undo->update_undo_before(_("camera"), 0);
967 (double)track->track_w / z_auto->get_value() / 2 -
969 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
971 gui->update_preview();
979 CWindowCameraCenter::CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
980 : BC_Button(x, y, mwindow->theme->get_image_set("center_justify"))
983 this->mwindow = mwindow;
984 set_tooltip(_("Center horizontal"));
986 int CWindowCameraCenter::handle_event()
988 FloatAuto *x_auto = 0;
989 Track *track = mwindow->cwindow->calculate_affected_track();
991 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
992 track->automation->autos[AUTOMATION_CAMERA_X],
997 mwindow->undo->update_undo_before(_("camera"), 0);
998 x_auto->set_value(0);
1000 gui->update_preview();
1001 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1008 CWindowCameraRight::CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1009 : BC_Button(x, y, mwindow->theme->get_image_set("right_justify"))
1012 this->mwindow = mwindow;
1013 set_tooltip(_("Right justify"));
1015 int CWindowCameraRight::handle_event()
1017 FloatAuto *x_auto = 0;
1018 FloatAuto *z_auto = 0;
1019 Track *track = mwindow->cwindow->calculate_affected_track();
1022 mwindow->cwindow->calculate_affected_autos(&x_auto,
1032 if(x_auto && z_auto)
1035 track->get_source_dimensions(
1036 mwindow->edl->local_session->get_selectionstart(1),
1042 mwindow->undo->update_undo_before(_("camera"), 0);
1043 x_auto->set_value( -((double)track->track_w / z_auto->get_value() / 2 -
1046 gui->update_preview();
1047 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1055 CWindowCameraTop::CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1056 : BC_Button(x, y, mwindow->theme->get_image_set("top_justify"))
1059 this->mwindow = mwindow;
1060 set_tooltip(_("Top justify"));
1062 int CWindowCameraTop::handle_event()
1064 FloatAuto *y_auto = 0;
1065 FloatAuto *z_auto = 0;
1066 Track *track = mwindow->cwindow->calculate_affected_track();
1069 mwindow->cwindow->calculate_affected_autos(0,
1079 if(y_auto && z_auto)
1082 track->get_source_dimensions(
1083 mwindow->edl->local_session->get_selectionstart(1),
1089 mwindow->undo->update_undo_before(_("camera"), 0);
1090 y_auto->set_value((double)track->track_h / z_auto->get_value() / 2 -
1093 gui->update_preview();
1094 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1102 CWindowCameraMiddle::CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1103 : BC_Button(x, y, mwindow->theme->get_image_set("middle_justify"))
1106 this->mwindow = mwindow;
1107 set_tooltip(_("Center vertical"));
1109 int CWindowCameraMiddle::handle_event()
1111 FloatAuto *y_auto = 0;
1112 Track *track = mwindow->cwindow->calculate_affected_track();
1114 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1115 track->automation->autos[AUTOMATION_CAMERA_Y], 1);
1119 mwindow->undo->update_undo_before(_("camera"), 0);
1120 y_auto->set_value(0);
1122 gui->update_preview();
1123 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1130 CWindowCameraBottom::CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1131 : BC_Button(x, y, mwindow->theme->get_image_set("bottom_justify"))
1134 this->mwindow = mwindow;
1135 set_tooltip(_("Bottom justify"));
1137 int CWindowCameraBottom::handle_event()
1139 FloatAuto *y_auto = 0;
1140 FloatAuto *z_auto = 0;
1141 Track *track = mwindow->cwindow->calculate_affected_track();
1144 mwindow->cwindow->calculate_affected_autos(0,
1154 if(y_auto && z_auto)
1157 track->get_source_dimensions(
1158 mwindow->edl->local_session->get_selectionstart(1),
1164 mwindow->undo->update_undo_before(_("camera"), 0);
1165 y_auto->set_value(-((double)track->track_h / z_auto->get_value() / 2 -
1168 gui->update_preview();
1169 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1177 CWindowProjectorGUI::CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread)
1178 : CWindowToolGUI(mwindow,
1180 _(PROGRAM_NAME ": Projector"),
1185 CWindowProjectorGUI::~CWindowProjectorGUI()
1188 void CWindowProjectorGUI::create_objects()
1190 int x = 10, y = 10, x1;
1191 Track *track = mwindow->cwindow->calculate_affected_track();
1192 FloatAuto *x_auto = 0;
1193 FloatAuto *y_auto = 0;
1194 FloatAuto *z_auto = 0;
1198 lock_window("CWindowProjectorGUI::create_objects");
1201 mwindow->cwindow->calculate_affected_autos(&x_auto,
1211 add_subwindow(title = new BC_Title(x, y, "X:"));
1212 x += title->get_w();
1213 this->x = new CWindowCoord(this, x, y,
1214 x_auto ? x_auto->get_value() : (float)0);
1215 this->x->create_objects();
1218 add_subwindow(title = new BC_Title(x, y, "Y:"));
1219 x += title->get_w();
1220 this->y = new CWindowCoord(this, x, y,
1221 y_auto ? y_auto->get_value() : (float)0);
1222 this->y->create_objects();
1225 add_subwindow(title = new BC_Title(x, y, "Z:"));
1226 x += title->get_w();
1227 this->z = new CWindowCoord(this, x, y,
1228 z_auto ? z_auto->get_value() : (float)1);
1229 this->z->create_objects();
1230 this->z->set_increment(0.01);
1234 add_subwindow(button = new CWindowProjectorLeft(mwindow, this, x1, y));
1235 x1 += button->get_w();
1236 add_subwindow(button = new CWindowProjectorCenter(mwindow, this, x1, y));
1237 x1 += button->get_w();
1238 add_subwindow(button = new CWindowProjectorRight(mwindow, this, x1, y));
1240 y += button->get_h();
1242 add_subwindow(button = new CWindowProjectorTop(mwindow, this, x1, y));
1243 x1 += button->get_w();
1244 add_subwindow(button = new CWindowProjectorMiddle(mwindow, this, x1, y));
1245 x1 += button->get_w();
1246 add_subwindow(button = new CWindowProjectorBottom(mwindow, this, x1, y));
1248 // additional Buttons to control the curve mode of the "current" keyframe
1249 x1 += button->get_w() + 15;
1250 add_subwindow(this->t_smooth = new CWindowCurveToggle(Projector_Crv_Smooth, mwindow, this, x1, y));
1251 x1 += button->get_w();
1252 add_subwindow(this->t_linear = new CWindowCurveToggle(Projector_Crv_Linear, mwindow, this, x1, y));
1254 // fill in current auto keyframe values, set toggle states.
1259 void CWindowProjectorGUI::update_preview()
1261 mwindow->gui->lock_window("CWindowProjectorGUI::update_preview");
1262 mwindow->restart_brender();
1263 mwindow->sync_parameters(CHANGE_PARAMS);
1264 mwindow->gui->draw_overlays(1);
1265 mwindow->gui->unlock_window();
1266 mwindow->cwindow->refresh_frame(CHANGE_NONE);
1267 mwindow->cwindow->gui->lock_window("CWindowProjectorGUI::update_preview");
1268 mwindow->cwindow->gui->canvas->draw_refresh();
1269 mwindow->cwindow->gui->unlock_window();
1272 void CWindowProjectorGUI::handle_event()
1274 FloatAuto *x_auto = 0;
1275 FloatAuto *y_auto = 0;
1276 FloatAuto *z_auto = 0;
1277 Track *track = mwindow->cwindow->calculate_affected_track();
1281 mwindow->undo->update_undo_before(_("projector"), this);
1282 if(event_caller == x)
1284 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1285 track->automation->autos[AUTOMATION_PROJECTOR_X],
1289 x_auto->set_value(atof(x->get_text()));
1295 if(event_caller == y)
1297 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1298 track->automation->autos[AUTOMATION_PROJECTOR_Y],
1302 y_auto->set_value(atof(y->get_text()));
1308 if(event_caller == z)
1310 z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1311 track->automation->autos[AUTOMATION_PROJECTOR_Z],
1315 float zoom = atof(z->get_text());
1316 if(zoom > 100.) zoom = 100.;
1317 else if(zoom < 0.01) zoom = 0.01;
1318 // if (zoom != atof(z->get_text()))
1320 z_auto->set_value(zoom);
1322 mwindow->gui->lock_window("CWindowProjectorGUI::handle_event");
1323 mwindow->gui->draw_overlays(1);
1324 mwindow->gui->unlock_window();
1330 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1334 void CWindowProjectorGUI::update()
1336 FloatAuto *x_auto = 0;
1337 FloatAuto *y_auto = 0;
1338 FloatAuto *z_auto = 0;
1339 Track *track = mwindow->cwindow->calculate_affected_track();
1343 mwindow->cwindow->calculate_affected_autos(&x_auto,
1354 x->update(x_auto->get_value());
1356 y->update(y_auto->get_value());
1358 float value = z_auto->get_value();
1360 thread->gui->lock_window("CWindowProjectorGUI::update");
1361 thread->gui->composite_panel->cpanel_zoom->update(value);
1362 thread->gui->unlock_window();
1365 if( x_auto && y_auto && z_auto )
1367 t_smooth->check_toggle_state(x_auto, y_auto, z_auto);
1368 t_linear->check_toggle_state(x_auto, y_auto, z_auto);
1372 CWindowProjectorLeft::CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1373 : BC_Button(x, y, mwindow->theme->get_image_set("left_justify"))
1376 this->mwindow = mwindow;
1377 set_tooltip(_("Left justify"));
1379 int CWindowProjectorLeft::handle_event()
1381 FloatAuto *x_auto = 0;
1382 FloatAuto *z_auto = 0;
1383 Track *track = mwindow->cwindow->calculate_affected_track();
1386 mwindow->cwindow->calculate_affected_autos(&x_auto,
1395 if(x_auto && z_auto)
1397 mwindow->undo->update_undo_before(_("projector"), 0);
1398 x_auto->set_value( (double)track->track_w * z_auto->get_value() / 2 -
1399 (double)mwindow->edl->session->output_w / 2 );
1401 gui->update_preview();
1402 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1409 CWindowProjectorCenter::CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1410 : BC_Button(x, y, mwindow->theme->get_image_set("center_justify"))
1413 this->mwindow = mwindow;
1414 set_tooltip(_("Center horizontal"));
1416 int CWindowProjectorCenter::handle_event()
1418 FloatAuto *x_auto = 0;
1419 Track *track = mwindow->cwindow->calculate_affected_track();
1421 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1422 track->automation->autos[AUTOMATION_PROJECTOR_X],
1427 mwindow->undo->update_undo_before(_("projector"), 0);
1428 x_auto->set_value(0);
1430 gui->update_preview();
1431 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1438 CWindowProjectorRight::CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1439 : BC_Button(x, y, mwindow->theme->get_image_set("right_justify"))
1442 this->mwindow = mwindow;
1443 set_tooltip(_("Right justify"));
1445 int CWindowProjectorRight::handle_event()
1447 FloatAuto *x_auto = 0;
1448 FloatAuto *z_auto = 0;
1449 Track *track = mwindow->cwindow->calculate_affected_track();
1452 mwindow->cwindow->calculate_affected_autos(&x_auto,
1462 if(x_auto && z_auto)
1464 mwindow->undo->update_undo_before(_("projector"), 0);
1465 x_auto->set_value( -((double)track->track_w * z_auto->get_value() / 2 -
1466 (double)mwindow->edl->session->output_w / 2));
1468 gui->update_preview();
1469 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1476 CWindowProjectorTop::CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1477 : BC_Button(x, y, mwindow->theme->get_image_set("top_justify"))
1480 this->mwindow = mwindow;
1481 set_tooltip(_("Top justify"));
1483 int CWindowProjectorTop::handle_event()
1485 FloatAuto *y_auto = 0;
1486 FloatAuto *z_auto = 0;
1487 Track *track = mwindow->cwindow->calculate_affected_track();
1490 mwindow->cwindow->calculate_affected_autos(0,
1500 if(y_auto && z_auto)
1502 mwindow->undo->update_undo_before(_("projector"), 0);
1503 y_auto->set_value( (double)track->track_h * z_auto->get_value() / 2 -
1504 (double)mwindow->edl->session->output_h / 2 );
1506 gui->update_preview();
1507 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1514 CWindowProjectorMiddle::CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1515 : BC_Button(x, y, mwindow->theme->get_image_set("middle_justify"))
1518 this->mwindow = mwindow;
1519 set_tooltip(_("Center vertical"));
1521 int CWindowProjectorMiddle::handle_event()
1523 FloatAuto *y_auto = 0;
1524 Track *track = mwindow->cwindow->calculate_affected_track();
1526 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1527 track->automation->autos[AUTOMATION_PROJECTOR_Y], 1);
1531 mwindow->undo->update_undo_before(_("projector"), 0);
1532 y_auto->set_value(0);
1534 gui->update_preview();
1535 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1542 CWindowProjectorBottom::CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1543 : BC_Button(x, y, mwindow->theme->get_image_set("bottom_justify"))
1546 this->mwindow = mwindow;
1547 set_tooltip(_("Bottom justify"));
1549 int CWindowProjectorBottom::handle_event()
1551 FloatAuto *y_auto = 0;
1552 FloatAuto *z_auto = 0;
1553 Track *track = mwindow->cwindow->calculate_affected_track();
1556 mwindow->cwindow->calculate_affected_autos(0,
1566 if(y_auto && z_auto)
1568 mwindow->undo->update_undo_before(_("projector"), 0);
1569 y_auto->set_value( -((double)track->track_h * z_auto->get_value() / 2 -
1570 (double)mwindow->edl->session->output_h / 2));
1572 gui->update_preview();
1573 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1580 CWindowMaskMode::CWindowMaskMode(MWindow *mwindow,
1581 CWindowToolGUI *gui, int x, int y, const char *text)
1582 : BC_PopupMenu(x, y, 220, text, 1)
1584 this->mwindow = mwindow;
1588 void CWindowMaskMode::create_objects()
1590 add_item(new BC_MenuItem(mode_to_text(MASK_MULTIPLY_ALPHA)));
1591 add_item(new BC_MenuItem(mode_to_text(MASK_SUBTRACT_ALPHA)));
1594 char* CWindowMaskMode::mode_to_text(int mode)
1598 case MASK_MULTIPLY_ALPHA:
1599 return _("Multiply alpha");
1602 case MASK_SUBTRACT_ALPHA:
1603 return _("Subtract alpha");
1607 return _("Subtract alpha");
1610 int CWindowMaskMode::text_to_mode(char *text)
1612 if(!strcasecmp(text, _("Multiply alpha")))
1613 return MASK_MULTIPLY_ALPHA;
1615 if(!strcasecmp(text, _("Subtract alpha")))
1616 return MASK_SUBTRACT_ALPHA;
1618 return MASK_SUBTRACT_ALPHA;
1621 int CWindowMaskMode::handle_event()
1628 // Get existing keyframe
1629 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1632 mwindow->undo->update_undo_before(_("mask mode"), 0);
1633 #ifdef USE_KEYFRAME_SPANNING
1634 // Create temp keyframe
1635 MaskAuto temp_keyframe(mwindow->edl, autos);
1636 temp_keyframe.copy_data(keyframe);
1638 temp_keyframe.mode = text_to_mode(get_text());
1639 // Commit change to span of keyframes
1640 autos->update_parameter(&temp_keyframe);
1642 ((MaskAuto*)autos->default_auto)->mode =
1643 text_to_mode(get_text());
1645 mwindow->undo->update_undo_after(_("mask mode"), LOAD_AUTOMATION);
1648 //printf("CWindowMaskMode::handle_event 1\n");
1649 gui->update_preview();
1660 CWindowMaskDelete::CWindowMaskDelete(MWindow *mwindow,
1661 CWindowToolGUI *gui,
1664 : BC_GenericButton(x, y, _("Delete"))
1666 this->mwindow = mwindow;
1670 int CWindowMaskDelete::handle_event()
1677 int total_points = 0;
1679 // Get existing keyframe
1680 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1684 mwindow->undo->update_undo_before(_("mask delete"), 0);
1686 #ifdef USE_KEYFRAME_SPANNING
1687 // Create temp keyframe
1688 MaskAuto temp_keyframe(mwindow->edl, autos);
1689 temp_keyframe.copy_data(keyframe);
1691 SubMask *submask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
1693 submask->points.remove_all_objects();
1695 for(int i = mwindow->cwindow->gui->affected_point;
1696 i < submask->points.total - 1;
1699 *submask->points.values[i] = *submask->points.values[i + 1];
1702 if(submask->points.total)
1704 submask->points.remove_object(
1705 submask->points.values[submask->points.total - 1]);
1707 total_points = submask->points.total;
1709 // Commit change to span of keyframes
1710 ((MaskAutos*)track->automation->autos[AUTOMATION_MASK])->update_parameter(&temp_keyframe);
1712 for(MaskAuto *current = (MaskAuto*)autos->default_auto;
1715 SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
1717 submask->points.remove_all_objects();
1719 for(int i = mwindow->cwindow->gui->affected_point;
1720 i < submask->points.total - 1;
1723 *submask->points.values[i] = *submask->points.values[i + 1];
1726 if(submask->points.total)
1728 submask->points.remove_object(
1729 submask->points.values[submask->points.total - 1]);
1731 total_points = submask->points.total;
1733 if(current == (MaskAuto*)autos->default_auto)
1734 current = (MaskAuto*)autos->first;
1736 current = (MaskAuto*)NEXT;
1739 if( mwindow->cwindow->gui->affected_point >= total_points )
1740 mwindow->cwindow->gui->affected_point =
1741 total_points > 0 ? total_points-1 : 0;
1744 gui->update_preview();
1745 mwindow->undo->update_undo_after(_("mask delete"), LOAD_AUTOMATION);
1752 int CWindowMaskDelete::keypress_event()
1754 if(get_keypress() == BACKSPACE ||
1755 get_keypress() == DELETE)
1756 return handle_event();
1761 // CWindowMaskCycleNext::CWindowMaskCycleNext(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1762 // : BC_GenericButton(x, y, _("Cycle next"))
1764 // this->mwindow = mwindow;
1767 // int CWindowMaskCycleNext::handle_event()
1769 // MaskAuto *keyframe;
1770 // MaskAutos *autos;
1772 // MaskPoint *point;
1774 // ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1778 // // Should apply to all keyframes
1779 // if(keyframe && mask->points.total)
1781 // temp = mask->points.values[0];
1783 // for(int i = 0; i < mask->points.total - 1; i++)
1785 // mask->points.values[i] = mask->points.values[i + 1];
1787 // mask->points.values[mask->points.total - 1] = temp;
1789 // mwindow->cwindow->gui->affected_point--;
1790 // if(mwindow->cwindow->gui->affected_point < 0)
1791 // mwindow->cwindow->gui->affected_point = mask->points.total - 1;
1794 // gui->update_preview();
1800 // CWindowMaskCyclePrev::CWindowMaskCyclePrev(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1801 // : BC_GenericButton(x, y, _("Cycle prev"))
1803 // this->mwindow = mwindow;
1806 // int CWindowMaskCyclePrev::handle_event()
1808 // MaskAuto *keyframe;
1809 // MaskAutos *autos;
1811 // MaskPoint *point;
1813 // ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1815 // // Should apply to all keyframes
1817 // if(keyframe && mask->points.total)
1819 // temp = mask->points.values[mask->points.total - 1];
1821 // for(int i = mask->points.total - 1; i > 0; i--)
1823 // mask->points.values[i] = mask->points.values[i - 1];
1825 // mask->points.values[0] = temp;
1827 // mwindow->cwindow->gui->affected_point++;
1828 // if(mwindow->cwindow->gui->affected_point >= mask->points.total)
1829 // mwindow->cwindow->gui->affected_point = 0;
1832 // gui->update_preview();
1838 CWindowMaskNumber::CWindowMaskNumber(MWindow *mwindow,
1839 CWindowToolGUI *gui,
1842 : BC_TumbleTextBox(gui,
1843 (int64_t)mwindow->edl->session->cwindow_mask,
1845 (int64_t)SUBMASKS - 1,
1850 this->mwindow = mwindow;
1854 CWindowMaskNumber::~CWindowMaskNumber()
1858 int CWindowMaskNumber::handle_event()
1860 mwindow->edl->session->cwindow_mask = atol(get_text());
1862 gui->update_preview();
1867 CWindowMaskAffectedPoint::CWindowMaskAffectedPoint(MWindow *mwindow,
1868 CWindowToolGUI *gui, int x, int y)
1869 : BC_TumbleTextBox(gui,
1870 (int64_t)mwindow->cwindow->gui->affected_point,
1871 (int64_t)0, INT64_MAX, x, y, 100)
1873 this->mwindow = mwindow;
1877 CWindowMaskAffectedPoint::~CWindowMaskAffectedPoint()
1881 int CWindowMaskAffectedPoint::handle_event()
1883 int total_points = 0;
1884 int affected_point = atol(get_text());
1885 Track *track = mwindow->cwindow->calculate_affected_track();
1887 MaskAutos *autos = (MaskAutos*)track->automation->autos[AUTOMATION_MASK];
1888 MaskAuto *keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(autos, 0);
1890 SubMask *mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
1891 total_points = mask->points.size();
1894 int active_point = affected_point;
1895 if( affected_point >= total_points )
1896 affected_point = total_points - 1;
1897 else if( affected_point < 0 )
1899 if( active_point != affected_point )
1900 update((int64_t)affected_point);
1901 mwindow->cwindow->gui->affected_point = affected_point;
1903 gui->update_preview();
1911 CWindowMaskFeather::CWindowMaskFeather(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1912 : BC_TumbleTextBox(gui,
1920 this->mwindow = mwindow;
1923 CWindowMaskFeather::~CWindowMaskFeather()
1926 int CWindowMaskFeather::handle_event()
1933 #ifdef USE_KEYFRAME_SPANNING
1939 mwindow->undo->update_undo_before(_("mask feather"), this);
1941 // Get existing keyframe
1942 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe,
1943 mask, point, create_it);
1947 #ifdef USE_KEYFRAME_SPANNING
1948 // Create temp keyframe
1949 MaskAuto temp_keyframe(mwindow->edl, autos);
1950 temp_keyframe.copy_data(keyframe);
1952 temp_keyframe.feather = atof(get_text());
1953 // Commit change to span of keyframes
1954 autos->update_parameter(&temp_keyframe);
1956 keyframe->feather = atof(get_text());
1959 gui->update_preview();
1962 mwindow->undo->update_undo_after(_("mask feather"), LOAD_AUTOMATION);
1967 CWindowMaskValue::CWindowMaskValue(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1977 this->mwindow = mwindow;
1981 CWindowMaskValue::~CWindowMaskValue()
1985 int CWindowMaskValue::handle_event()
1992 #ifdef USE_KEYFRAME_SPANNING
1998 mwindow->undo->update_undo_before(_("mask value"), this);
1999 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe,
2000 mask, point, create_it);
2004 #ifdef USE_KEYFRAME_SPANNING
2005 // Create temp keyframe
2006 MaskAuto temp_keyframe(mwindow->edl, autos);
2007 temp_keyframe.copy_data(keyframe);
2009 temp_keyframe.value = get_value();
2010 // Commit change to span of keyframes
2011 autos->update_parameter(&temp_keyframe);
2013 keyframe->value = get_value();
2017 gui->update_preview();
2018 mwindow->undo->update_undo_after(_("mask value"), LOAD_AUTOMATION);
2023 CWindowMaskBeforePlugins::CWindowMaskBeforePlugins(CWindowToolGUI *gui, int x, int y)
2027 _("Apply mask before plugins"))
2032 int CWindowMaskBeforePlugins::handle_event()
2039 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 1);
2042 keyframe->apply_before_plugins = get_value();
2043 gui->update_preview();
2049 CWindowDisableOpenGLMasking::CWindowDisableOpenGLMasking(CWindowToolGUI *gui, int x, int y)
2050 : BC_CheckBox(x, y, 1, _("Disable OpenGL masking"))
2055 int CWindowDisableOpenGLMasking::handle_event()
2062 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 1);
2065 keyframe->disable_opengl_masking = get_value();
2066 gui->update_preview();
2079 CWindowMaskGUI::CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread)
2080 : CWindowToolGUI(mwindow, thread,
2081 _(PROGRAM_NAME ": Mask"), 330, 320)
2083 this->mwindow = mwindow;
2084 this->thread = thread;
2089 CWindowMaskGUI::~CWindowMaskGUI()
2091 lock_window("CWindowMaskGUI::~CWindowMaskGUI");
2093 delete active_point;
2098 void CWindowMaskGUI::create_objects()
2100 int x = 10, y = 10, margin = mwindow->theme->widget_border;
2101 //MaskAuto *keyframe = 0;
2102 //Track *track = mwindow->cwindow->calculate_affected_track();
2104 // keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->autos[AUTOMATION_MASK], 0);
2106 lock_window("CWindowMaskGUI::create_objects");
2108 add_subwindow(title = new BC_Title(x, y, _("Mode:")));
2109 add_subwindow(mode = new CWindowMaskMode(mwindow,
2110 this, x + title->get_w() + margin, y, ""));
2111 mode->create_objects();
2112 y += mode->get_h() + margin;
2113 add_subwindow(title = new BC_Title(x, y, _("Value:")));
2114 add_subwindow(value = new CWindowMaskValue(mwindow, this, x + title->get_w() + margin, y));
2115 y += value->get_h() + margin;
2116 add_subwindow(delete_point = new CWindowMaskDelete(mwindow, this, x, y));
2117 int x1 = x + delete_point->get_w() + 2*margin;
2118 add_subwindow(title = new BC_Title(x1, y, _("Point:")));
2119 x1 += title->get_w() + margin;
2120 active_point = new CWindowMaskAffectedPoint(mwindow, this, x1, y);
2121 active_point->create_objects();
2122 y += delete_point->get_h() + margin;
2123 add_subwindow(title = new BC_Title(x, y, _("Mask number:")));
2124 number = new CWindowMaskNumber(mwindow,
2125 this, x + title->get_w() + margin, y);
2126 number->create_objects();
2127 y += number->get_h() + margin;
2128 add_subwindow(title = new BC_Title(x, y, _("Feather:")));
2129 feather = new CWindowMaskFeather(mwindow,
2130 this, x + title->get_w() + margin, y);
2131 feather->create_objects();
2132 y += feather->get_h() + margin;
2133 add_subwindow(title = new BC_Title(x, y, "X:"));
2134 x += title->get_w() + margin;
2135 this->x = new CWindowCoord(this, x, y, (float)0.0);
2136 this->x->create_objects();
2137 x += this->x->get_w() + margin;
2138 add_subwindow(title = new BC_Title(x, y, "Y:"));
2139 x += title->get_w() + margin;
2140 this->y = new CWindowCoord(this, x, y, (float)0.0);
2141 this->y->create_objects();
2144 y += this->y->get_h() + margin;
2145 add_subwindow(title = new BC_Title(x, y, _("Press Shift to move an end point")));
2146 y += title->get_h() + margin;
2147 add_subwindow(title = new BC_Title(x, y, _("Press Ctrl to move a control point")));
2148 y += title->get_h() + margin;
2149 add_subwindow(title = new BC_Title(x, y, _("Shift+click Delete to delete the mask")));
2150 y += title->get_h() + margin;
2151 add_subwindow(title = new BC_Title(x, y, _("Press Alt to translate the mask")));
2154 add_subwindow(this->apply_before_plugins = new CWindowMaskBeforePlugins(this, 10, y));
2155 y += this->apply_before_plugins->get_h() + margin;
2156 add_subwindow(this->disable_opengl_masking = new CWindowDisableOpenGLMasking(this, 10, y));
2162 void CWindowMaskGUI::get_keyframe(Track* &track,
2164 MaskAuto* &keyframe,
2172 track = mwindow->cwindow->calculate_affected_track();
2175 autos = (MaskAutos*)track->automation->autos[AUTOMATION_MASK];
2176 keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(
2182 mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
2189 if(mwindow->cwindow->gui->affected_point < mask->points.total &&
2190 mwindow->cwindow->gui->affected_point >= 0)
2192 point = mask->points.values[mwindow->cwindow->gui->affected_point];
2197 void CWindowMaskGUI::update()
2204 //printf("CWindowMaskGUI::update 1\n");
2205 get_keyframe(track, autos, keyframe, mask, point, 0);
2207 double position = mwindow->edl->local_session->get_selectionstart(1);
2208 position = mwindow->edl->align_to_frame(position, 0);
2211 int64_t position_i = track->to_units(position, 0);
2215 x->update(point->x);
2216 y->update(point->y);
2221 feather->update((int64_t)autos->get_feather(position_i, PLAY_FORWARD));
2222 value->update((int64_t)autos->get_value(position_i, PLAY_FORWARD));
2223 apply_before_plugins->update((int64_t)keyframe->apply_before_plugins);
2224 disable_opengl_masking->update((int64_t)keyframe->disable_opengl_masking);
2228 //printf("CWindowMaskGUI::update 1\n");
2229 active_point->update((int64_t)mwindow->cwindow->gui->affected_point);
2230 number->update((int64_t)mwindow->edl->session->cwindow_mask);
2232 //printf("CWindowMaskGUI::update 1\n");
2235 #ifdef USE_KEYFRAME_SPANNING
2237 CWindowMaskMode::mode_to_text(keyframe->mode));
2240 CWindowMaskMode::mode_to_text(((MaskAuto*)autos->default_auto)->mode));
2243 //printf("CWindowMaskGUI::update 2\n");
2246 void CWindowMaskGUI::handle_event()
2253 get_keyframe(track, autos, keyframe, mask, point, 0);
2255 mwindow->undo->update_undo_before(_("mask point"), this);
2259 #ifdef USE_KEYFRAME_SPANNING
2260 // Create temp keyframe
2261 MaskAuto temp_keyframe(mwindow->edl, autos);
2262 temp_keyframe.copy_data(keyframe);
2263 // Get affected point in temp keyframe
2264 mask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
2265 if(mwindow->cwindow->gui->affected_point < mask->points.total &&
2266 mwindow->cwindow->gui->affected_point >= 0)
2268 point = mask->points.values[mwindow->cwindow->gui->affected_point];
2273 point->x = atof(x->get_text());
2274 point->y = atof(y->get_text());
2275 // Commit to spanned keyframes
2276 autos->update_parameter(&temp_keyframe);
2279 point->x = atof(x->get_text());
2280 point->y = atof(y->get_text());
2285 mwindow->undo->update_undo_after(_("mask point"), LOAD_AUTOMATION);
2288 void CWindowMaskGUI::update_preview()
2290 mwindow->gui->lock_window("CWindowMaskGUI::update_preview");
2291 mwindow->restart_brender();
2292 mwindow->sync_parameters(CHANGE_PARAMS);
2293 mwindow->gui->draw_overlays(1);
2294 mwindow->gui->unlock_window();
2295 mwindow->cwindow->refresh_frame(CHANGE_NONE);
2296 mwindow->cwindow->gui->lock_window("CWindowMaskGUI::update_preview");
2297 mwindow->cwindow->gui->canvas->draw_refresh();
2298 mwindow->cwindow->gui->unlock_window();
2302 CWindowRulerGUI::CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread)
2303 : CWindowToolGUI(mwindow,
2305 _(PROGRAM_NAME ": Ruler"),
2311 CWindowRulerGUI::~CWindowRulerGUI()
2315 void CWindowRulerGUI::create_objects()
2317 int x = 10, y = 10, x1 = 100;
2320 lock_window("CWindowRulerGUI::create_objects");
2321 add_subwindow(title = new BC_Title(x, y, _("Current:")));
2322 add_subwindow(current = new BC_TextBox(x1, y, 200, 1, ""));
2323 y += title->get_h() + 5;
2324 add_subwindow(title = new BC_Title(x, y, _("Point 1:")));
2325 add_subwindow(point1 = new BC_TextBox(x1, y, 200, 1, ""));
2326 y += title->get_h() + 5;
2327 add_subwindow(title = new BC_Title(x, y, _("Point 2:")));
2328 add_subwindow(point2 = new BC_TextBox(x1, y, 200, 1, ""));
2329 y += title->get_h() + 5;
2330 add_subwindow(title = new BC_Title(x, y, _("Deltas:")));
2331 add_subwindow(deltas = new BC_TextBox(x1, y, 200, 1, ""));
2332 y += title->get_h() + 5;
2333 add_subwindow(title = new BC_Title(x, y, _("Distance:")));
2334 add_subwindow(distance = new BC_TextBox(x1, y, 200, 1, ""));
2335 y += title->get_h() + 5;
2336 add_subwindow(title = new BC_Title(x, y, _("Angle:")));
2337 add_subwindow(angle = new BC_TextBox(x1, y, 200, 1, ""));
2338 y += title->get_h() + 10;
2339 char string[BCTEXTLEN];
2341 _("Press Ctrl to lock ruler to the\nnearest 45%c%c angle."),
2342 0xc2, 0xb0); // degrees utf
2343 add_subwindow(title = new BC_Title(x,
2346 y += title->get_h() + 10;
2347 sprintf(string, _("Press Alt to translate the ruler."));
2348 add_subwindow(title = new BC_Title(x,
2355 void CWindowRulerGUI::update()
2357 char string[BCTEXTLEN];
2358 int cx = mwindow->session->cwindow_output_x;
2359 int cy = mwindow->session->cwindow_output_y;
2360 sprintf(string, "%d, %d", cx, cy);
2361 current->update(string);
2362 double x1 = mwindow->edl->session->ruler_x1;
2363 double y1 = mwindow->edl->session->ruler_y1;
2364 sprintf(string, "%.0f, %.0f", x1, y1);
2365 point1->update(string);
2366 double x2 = mwindow->edl->session->ruler_x2;
2367 double y2 = mwindow->edl->session->ruler_y2;
2368 sprintf(string, "%.0f, %.0f", x2, y2);
2369 point2->update(string);
2370 double dx = x2 - x1, dy = y2 - y1;
2371 sprintf(string, "%s%.0f, %s%.0f", (dx>=0? "+":""), dx, (dy>=0? "+":""), dy);
2372 deltas->update(string);
2373 double d = sqrt(dx*dx + dy*dy);
2374 sprintf(string, _("%0.01f pixels"), d);
2375 distance->update(string);
2376 double a = d > 0 ? (atan2(-dy, dx) * 180/M_PI) : 0.;
2377 sprintf(string, "%0.02f %c%c", a, 0xc2, 0xb0);
2378 angle->update(string);
2381 void CWindowRulerGUI::handle_event()