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()
293 int cwindow_operation = CWINDOW_NONE;
295 switch( get_keypress() ) {
298 return close_event();
309 resend_event(thread->gui);
316 int CWindowToolGUI::translation_event()
318 mwindow->session->ctool_x = get_x();
319 mwindow->session->ctool_y = get_y();
328 CWindowCoord::CWindowCoord(CWindowToolGUI *gui, int x, int y, float value, int log_increment = 0)
329 : BC_TumbleTextBox(gui, (float)value, (float)-65536, (float)65536, x, y, 100)
332 set_log_floatincrement(log_increment);
335 CWindowCoord::CWindowCoord(CWindowToolGUI *gui, int x, int y, int value)
336 : BC_TumbleTextBox(gui, (int64_t)value, (int64_t)-65536, (int64_t)65536, x, y, 100)
340 int CWindowCoord::handle_event()
342 gui->event_caller = this;
348 CWindowCropOK::CWindowCropOK(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
349 : BC_GenericButton(x, y, _("Do it"))
351 this->mwindow = mwindow;
354 int CWindowCropOK::handle_event()
356 mwindow->crop_video();
361 int CWindowCropOK::keypress_event()
363 if(get_keypress() == 0xd)
377 CWindowCropGUI::CWindowCropGUI(MWindow *mwindow, CWindowTool *thread)
378 : CWindowToolGUI(mwindow,
380 _(PROGRAM_NAME ": Crop"),
387 CWindowCropGUI::~CWindowCropGUI()
391 void CWindowCropGUI::create_objects()
396 lock_window("CWindowCropGUI::create_objects");
398 int pad = MAX(BC_TextBox::calculate_h(this, MEDIUMFONT, 1, 1),
399 BC_Title::calculate_h(this, "X")) + 5;
400 add_subwindow(title = new BC_Title(x, y, "X1:"));
401 column1 = MAX(column1, title->get_w());
403 add_subwindow(title = new BC_Title(x, y, _("W:")));
404 column1 = MAX(column1, title->get_w());
406 add_subwindow(new CWindowCropOK(mwindow, thread->tool_gui, x, y));
410 x1 = new CWindowCoord(thread->tool_gui, x, y,
411 mwindow->edl->session->crop_x1);
412 x1->create_objects();
414 width = new CWindowCoord(thread->tool_gui, x, y,
415 mwindow->edl->session->crop_x2 - mwindow->edl->session->crop_x1);
416 width->create_objects();
419 x += x1->get_w() + 10;
422 add_subwindow(title = new BC_Title(x, y, "Y1:"));
423 column2 = MAX(column2, title->get_w());
425 add_subwindow(title = new BC_Title(x, y, _("H:")));
426 column2 = MAX(column2, title->get_w());
431 y1 = new CWindowCoord(thread->tool_gui, x, y,
432 mwindow->edl->session->crop_y1);
433 y1->create_objects();
435 height = new CWindowCoord(thread->tool_gui, x, y,
436 mwindow->edl->session->crop_y2 - mwindow->edl->session->crop_y1);
437 height->create_objects();
441 void CWindowCropGUI::handle_event()
444 new_x1 = atol(x1->get_text());
445 new_y1 = atol(y1->get_text());
446 if(new_x1 != mwindow->edl->session->crop_x1)
448 mwindow->edl->session->crop_x2 = new_x1 +
449 mwindow->edl->session->crop_x2 -
450 mwindow->edl->session->crop_x1;
451 mwindow->edl->session->crop_x1 = new_x1;
453 if(new_y1 != mwindow->edl->session->crop_y1)
455 mwindow->edl->session->crop_y2 = new_y1 +
456 mwindow->edl->session->crop_y2 -
457 mwindow->edl->session->crop_y1;
458 mwindow->edl->session->crop_y1 = atol(y1->get_text());
460 mwindow->edl->session->crop_x2 = atol(width->get_text()) +
461 mwindow->edl->session->crop_x1;
462 mwindow->edl->session->crop_y2 = atol(height->get_text()) +
463 mwindow->edl->session->crop_y1;
465 mwindow->cwindow->gui->lock_window("CWindowCropGUI::handle_event");
466 mwindow->cwindow->gui->canvas->draw_refresh();
467 mwindow->cwindow->gui->unlock_window();
470 void CWindowCropGUI::update()
472 x1->update((int64_t)mwindow->edl->session->crop_x1);
473 y1->update((int64_t)mwindow->edl->session->crop_y1);
474 width->update((int64_t)mwindow->edl->session->crop_x2 -
475 mwindow->edl->session->crop_x1);
476 height->update((int64_t)mwindow->edl->session->crop_y2 -
477 mwindow->edl->session->crop_y1);
481 CWindowEyedropGUI::CWindowEyedropGUI(MWindow *mwindow, CWindowTool *thread)
482 : CWindowToolGUI(mwindow, thread, _(PROGRAM_NAME ": Color"), 220, 290)
486 CWindowEyedropGUI::~CWindowEyedropGUI()
490 void CWindowEyedropGUI::create_objects()
492 int margin = mwindow->theme->widget_border;
495 int x2 = 70, x3 = x2 + 60;
496 lock_window("CWindowEyedropGUI::create_objects");
497 BC_Title *title0, *title1, *title2, *title3, *title4, *title5, *title6, *title7;
498 add_subwindow(title0 = new BC_Title(x, y,_("X,Y:")));
499 y += title0->get_h() + margin;
500 add_subwindow(title7 = new BC_Title(x, y, _("Radius:")));
501 y += BC_TextBox::calculate_h(this, MEDIUMFONT, 1, 1) + margin;
503 add_subwindow(title1 = new BC_Title(x, y, _("Red:")));
504 y += title1->get_h() + margin;
505 add_subwindow(title2 = new BC_Title(x, y, _("Green:")));
506 y += title2->get_h() + margin;
507 add_subwindow(title3 = new BC_Title(x, y, _("Blue:")));
508 y += title3->get_h() + margin;
510 add_subwindow(title4 = new BC_Title(x, y, "Y:"));
511 y += title4->get_h() + margin;
512 add_subwindow(title5 = new BC_Title(x, y, "U:"));
513 y += title5->get_h() + margin;
514 add_subwindow(title6 = new BC_Title(x, y, "V:"));
516 add_subwindow(current = new BC_Title(x2, title0->get_y(), ""));
518 radius = new CWindowCoord(this, x2, title7->get_y(),
519 mwindow->edl->session->eyedrop_radius);
520 radius->create_objects();
521 radius->set_boundaries((int64_t)0, (int64_t)255);
523 add_subwindow(red = new BC_Title(x2, title1->get_y(), "0"));
524 add_subwindow(green = new BC_Title(x2, title2->get_y(), "0"));
525 add_subwindow(blue = new BC_Title(x2, title3->get_y(), "0"));
526 add_subwindow(rgb_hex = new BC_Title(x3, red->get_y(), "#000000"));
528 add_subwindow(this->y = new BC_Title(x2, title4->get_y(), "0"));
529 add_subwindow(this->u = new BC_Title(x2, title5->get_y(), "0"));
530 add_subwindow(this->v = new BC_Title(x2, title6->get_y(), "0"));
531 add_subwindow(yuv_hex = new BC_Title(x3, this->y->get_y(), "#000000"));
533 y = title6->get_y() + this->v->get_h() + 2*margin;
534 add_subwindow(sample = new BC_SubWindow(x, y, 50, 50));
535 y += sample->get_h() + margin;
536 add_subwindow(use_max = new CWindowEyedropCheckBox(mwindow, this, x, y));
541 void CWindowEyedropGUI::update()
543 char string[BCTEXTLEN];
544 sprintf(string, "%d, %d",
545 thread->gui->eyedrop_x,
546 thread->gui->eyedrop_y);
547 current->update(string);
549 radius->update((int64_t)mwindow->edl->session->eyedrop_radius);
551 LocalSession *local_session = mwindow->edl->local_session;
552 int use_max = local_session->use_max;
553 float r = use_max ? local_session->red_max : local_session->red;
554 float g = use_max ? local_session->green_max : local_session->green;
555 float b = use_max ? local_session->blue_max : local_session->blue;
556 this->red->update(r);
557 this->green->update(g);
558 this->blue->update(b);
560 int rx = 255*r + 0.5; bclamp(rx,0,255);
561 int gx = 255*g + 0.5; bclamp(gx,0,255);
562 int bx = 255*b + 0.5; bclamp(bx,0,255);
563 char rgb_text[BCSTRLEN];
564 sprintf(rgb_text, "#%02x%02x%02x", rx, gx, bx);
565 rgb_hex->update(rgb_text);
568 YUV::yuv.rgb_to_yuv_f(r, g, b, y, u, v);
570 this->u->update(u); u += 0.5;
571 this->v->update(v); v += 0.5;
573 int yx = 255*y + 0.5; bclamp(yx,0,255);
574 int ux = 255*u + 0.5; bclamp(ux,0,255);
575 int vx = 255*v + 0.5; bclamp(vx,0,255);
576 char yuv_text[BCSTRLEN];
577 sprintf(yuv_text, "#%02x%02x%02x", yx, ux, vx);
578 yuv_hex->update(yuv_text);
580 int rgb = (rx << 16) | (gx << 8) | (bx << 0);
581 sample->set_color(rgb);
582 sample->draw_box(0, 0, sample->get_w(), sample->get_h());
583 sample->set_color(BLACK);
584 sample->draw_rectangle(0, 0, sample->get_w(), sample->get_h());
588 void CWindowEyedropGUI::handle_event()
590 int new_radius = atoi(radius->get_text());
591 if(new_radius != mwindow->edl->session->eyedrop_radius)
593 CWindowGUI *gui = mwindow->cwindow->gui;
594 if(gui->eyedrop_visible)
596 gui->lock_window("CWindowEyedropGUI::handle_event");
599 gui->canvas->do_eyedrop(rerender, 0, 1);
602 mwindow->edl->session->eyedrop_radius = new_radius;
604 if(gui->eyedrop_visible)
608 gui->canvas->do_eyedrop(rerender, 0, 1);
609 gui->unlock_window();
616 /* Buttons to control Keyframe-Curve-Mode for Projector or Camera */
618 // Configuration for all possible Keyframe Curve Mode toggles
620 FloatAuto::t_mode mode;
626 const _CVD Camera_Crv_Smooth =
630 N_("\"smooth\" Curve on current Camera Keyframes")
632 const _CVD Camera_Crv_Linear =
636 N_("\"linear\" Curve on current Camera Keyframes")
638 const _CVD Projector_Crv_Smooth =
642 N_("\"smooth\" Curve on current Projector Keyframes")
644 const _CVD Projector_Crv_Linear =
648 N_("\"linear\" Curve on current Projector Keyframes")
651 // Implementation Class für Keyframe Curve Mode buttons
653 // This button reflects the state of the "current" keyframe
654 // (the nearest keyframe on the left) for all three automation
655 // lines together. Clicking on this button (re)sets the curve
656 // mode for the three "current" keyframes simultanously, but
657 // never creates a new keyframe.
659 class CWindowCurveToggle : public BC_Toggle
662 CWindowCurveToggle(_CVD mode, MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
663 void check_toggle_state(FloatAuto *x, FloatAuto *y, FloatAuto *z);
672 CWindowCurveToggle::CWindowCurveToggle(_CVD mode, MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
673 : BC_Toggle(x, y, mwindow->theme->get_image_set(mode.icon_id), false),
677 this->mwindow = mwindow;
678 set_tooltip(_(cfg.tooltip));
681 void CWindowCurveToggle::check_toggle_state(FloatAuto *x, FloatAuto *y, FloatAuto *z)
683 // the toggle state is only set to ON if all
684 // three automation lines have the same curve mode.
685 // For mixed states the toggle stays off.
686 set_value( x->curve_mode == this->cfg.mode &&
687 y->curve_mode == this->cfg.mode &&
688 z->curve_mode == this->cfg.mode
689 ,true // redraw to show new state
693 int CWindowCurveToggle::handle_event()
695 FloatAuto *x=0, *y=0, *z=0;
696 Track *track = mwindow->cwindow->calculate_affected_track();
699 { mwindow->cwindow->calculate_affected_autos(&x, &y, &z,
700 track, cfg.use_camera, 0,0,0); // don't create new keyframe
702 if(x) x->change_curve_mode(cfg.mode);
703 if(y) y->change_curve_mode(cfg.mode);
704 if(z) z->change_curve_mode(cfg.mode);
707 gui->update_preview();
714 CWindowEyedropCheckBox::CWindowEyedropCheckBox(MWindow *mwindow,
715 CWindowEyedropGUI *gui, int x, int y)
716 : BC_CheckBox(x, y, mwindow->edl->local_session->use_max, _("Use maximum"))
718 this->mwindow = mwindow;
722 int CWindowEyedropCheckBox::handle_event()
724 mwindow->edl->local_session->use_max = get_value();
731 CWindowCameraGUI::CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread)
732 : CWindowToolGUI(mwindow,
734 _(PROGRAM_NAME ": Camera"),
739 CWindowCameraGUI::~CWindowCameraGUI()
743 void CWindowCameraGUI::create_objects()
745 int x = 10, y = 10, x1;
746 Track *track = mwindow->cwindow->calculate_affected_track();
747 FloatAuto *x_auto = 0;
748 FloatAuto *y_auto = 0;
749 FloatAuto *z_auto = 0;
753 lock_window("CWindowCameraGUI::create_objects");
756 mwindow->cwindow->calculate_affected_autos(&x_auto,
757 &y_auto, &z_auto, track, 1, 0, 0, 0);
760 add_subwindow(title = new BC_Title(x, y, "X:"));
762 this->x = new CWindowCoord(this, x, y,
763 x_auto ? x_auto->get_value() : (float)0);
764 this->x->create_objects();
769 add_subwindow(title = new BC_Title(x, y, "Y:"));
771 this->y = new CWindowCoord(this, x, y,
772 y_auto ? y_auto->get_value() : (float)0);
773 this->y->create_objects();
776 add_subwindow(title = new BC_Title(x, y, "Z:"));
778 this->z = new CWindowCoord(this, x, y,
779 z_auto ? z_auto->get_value() : (float)1);
780 this->z->create_objects();
781 this->z->set_increment(0.01);
785 add_subwindow(button = new CWindowCameraLeft(mwindow, this, x1, y));
786 x1 += button->get_w();
787 add_subwindow(button = new CWindowCameraCenter(mwindow, this, x1, y));
788 x1 += button->get_w();
789 add_subwindow(button = new CWindowCameraRight(mwindow, this, x1, y));
791 y += button->get_h();
793 add_subwindow(button = new CWindowCameraTop(mwindow, this, x1, y));
794 x1 += button->get_w();
795 add_subwindow(button = new CWindowCameraMiddle(mwindow, this, x1, y));
796 x1 += button->get_w();
797 add_subwindow(button = new CWindowCameraBottom(mwindow, this, x1, y));
798 // additional Buttons to control the curve mode of the "current" keyframe
799 x1 += button->get_w() + 15;
800 add_subwindow(this->t_smooth = new CWindowCurveToggle(Camera_Crv_Smooth, mwindow, this, x1, y));
801 x1 += button->get_w();
802 add_subwindow(this->t_linear = new CWindowCurveToggle(Camera_Crv_Linear, mwindow, this, x1, y));
804 // fill in current auto keyframe values, set toggle states.
809 void CWindowCameraGUI::update_preview()
811 mwindow->gui->lock_window("CWindowCameraGUI::update_preview");
812 mwindow->restart_brender();
813 mwindow->gui->draw_overlays(1);
814 mwindow->sync_parameters(CHANGE_PARAMS);
815 mwindow->gui->unlock_window();
816 mwindow->cwindow->refresh_frame(CHANGE_NONE);
817 mwindow->cwindow->gui->lock_window("CWindowCameraGUI::update_preview");
818 mwindow->cwindow->gui->canvas->draw_refresh();
819 mwindow->cwindow->gui->unlock_window();
823 void CWindowCameraGUI::handle_event()
825 FloatAuto *x_auto = 0;
826 FloatAuto *y_auto = 0;
827 FloatAuto *z_auto = 0;
828 Track *track = mwindow->cwindow->calculate_affected_track();
831 mwindow->undo->update_undo_before(_("camera"), this);
832 if(event_caller == x)
834 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
835 track->automation->autos[AUTOMATION_CAMERA_X],
839 x_auto->set_value(atof(x->get_text()));
845 if(event_caller == y)
847 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
848 track->automation->autos[AUTOMATION_CAMERA_Y],
852 y_auto->set_value(atof(y->get_text()));
858 if(event_caller == z)
860 z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
861 track->automation->autos[AUTOMATION_CAMERA_Z],
865 float zoom = atof(z->get_text());
866 if(zoom > 100.) zoom = 100.;
868 if(zoom < 0.01) zoom = 0.01;
869 // Doesn't allow user to enter from scratch
870 // if(zoom != atof(z->get_text()))
873 z_auto->set_value(zoom);
874 mwindow->gui->lock_window("CWindowCameraGUI::handle_event");
875 mwindow->gui->draw_overlays(1);
876 mwindow->gui->unlock_window();
882 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
886 void CWindowCameraGUI::update()
888 FloatAuto *x_auto = 0;
889 FloatAuto *y_auto = 0;
890 FloatAuto *z_auto = 0;
891 Track *track = mwindow->cwindow->calculate_affected_track();
895 mwindow->cwindow->calculate_affected_autos(&x_auto,
906 x->update(x_auto->get_value());
908 y->update(y_auto->get_value());
910 float value = z_auto->get_value();
912 thread->gui->composite_panel->cpanel_zoom->update(value);
915 if( x_auto && y_auto && z_auto )
917 t_smooth->check_toggle_state(x_auto, y_auto, z_auto);
918 t_linear->check_toggle_state(x_auto, y_auto, z_auto);
925 CWindowCameraLeft::CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
926 : BC_Button(x, y, mwindow->theme->get_image_set("left_justify"))
929 this->mwindow = mwindow;
930 set_tooltip(_("Left justify"));
932 int CWindowCameraLeft::handle_event()
934 FloatAuto *x_auto = 0;
935 FloatAuto *z_auto = 0;
936 Track *track = mwindow->cwindow->calculate_affected_track();
939 mwindow->cwindow->calculate_affected_autos(&x_auto,
952 track->get_source_dimensions(
953 mwindow->edl->local_session->get_selectionstart(1),
959 mwindow->undo->update_undo_before(_("camera"), 0);
961 (double)track->track_w / z_auto->get_value() / 2 -
963 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
965 gui->update_preview();
973 CWindowCameraCenter::CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
974 : BC_Button(x, y, mwindow->theme->get_image_set("center_justify"))
977 this->mwindow = mwindow;
978 set_tooltip(_("Center horizontal"));
980 int CWindowCameraCenter::handle_event()
982 FloatAuto *x_auto = 0;
983 Track *track = mwindow->cwindow->calculate_affected_track();
985 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
986 track->automation->autos[AUTOMATION_CAMERA_X],
991 mwindow->undo->update_undo_before(_("camera"), 0);
992 x_auto->set_value(0);
994 gui->update_preview();
995 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1002 CWindowCameraRight::CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1003 : BC_Button(x, y, mwindow->theme->get_image_set("right_justify"))
1006 this->mwindow = mwindow;
1007 set_tooltip(_("Right justify"));
1009 int CWindowCameraRight::handle_event()
1011 FloatAuto *x_auto = 0;
1012 FloatAuto *z_auto = 0;
1013 Track *track = mwindow->cwindow->calculate_affected_track();
1016 mwindow->cwindow->calculate_affected_autos(&x_auto,
1026 if(x_auto && z_auto)
1029 track->get_source_dimensions(
1030 mwindow->edl->local_session->get_selectionstart(1),
1036 mwindow->undo->update_undo_before(_("camera"), 0);
1037 x_auto->set_value( -((double)track->track_w / z_auto->get_value() / 2 -
1040 gui->update_preview();
1041 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1049 CWindowCameraTop::CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1050 : BC_Button(x, y, mwindow->theme->get_image_set("top_justify"))
1053 this->mwindow = mwindow;
1054 set_tooltip(_("Top justify"));
1056 int CWindowCameraTop::handle_event()
1058 FloatAuto *y_auto = 0;
1059 FloatAuto *z_auto = 0;
1060 Track *track = mwindow->cwindow->calculate_affected_track();
1063 mwindow->cwindow->calculate_affected_autos(0,
1073 if(y_auto && z_auto)
1076 track->get_source_dimensions(
1077 mwindow->edl->local_session->get_selectionstart(1),
1083 mwindow->undo->update_undo_before(_("camera"), 0);
1084 y_auto->set_value((double)track->track_h / z_auto->get_value() / 2 -
1087 gui->update_preview();
1088 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1096 CWindowCameraMiddle::CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1097 : BC_Button(x, y, mwindow->theme->get_image_set("middle_justify"))
1100 this->mwindow = mwindow;
1101 set_tooltip(_("Center vertical"));
1103 int CWindowCameraMiddle::handle_event()
1105 FloatAuto *y_auto = 0;
1106 Track *track = mwindow->cwindow->calculate_affected_track();
1108 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1109 track->automation->autos[AUTOMATION_CAMERA_Y], 1);
1113 mwindow->undo->update_undo_before(_("camera"), 0);
1114 y_auto->set_value(0);
1116 gui->update_preview();
1117 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1124 CWindowCameraBottom::CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1125 : BC_Button(x, y, mwindow->theme->get_image_set("bottom_justify"))
1128 this->mwindow = mwindow;
1129 set_tooltip(_("Bottom justify"));
1131 int CWindowCameraBottom::handle_event()
1133 FloatAuto *y_auto = 0;
1134 FloatAuto *z_auto = 0;
1135 Track *track = mwindow->cwindow->calculate_affected_track();
1138 mwindow->cwindow->calculate_affected_autos(0,
1148 if(y_auto && z_auto)
1151 track->get_source_dimensions(
1152 mwindow->edl->local_session->get_selectionstart(1),
1158 mwindow->undo->update_undo_before(_("camera"), 0);
1159 y_auto->set_value(-((double)track->track_h / z_auto->get_value() / 2 -
1162 gui->update_preview();
1163 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1171 CWindowProjectorGUI::CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread)
1172 : CWindowToolGUI(mwindow,
1174 _(PROGRAM_NAME ": Projector"),
1179 CWindowProjectorGUI::~CWindowProjectorGUI()
1182 void CWindowProjectorGUI::create_objects()
1184 int x = 10, y = 10, x1;
1185 Track *track = mwindow->cwindow->calculate_affected_track();
1186 FloatAuto *x_auto = 0;
1187 FloatAuto *y_auto = 0;
1188 FloatAuto *z_auto = 0;
1192 lock_window("CWindowProjectorGUI::create_objects");
1195 mwindow->cwindow->calculate_affected_autos(&x_auto,
1205 add_subwindow(title = new BC_Title(x, y, "X:"));
1206 x += title->get_w();
1207 this->x = new CWindowCoord(this, x, y,
1208 x_auto ? x_auto->get_value() : (float)0);
1209 this->x->create_objects();
1212 add_subwindow(title = new BC_Title(x, y, "Y:"));
1213 x += title->get_w();
1214 this->y = new CWindowCoord(this, x, y,
1215 y_auto ? y_auto->get_value() : (float)0);
1216 this->y->create_objects();
1219 add_subwindow(title = new BC_Title(x, y, "Z:"));
1220 x += title->get_w();
1221 this->z = new CWindowCoord(this, x, y,
1222 z_auto ? z_auto->get_value() : (float)1);
1223 this->z->create_objects();
1224 this->z->set_increment(0.01);
1228 add_subwindow(button = new CWindowProjectorLeft(mwindow, this, x1, y));
1229 x1 += button->get_w();
1230 add_subwindow(button = new CWindowProjectorCenter(mwindow, this, x1, y));
1231 x1 += button->get_w();
1232 add_subwindow(button = new CWindowProjectorRight(mwindow, this, x1, y));
1234 y += button->get_h();
1236 add_subwindow(button = new CWindowProjectorTop(mwindow, this, x1, y));
1237 x1 += button->get_w();
1238 add_subwindow(button = new CWindowProjectorMiddle(mwindow, this, x1, y));
1239 x1 += button->get_w();
1240 add_subwindow(button = new CWindowProjectorBottom(mwindow, this, x1, y));
1242 // additional Buttons to control the curve mode of the "current" keyframe
1243 x1 += button->get_w() + 15;
1244 add_subwindow(this->t_smooth = new CWindowCurveToggle(Projector_Crv_Smooth, mwindow, this, x1, y));
1245 x1 += button->get_w();
1246 add_subwindow(this->t_linear = new CWindowCurveToggle(Projector_Crv_Linear, mwindow, this, x1, y));
1248 // fill in current auto keyframe values, set toggle states.
1253 void CWindowProjectorGUI::update_preview()
1255 mwindow->gui->lock_window("CWindowProjectorGUI::update_preview");
1256 mwindow->restart_brender();
1257 mwindow->sync_parameters(CHANGE_PARAMS);
1258 mwindow->gui->draw_overlays(1);
1259 mwindow->gui->unlock_window();
1260 mwindow->cwindow->refresh_frame(CHANGE_NONE);
1261 mwindow->cwindow->gui->lock_window("CWindowProjectorGUI::update_preview");
1262 mwindow->cwindow->gui->canvas->draw_refresh();
1263 mwindow->cwindow->gui->unlock_window();
1266 void CWindowProjectorGUI::handle_event()
1268 FloatAuto *x_auto = 0;
1269 FloatAuto *y_auto = 0;
1270 FloatAuto *z_auto = 0;
1271 Track *track = mwindow->cwindow->calculate_affected_track();
1275 mwindow->undo->update_undo_before(_("projector"), this);
1276 if(event_caller == x)
1278 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1279 track->automation->autos[AUTOMATION_PROJECTOR_X],
1283 x_auto->set_value(atof(x->get_text()));
1289 if(event_caller == y)
1291 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1292 track->automation->autos[AUTOMATION_PROJECTOR_Y],
1296 y_auto->set_value(atof(y->get_text()));
1302 if(event_caller == z)
1304 z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1305 track->automation->autos[AUTOMATION_PROJECTOR_Z],
1309 float zoom = atof(z->get_text());
1310 if(zoom > 100.) zoom = 100.;
1311 else if(zoom < 0.01) zoom = 0.01;
1312 // if (zoom != atof(z->get_text()))
1314 z_auto->set_value(zoom);
1316 mwindow->gui->lock_window("CWindowProjectorGUI::handle_event");
1317 mwindow->gui->draw_overlays(1);
1318 mwindow->gui->unlock_window();
1324 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1328 void CWindowProjectorGUI::update()
1330 FloatAuto *x_auto = 0;
1331 FloatAuto *y_auto = 0;
1332 FloatAuto *z_auto = 0;
1333 Track *track = mwindow->cwindow->calculate_affected_track();
1337 mwindow->cwindow->calculate_affected_autos(&x_auto,
1348 x->update(x_auto->get_value());
1350 y->update(y_auto->get_value());
1352 float value = z_auto->get_value();
1354 thread->gui->composite_panel->cpanel_zoom->update(value);
1357 if( x_auto && y_auto && z_auto )
1359 t_smooth->check_toggle_state(x_auto, y_auto, z_auto);
1360 t_linear->check_toggle_state(x_auto, y_auto, z_auto);
1364 CWindowProjectorLeft::CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1365 : BC_Button(x, y, mwindow->theme->get_image_set("left_justify"))
1368 this->mwindow = mwindow;
1369 set_tooltip(_("Left justify"));
1371 int CWindowProjectorLeft::handle_event()
1373 FloatAuto *x_auto = 0;
1374 FloatAuto *z_auto = 0;
1375 Track *track = mwindow->cwindow->calculate_affected_track();
1378 mwindow->cwindow->calculate_affected_autos(&x_auto,
1387 if(x_auto && z_auto)
1389 mwindow->undo->update_undo_before(_("projector"), 0);
1390 x_auto->set_value( (double)track->track_w * z_auto->get_value() / 2 -
1391 (double)mwindow->edl->session->output_w / 2 );
1393 gui->update_preview();
1394 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1401 CWindowProjectorCenter::CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1402 : BC_Button(x, y, mwindow->theme->get_image_set("center_justify"))
1405 this->mwindow = mwindow;
1406 set_tooltip(_("Center horizontal"));
1408 int CWindowProjectorCenter::handle_event()
1410 FloatAuto *x_auto = 0;
1411 Track *track = mwindow->cwindow->calculate_affected_track();
1413 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1414 track->automation->autos[AUTOMATION_PROJECTOR_X],
1419 mwindow->undo->update_undo_before(_("projector"), 0);
1420 x_auto->set_value(0);
1422 gui->update_preview();
1423 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1430 CWindowProjectorRight::CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1431 : BC_Button(x, y, mwindow->theme->get_image_set("right_justify"))
1434 this->mwindow = mwindow;
1435 set_tooltip(_("Right justify"));
1437 int CWindowProjectorRight::handle_event()
1439 FloatAuto *x_auto = 0;
1440 FloatAuto *z_auto = 0;
1441 Track *track = mwindow->cwindow->calculate_affected_track();
1444 mwindow->cwindow->calculate_affected_autos(&x_auto,
1454 if(x_auto && z_auto)
1456 mwindow->undo->update_undo_before(_("projector"), 0);
1457 x_auto->set_value( -((double)track->track_w * z_auto->get_value() / 2 -
1458 (double)mwindow->edl->session->output_w / 2));
1460 gui->update_preview();
1461 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1468 CWindowProjectorTop::CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1469 : BC_Button(x, y, mwindow->theme->get_image_set("top_justify"))
1472 this->mwindow = mwindow;
1473 set_tooltip(_("Top justify"));
1475 int CWindowProjectorTop::handle_event()
1477 FloatAuto *y_auto = 0;
1478 FloatAuto *z_auto = 0;
1479 Track *track = mwindow->cwindow->calculate_affected_track();
1482 mwindow->cwindow->calculate_affected_autos(0,
1492 if(y_auto && z_auto)
1494 mwindow->undo->update_undo_before(_("projector"), 0);
1495 y_auto->set_value( (double)track->track_h * z_auto->get_value() / 2 -
1496 (double)mwindow->edl->session->output_h / 2 );
1498 gui->update_preview();
1499 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1506 CWindowProjectorMiddle::CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1507 : BC_Button(x, y, mwindow->theme->get_image_set("middle_justify"))
1510 this->mwindow = mwindow;
1511 set_tooltip(_("Center vertical"));
1513 int CWindowProjectorMiddle::handle_event()
1515 FloatAuto *y_auto = 0;
1516 Track *track = mwindow->cwindow->calculate_affected_track();
1518 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1519 track->automation->autos[AUTOMATION_PROJECTOR_Y], 1);
1523 mwindow->undo->update_undo_before(_("projector"), 0);
1524 y_auto->set_value(0);
1526 gui->update_preview();
1527 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1534 CWindowProjectorBottom::CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1535 : BC_Button(x, y, mwindow->theme->get_image_set("bottom_justify"))
1538 this->mwindow = mwindow;
1539 set_tooltip(_("Bottom justify"));
1541 int CWindowProjectorBottom::handle_event()
1543 FloatAuto *y_auto = 0;
1544 FloatAuto *z_auto = 0;
1545 Track *track = mwindow->cwindow->calculate_affected_track();
1548 mwindow->cwindow->calculate_affected_autos(0,
1558 if(y_auto && z_auto)
1560 mwindow->undo->update_undo_before(_("projector"), 0);
1561 y_auto->set_value( -((double)track->track_h * z_auto->get_value() / 2 -
1562 (double)mwindow->edl->session->output_h / 2));
1564 gui->update_preview();
1565 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1572 CWindowMaskMode::CWindowMaskMode(MWindow *mwindow,
1573 CWindowToolGUI *gui, int x, int y, const char *text)
1574 : BC_PopupMenu(x, y, 220, text, 1)
1576 this->mwindow = mwindow;
1580 void CWindowMaskMode::create_objects()
1582 add_item(new BC_MenuItem(mode_to_text(MASK_MULTIPLY_ALPHA)));
1583 add_item(new BC_MenuItem(mode_to_text(MASK_SUBTRACT_ALPHA)));
1586 char* CWindowMaskMode::mode_to_text(int mode)
1590 case MASK_MULTIPLY_ALPHA:
1591 return _("Multiply alpha");
1594 case MASK_SUBTRACT_ALPHA:
1595 return _("Subtract alpha");
1599 return _("Subtract alpha");
1602 int CWindowMaskMode::text_to_mode(char *text)
1604 if(!strcasecmp(text, _("Multiply alpha")))
1605 return MASK_MULTIPLY_ALPHA;
1607 if(!strcasecmp(text, _("Subtract alpha")))
1608 return MASK_SUBTRACT_ALPHA;
1610 return MASK_SUBTRACT_ALPHA;
1613 int CWindowMaskMode::handle_event()
1620 // Get existing keyframe
1621 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1624 mwindow->undo->update_undo_before(_("mask mode"), 0);
1625 #ifdef USE_KEYFRAME_SPANNING
1626 // Create temp keyframe
1627 MaskAuto temp_keyframe(mwindow->edl, autos);
1628 temp_keyframe.copy_data(keyframe);
1630 temp_keyframe.mode = text_to_mode(get_text());
1631 // Commit change to span of keyframes
1632 autos->update_parameter(&temp_keyframe);
1634 ((MaskAuto*)autos->default_auto)->mode =
1635 text_to_mode(get_text());
1637 mwindow->undo->update_undo_after(_("mask mode"), LOAD_AUTOMATION);
1640 //printf("CWindowMaskMode::handle_event 1\n");
1641 gui->update_preview();
1652 CWindowMaskDelete::CWindowMaskDelete(MWindow *mwindow,
1653 CWindowToolGUI *gui,
1656 : BC_GenericButton(x, y, _("Delete"))
1658 this->mwindow = mwindow;
1662 int CWindowMaskDelete::handle_event()
1669 int total_points = 0;
1671 // Get existing keyframe
1672 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1676 mwindow->undo->update_undo_before(_("mask delete"), 0);
1678 #ifdef USE_KEYFRAME_SPANNING
1679 // Create temp keyframe
1680 MaskAuto temp_keyframe(mwindow->edl, autos);
1681 temp_keyframe.copy_data(keyframe);
1683 SubMask *submask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
1685 submask->points.remove_all_objects();
1687 for(int i = mwindow->cwindow->gui->affected_point;
1688 i < submask->points.total - 1;
1691 *submask->points.values[i] = *submask->points.values[i + 1];
1694 if(submask->points.total)
1696 submask->points.remove_object(
1697 submask->points.values[submask->points.total - 1]);
1699 total_points = submask->points.total;
1701 // Commit change to span of keyframes
1702 ((MaskAutos*)track->automation->autos[AUTOMATION_MASK])->update_parameter(&temp_keyframe);
1704 for(MaskAuto *current = (MaskAuto*)autos->default_auto;
1707 SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
1709 submask->points.remove_all_objects();
1711 for(int i = mwindow->cwindow->gui->affected_point;
1712 i < submask->points.total - 1;
1715 *submask->points.values[i] = *submask->points.values[i + 1];
1718 if(submask->points.total)
1720 submask->points.remove_object(
1721 submask->points.values[submask->points.total - 1]);
1723 total_points = submask->points.total;
1725 if(current == (MaskAuto*)autos->default_auto)
1726 current = (MaskAuto*)autos->first;
1728 current = (MaskAuto*)NEXT;
1731 if( mwindow->cwindow->gui->affected_point >= total_points )
1732 mwindow->cwindow->gui->affected_point =
1733 total_points > 0 ? total_points-1 : 0;
1736 gui->update_preview();
1737 mwindow->undo->update_undo_after(_("mask delete"), LOAD_AUTOMATION);
1744 int CWindowMaskDelete::keypress_event()
1746 if(get_keypress() == BACKSPACE ||
1747 get_keypress() == DELETE)
1748 return handle_event();
1753 // CWindowMaskCycleNext::CWindowMaskCycleNext(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1754 // : BC_GenericButton(x, y, _("Cycle next"))
1756 // this->mwindow = mwindow;
1759 // int CWindowMaskCycleNext::handle_event()
1761 // MaskAuto *keyframe;
1762 // MaskAutos *autos;
1764 // MaskPoint *point;
1766 // ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1770 // // Should apply to all keyframes
1771 // if(keyframe && mask->points.total)
1773 // temp = mask->points.values[0];
1775 // for(int i = 0; i < mask->points.total - 1; i++)
1777 // mask->points.values[i] = mask->points.values[i + 1];
1779 // mask->points.values[mask->points.total - 1] = temp;
1781 // mwindow->cwindow->gui->affected_point--;
1782 // if(mwindow->cwindow->gui->affected_point < 0)
1783 // mwindow->cwindow->gui->affected_point = mask->points.total - 1;
1786 // gui->update_preview();
1792 // CWindowMaskCyclePrev::CWindowMaskCyclePrev(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1793 // : BC_GenericButton(x, y, _("Cycle prev"))
1795 // this->mwindow = mwindow;
1798 // int CWindowMaskCyclePrev::handle_event()
1800 // MaskAuto *keyframe;
1801 // MaskAutos *autos;
1803 // MaskPoint *point;
1805 // ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1807 // // Should apply to all keyframes
1809 // if(keyframe && mask->points.total)
1811 // temp = mask->points.values[mask->points.total - 1];
1813 // for(int i = mask->points.total - 1; i > 0; i--)
1815 // mask->points.values[i] = mask->points.values[i - 1];
1817 // mask->points.values[0] = temp;
1819 // mwindow->cwindow->gui->affected_point++;
1820 // if(mwindow->cwindow->gui->affected_point >= mask->points.total)
1821 // mwindow->cwindow->gui->affected_point = 0;
1824 // gui->update_preview();
1830 CWindowMaskNumber::CWindowMaskNumber(MWindow *mwindow,
1831 CWindowToolGUI *gui,
1834 : BC_TumbleTextBox(gui,
1835 (int64_t)mwindow->edl->session->cwindow_mask,
1837 (int64_t)SUBMASKS - 1,
1842 this->mwindow = mwindow;
1846 CWindowMaskNumber::~CWindowMaskNumber()
1850 int CWindowMaskNumber::handle_event()
1852 mwindow->edl->session->cwindow_mask = atol(get_text());
1854 gui->update_preview();
1859 CWindowMaskAffectedPoint::CWindowMaskAffectedPoint(MWindow *mwindow,
1860 CWindowToolGUI *gui, int x, int y)
1861 : BC_TumbleTextBox(gui,
1862 (int64_t)mwindow->cwindow->gui->affected_point,
1863 (int64_t)0, INT64_MAX, x, y, 100)
1865 this->mwindow = mwindow;
1869 CWindowMaskAffectedPoint::~CWindowMaskAffectedPoint()
1873 int CWindowMaskAffectedPoint::handle_event()
1875 int total_points = 0;
1876 int affected_point = atol(get_text());
1877 Track *track = mwindow->cwindow->calculate_affected_track();
1879 MaskAutos *autos = (MaskAutos*)track->automation->autos[AUTOMATION_MASK];
1880 MaskAuto *keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(autos, 0);
1882 SubMask *mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
1883 total_points = mask->points.size();
1886 int active_point = affected_point;
1887 if( affected_point >= total_points )
1888 affected_point = total_points - 1;
1889 else if( affected_point < 0 )
1891 if( active_point != affected_point )
1892 update((int64_t)affected_point);
1893 mwindow->cwindow->gui->affected_point = affected_point;
1895 gui->update_preview();
1903 CWindowMaskFeather::CWindowMaskFeather(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1904 : BC_TumbleTextBox(gui,
1912 this->mwindow = mwindow;
1915 CWindowMaskFeather::~CWindowMaskFeather()
1918 int CWindowMaskFeather::handle_event()
1925 #ifdef USE_KEYFRAME_SPANNING
1931 mwindow->undo->update_undo_before(_("mask feather"), this);
1933 // Get existing keyframe
1934 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe,
1935 mask, point, create_it);
1939 #ifdef USE_KEYFRAME_SPANNING
1940 // Create temp keyframe
1941 MaskAuto temp_keyframe(mwindow->edl, autos);
1942 temp_keyframe.copy_data(keyframe);
1944 temp_keyframe.feather = atof(get_text());
1945 // Commit change to span of keyframes
1946 autos->update_parameter(&temp_keyframe);
1948 keyframe->feather = atof(get_text());
1951 gui->update_preview();
1954 mwindow->undo->update_undo_after(_("mask feather"), LOAD_AUTOMATION);
1959 CWindowMaskValue::CWindowMaskValue(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1969 this->mwindow = mwindow;
1973 CWindowMaskValue::~CWindowMaskValue()
1977 int CWindowMaskValue::handle_event()
1984 #ifdef USE_KEYFRAME_SPANNING
1990 mwindow->undo->update_undo_before(_("mask value"), this);
1991 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe,
1992 mask, point, create_it);
1996 #ifdef USE_KEYFRAME_SPANNING
1997 // Create temp keyframe
1998 MaskAuto temp_keyframe(mwindow->edl, autos);
1999 temp_keyframe.copy_data(keyframe);
2001 temp_keyframe.value = get_value();
2002 // Commit change to span of keyframes
2003 autos->update_parameter(&temp_keyframe);
2005 keyframe->value = get_value();
2009 gui->update_preview();
2010 mwindow->undo->update_undo_after(_("mask value"), LOAD_AUTOMATION);
2015 CWindowMaskBeforePlugins::CWindowMaskBeforePlugins(CWindowToolGUI *gui, int x, int y)
2019 _("Apply mask before plugins"))
2024 int CWindowMaskBeforePlugins::handle_event()
2031 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 1);
2034 keyframe->apply_before_plugins = get_value();
2035 gui->update_preview();
2041 CWindowDisableOpenGLMasking::CWindowDisableOpenGLMasking(CWindowToolGUI *gui, int x, int y)
2042 : BC_CheckBox(x, y, 1, _("Disable OpenGL masking"))
2047 int CWindowDisableOpenGLMasking::handle_event()
2054 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 1);
2057 keyframe->disable_opengl_masking = get_value();
2058 gui->update_preview();
2071 CWindowMaskGUI::CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread)
2072 : CWindowToolGUI(mwindow, thread,
2073 _(PROGRAM_NAME ": Mask"), 330, 320)
2075 this->mwindow = mwindow;
2076 this->thread = thread;
2081 CWindowMaskGUI::~CWindowMaskGUI()
2083 lock_window("CWindowMaskGUI::~CWindowMaskGUI");
2085 delete active_point;
2090 void CWindowMaskGUI::create_objects()
2092 int x = 10, y = 10, margin = mwindow->theme->widget_border;
2093 //MaskAuto *keyframe = 0;
2094 //Track *track = mwindow->cwindow->calculate_affected_track();
2096 // keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->autos[AUTOMATION_MASK], 0);
2098 lock_window("CWindowMaskGUI::create_objects");
2100 add_subwindow(title = new BC_Title(x, y, _("Mode:")));
2101 add_subwindow(mode = new CWindowMaskMode(mwindow,
2102 this, x + title->get_w() + margin, y, ""));
2103 mode->create_objects();
2104 y += mode->get_h() + margin;
2105 add_subwindow(title = new BC_Title(x, y, _("Value:")));
2106 add_subwindow(value = new CWindowMaskValue(mwindow, this, x + title->get_w() + margin, y));
2107 y += value->get_h() + margin;
2108 add_subwindow(delete_point = new CWindowMaskDelete(mwindow, this, x, y));
2109 int x1 = x + delete_point->get_w() + 2*margin;
2110 add_subwindow(title = new BC_Title(x1, y, _("Point:")));
2111 x1 += title->get_w() + margin;
2112 active_point = new CWindowMaskAffectedPoint(mwindow, this, x1, y);
2113 active_point->create_objects();
2114 y += delete_point->get_h() + margin;
2115 add_subwindow(title = new BC_Title(x, y, _("Mask number:")));
2116 number = new CWindowMaskNumber(mwindow,
2117 this, x + title->get_w() + margin, y);
2118 number->create_objects();
2119 y += number->get_h() + margin;
2120 add_subwindow(title = new BC_Title(x, y, _("Feather:")));
2121 feather = new CWindowMaskFeather(mwindow,
2122 this, x + title->get_w() + margin, y);
2123 feather->create_objects();
2124 y += feather->get_h() + margin;
2125 add_subwindow(title = new BC_Title(x, y, "X:"));
2126 x += title->get_w() + margin;
2127 this->x = new CWindowCoord(this, x, y, (float)0.0);
2128 this->x->create_objects();
2129 x += this->x->get_w() + margin;
2130 add_subwindow(title = new BC_Title(x, y, "Y:"));
2131 x += title->get_w() + margin;
2132 this->y = new CWindowCoord(this, x, y, (float)0.0);
2133 this->y->create_objects();
2136 y += this->y->get_h() + margin;
2137 add_subwindow(title = new BC_Title(x, y, _("Press Shift to move an end point")));
2138 y += title->get_h() + margin;
2139 add_subwindow(title = new BC_Title(x, y, _("Press Ctrl to move a control point")));
2140 y += title->get_h() + margin;
2141 add_subwindow(title = new BC_Title(x, y, _("Shift+click Delete to delete the mask")));
2142 y += title->get_h() + margin;
2143 add_subwindow(title = new BC_Title(x, y, _("Press Alt to translate the mask")));
2146 add_subwindow(this->apply_before_plugins = new CWindowMaskBeforePlugins(this, 10, y));
2147 y += this->apply_before_plugins->get_h() + margin;
2148 add_subwindow(this->disable_opengl_masking = new CWindowDisableOpenGLMasking(this, 10, y));
2154 void CWindowMaskGUI::get_keyframe(Track* &track,
2156 MaskAuto* &keyframe,
2164 track = mwindow->cwindow->calculate_affected_track();
2167 autos = (MaskAutos*)track->automation->autos[AUTOMATION_MASK];
2168 keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(
2174 mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
2181 if(mwindow->cwindow->gui->affected_point < mask->points.total &&
2182 mwindow->cwindow->gui->affected_point >= 0)
2184 point = mask->points.values[mwindow->cwindow->gui->affected_point];
2189 void CWindowMaskGUI::update()
2196 //printf("CWindowMaskGUI::update 1\n");
2197 get_keyframe(track, autos, keyframe, mask, point, 0);
2199 double position = mwindow->edl->local_session->get_selectionstart(1);
2200 position = mwindow->edl->align_to_frame(position, 0);
2203 int64_t position_i = track->to_units(position, 0);
2207 x->update(point->x);
2208 y->update(point->y);
2213 feather->update((int64_t)autos->get_feather(position_i, PLAY_FORWARD));
2214 value->update((int64_t)autos->get_value(position_i, PLAY_FORWARD));
2215 apply_before_plugins->update((int64_t)keyframe->apply_before_plugins);
2216 disable_opengl_masking->update((int64_t)keyframe->disable_opengl_masking);
2220 //printf("CWindowMaskGUI::update 1\n");
2221 active_point->update((int64_t)mwindow->cwindow->gui->affected_point);
2222 number->update((int64_t)mwindow->edl->session->cwindow_mask);
2224 //printf("CWindowMaskGUI::update 1\n");
2227 #ifdef USE_KEYFRAME_SPANNING
2229 CWindowMaskMode::mode_to_text(keyframe->mode));
2232 CWindowMaskMode::mode_to_text(((MaskAuto*)autos->default_auto)->mode));
2235 //printf("CWindowMaskGUI::update 2\n");
2238 void CWindowMaskGUI::handle_event()
2245 get_keyframe(track, autos, keyframe, mask, point, 0);
2247 mwindow->undo->update_undo_before(_("mask point"), this);
2251 #ifdef USE_KEYFRAME_SPANNING
2252 // Create temp keyframe
2253 MaskAuto temp_keyframe(mwindow->edl, autos);
2254 temp_keyframe.copy_data(keyframe);
2255 // Get affected point in temp keyframe
2256 mask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
2257 if(mwindow->cwindow->gui->affected_point < mask->points.total &&
2258 mwindow->cwindow->gui->affected_point >= 0)
2260 point = mask->points.values[mwindow->cwindow->gui->affected_point];
2265 point->x = atof(x->get_text());
2266 point->y = atof(y->get_text());
2267 // Commit to spanned keyframes
2268 autos->update_parameter(&temp_keyframe);
2271 point->x = atof(x->get_text());
2272 point->y = atof(y->get_text());
2277 mwindow->undo->update_undo_after(_("mask point"), LOAD_AUTOMATION);
2280 void CWindowMaskGUI::update_preview()
2282 mwindow->gui->lock_window("CWindowMaskGUI::update_preview");
2283 mwindow->restart_brender();
2284 mwindow->sync_parameters(CHANGE_PARAMS);
2285 mwindow->gui->draw_overlays(1);
2286 mwindow->gui->unlock_window();
2287 mwindow->cwindow->refresh_frame(CHANGE_NONE);
2288 mwindow->cwindow->gui->lock_window("CWindowMaskGUI::update_preview");
2289 mwindow->cwindow->gui->canvas->draw_refresh();
2290 mwindow->cwindow->gui->unlock_window();
2294 CWindowRulerGUI::CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread)
2295 : CWindowToolGUI(mwindow,
2297 _(PROGRAM_NAME ": Ruler"),
2303 CWindowRulerGUI::~CWindowRulerGUI()
2307 void CWindowRulerGUI::create_objects()
2312 lock_window("CWindowRulerGUI::create_objects");
2313 add_subwindow(title = new BC_Title(x, y, _("Current:")));
2314 add_subwindow(current = new BC_Title(x + title->get_w() + 10, y, ""));
2315 y += title->get_h() + 5;
2317 add_subwindow(title = new BC_Title(x, y, _("Point 1:")));
2318 add_subwindow(point1 = new BC_Title(x + title->get_w() + 10, y, ""));
2319 y += title->get_h() + 5;
2321 add_subwindow(title = new BC_Title(x, y, _("Point 2:")));
2322 add_subwindow(point2 = new BC_Title(x + title->get_w() + 10, y, ""));
2323 y += title->get_h() + 5;
2325 add_subwindow(title = new BC_Title(x, y, _("Distance:")));
2326 add_subwindow(distance = new BC_Title(x + title->get_w() + 10, y, ""));
2327 y += title->get_h() + 5;
2328 add_subwindow(title = new BC_Title(x, y, _("Angle:")));
2329 add_subwindow(angle = new BC_Title(x + title->get_w() + 10, y, ""));
2330 y += title->get_h() + 10;
2331 char string[BCTEXTLEN];
2332 sprintf(string, _("Press Ctrl to lock ruler to the\nnearest 45%c angle."), 0xb0);
2333 add_subwindow(title = new BC_Title(x,
2336 y += title->get_h() + 10;
2337 sprintf(string, _("Press Alt to translate the ruler."));
2338 add_subwindow(title = new BC_Title(x,
2345 void CWindowRulerGUI::update()
2347 double distance_value =
2348 sqrt(SQR(mwindow->edl->session->ruler_x2 - mwindow->edl->session->ruler_x1) +
2349 SQR(mwindow->edl->session->ruler_y2 - mwindow->edl->session->ruler_y1));
2350 double angle_value = atan((mwindow->edl->session->ruler_y2 - mwindow->edl->session->ruler_y1) /
2351 (mwindow->edl->session->ruler_x2 - mwindow->edl->session->ruler_x1)) *
2356 if(EQUIV(distance_value, 0.0))
2366 char string[BCTEXTLEN];
2367 sprintf(string, "%d, %d",
2368 mwindow->session->cwindow_output_x,
2369 mwindow->session->cwindow_output_y);
2370 current->update(string);
2371 sprintf(string, "%.0f, %.0f",
2372 mwindow->edl->session->ruler_x1,
2373 mwindow->edl->session->ruler_y1);
2374 point1->update(string);
2375 sprintf(string, "%.0f, %.0f",
2376 mwindow->edl->session->ruler_x2,
2377 mwindow->edl->session->ruler_y2);
2378 point2->update(string);
2380 sprintf(string, _("%0.01f pixels"), distance_value);
2381 distance->update(string);
2382 sprintf(string, "%0.02f %c", angle_value, 0xb0);
2383 angle->update(string);
2386 void CWindowRulerGUI::handle_event()