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
25 #include "automation.h"
28 #include "condition.h"
30 #include "cplayback.h"
32 #include "cwindowgui.h"
33 #include "cwindowtool.h"
35 #include "edlsession.h"
36 #include "floatauto.h"
37 #include "floatautos.h"
40 #include "localsession.h"
41 #include "mainsession.h"
44 #include "maskautos.h"
47 #include "mwindowgui.h"
50 #include "trackcanvas.h"
51 #include "transportque.h"
54 CWindowTool::CWindowTool(MWindow *mwindow, CWindowGUI *gui)
57 this->mwindow = mwindow;
61 current_tool = CWINDOW_NONE;
63 input_lock = new Condition(0, "CWindowTool::input_lock");
64 output_lock = new Condition(1, "CWindowTool::output_lock");
65 tool_gui_lock = new Mutex("CWindowTool::tool_gui_lock");
68 CWindowTool::~CWindowTool()
79 void CWindowTool::start_tool(int operation)
81 CWindowToolGUI *new_gui = 0;
84 //printf("CWindowTool::start_tool 1\n");
85 if(current_tool != operation)
87 current_tool = operation;
91 new_gui = new CWindowEyedropGUI(mwindow, this);
94 new_gui = new CWindowCropGUI(mwindow, this);
97 new_gui = new CWindowCameraGUI(mwindow, this);
99 case CWINDOW_PROJECTOR:
100 new_gui = new CWindowProjectorGUI(mwindow, this);
103 new_gui = new CWindowMaskGUI(mwindow, this);
106 new_gui = new CWindowRulerGUI(mwindow, this);
114 //printf("CWindowTool::start_tool 1\n");
120 // Wait for previous tool GUI to finish
121 output_lock->lock("CWindowTool::start_tool");
122 this->tool_gui = new_gui;
123 tool_gui->create_objects();
125 if(mwindow->edl->session->tool_window &&
126 mwindow->session->show_cwindow) tool_gui->show_window();
127 tool_gui->lock_window("CWindowTool::start_tool 1");
129 tool_gui->unlock_window();
132 // Signal thread to run next tool GUI
133 input_lock->unlock();
135 //printf("CWindowTool::start_tool 1\n");
140 tool_gui->lock_window("CWindowTool::start_tool");
142 tool_gui->unlock_window();
145 //printf("CWindowTool::start_tool 2\n");
150 void CWindowTool::stop_tool()
154 tool_gui->lock_window("CWindowTool::stop_tool");
155 tool_gui->set_done(0);
156 tool_gui->unlock_window();
160 void CWindowTool::show_tool()
162 if(tool_gui && mwindow->edl->session->tool_window)
164 tool_gui->lock_window("CWindowTool::show_tool");
165 tool_gui->show_window();
166 tool_gui->unlock_window();
170 void CWindowTool::hide_tool()
172 if(tool_gui && mwindow->edl->session->tool_window)
174 tool_gui->lock_window("CWindowTool::show_tool");
175 tool_gui->hide_window();
176 tool_gui->unlock_window();
181 void CWindowTool::run()
185 input_lock->lock("CWindowTool::run");
188 tool_gui->run_window();
189 tool_gui_lock->lock("CWindowTool::run");
192 tool_gui_lock->unlock();
194 output_lock->unlock();
198 void CWindowTool::update_show_window()
202 tool_gui->lock_window("CWindowTool::update_show_window");
204 if(mwindow->edl->session->tool_window)
207 tool_gui->show_window();
210 tool_gui->hide_window();
213 tool_gui->unlock_window();
217 void CWindowTool::raise_window()
221 gui->unlock_window();
222 tool_gui->lock_window("CWindowTool::raise_window");
223 tool_gui->raise_window();
224 tool_gui->unlock_window();
225 gui->lock_window("CWindowTool::raise_window");
229 void CWindowTool::update_values()
231 tool_gui_lock->lock("CWindowTool::update_values");
234 tool_gui->lock_window("CWindowTool::update_values");
237 tool_gui->unlock_window();
239 tool_gui_lock->unlock();
248 CWindowToolGUI::CWindowToolGUI(MWindow *mwindow,
254 mwindow->session->ctool_x,
255 mwindow->session->ctool_y,
264 this->mwindow = mwindow;
265 this->thread = thread;
266 current_operation = 0;
269 CWindowToolGUI::~CWindowToolGUI()
273 int CWindowToolGUI::close_event()
277 mwindow->edl->session->tool_window = 0;
282 thread->gui->lock_window("CWindowToolGUI::close_event");
283 thread->gui->composite_panel->set_operation(mwindow->edl->session->cwindow_operation);
284 thread->gui->flush();
285 thread->gui->unlock_window();
287 lock_window("CWindowToolGUI::close_event");
291 int CWindowToolGUI::keypress_event()
293 if(get_keypress() == 'w' || get_keypress() == 'W')
294 return close_event();
298 int CWindowToolGUI::translation_event()
300 mwindow->session->ctool_x = get_x();
301 mwindow->session->ctool_y = get_y();
310 CWindowCoord::CWindowCoord(CWindowToolGUI *gui, int x, int y, float value, int log_increment = 0)
311 : BC_TumbleTextBox(gui, (float)value, (float)-65536, (float)65536, x, y, 100)
314 set_log_floatincrement(log_increment);
317 CWindowCoord::CWindowCoord(CWindowToolGUI *gui, int x, int y, int value)
318 : BC_TumbleTextBox(gui, (int64_t)value, (int64_t)-65536, (int64_t)65536, x, y, 100)
322 int CWindowCoord::handle_event()
324 gui->event_caller = this;
330 CWindowCropOK::CWindowCropOK(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
331 : BC_GenericButton(x, y, _("Do it"))
333 this->mwindow = mwindow;
336 int CWindowCropOK::handle_event()
338 mwindow->crop_video();
343 int CWindowCropOK::keypress_event()
345 if(get_keypress() == 0xd)
359 CWindowCropGUI::CWindowCropGUI(MWindow *mwindow, CWindowTool *thread)
360 : CWindowToolGUI(mwindow,
362 _(PROGRAM_NAME ": Crop"),
369 CWindowCropGUI::~CWindowCropGUI()
373 void CWindowCropGUI::create_objects()
378 lock_window("CWindowCropGUI::create_objects");
380 int pad = MAX(BC_TextBox::calculate_h(this, MEDIUMFONT, 1, 1),
381 BC_Title::calculate_h(this, "X")) + 5;
382 add_subwindow(title = new BC_Title(x, y, "X1:"));
383 column1 = MAX(column1, title->get_w());
385 add_subwindow(title = new BC_Title(x, y, _("W:")));
386 column1 = MAX(column1, title->get_w());
388 add_subwindow(new CWindowCropOK(mwindow, thread->tool_gui, x, y));
392 x1 = new CWindowCoord(thread->tool_gui, x, y,
393 mwindow->edl->session->crop_x1);
394 x1->create_objects();
396 width = new CWindowCoord(thread->tool_gui, x, y,
397 mwindow->edl->session->crop_x2 - mwindow->edl->session->crop_x1);
398 width->create_objects();
401 x += x1->get_w() + 10;
404 add_subwindow(title = new BC_Title(x, y, "Y1:"));
405 column2 = MAX(column2, title->get_w());
407 add_subwindow(title = new BC_Title(x, y, _("H:")));
408 column2 = MAX(column2, title->get_w());
413 y1 = new CWindowCoord(thread->tool_gui, x, y,
414 mwindow->edl->session->crop_y1);
415 y1->create_objects();
417 height = new CWindowCoord(thread->tool_gui, x, y,
418 mwindow->edl->session->crop_y2 - mwindow->edl->session->crop_y1);
419 height->create_objects();
423 void CWindowCropGUI::handle_event()
426 new_x1 = atol(x1->get_text());
427 new_y1 = atol(y1->get_text());
428 if(new_x1 != mwindow->edl->session->crop_x1)
430 mwindow->edl->session->crop_x2 = new_x1 +
431 mwindow->edl->session->crop_x2 -
432 mwindow->edl->session->crop_x1;
433 mwindow->edl->session->crop_x1 = new_x1;
435 if(new_y1 != mwindow->edl->session->crop_y1)
437 mwindow->edl->session->crop_y2 = new_y1 +
438 mwindow->edl->session->crop_y2 -
439 mwindow->edl->session->crop_y1;
440 mwindow->edl->session->crop_y1 = atol(y1->get_text());
442 mwindow->edl->session->crop_x2 = atol(width->get_text()) +
443 mwindow->edl->session->crop_x1;
444 mwindow->edl->session->crop_y2 = atol(height->get_text()) +
445 mwindow->edl->session->crop_y1;
447 mwindow->cwindow->gui->lock_window("CWindowCropGUI::handle_event");
448 mwindow->cwindow->gui->canvas->draw_refresh();
449 mwindow->cwindow->gui->unlock_window();
452 void CWindowCropGUI::update()
454 x1->update((int64_t)mwindow->edl->session->crop_x1);
455 y1->update((int64_t)mwindow->edl->session->crop_y1);
456 width->update((int64_t)mwindow->edl->session->crop_x2 -
457 mwindow->edl->session->crop_x1);
458 height->update((int64_t)mwindow->edl->session->crop_y2 -
459 mwindow->edl->session->crop_y1);
463 CWindowEyedropGUI::CWindowEyedropGUI(MWindow *mwindow, CWindowTool *thread)
464 : CWindowToolGUI(mwindow, thread, _(PROGRAM_NAME ": Color"), 220, 250)
468 CWindowEyedropGUI::~CWindowEyedropGUI()
472 void CWindowEyedropGUI::create_objects()
474 int margin = mwindow->theme->widget_border;
477 int x2 = 70, x3 = x2 + 60;
478 lock_window("CWindowEyedropGUI::create_objects");
479 BC_Title *title0, *title1, *title2, *title3, *title4, *title5, *title6, *title7;
480 add_subwindow(title0 = new BC_Title(x, y,_("X,Y:")));
481 y += title0->get_h() + margin;
482 add_subwindow(title7 = new BC_Title(x, y, _("Radius:")));
483 y += BC_TextBox::calculate_h(this, MEDIUMFONT, 1, 1) + margin;
485 add_subwindow(title1 = new BC_Title(x, y, _("Red:")));
486 y += title1->get_h() + margin;
487 add_subwindow(title2 = new BC_Title(x, y, _("Green:")));
488 y += title2->get_h() + margin;
489 add_subwindow(title3 = new BC_Title(x, y, _("Blue:")));
490 y += title3->get_h() + margin;
492 add_subwindow(title4 = new BC_Title(x, y, "Y:"));
493 y += title4->get_h() + margin;
494 add_subwindow(title5 = new BC_Title(x, y, "U:"));
495 y += title5->get_h() + margin;
496 add_subwindow(title6 = new BC_Title(x, y, "V:"));
498 add_subwindow(current = new BC_Title(x2, title0->get_y(), ""));
500 radius = new CWindowCoord(this, x2, title7->get_y(),
501 mwindow->edl->session->eyedrop_radius);
502 radius->create_objects();
503 radius->set_boundaries((int64_t)0, (int64_t)255);
505 add_subwindow(red = new BC_Title(x2, title1->get_y(), "0"));
506 add_subwindow(green = new BC_Title(x2, title2->get_y(), "0"));
507 add_subwindow(blue = new BC_Title(x2, title3->get_y(), "0"));
508 add_subwindow(rgb_hex = new BC_Title(x3, red->get_y(), "#000000"));
510 add_subwindow(this->y = new BC_Title(x2, title4->get_y(), "0"));
511 add_subwindow(this->u = new BC_Title(x2, title5->get_y(), "0"));
512 add_subwindow(this->v = new BC_Title(x2, title6->get_y(), "0"));
513 add_subwindow(yuv_hex = new BC_Title(x3, this->y->get_y(), "#000000"));
515 y = title6->get_y() + this->v->get_h() + 2*margin;
516 add_subwindow(sample = new BC_SubWindow(x, y, 50, 50));
521 void CWindowEyedropGUI::update()
523 char string[BCTEXTLEN];
524 sprintf(string, "%d, %d",
525 thread->gui->eyedrop_x,
526 thread->gui->eyedrop_y);
527 current->update(string);
529 radius->update((int64_t)mwindow->edl->session->eyedrop_radius);
531 float r = mwindow->edl->local_session->red;
532 float g = mwindow->edl->local_session->green;
533 float b = mwindow->edl->local_session->blue;
537 int rx = 255*r + 0.5; bclamp(rx,0,255);
538 int gx = 255*g + 0.5; bclamp(gx,0,255);
539 int bx = 255*b + 0.5; bclamp(bx,0,255);
540 char rgb_text[BCSTRLEN];
541 sprintf(rgb_text, "#%02x%02x%02x", rx, gx, bx);
542 rgb_hex->update(rgb_text);
545 YUV::rgb_to_yuv_f(mwindow->edl->local_session->red,
546 mwindow->edl->local_session->green,
547 mwindow->edl->local_session->blue,
550 this->u->update(u); u += 0.5;
551 this->v->update(v); v += 0.5;
552 int yx = 255*y + 0.5; bclamp(yx,0,255);
553 int ux = 255*u + 0.5; bclamp(ux,0,255);
554 int vx = 255*v + 0.5; bclamp(vx,0,255);
555 char yuv_text[BCSTRLEN];
556 sprintf(yuv_text, "#%02x%02x%02x", yx, ux, vx);
557 yuv_hex->update(yuv_text);
559 int rgb = (rx << 16) | (gx << 8) | (bx << 0);
560 sample->set_color(rgb);
561 sample->draw_box(0, 0, sample->get_w(), sample->get_h());
562 sample->set_color(BLACK);
563 sample->draw_rectangle(0, 0, sample->get_w(), sample->get_h());
567 void CWindowEyedropGUI::handle_event()
569 int new_radius = atoi(radius->get_text());
570 if(new_radius != mwindow->edl->session->eyedrop_radius)
572 CWindowGUI *gui = mwindow->cwindow->gui;
573 if(gui->eyedrop_visible)
575 gui->lock_window("CWindowEyedropGUI::handle_event");
578 gui->canvas->do_eyedrop(rerender, 0, 1);
581 mwindow->edl->session->eyedrop_radius = new_radius;
583 if(gui->eyedrop_visible)
587 gui->canvas->do_eyedrop(rerender, 0, 1);
588 gui->unlock_window();
595 /* Buttons to control Keyframe-Curve-Mode for Projector or Camera */
597 // Configuration for all possible Keyframe Curve Mode toggles
599 FloatAuto::t_mode mode;
605 const _CVD Camera_Crv_Smooth =
609 N_("\"smooth\" Curve on current Camera Keyframes")
611 const _CVD Camera_Crv_Linear =
615 N_("\"linear\" Curve on current Camera Keyframes")
617 const _CVD Projector_Crv_Smooth =
621 N_("\"smooth\" Curve on current Projector Keyframes")
623 const _CVD Projector_Crv_Linear =
627 N_("\"linear\" Curve on current Projector Keyframes")
630 // Implementation Class für Keyframe Curve Mode buttons
632 // This button reflects the state of the "current" keyframe
633 // (the nearest keyframe on the left) for all three automation
634 // lines together. Clicking on this button (re)sets the curve
635 // mode for the three "current" keyframes simultanously, but
636 // never creates a new keyframe.
638 class CWindowCurveToggle : public BC_Toggle
641 CWindowCurveToggle(_CVD mode, MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
642 void check_toggle_state(FloatAuto *x, FloatAuto *y, FloatAuto *z);
651 CWindowCurveToggle::CWindowCurveToggle(_CVD mode, MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
652 : BC_Toggle(x, y, mwindow->theme->get_image_set(mode.icon_id), false),
656 this->mwindow = mwindow;
657 set_tooltip(_(cfg.tooltip));
660 void CWindowCurveToggle::check_toggle_state(FloatAuto *x, FloatAuto *y, FloatAuto *z)
662 // the toggle state is only set to ON if all
663 // three automation lines have the same curve mode.
664 // For mixed states the toggle stays off.
665 set_value( x->curve_mode == this->cfg.mode &&
666 y->curve_mode == this->cfg.mode &&
667 z->curve_mode == this->cfg.mode
668 ,true // redraw to show new state
672 int CWindowCurveToggle::handle_event()
674 FloatAuto *x=0, *y=0, *z=0;
675 Track *track = mwindow->cwindow->calculate_affected_track();
678 { mwindow->cwindow->calculate_affected_autos(&x, &y, &z,
679 track, cfg.use_camera, 0,0,0); // don't create new keyframe
681 if(x) x->change_curve_mode(cfg.mode);
682 if(y) y->change_curve_mode(cfg.mode);
683 if(z) z->change_curve_mode(cfg.mode);
686 gui->update_preview();
693 CWindowCameraGUI::CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread)
694 : CWindowToolGUI(mwindow,
696 _(PROGRAM_NAME ": Camera"),
701 CWindowCameraGUI::~CWindowCameraGUI()
705 void CWindowCameraGUI::create_objects()
707 int x = 10, y = 10, x1;
708 Track *track = mwindow->cwindow->calculate_affected_track();
709 FloatAuto *x_auto = 0;
710 FloatAuto *y_auto = 0;
711 FloatAuto *z_auto = 0;
715 lock_window("CWindowCameraGUI::create_objects");
718 mwindow->cwindow->calculate_affected_autos(&x_auto,
719 &y_auto, &z_auto, track, 1, 0, 0, 0);
722 add_subwindow(title = new BC_Title(x, y, "X:"));
724 this->x = new CWindowCoord(this, x, y,
725 x_auto ? x_auto->get_value() : (float)0);
726 this->x->create_objects();
731 add_subwindow(title = new BC_Title(x, y, "Y:"));
733 this->y = new CWindowCoord(this, x, y,
734 y_auto ? y_auto->get_value() : (float)0);
735 this->y->create_objects();
738 add_subwindow(title = new BC_Title(x, y, "Z:"));
740 this->z = new CWindowCoord(this, x, y,
741 z_auto ? z_auto->get_value() : (float)1);
742 this->z->create_objects();
743 this->z->set_increment(0.01);
747 add_subwindow(button = new CWindowCameraLeft(mwindow, this, x1, y));
748 x1 += button->get_w();
749 add_subwindow(button = new CWindowCameraCenter(mwindow, this, x1, y));
750 x1 += button->get_w();
751 add_subwindow(button = new CWindowCameraRight(mwindow, this, x1, y));
753 y += button->get_h();
755 add_subwindow(button = new CWindowCameraTop(mwindow, this, x1, y));
756 x1 += button->get_w();
757 add_subwindow(button = new CWindowCameraMiddle(mwindow, this, x1, y));
758 x1 += button->get_w();
759 add_subwindow(button = new CWindowCameraBottom(mwindow, this, x1, y));
760 // additional Buttons to control the curve mode of the "current" keyframe
761 x1 += button->get_w() + 15;
762 add_subwindow(this->t_smooth = new CWindowCurveToggle(Camera_Crv_Smooth, mwindow, this, x1, y));
763 x1 += button->get_w();
764 add_subwindow(this->t_linear = new CWindowCurveToggle(Camera_Crv_Linear, mwindow, this, x1, y));
766 // fill in current auto keyframe values, set toggle states.
771 void CWindowCameraGUI::update_preview()
773 mwindow->restart_brender();
774 mwindow->sync_parameters(CHANGE_PARAMS);
776 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
780 mwindow->gui->lock_window("CWindowCameraGUI::update_preview");
781 mwindow->gui->draw_overlays(1);
782 mwindow->gui->unlock_window();
783 mwindow->cwindow->gui->lock_window("CWindowCameraGUI::update_preview");
784 mwindow->cwindow->gui->canvas->draw_refresh();
785 mwindow->cwindow->gui->unlock_window();
789 void CWindowCameraGUI::handle_event()
791 FloatAuto *x_auto = 0;
792 FloatAuto *y_auto = 0;
793 FloatAuto *z_auto = 0;
794 Track *track = mwindow->cwindow->calculate_affected_track();
797 mwindow->undo->update_undo_before(_("camera"), this);
798 if(event_caller == x)
800 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
801 track->automation->autos[AUTOMATION_CAMERA_X],
805 x_auto->set_value(atof(x->get_text()));
811 if(event_caller == y)
813 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
814 track->automation->autos[AUTOMATION_CAMERA_Y],
818 y_auto->set_value(atof(y->get_text()));
824 if(event_caller == z)
826 z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
827 track->automation->autos[AUTOMATION_CAMERA_Z],
831 float zoom = atof(z->get_text());
832 if(zoom > 100.) zoom = 100.;
834 if(zoom < 0.01) zoom = 0.01;
835 // Doesn't allow user to enter from scratch
836 // if(zoom != atof(z->get_text()))
839 z_auto->set_value(zoom);
840 mwindow->gui->lock_window("CWindowCameraGUI::handle_event");
841 mwindow->gui->draw_overlays(1);
842 mwindow->gui->unlock_window();
848 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
852 void CWindowCameraGUI::update()
854 FloatAuto *x_auto = 0;
855 FloatAuto *y_auto = 0;
856 FloatAuto *z_auto = 0;
857 Track *track = mwindow->cwindow->calculate_affected_track();
861 mwindow->cwindow->calculate_affected_autos(&x_auto,
872 x->update(x_auto->get_value());
874 y->update(y_auto->get_value());
876 float value = z_auto->get_value();
878 thread->gui->composite_panel->cpanel_zoom->update(value);
881 if( x_auto && y_auto && z_auto )
883 t_smooth->check_toggle_state(x_auto, y_auto, z_auto);
884 t_linear->check_toggle_state(x_auto, y_auto, z_auto);
891 CWindowCameraLeft::CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
892 : BC_Button(x, y, mwindow->theme->get_image_set("left_justify"))
895 this->mwindow = mwindow;
896 set_tooltip(_("Left justify"));
898 int CWindowCameraLeft::handle_event()
900 FloatAuto *x_auto = 0;
901 FloatAuto *z_auto = 0;
902 Track *track = mwindow->cwindow->calculate_affected_track();
905 mwindow->cwindow->calculate_affected_autos(&x_auto,
918 track->get_source_dimensions(
919 mwindow->edl->local_session->get_selectionstart(1),
925 mwindow->undo->update_undo_before(_("camera"), 0);
927 (double)track->track_w / z_auto->get_value() / 2 -
929 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
931 gui->update_preview();
939 CWindowCameraCenter::CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
940 : BC_Button(x, y, mwindow->theme->get_image_set("center_justify"))
943 this->mwindow = mwindow;
944 set_tooltip(_("Center horizontal"));
946 int CWindowCameraCenter::handle_event()
948 FloatAuto *x_auto = 0;
949 Track *track = mwindow->cwindow->calculate_affected_track();
951 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
952 track->automation->autos[AUTOMATION_CAMERA_X],
957 mwindow->undo->update_undo_before(_("camera"), 0);
958 x_auto->set_value(0);
960 gui->update_preview();
961 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
968 CWindowCameraRight::CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
969 : BC_Button(x, y, mwindow->theme->get_image_set("right_justify"))
972 this->mwindow = mwindow;
973 set_tooltip(_("Right justify"));
975 int CWindowCameraRight::handle_event()
977 FloatAuto *x_auto = 0;
978 FloatAuto *z_auto = 0;
979 Track *track = mwindow->cwindow->calculate_affected_track();
982 mwindow->cwindow->calculate_affected_autos(&x_auto,
995 track->get_source_dimensions(
996 mwindow->edl->local_session->get_selectionstart(1),
1002 mwindow->undo->update_undo_before(_("camera"), 0);
1003 x_auto->set_value( -((double)track->track_w / z_auto->get_value() / 2 -
1006 gui->update_preview();
1007 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1015 CWindowCameraTop::CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1016 : BC_Button(x, y, mwindow->theme->get_image_set("top_justify"))
1019 this->mwindow = mwindow;
1020 set_tooltip(_("Top justify"));
1022 int CWindowCameraTop::handle_event()
1024 FloatAuto *y_auto = 0;
1025 FloatAuto *z_auto = 0;
1026 Track *track = mwindow->cwindow->calculate_affected_track();
1029 mwindow->cwindow->calculate_affected_autos(0,
1039 if(y_auto && z_auto)
1042 track->get_source_dimensions(
1043 mwindow->edl->local_session->get_selectionstart(1),
1049 mwindow->undo->update_undo_before(_("camera"), 0);
1050 y_auto->set_value((double)track->track_h / z_auto->get_value() / 2 -
1053 gui->update_preview();
1054 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1062 CWindowCameraMiddle::CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1063 : BC_Button(x, y, mwindow->theme->get_image_set("middle_justify"))
1066 this->mwindow = mwindow;
1067 set_tooltip(_("Center vertical"));
1069 int CWindowCameraMiddle::handle_event()
1071 FloatAuto *y_auto = 0;
1072 Track *track = mwindow->cwindow->calculate_affected_track();
1074 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1075 track->automation->autos[AUTOMATION_CAMERA_Y], 1);
1079 mwindow->undo->update_undo_before(_("camera"), 0);
1080 y_auto->set_value(0);
1082 gui->update_preview();
1083 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1090 CWindowCameraBottom::CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
1091 : BC_Button(x, y, mwindow->theme->get_image_set("bottom_justify"))
1094 this->mwindow = mwindow;
1095 set_tooltip(_("Bottom justify"));
1097 int CWindowCameraBottom::handle_event()
1099 FloatAuto *y_auto = 0;
1100 FloatAuto *z_auto = 0;
1101 Track *track = mwindow->cwindow->calculate_affected_track();
1104 mwindow->cwindow->calculate_affected_autos(0,
1114 if(y_auto && z_auto)
1117 track->get_source_dimensions(
1118 mwindow->edl->local_session->get_selectionstart(1),
1124 mwindow->undo->update_undo_before(_("camera"), 0);
1125 y_auto->set_value(-((double)track->track_h / z_auto->get_value() / 2 -
1128 gui->update_preview();
1129 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1137 CWindowProjectorGUI::CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread)
1138 : CWindowToolGUI(mwindow,
1140 _(PROGRAM_NAME ": Projector"),
1145 CWindowProjectorGUI::~CWindowProjectorGUI()
1148 void CWindowProjectorGUI::create_objects()
1150 int x = 10, y = 10, x1;
1151 Track *track = mwindow->cwindow->calculate_affected_track();
1152 FloatAuto *x_auto = 0;
1153 FloatAuto *y_auto = 0;
1154 FloatAuto *z_auto = 0;
1158 lock_window("CWindowProjectorGUI::create_objects");
1161 mwindow->cwindow->calculate_affected_autos(&x_auto,
1171 add_subwindow(title = new BC_Title(x, y, "X:"));
1172 x += title->get_w();
1173 this->x = new CWindowCoord(this, x, y,
1174 x_auto ? x_auto->get_value() : (float)0);
1175 this->x->create_objects();
1178 add_subwindow(title = new BC_Title(x, y, "Y:"));
1179 x += title->get_w();
1180 this->y = new CWindowCoord(this, x, y,
1181 y_auto ? y_auto->get_value() : (float)0);
1182 this->y->create_objects();
1185 add_subwindow(title = new BC_Title(x, y, "Z:"));
1186 x += title->get_w();
1187 this->z = new CWindowCoord(this, x, y,
1188 z_auto ? z_auto->get_value() : (float)1);
1189 this->z->create_objects();
1190 this->z->set_increment(0.01);
1194 add_subwindow(button = new CWindowProjectorLeft(mwindow, this, x1, y));
1195 x1 += button->get_w();
1196 add_subwindow(button = new CWindowProjectorCenter(mwindow, this, x1, y));
1197 x1 += button->get_w();
1198 add_subwindow(button = new CWindowProjectorRight(mwindow, this, x1, y));
1200 y += button->get_h();
1202 add_subwindow(button = new CWindowProjectorTop(mwindow, this, x1, y));
1203 x1 += button->get_w();
1204 add_subwindow(button = new CWindowProjectorMiddle(mwindow, this, x1, y));
1205 x1 += button->get_w();
1206 add_subwindow(button = new CWindowProjectorBottom(mwindow, this, x1, y));
1208 // additional Buttons to control the curve mode of the "current" keyframe
1209 x1 += button->get_w() + 15;
1210 add_subwindow(this->t_smooth = new CWindowCurveToggle(Projector_Crv_Smooth, mwindow, this, x1, y));
1211 x1 += button->get_w();
1212 add_subwindow(this->t_linear = new CWindowCurveToggle(Projector_Crv_Linear, mwindow, this, x1, y));
1214 // fill in current auto keyframe values, set toggle states.
1219 void CWindowProjectorGUI::update_preview()
1221 mwindow->restart_brender();
1222 mwindow->sync_parameters(CHANGE_PARAMS);
1223 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1227 // TODO: really need to lock the main window??
1228 mwindow->gui->lock_window("CWindowProjectorGUI::update_preview");
1229 mwindow->gui->draw_overlays(1);
1230 mwindow->gui->unlock_window();
1231 mwindow->cwindow->gui->lock_window("CWindowProjectorGUI::update_preview");
1232 mwindow->cwindow->gui->canvas->draw_refresh();
1233 mwindow->cwindow->gui->unlock_window();
1236 void CWindowProjectorGUI::handle_event()
1238 FloatAuto *x_auto = 0;
1239 FloatAuto *y_auto = 0;
1240 FloatAuto *z_auto = 0;
1241 Track *track = mwindow->cwindow->calculate_affected_track();
1245 mwindow->undo->update_undo_before(_("projector"), this);
1246 if(event_caller == x)
1248 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1249 track->automation->autos[AUTOMATION_PROJECTOR_X],
1253 x_auto->set_value(atof(x->get_text()));
1259 if(event_caller == y)
1261 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1262 track->automation->autos[AUTOMATION_PROJECTOR_Y],
1266 y_auto->set_value(atof(y->get_text()));
1272 if(event_caller == z)
1274 z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1275 track->automation->autos[AUTOMATION_PROJECTOR_Z],
1279 float zoom = atof(z->get_text());
1280 if(zoom > 100.) zoom = 100.;
1281 else if(zoom < 0.01) zoom = 0.01;
1282 // if (zoom != atof(z->get_text()))
1284 z_auto->set_value(zoom);
1286 mwindow->gui->lock_window("CWindowProjectorGUI::handle_event");
1287 mwindow->gui->draw_overlays(1);
1288 mwindow->gui->unlock_window();
1294 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1298 void CWindowProjectorGUI::update()
1300 FloatAuto *x_auto = 0;
1301 FloatAuto *y_auto = 0;
1302 FloatAuto *z_auto = 0;
1303 Track *track = mwindow->cwindow->calculate_affected_track();
1307 mwindow->cwindow->calculate_affected_autos(&x_auto,
1318 x->update(x_auto->get_value());
1320 y->update(y_auto->get_value());
1322 float value = z_auto->get_value();
1324 thread->gui->composite_panel->cpanel_zoom->update(value);
1327 if( x_auto && y_auto && z_auto )
1329 t_smooth->check_toggle_state(x_auto, y_auto, z_auto);
1330 t_linear->check_toggle_state(x_auto, y_auto, z_auto);
1334 CWindowProjectorLeft::CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1335 : BC_Button(x, y, mwindow->theme->get_image_set("left_justify"))
1338 this->mwindow = mwindow;
1339 set_tooltip(_("Left justify"));
1341 int CWindowProjectorLeft::handle_event()
1343 FloatAuto *x_auto = 0;
1344 FloatAuto *z_auto = 0;
1345 Track *track = mwindow->cwindow->calculate_affected_track();
1348 mwindow->cwindow->calculate_affected_autos(&x_auto,
1357 if(x_auto && z_auto)
1359 mwindow->undo->update_undo_before(_("projector"), 0);
1360 x_auto->set_value( (double)track->track_w * z_auto->get_value() / 2 -
1361 (double)mwindow->edl->session->output_w / 2 );
1363 gui->update_preview();
1364 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1371 CWindowProjectorCenter::CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1372 : BC_Button(x, y, mwindow->theme->get_image_set("center_justify"))
1375 this->mwindow = mwindow;
1376 set_tooltip(_("Center horizontal"));
1378 int CWindowProjectorCenter::handle_event()
1380 FloatAuto *x_auto = 0;
1381 Track *track = mwindow->cwindow->calculate_affected_track();
1383 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1384 track->automation->autos[AUTOMATION_PROJECTOR_X],
1389 mwindow->undo->update_undo_before(_("projector"), 0);
1390 x_auto->set_value(0);
1392 gui->update_preview();
1393 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1400 CWindowProjectorRight::CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1401 : BC_Button(x, y, mwindow->theme->get_image_set("right_justify"))
1404 this->mwindow = mwindow;
1405 set_tooltip(_("Right justify"));
1407 int CWindowProjectorRight::handle_event()
1409 FloatAuto *x_auto = 0;
1410 FloatAuto *z_auto = 0;
1411 Track *track = mwindow->cwindow->calculate_affected_track();
1414 mwindow->cwindow->calculate_affected_autos(&x_auto,
1424 if(x_auto && z_auto)
1426 mwindow->undo->update_undo_before(_("projector"), 0);
1427 x_auto->set_value( -((double)track->track_w * z_auto->get_value() / 2 -
1428 (double)mwindow->edl->session->output_w / 2));
1430 gui->update_preview();
1431 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1438 CWindowProjectorTop::CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1439 : BC_Button(x, y, mwindow->theme->get_image_set("top_justify"))
1442 this->mwindow = mwindow;
1443 set_tooltip(_("Top justify"));
1445 int CWindowProjectorTop::handle_event()
1447 FloatAuto *y_auto = 0;
1448 FloatAuto *z_auto = 0;
1449 Track *track = mwindow->cwindow->calculate_affected_track();
1452 mwindow->cwindow->calculate_affected_autos(0,
1462 if(y_auto && z_auto)
1464 mwindow->undo->update_undo_before(_("projector"), 0);
1465 y_auto->set_value( (double)track->track_h * z_auto->get_value() / 2 -
1466 (double)mwindow->edl->session->output_h / 2 );
1468 gui->update_preview();
1469 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1476 CWindowProjectorMiddle::CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1477 : BC_Button(x, y, mwindow->theme->get_image_set("middle_justify"))
1480 this->mwindow = mwindow;
1481 set_tooltip(_("Center vertical"));
1483 int CWindowProjectorMiddle::handle_event()
1485 FloatAuto *y_auto = 0;
1486 Track *track = mwindow->cwindow->calculate_affected_track();
1488 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1489 track->automation->autos[AUTOMATION_PROJECTOR_Y], 1);
1493 mwindow->undo->update_undo_before(_("projector"), 0);
1494 y_auto->set_value(0);
1496 gui->update_preview();
1497 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1504 CWindowProjectorBottom::CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1505 : BC_Button(x, y, mwindow->theme->get_image_set("bottom_justify"))
1508 this->mwindow = mwindow;
1509 set_tooltip(_("Bottom justify"));
1511 int CWindowProjectorBottom::handle_event()
1513 FloatAuto *y_auto = 0;
1514 FloatAuto *z_auto = 0;
1515 Track *track = mwindow->cwindow->calculate_affected_track();
1518 mwindow->cwindow->calculate_affected_autos(0,
1528 if(y_auto && z_auto)
1530 mwindow->undo->update_undo_before(_("projector"), 0);
1531 y_auto->set_value( -((double)track->track_h * z_auto->get_value() / 2 -
1532 (double)mwindow->edl->session->output_h / 2));
1534 gui->update_preview();
1535 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1542 CWindowMaskMode::CWindowMaskMode(MWindow *mwindow,
1543 CWindowToolGUI *gui, int x, int y, const char *text)
1544 : BC_PopupMenu(x, y, 220, text, 1)
1546 this->mwindow = mwindow;
1550 void CWindowMaskMode::create_objects()
1552 add_item(new BC_MenuItem(mode_to_text(MASK_MULTIPLY_ALPHA)));
1553 add_item(new BC_MenuItem(mode_to_text(MASK_SUBTRACT_ALPHA)));
1556 char* CWindowMaskMode::mode_to_text(int mode)
1560 case MASK_MULTIPLY_ALPHA:
1561 return _("Multiply alpha");
1564 case MASK_SUBTRACT_ALPHA:
1565 return _("Subtract alpha");
1569 return _("Subtract alpha");
1572 int CWindowMaskMode::text_to_mode(char *text)
1574 if(!strcasecmp(text, _("Multiply alpha")))
1575 return MASK_MULTIPLY_ALPHA;
1577 if(!strcasecmp(text, _("Subtract alpha")))
1578 return MASK_SUBTRACT_ALPHA;
1580 return MASK_SUBTRACT_ALPHA;
1583 int CWindowMaskMode::handle_event()
1590 // Get existing keyframe
1591 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1594 mwindow->undo->update_undo_before(_("mask mode"), 0);
1595 #ifdef USE_KEYFRAME_SPANNING
1596 // Create temp keyframe
1597 MaskAuto temp_keyframe(mwindow->edl, autos);
1598 temp_keyframe.copy_data(keyframe);
1600 temp_keyframe.mode = text_to_mode(get_text());
1601 // Commit change to span of keyframes
1602 autos->update_parameter(&temp_keyframe);
1604 ((MaskAuto*)autos->default_auto)->mode =
1605 text_to_mode(get_text());
1607 mwindow->undo->update_undo_after(_("mask mode"), LOAD_AUTOMATION);
1610 //printf("CWindowMaskMode::handle_event 1\n");
1611 gui->update_preview();
1622 CWindowMaskDelete::CWindowMaskDelete(MWindow *mwindow,
1623 CWindowToolGUI *gui,
1626 : BC_GenericButton(x, y, _("Delete"))
1628 this->mwindow = mwindow;
1632 int CWindowMaskDelete::handle_event()
1639 int total_points = 0;
1641 // Get existing keyframe
1642 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1646 mwindow->undo->update_undo_before(_("mask delete"), 0);
1648 #ifdef USE_KEYFRAME_SPANNING
1649 // Create temp keyframe
1650 MaskAuto temp_keyframe(mwindow->edl, autos);
1651 temp_keyframe.copy_data(keyframe);
1653 SubMask *submask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
1654 for(int i = mwindow->cwindow->gui->affected_point;
1655 i < submask->points.total - 1;
1658 *submask->points.values[i] = *submask->points.values[i + 1];
1661 if(submask->points.total)
1663 submask->points.remove_object(
1664 submask->points.values[submask->points.total - 1]);
1666 total_points = submask->points.total;
1668 // Commit change to span of keyframes
1669 ((MaskAutos*)track->automation->autos[AUTOMATION_MASK])->update_parameter(&temp_keyframe);
1671 for(MaskAuto *current = (MaskAuto*)autos->default_auto;
1674 SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
1676 for(int i = mwindow->cwindow->gui->affected_point;
1677 i < submask->points.total - 1;
1680 *submask->points.values[i] = *submask->points.values[i + 1];
1683 if(submask->points.total)
1685 submask->points.remove_object(
1686 submask->points.values[submask->points.total - 1]);
1688 total_points = submask->points.total;
1690 if(current == (MaskAuto*)autos->default_auto)
1691 current = (MaskAuto*)autos->first;
1693 current = (MaskAuto*)NEXT;
1696 if( mwindow->cwindow->gui->affected_point >= total_points )
1697 mwindow->cwindow->gui->affected_point =
1698 total_points > 0 ? total_points-1 : 0;
1701 gui->update_preview();
1702 mwindow->undo->update_undo_after(_("mask delete"), LOAD_AUTOMATION);
1709 int CWindowMaskDelete::keypress_event()
1711 if(get_keypress() == BACKSPACE ||
1712 get_keypress() == DELETE)
1713 return handle_event();
1718 // CWindowMaskCycleNext::CWindowMaskCycleNext(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1719 // : BC_GenericButton(x, y, _("Cycle next"))
1721 // this->mwindow = mwindow;
1724 // int CWindowMaskCycleNext::handle_event()
1726 // MaskAuto *keyframe;
1727 // MaskAutos *autos;
1729 // MaskPoint *point;
1731 // ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1735 // // Should apply to all keyframes
1736 // if(keyframe && mask->points.total)
1738 // temp = mask->points.values[0];
1740 // for(int i = 0; i < mask->points.total - 1; i++)
1742 // mask->points.values[i] = mask->points.values[i + 1];
1744 // mask->points.values[mask->points.total - 1] = temp;
1746 // mwindow->cwindow->gui->affected_point--;
1747 // if(mwindow->cwindow->gui->affected_point < 0)
1748 // mwindow->cwindow->gui->affected_point = mask->points.total - 1;
1751 // gui->update_preview();
1757 // CWindowMaskCyclePrev::CWindowMaskCyclePrev(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1758 // : BC_GenericButton(x, y, _("Cycle prev"))
1760 // this->mwindow = mwindow;
1763 // int CWindowMaskCyclePrev::handle_event()
1765 // MaskAuto *keyframe;
1766 // MaskAutos *autos;
1768 // MaskPoint *point;
1770 // ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
1772 // // Should apply to all keyframes
1774 // if(keyframe && mask->points.total)
1776 // temp = mask->points.values[mask->points.total - 1];
1778 // for(int i = mask->points.total - 1; i > 0; i--)
1780 // mask->points.values[i] = mask->points.values[i - 1];
1782 // mask->points.values[0] = temp;
1784 // mwindow->cwindow->gui->affected_point++;
1785 // if(mwindow->cwindow->gui->affected_point >= mask->points.total)
1786 // mwindow->cwindow->gui->affected_point = 0;
1789 // gui->update_preview();
1795 CWindowMaskNumber::CWindowMaskNumber(MWindow *mwindow,
1796 CWindowToolGUI *gui,
1799 : BC_TumbleTextBox(gui,
1800 (int64_t)mwindow->edl->session->cwindow_mask,
1802 (int64_t)SUBMASKS - 1,
1807 this->mwindow = mwindow;
1811 CWindowMaskNumber::~CWindowMaskNumber()
1815 int CWindowMaskNumber::handle_event()
1817 mwindow->edl->session->cwindow_mask = atol(get_text());
1819 gui->update_preview();
1824 CWindowMaskAffectedPoint::CWindowMaskAffectedPoint(MWindow *mwindow,
1825 CWindowToolGUI *gui, int x, int y)
1826 : BC_TumbleTextBox(gui,
1827 (int64_t)mwindow->cwindow->gui->affected_point,
1828 (int64_t)0, INT64_MAX, x, y, 100)
1830 this->mwindow = mwindow;
1834 CWindowMaskAffectedPoint::~CWindowMaskAffectedPoint()
1838 int CWindowMaskAffectedPoint::handle_event()
1840 int total_points = 0;
1841 int affected_point = atol(get_text());
1842 Track *track = mwindow->cwindow->calculate_affected_track();
1844 MaskAutos *autos = (MaskAutos*)track->automation->autos[AUTOMATION_MASK];
1845 MaskAuto *keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(autos, 0);
1847 SubMask *mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
1848 total_points = mask->points.size();
1851 int active_point = affected_point;
1852 if( affected_point >= total_points )
1853 affected_point = total_points - 1;
1854 else if( affected_point < 0 )
1856 if( active_point != affected_point )
1857 update((int64_t)affected_point);
1858 mwindow->cwindow->gui->affected_point = affected_point;
1860 gui->update_preview();
1868 CWindowMaskFeather::CWindowMaskFeather(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1869 : BC_TumbleTextBox(gui,
1877 this->mwindow = mwindow;
1880 CWindowMaskFeather::~CWindowMaskFeather()
1883 int CWindowMaskFeather::handle_event()
1890 #ifdef USE_KEYFRAME_SPANNING
1896 mwindow->undo->update_undo_before(_("mask feather"), this);
1898 // Get existing keyframe
1899 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe,
1900 mask, point, create_it);
1904 #ifdef USE_KEYFRAME_SPANNING
1905 // Create temp keyframe
1906 MaskAuto temp_keyframe(mwindow->edl, autos);
1907 temp_keyframe.copy_data(keyframe);
1909 temp_keyframe.feather = atof(get_text());
1910 // Commit change to span of keyframes
1911 autos->update_parameter(&temp_keyframe);
1913 keyframe->feather = atof(get_text());
1916 gui->update_preview();
1919 mwindow->undo->update_undo_after(_("mask feather"), LOAD_AUTOMATION);
1924 CWindowMaskValue::CWindowMaskValue(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1934 this->mwindow = mwindow;
1938 CWindowMaskValue::~CWindowMaskValue()
1942 int CWindowMaskValue::handle_event()
1949 #ifdef USE_KEYFRAME_SPANNING
1955 mwindow->undo->update_undo_before(_("mask value"), this);
1956 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe,
1957 mask, point, create_it);
1961 #ifdef USE_KEYFRAME_SPANNING
1962 // Create temp keyframe
1963 MaskAuto temp_keyframe(mwindow->edl, autos);
1964 temp_keyframe.copy_data(keyframe);
1966 temp_keyframe.value = get_value();
1967 // Commit change to span of keyframes
1968 autos->update_parameter(&temp_keyframe);
1970 keyframe->value = get_value();
1974 gui->update_preview();
1975 mwindow->undo->update_undo_after(_("mask value"), LOAD_AUTOMATION);
1980 CWindowMaskBeforePlugins::CWindowMaskBeforePlugins(CWindowToolGUI *gui, int x, int y)
1984 _("Apply mask before plugins"))
1989 int CWindowMaskBeforePlugins::handle_event()
1996 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 1);
1999 keyframe->apply_before_plugins = get_value();
2000 gui->update_preview();
2006 CWindowDisableOpenGLMasking::CWindowDisableOpenGLMasking(CWindowToolGUI *gui, int x, int y)
2007 : BC_CheckBox(x, y, 1, _("Disable OpenGL masking"))
2012 int CWindowDisableOpenGLMasking::handle_event()
2019 ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 1);
2022 keyframe->disable_opengl_masking = get_value();
2023 gui->update_preview();
2036 CWindowMaskGUI::CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread)
2037 : CWindowToolGUI(mwindow,
2039 _(PROGRAM_NAME ": Mask"),
2043 this->mwindow = mwindow;
2044 this->thread = thread;
2049 CWindowMaskGUI::~CWindowMaskGUI()
2051 lock_window("CWindowMaskGUI::~CWindowMaskGUI");
2053 delete active_point;
2058 void CWindowMaskGUI::create_objects()
2060 int x = 10, y = 10, margin = mwindow->theme->widget_border;
2061 //MaskAuto *keyframe = 0;
2062 //Track *track = mwindow->cwindow->calculate_affected_track();
2064 // keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->autos[AUTOMATION_MASK], 0);
2066 lock_window("CWindowMaskGUI::create_objects");
2068 add_subwindow(title = new BC_Title(x, y, _("Mode:")));
2069 add_subwindow(mode = new CWindowMaskMode(mwindow,
2070 this, x + title->get_w() + margin, y, ""));
2071 mode->create_objects();
2072 y += mode->get_h() + margin;
2073 add_subwindow(title = new BC_Title(x, y, _("Value:")));
2074 add_subwindow(value = new CWindowMaskValue(mwindow, this, x + title->get_w() + margin, y));
2075 y += value->get_h() + margin;
2076 add_subwindow(delete_point = new CWindowMaskDelete(mwindow, this, x, y));
2077 int x1 = x + delete_point->get_w() + 2*margin;
2078 add_subwindow(title = new BC_Title(x1, y, _("Point:")));
2079 x1 += title->get_w() + margin;
2080 active_point = new CWindowMaskAffectedPoint(mwindow, this, x1, y);
2081 active_point->create_objects();
2082 y += delete_point->get_h() + margin;
2083 add_subwindow(title = new BC_Title(x, y, _("Mask number:")));
2084 number = new CWindowMaskNumber(mwindow,
2085 this, x + title->get_w() + margin, y);
2086 number->create_objects();
2087 y += number->get_h() + margin;
2088 add_subwindow(title = new BC_Title(x, y, _("Feather:")));
2089 feather = new CWindowMaskFeather(mwindow,
2090 this, x + title->get_w() + margin, y);
2091 feather->create_objects();
2092 y += feather->get_h() + margin;
2093 add_subwindow(title = new BC_Title(x, y, "X:"));
2094 x += title->get_w() + margin;
2095 this->x = new CWindowCoord(this, x, y, (float)0.0);
2096 this->x->create_objects();
2097 x += this->x->get_w() + margin;
2098 add_subwindow(title = new BC_Title(x, y, "Y:"));
2099 x += title->get_w() + margin;
2100 this->y = new CWindowCoord(this, x, y, (float)0.0);
2101 this->y->create_objects();
2104 y += this->y->get_h() + margin;
2105 add_subwindow(title = new BC_Title(x, y, _("Press Shift to move an end point")));
2106 y += title->get_h() + margin;
2107 add_subwindow(title = new BC_Title(x, y, _("Press Ctrl to move a control point")));
2108 y += title->get_h() + margin;
2109 add_subwindow(title = new BC_Title(x, y, _("Press Alt to translate the mask")));
2112 add_subwindow(this->apply_before_plugins = new CWindowMaskBeforePlugins(this, 10, y));
2113 y += this->apply_before_plugins->get_h() + margin;
2114 add_subwindow(this->disable_opengl_masking = new CWindowDisableOpenGLMasking(this, 10, y));
2120 void CWindowMaskGUI::get_keyframe(Track* &track,
2122 MaskAuto* &keyframe,
2130 track = mwindow->cwindow->calculate_affected_track();
2133 autos = (MaskAutos*)track->automation->autos[AUTOMATION_MASK];
2134 keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(
2140 mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
2147 if(mwindow->cwindow->gui->affected_point < mask->points.total &&
2148 mwindow->cwindow->gui->affected_point >= 0)
2150 point = mask->points.values[mwindow->cwindow->gui->affected_point];
2155 void CWindowMaskGUI::update()
2162 //printf("CWindowMaskGUI::update 1\n");
2163 get_keyframe(track, autos, keyframe, mask, point, 0);
2165 double position = mwindow->edl->local_session->get_selectionstart(1);
2166 position = mwindow->edl->align_to_frame(position, 0);
2169 int64_t position_i = track->to_units(position, 0);
2173 x->update(point->x);
2174 y->update(point->y);
2179 feather->update((int64_t)autos->get_feather(position_i, PLAY_FORWARD));
2180 value->update((int64_t)autos->get_value(position_i, PLAY_FORWARD));
2181 apply_before_plugins->update((int64_t)keyframe->apply_before_plugins);
2182 disable_opengl_masking->update((int64_t)keyframe->disable_opengl_masking);
2186 //printf("CWindowMaskGUI::update 1\n");
2187 active_point->update((int64_t)mwindow->cwindow->gui->affected_point);
2188 number->update((int64_t)mwindow->edl->session->cwindow_mask);
2190 //printf("CWindowMaskGUI::update 1\n");
2193 #ifdef USE_KEYFRAME_SPANNING
2195 CWindowMaskMode::mode_to_text(keyframe->mode));
2198 CWindowMaskMode::mode_to_text(((MaskAuto*)autos->default_auto)->mode));
2201 //printf("CWindowMaskGUI::update 2\n");
2204 void CWindowMaskGUI::handle_event()
2211 get_keyframe(track, autos, keyframe, mask, point, 0);
2213 mwindow->undo->update_undo_before(_("mask point"), this);
2217 #ifdef USE_KEYFRAME_SPANNING
2218 // Create temp keyframe
2219 MaskAuto temp_keyframe(mwindow->edl, autos);
2220 temp_keyframe.copy_data(keyframe);
2221 // Get affected point in temp keyframe
2222 mask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
2223 if(mwindow->cwindow->gui->affected_point < mask->points.total &&
2224 mwindow->cwindow->gui->affected_point >= 0)
2226 point = mask->points.values[mwindow->cwindow->gui->affected_point];
2231 point->x = atof(x->get_text());
2232 point->y = atof(y->get_text());
2233 // Commit to spanned keyframes
2234 autos->update_parameter(&temp_keyframe);
2237 point->x = atof(x->get_text());
2238 point->y = atof(y->get_text());
2243 mwindow->undo->update_undo_after(_("mask point"), LOAD_AUTOMATION);
2246 void CWindowMaskGUI::update_preview()
2248 mwindow->restart_brender();
2249 mwindow->sync_parameters(CHANGE_PARAMS);
2250 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
2254 mwindow->cwindow->gui->lock_window("CWindowMaskGUI::update_preview");
2255 mwindow->cwindow->gui->canvas->draw_refresh();
2256 mwindow->cwindow->gui->unlock_window();
2260 CWindowRulerGUI::CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread)
2261 : CWindowToolGUI(mwindow,
2263 _(PROGRAM_NAME ": Ruler"),
2269 CWindowRulerGUI::~CWindowRulerGUI()
2273 void CWindowRulerGUI::create_objects()
2278 lock_window("CWindowRulerGUI::create_objects");
2279 add_subwindow(title = new BC_Title(x, y, _("Current:")));
2280 add_subwindow(current = new BC_Title(x + title->get_w() + 10, y, ""));
2281 y += title->get_h() + 5;
2283 add_subwindow(title = new BC_Title(x, y, _("Point 1:")));
2284 add_subwindow(point1 = new BC_Title(x + title->get_w() + 10, y, ""));
2285 y += title->get_h() + 5;
2287 add_subwindow(title = new BC_Title(x, y, _("Point 2:")));
2288 add_subwindow(point2 = new BC_Title(x + title->get_w() + 10, y, ""));
2289 y += title->get_h() + 5;
2291 add_subwindow(title = new BC_Title(x, y, _("Distance:")));
2292 add_subwindow(distance = new BC_Title(x + title->get_w() + 10, y, ""));
2293 y += title->get_h() + 5;
2294 add_subwindow(title = new BC_Title(x, y, _("Angle:")));
2295 add_subwindow(angle = new BC_Title(x + title->get_w() + 10, y, ""));
2296 y += title->get_h() + 10;
2297 char string[BCTEXTLEN];
2298 sprintf(string, _("Press Ctrl to lock ruler to the\nnearest 45%c angle."), 0xb0);
2299 add_subwindow(title = new BC_Title(x,
2302 y += title->get_h() + 10;
2303 sprintf(string, _("Press Alt to translate the ruler."));
2304 add_subwindow(title = new BC_Title(x,
2311 void CWindowRulerGUI::update()
2313 double distance_value =
2314 sqrt(SQR(mwindow->edl->session->ruler_x2 - mwindow->edl->session->ruler_x1) +
2315 SQR(mwindow->edl->session->ruler_y2 - mwindow->edl->session->ruler_y1));
2316 double angle_value = atan((mwindow->edl->session->ruler_y2 - mwindow->edl->session->ruler_y1) /
2317 (mwindow->edl->session->ruler_x2 - mwindow->edl->session->ruler_x1)) *
2322 if(EQUIV(distance_value, 0.0))
2332 char string[BCTEXTLEN];
2333 sprintf(string, "%d, %d",
2334 mwindow->session->cwindow_output_x,
2335 mwindow->session->cwindow_output_y);
2336 current->update(string);
2337 sprintf(string, "%.0f, %.0f",
2338 mwindow->edl->session->ruler_x1,
2339 mwindow->edl->session->ruler_y1);
2340 point1->update(string);
2341 sprintf(string, "%.0f, %.0f",
2342 mwindow->edl->session->ruler_x2,
2343 mwindow->edl->session->ruler_y2);
2344 point2->update(string);
2346 sprintf(string, _("%0.01f pixels"), distance_value);
2347 distance->update(string);
2348 sprintf(string, "%0.02f %c", angle_value, 0xb0);
2349 angle->update(string);
2352 void CWindowRulerGUI::handle_event()