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);
464 CWindowEyedropGUI::CWindowEyedropGUI(MWindow *mwindow, CWindowTool *thread)
465 : CWindowToolGUI(mwindow,
467 _(PROGRAM_NAME ": Color"),
473 CWindowEyedropGUI::~CWindowEyedropGUI()
477 void CWindowEyedropGUI::create_objects()
479 int margin = mwindow->theme->widget_border;
483 lock_window("CWindowEyedropGUI::create_objects");
484 BC_Title *title1, *title2, *title3, *title4, *title5, *title6, *title7;
485 add_subwindow(title7 = new BC_Title(x, y, _("Radius:")));
486 y += BC_TextBox::calculate_h(this, MEDIUMFONT, 1, 1) + margin;
488 add_subwindow(title1 = new BC_Title(x, y, _("Red:")));
489 y += title1->get_h() + margin;
490 add_subwindow(title2 = new BC_Title(x, y, _("Green:")));
491 y += title2->get_h() + margin;
492 add_subwindow(title3 = new BC_Title(x, y, _("Blue:")));
493 y += title3->get_h() + margin;
495 add_subwindow(title4 = new BC_Title(x, y, "Y:"));
496 y += title4->get_h() + margin;
497 add_subwindow(title5 = new BC_Title(x, y, "U:"));
498 y += title5->get_h() + margin;
499 add_subwindow(title6 = new BC_Title(x, y, "V:"));
502 radius = new CWindowCoord(this, x2, title7->get_y(),
503 mwindow->edl->session->eyedrop_radius);
504 radius->create_objects();
505 radius->set_boundaries((int64_t)0, (int64_t)255);
508 add_subwindow(red = new BC_Title(x2, title1->get_y(), "0"));
509 add_subwindow(green = new BC_Title(x2, title2->get_y(), "0"));
510 add_subwindow(blue = new BC_Title(x2, title3->get_y(), "0"));
512 add_subwindow(this->y = new BC_Title(x2, title4->get_y(), "0"));
513 add_subwindow(this->u = new BC_Title(x2, title5->get_y(), "0"));
514 add_subwindow(this->v = new BC_Title(x2, title6->get_y(), "0"));
516 y = title6->get_y() + this->v->get_h() + margin;
517 add_subwindow(sample = new BC_SubWindow(x, y, 50, 50));
522 void CWindowEyedropGUI::update()
524 radius->update((int64_t)mwindow->edl->session->eyedrop_radius);
526 red->update(mwindow->edl->local_session->red);
527 green->update(mwindow->edl->local_session->green);
528 blue->update(mwindow->edl->local_session->blue);
531 YUV::rgb_to_yuv_f(mwindow->edl->local_session->red,
532 mwindow->edl->local_session->green,
533 mwindow->edl->local_session->blue,
541 int red = (int)(CLIP(mwindow->edl->local_session->red, 0, 1) * 0xff);
542 int green = (int)(CLIP(mwindow->edl->local_session->green, 0, 1) * 0xff);
543 int blue = (int)(CLIP(mwindow->edl->local_session->blue, 0, 1) * 0xff);
544 sample->set_color((red << 16) | (green << 8) | blue);
545 sample->draw_box(0, 0, sample->get_w(), sample->get_h());
546 sample->set_color(BLACK);
547 sample->draw_rectangle(0, 0, sample->get_w(), sample->get_h());
551 void CWindowEyedropGUI::handle_event()
553 int new_radius = atoi(radius->get_text());
554 if(new_radius != mwindow->edl->session->eyedrop_radius)
556 CWindowGUI *gui = mwindow->cwindow->gui;
557 if(gui->eyedrop_visible)
559 gui->lock_window("CWindowEyedropGUI::handle_event");
562 gui->canvas->do_eyedrop(rerender, 0, 1);
565 mwindow->edl->session->eyedrop_radius = new_radius;
567 if(gui->eyedrop_visible)
571 gui->canvas->do_eyedrop(rerender, 0, 1);
572 gui->unlock_window();
579 /* Buttons to control Keyframe-Curve-Mode for Projector or Camera */
581 // Configuration for all possible Keyframe Curve Mode toggles
583 FloatAuto::t_mode mode;
589 const _CVD Camera_Crv_Smooth =
593 _("\"smooth\" Curve on current Camera Keyframes")
595 const _CVD Camera_Crv_Linear =
599 _("\"linear\" Curve on current Camera Keyframes")
601 const _CVD Projector_Crv_Smooth =
605 _("\"smooth\" Curve on current Projector Keyframes")
607 const _CVD Projector_Crv_Linear =
611 _("\"linear\" Curve on current Projector Keyframes")
615 // Implementation Class für Keyframe Curve Mode buttons
617 // This button reflects the state of the "current" keyframe
618 // (the nearest keyframe on the left) for all three automation
619 // lines together. Clicking on this button (re)sets the curve
620 // mode for the three "current" keyframes simultanously, but
621 // never creates a new keyframe.
623 class CWindowCurveToggle : public BC_Toggle
626 CWindowCurveToggle(_CVD mode, MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
627 void check_toggle_state(FloatAuto *x, FloatAuto *y, FloatAuto *z);
636 CWindowCurveToggle::CWindowCurveToggle(_CVD mode, MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
637 : BC_Toggle(x, y, mwindow->theme->get_image_set(mode.icon_id), false),
641 this->mwindow = mwindow;
642 set_tooltip(cfg.tooltip);
645 void CWindowCurveToggle::check_toggle_state(FloatAuto *x, FloatAuto *y, FloatAuto *z)
647 // the toggle state is only set to ON if all
648 // three automation lines have the same curve mode.
649 // For mixed states the toggle stays off.
650 set_value( x->curve_mode == this->cfg.mode &&
651 y->curve_mode == this->cfg.mode &&
652 z->curve_mode == this->cfg.mode
653 ,true // redraw to show new state
657 int CWindowCurveToggle::handle_event()
659 FloatAuto *x=0, *y=0, *z=0;
660 Track *track = mwindow->cwindow->calculate_affected_track();
663 { mwindow->cwindow->calculate_affected_autos(&x, &y, &z,
664 track, cfg.use_camera, 0,0,0); // don't create new keyframe
666 if(x) x->change_curve_mode(cfg.mode);
667 if(y) y->change_curve_mode(cfg.mode);
668 if(z) z->change_curve_mode(cfg.mode);
671 gui->update_preview();
682 CWindowCameraGUI::CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread)
683 : CWindowToolGUI(mwindow,
685 _(PROGRAM_NAME ": Camera"),
690 CWindowCameraGUI::~CWindowCameraGUI()
694 void CWindowCameraGUI::create_objects()
696 int x = 10, y = 10, x1;
697 Track *track = mwindow->cwindow->calculate_affected_track();
698 FloatAuto *x_auto = 0;
699 FloatAuto *y_auto = 0;
700 FloatAuto *z_auto = 0;
704 lock_window("CWindowCameraGUI::create_objects");
707 mwindow->cwindow->calculate_affected_autos(&x_auto,
708 &y_auto, &z_auto, track, 1, 0, 0, 0);
711 add_subwindow(title = new BC_Title(x, y, "X:"));
713 this->x = new CWindowCoord(this, x, y,
714 x_auto ? x_auto->get_value() : (float)0);
715 this->x->create_objects();
720 add_subwindow(title = new BC_Title(x, y, "Y:"));
722 this->y = new CWindowCoord(this, x, y,
723 y_auto ? y_auto->get_value() : (float)0);
724 this->y->create_objects();
727 add_subwindow(title = new BC_Title(x, y, "Z:"));
729 this->z = new CWindowCoord(this, x, y,
730 z_auto ? z_auto->get_value() : (float)1);
731 this->z->create_objects();
732 this->z->set_increment(0.01);
736 add_subwindow(button = new CWindowCameraLeft(mwindow, this, x1, y));
737 x1 += button->get_w();
738 add_subwindow(button = new CWindowCameraCenter(mwindow, this, x1, y));
739 x1 += button->get_w();
740 add_subwindow(button = new CWindowCameraRight(mwindow, this, x1, y));
742 y += button->get_h();
744 add_subwindow(button = new CWindowCameraTop(mwindow, this, x1, y));
745 x1 += button->get_w();
746 add_subwindow(button = new CWindowCameraMiddle(mwindow, this, x1, y));
747 x1 += button->get_w();
748 add_subwindow(button = new CWindowCameraBottom(mwindow, this, x1, y));
749 // additional Buttons to control the curve mode of the "current" keyframe
750 x1 += button->get_w() + 15;
751 add_subwindow(this->t_smooth = new CWindowCurveToggle(Camera_Crv_Smooth, mwindow, this, x1, y));
752 x1 += button->get_w();
753 add_subwindow(this->t_linear = new CWindowCurveToggle(Camera_Crv_Linear, mwindow, this, x1, y));
755 // fill in current auto keyframe values, set toggle states.
760 void CWindowCameraGUI::update_preview()
762 mwindow->restart_brender();
763 mwindow->sync_parameters(CHANGE_PARAMS);
765 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
769 mwindow->gui->lock_window("CWindowCameraGUI::update_preview");
770 mwindow->gui->draw_overlays(1);
771 mwindow->gui->unlock_window();
772 mwindow->cwindow->gui->lock_window("CWindowCameraGUI::update_preview");
773 mwindow->cwindow->gui->canvas->draw_refresh();
774 mwindow->cwindow->gui->unlock_window();
778 void CWindowCameraGUI::handle_event()
780 FloatAuto *x_auto = 0;
781 FloatAuto *y_auto = 0;
782 FloatAuto *z_auto = 0;
783 Track *track = mwindow->cwindow->calculate_affected_track();
786 mwindow->undo->update_undo_before(_("camera"), this);
787 if(event_caller == x)
789 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
790 track->automation->autos[AUTOMATION_CAMERA_X],
794 x_auto->set_value(atof(x->get_text()));
800 if(event_caller == y)
802 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
803 track->automation->autos[AUTOMATION_CAMERA_Y],
807 y_auto->set_value(atof(y->get_text()));
813 if(event_caller == z)
815 z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
816 track->automation->autos[AUTOMATION_CAMERA_Z],
820 float zoom = atof(z->get_text());
821 if(zoom > 10) zoom = 10;
823 if(zoom < 0) zoom = 0;
824 // Doesn't allow user to enter from scratch
825 // if(zoom != atof(z->get_text()))
828 z_auto->set_value(zoom);
829 mwindow->gui->lock_window("CWindowCameraGUI::handle_event");
830 mwindow->gui->draw_overlays(1);
831 mwindow->gui->unlock_window();
837 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
841 void CWindowCameraGUI::update()
843 FloatAuto *x_auto = 0;
844 FloatAuto *y_auto = 0;
845 FloatAuto *z_auto = 0;
846 Track *track = mwindow->cwindow->calculate_affected_track();
850 mwindow->cwindow->calculate_affected_autos(&x_auto,
861 x->update(x_auto->get_value());
863 y->update(y_auto->get_value());
865 z->update(z_auto->get_value());
867 if( x_auto && y_auto && z_auto )
869 t_smooth->check_toggle_state(x_auto, y_auto, z_auto);
870 t_linear->check_toggle_state(x_auto, y_auto, z_auto);
877 CWindowCameraLeft::CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
878 : BC_Button(x, y, mwindow->theme->get_image_set("left_justify"))
881 this->mwindow = mwindow;
882 set_tooltip(_("Left justify"));
884 int CWindowCameraLeft::handle_event()
886 FloatAuto *x_auto = 0;
887 FloatAuto *z_auto = 0;
888 Track *track = mwindow->cwindow->calculate_affected_track();
891 mwindow->cwindow->calculate_affected_autos(&x_auto,
904 track->get_source_dimensions(
905 mwindow->edl->local_session->get_selectionstart(1),
911 mwindow->undo->update_undo_before(_("camera"), 0);
913 (double)track->track_w / z_auto->get_value() / 2 -
915 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
917 gui->update_preview();
925 CWindowCameraCenter::CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
926 : BC_Button(x, y, mwindow->theme->get_image_set("center_justify"))
929 this->mwindow = mwindow;
930 set_tooltip(_("Center horizontal"));
932 int CWindowCameraCenter::handle_event()
934 FloatAuto *x_auto = 0;
935 Track *track = mwindow->cwindow->calculate_affected_track();
937 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
938 track->automation->autos[AUTOMATION_CAMERA_X],
943 mwindow->undo->update_undo_before(_("camera"), 0);
944 x_auto->set_value(0);
946 gui->update_preview();
947 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
954 CWindowCameraRight::CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
955 : BC_Button(x, y, mwindow->theme->get_image_set("right_justify"))
958 this->mwindow = mwindow;
959 set_tooltip(_("Right justify"));
961 int CWindowCameraRight::handle_event()
963 FloatAuto *x_auto = 0;
964 FloatAuto *z_auto = 0;
965 Track *track = mwindow->cwindow->calculate_affected_track();
968 mwindow->cwindow->calculate_affected_autos(&x_auto,
981 track->get_source_dimensions(
982 mwindow->edl->local_session->get_selectionstart(1),
988 mwindow->undo->update_undo_before(_("camera"), 0);
989 x_auto->set_value( -((double)track->track_w / z_auto->get_value() / 2 -
992 gui->update_preview();
993 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1001 CWindowCameraTop::CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1002 : BC_Button(x, y, mwindow->theme->get_image_set("top_justify"))
1005 this->mwindow = mwindow;
1006 set_tooltip(_("Top justify"));
1008 int CWindowCameraTop::handle_event()
1010 FloatAuto *y_auto = 0;
1011 FloatAuto *z_auto = 0;
1012 Track *track = mwindow->cwindow->calculate_affected_track();
1015 mwindow->cwindow->calculate_affected_autos(0,
1025 if(y_auto && z_auto)
1028 track->get_source_dimensions(
1029 mwindow->edl->local_session->get_selectionstart(1),
1035 mwindow->undo->update_undo_before(_("camera"), 0);
1036 y_auto->set_value((double)track->track_h / z_auto->get_value() / 2 -
1039 gui->update_preview();
1040 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1048 CWindowCameraMiddle::CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1049 : BC_Button(x, y, mwindow->theme->get_image_set("middle_justify"))
1052 this->mwindow = mwindow;
1053 set_tooltip(_("Center vertical"));
1055 int CWindowCameraMiddle::handle_event()
1057 FloatAuto *y_auto = 0;
1058 Track *track = mwindow->cwindow->calculate_affected_track();
1060 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1061 track->automation->autos[AUTOMATION_CAMERA_Y], 1);
1065 mwindow->undo->update_undo_before(_("camera"), 0);
1066 y_auto->set_value(0);
1068 gui->update_preview();
1069 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1076 CWindowCameraBottom::CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1077 : BC_Button(x, y, mwindow->theme->get_image_set("bottom_justify"))
1080 this->mwindow = mwindow;
1081 set_tooltip(_("Bottom justify"));
1083 int CWindowCameraBottom::handle_event()
1085 FloatAuto *y_auto = 0;
1086 FloatAuto *z_auto = 0;
1087 Track *track = mwindow->cwindow->calculate_affected_track();
1090 mwindow->cwindow->calculate_affected_autos(0,
1100 if(y_auto && z_auto)
1103 track->get_source_dimensions(
1104 mwindow->edl->local_session->get_selectionstart(1),
1110 mwindow->undo->update_undo_before(_("camera"), 0);
1111 y_auto->set_value(-((double)track->track_h / z_auto->get_value() / 2 -
1114 gui->update_preview();
1115 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1138 CWindowProjectorGUI::CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread)
1139 : CWindowToolGUI(mwindow,
1141 _(PROGRAM_NAME ": Projector"),
1146 CWindowProjectorGUI::~CWindowProjectorGUI()
1149 void CWindowProjectorGUI::create_objects()
1151 int x = 10, y = 10, x1;
1152 Track *track = mwindow->cwindow->calculate_affected_track();
1153 FloatAuto *x_auto = 0;
1154 FloatAuto *y_auto = 0;
1155 FloatAuto *z_auto = 0;
1159 lock_window("CWindowProjectorGUI::create_objects");
1162 mwindow->cwindow->calculate_affected_autos(&x_auto,
1172 add_subwindow(title = new BC_Title(x, y, "X:"));
1173 x += title->get_w();
1174 this->x = new CWindowCoord(this, x, y,
1175 x_auto ? x_auto->get_value() : (float)0);
1176 this->x->create_objects();
1179 add_subwindow(title = new BC_Title(x, y, "Y:"));
1180 x += title->get_w();
1181 this->y = new CWindowCoord(this, x, y,
1182 y_auto ? y_auto->get_value() : (float)0);
1183 this->y->create_objects();
1186 add_subwindow(title = new BC_Title(x, y, "Z:"));
1187 x += title->get_w();
1188 this->z = new CWindowCoord(this, x, y,
1189 z_auto ? z_auto->get_value() : (float)1);
1190 this->z->create_objects();
1191 this->z->set_increment(0.01);
1195 add_subwindow(button = new CWindowProjectorLeft(mwindow, this, x1, y));
1196 x1 += button->get_w();
1197 add_subwindow(button = new CWindowProjectorCenter(mwindow, this, x1, y));
1198 x1 += button->get_w();
1199 add_subwindow(button = new CWindowProjectorRight(mwindow, this, x1, y));
1201 y += button->get_h();
1203 add_subwindow(button = new CWindowProjectorTop(mwindow, this, x1, y));
1204 x1 += button->get_w();
1205 add_subwindow(button = new CWindowProjectorMiddle(mwindow, this, x1, y));
1206 x1 += button->get_w();
1207 add_subwindow(button = new CWindowProjectorBottom(mwindow, this, x1, y));
1209 // additional Buttons to control the curve mode of the "current" keyframe
1210 x1 += button->get_w() + 15;
1211 add_subwindow(this->t_smooth = new CWindowCurveToggle(Projector_Crv_Smooth, mwindow, this, x1, y));
1212 x1 += button->get_w();
1213 add_subwindow(this->t_linear = new CWindowCurveToggle(Projector_Crv_Linear, mwindow, this, x1, y));
1215 // fill in current auto keyframe values, set toggle states.
1220 void CWindowProjectorGUI::update_preview()
1222 mwindow->restart_brender();
1223 mwindow->sync_parameters(CHANGE_PARAMS);
1224 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1228 // TODO: really need to lock the main window??
1229 mwindow->gui->lock_window("CWindowProjectorGUI::update_preview");
1230 mwindow->gui->draw_overlays(1);
1231 mwindow->gui->unlock_window();
1232 mwindow->cwindow->gui->lock_window("CWindowProjectorGUI::update_preview");
1233 mwindow->cwindow->gui->canvas->draw_refresh();
1234 mwindow->cwindow->gui->unlock_window();
1237 void CWindowProjectorGUI::handle_event()
1239 FloatAuto *x_auto = 0;
1240 FloatAuto *y_auto = 0;
1241 FloatAuto *z_auto = 0;
1242 Track *track = mwindow->cwindow->calculate_affected_track();
1246 mwindow->undo->update_undo_before(_("projector"), this);
1247 if(event_caller == x)
1249 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1250 track->automation->autos[AUTOMATION_PROJECTOR_X],
1254 x_auto->set_value(atof(x->get_text()));
1260 if(event_caller == y)
1262 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1263 track->automation->autos[AUTOMATION_PROJECTOR_Y],
1267 y_auto->set_value(atof(y->get_text()));
1273 if(event_caller == z)
1275 z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1276 track->automation->autos[AUTOMATION_PROJECTOR_Z],
1280 float zoom = atof(z->get_text());
1281 if(zoom > 10000) zoom = 10000;
1283 if(zoom < 0) zoom = 0;
1284 // if (zoom != atof(z->get_text()))
1286 z_auto->set_value(zoom);
1288 mwindow->gui->lock_window("CWindowProjectorGUI::handle_event");
1289 mwindow->gui->draw_overlays(1);
1290 mwindow->gui->unlock_window();
1296 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1300 void CWindowProjectorGUI::update()
1302 FloatAuto *x_auto = 0;
1303 FloatAuto *y_auto = 0;
1304 FloatAuto *z_auto = 0;
1305 Track *track = mwindow->cwindow->calculate_affected_track();
1309 mwindow->cwindow->calculate_affected_autos(&x_auto,
1320 x->update(x_auto->get_value());
1322 y->update(y_auto->get_value());
1324 z->update(z_auto->get_value());
1326 if( x_auto && y_auto && z_auto )
1328 t_smooth->check_toggle_state(x_auto, y_auto, z_auto);
1329 t_linear->check_toggle_state(x_auto, y_auto, z_auto);
1371 CWindowProjectorLeft::CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1372 : BC_Button(x, y, mwindow->theme->get_image_set("left_justify"))
1375 this->mwindow = mwindow;
1376 set_tooltip(_("Left justify"));
1378 int CWindowProjectorLeft::handle_event()
1380 FloatAuto *x_auto = 0;
1381 FloatAuto *z_auto = 0;
1382 Track *track = mwindow->cwindow->calculate_affected_track();
1385 mwindow->cwindow->calculate_affected_autos(&x_auto,
1394 if(x_auto && z_auto)
1396 mwindow->undo->update_undo_before(_("projector"), 0);
1397 x_auto->set_value( (double)track->track_w * z_auto->get_value() / 2 -
1398 (double)mwindow->edl->session->output_w / 2 );
1400 gui->update_preview();
1401 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1408 CWindowProjectorCenter::CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1409 : BC_Button(x, y, mwindow->theme->get_image_set("center_justify"))
1412 this->mwindow = mwindow;
1413 set_tooltip(_("Center horizontal"));
1415 int CWindowProjectorCenter::handle_event()
1417 FloatAuto *x_auto = 0;
1418 Track *track = mwindow->cwindow->calculate_affected_track();
1420 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1421 track->automation->autos[AUTOMATION_PROJECTOR_X],
1426 mwindow->undo->update_undo_before(_("projector"), 0);
1427 x_auto->set_value(0);
1429 gui->update_preview();
1430 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1437 CWindowProjectorRight::CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1438 : BC_Button(x, y, mwindow->theme->get_image_set("right_justify"))
1441 this->mwindow = mwindow;
1442 set_tooltip(_("Right justify"));
1444 int CWindowProjectorRight::handle_event()
1446 FloatAuto *x_auto = 0;
1447 FloatAuto *z_auto = 0;
1448 Track *track = mwindow->cwindow->calculate_affected_track();
1451 mwindow->cwindow->calculate_affected_autos(&x_auto,
1461 if(x_auto && z_auto)
1463 mwindow->undo->update_undo_before(_("projector"), 0);
1464 x_auto->set_value( -((double)track->track_w * z_auto->get_value() / 2 -
1465 (double)mwindow->edl->session->output_w / 2));
1467 gui->update_preview();
1468 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1475 CWindowProjectorTop::CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1476 : BC_Button(x, y, mwindow->theme->get_image_set("top_justify"))
1479 this->mwindow = mwindow;
1480 set_tooltip(_("Top justify"));
1482 int CWindowProjectorTop::handle_event()
1484 FloatAuto *y_auto = 0;
1485 FloatAuto *z_auto = 0;
1486 Track *track = mwindow->cwindow->calculate_affected_track();
1489 mwindow->cwindow->calculate_affected_autos(0,
1499 if(y_auto && z_auto)
1501 mwindow->undo->update_undo_before(_("projector"), 0);
1502 y_auto->set_value( (double)track->track_h * z_auto->get_value() / 2 -
1503 (double)mwindow->edl->session->output_h / 2 );
1505 gui->update_preview();
1506 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1513 CWindowProjectorMiddle::CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1514 : BC_Button(x, y, mwindow->theme->get_image_set("middle_justify"))
1517 this->mwindow = mwindow;
1518 set_tooltip(_("Center vertical"));
1520 int CWindowProjectorMiddle::handle_event()
1522 FloatAuto *y_auto = 0;
1523 Track *track = mwindow->cwindow->calculate_affected_track();
1525 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1526 track->automation->autos[AUTOMATION_PROJECTOR_Y], 1);
1530 mwindow->undo->update_undo_before(_("projector"), 0);
1531 y_auto->set_value(0);
1533 gui->update_preview();
1534 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1541 CWindowProjectorBottom::CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1542 : BC_Button(x, y, mwindow->theme->get_image_set("bottom_justify"))
1545 this->mwindow = mwindow;
1546 set_tooltip(_("Bottom justify"));
1548 int CWindowProjectorBottom::handle_event()
1550 FloatAuto *y_auto = 0;
1551 FloatAuto *z_auto = 0;
1552 Track *track = mwindow->cwindow->calculate_affected_track();
1555 mwindow->cwindow->calculate_affected_autos(0,
1565 if(y_auto && z_auto)
1567 mwindow->undo->update_undo_before(_("projector"), 0);
1568 y_auto->set_value( -((double)track->track_h * z_auto->get_value() / 2 -
1569 (double)mwindow->edl->session->output_h / 2));
1571 gui->update_preview();
1572 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1585 CWindowMaskMode::CWindowMaskMode(MWindow *mwindow,
1586 CWindowToolGUI *gui, int x, int y, const char *text)
1587 : BC_PopupMenu(x, y, 220, text, 1)
1589 this->mwindow = mwindow;
1593 void CWindowMaskMode::create_objects()
1595 add_item(new BC_MenuItem(mode_to_text(MASK_MULTIPLY_ALPHA)));
1596 add_item(new BC_MenuItem(mode_to_text(MASK_SUBTRACT_ALPHA)));
1599 char* CWindowMaskMode::mode_to_text(int mode)
1603 case MASK_MULTIPLY_ALPHA:
1604 return _("Multiply alpha");
1607 case MASK_SUBTRACT_ALPHA:
1608 return _("Subtract alpha");
1612 return _("Subtract alpha");
1615 int CWindowMaskMode::text_to_mode(char *text)
1617 if(!strcasecmp(text, _("Multiply alpha")))
1618 return MASK_MULTIPLY_ALPHA;
1620 if(!strcasecmp(text, _("Subtract alpha")))
1621 return MASK_SUBTRACT_ALPHA;
1623 return MASK_SUBTRACT_ALPHA;
1626 int CWindowMaskMode::handle_event()
1633 // Get existing keyframe
1634 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1637 mwindow->undo->update_undo_before(_("mask mode"), 0);
1638 #ifdef USE_KEYFRAME_SPANNING
1639 // Create temp keyframe
1640 MaskAuto temp_keyframe(mwindow->edl, autos);
1641 temp_keyframe.copy_data(keyframe);
1643 temp_keyframe.mode = text_to_mode(get_text());
1644 // Commit change to span of keyframes
1645 autos->update_parameter(&temp_keyframe);
1647 ((MaskAuto*)autos->default_auto)->mode =
1648 text_to_mode(get_text());
1650 mwindow->undo->update_undo_after(_("mask mode"), LOAD_AUTOMATION);
1653 //printf("CWindowMaskMode::handle_event 1\n");
1654 gui->update_preview();
1665 CWindowMaskDelete::CWindowMaskDelete(MWindow *mwindow,
1666 CWindowToolGUI *gui,
1669 : BC_GenericButton(x, y, _("Delete"))
1671 this->mwindow = mwindow;
1675 int CWindowMaskDelete::handle_event()
1683 // Get existing keyframe
1684 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1688 mwindow->undo->update_undo_before(_("mask delete"), 0);
1690 #ifdef USE_KEYFRAME_SPANNING
1691 // Create temp keyframe
1692 MaskAuto temp_keyframe(mwindow->edl, autos);
1693 temp_keyframe.copy_data(keyframe);
1695 SubMask *submask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
1696 for(int i = mwindow->cwindow->gui->affected_point;
1697 i < submask->points.total - 1;
1700 *submask->points.values[i] = *submask->points.values[i + 1];
1703 if(submask->points.total)
1705 submask->points.remove_object(
1706 submask->points.values[submask->points.total - 1]);
1708 // Commit change to span of keyframes
1709 ((MaskAutos*)track->automation->autos[AUTOMATION_MASK])->update_parameter(&temp_keyframe);
1711 for(MaskAuto *current = (MaskAuto*)autos->default_auto;
1714 SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
1718 for(int i = mwindow->cwindow->gui->affected_point;
1719 i < submask->points.total - 1;
1722 *submask->points.values[i] = *submask->points.values[i + 1];
1725 if(submask->points.total)
1727 submask->points.remove_object(
1728 submask->points.values[submask->points.total - 1]);
1732 if(current == (MaskAuto*)autos->default_auto)
1733 current = (MaskAuto*)autos->first;
1735 current = (MaskAuto*)NEXT;
1740 gui->update_preview();
1741 mwindow->undo->update_undo_after(_("mask delete"), LOAD_AUTOMATION);
1748 int CWindowMaskDelete::keypress_event()
1750 if(get_keypress() == BACKSPACE ||
1751 get_keypress() == DELETE)
1752 return handle_event();
1757 // CWindowMaskCycleNext::CWindowMaskCycleNext(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1758 // : BC_GenericButton(x, y, _("Cycle next"))
1760 // this->mwindow = mwindow;
1763 // int CWindowMaskCycleNext::handle_event()
1765 // MaskAuto *keyframe;
1766 // MaskAutos *autos;
1768 // MaskPoint *point;
1770 // ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1774 // // Should apply to all keyframes
1775 // if(keyframe && mask->points.total)
1777 // temp = mask->points.values[0];
1779 // for(int i = 0; i < mask->points.total - 1; i++)
1781 // mask->points.values[i] = mask->points.values[i + 1];
1783 // mask->points.values[mask->points.total - 1] = temp;
1785 // mwindow->cwindow->gui->affected_point--;
1786 // if(mwindow->cwindow->gui->affected_point < 0)
1787 // mwindow->cwindow->gui->affected_point = mask->points.total - 1;
1790 // gui->update_preview();
1796 // CWindowMaskCyclePrev::CWindowMaskCyclePrev(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1797 // : BC_GenericButton(x, y, _("Cycle prev"))
1799 // this->mwindow = mwindow;
1802 // int CWindowMaskCyclePrev::handle_event()
1804 // MaskAuto *keyframe;
1805 // MaskAutos *autos;
1807 // MaskPoint *point;
1809 // ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1811 // // Should apply to all keyframes
1813 // if(keyframe && mask->points.total)
1815 // temp = mask->points.values[mask->points.total - 1];
1817 // for(int i = mask->points.total - 1; i > 0; i--)
1819 // mask->points.values[i] = mask->points.values[i - 1];
1821 // mask->points.values[0] = temp;
1823 // mwindow->cwindow->gui->affected_point++;
1824 // if(mwindow->cwindow->gui->affected_point >= mask->points.total)
1825 // mwindow->cwindow->gui->affected_point = 0;
1828 // gui->update_preview();
1834 CWindowMaskNumber::CWindowMaskNumber(MWindow *mwindow,
1835 CWindowToolGUI *gui,
1838 : BC_TumbleTextBox(gui,
1839 (int64_t)mwindow->edl->session->cwindow_mask,
1841 (int64_t)SUBMASKS - 1,
1846 this->mwindow = mwindow;
1850 CWindowMaskNumber::~CWindowMaskNumber()
1854 int CWindowMaskNumber::handle_event()
1856 mwindow->edl->session->cwindow_mask = atol(get_text());
1858 gui->update_preview();
1866 CWindowMaskFeather::CWindowMaskFeather(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1867 : BC_TumbleTextBox(gui,
1875 this->mwindow = mwindow;
1878 CWindowMaskFeather::~CWindowMaskFeather()
1881 int CWindowMaskFeather::handle_event()
1888 #ifdef USE_KEYFRAME_SPANNING
1894 mwindow->undo->update_undo_before(_("mask feather"), this);
1896 // Get existing keyframe
1897 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe,
1898 mask, point, create_it);
1902 #ifdef USE_KEYFRAME_SPANNING
1903 // Create temp keyframe
1904 MaskAuto temp_keyframe(mwindow->edl, autos);
1905 temp_keyframe.copy_data(keyframe);
1907 temp_keyframe.feather = atof(get_text());
1908 // Commit change to span of keyframes
1909 autos->update_parameter(&temp_keyframe);
1911 keyframe->feather = atof(get_text());
1914 gui->update_preview();
1917 mwindow->undo->update_undo_after(_("mask feather"), LOAD_AUTOMATION);
1922 CWindowMaskValue::CWindowMaskValue(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1932 this->mwindow = mwindow;
1936 CWindowMaskValue::~CWindowMaskValue()
1940 int CWindowMaskValue::handle_event()
1947 #ifdef USE_KEYFRAME_SPANNING
1953 mwindow->undo->update_undo_before(_("mask value"), this);
1954 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe,
1955 mask, point, create_it);
1959 #ifdef USE_KEYFRAME_SPANNING
1960 // Create temp keyframe
1961 MaskAuto temp_keyframe(mwindow->edl, autos);
1962 temp_keyframe.copy_data(keyframe);
1964 temp_keyframe.value = get_value();
1965 // Commit change to span of keyframes
1966 autos->update_parameter(&temp_keyframe);
1968 keyframe->value = get_value();
1972 gui->update_preview();
1973 mwindow->undo->update_undo_after(_("mask value"), LOAD_AUTOMATION);
1978 CWindowMaskBeforePlugins::CWindowMaskBeforePlugins(CWindowToolGUI *gui, int x, int y)
1982 _("Apply mask before plugins"))
1987 int CWindowMaskBeforePlugins::handle_event()
1994 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 1);
1997 keyframe->apply_before_plugins = get_value();
1998 gui->update_preview();
2010 CWindowMaskGUI::CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread)
2011 : CWindowToolGUI(mwindow,
2013 _(PROGRAM_NAME ": Mask"),
2017 this->mwindow = mwindow;
2018 this->thread = thread;
2020 CWindowMaskGUI::~CWindowMaskGUI()
2022 lock_window("CWindowMaskGUI::~CWindowMaskGUI");
2028 void CWindowMaskGUI::create_objects()
2030 int x = 10, y = 10, margin = mwindow->theme->widget_border;
2031 //MaskAuto *keyframe = 0;
2032 //Track *track = mwindow->cwindow->calculate_affected_track();
2034 // keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->autos[AUTOMATION_MASK], 0);
2036 lock_window("CWindowMaskGUI::create_objects");
2038 add_subwindow(title = new BC_Title(x, y, _("Mode:")));
2039 add_subwindow(mode = new CWindowMaskMode(mwindow,
2040 this, x + title->get_w() + margin, y, ""));
2041 mode->create_objects();
2042 y += mode->get_h() + margin;
2043 add_subwindow(title = new BC_Title(x, y, _("Value:")));
2044 add_subwindow(value = new CWindowMaskValue(mwindow, this, x + title->get_w() + margin, y));
2045 y += value->get_h() + margin;
2046 add_subwindow(delete_point = new CWindowMaskDelete(mwindow, this, x, y));
2047 y += delete_point->get_h() + margin;
2048 add_subwindow(title = new BC_Title(x, y, _("Mask number:")));
2049 number = new CWindowMaskNumber(mwindow,
2050 this, x + title->get_w() + margin, y);
2051 number->create_objects();
2052 y += number->get_h() + margin;
2053 add_subwindow(title = new BC_Title(x, y, _("Feather:")));
2054 feather = new CWindowMaskFeather(mwindow,
2055 this, x + title->get_w() + margin, y);
2056 feather->create_objects();
2057 y += feather->get_h() + margin;
2058 add_subwindow(title = new BC_Title(x, y, "X:"));
2059 x += title->get_w() + margin;
2060 this->x = new CWindowCoord(this, x, y, (float)0.0);
2061 this->x->create_objects();
2062 x += this->x->get_w() + margin;
2063 add_subwindow(title = new BC_Title(x, y, "Y:"));
2064 x += title->get_w() + margin;
2065 this->y = new CWindowCoord(this, x, y, (float)0.0);
2066 this->y->create_objects();
2069 y += this->y->get_h() + margin;
2070 add_subwindow(title = new BC_Title(x, y, _("Press Ctrl to move a point")));
2071 y += title->get_h() + margin;
2072 add_subwindow(title = new BC_Title(x, y, _("Press Alt to translate the mask")));
2073 y += title->get_h() + margin;
2074 add_subwindow(title = new BC_Title(x, y, _("Press Shift to edit bezier curve")));
2077 // add_subwindow(title = new BC_Title(x, y, _("Apply mask before plugins:")));
2079 add_subwindow(this->apply_before_plugins = new CWindowMaskBeforePlugins(this,
2082 // this->apply_before_plugins->create_objects();
2088 void CWindowMaskGUI::get_keyframe(Track* &track,
2090 MaskAuto* &keyframe,
2098 track = mwindow->cwindow->calculate_affected_track();
2101 autos = (MaskAutos*)track->automation->autos[AUTOMATION_MASK];
2102 keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(
2108 mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
2115 if(mwindow->cwindow->gui->affected_point < mask->points.total &&
2116 mwindow->cwindow->gui->affected_point >= 0)
2118 point = mask->points.values[mwindow->cwindow->gui->affected_point];
2123 void CWindowMaskGUI::update()
2130 //printf("CWindowMaskGUI::update 1\n");
2131 get_keyframe(track, autos, keyframe, mask, point, 0);
2133 double position = mwindow->edl->local_session->get_selectionstart(1);
2134 position = mwindow->edl->align_to_frame(position, 0);
2137 int64_t position_i = track->to_units(position, 0);
2141 x->update(point->x);
2142 y->update(point->y);
2147 feather->update((int64_t)autos->get_feather(position_i, PLAY_FORWARD));
2148 value->update((int64_t)autos->get_value(position_i, PLAY_FORWARD));
2149 apply_before_plugins->update((int64_t)keyframe->apply_before_plugins);
2152 //printf("CWindowMaskGUI::update 1\n");
2154 number->update((int64_t)mwindow->edl->session->cwindow_mask);
2156 //printf("CWindowMaskGUI::update 1\n");
2159 #ifdef USE_KEYFRAME_SPANNING
2161 CWindowMaskMode::mode_to_text(keyframe->mode));
2164 CWindowMaskMode::mode_to_text(((MaskAuto*)autos->default_auto)->mode));
2167 //printf("CWindowMaskGUI::update 2\n");
2170 void CWindowMaskGUI::handle_event()
2177 get_keyframe(track, autos, keyframe, mask, point, 0);
2179 mwindow->undo->update_undo_before(_("mask point"), this);
2183 #ifdef USE_KEYFRAME_SPANNING
2184 // Create temp keyframe
2185 MaskAuto temp_keyframe(mwindow->edl, autos);
2186 temp_keyframe.copy_data(keyframe);
2187 // Get affected point in temp keyframe
2188 mask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
2189 if(mwindow->cwindow->gui->affected_point < mask->points.total &&
2190 mwindow->cwindow->gui->affected_point >= 0)
2192 point = mask->points.values[mwindow->cwindow->gui->affected_point];
2197 point->x = atof(x->get_text());
2198 point->y = atof(y->get_text());
2199 // Commit to spanned keyframes
2200 autos->update_parameter(&temp_keyframe);
2203 point->x = atof(x->get_text());
2204 point->y = atof(y->get_text());
2209 mwindow->undo->update_undo_after(_("mask point"), LOAD_AUTOMATION);
2212 void CWindowMaskGUI::update_preview()
2214 mwindow->restart_brender();
2215 mwindow->sync_parameters(CHANGE_PARAMS);
2216 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
2220 mwindow->cwindow->gui->lock_window("CWindowMaskGUI::update_preview");
2221 mwindow->cwindow->gui->canvas->draw_refresh();
2222 mwindow->cwindow->gui->unlock_window();
2226 CWindowRulerGUI::CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread)
2227 : CWindowToolGUI(mwindow,
2229 _(PROGRAM_NAME ": Ruler"),
2235 CWindowRulerGUI::~CWindowRulerGUI()
2239 void CWindowRulerGUI::create_objects()
2244 lock_window("CWindowRulerGUI::create_objects");
2245 add_subwindow(title = new BC_Title(x, y, _("Current:")));
2246 add_subwindow(current = new BC_Title(x + title->get_w() + 10, y, ""));
2247 y += title->get_h() + 5;
2249 add_subwindow(title = new BC_Title(x, y, _("Point 1:")));
2250 add_subwindow(point1 = new BC_Title(x + title->get_w() + 10, y, ""));
2251 y += title->get_h() + 5;
2253 add_subwindow(title = new BC_Title(x, y, _("Point 2:")));
2254 add_subwindow(point2 = new BC_Title(x + title->get_w() + 10, y, ""));
2255 y += title->get_h() + 5;
2257 add_subwindow(title = new BC_Title(x, y, _("Distance:")));
2258 add_subwindow(distance = new BC_Title(x + title->get_w() + 10, y, ""));
2259 y += title->get_h() + 5;
2260 add_subwindow(title = new BC_Title(x, y, _("Angle:")));
2261 add_subwindow(angle = new BC_Title(x + title->get_w() + 10, y, ""));
2262 y += title->get_h() + 10;
2263 char string[BCTEXTLEN];
2264 sprintf(string, _("Press Ctrl to lock ruler to the\nnearest 45%c angle."), 0xb0);
2265 add_subwindow(title = new BC_Title(x,
2268 y += title->get_h() + 10;
2269 sprintf(string, _("Press Alt to translate the ruler."));
2270 add_subwindow(title = new BC_Title(x,
2277 void CWindowRulerGUI::update()
2279 double distance_value =
2280 sqrt(SQR(mwindow->edl->session->ruler_x2 - mwindow->edl->session->ruler_x1) +
2281 SQR(mwindow->edl->session->ruler_y2 - mwindow->edl->session->ruler_y1));
2282 double angle_value = atan((mwindow->edl->session->ruler_y2 - mwindow->edl->session->ruler_y1) /
2283 (mwindow->edl->session->ruler_x2 - mwindow->edl->session->ruler_x1)) *
2288 if(EQUIV(distance_value, 0.0))
2298 char string[BCTEXTLEN];
2299 sprintf(string, "%d, %d",
2300 mwindow->session->cwindow_output_x,
2301 mwindow->session->cwindow_output_y);
2302 current->update(string);
2303 sprintf(string, "%.0f, %.0f",
2304 mwindow->edl->session->ruler_x1,
2305 mwindow->edl->session->ruler_y1);
2306 point1->update(string);
2307 sprintf(string, "%.0f, %.0f",
2308 mwindow->edl->session->ruler_x2,
2309 mwindow->edl->session->ruler_y2);
2310 point2->update(string);
2312 sprintf(string, _("%0.01f pixels"), distance_value);
2313 distance->update(string);
2314 sprintf(string, "%0.02f %c", angle_value, 0xb0);
2315 angle->update(string);
2318 void CWindowRulerGUI::handle_event()