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 current_tool = operation;
90 new_gui = new CWindowEyedropGUI(mwindow, this);
93 new_gui = new CWindowCropGUI(mwindow, this);
96 new_gui = new CWindowCameraGUI(mwindow, this);
98 case CWINDOW_PROJECTOR:
99 new_gui = new CWindowProjectorGUI(mwindow, this);
102 new_gui = new CWindowMaskGUI(mwindow, this);
105 new_gui = new CWindowRulerGUI(mwindow, this);
113 //printf("CWindowTool::start_tool 1\n");
119 // Wait for previous tool GUI to finish
120 output_lock->lock("CWindowTool::start_tool");
121 this->tool_gui = new_gui;
122 tool_gui->create_objects();
124 if(mwindow->edl->session->tool_window &&
125 mwindow->session->show_cwindow) tool_gui->show_window();
126 tool_gui->lock_window("CWindowTool::start_tool 1");
128 tool_gui->unlock_window();
131 // Signal thread to run next tool GUI
132 input_lock->unlock();
134 //printf("CWindowTool::start_tool 1\n");
139 tool_gui->lock_window("CWindowTool::start_tool");
141 tool_gui->unlock_window();
144 //printf("CWindowTool::start_tool 2\n");
149 void CWindowTool::stop_tool()
153 tool_gui->lock_window("CWindowTool::stop_tool");
154 tool_gui->set_done(0);
155 tool_gui->unlock_window();
159 void CWindowTool::show_tool()
161 if(tool_gui && mwindow->edl->session->tool_window)
163 tool_gui->lock_window("CWindowTool::show_tool");
164 tool_gui->show_window();
165 tool_gui->unlock_window();
169 void CWindowTool::hide_tool()
171 if(tool_gui && mwindow->edl->session->tool_window)
173 tool_gui->lock_window("CWindowTool::show_tool");
174 tool_gui->hide_window();
175 tool_gui->unlock_window();
180 void CWindowTool::run()
184 input_lock->lock("CWindowTool::run");
187 tool_gui->run_window();
188 tool_gui_lock->lock("CWindowTool::run");
191 tool_gui_lock->unlock();
193 output_lock->unlock();
197 void CWindowTool::update_show_window()
201 tool_gui->lock_window("CWindowTool::update_show_window");
203 if(mwindow->edl->session->tool_window)
206 tool_gui->show_window();
209 tool_gui->hide_window();
212 tool_gui->unlock_window();
216 void CWindowTool::raise_window()
220 gui->unlock_window();
221 tool_gui->lock_window("CWindowTool::raise_window");
222 tool_gui->raise_window();
223 tool_gui->unlock_window();
224 gui->lock_window("CWindowTool::raise_window");
228 void CWindowTool::update_values()
230 tool_gui_lock->lock("CWindowTool::update_values");
233 tool_gui->lock_window("CWindowTool::update_values");
236 tool_gui->unlock_window();
238 tool_gui_lock->unlock();
247 CWindowToolGUI::CWindowToolGUI(MWindow *mwindow,
253 mwindow->session->ctool_x,
254 mwindow->session->ctool_y,
263 this->mwindow = mwindow;
264 this->thread = thread;
265 current_operation = 0;
268 CWindowToolGUI::~CWindowToolGUI()
272 int CWindowToolGUI::close_event()
276 mwindow->edl->session->tool_window = 0;
281 thread->gui->lock_window("CWindowToolGUI::close_event");
282 thread->gui->composite_panel->set_operation(mwindow->edl->session->cwindow_operation);
283 thread->gui->flush();
284 thread->gui->unlock_window();
286 lock_window("CWindowToolGUI::close_event");
290 int CWindowToolGUI::keypress_event()
294 switch( get_keypress() ) {
297 return close_event();
308 resend_event(thread->gui);
315 int CWindowToolGUI::translation_event()
317 mwindow->session->ctool_x = get_x();
318 mwindow->session->ctool_y = get_y();
327 CWindowCoord::CWindowCoord(CWindowToolGUI *gui, int x, int y, float value, int log_increment = 0)
328 : BC_TumbleTextBox(gui, (float)value, (float)-65536, (float)65536, x, y, 100)
331 set_log_floatincrement(log_increment);
334 CWindowCoord::CWindowCoord(CWindowToolGUI *gui, int x, int y, int value)
335 : BC_TumbleTextBox(gui, (int64_t)value, (int64_t)-65536, (int64_t)65536, x, y, 100)
339 int CWindowCoord::handle_event()
341 gui->event_caller = this;
347 CWindowCropOK::CWindowCropOK(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
348 : BC_GenericButton(x, y, _("Do it"))
350 this->mwindow = mwindow;
353 int CWindowCropOK::handle_event()
355 mwindow->crop_video();
360 int CWindowCropOK::keypress_event()
362 if(get_keypress() == 0xd)
376 CWindowCropGUI::CWindowCropGUI(MWindow *mwindow, CWindowTool *thread)
377 : CWindowToolGUI(mwindow,
379 _(PROGRAM_NAME ": Crop"),
386 CWindowCropGUI::~CWindowCropGUI()
390 void CWindowCropGUI::create_objects()
395 lock_window("CWindowCropGUI::create_objects");
397 int pad = MAX(BC_TextBox::calculate_h(this, MEDIUMFONT, 1, 1),
398 BC_Title::calculate_h(this, "X")) + 5;
399 add_subwindow(title = new BC_Title(x, y, "X1:"));
400 column1 = MAX(column1, title->get_w());
402 add_subwindow(title = new BC_Title(x, y, _("W:")));
403 column1 = MAX(column1, title->get_w());
405 add_subwindow(new CWindowCropOK(mwindow, thread->tool_gui, x, y));
409 x1 = new CWindowCoord(thread->tool_gui, x, y,
410 mwindow->edl->session->crop_x1);
411 x1->create_objects();
413 width = new CWindowCoord(thread->tool_gui, x, y,
414 mwindow->edl->session->crop_x2 - mwindow->edl->session->crop_x1);
415 width->create_objects();
418 x += x1->get_w() + 10;
421 add_subwindow(title = new BC_Title(x, y, "Y1:"));
422 column2 = MAX(column2, title->get_w());
424 add_subwindow(title = new BC_Title(x, y, _("H:")));
425 column2 = MAX(column2, title->get_w());
430 y1 = new CWindowCoord(thread->tool_gui, x, y,
431 mwindow->edl->session->crop_y1);
432 y1->create_objects();
434 height = new CWindowCoord(thread->tool_gui, x, y,
435 mwindow->edl->session->crop_y2 - mwindow->edl->session->crop_y1);
436 height->create_objects();
440 void CWindowCropGUI::handle_event()
443 new_x1 = atol(x1->get_text());
444 new_y1 = atol(y1->get_text());
445 if(new_x1 != mwindow->edl->session->crop_x1)
447 mwindow->edl->session->crop_x2 = new_x1 +
448 mwindow->edl->session->crop_x2 -
449 mwindow->edl->session->crop_x1;
450 mwindow->edl->session->crop_x1 = new_x1;
452 if(new_y1 != mwindow->edl->session->crop_y1)
454 mwindow->edl->session->crop_y2 = new_y1 +
455 mwindow->edl->session->crop_y2 -
456 mwindow->edl->session->crop_y1;
457 mwindow->edl->session->crop_y1 = atol(y1->get_text());
459 mwindow->edl->session->crop_x2 = atol(width->get_text()) +
460 mwindow->edl->session->crop_x1;
461 mwindow->edl->session->crop_y2 = atol(height->get_text()) +
462 mwindow->edl->session->crop_y1;
464 mwindow->cwindow->gui->lock_window("CWindowCropGUI::handle_event");
465 mwindow->cwindow->gui->canvas->draw_refresh();
466 mwindow->cwindow->gui->unlock_window();
469 void CWindowCropGUI::update()
471 x1->update((int64_t)mwindow->edl->session->crop_x1);
472 y1->update((int64_t)mwindow->edl->session->crop_y1);
473 width->update((int64_t)mwindow->edl->session->crop_x2 -
474 mwindow->edl->session->crop_x1);
475 height->update((int64_t)mwindow->edl->session->crop_y2 -
476 mwindow->edl->session->crop_y1);
480 CWindowEyedropGUI::CWindowEyedropGUI(MWindow *mwindow, CWindowTool *thread)
481 : CWindowToolGUI(mwindow, thread, _(PROGRAM_NAME ": Color"), 220, 290)
485 CWindowEyedropGUI::~CWindowEyedropGUI()
489 void CWindowEyedropGUI::create_objects()
491 int margin = mwindow->theme->widget_border;
494 int x2 = 70, x3 = x2 + 60;
495 lock_window("CWindowEyedropGUI::create_objects");
496 BC_Title *title0, *title1, *title2, *title3, *title4, *title5, *title6, *title7;
497 add_subwindow(title0 = new BC_Title(x, y,_("X,Y:")));
498 y += title0->get_h() + margin;
499 add_subwindow(title7 = new BC_Title(x, y, _("Radius:")));
500 y += BC_TextBox::calculate_h(this, MEDIUMFONT, 1, 1) + margin;
502 add_subwindow(title1 = new BC_Title(x, y, _("Red:")));
503 y += title1->get_h() + margin;
504 add_subwindow(title2 = new BC_Title(x, y, _("Green:")));
505 y += title2->get_h() + margin;
506 add_subwindow(title3 = new BC_Title(x, y, _("Blue:")));
507 y += title3->get_h() + margin;
509 add_subwindow(title4 = new BC_Title(x, y, "Y:"));
510 y += title4->get_h() + margin;
511 add_subwindow(title5 = new BC_Title(x, y, "U:"));
512 y += title5->get_h() + margin;
513 add_subwindow(title6 = new BC_Title(x, y, "V:"));
515 add_subwindow(current = new BC_Title(x2, title0->get_y(), ""));
517 radius = new CWindowCoord(this, x2, title7->get_y(),
518 mwindow->edl->session->eyedrop_radius);
519 radius->create_objects();
520 radius->set_boundaries((int64_t)0, (int64_t)255);
522 add_subwindow(red = new BC_Title(x2, title1->get_y(), "0"));
523 add_subwindow(green = new BC_Title(x2, title2->get_y(), "0"));
524 add_subwindow(blue = new BC_Title(x2, title3->get_y(), "0"));
525 add_subwindow(rgb_hex = new BC_Title(x3, red->get_y(), "#000000"));
527 add_subwindow(this->y = new BC_Title(x2, title4->get_y(), "0"));
528 add_subwindow(this->u = new BC_Title(x2, title5->get_y(), "0"));
529 add_subwindow(this->v = new BC_Title(x2, title6->get_y(), "0"));
530 add_subwindow(yuv_hex = new BC_Title(x3, this->y->get_y(), "#000000"));
532 y = title6->get_y() + this->v->get_h() + 2*margin;
533 add_subwindow(sample = new BC_SubWindow(x, y, 50, 50));
534 y += sample->get_h() + margin;
535 add_subwindow(use_max = new CWindowEyedropCheckBox(mwindow, this, x, y));
540 void CWindowEyedropGUI::update()
542 char string[BCTEXTLEN];
543 sprintf(string, "%d, %d",
544 thread->gui->eyedrop_x,
545 thread->gui->eyedrop_y);
546 current->update(string);
548 radius->update((int64_t)mwindow->edl->session->eyedrop_radius);
550 LocalSession *local_session = mwindow->edl->local_session;
551 int use_max = local_session->use_max;
552 float r = use_max ? local_session->red_max : local_session->red;
553 float g = use_max ? local_session->green_max : local_session->green;
554 float b = use_max ? local_session->blue_max : local_session->blue;
555 this->red->update(r);
556 this->green->update(g);
557 this->blue->update(b);
559 int rx = 255*r + 0.5; bclamp(rx,0,255);
560 int gx = 255*g + 0.5; bclamp(gx,0,255);
561 int bx = 255*b + 0.5; bclamp(bx,0,255);
562 char rgb_text[BCSTRLEN];
563 sprintf(rgb_text, "#%02x%02x%02x", rx, gx, bx);
564 rgb_hex->update(rgb_text);
567 YUV::yuv.rgb_to_yuv_f(r, g, b, y, u, v);
569 this->u->update(u); u += 0.5;
570 this->v->update(v); v += 0.5;
572 int yx = 255*y + 0.5; bclamp(yx,0,255);
573 int ux = 255*u + 0.5; bclamp(ux,0,255);
574 int vx = 255*v + 0.5; bclamp(vx,0,255);
575 char yuv_text[BCSTRLEN];
576 sprintf(yuv_text, "#%02x%02x%02x", yx, ux, vx);
577 yuv_hex->update(yuv_text);
579 int rgb = (rx << 16) | (gx << 8) | (bx << 0);
580 sample->set_color(rgb);
581 sample->draw_box(0, 0, sample->get_w(), sample->get_h());
582 sample->set_color(BLACK);
583 sample->draw_rectangle(0, 0, sample->get_w(), sample->get_h());
587 void CWindowEyedropGUI::handle_event()
589 int new_radius = atoi(radius->get_text());
590 if(new_radius != mwindow->edl->session->eyedrop_radius)
592 CWindowGUI *gui = mwindow->cwindow->gui;
593 if(gui->eyedrop_visible)
595 gui->lock_window("CWindowEyedropGUI::handle_event");
598 gui->canvas->do_eyedrop(rerender, 0, 1);
601 mwindow->edl->session->eyedrop_radius = new_radius;
603 if(gui->eyedrop_visible)
607 gui->canvas->do_eyedrop(rerender, 0, 1);
608 gui->unlock_window();
615 /* Buttons to control Keyframe-Curve-Mode for Projector or Camera */
617 // Configuration for all possible Keyframe Curve Mode toggles
619 FloatAuto::t_mode mode;
625 const _CVD Camera_Crv_Smooth =
629 N_("\"smooth\" Curve on current Camera Keyframes")
631 const _CVD Camera_Crv_Linear =
635 N_("\"linear\" Curve on current Camera Keyframes")
637 const _CVD Projector_Crv_Smooth =
641 N_("\"smooth\" Curve on current Projector Keyframes")
643 const _CVD Projector_Crv_Linear =
647 N_("\"linear\" Curve on current Projector Keyframes")
650 // Implementation Class für Keyframe Curve Mode buttons
652 // This button reflects the state of the "current" keyframe
653 // (the nearest keyframe on the left) for all three automation
654 // lines together. Clicking on this button (re)sets the curve
655 // mode for the three "current" keyframes simultanously, but
656 // never creates a new keyframe.
658 class CWindowCurveToggle : public BC_Toggle
661 CWindowCurveToggle(_CVD mode, MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
662 void check_toggle_state(FloatAuto *x, FloatAuto *y, FloatAuto *z);
671 CWindowCurveToggle::CWindowCurveToggle(_CVD mode, MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
672 : BC_Toggle(x, y, mwindow->theme->get_image_set(mode.icon_id), false),
676 this->mwindow = mwindow;
677 set_tooltip(_(cfg.tooltip));
680 void CWindowCurveToggle::check_toggle_state(FloatAuto *x, FloatAuto *y, FloatAuto *z)
682 // the toggle state is only set to ON if all
683 // three automation lines have the same curve mode.
684 // For mixed states the toggle stays off.
685 set_value( x->curve_mode == this->cfg.mode &&
686 y->curve_mode == this->cfg.mode &&
687 z->curve_mode == this->cfg.mode
688 ,true // redraw to show new state
692 int CWindowCurveToggle::handle_event()
694 FloatAuto *x=0, *y=0, *z=0;
695 Track *track = mwindow->cwindow->calculate_affected_track();
698 { mwindow->cwindow->calculate_affected_autos(&x, &y, &z,
699 track, cfg.use_camera, 0,0,0); // don't create new keyframe
701 if(x) x->change_curve_mode(cfg.mode);
702 if(y) y->change_curve_mode(cfg.mode);
703 if(z) z->change_curve_mode(cfg.mode);
706 gui->update_preview();
713 CWindowEyedropCheckBox::CWindowEyedropCheckBox(MWindow *mwindow,
714 CWindowEyedropGUI *gui, int x, int y)
715 : BC_CheckBox(x, y, mwindow->edl->local_session->use_max, _("Use maximum"))
717 this->mwindow = mwindow;
721 int CWindowEyedropCheckBox::handle_event()
723 mwindow->edl->local_session->use_max = get_value();
730 CWindowCameraGUI::CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread)
731 : CWindowToolGUI(mwindow,
733 _(PROGRAM_NAME ": Camera"),
738 CWindowCameraGUI::~CWindowCameraGUI()
742 void CWindowCameraGUI::create_objects()
744 int x = 10, y = 10, x1;
745 Track *track = mwindow->cwindow->calculate_affected_track();
746 FloatAuto *x_auto = 0;
747 FloatAuto *y_auto = 0;
748 FloatAuto *z_auto = 0;
752 lock_window("CWindowCameraGUI::create_objects");
755 mwindow->cwindow->calculate_affected_autos(&x_auto,
756 &y_auto, &z_auto, track, 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 mwindow->gui->lock_window("CWindowCameraGUI::update_preview");
811 mwindow->restart_brender();
812 mwindow->gui->draw_overlays(1);
813 mwindow->sync_parameters(CHANGE_PARAMS);
814 mwindow->gui->unlock_window();
815 mwindow->cwindow->refresh_frame(CHANGE_NONE);
816 mwindow->cwindow->gui->lock_window("CWindowCameraGUI::update_preview");
817 mwindow->cwindow->gui->canvas->draw_refresh();
818 mwindow->cwindow->gui->unlock_window();
822 void CWindowCameraGUI::handle_event()
824 FloatAuto *x_auto = 0;
825 FloatAuto *y_auto = 0;
826 FloatAuto *z_auto = 0;
827 Track *track = mwindow->cwindow->calculate_affected_track();
830 mwindow->undo->update_undo_before(_("camera"), this);
831 if(event_caller == x)
833 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
834 track->automation->autos[AUTOMATION_CAMERA_X],
838 x_auto->set_value(atof(x->get_text()));
844 if(event_caller == y)
846 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
847 track->automation->autos[AUTOMATION_CAMERA_Y],
851 y_auto->set_value(atof(y->get_text()));
857 if(event_caller == z)
859 z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
860 track->automation->autos[AUTOMATION_CAMERA_Z],
864 float zoom = atof(z->get_text());
865 if(zoom > 100.) zoom = 100.;
867 if(zoom < 0.01) zoom = 0.01;
868 // Doesn't allow user to enter from scratch
869 // if(zoom != atof(z->get_text()))
872 z_auto->set_value(zoom);
873 mwindow->gui->lock_window("CWindowCameraGUI::handle_event");
874 mwindow->gui->draw_overlays(1);
875 mwindow->gui->unlock_window();
881 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
885 void CWindowCameraGUI::update()
887 FloatAuto *x_auto = 0;
888 FloatAuto *y_auto = 0;
889 FloatAuto *z_auto = 0;
890 Track *track = mwindow->cwindow->calculate_affected_track();
894 mwindow->cwindow->calculate_affected_autos(&x_auto,
905 x->update(x_auto->get_value());
907 y->update(y_auto->get_value());
909 float value = z_auto->get_value();
911 thread->gui->composite_panel->cpanel_zoom->update(value);
914 if( x_auto && y_auto && z_auto )
916 t_smooth->check_toggle_state(x_auto, y_auto, z_auto);
917 t_linear->check_toggle_state(x_auto, y_auto, z_auto);
924 CWindowCameraLeft::CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
925 : BC_Button(x, y, mwindow->theme->get_image_set("left_justify"))
928 this->mwindow = mwindow;
929 set_tooltip(_("Left justify"));
931 int CWindowCameraLeft::handle_event()
933 FloatAuto *x_auto = 0;
934 FloatAuto *z_auto = 0;
935 Track *track = mwindow->cwindow->calculate_affected_track();
938 mwindow->cwindow->calculate_affected_autos(&x_auto,
951 track->get_source_dimensions(
952 mwindow->edl->local_session->get_selectionstart(1),
958 mwindow->undo->update_undo_before(_("camera"), 0);
960 (double)track->track_w / z_auto->get_value() / 2 -
962 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
964 gui->update_preview();
972 CWindowCameraCenter::CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
973 : BC_Button(x, y, mwindow->theme->get_image_set("center_justify"))
976 this->mwindow = mwindow;
977 set_tooltip(_("Center horizontal"));
979 int CWindowCameraCenter::handle_event()
981 FloatAuto *x_auto = 0;
982 Track *track = mwindow->cwindow->calculate_affected_track();
984 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
985 track->automation->autos[AUTOMATION_CAMERA_X],
990 mwindow->undo->update_undo_before(_("camera"), 0);
991 x_auto->set_value(0);
993 gui->update_preview();
994 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1001 CWindowCameraRight::CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1002 : BC_Button(x, y, mwindow->theme->get_image_set("right_justify"))
1005 this->mwindow = mwindow;
1006 set_tooltip(_("Right justify"));
1008 int CWindowCameraRight::handle_event()
1010 FloatAuto *x_auto = 0;
1011 FloatAuto *z_auto = 0;
1012 Track *track = mwindow->cwindow->calculate_affected_track();
1015 mwindow->cwindow->calculate_affected_autos(&x_auto,
1025 if(x_auto && z_auto)
1028 track->get_source_dimensions(
1029 mwindow->edl->local_session->get_selectionstart(1),
1035 mwindow->undo->update_undo_before(_("camera"), 0);
1036 x_auto->set_value( -((double)track->track_w / z_auto->get_value() / 2 -
1039 gui->update_preview();
1040 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1048 CWindowCameraTop::CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1049 : BC_Button(x, y, mwindow->theme->get_image_set("top_justify"))
1052 this->mwindow = mwindow;
1053 set_tooltip(_("Top justify"));
1055 int CWindowCameraTop::handle_event()
1057 FloatAuto *y_auto = 0;
1058 FloatAuto *z_auto = 0;
1059 Track *track = mwindow->cwindow->calculate_affected_track();
1062 mwindow->cwindow->calculate_affected_autos(0,
1072 if(y_auto && z_auto)
1075 track->get_source_dimensions(
1076 mwindow->edl->local_session->get_selectionstart(1),
1082 mwindow->undo->update_undo_before(_("camera"), 0);
1083 y_auto->set_value((double)track->track_h / z_auto->get_value() / 2 -
1086 gui->update_preview();
1087 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1095 CWindowCameraMiddle::CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1096 : BC_Button(x, y, mwindow->theme->get_image_set("middle_justify"))
1099 this->mwindow = mwindow;
1100 set_tooltip(_("Center vertical"));
1102 int CWindowCameraMiddle::handle_event()
1104 FloatAuto *y_auto = 0;
1105 Track *track = mwindow->cwindow->calculate_affected_track();
1107 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1108 track->automation->autos[AUTOMATION_CAMERA_Y], 1);
1112 mwindow->undo->update_undo_before(_("camera"), 0);
1113 y_auto->set_value(0);
1115 gui->update_preview();
1116 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1123 CWindowCameraBottom::CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1124 : BC_Button(x, y, mwindow->theme->get_image_set("bottom_justify"))
1127 this->mwindow = mwindow;
1128 set_tooltip(_("Bottom justify"));
1130 int CWindowCameraBottom::handle_event()
1132 FloatAuto *y_auto = 0;
1133 FloatAuto *z_auto = 0;
1134 Track *track = mwindow->cwindow->calculate_affected_track();
1137 mwindow->cwindow->calculate_affected_autos(0,
1147 if(y_auto && z_auto)
1150 track->get_source_dimensions(
1151 mwindow->edl->local_session->get_selectionstart(1),
1157 mwindow->undo->update_undo_before(_("camera"), 0);
1158 y_auto->set_value(-((double)track->track_h / z_auto->get_value() / 2 -
1161 gui->update_preview();
1162 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1170 CWindowProjectorGUI::CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread)
1171 : CWindowToolGUI(mwindow,
1173 _(PROGRAM_NAME ": Projector"),
1178 CWindowProjectorGUI::~CWindowProjectorGUI()
1181 void CWindowProjectorGUI::create_objects()
1183 int x = 10, y = 10, x1;
1184 Track *track = mwindow->cwindow->calculate_affected_track();
1185 FloatAuto *x_auto = 0;
1186 FloatAuto *y_auto = 0;
1187 FloatAuto *z_auto = 0;
1191 lock_window("CWindowProjectorGUI::create_objects");
1194 mwindow->cwindow->calculate_affected_autos(&x_auto,
1204 add_subwindow(title = new BC_Title(x, y, "X:"));
1205 x += title->get_w();
1206 this->x = new CWindowCoord(this, x, y,
1207 x_auto ? x_auto->get_value() : (float)0);
1208 this->x->create_objects();
1211 add_subwindow(title = new BC_Title(x, y, "Y:"));
1212 x += title->get_w();
1213 this->y = new CWindowCoord(this, x, y,
1214 y_auto ? y_auto->get_value() : (float)0);
1215 this->y->create_objects();
1218 add_subwindow(title = new BC_Title(x, y, "Z:"));
1219 x += title->get_w();
1220 this->z = new CWindowCoord(this, x, y,
1221 z_auto ? z_auto->get_value() : (float)1);
1222 this->z->create_objects();
1223 this->z->set_increment(0.01);
1227 add_subwindow(button = new CWindowProjectorLeft(mwindow, this, x1, y));
1228 x1 += button->get_w();
1229 add_subwindow(button = new CWindowProjectorCenter(mwindow, this, x1, y));
1230 x1 += button->get_w();
1231 add_subwindow(button = new CWindowProjectorRight(mwindow, this, x1, y));
1233 y += button->get_h();
1235 add_subwindow(button = new CWindowProjectorTop(mwindow, this, x1, y));
1236 x1 += button->get_w();
1237 add_subwindow(button = new CWindowProjectorMiddle(mwindow, this, x1, y));
1238 x1 += button->get_w();
1239 add_subwindow(button = new CWindowProjectorBottom(mwindow, this, x1, y));
1241 // additional Buttons to control the curve mode of the "current" keyframe
1242 x1 += button->get_w() + 15;
1243 add_subwindow(this->t_smooth = new CWindowCurveToggle(Projector_Crv_Smooth, mwindow, this, x1, y));
1244 x1 += button->get_w();
1245 add_subwindow(this->t_linear = new CWindowCurveToggle(Projector_Crv_Linear, mwindow, this, x1, y));
1247 // fill in current auto keyframe values, set toggle states.
1252 void CWindowProjectorGUI::update_preview()
1254 mwindow->gui->lock_window("CWindowProjectorGUI::update_preview");
1255 mwindow->restart_brender();
1256 mwindow->sync_parameters(CHANGE_PARAMS);
1257 mwindow->gui->draw_overlays(1);
1258 mwindow->gui->unlock_window();
1259 mwindow->cwindow->refresh_frame(CHANGE_NONE);
1260 mwindow->cwindow->gui->lock_window("CWindowProjectorGUI::update_preview");
1261 mwindow->cwindow->gui->canvas->draw_refresh();
1262 mwindow->cwindow->gui->unlock_window();
1265 void CWindowProjectorGUI::handle_event()
1267 FloatAuto *x_auto = 0;
1268 FloatAuto *y_auto = 0;
1269 FloatAuto *z_auto = 0;
1270 Track *track = mwindow->cwindow->calculate_affected_track();
1274 mwindow->undo->update_undo_before(_("projector"), this);
1275 if(event_caller == x)
1277 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1278 track->automation->autos[AUTOMATION_PROJECTOR_X],
1282 x_auto->set_value(atof(x->get_text()));
1288 if(event_caller == y)
1290 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1291 track->automation->autos[AUTOMATION_PROJECTOR_Y],
1295 y_auto->set_value(atof(y->get_text()));
1301 if(event_caller == z)
1303 z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1304 track->automation->autos[AUTOMATION_PROJECTOR_Z],
1308 float zoom = atof(z->get_text());
1309 if(zoom > 100.) zoom = 100.;
1310 else if(zoom < 0.01) zoom = 0.01;
1311 // if (zoom != atof(z->get_text()))
1313 z_auto->set_value(zoom);
1315 mwindow->gui->lock_window("CWindowProjectorGUI::handle_event");
1316 mwindow->gui->draw_overlays(1);
1317 mwindow->gui->unlock_window();
1323 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1327 void CWindowProjectorGUI::update()
1329 FloatAuto *x_auto = 0;
1330 FloatAuto *y_auto = 0;
1331 FloatAuto *z_auto = 0;
1332 Track *track = mwindow->cwindow->calculate_affected_track();
1336 mwindow->cwindow->calculate_affected_autos(&x_auto,
1347 x->update(x_auto->get_value());
1349 y->update(y_auto->get_value());
1351 float value = z_auto->get_value();
1353 thread->gui->composite_panel->cpanel_zoom->update(value);
1356 if( x_auto && y_auto && z_auto )
1358 t_smooth->check_toggle_state(x_auto, y_auto, z_auto);
1359 t_linear->check_toggle_state(x_auto, y_auto, z_auto);
1363 CWindowProjectorLeft::CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1364 : BC_Button(x, y, mwindow->theme->get_image_set("left_justify"))
1367 this->mwindow = mwindow;
1368 set_tooltip(_("Left justify"));
1370 int CWindowProjectorLeft::handle_event()
1372 FloatAuto *x_auto = 0;
1373 FloatAuto *z_auto = 0;
1374 Track *track = mwindow->cwindow->calculate_affected_track();
1377 mwindow->cwindow->calculate_affected_autos(&x_auto,
1386 if(x_auto && z_auto)
1388 mwindow->undo->update_undo_before(_("projector"), 0);
1389 x_auto->set_value( (double)track->track_w * z_auto->get_value() / 2 -
1390 (double)mwindow->edl->session->output_w / 2 );
1392 gui->update_preview();
1393 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1400 CWindowProjectorCenter::CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1401 : BC_Button(x, y, mwindow->theme->get_image_set("center_justify"))
1404 this->mwindow = mwindow;
1405 set_tooltip(_("Center horizontal"));
1407 int CWindowProjectorCenter::handle_event()
1409 FloatAuto *x_auto = 0;
1410 Track *track = mwindow->cwindow->calculate_affected_track();
1412 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1413 track->automation->autos[AUTOMATION_PROJECTOR_X],
1418 mwindow->undo->update_undo_before(_("projector"), 0);
1419 x_auto->set_value(0);
1421 gui->update_preview();
1422 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1429 CWindowProjectorRight::CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1430 : BC_Button(x, y, mwindow->theme->get_image_set("right_justify"))
1433 this->mwindow = mwindow;
1434 set_tooltip(_("Right justify"));
1436 int CWindowProjectorRight::handle_event()
1438 FloatAuto *x_auto = 0;
1439 FloatAuto *z_auto = 0;
1440 Track *track = mwindow->cwindow->calculate_affected_track();
1443 mwindow->cwindow->calculate_affected_autos(&x_auto,
1453 if(x_auto && z_auto)
1455 mwindow->undo->update_undo_before(_("projector"), 0);
1456 x_auto->set_value( -((double)track->track_w * z_auto->get_value() / 2 -
1457 (double)mwindow->edl->session->output_w / 2));
1459 gui->update_preview();
1460 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1467 CWindowProjectorTop::CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1468 : BC_Button(x, y, mwindow->theme->get_image_set("top_justify"))
1471 this->mwindow = mwindow;
1472 set_tooltip(_("Top justify"));
1474 int CWindowProjectorTop::handle_event()
1476 FloatAuto *y_auto = 0;
1477 FloatAuto *z_auto = 0;
1478 Track *track = mwindow->cwindow->calculate_affected_track();
1481 mwindow->cwindow->calculate_affected_autos(0,
1491 if(y_auto && z_auto)
1493 mwindow->undo->update_undo_before(_("projector"), 0);
1494 y_auto->set_value( (double)track->track_h * z_auto->get_value() / 2 -
1495 (double)mwindow->edl->session->output_h / 2 );
1497 gui->update_preview();
1498 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1505 CWindowProjectorMiddle::CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1506 : BC_Button(x, y, mwindow->theme->get_image_set("middle_justify"))
1509 this->mwindow = mwindow;
1510 set_tooltip(_("Center vertical"));
1512 int CWindowProjectorMiddle::handle_event()
1514 FloatAuto *y_auto = 0;
1515 Track *track = mwindow->cwindow->calculate_affected_track();
1517 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1518 track->automation->autos[AUTOMATION_PROJECTOR_Y], 1);
1522 mwindow->undo->update_undo_before(_("projector"), 0);
1523 y_auto->set_value(0);
1525 gui->update_preview();
1526 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1533 CWindowProjectorBottom::CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1534 : BC_Button(x, y, mwindow->theme->get_image_set("bottom_justify"))
1537 this->mwindow = mwindow;
1538 set_tooltip(_("Bottom justify"));
1540 int CWindowProjectorBottom::handle_event()
1542 FloatAuto *y_auto = 0;
1543 FloatAuto *z_auto = 0;
1544 Track *track = mwindow->cwindow->calculate_affected_track();
1547 mwindow->cwindow->calculate_affected_autos(0,
1557 if(y_auto && z_auto)
1559 mwindow->undo->update_undo_before(_("projector"), 0);
1560 y_auto->set_value( -((double)track->track_h * z_auto->get_value() / 2 -
1561 (double)mwindow->edl->session->output_h / 2));
1563 gui->update_preview();
1564 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1571 CWindowMaskMode::CWindowMaskMode(MWindow *mwindow,
1572 CWindowToolGUI *gui, int x, int y, const char *text)
1573 : BC_PopupMenu(x, y, 220, text, 1)
1575 this->mwindow = mwindow;
1579 void CWindowMaskMode::create_objects()
1581 add_item(new BC_MenuItem(mode_to_text(MASK_MULTIPLY_ALPHA)));
1582 add_item(new BC_MenuItem(mode_to_text(MASK_SUBTRACT_ALPHA)));
1585 char* CWindowMaskMode::mode_to_text(int mode)
1589 case MASK_MULTIPLY_ALPHA:
1590 return _("Multiply alpha");
1593 case MASK_SUBTRACT_ALPHA:
1594 return _("Subtract alpha");
1598 return _("Subtract alpha");
1601 int CWindowMaskMode::text_to_mode(char *text)
1603 if(!strcasecmp(text, _("Multiply alpha")))
1604 return MASK_MULTIPLY_ALPHA;
1606 if(!strcasecmp(text, _("Subtract alpha")))
1607 return MASK_SUBTRACT_ALPHA;
1609 return MASK_SUBTRACT_ALPHA;
1612 int CWindowMaskMode::handle_event()
1619 // Get existing keyframe
1620 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1623 mwindow->undo->update_undo_before(_("mask mode"), 0);
1624 #ifdef USE_KEYFRAME_SPANNING
1625 // Create temp keyframe
1626 MaskAuto temp_keyframe(mwindow->edl, autos);
1627 temp_keyframe.copy_data(keyframe);
1629 temp_keyframe.mode = text_to_mode(get_text());
1630 // Commit change to span of keyframes
1631 autos->update_parameter(&temp_keyframe);
1633 ((MaskAuto*)autos->default_auto)->mode =
1634 text_to_mode(get_text());
1636 mwindow->undo->update_undo_after(_("mask mode"), LOAD_AUTOMATION);
1639 //printf("CWindowMaskMode::handle_event 1\n");
1640 gui->update_preview();
1651 CWindowMaskDelete::CWindowMaskDelete(MWindow *mwindow,
1652 CWindowToolGUI *gui,
1655 : BC_GenericButton(x, y, _("Delete"))
1657 this->mwindow = mwindow;
1661 int CWindowMaskDelete::handle_event()
1668 int total_points = 0;
1670 // Get existing keyframe
1671 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1675 mwindow->undo->update_undo_before(_("mask delete"), 0);
1677 #ifdef USE_KEYFRAME_SPANNING
1678 // Create temp keyframe
1679 MaskAuto temp_keyframe(mwindow->edl, autos);
1680 temp_keyframe.copy_data(keyframe);
1682 SubMask *submask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
1684 submask->points.remove_all_objects();
1686 for(int i = mwindow->cwindow->gui->affected_point;
1687 i < submask->points.total - 1;
1690 *submask->points.values[i] = *submask->points.values[i + 1];
1693 if(submask->points.total)
1695 submask->points.remove_object(
1696 submask->points.values[submask->points.total - 1]);
1698 total_points = submask->points.total;
1700 // Commit change to span of keyframes
1701 ((MaskAutos*)track->automation->autos[AUTOMATION_MASK])->update_parameter(&temp_keyframe);
1703 for(MaskAuto *current = (MaskAuto*)autos->default_auto;
1706 SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
1708 submask->points.remove_all_objects();
1710 for(int i = mwindow->cwindow->gui->affected_point;
1711 i < submask->points.total - 1;
1714 *submask->points.values[i] = *submask->points.values[i + 1];
1717 if(submask->points.total)
1719 submask->points.remove_object(
1720 submask->points.values[submask->points.total - 1]);
1722 total_points = submask->points.total;
1724 if(current == (MaskAuto*)autos->default_auto)
1725 current = (MaskAuto*)autos->first;
1727 current = (MaskAuto*)NEXT;
1730 if( mwindow->cwindow->gui->affected_point >= total_points )
1731 mwindow->cwindow->gui->affected_point =
1732 total_points > 0 ? total_points-1 : 0;
1735 gui->update_preview();
1736 mwindow->undo->update_undo_after(_("mask delete"), LOAD_AUTOMATION);
1743 int CWindowMaskDelete::keypress_event()
1745 if(get_keypress() == BACKSPACE ||
1746 get_keypress() == DELETE)
1747 return handle_event();
1752 // CWindowMaskCycleNext::CWindowMaskCycleNext(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1753 // : BC_GenericButton(x, y, _("Cycle next"))
1755 // this->mwindow = mwindow;
1758 // int CWindowMaskCycleNext::handle_event()
1760 // MaskAuto *keyframe;
1761 // MaskAutos *autos;
1763 // MaskPoint *point;
1765 // ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1769 // // Should apply to all keyframes
1770 // if(keyframe && mask->points.total)
1772 // temp = mask->points.values[0];
1774 // for(int i = 0; i < mask->points.total - 1; i++)
1776 // mask->points.values[i] = mask->points.values[i + 1];
1778 // mask->points.values[mask->points.total - 1] = temp;
1780 // mwindow->cwindow->gui->affected_point--;
1781 // if(mwindow->cwindow->gui->affected_point < 0)
1782 // mwindow->cwindow->gui->affected_point = mask->points.total - 1;
1785 // gui->update_preview();
1791 // CWindowMaskCyclePrev::CWindowMaskCyclePrev(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1792 // : BC_GenericButton(x, y, _("Cycle prev"))
1794 // this->mwindow = mwindow;
1797 // int CWindowMaskCyclePrev::handle_event()
1799 // MaskAuto *keyframe;
1800 // MaskAutos *autos;
1802 // MaskPoint *point;
1804 // ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1806 // // Should apply to all keyframes
1808 // if(keyframe && mask->points.total)
1810 // temp = mask->points.values[mask->points.total - 1];
1812 // for(int i = mask->points.total - 1; i > 0; i--)
1814 // mask->points.values[i] = mask->points.values[i - 1];
1816 // mask->points.values[0] = temp;
1818 // mwindow->cwindow->gui->affected_point++;
1819 // if(mwindow->cwindow->gui->affected_point >= mask->points.total)
1820 // mwindow->cwindow->gui->affected_point = 0;
1823 // gui->update_preview();
1829 CWindowMaskNumber::CWindowMaskNumber(MWindow *mwindow,
1830 CWindowToolGUI *gui,
1833 : BC_TumbleTextBox(gui,
1834 (int64_t)mwindow->edl->session->cwindow_mask,
1836 (int64_t)SUBMASKS - 1,
1841 this->mwindow = mwindow;
1845 CWindowMaskNumber::~CWindowMaskNumber()
1849 int CWindowMaskNumber::handle_event()
1851 mwindow->edl->session->cwindow_mask = atol(get_text());
1853 gui->update_preview();
1858 CWindowMaskAffectedPoint::CWindowMaskAffectedPoint(MWindow *mwindow,
1859 CWindowToolGUI *gui, int x, int y)
1860 : BC_TumbleTextBox(gui,
1861 (int64_t)mwindow->cwindow->gui->affected_point,
1862 (int64_t)0, INT64_MAX, x, y, 100)
1864 this->mwindow = mwindow;
1868 CWindowMaskAffectedPoint::~CWindowMaskAffectedPoint()
1872 int CWindowMaskAffectedPoint::handle_event()
1874 int total_points = 0;
1875 int affected_point = atol(get_text());
1876 Track *track = mwindow->cwindow->calculate_affected_track();
1878 MaskAutos *autos = (MaskAutos*)track->automation->autos[AUTOMATION_MASK];
1879 MaskAuto *keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(autos, 0);
1881 SubMask *mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
1882 total_points = mask->points.size();
1885 int active_point = affected_point;
1886 if( affected_point >= total_points )
1887 affected_point = total_points - 1;
1888 else if( affected_point < 0 )
1890 if( active_point != affected_point )
1891 update((int64_t)affected_point);
1892 mwindow->cwindow->gui->affected_point = affected_point;
1894 gui->update_preview();
1902 CWindowMaskFeather::CWindowMaskFeather(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1903 : BC_TumbleTextBox(gui,
1911 this->mwindow = mwindow;
1914 CWindowMaskFeather::~CWindowMaskFeather()
1917 int CWindowMaskFeather::handle_event()
1924 #ifdef USE_KEYFRAME_SPANNING
1930 mwindow->undo->update_undo_before(_("mask feather"), this);
1932 // Get existing keyframe
1933 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe,
1934 mask, point, create_it);
1938 #ifdef USE_KEYFRAME_SPANNING
1939 // Create temp keyframe
1940 MaskAuto temp_keyframe(mwindow->edl, autos);
1941 temp_keyframe.copy_data(keyframe);
1943 temp_keyframe.feather = atof(get_text());
1944 // Commit change to span of keyframes
1945 autos->update_parameter(&temp_keyframe);
1947 keyframe->feather = atof(get_text());
1950 gui->update_preview();
1953 mwindow->undo->update_undo_after(_("mask feather"), LOAD_AUTOMATION);
1958 CWindowMaskValue::CWindowMaskValue(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1968 this->mwindow = mwindow;
1972 CWindowMaskValue::~CWindowMaskValue()
1976 int CWindowMaskValue::handle_event()
1983 #ifdef USE_KEYFRAME_SPANNING
1989 mwindow->undo->update_undo_before(_("mask value"), this);
1990 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe,
1991 mask, point, create_it);
1995 #ifdef USE_KEYFRAME_SPANNING
1996 // Create temp keyframe
1997 MaskAuto temp_keyframe(mwindow->edl, autos);
1998 temp_keyframe.copy_data(keyframe);
2000 temp_keyframe.value = get_value();
2001 // Commit change to span of keyframes
2002 autos->update_parameter(&temp_keyframe);
2004 keyframe->value = get_value();
2008 gui->update_preview();
2009 mwindow->undo->update_undo_after(_("mask value"), LOAD_AUTOMATION);
2014 CWindowMaskBeforePlugins::CWindowMaskBeforePlugins(CWindowToolGUI *gui, int x, int y)
2018 _("Apply mask before plugins"))
2023 int CWindowMaskBeforePlugins::handle_event()
2030 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 1);
2033 keyframe->apply_before_plugins = get_value();
2034 gui->update_preview();
2040 CWindowDisableOpenGLMasking::CWindowDisableOpenGLMasking(CWindowToolGUI *gui, int x, int y)
2041 : BC_CheckBox(x, y, 1, _("Disable OpenGL masking"))
2046 int CWindowDisableOpenGLMasking::handle_event()
2053 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 1);
2056 keyframe->disable_opengl_masking = get_value();
2057 gui->update_preview();
2070 CWindowMaskGUI::CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread)
2071 : CWindowToolGUI(mwindow, thread,
2072 _(PROGRAM_NAME ": Mask"), 330, 320)
2074 this->mwindow = mwindow;
2075 this->thread = thread;
2080 CWindowMaskGUI::~CWindowMaskGUI()
2082 lock_window("CWindowMaskGUI::~CWindowMaskGUI");
2084 delete active_point;
2089 void CWindowMaskGUI::create_objects()
2091 int x = 10, y = 10, margin = mwindow->theme->widget_border;
2092 //MaskAuto *keyframe = 0;
2093 //Track *track = mwindow->cwindow->calculate_affected_track();
2095 // keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->autos[AUTOMATION_MASK], 0);
2097 lock_window("CWindowMaskGUI::create_objects");
2099 add_subwindow(title = new BC_Title(x, y, _("Mode:")));
2100 add_subwindow(mode = new CWindowMaskMode(mwindow,
2101 this, x + title->get_w() + margin, y, ""));
2102 mode->create_objects();
2103 y += mode->get_h() + margin;
2104 add_subwindow(title = new BC_Title(x, y, _("Value:")));
2105 add_subwindow(value = new CWindowMaskValue(mwindow, this, x + title->get_w() + margin, y));
2106 y += value->get_h() + margin;
2107 add_subwindow(delete_point = new CWindowMaskDelete(mwindow, this, x, y));
2108 int x1 = x + delete_point->get_w() + 2*margin;
2109 add_subwindow(title = new BC_Title(x1, y, _("Point:")));
2110 x1 += title->get_w() + margin;
2111 active_point = new CWindowMaskAffectedPoint(mwindow, this, x1, y);
2112 active_point->create_objects();
2113 y += delete_point->get_h() + margin;
2114 add_subwindow(title = new BC_Title(x, y, _("Mask number:")));
2115 number = new CWindowMaskNumber(mwindow,
2116 this, x + title->get_w() + margin, y);
2117 number->create_objects();
2118 y += number->get_h() + margin;
2119 add_subwindow(title = new BC_Title(x, y, _("Feather:")));
2120 feather = new CWindowMaskFeather(mwindow,
2121 this, x + title->get_w() + margin, y);
2122 feather->create_objects();
2123 y += feather->get_h() + margin;
2124 add_subwindow(title = new BC_Title(x, y, "X:"));
2125 x += title->get_w() + margin;
2126 this->x = new CWindowCoord(this, x, y, (float)0.0);
2127 this->x->create_objects();
2128 x += this->x->get_w() + margin;
2129 add_subwindow(title = new BC_Title(x, y, "Y:"));
2130 x += title->get_w() + margin;
2131 this->y = new CWindowCoord(this, x, y, (float)0.0);
2132 this->y->create_objects();
2135 y += this->y->get_h() + margin;
2136 add_subwindow(title = new BC_Title(x, y, _("Press Shift to move an end point")));
2137 y += title->get_h() + margin;
2138 add_subwindow(title = new BC_Title(x, y, _("Press Ctrl to move a control point")));
2139 y += title->get_h() + margin;
2140 add_subwindow(title = new BC_Title(x, y, _("Shift+click Delete to delete the mask")));
2141 y += title->get_h() + margin;
2142 add_subwindow(title = new BC_Title(x, y, _("Press Alt to translate the mask")));
2145 add_subwindow(this->apply_before_plugins = new CWindowMaskBeforePlugins(this, 10, y));
2146 y += this->apply_before_plugins->get_h() + margin;
2147 add_subwindow(this->disable_opengl_masking = new CWindowDisableOpenGLMasking(this, 10, y));
2153 void CWindowMaskGUI::get_keyframe(Track* &track,
2155 MaskAuto* &keyframe,
2163 track = mwindow->cwindow->calculate_affected_track();
2166 autos = (MaskAutos*)track->automation->autos[AUTOMATION_MASK];
2167 keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(
2173 mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
2180 if(mwindow->cwindow->gui->affected_point < mask->points.total &&
2181 mwindow->cwindow->gui->affected_point >= 0)
2183 point = mask->points.values[mwindow->cwindow->gui->affected_point];
2188 void CWindowMaskGUI::update()
2195 //printf("CWindowMaskGUI::update 1\n");
2196 get_keyframe(track, autos, keyframe, mask, point, 0);
2198 double position = mwindow->edl->local_session->get_selectionstart(1);
2199 position = mwindow->edl->align_to_frame(position, 0);
2202 int64_t position_i = track->to_units(position, 0);
2206 x->update(point->x);
2207 y->update(point->y);
2212 feather->update((int64_t)autos->get_feather(position_i, PLAY_FORWARD));
2213 value->update((int64_t)autos->get_value(position_i, PLAY_FORWARD));
2214 apply_before_plugins->update((int64_t)keyframe->apply_before_plugins);
2215 disable_opengl_masking->update((int64_t)keyframe->disable_opengl_masking);
2219 //printf("CWindowMaskGUI::update 1\n");
2220 active_point->update((int64_t)mwindow->cwindow->gui->affected_point);
2221 number->update((int64_t)mwindow->edl->session->cwindow_mask);
2223 //printf("CWindowMaskGUI::update 1\n");
2226 #ifdef USE_KEYFRAME_SPANNING
2228 CWindowMaskMode::mode_to_text(keyframe->mode));
2231 CWindowMaskMode::mode_to_text(((MaskAuto*)autos->default_auto)->mode));
2234 //printf("CWindowMaskGUI::update 2\n");
2237 void CWindowMaskGUI::handle_event()
2244 get_keyframe(track, autos, keyframe, mask, point, 0);
2246 mwindow->undo->update_undo_before(_("mask point"), this);
2250 #ifdef USE_KEYFRAME_SPANNING
2251 // Create temp keyframe
2252 MaskAuto temp_keyframe(mwindow->edl, autos);
2253 temp_keyframe.copy_data(keyframe);
2254 // Get affected point in temp keyframe
2255 mask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
2256 if(mwindow->cwindow->gui->affected_point < mask->points.total &&
2257 mwindow->cwindow->gui->affected_point >= 0)
2259 point = mask->points.values[mwindow->cwindow->gui->affected_point];
2264 point->x = atof(x->get_text());
2265 point->y = atof(y->get_text());
2266 // Commit to spanned keyframes
2267 autos->update_parameter(&temp_keyframe);
2270 point->x = atof(x->get_text());
2271 point->y = atof(y->get_text());
2276 mwindow->undo->update_undo_after(_("mask point"), LOAD_AUTOMATION);
2279 void CWindowMaskGUI::update_preview()
2281 mwindow->gui->lock_window("CWindowMaskGUI::update_preview");
2282 mwindow->restart_brender();
2283 mwindow->sync_parameters(CHANGE_PARAMS);
2284 mwindow->gui->draw_overlays(1);
2285 mwindow->gui->unlock_window();
2286 mwindow->cwindow->refresh_frame(CHANGE_NONE);
2287 mwindow->cwindow->gui->lock_window("CWindowMaskGUI::update_preview");
2288 mwindow->cwindow->gui->canvas->draw_refresh();
2289 mwindow->cwindow->gui->unlock_window();
2293 CWindowRulerGUI::CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread)
2294 : CWindowToolGUI(mwindow,
2296 _(PROGRAM_NAME ": Ruler"),
2302 CWindowRulerGUI::~CWindowRulerGUI()
2306 void CWindowRulerGUI::create_objects()
2311 lock_window("CWindowRulerGUI::create_objects");
2312 add_subwindow(title = new BC_Title(x, y, _("Current:")));
2313 add_subwindow(current = new BC_Title(x + title->get_w() + 10, y, ""));
2314 y += title->get_h() + 5;
2316 add_subwindow(title = new BC_Title(x, y, _("Point 1:")));
2317 add_subwindow(point1 = new BC_Title(x + title->get_w() + 10, y, ""));
2318 y += title->get_h() + 5;
2320 add_subwindow(title = new BC_Title(x, y, _("Point 2:")));
2321 add_subwindow(point2 = new BC_Title(x + title->get_w() + 10, y, ""));
2322 y += title->get_h() + 5;
2324 add_subwindow(title = new BC_Title(x, y, _("Distance:")));
2325 add_subwindow(distance = new BC_Title(x + title->get_w() + 10, y, ""));
2326 y += title->get_h() + 5;
2327 add_subwindow(title = new BC_Title(x, y, _("Angle:")));
2328 add_subwindow(angle = new BC_Title(x + title->get_w() + 10, y, ""));
2329 y += title->get_h() + 10;
2330 char string[BCTEXTLEN];
2331 sprintf(string, _("Press Ctrl to lock ruler to the\nnearest 45%c angle."), 0xb0);
2332 add_subwindow(title = new BC_Title(x,
2335 y += title->get_h() + 10;
2336 sprintf(string, _("Press Alt to translate the ruler."));
2337 add_subwindow(title = new BC_Title(x,
2344 void CWindowRulerGUI::update()
2346 double distance_value =
2347 sqrt(SQR(mwindow->edl->session->ruler_x2 - mwindow->edl->session->ruler_x1) +
2348 SQR(mwindow->edl->session->ruler_y2 - mwindow->edl->session->ruler_y1));
2349 double angle_value = atan((mwindow->edl->session->ruler_y2 - mwindow->edl->session->ruler_y1) /
2350 (mwindow->edl->session->ruler_x2 - mwindow->edl->session->ruler_x1)) *
2355 if(EQUIV(distance_value, 0.0))
2365 char string[BCTEXTLEN];
2366 sprintf(string, "%d, %d",
2367 mwindow->session->cwindow_output_x,
2368 mwindow->session->cwindow_output_y);
2369 current->update(string);
2370 sprintf(string, "%.0f, %.0f",
2371 mwindow->edl->session->ruler_x1,
2372 mwindow->edl->session->ruler_y1);
2373 point1->update(string);
2374 sprintf(string, "%.0f, %.0f",
2375 mwindow->edl->session->ruler_x2,
2376 mwindow->edl->session->ruler_y2);
2377 point2->update(string);
2379 sprintf(string, _("%0.01f pixels"), distance_value);
2380 distance->update(string);
2381 sprintf(string, "%0.02f %c", angle_value, 0xb0);
2382 angle->update(string);
2385 void CWindowRulerGUI::handle_event()