4 * Copyright (C) 2008-2014 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "automation.h"
25 #include "condition.h"
27 #include "cplayback.h"
29 #include "cwindowgui.h"
30 #include "cwindowtool.h"
32 #include "edlsession.h"
33 #include "floatauto.h"
34 #include "floatautos.h"
37 #include "localsession.h"
38 #include "mainsession.h"
41 #include "maskautos.h"
44 #include "mwindowgui.h"
47 #include "trackcanvas.h"
48 #include "transportque.h"
51 CWindowTool::CWindowTool(MWindow *mwindow, CWindowGUI *gui)
54 this->mwindow = mwindow;
58 current_tool = CWINDOW_NONE;
60 input_lock = new Condition(0, "CWindowTool::input_lock");
61 output_lock = new Condition(1, "CWindowTool::output_lock");
62 tool_gui_lock = new Mutex("CWindowTool::tool_gui_lock");
65 CWindowTool::~CWindowTool()
76 void CWindowTool::start_tool(int operation)
78 CWindowToolGUI *new_gui = 0;
81 //printf("CWindowTool::start_tool 1\n");
82 if(current_tool != operation)
84 current_tool = operation;
88 new_gui = new CWindowEyedropGUI(mwindow, this);
91 new_gui = new CWindowCropGUI(mwindow, this);
94 new_gui = new CWindowCameraGUI(mwindow, this);
96 case CWINDOW_PROJECTOR:
97 new_gui = new CWindowProjectorGUI(mwindow, this);
100 new_gui = new CWindowMaskGUI(mwindow, this);
103 new_gui = new CWindowRulerGUI(mwindow, this);
111 //printf("CWindowTool::start_tool 1\n");
117 // Wait for previous tool GUI to finish
118 output_lock->lock("CWindowTool::start_tool");
119 this->tool_gui = new_gui;
120 tool_gui->create_objects();
122 if(mwindow->edl->session->tool_window &&
123 mwindow->session->show_cwindow) tool_gui->show_window();
124 tool_gui->lock_window("CWindowTool::start_tool 1");
126 tool_gui->unlock_window();
129 // Signal thread to run next tool GUI
130 input_lock->unlock();
132 //printf("CWindowTool::start_tool 1\n");
137 tool_gui->lock_window("CWindowTool::start_tool");
139 tool_gui->unlock_window();
142 //printf("CWindowTool::start_tool 2\n");
147 void CWindowTool::stop_tool()
151 tool_gui->lock_window("CWindowTool::stop_tool");
152 tool_gui->set_done(0);
153 tool_gui->unlock_window();
157 void CWindowTool::show_tool()
159 if(tool_gui && mwindow->edl->session->tool_window)
161 tool_gui->lock_window("CWindowTool::show_tool");
162 tool_gui->show_window();
163 tool_gui->unlock_window();
167 void CWindowTool::hide_tool()
169 if(tool_gui && mwindow->edl->session->tool_window)
171 tool_gui->lock_window("CWindowTool::show_tool");
172 tool_gui->hide_window();
173 tool_gui->unlock_window();
178 void CWindowTool::run()
182 input_lock->lock("CWindowTool::run");
185 tool_gui->run_window();
186 tool_gui_lock->lock("CWindowTool::run");
189 tool_gui_lock->unlock();
191 output_lock->unlock();
195 void CWindowTool::update_show_window()
199 tool_gui->lock_window("CWindowTool::update_show_window");
201 if(mwindow->edl->session->tool_window)
204 tool_gui->show_window();
207 tool_gui->hide_window();
210 tool_gui->unlock_window();
214 void CWindowTool::raise_window()
218 gui->unlock_window();
219 tool_gui->lock_window("CWindowTool::raise_window");
220 tool_gui->raise_window();
221 tool_gui->unlock_window();
222 gui->lock_window("CWindowTool::raise_window");
226 void CWindowTool::update_values()
228 tool_gui_lock->lock("CWindowTool::update_values");
231 tool_gui->lock_window("CWindowTool::update_values");
234 tool_gui->unlock_window();
236 tool_gui_lock->unlock();
245 CWindowToolGUI::CWindowToolGUI(MWindow *mwindow,
251 mwindow->session->ctool_x,
252 mwindow->session->ctool_y,
261 this->mwindow = mwindow;
262 this->thread = thread;
263 current_operation = 0;
266 CWindowToolGUI::~CWindowToolGUI()
270 int CWindowToolGUI::close_event()
274 mwindow->edl->session->tool_window = 0;
279 thread->gui->lock_window("CWindowToolGUI::close_event");
280 thread->gui->composite_panel->set_operation(mwindow->edl->session->cwindow_operation);
281 thread->gui->flush();
282 thread->gui->unlock_window();
284 lock_window("CWindowToolGUI::close_event");
288 int CWindowToolGUI::keypress_event()
290 if(get_keypress() == 'w' || get_keypress() == 'W')
291 return close_event();
295 int CWindowToolGUI::translation_event()
297 mwindow->session->ctool_x = get_x();
298 mwindow->session->ctool_y = get_y();
307 CWindowCoord::CWindowCoord(CWindowToolGUI *gui, int x, int y, float value, int log_increment = 0)
308 : BC_TumbleTextBox(gui, (float)value, (float)-65536, (float)65536, x, y, 100)
311 set_log_floatincrement(log_increment);
314 CWindowCoord::CWindowCoord(CWindowToolGUI *gui, int x, int y, int value)
315 : BC_TumbleTextBox(gui, (int64_t)value, (int64_t)-65536, (int64_t)65536, x, y, 100)
319 int CWindowCoord::handle_event()
321 gui->event_caller = this;
327 CWindowCropOK::CWindowCropOK(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
328 : BC_GenericButton(x, y, _("Do it"))
330 this->mwindow = mwindow;
333 int CWindowCropOK::handle_event()
335 mwindow->crop_video();
340 int CWindowCropOK::keypress_event()
342 if(get_keypress() == 0xd)
356 CWindowCropGUI::CWindowCropGUI(MWindow *mwindow, CWindowTool *thread)
357 : CWindowToolGUI(mwindow,
359 _(PROGRAM_NAME ": Crop"),
366 CWindowCropGUI::~CWindowCropGUI()
370 void CWindowCropGUI::create_objects()
375 lock_window("CWindowCropGUI::create_objects");
377 int pad = MAX(BC_TextBox::calculate_h(this, MEDIUMFONT, 1, 1),
378 BC_Title::calculate_h(this, "X")) + 5;
379 add_subwindow(title = new BC_Title(x, y, "X1:"));
380 column1 = MAX(column1, title->get_w());
382 add_subwindow(title = new BC_Title(x, y, _("W:")));
383 column1 = MAX(column1, title->get_w());
385 add_subwindow(new CWindowCropOK(mwindow, thread->tool_gui, x, y));
389 x1 = new CWindowCoord(thread->tool_gui, x, y,
390 mwindow->edl->session->crop_x1);
391 x1->create_objects();
393 width = new CWindowCoord(thread->tool_gui, x, y,
394 mwindow->edl->session->crop_x2 - mwindow->edl->session->crop_x1);
395 width->create_objects();
398 x += x1->get_w() + 10;
401 add_subwindow(title = new BC_Title(x, y, "Y1:"));
402 column2 = MAX(column2, title->get_w());
404 add_subwindow(title = new BC_Title(x, y, _("H:")));
405 column2 = MAX(column2, title->get_w());
410 y1 = new CWindowCoord(thread->tool_gui, x, y,
411 mwindow->edl->session->crop_y1);
412 y1->create_objects();
414 height = new CWindowCoord(thread->tool_gui, x, y,
415 mwindow->edl->session->crop_y2 - mwindow->edl->session->crop_y1);
416 height->create_objects();
420 void CWindowCropGUI::handle_event()
423 new_x1 = atol(x1->get_text());
424 new_y1 = atol(y1->get_text());
425 if(new_x1 != mwindow->edl->session->crop_x1)
427 mwindow->edl->session->crop_x2 = new_x1 +
428 mwindow->edl->session->crop_x2 -
429 mwindow->edl->session->crop_x1;
430 mwindow->edl->session->crop_x1 = new_x1;
432 if(new_y1 != mwindow->edl->session->crop_y1)
434 mwindow->edl->session->crop_y2 = new_y1 +
435 mwindow->edl->session->crop_y2 -
436 mwindow->edl->session->crop_y1;
437 mwindow->edl->session->crop_y1 = atol(y1->get_text());
439 mwindow->edl->session->crop_x2 = atol(width->get_text()) +
440 mwindow->edl->session->crop_x1;
441 mwindow->edl->session->crop_y2 = atol(height->get_text()) +
442 mwindow->edl->session->crop_y1;
444 mwindow->cwindow->gui->lock_window("CWindowCropGUI::handle_event");
445 mwindow->cwindow->gui->canvas->draw_refresh();
446 mwindow->cwindow->gui->unlock_window();
449 void CWindowCropGUI::update()
451 x1->update((int64_t)mwindow->edl->session->crop_x1);
452 y1->update((int64_t)mwindow->edl->session->crop_y1);
453 width->update((int64_t)mwindow->edl->session->crop_x2 -
454 mwindow->edl->session->crop_x1);
455 height->update((int64_t)mwindow->edl->session->crop_y2 -
456 mwindow->edl->session->crop_y1);
460 CWindowEyedropGUI::CWindowEyedropGUI(MWindow *mwindow, CWindowTool *thread)
461 : CWindowToolGUI(mwindow,
463 _(PROGRAM_NAME ": Color"),
469 CWindowEyedropGUI::~CWindowEyedropGUI()
473 void CWindowEyedropGUI::create_objects()
475 int margin = mwindow->theme->widget_border;
479 lock_window("CWindowEyedropGUI::create_objects");
480 BC_Title *title1, *title2, *title3, *title4, *title5, *title6, *title7;
481 add_subwindow(title7 = new BC_Title(x, y, _("Radius:")));
482 y += BC_TextBox::calculate_h(this, MEDIUMFONT, 1, 1) + margin;
484 add_subwindow(title1 = new BC_Title(x, y, _("Red:")));
485 y += title1->get_h() + margin;
486 add_subwindow(title2 = new BC_Title(x, y, _("Green:")));
487 y += title2->get_h() + margin;
488 add_subwindow(title3 = new BC_Title(x, y, _("Blue:")));
489 y += title3->get_h() + margin;
491 add_subwindow(title4 = new BC_Title(x, y, "Y:"));
492 y += title4->get_h() + margin;
493 add_subwindow(title5 = new BC_Title(x, y, "U:"));
494 y += title5->get_h() + margin;
495 add_subwindow(title6 = new BC_Title(x, y, "V:"));
498 radius = new CWindowCoord(this, x2, title7->get_y(),
499 mwindow->edl->session->eyedrop_radius);
500 radius->create_objects();
501 radius->set_boundaries((int64_t)0, (int64_t)255);
504 add_subwindow(red = new BC_Title(x2, title1->get_y(), "0"));
505 add_subwindow(green = new BC_Title(x2, title2->get_y(), "0"));
506 add_subwindow(blue = new BC_Title(x2, title3->get_y(), "0"));
508 add_subwindow(this->y = new BC_Title(x2, title4->get_y(), "0"));
509 add_subwindow(this->u = new BC_Title(x2, title5->get_y(), "0"));
510 add_subwindow(this->v = new BC_Title(x2, title6->get_y(), "0"));
512 y = title6->get_y() + this->v->get_h() + margin;
513 add_subwindow(sample = new BC_SubWindow(x, y, 50, 50));
518 void CWindowEyedropGUI::update()
520 radius->update((int64_t)mwindow->edl->session->eyedrop_radius);
522 red->update(mwindow->edl->local_session->red);
523 green->update(mwindow->edl->local_session->green);
524 blue->update(mwindow->edl->local_session->blue);
527 YUV::rgb_to_yuv_f(mwindow->edl->local_session->red,
528 mwindow->edl->local_session->green,
529 mwindow->edl->local_session->blue,
537 int red = (int)(CLIP(mwindow->edl->local_session->red, 0, 1) * 0xff);
538 int green = (int)(CLIP(mwindow->edl->local_session->green, 0, 1) * 0xff);
539 int blue = (int)(CLIP(mwindow->edl->local_session->blue, 0, 1) * 0xff);
540 sample->set_color((red << 16) | (green << 8) | blue);
541 sample->draw_box(0, 0, sample->get_w(), sample->get_h());
542 sample->set_color(BLACK);
543 sample->draw_rectangle(0, 0, sample->get_w(), sample->get_h());
547 void CWindowEyedropGUI::handle_event()
549 int new_radius = atoi(radius->get_text());
550 if(new_radius != mwindow->edl->session->eyedrop_radius)
552 CWindowGUI *gui = mwindow->cwindow->gui;
553 if(gui->eyedrop_visible)
555 gui->lock_window("CWindowEyedropGUI::handle_event");
558 gui->canvas->do_eyedrop(rerender, 0, 1);
561 mwindow->edl->session->eyedrop_radius = new_radius;
563 if(gui->eyedrop_visible)
567 gui->canvas->do_eyedrop(rerender, 0, 1);
568 gui->unlock_window();
575 /* Buttons to control Keyframe-Curve-Mode for Projector or Camera */
577 // Configuration for all possible Keyframe Curve Mode toggles
579 FloatAuto::t_mode mode;
585 const _CVD Camera_Crv_Smooth =
589 _("\"smooth\" Curve on current Camera Keyframes")
591 const _CVD Camera_Crv_Linear =
595 _("\"linear\" Curve on current Camera Keyframes")
597 const _CVD Projector_Crv_Smooth =
601 _("\"smooth\" Curve on current Projector Keyframes")
603 const _CVD Projector_Crv_Linear =
607 _("\"linear\" Curve on current Projector Keyframes")
611 // Implementation Class für Keyframe Curve Mode buttons
613 // This button reflects the state of the "current" keyframe
614 // (the nearest keyframe on the left) for all three automation
615 // lines together. Clicking on this button (re)sets the curve
616 // mode for the three "current" keyframes simultanously, but
617 // never creates a new keyframe.
619 class CWindowCurveToggle : public BC_Toggle
622 CWindowCurveToggle(_CVD mode, MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
623 void check_toggle_state(FloatAuto *x, FloatAuto *y, FloatAuto *z);
632 CWindowCurveToggle::CWindowCurveToggle(_CVD mode, MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
633 : BC_Toggle(x, y, mwindow->theme->get_image_set(mode.icon_id), false),
637 this->mwindow = mwindow;
638 set_tooltip(cfg.tooltip);
641 void CWindowCurveToggle::check_toggle_state(FloatAuto *x, FloatAuto *y, FloatAuto *z)
643 // the toggle state is only set to ON if all
644 // three automation lines have the same curve mode.
645 // For mixed states the toggle stays off.
646 set_value( x->curve_mode == this->cfg.mode &&
647 y->curve_mode == this->cfg.mode &&
648 z->curve_mode == this->cfg.mode
649 ,true // redraw to show new state
653 int CWindowCurveToggle::handle_event()
655 FloatAuto *x=0, *y=0, *z=0;
656 Track *track = mwindow->cwindow->calculate_affected_track();
659 { mwindow->cwindow->calculate_affected_autos(&x, &y, &z,
660 track, cfg.use_camera, 0,0,0); // don't create new keyframe
662 if(x) x->change_curve_mode(cfg.mode);
663 if(y) y->change_curve_mode(cfg.mode);
664 if(z) z->change_curve_mode(cfg.mode);
667 gui->update_preview();
674 CWindowCameraGUI::CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread)
675 : CWindowToolGUI(mwindow,
677 _(PROGRAM_NAME ": Camera"),
682 CWindowCameraGUI::~CWindowCameraGUI()
686 void CWindowCameraGUI::create_objects()
688 int x = 10, y = 10, x1;
689 Track *track = mwindow->cwindow->calculate_affected_track();
690 FloatAuto *x_auto = 0;
691 FloatAuto *y_auto = 0;
692 FloatAuto *z_auto = 0;
696 lock_window("CWindowCameraGUI::create_objects");
699 mwindow->cwindow->calculate_affected_autos(&x_auto,
700 &y_auto, &z_auto, track, 1, 0, 0, 0);
703 add_subwindow(title = new BC_Title(x, y, "X:"));
705 this->x = new CWindowCoord(this, x, y,
706 x_auto ? x_auto->get_value() : (float)0);
707 this->x->create_objects();
712 add_subwindow(title = new BC_Title(x, y, "Y:"));
714 this->y = new CWindowCoord(this, x, y,
715 y_auto ? y_auto->get_value() : (float)0);
716 this->y->create_objects();
719 add_subwindow(title = new BC_Title(x, y, "Z:"));
721 this->z = new CWindowCoord(this, x, y,
722 z_auto ? z_auto->get_value() : (float)1);
723 this->z->create_objects();
724 this->z->set_increment(0.01);
728 add_subwindow(button = new CWindowCameraLeft(mwindow, this, x1, y));
729 x1 += button->get_w();
730 add_subwindow(button = new CWindowCameraCenter(mwindow, this, x1, y));
731 x1 += button->get_w();
732 add_subwindow(button = new CWindowCameraRight(mwindow, this, x1, y));
734 y += button->get_h();
736 add_subwindow(button = new CWindowCameraTop(mwindow, this, x1, y));
737 x1 += button->get_w();
738 add_subwindow(button = new CWindowCameraMiddle(mwindow, this, x1, y));
739 x1 += button->get_w();
740 add_subwindow(button = new CWindowCameraBottom(mwindow, this, x1, y));
741 // additional Buttons to control the curve mode of the "current" keyframe
742 x1 += button->get_w() + 15;
743 add_subwindow(this->t_smooth = new CWindowCurveToggle(Camera_Crv_Smooth, mwindow, this, x1, y));
744 x1 += button->get_w();
745 add_subwindow(this->t_linear = new CWindowCurveToggle(Camera_Crv_Linear, mwindow, this, x1, y));
747 // fill in current auto keyframe values, set toggle states.
752 void CWindowCameraGUI::update_preview()
754 mwindow->restart_brender();
755 mwindow->sync_parameters(CHANGE_PARAMS);
757 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
761 mwindow->gui->lock_window("CWindowCameraGUI::update_preview");
762 mwindow->gui->draw_overlays(1);
763 mwindow->gui->unlock_window();
764 mwindow->cwindow->gui->lock_window("CWindowCameraGUI::update_preview");
765 mwindow->cwindow->gui->canvas->draw_refresh();
766 mwindow->cwindow->gui->unlock_window();
770 void CWindowCameraGUI::handle_event()
772 FloatAuto *x_auto = 0;
773 FloatAuto *y_auto = 0;
774 FloatAuto *z_auto = 0;
775 Track *track = mwindow->cwindow->calculate_affected_track();
778 mwindow->undo->update_undo_before(_("camera"), this);
779 if(event_caller == x)
781 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
782 track->automation->autos[AUTOMATION_CAMERA_X],
786 x_auto->set_value(atof(x->get_text()));
792 if(event_caller == y)
794 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
795 track->automation->autos[AUTOMATION_CAMERA_Y],
799 y_auto->set_value(atof(y->get_text()));
805 if(event_caller == z)
807 z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
808 track->automation->autos[AUTOMATION_CAMERA_Z],
812 float zoom = atof(z->get_text());
813 if(zoom > 10) zoom = 10;
815 if(zoom < 0) zoom = 0;
816 // Doesn't allow user to enter from scratch
817 // if(zoom != atof(z->get_text()))
820 z_auto->set_value(zoom);
821 mwindow->gui->lock_window("CWindowCameraGUI::handle_event");
822 mwindow->gui->draw_overlays(1);
823 mwindow->gui->unlock_window();
829 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
833 void CWindowCameraGUI::update()
835 FloatAuto *x_auto = 0;
836 FloatAuto *y_auto = 0;
837 FloatAuto *z_auto = 0;
838 Track *track = mwindow->cwindow->calculate_affected_track();
842 mwindow->cwindow->calculate_affected_autos(&x_auto,
853 x->update(x_auto->get_value());
855 y->update(y_auto->get_value());
857 z->update(z_auto->get_value());
859 if( x_auto && y_auto && z_auto )
861 t_smooth->check_toggle_state(x_auto, y_auto, z_auto);
862 t_linear->check_toggle_state(x_auto, y_auto, z_auto);
869 CWindowCameraLeft::CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
870 : BC_Button(x, y, mwindow->theme->get_image_set("left_justify"))
873 this->mwindow = mwindow;
874 set_tooltip(_("Left justify"));
876 int CWindowCameraLeft::handle_event()
878 FloatAuto *x_auto = 0;
879 FloatAuto *z_auto = 0;
880 Track *track = mwindow->cwindow->calculate_affected_track();
883 mwindow->cwindow->calculate_affected_autos(&x_auto,
896 track->get_source_dimensions(
897 mwindow->edl->local_session->get_selectionstart(1),
903 mwindow->undo->update_undo_before(_("camera"), 0);
905 (double)track->track_w / z_auto->get_value() / 2 -
907 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
909 gui->update_preview();
917 CWindowCameraCenter::CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
918 : BC_Button(x, y, mwindow->theme->get_image_set("center_justify"))
921 this->mwindow = mwindow;
922 set_tooltip(_("Center horizontal"));
924 int CWindowCameraCenter::handle_event()
926 FloatAuto *x_auto = 0;
927 Track *track = mwindow->cwindow->calculate_affected_track();
929 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
930 track->automation->autos[AUTOMATION_CAMERA_X],
935 mwindow->undo->update_undo_before(_("camera"), 0);
936 x_auto->set_value(0);
938 gui->update_preview();
939 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
946 CWindowCameraRight::CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
947 : BC_Button(x, y, mwindow->theme->get_image_set("right_justify"))
950 this->mwindow = mwindow;
951 set_tooltip(_("Right justify"));
953 int CWindowCameraRight::handle_event()
955 FloatAuto *x_auto = 0;
956 FloatAuto *z_auto = 0;
957 Track *track = mwindow->cwindow->calculate_affected_track();
960 mwindow->cwindow->calculate_affected_autos(&x_auto,
973 track->get_source_dimensions(
974 mwindow->edl->local_session->get_selectionstart(1),
980 mwindow->undo->update_undo_before(_("camera"), 0);
981 x_auto->set_value( -((double)track->track_w / z_auto->get_value() / 2 -
984 gui->update_preview();
985 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
993 CWindowCameraTop::CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
994 : BC_Button(x, y, mwindow->theme->get_image_set("top_justify"))
997 this->mwindow = mwindow;
998 set_tooltip(_("Top justify"));
1000 int CWindowCameraTop::handle_event()
1002 FloatAuto *y_auto = 0;
1003 FloatAuto *z_auto = 0;
1004 Track *track = mwindow->cwindow->calculate_affected_track();
1007 mwindow->cwindow->calculate_affected_autos(0,
1017 if(y_auto && z_auto)
1020 track->get_source_dimensions(
1021 mwindow->edl->local_session->get_selectionstart(1),
1027 mwindow->undo->update_undo_before(_("camera"), 0);
1028 y_auto->set_value((double)track->track_h / z_auto->get_value() / 2 -
1031 gui->update_preview();
1032 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1040 CWindowCameraMiddle::CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1041 : BC_Button(x, y, mwindow->theme->get_image_set("middle_justify"))
1044 this->mwindow = mwindow;
1045 set_tooltip(_("Center vertical"));
1047 int CWindowCameraMiddle::handle_event()
1049 FloatAuto *y_auto = 0;
1050 Track *track = mwindow->cwindow->calculate_affected_track();
1052 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1053 track->automation->autos[AUTOMATION_CAMERA_Y], 1);
1057 mwindow->undo->update_undo_before(_("camera"), 0);
1058 y_auto->set_value(0);
1060 gui->update_preview();
1061 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1068 CWindowCameraBottom::CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1069 : BC_Button(x, y, mwindow->theme->get_image_set("bottom_justify"))
1072 this->mwindow = mwindow;
1073 set_tooltip(_("Bottom justify"));
1075 int CWindowCameraBottom::handle_event()
1077 FloatAuto *y_auto = 0;
1078 FloatAuto *z_auto = 0;
1079 Track *track = mwindow->cwindow->calculate_affected_track();
1082 mwindow->cwindow->calculate_affected_autos(0,
1092 if(y_auto && z_auto)
1095 track->get_source_dimensions(
1096 mwindow->edl->local_session->get_selectionstart(1),
1102 mwindow->undo->update_undo_before(_("camera"), 0);
1103 y_auto->set_value(-((double)track->track_h / z_auto->get_value() / 2 -
1106 gui->update_preview();
1107 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1115 CWindowProjectorGUI::CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread)
1116 : CWindowToolGUI(mwindow,
1118 _(PROGRAM_NAME ": Projector"),
1123 CWindowProjectorGUI::~CWindowProjectorGUI()
1126 void CWindowProjectorGUI::create_objects()
1128 int x = 10, y = 10, x1;
1129 Track *track = mwindow->cwindow->calculate_affected_track();
1130 FloatAuto *x_auto = 0;
1131 FloatAuto *y_auto = 0;
1132 FloatAuto *z_auto = 0;
1136 lock_window("CWindowProjectorGUI::create_objects");
1139 mwindow->cwindow->calculate_affected_autos(&x_auto,
1149 add_subwindow(title = new BC_Title(x, y, "X:"));
1150 x += title->get_w();
1151 this->x = new CWindowCoord(this, x, y,
1152 x_auto ? x_auto->get_value() : (float)0);
1153 this->x->create_objects();
1156 add_subwindow(title = new BC_Title(x, y, "Y:"));
1157 x += title->get_w();
1158 this->y = new CWindowCoord(this, x, y,
1159 y_auto ? y_auto->get_value() : (float)0);
1160 this->y->create_objects();
1163 add_subwindow(title = new BC_Title(x, y, "Z:"));
1164 x += title->get_w();
1165 this->z = new CWindowCoord(this, x, y,
1166 z_auto ? z_auto->get_value() : (float)1);
1167 this->z->create_objects();
1168 this->z->set_increment(0.01);
1172 add_subwindow(button = new CWindowProjectorLeft(mwindow, this, x1, y));
1173 x1 += button->get_w();
1174 add_subwindow(button = new CWindowProjectorCenter(mwindow, this, x1, y));
1175 x1 += button->get_w();
1176 add_subwindow(button = new CWindowProjectorRight(mwindow, this, x1, y));
1178 y += button->get_h();
1180 add_subwindow(button = new CWindowProjectorTop(mwindow, this, x1, y));
1181 x1 += button->get_w();
1182 add_subwindow(button = new CWindowProjectorMiddle(mwindow, this, x1, y));
1183 x1 += button->get_w();
1184 add_subwindow(button = new CWindowProjectorBottom(mwindow, this, x1, y));
1186 // additional Buttons to control the curve mode of the "current" keyframe
1187 x1 += button->get_w() + 15;
1188 add_subwindow(this->t_smooth = new CWindowCurveToggle(Projector_Crv_Smooth, mwindow, this, x1, y));
1189 x1 += button->get_w();
1190 add_subwindow(this->t_linear = new CWindowCurveToggle(Projector_Crv_Linear, mwindow, this, x1, y));
1192 // fill in current auto keyframe values, set toggle states.
1197 void CWindowProjectorGUI::update_preview()
1199 mwindow->restart_brender();
1200 mwindow->sync_parameters(CHANGE_PARAMS);
1201 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1205 // TODO: really need to lock the main window??
1206 mwindow->gui->lock_window("CWindowProjectorGUI::update_preview");
1207 mwindow->gui->draw_overlays(1);
1208 mwindow->gui->unlock_window();
1209 mwindow->cwindow->gui->lock_window("CWindowProjectorGUI::update_preview");
1210 mwindow->cwindow->gui->canvas->draw_refresh();
1211 mwindow->cwindow->gui->unlock_window();
1214 void CWindowProjectorGUI::handle_event()
1216 FloatAuto *x_auto = 0;
1217 FloatAuto *y_auto = 0;
1218 FloatAuto *z_auto = 0;
1219 Track *track = mwindow->cwindow->calculate_affected_track();
1223 mwindow->undo->update_undo_before(_("projector"), this);
1224 if(event_caller == x)
1226 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1227 track->automation->autos[AUTOMATION_PROJECTOR_X],
1231 x_auto->set_value(atof(x->get_text()));
1237 if(event_caller == y)
1239 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1240 track->automation->autos[AUTOMATION_PROJECTOR_Y],
1244 y_auto->set_value(atof(y->get_text()));
1250 if(event_caller == z)
1252 z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1253 track->automation->autos[AUTOMATION_PROJECTOR_Z],
1257 float zoom = atof(z->get_text());
1258 if(zoom > 10000) zoom = 10000;
1260 if(zoom < 0) zoom = 0;
1261 // if (zoom != atof(z->get_text()))
1263 z_auto->set_value(zoom);
1265 mwindow->gui->lock_window("CWindowProjectorGUI::handle_event");
1266 mwindow->gui->draw_overlays(1);
1267 mwindow->gui->unlock_window();
1273 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1277 void CWindowProjectorGUI::update()
1279 FloatAuto *x_auto = 0;
1280 FloatAuto *y_auto = 0;
1281 FloatAuto *z_auto = 0;
1282 Track *track = mwindow->cwindow->calculate_affected_track();
1286 mwindow->cwindow->calculate_affected_autos(&x_auto,
1297 x->update(x_auto->get_value());
1299 y->update(y_auto->get_value());
1301 z->update(z_auto->get_value());
1303 if( x_auto && y_auto && z_auto )
1305 t_smooth->check_toggle_state(x_auto, y_auto, z_auto);
1306 t_linear->check_toggle_state(x_auto, y_auto, z_auto);
1310 CWindowProjectorLeft::CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1311 : BC_Button(x, y, mwindow->theme->get_image_set("left_justify"))
1314 this->mwindow = mwindow;
1315 set_tooltip(_("Left justify"));
1317 int CWindowProjectorLeft::handle_event()
1319 FloatAuto *x_auto = 0;
1320 FloatAuto *z_auto = 0;
1321 Track *track = mwindow->cwindow->calculate_affected_track();
1324 mwindow->cwindow->calculate_affected_autos(&x_auto,
1333 if(x_auto && z_auto)
1335 mwindow->undo->update_undo_before(_("projector"), 0);
1336 x_auto->set_value( (double)track->track_w * z_auto->get_value() / 2 -
1337 (double)mwindow->edl->session->output_w / 2 );
1339 gui->update_preview();
1340 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1347 CWindowProjectorCenter::CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1348 : BC_Button(x, y, mwindow->theme->get_image_set("center_justify"))
1351 this->mwindow = mwindow;
1352 set_tooltip(_("Center horizontal"));
1354 int CWindowProjectorCenter::handle_event()
1356 FloatAuto *x_auto = 0;
1357 Track *track = mwindow->cwindow->calculate_affected_track();
1359 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1360 track->automation->autos[AUTOMATION_PROJECTOR_X],
1365 mwindow->undo->update_undo_before(_("projector"), 0);
1366 x_auto->set_value(0);
1368 gui->update_preview();
1369 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1376 CWindowProjectorRight::CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1377 : BC_Button(x, y, mwindow->theme->get_image_set("right_justify"))
1380 this->mwindow = mwindow;
1381 set_tooltip(_("Right justify"));
1383 int CWindowProjectorRight::handle_event()
1385 FloatAuto *x_auto = 0;
1386 FloatAuto *z_auto = 0;
1387 Track *track = mwindow->cwindow->calculate_affected_track();
1390 mwindow->cwindow->calculate_affected_autos(&x_auto,
1400 if(x_auto && z_auto)
1402 mwindow->undo->update_undo_before(_("projector"), 0);
1403 x_auto->set_value( -((double)track->track_w * z_auto->get_value() / 2 -
1404 (double)mwindow->edl->session->output_w / 2));
1406 gui->update_preview();
1407 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1414 CWindowProjectorTop::CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1415 : BC_Button(x, y, mwindow->theme->get_image_set("top_justify"))
1418 this->mwindow = mwindow;
1419 set_tooltip(_("Top justify"));
1421 int CWindowProjectorTop::handle_event()
1423 FloatAuto *y_auto = 0;
1424 FloatAuto *z_auto = 0;
1425 Track *track = mwindow->cwindow->calculate_affected_track();
1428 mwindow->cwindow->calculate_affected_autos(0,
1438 if(y_auto && z_auto)
1440 mwindow->undo->update_undo_before(_("projector"), 0);
1441 y_auto->set_value( (double)track->track_h * z_auto->get_value() / 2 -
1442 (double)mwindow->edl->session->output_h / 2 );
1444 gui->update_preview();
1445 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1452 CWindowProjectorMiddle::CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1453 : BC_Button(x, y, mwindow->theme->get_image_set("middle_justify"))
1456 this->mwindow = mwindow;
1457 set_tooltip(_("Center vertical"));
1459 int CWindowProjectorMiddle::handle_event()
1461 FloatAuto *y_auto = 0;
1462 Track *track = mwindow->cwindow->calculate_affected_track();
1464 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1465 track->automation->autos[AUTOMATION_PROJECTOR_Y], 1);
1469 mwindow->undo->update_undo_before(_("projector"), 0);
1470 y_auto->set_value(0);
1472 gui->update_preview();
1473 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1480 CWindowProjectorBottom::CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1481 : BC_Button(x, y, mwindow->theme->get_image_set("bottom_justify"))
1484 this->mwindow = mwindow;
1485 set_tooltip(_("Bottom justify"));
1487 int CWindowProjectorBottom::handle_event()
1489 FloatAuto *y_auto = 0;
1490 FloatAuto *z_auto = 0;
1491 Track *track = mwindow->cwindow->calculate_affected_track();
1494 mwindow->cwindow->calculate_affected_autos(0,
1504 if(y_auto && z_auto)
1506 mwindow->undo->update_undo_before(_("projector"), 0);
1507 y_auto->set_value( -((double)track->track_h * z_auto->get_value() / 2 -
1508 (double)mwindow->edl->session->output_h / 2));
1510 gui->update_preview();
1511 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1518 CWindowMaskMode::CWindowMaskMode(MWindow *mwindow,
1519 CWindowToolGUI *gui, int x, int y, const char *text)
1520 : BC_PopupMenu(x, y, 220, text, 1)
1522 this->mwindow = mwindow;
1526 void CWindowMaskMode::create_objects()
1528 add_item(new BC_MenuItem(mode_to_text(MASK_MULTIPLY_ALPHA)));
1529 add_item(new BC_MenuItem(mode_to_text(MASK_SUBTRACT_ALPHA)));
1532 char* CWindowMaskMode::mode_to_text(int mode)
1536 case MASK_MULTIPLY_ALPHA:
1537 return _("Multiply alpha");
1540 case MASK_SUBTRACT_ALPHA:
1541 return _("Subtract alpha");
1545 return _("Subtract alpha");
1548 int CWindowMaskMode::text_to_mode(char *text)
1550 if(!strcasecmp(text, _("Multiply alpha")))
1551 return MASK_MULTIPLY_ALPHA;
1553 if(!strcasecmp(text, _("Subtract alpha")))
1554 return MASK_SUBTRACT_ALPHA;
1556 return MASK_SUBTRACT_ALPHA;
1559 int CWindowMaskMode::handle_event()
1566 // Get existing keyframe
1567 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1570 mwindow->undo->update_undo_before(_("mask mode"), 0);
1571 #ifdef USE_KEYFRAME_SPANNING
1572 // Create temp keyframe
1573 MaskAuto temp_keyframe(mwindow->edl, autos);
1574 temp_keyframe.copy_data(keyframe);
1576 temp_keyframe.mode = text_to_mode(get_text());
1577 // Commit change to span of keyframes
1578 autos->update_parameter(&temp_keyframe);
1580 ((MaskAuto*)autos->default_auto)->mode =
1581 text_to_mode(get_text());
1583 mwindow->undo->update_undo_after(_("mask mode"), LOAD_AUTOMATION);
1586 //printf("CWindowMaskMode::handle_event 1\n");
1587 gui->update_preview();
1598 CWindowMaskDelete::CWindowMaskDelete(MWindow *mwindow,
1599 CWindowToolGUI *gui,
1602 : BC_GenericButton(x, y, _("Delete"))
1604 this->mwindow = mwindow;
1608 int CWindowMaskDelete::handle_event()
1615 int total_points = 0;
1617 // Get existing keyframe
1618 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1622 mwindow->undo->update_undo_before(_("mask delete"), 0);
1624 #ifdef USE_KEYFRAME_SPANNING
1625 // Create temp keyframe
1626 MaskAuto temp_keyframe(mwindow->edl, autos);
1627 temp_keyframe.copy_data(keyframe);
1629 SubMask *submask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
1630 for(int i = mwindow->cwindow->gui->affected_point;
1631 i < submask->points.total - 1;
1634 *submask->points.values[i] = *submask->points.values[i + 1];
1637 if(submask->points.total)
1639 submask->points.remove_object(
1640 submask->points.values[submask->points.total - 1]);
1642 total_points = submask->points.total;
1644 // Commit change to span of keyframes
1645 ((MaskAutos*)track->automation->autos[AUTOMATION_MASK])->update_parameter(&temp_keyframe);
1647 for(MaskAuto *current = (MaskAuto*)autos->default_auto;
1650 SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
1652 for(int i = mwindow->cwindow->gui->affected_point;
1653 i < submask->points.total - 1;
1656 *submask->points.values[i] = *submask->points.values[i + 1];
1659 if(submask->points.total)
1661 submask->points.remove_object(
1662 submask->points.values[submask->points.total - 1]);
1664 total_points = submask->points.total;
1666 if(current == (MaskAuto*)autos->default_auto)
1667 current = (MaskAuto*)autos->first;
1669 current = (MaskAuto*)NEXT;
1672 if( mwindow->cwindow->gui->affected_point >= total_points )
1673 mwindow->cwindow->gui->affected_point =
1674 total_points > 0 ? total_points-1 : 0;
1677 gui->update_preview();
1678 mwindow->undo->update_undo_after(_("mask delete"), LOAD_AUTOMATION);
1685 int CWindowMaskDelete::keypress_event()
1687 if(get_keypress() == BACKSPACE ||
1688 get_keypress() == DELETE)
1689 return handle_event();
1694 // CWindowMaskCycleNext::CWindowMaskCycleNext(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1695 // : BC_GenericButton(x, y, _("Cycle next"))
1697 // this->mwindow = mwindow;
1700 // int CWindowMaskCycleNext::handle_event()
1702 // MaskAuto *keyframe;
1703 // MaskAutos *autos;
1705 // MaskPoint *point;
1707 // ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1711 // // Should apply to all keyframes
1712 // if(keyframe && mask->points.total)
1714 // temp = mask->points.values[0];
1716 // for(int i = 0; i < mask->points.total - 1; i++)
1718 // mask->points.values[i] = mask->points.values[i + 1];
1720 // mask->points.values[mask->points.total - 1] = temp;
1722 // mwindow->cwindow->gui->affected_point--;
1723 // if(mwindow->cwindow->gui->affected_point < 0)
1724 // mwindow->cwindow->gui->affected_point = mask->points.total - 1;
1727 // gui->update_preview();
1733 // CWindowMaskCyclePrev::CWindowMaskCyclePrev(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1734 // : BC_GenericButton(x, y, _("Cycle prev"))
1736 // this->mwindow = mwindow;
1739 // int CWindowMaskCyclePrev::handle_event()
1741 // MaskAuto *keyframe;
1742 // MaskAutos *autos;
1744 // MaskPoint *point;
1746 // ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1748 // // Should apply to all keyframes
1750 // if(keyframe && mask->points.total)
1752 // temp = mask->points.values[mask->points.total - 1];
1754 // for(int i = mask->points.total - 1; i > 0; i--)
1756 // mask->points.values[i] = mask->points.values[i - 1];
1758 // mask->points.values[0] = temp;
1760 // mwindow->cwindow->gui->affected_point++;
1761 // if(mwindow->cwindow->gui->affected_point >= mask->points.total)
1762 // mwindow->cwindow->gui->affected_point = 0;
1765 // gui->update_preview();
1771 CWindowMaskNumber::CWindowMaskNumber(MWindow *mwindow,
1772 CWindowToolGUI *gui,
1775 : BC_TumbleTextBox(gui,
1776 (int64_t)mwindow->edl->session->cwindow_mask,
1778 (int64_t)SUBMASKS - 1,
1783 this->mwindow = mwindow;
1787 CWindowMaskNumber::~CWindowMaskNumber()
1791 int CWindowMaskNumber::handle_event()
1793 mwindow->edl->session->cwindow_mask = atol(get_text());
1795 gui->update_preview();
1800 CWindowMaskAffectedPoint::CWindowMaskAffectedPoint(MWindow *mwindow,
1801 CWindowToolGUI *gui, int x, int y)
1802 : BC_TumbleTextBox(gui,
1803 (int64_t)mwindow->cwindow->gui->affected_point,
1804 (int64_t)0, INT64_MAX, x, y, 100)
1806 this->mwindow = mwindow;
1810 CWindowMaskAffectedPoint::~CWindowMaskAffectedPoint()
1814 int CWindowMaskAffectedPoint::handle_event()
1816 int total_points = 0;
1817 int affected_point = atol(get_text());
1818 Track *track = mwindow->cwindow->calculate_affected_track();
1820 MaskAutos *autos = (MaskAutos*)track->automation->autos[AUTOMATION_MASK];
1821 MaskAuto *keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(autos, 0);
1823 SubMask *mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
1824 total_points = mask->points.size();
1827 int active_point = affected_point;
1828 if( affected_point >= total_points )
1829 affected_point = total_points - 1;
1830 else if( affected_point < 0 )
1832 if( active_point != affected_point )
1833 update((int64_t)affected_point);
1834 mwindow->cwindow->gui->affected_point = affected_point;
1836 gui->update_preview();
1844 CWindowMaskFeather::CWindowMaskFeather(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1845 : BC_TumbleTextBox(gui,
1853 this->mwindow = mwindow;
1856 CWindowMaskFeather::~CWindowMaskFeather()
1859 int CWindowMaskFeather::handle_event()
1866 #ifdef USE_KEYFRAME_SPANNING
1872 mwindow->undo->update_undo_before(_("mask feather"), this);
1874 // Get existing keyframe
1875 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe,
1876 mask, point, create_it);
1880 #ifdef USE_KEYFRAME_SPANNING
1881 // Create temp keyframe
1882 MaskAuto temp_keyframe(mwindow->edl, autos);
1883 temp_keyframe.copy_data(keyframe);
1885 temp_keyframe.feather = atof(get_text());
1886 // Commit change to span of keyframes
1887 autos->update_parameter(&temp_keyframe);
1889 keyframe->feather = atof(get_text());
1892 gui->update_preview();
1895 mwindow->undo->update_undo_after(_("mask feather"), LOAD_AUTOMATION);
1900 CWindowMaskValue::CWindowMaskValue(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1910 this->mwindow = mwindow;
1914 CWindowMaskValue::~CWindowMaskValue()
1918 int CWindowMaskValue::handle_event()
1925 #ifdef USE_KEYFRAME_SPANNING
1931 mwindow->undo->update_undo_before(_("mask value"), this);
1932 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe,
1933 mask, point, create_it);
1937 #ifdef USE_KEYFRAME_SPANNING
1938 // Create temp keyframe
1939 MaskAuto temp_keyframe(mwindow->edl, autos);
1940 temp_keyframe.copy_data(keyframe);
1942 temp_keyframe.value = get_value();
1943 // Commit change to span of keyframes
1944 autos->update_parameter(&temp_keyframe);
1946 keyframe->value = get_value();
1950 gui->update_preview();
1951 mwindow->undo->update_undo_after(_("mask value"), LOAD_AUTOMATION);
1956 CWindowMaskBeforePlugins::CWindowMaskBeforePlugins(CWindowToolGUI *gui, int x, int y)
1960 _("Apply mask before plugins"))
1965 int CWindowMaskBeforePlugins::handle_event()
1972 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 1);
1975 keyframe->apply_before_plugins = get_value();
1976 gui->update_preview();
1982 CWindowDisableOpenGLMasking::CWindowDisableOpenGLMasking(CWindowToolGUI *gui, int x, int y)
1983 : BC_CheckBox(x, y, 1, _("Disable OpenGL masking"))
1988 int CWindowDisableOpenGLMasking::handle_event()
1995 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 1);
1998 keyframe->disable_opengl_masking = get_value();
1999 gui->update_preview();
2012 CWindowMaskGUI::CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread)
2013 : CWindowToolGUI(mwindow,
2015 _(PROGRAM_NAME ": Mask"),
2019 this->mwindow = mwindow;
2020 this->thread = thread;
2025 CWindowMaskGUI::~CWindowMaskGUI()
2027 lock_window("CWindowMaskGUI::~CWindowMaskGUI");
2029 delete active_point;
2034 void CWindowMaskGUI::create_objects()
2036 int x = 10, y = 10, margin = mwindow->theme->widget_border;
2037 //MaskAuto *keyframe = 0;
2038 //Track *track = mwindow->cwindow->calculate_affected_track();
2040 // keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->autos[AUTOMATION_MASK], 0);
2042 lock_window("CWindowMaskGUI::create_objects");
2044 add_subwindow(title = new BC_Title(x, y, _("Mode:")));
2045 add_subwindow(mode = new CWindowMaskMode(mwindow,
2046 this, x + title->get_w() + margin, y, ""));
2047 mode->create_objects();
2048 y += mode->get_h() + margin;
2049 add_subwindow(title = new BC_Title(x, y, _("Value:")));
2050 add_subwindow(value = new CWindowMaskValue(mwindow, this, x + title->get_w() + margin, y));
2051 y += value->get_h() + margin;
2052 add_subwindow(delete_point = new CWindowMaskDelete(mwindow, this, x, y));
2053 int x1 = x + delete_point->get_w() + 2*margin;
2054 add_subwindow(title = new BC_Title(x1, y, _("Point:")));
2055 x1 += title->get_w() + margin;
2056 active_point = new CWindowMaskAffectedPoint(mwindow, this, x1, y);
2057 active_point->create_objects();
2058 y += delete_point->get_h() + margin;
2059 add_subwindow(title = new BC_Title(x, y, _("Mask number:")));
2060 number = new CWindowMaskNumber(mwindow,
2061 this, x + title->get_w() + margin, y);
2062 number->create_objects();
2063 y += number->get_h() + margin;
2064 add_subwindow(title = new BC_Title(x, y, _("Feather:")));
2065 feather = new CWindowMaskFeather(mwindow,
2066 this, x + title->get_w() + margin, y);
2067 feather->create_objects();
2068 y += feather->get_h() + margin;
2069 add_subwindow(title = new BC_Title(x, y, "X:"));
2070 x += title->get_w() + margin;
2071 this->x = new CWindowCoord(this, x, y, (float)0.0);
2072 this->x->create_objects();
2073 x += this->x->get_w() + margin;
2074 add_subwindow(title = new BC_Title(x, y, "Y:"));
2075 x += title->get_w() + margin;
2076 this->y = new CWindowCoord(this, x, y, (float)0.0);
2077 this->y->create_objects();
2080 y += this->y->get_h() + margin;
2081 add_subwindow(title = new BC_Title(x, y, _("Press Shift to move an end point")));
2082 y += title->get_h() + margin;
2083 add_subwindow(title = new BC_Title(x, y, _("Press Ctrl to move a control point")));
2084 y += title->get_h() + margin;
2085 add_subwindow(title = new BC_Title(x, y, _("Press Alt to translate the mask")));
2088 add_subwindow(this->apply_before_plugins = new CWindowMaskBeforePlugins(this, 10, y));
2089 y += this->apply_before_plugins->get_h() + margin;
2090 add_subwindow(this->disable_opengl_masking = new CWindowDisableOpenGLMasking(this, 10, y));
2096 void CWindowMaskGUI::get_keyframe(Track* &track,
2098 MaskAuto* &keyframe,
2106 track = mwindow->cwindow->calculate_affected_track();
2109 autos = (MaskAutos*)track->automation->autos[AUTOMATION_MASK];
2110 keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(
2116 mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
2123 if(mwindow->cwindow->gui->affected_point < mask->points.total &&
2124 mwindow->cwindow->gui->affected_point >= 0)
2126 point = mask->points.values[mwindow->cwindow->gui->affected_point];
2131 void CWindowMaskGUI::update()
2138 //printf("CWindowMaskGUI::update 1\n");
2139 get_keyframe(track, autos, keyframe, mask, point, 0);
2141 double position = mwindow->edl->local_session->get_selectionstart(1);
2142 position = mwindow->edl->align_to_frame(position, 0);
2145 int64_t position_i = track->to_units(position, 0);
2149 x->update(point->x);
2150 y->update(point->y);
2155 feather->update((int64_t)autos->get_feather(position_i, PLAY_FORWARD));
2156 value->update((int64_t)autos->get_value(position_i, PLAY_FORWARD));
2157 apply_before_plugins->update((int64_t)keyframe->apply_before_plugins);
2158 disable_opengl_masking->update((int64_t)keyframe->disable_opengl_masking);
2162 //printf("CWindowMaskGUI::update 1\n");
2163 active_point->update((int64_t)mwindow->cwindow->gui->affected_point);
2164 number->update((int64_t)mwindow->edl->session->cwindow_mask);
2166 //printf("CWindowMaskGUI::update 1\n");
2169 #ifdef USE_KEYFRAME_SPANNING
2171 CWindowMaskMode::mode_to_text(keyframe->mode));
2174 CWindowMaskMode::mode_to_text(((MaskAuto*)autos->default_auto)->mode));
2177 //printf("CWindowMaskGUI::update 2\n");
2180 void CWindowMaskGUI::handle_event()
2187 get_keyframe(track, autos, keyframe, mask, point, 0);
2189 mwindow->undo->update_undo_before(_("mask point"), this);
2193 #ifdef USE_KEYFRAME_SPANNING
2194 // Create temp keyframe
2195 MaskAuto temp_keyframe(mwindow->edl, autos);
2196 temp_keyframe.copy_data(keyframe);
2197 // Get affected point in temp keyframe
2198 mask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
2199 if(mwindow->cwindow->gui->affected_point < mask->points.total &&
2200 mwindow->cwindow->gui->affected_point >= 0)
2202 point = mask->points.values[mwindow->cwindow->gui->affected_point];
2207 point->x = atof(x->get_text());
2208 point->y = atof(y->get_text());
2209 // Commit to spanned keyframes
2210 autos->update_parameter(&temp_keyframe);
2213 point->x = atof(x->get_text());
2214 point->y = atof(y->get_text());
2219 mwindow->undo->update_undo_after(_("mask point"), LOAD_AUTOMATION);
2222 void CWindowMaskGUI::update_preview()
2224 mwindow->restart_brender();
2225 mwindow->sync_parameters(CHANGE_PARAMS);
2226 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
2230 mwindow->cwindow->gui->lock_window("CWindowMaskGUI::update_preview");
2231 mwindow->cwindow->gui->canvas->draw_refresh();
2232 mwindow->cwindow->gui->unlock_window();
2236 CWindowRulerGUI::CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread)
2237 : CWindowToolGUI(mwindow,
2239 _(PROGRAM_NAME ": Ruler"),
2245 CWindowRulerGUI::~CWindowRulerGUI()
2249 void CWindowRulerGUI::create_objects()
2254 lock_window("CWindowRulerGUI::create_objects");
2255 add_subwindow(title = new BC_Title(x, y, _("Current:")));
2256 add_subwindow(current = new BC_Title(x + title->get_w() + 10, y, ""));
2257 y += title->get_h() + 5;
2259 add_subwindow(title = new BC_Title(x, y, _("Point 1:")));
2260 add_subwindow(point1 = new BC_Title(x + title->get_w() + 10, y, ""));
2261 y += title->get_h() + 5;
2263 add_subwindow(title = new BC_Title(x, y, _("Point 2:")));
2264 add_subwindow(point2 = new BC_Title(x + title->get_w() + 10, y, ""));
2265 y += title->get_h() + 5;
2267 add_subwindow(title = new BC_Title(x, y, _("Distance:")));
2268 add_subwindow(distance = new BC_Title(x + title->get_w() + 10, y, ""));
2269 y += title->get_h() + 5;
2270 add_subwindow(title = new BC_Title(x, y, _("Angle:")));
2271 add_subwindow(angle = new BC_Title(x + title->get_w() + 10, y, ""));
2272 y += title->get_h() + 10;
2273 char string[BCTEXTLEN];
2274 sprintf(string, _("Press Ctrl to lock ruler to the\nnearest 45%c angle."), 0xb0);
2275 add_subwindow(title = new BC_Title(x,
2278 y += title->get_h() + 10;
2279 sprintf(string, _("Press Alt to translate the ruler."));
2280 add_subwindow(title = new BC_Title(x,
2287 void CWindowRulerGUI::update()
2289 double distance_value =
2290 sqrt(SQR(mwindow->edl->session->ruler_x2 - mwindow->edl->session->ruler_x1) +
2291 SQR(mwindow->edl->session->ruler_y2 - mwindow->edl->session->ruler_y1));
2292 double angle_value = atan((mwindow->edl->session->ruler_y2 - mwindow->edl->session->ruler_y1) /
2293 (mwindow->edl->session->ruler_x2 - mwindow->edl->session->ruler_x1)) *
2298 if(EQUIV(distance_value, 0.0))
2308 char string[BCTEXTLEN];
2309 sprintf(string, "%d, %d",
2310 mwindow->session->cwindow_output_x,
2311 mwindow->session->cwindow_output_y);
2312 current->update(string);
2313 sprintf(string, "%.0f, %.0f",
2314 mwindow->edl->session->ruler_x1,
2315 mwindow->edl->session->ruler_y1);
2316 point1->update(string);
2317 sprintf(string, "%.0f, %.0f",
2318 mwindow->edl->session->ruler_x2,
2319 mwindow->edl->session->ruler_y2);
2320 point2->update(string);
2322 sprintf(string, _("%0.01f pixels"), distance_value);
2323 distance->update(string);
2324 sprintf(string, "%0.02f %c", angle_value, 0xb0);
2325 angle->update(string);
2328 void CWindowRulerGUI::handle_event()