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 Track *track = mwindow->cwindow->calculate_affected_track();
701 FloatAuto *x=0, *y=0, *z=0;
702 mwindow->cwindow->calculate_affected_autos(track,
703 &x, &y, &z, cfg.use_camera, 0,0,0); // don't create new keyframe
704 if( x ) x->change_curve_mode(cfg.mode);
705 if( y ) y->change_curve_mode(cfg.mode);
706 if( z ) z->change_curve_mode(cfg.mode);
709 gui->update_preview();
716 CWindowEyedropCheckBox::CWindowEyedropCheckBox(MWindow *mwindow,
717 CWindowEyedropGUI *gui, int x, int y)
718 : BC_CheckBox(x, y, mwindow->edl->local_session->use_max, _("Use maximum"))
720 this->mwindow = mwindow;
724 int CWindowEyedropCheckBox::handle_event()
726 mwindow->edl->local_session->use_max = get_value();
733 CWindowCameraGUI::CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread)
734 : CWindowToolGUI(mwindow,
736 _(PROGRAM_NAME ": Camera"),
741 CWindowCameraGUI::~CWindowCameraGUI()
745 void CWindowCameraGUI::create_objects()
747 int x = 10, y = 10, x1;
748 Track *track = mwindow->cwindow->calculate_affected_track();
749 FloatAuto *x_auto = 0, *y_auto = 0, *z_auto = 0;
753 lock_window("CWindowCameraGUI::create_objects");
755 mwindow->cwindow->calculate_affected_autos(track,
756 &x_auto, &y_auto, &z_auto, 1, 0, 0, 0);
759 add_subwindow(title = new BC_Title(x, y, "X:"));
761 this->x = new CWindowCoord(this, x, y,
762 x_auto ? x_auto->get_value() : (float)0);
763 this->x->create_objects();
768 add_subwindow(title = new BC_Title(x, y, "Y:"));
770 this->y = new CWindowCoord(this, x, y,
771 y_auto ? y_auto->get_value() : (float)0);
772 this->y->create_objects();
775 add_subwindow(title = new BC_Title(x, y, "Z:"));
777 this->z = new CWindowCoord(this, x, y,
778 z_auto ? z_auto->get_value() : (float)1);
779 this->z->create_objects();
780 this->z->set_increment(0.01);
784 add_subwindow(button = new CWindowCameraLeft(mwindow, this, x1, y));
785 x1 += button->get_w();
786 add_subwindow(button = new CWindowCameraCenter(mwindow, this, x1, y));
787 x1 += button->get_w();
788 add_subwindow(button = new CWindowCameraRight(mwindow, this, x1, y));
790 y += button->get_h();
792 add_subwindow(button = new CWindowCameraTop(mwindow, this, x1, y));
793 x1 += button->get_w();
794 add_subwindow(button = new CWindowCameraMiddle(mwindow, this, x1, y));
795 x1 += button->get_w();
796 add_subwindow(button = new CWindowCameraBottom(mwindow, this, x1, y));
797 // additional Buttons to control the curve mode of the "current" keyframe
798 x1 += button->get_w() + 15;
799 add_subwindow(this->t_smooth = new CWindowCurveToggle(Camera_Crv_Smooth, mwindow, this, x1, y));
800 x1 += button->get_w();
801 add_subwindow(this->t_linear = new CWindowCurveToggle(Camera_Crv_Linear, mwindow, this, x1, y));
803 // fill in current auto keyframe values, set toggle states.
808 void CWindowCameraGUI::update_preview()
810 CWindowGUI *cgui = mwindow->cwindow->gui;
811 cgui->lock_window("CWindowCameraGUI::update_preview");
812 cgui->sync_parameters(CHANGE_PARAMS, 0, 1);
813 cgui->unlock_window();
817 void CWindowCameraGUI::handle_event()
819 FloatAuto *x_auto = 0;
820 FloatAuto *y_auto = 0;
821 FloatAuto *z_auto = 0;
822 Track *track = mwindow->cwindow->calculate_affected_track();
825 mwindow->undo->update_undo_before(_("camera"), this);
826 if(event_caller == x)
828 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
829 track->automation->autos[AUTOMATION_CAMERA_X],
833 x_auto->set_value(atof(x->get_text()));
839 if(event_caller == y)
841 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
842 track->automation->autos[AUTOMATION_CAMERA_Y],
846 y_auto->set_value(atof(y->get_text()));
852 if(event_caller == z)
854 z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
855 track->automation->autos[AUTOMATION_CAMERA_Z],
859 float zoom = atof(z->get_text());
860 if(zoom > 100.) zoom = 100.;
862 if(zoom < 0.01) zoom = 0.01;
863 // Doesn't allow user to enter from scratch
864 // if(zoom != atof(z->get_text()))
867 z_auto->set_value(zoom);
868 mwindow->gui->lock_window("CWindowCameraGUI::handle_event");
869 mwindow->gui->draw_overlays(1);
870 mwindow->gui->unlock_window();
876 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
880 void CWindowCameraGUI::update()
882 FloatAuto *x_auto = 0;
883 FloatAuto *y_auto = 0;
884 FloatAuto *z_auto = 0;
885 Track *track = mwindow->cwindow->calculate_affected_track();
887 mwindow->cwindow->calculate_affected_autos(track,
888 &x_auto, &y_auto, &z_auto, 1, 0, 0, 0);
892 x->update(x_auto->get_value());
894 y->update(y_auto->get_value());
896 float value = z_auto->get_value();
898 thread->gui->lock_window("CWindowCameraGUI::update");
899 thread->gui->composite_panel->cpanel_zoom->update(value);
900 thread->gui->unlock_window();
903 if( x_auto && y_auto && z_auto )
905 t_smooth->check_toggle_state(x_auto, y_auto, z_auto);
906 t_linear->check_toggle_state(x_auto, y_auto, z_auto);
913 CWindowCameraLeft::CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
914 : BC_Button(x, y, mwindow->theme->get_image_set("left_justify"))
917 this->mwindow = mwindow;
918 set_tooltip(_("Left justify"));
920 int CWindowCameraLeft::handle_event()
922 FloatAuto *x_auto = 0;
923 FloatAuto *z_auto = 0;
924 Track *track = mwindow->cwindow->calculate_affected_track();
926 mwindow->cwindow->calculate_affected_autos(track,
927 &x_auto, 0, &z_auto, 1, 1, 0, 0);
933 track->get_source_dimensions(
934 mwindow->edl->local_session->get_selectionstart(1),
940 mwindow->undo->update_undo_before(_("camera"), 0);
942 (double)track->track_w / z_auto->get_value() / 2 -
944 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
946 gui->update_preview();
954 CWindowCameraCenter::CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
955 : BC_Button(x, y, mwindow->theme->get_image_set("center_justify"))
958 this->mwindow = mwindow;
959 set_tooltip(_("Center horizontal"));
961 int CWindowCameraCenter::handle_event()
963 FloatAuto *x_auto = 0;
964 Track *track = mwindow->cwindow->calculate_affected_track();
966 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
967 track->automation->autos[AUTOMATION_CAMERA_X],
972 mwindow->undo->update_undo_before(_("camera"), 0);
973 x_auto->set_value(0);
975 gui->update_preview();
976 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
983 CWindowCameraRight::CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
984 : BC_Button(x, y, mwindow->theme->get_image_set("right_justify"))
987 this->mwindow = mwindow;
988 set_tooltip(_("Right justify"));
990 int CWindowCameraRight::handle_event()
992 FloatAuto *x_auto = 0;
993 FloatAuto *z_auto = 0;
994 Track *track = mwindow->cwindow->calculate_affected_track();
996 mwindow->cwindow->calculate_affected_autos(track,
997 &x_auto, 0, &z_auto, 1, 1, 0, 0);
1000 if(x_auto && z_auto)
1003 track->get_source_dimensions(
1004 mwindow->edl->local_session->get_selectionstart(1),
1010 mwindow->undo->update_undo_before(_("camera"), 0);
1011 x_auto->set_value( -((double)track->track_w / z_auto->get_value() / 2 -
1014 gui->update_preview();
1015 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1023 CWindowCameraTop::CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1024 : BC_Button(x, y, mwindow->theme->get_image_set("top_justify"))
1027 this->mwindow = mwindow;
1028 set_tooltip(_("Top justify"));
1030 int CWindowCameraTop::handle_event()
1032 FloatAuto *y_auto = 0;
1033 FloatAuto *z_auto = 0;
1034 Track *track = mwindow->cwindow->calculate_affected_track();
1036 mwindow->cwindow->calculate_affected_autos(track,
1037 0, &y_auto, &z_auto, 1, 0, 1, 0);
1040 if(y_auto && z_auto)
1043 track->get_source_dimensions(
1044 mwindow->edl->local_session->get_selectionstart(1),
1050 mwindow->undo->update_undo_before(_("camera"), 0);
1051 y_auto->set_value((double)track->track_h / z_auto->get_value() / 2 -
1054 gui->update_preview();
1055 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1063 CWindowCameraMiddle::CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1064 : BC_Button(x, y, mwindow->theme->get_image_set("middle_justify"))
1067 this->mwindow = mwindow;
1068 set_tooltip(_("Center vertical"));
1070 int CWindowCameraMiddle::handle_event()
1072 FloatAuto *y_auto = 0;
1073 Track *track = mwindow->cwindow->calculate_affected_track();
1075 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1076 track->automation->autos[AUTOMATION_CAMERA_Y], 1);
1080 mwindow->undo->update_undo_before(_("camera"), 0);
1081 y_auto->set_value(0);
1083 gui->update_preview();
1084 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1091 CWindowCameraBottom::CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1092 : BC_Button(x, y, mwindow->theme->get_image_set("bottom_justify"))
1095 this->mwindow = mwindow;
1096 set_tooltip(_("Bottom justify"));
1098 int CWindowCameraBottom::handle_event()
1100 FloatAuto *y_auto = 0;
1101 FloatAuto *z_auto = 0;
1102 Track *track = mwindow->cwindow->calculate_affected_track();
1104 mwindow->cwindow->calculate_affected_autos(track,
1105 0, &y_auto, &z_auto, 1, 0, 1, 0);
1108 if(y_auto && z_auto)
1111 track->get_source_dimensions(
1112 mwindow->edl->local_session->get_selectionstart(1),
1118 mwindow->undo->update_undo_before(_("camera"), 0);
1119 y_auto->set_value(-((double)track->track_h / z_auto->get_value() / 2 -
1122 gui->update_preview();
1123 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1131 CWindowProjectorGUI::CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread)
1132 : CWindowToolGUI(mwindow,
1134 _(PROGRAM_NAME ": Projector"),
1139 CWindowProjectorGUI::~CWindowProjectorGUI()
1142 void CWindowProjectorGUI::create_objects()
1144 int x = 10, y = 10, x1;
1145 Track *track = mwindow->cwindow->calculate_affected_track();
1146 FloatAuto *x_auto = 0;
1147 FloatAuto *y_auto = 0;
1148 FloatAuto *z_auto = 0;
1152 lock_window("CWindowProjectorGUI::create_objects");
1154 mwindow->cwindow->calculate_affected_autos(track,
1155 &x_auto, &y_auto, &z_auto, 0, 0, 0, 0);
1158 add_subwindow(title = new BC_Title(x, y, "X:"));
1159 x += title->get_w();
1160 this->x = new CWindowCoord(this, x, y,
1161 x_auto ? x_auto->get_value() : (float)0);
1162 this->x->create_objects();
1165 add_subwindow(title = new BC_Title(x, y, "Y:"));
1166 x += title->get_w();
1167 this->y = new CWindowCoord(this, x, y,
1168 y_auto ? y_auto->get_value() : (float)0);
1169 this->y->create_objects();
1172 add_subwindow(title = new BC_Title(x, y, "Z:"));
1173 x += title->get_w();
1174 this->z = new CWindowCoord(this, x, y,
1175 z_auto ? z_auto->get_value() : (float)1);
1176 this->z->create_objects();
1177 this->z->set_increment(0.01);
1181 add_subwindow(button = new CWindowProjectorLeft(mwindow, this, x1, y));
1182 x1 += button->get_w();
1183 add_subwindow(button = new CWindowProjectorCenter(mwindow, this, x1, y));
1184 x1 += button->get_w();
1185 add_subwindow(button = new CWindowProjectorRight(mwindow, this, x1, y));
1187 y += button->get_h();
1189 add_subwindow(button = new CWindowProjectorTop(mwindow, this, x1, y));
1190 x1 += button->get_w();
1191 add_subwindow(button = new CWindowProjectorMiddle(mwindow, this, x1, y));
1192 x1 += button->get_w();
1193 add_subwindow(button = new CWindowProjectorBottom(mwindow, this, x1, y));
1195 // additional Buttons to control the curve mode of the "current" keyframe
1196 x1 += button->get_w() + 15;
1197 add_subwindow(this->t_smooth = new CWindowCurveToggle(Projector_Crv_Smooth, mwindow, this, x1, y));
1198 x1 += button->get_w();
1199 add_subwindow(this->t_linear = new CWindowCurveToggle(Projector_Crv_Linear, mwindow, this, x1, y));
1201 // fill in current auto keyframe values, set toggle states.
1206 void CWindowProjectorGUI::update_preview()
1208 CWindowGUI *cgui = mwindow->cwindow->gui;
1209 cgui->lock_window("CWindowProjectorGUI::update_preview");
1210 cgui->sync_parameters(CHANGE_PARAMS, 0, 1);
1211 cgui->unlock_window();
1214 void CWindowProjectorGUI::handle_event()
1216 FloatAuto *x_auto = 0;
1217 FloatAuto *y_auto = 0;
1218 FloatAuto *z_auto = 0;
1219 Track *track = mwindow->cwindow->calculate_affected_track();
1223 mwindow->undo->update_undo_before(_("projector"), this);
1224 if(event_caller == x)
1226 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1227 track->automation->autos[AUTOMATION_PROJECTOR_X],
1231 x_auto->set_value(atof(x->get_text()));
1237 if(event_caller == y)
1239 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1240 track->automation->autos[AUTOMATION_PROJECTOR_Y],
1244 y_auto->set_value(atof(y->get_text()));
1250 if(event_caller == z)
1252 z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1253 track->automation->autos[AUTOMATION_PROJECTOR_Z],
1257 float zoom = atof(z->get_text());
1258 if(zoom > 100.) zoom = 100.;
1259 else if(zoom < 0.01) zoom = 0.01;
1260 // if (zoom != atof(z->get_text()))
1262 z_auto->set_value(zoom);
1264 mwindow->gui->lock_window("CWindowProjectorGUI::handle_event");
1265 mwindow->gui->draw_overlays(1);
1266 mwindow->gui->unlock_window();
1272 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1276 void CWindowProjectorGUI::update()
1278 FloatAuto *x_auto = 0;
1279 FloatAuto *y_auto = 0;
1280 FloatAuto *z_auto = 0;
1281 Track *track = mwindow->cwindow->calculate_affected_track();
1283 mwindow->cwindow->calculate_affected_autos(track,
1284 &x_auto, &y_auto, &z_auto, 0, 0, 0, 0);
1288 x->update(x_auto->get_value());
1290 y->update(y_auto->get_value());
1292 float value = z_auto->get_value();
1294 thread->gui->lock_window("CWindowProjectorGUI::update");
1295 thread->gui->composite_panel->cpanel_zoom->update(value);
1296 thread->gui->unlock_window();
1299 if( x_auto && y_auto && z_auto )
1301 t_smooth->check_toggle_state(x_auto, y_auto, z_auto);
1302 t_linear->check_toggle_state(x_auto, y_auto, z_auto);
1306 CWindowProjectorLeft::CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1307 : BC_Button(x, y, mwindow->theme->get_image_set("left_justify"))
1310 this->mwindow = mwindow;
1311 set_tooltip(_("Left justify"));
1313 int CWindowProjectorLeft::handle_event()
1315 FloatAuto *x_auto = 0;
1316 FloatAuto *z_auto = 0;
1317 Track *track = mwindow->cwindow->calculate_affected_track();
1319 mwindow->cwindow->calculate_affected_autos(track,
1320 &x_auto, 0, &z_auto, 0, 1, 0, 0);
1322 if(x_auto && z_auto)
1324 mwindow->undo->update_undo_before(_("projector"), 0);
1325 x_auto->set_value( (double)track->track_w * z_auto->get_value() / 2 -
1326 (double)mwindow->edl->session->output_w / 2 );
1328 gui->update_preview();
1329 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1336 CWindowProjectorCenter::CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1337 : BC_Button(x, y, mwindow->theme->get_image_set("center_justify"))
1340 this->mwindow = mwindow;
1341 set_tooltip(_("Center horizontal"));
1343 int CWindowProjectorCenter::handle_event()
1345 FloatAuto *x_auto = 0;
1346 Track *track = mwindow->cwindow->calculate_affected_track();
1348 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1349 track->automation->autos[AUTOMATION_PROJECTOR_X],
1354 mwindow->undo->update_undo_before(_("projector"), 0);
1355 x_auto->set_value(0);
1357 gui->update_preview();
1358 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1365 CWindowProjectorRight::CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1366 : BC_Button(x, y, mwindow->theme->get_image_set("right_justify"))
1369 this->mwindow = mwindow;
1370 set_tooltip(_("Right justify"));
1372 int CWindowProjectorRight::handle_event()
1374 FloatAuto *x_auto = 0;
1375 FloatAuto *z_auto = 0;
1376 Track *track = mwindow->cwindow->calculate_affected_track();
1378 mwindow->cwindow->calculate_affected_autos(track,
1379 &x_auto, 0, &z_auto, 0, 1, 0, 0);
1382 if(x_auto && z_auto)
1384 mwindow->undo->update_undo_before(_("projector"), 0);
1385 x_auto->set_value( -((double)track->track_w * z_auto->get_value() / 2 -
1386 (double)mwindow->edl->session->output_w / 2));
1388 gui->update_preview();
1389 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1396 CWindowProjectorTop::CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1397 : BC_Button(x, y, mwindow->theme->get_image_set("top_justify"))
1400 this->mwindow = mwindow;
1401 set_tooltip(_("Top justify"));
1403 int CWindowProjectorTop::handle_event()
1405 FloatAuto *y_auto = 0;
1406 FloatAuto *z_auto = 0;
1407 Track *track = mwindow->cwindow->calculate_affected_track();
1409 mwindow->cwindow->calculate_affected_autos(track,
1410 0, &y_auto, &z_auto, 0, 0, 1, 0);
1413 if(y_auto && z_auto)
1415 mwindow->undo->update_undo_before(_("projector"), 0);
1416 y_auto->set_value( (double)track->track_h * z_auto->get_value() / 2 -
1417 (double)mwindow->edl->session->output_h / 2 );
1419 gui->update_preview();
1420 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1427 CWindowProjectorMiddle::CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1428 : BC_Button(x, y, mwindow->theme->get_image_set("middle_justify"))
1431 this->mwindow = mwindow;
1432 set_tooltip(_("Center vertical"));
1434 int CWindowProjectorMiddle::handle_event()
1436 FloatAuto *y_auto = 0;
1437 Track *track = mwindow->cwindow->calculate_affected_track();
1439 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1440 track->automation->autos[AUTOMATION_PROJECTOR_Y], 1);
1444 mwindow->undo->update_undo_before(_("projector"), 0);
1445 y_auto->set_value(0);
1447 gui->update_preview();
1448 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1455 CWindowProjectorBottom::CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1456 : BC_Button(x, y, mwindow->theme->get_image_set("bottom_justify"))
1459 this->mwindow = mwindow;
1460 set_tooltip(_("Bottom justify"));
1462 int CWindowProjectorBottom::handle_event()
1464 FloatAuto *y_auto = 0;
1465 FloatAuto *z_auto = 0;
1466 Track *track = mwindow->cwindow->calculate_affected_track();
1468 mwindow->cwindow->calculate_affected_autos(track,
1469 0, &y_auto, &z_auto, 0, 0, 1, 0);
1472 if(y_auto && z_auto)
1474 mwindow->undo->update_undo_before(_("projector"), 0);
1475 y_auto->set_value( -((double)track->track_h * z_auto->get_value() / 2 -
1476 (double)mwindow->edl->session->output_h / 2));
1478 gui->update_preview();
1479 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1486 CWindowMaskMode::CWindowMaskMode(MWindow *mwindow,
1487 CWindowToolGUI *gui, int x, int y, const char *text)
1488 : BC_PopupMenu(x, y, 220, text, 1)
1490 this->mwindow = mwindow;
1494 void CWindowMaskMode::create_objects()
1496 add_item(new BC_MenuItem(mode_to_text(MASK_MULTIPLY_ALPHA)));
1497 add_item(new BC_MenuItem(mode_to_text(MASK_SUBTRACT_ALPHA)));
1500 char* CWindowMaskMode::mode_to_text(int mode)
1504 case MASK_MULTIPLY_ALPHA:
1505 return _("Multiply alpha");
1508 case MASK_SUBTRACT_ALPHA:
1509 return _("Subtract alpha");
1513 return _("Subtract alpha");
1516 int CWindowMaskMode::text_to_mode(char *text)
1518 if(!strcasecmp(text, _("Multiply alpha")))
1519 return MASK_MULTIPLY_ALPHA;
1521 if(!strcasecmp(text, _("Subtract alpha")))
1522 return MASK_SUBTRACT_ALPHA;
1524 return MASK_SUBTRACT_ALPHA;
1527 int CWindowMaskMode::handle_event()
1534 // Get existing keyframe
1535 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1538 mwindow->undo->update_undo_before(_("mask mode"), 0);
1539 #ifdef USE_KEYFRAME_SPANNING
1540 // Create temp keyframe
1541 MaskAuto temp_keyframe(mwindow->edl, autos);
1542 temp_keyframe.copy_data(keyframe);
1544 temp_keyframe.mode = text_to_mode(get_text());
1545 // Commit change to span of keyframes
1546 autos->update_parameter(&temp_keyframe);
1548 ((MaskAuto*)autos->default_auto)->mode =
1549 text_to_mode(get_text());
1551 mwindow->undo->update_undo_after(_("mask mode"), LOAD_AUTOMATION);
1554 //printf("CWindowMaskMode::handle_event 1\n");
1555 gui->update_preview();
1566 CWindowMaskDelete::CWindowMaskDelete(MWindow *mwindow,
1567 CWindowToolGUI *gui,
1570 : BC_GenericButton(x, y, _("Delete"))
1572 this->mwindow = mwindow;
1576 int CWindowMaskDelete::handle_event()
1583 int total_points = 0;
1585 // Get existing keyframe
1586 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1590 mwindow->undo->update_undo_before(_("mask delete"), 0);
1592 #ifdef USE_KEYFRAME_SPANNING
1593 // Create temp keyframe
1594 MaskAuto temp_keyframe(mwindow->edl, autos);
1595 temp_keyframe.copy_data(keyframe);
1597 SubMask *submask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
1599 submask->points.remove_all_objects();
1601 for(int i = mwindow->cwindow->gui->affected_point;
1602 i < submask->points.total - 1;
1605 *submask->points.values[i] = *submask->points.values[i + 1];
1608 if(submask->points.total)
1610 submask->points.remove_object(
1611 submask->points.values[submask->points.total - 1]);
1613 total_points = submask->points.total;
1615 // Commit change to span of keyframes
1616 ((MaskAutos*)track->automation->autos[AUTOMATION_MASK])->update_parameter(&temp_keyframe);
1618 for(MaskAuto *current = (MaskAuto*)autos->default_auto;
1621 SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
1623 submask->points.remove_all_objects();
1625 for(int i = mwindow->cwindow->gui->affected_point;
1626 i < submask->points.total - 1;
1629 *submask->points.values[i] = *submask->points.values[i + 1];
1632 if(submask->points.total)
1634 submask->points.remove_object(
1635 submask->points.values[submask->points.total - 1]);
1637 total_points = submask->points.total;
1639 if(current == (MaskAuto*)autos->default_auto)
1640 current = (MaskAuto*)autos->first;
1642 current = (MaskAuto*)NEXT;
1645 if( mwindow->cwindow->gui->affected_point >= total_points )
1646 mwindow->cwindow->gui->affected_point =
1647 total_points > 0 ? total_points-1 : 0;
1650 gui->update_preview();
1651 mwindow->undo->update_undo_after(_("mask delete"), LOAD_AUTOMATION);
1658 int CWindowMaskDelete::keypress_event()
1660 if(get_keypress() == BACKSPACE ||
1661 get_keypress() == DELETE)
1662 return handle_event();
1667 // CWindowMaskCycleNext::CWindowMaskCycleNext(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1668 // : BC_GenericButton(x, y, _("Cycle next"))
1670 // this->mwindow = mwindow;
1673 // int CWindowMaskCycleNext::handle_event()
1675 // MaskAuto *keyframe;
1676 // MaskAutos *autos;
1678 // MaskPoint *point;
1680 // ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1684 // // Should apply to all keyframes
1685 // if(keyframe && mask->points.total)
1687 // temp = mask->points.values[0];
1689 // for(int i = 0; i < mask->points.total - 1; i++)
1691 // mask->points.values[i] = mask->points.values[i + 1];
1693 // mask->points.values[mask->points.total - 1] = temp;
1695 // mwindow->cwindow->gui->affected_point--;
1696 // if(mwindow->cwindow->gui->affected_point < 0)
1697 // mwindow->cwindow->gui->affected_point = mask->points.total - 1;
1700 // gui->update_preview();
1706 // CWindowMaskCyclePrev::CWindowMaskCyclePrev(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1707 // : BC_GenericButton(x, y, _("Cycle prev"))
1709 // this->mwindow = mwindow;
1712 // int CWindowMaskCyclePrev::handle_event()
1714 // MaskAuto *keyframe;
1715 // MaskAutos *autos;
1717 // MaskPoint *point;
1719 // ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1721 // // Should apply to all keyframes
1723 // if(keyframe && mask->points.total)
1725 // temp = mask->points.values[mask->points.total - 1];
1727 // for(int i = mask->points.total - 1; i > 0; i--)
1729 // mask->points.values[i] = mask->points.values[i - 1];
1731 // mask->points.values[0] = temp;
1733 // mwindow->cwindow->gui->affected_point++;
1734 // if(mwindow->cwindow->gui->affected_point >= mask->points.total)
1735 // mwindow->cwindow->gui->affected_point = 0;
1738 // gui->update_preview();
1744 CWindowMaskNumber::CWindowMaskNumber(MWindow *mwindow,
1745 CWindowToolGUI *gui,
1748 : BC_TumbleTextBox(gui,
1749 (int64_t)mwindow->edl->session->cwindow_mask,
1751 (int64_t)SUBMASKS - 1,
1756 this->mwindow = mwindow;
1760 CWindowMaskNumber::~CWindowMaskNumber()
1764 int CWindowMaskNumber::handle_event()
1766 mwindow->edl->session->cwindow_mask = atol(get_text());
1768 gui->update_preview();
1773 CWindowMaskAffectedPoint::CWindowMaskAffectedPoint(MWindow *mwindow,
1774 CWindowToolGUI *gui, int x, int y)
1775 : BC_TumbleTextBox(gui,
1776 (int64_t)mwindow->cwindow->gui->affected_point,
1777 (int64_t)0, INT64_MAX, x, y, 100)
1779 this->mwindow = mwindow;
1783 CWindowMaskAffectedPoint::~CWindowMaskAffectedPoint()
1787 int CWindowMaskAffectedPoint::handle_event()
1789 int total_points = 0;
1790 int affected_point = atol(get_text());
1791 Track *track = mwindow->cwindow->calculate_affected_track();
1793 MaskAutos *autos = (MaskAutos*)track->automation->autos[AUTOMATION_MASK];
1794 MaskAuto *keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(autos, 0);
1796 SubMask *mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
1797 total_points = mask->points.size();
1800 int active_point = affected_point;
1801 if( affected_point >= total_points )
1802 affected_point = total_points - 1;
1803 else if( affected_point < 0 )
1805 if( active_point != affected_point )
1806 update((int64_t)affected_point);
1807 mwindow->cwindow->gui->affected_point = affected_point;
1809 gui->update_preview();
1817 CWindowMaskFeather::CWindowMaskFeather(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1818 : BC_TumbleTextBox(gui,
1826 this->mwindow = mwindow;
1829 CWindowMaskFeather::~CWindowMaskFeather()
1832 int CWindowMaskFeather::handle_event()
1839 #ifdef USE_KEYFRAME_SPANNING
1845 mwindow->undo->update_undo_before(_("mask feather"), this);
1847 // Get existing keyframe
1848 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe,
1849 mask, point, create_it);
1853 #ifdef USE_KEYFRAME_SPANNING
1854 // Create temp keyframe
1855 MaskAuto temp_keyframe(mwindow->edl, autos);
1856 temp_keyframe.copy_data(keyframe);
1858 temp_keyframe.feather = atof(get_text());
1859 // Commit change to span of keyframes
1860 autos->update_parameter(&temp_keyframe);
1862 keyframe->feather = atof(get_text());
1865 gui->update_preview();
1868 mwindow->undo->update_undo_after(_("mask feather"), LOAD_AUTOMATION);
1873 CWindowMaskValue::CWindowMaskValue(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1883 this->mwindow = mwindow;
1887 CWindowMaskValue::~CWindowMaskValue()
1891 int CWindowMaskValue::handle_event()
1898 #ifdef USE_KEYFRAME_SPANNING
1904 mwindow->undo->update_undo_before(_("mask value"), this);
1905 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe,
1906 mask, point, create_it);
1910 #ifdef USE_KEYFRAME_SPANNING
1911 // Create temp keyframe
1912 MaskAuto temp_keyframe(mwindow->edl, autos);
1913 temp_keyframe.copy_data(keyframe);
1915 temp_keyframe.value = get_value();
1916 // Commit change to span of keyframes
1917 autos->update_parameter(&temp_keyframe);
1919 keyframe->value = get_value();
1923 gui->update_preview();
1924 mwindow->undo->update_undo_after(_("mask value"), LOAD_AUTOMATION);
1929 CWindowMaskBeforePlugins::CWindowMaskBeforePlugins(CWindowToolGUI *gui, int x, int y)
1933 _("Apply mask before plugins"))
1938 int CWindowMaskBeforePlugins::handle_event()
1945 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 1);
1948 keyframe->apply_before_plugins = get_value();
1949 gui->update_preview();
1955 CWindowDisableOpenGLMasking::CWindowDisableOpenGLMasking(CWindowToolGUI *gui, int x, int y)
1956 : BC_CheckBox(x, y, 1, _("Disable OpenGL masking"))
1961 int CWindowDisableOpenGLMasking::handle_event()
1968 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 1);
1971 keyframe->disable_opengl_masking = get_value();
1972 gui->update_preview();
1985 CWindowMaskGUI::CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread)
1986 : CWindowToolGUI(mwindow, thread,
1987 _(PROGRAM_NAME ": Mask"), 330, 320)
1989 this->mwindow = mwindow;
1990 this->thread = thread;
1995 CWindowMaskGUI::~CWindowMaskGUI()
1997 lock_window("CWindowMaskGUI::~CWindowMaskGUI");
1999 delete active_point;
2004 void CWindowMaskGUI::create_objects()
2006 int x = 10, y = 10, margin = mwindow->theme->widget_border;
2007 //MaskAuto *keyframe = 0;
2008 //Track *track = mwindow->cwindow->calculate_affected_track();
2010 // keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->autos[AUTOMATION_MASK], 0);
2012 lock_window("CWindowMaskGUI::create_objects");
2014 add_subwindow(title = new BC_Title(x, y, _("Mode:")));
2015 add_subwindow(mode = new CWindowMaskMode(mwindow,
2016 this, x + title->get_w() + margin, y, ""));
2017 mode->create_objects();
2018 y += mode->get_h() + margin;
2019 add_subwindow(title = new BC_Title(x, y, _("Value:")));
2020 add_subwindow(value = new CWindowMaskValue(mwindow, this, x + title->get_w() + margin, y));
2021 y += value->get_h() + margin;
2022 add_subwindow(delete_point = new CWindowMaskDelete(mwindow, this, x, y));
2023 int x1 = x + delete_point->get_w() + 2*margin;
2024 add_subwindow(title = new BC_Title(x1, y, _("Point:")));
2025 x1 += title->get_w() + margin;
2026 active_point = new CWindowMaskAffectedPoint(mwindow, this, x1, y);
2027 active_point->create_objects();
2028 y += delete_point->get_h() + margin;
2029 add_subwindow(title = new BC_Title(x, y, _("Mask number:")));
2030 number = new CWindowMaskNumber(mwindow,
2031 this, x + title->get_w() + margin, y);
2032 number->create_objects();
2033 y += number->get_h() + margin;
2034 add_subwindow(title = new BC_Title(x, y, _("Feather:")));
2035 feather = new CWindowMaskFeather(mwindow,
2036 this, x + title->get_w() + margin, y);
2037 feather->create_objects();
2038 y += feather->get_h() + margin;
2039 add_subwindow(title = new BC_Title(x, y, "X:"));
2040 x += title->get_w() + margin;
2041 this->x = new CWindowCoord(this, x, y, (float)0.0);
2042 this->x->create_objects();
2043 x += this->x->get_w() + margin;
2044 add_subwindow(title = new BC_Title(x, y, "Y:"));
2045 x += title->get_w() + margin;
2046 this->y = new CWindowCoord(this, x, y, (float)0.0);
2047 this->y->create_objects();
2050 y += this->y->get_h() + margin;
2051 add_subwindow(title = new BC_Title(x, y, _("Press Shift to move an end point")));
2052 y += title->get_h() + margin;
2053 add_subwindow(title = new BC_Title(x, y, _("Press Ctrl to move a control point")));
2054 y += title->get_h() + margin;
2055 add_subwindow(title = new BC_Title(x, y, _("Shift+click Delete to delete the mask")));
2056 y += title->get_h() + margin;
2057 add_subwindow(title = new BC_Title(x, y, _("Press Alt to translate the mask")));
2060 add_subwindow(this->apply_before_plugins = new CWindowMaskBeforePlugins(this, 10, y));
2061 y += this->apply_before_plugins->get_h() + margin;
2062 add_subwindow(this->disable_opengl_masking = new CWindowDisableOpenGLMasking(this, 10, y));
2068 void CWindowMaskGUI::get_keyframe(Track* &track,
2070 MaskAuto* &keyframe,
2078 track = mwindow->cwindow->calculate_affected_track();
2081 autos = (MaskAutos*)track->automation->autos[AUTOMATION_MASK];
2082 keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(
2088 mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
2095 if(mwindow->cwindow->gui->affected_point < mask->points.total &&
2096 mwindow->cwindow->gui->affected_point >= 0)
2098 point = mask->points.values[mwindow->cwindow->gui->affected_point];
2103 void CWindowMaskGUI::update()
2110 //printf("CWindowMaskGUI::update 1\n");
2111 get_keyframe(track, autos, keyframe, mask, point, 0);
2113 double position = mwindow->edl->local_session->get_selectionstart(1);
2114 position = mwindow->edl->align_to_frame(position, 0);
2117 int64_t position_i = track->to_units(position, 0);
2121 x->update(point->x);
2122 y->update(point->y);
2127 feather->update((int64_t)autos->get_feather(position_i, PLAY_FORWARD));
2128 value->update((int64_t)autos->get_value(position_i, PLAY_FORWARD));
2129 apply_before_plugins->update((int64_t)keyframe->apply_before_plugins);
2130 disable_opengl_masking->update((int64_t)keyframe->disable_opengl_masking);
2134 //printf("CWindowMaskGUI::update 1\n");
2135 active_point->update((int64_t)mwindow->cwindow->gui->affected_point);
2136 number->update((int64_t)mwindow->edl->session->cwindow_mask);
2138 //printf("CWindowMaskGUI::update 1\n");
2141 #ifdef USE_KEYFRAME_SPANNING
2143 CWindowMaskMode::mode_to_text(keyframe->mode));
2146 CWindowMaskMode::mode_to_text(((MaskAuto*)autos->default_auto)->mode));
2149 //printf("CWindowMaskGUI::update 2\n");
2152 void CWindowMaskGUI::handle_event()
2159 get_keyframe(track, autos, keyframe, mask, point, 0);
2161 mwindow->undo->update_undo_before(_("mask point"), this);
2165 #ifdef USE_KEYFRAME_SPANNING
2166 // Create temp keyframe
2167 MaskAuto temp_keyframe(mwindow->edl, autos);
2168 temp_keyframe.copy_data(keyframe);
2169 // Get affected point in temp keyframe
2170 mask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
2171 if(mwindow->cwindow->gui->affected_point < mask->points.total &&
2172 mwindow->cwindow->gui->affected_point >= 0)
2174 point = mask->points.values[mwindow->cwindow->gui->affected_point];
2179 point->x = atof(x->get_text());
2180 point->y = atof(y->get_text());
2181 // Commit to spanned keyframes
2182 autos->update_parameter(&temp_keyframe);
2185 point->x = atof(x->get_text());
2186 point->y = atof(y->get_text());
2191 mwindow->undo->update_undo_after(_("mask point"), LOAD_AUTOMATION);
2194 void CWindowMaskGUI::update_preview()
2196 CWindowGUI *cgui = mwindow->cwindow->gui;
2197 cgui->lock_window("CWindowMaskGUI::update_preview");
2198 cgui->sync_parameters(CHANGE_PARAMS, 0, 1);
2199 cgui->unlock_window();
2203 CWindowRulerGUI::CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread)
2204 : CWindowToolGUI(mwindow,
2206 _(PROGRAM_NAME ": Ruler"),
2212 CWindowRulerGUI::~CWindowRulerGUI()
2216 void CWindowRulerGUI::create_objects()
2218 int x = 10, y = 10, x1 = 100;
2221 lock_window("CWindowRulerGUI::create_objects");
2222 add_subwindow(title = new BC_Title(x, y, _("Current:")));
2223 add_subwindow(current = new BC_TextBox(x1, y, 200, 1, ""));
2224 y += title->get_h() + 5;
2225 add_subwindow(title = new BC_Title(x, y, _("Point 1:")));
2226 add_subwindow(point1 = new BC_TextBox(x1, y, 200, 1, ""));
2227 y += title->get_h() + 5;
2228 add_subwindow(title = new BC_Title(x, y, _("Point 2:")));
2229 add_subwindow(point2 = new BC_TextBox(x1, y, 200, 1, ""));
2230 y += title->get_h() + 5;
2231 add_subwindow(title = new BC_Title(x, y, _("Deltas:")));
2232 add_subwindow(deltas = new BC_TextBox(x1, y, 200, 1, ""));
2233 y += title->get_h() + 5;
2234 add_subwindow(title = new BC_Title(x, y, _("Distance:")));
2235 add_subwindow(distance = new BC_TextBox(x1, y, 200, 1, ""));
2236 y += title->get_h() + 5;
2237 add_subwindow(title = new BC_Title(x, y, _("Angle:")));
2238 add_subwindow(angle = new BC_TextBox(x1, y, 200, 1, ""));
2239 y += title->get_h() + 10;
2240 char string[BCTEXTLEN];
2242 _("Press Ctrl to lock ruler to the\nnearest 45%c%c angle."),
2243 0xc2, 0xb0); // degrees utf
2244 add_subwindow(title = new BC_Title(x,
2247 y += title->get_h() + 10;
2248 sprintf(string, _("Press Alt to translate the ruler."));
2249 add_subwindow(title = new BC_Title(x,
2256 void CWindowRulerGUI::update()
2258 char string[BCTEXTLEN];
2259 int cx = mwindow->session->cwindow_output_x;
2260 int cy = mwindow->session->cwindow_output_y;
2261 sprintf(string, "%d, %d", cx, cy);
2262 current->update(string);
2263 double x1 = mwindow->edl->session->ruler_x1;
2264 double y1 = mwindow->edl->session->ruler_y1;
2265 sprintf(string, "%.0f, %.0f", x1, y1);
2266 point1->update(string);
2267 double x2 = mwindow->edl->session->ruler_x2;
2268 double y2 = mwindow->edl->session->ruler_y2;
2269 sprintf(string, "%.0f, %.0f", x2, y2);
2270 point2->update(string);
2271 double dx = x2 - x1, dy = y2 - y1;
2272 sprintf(string, "%s%.0f, %s%.0f", (dx>=0? "+":""), dx, (dy>=0? "+":""), dy);
2273 deltas->update(string);
2274 double d = sqrt(dx*dx + dy*dy);
2275 sprintf(string, _("%0.01f pixels"), d);
2276 distance->update(string);
2277 double a = d > 0 ? (atan2(-dy, dx) * 180/M_PI) : 0.;
2278 sprintf(string, "%0.02f %c%c", a, 0xc2, 0xb0);
2279 angle->update(string);
2282 void CWindowRulerGUI::handle_event()