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)
308 : BC_TumbleTextBox(gui,
319 CWindowCoord::CWindowCoord(CWindowToolGUI *gui, int x, int y, int value)
320 : BC_TumbleTextBox(gui,
330 int CWindowCoord::handle_event()
332 gui->event_caller = this;
338 CWindowCropOK::CWindowCropOK(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
339 : BC_GenericButton(x, y, _("Do it"))
341 this->mwindow = mwindow;
344 int CWindowCropOK::handle_event()
346 mwindow->crop_video();
351 int CWindowCropOK::keypress_event()
353 if(get_keypress() == 0xd)
367 CWindowCropGUI::CWindowCropGUI(MWindow *mwindow, CWindowTool *thread)
368 : CWindowToolGUI(mwindow,
370 _(PROGRAM_NAME ": Crop"),
377 CWindowCropGUI::~CWindowCropGUI()
381 void CWindowCropGUI::create_objects()
386 lock_window("CWindowCropGUI::create_objects");
388 int pad = MAX(BC_TextBox::calculate_h(this, MEDIUMFONT, 1, 1),
389 BC_Title::calculate_h(this, "X")) + 5;
390 add_subwindow(title = new BC_Title(x, y, _("X1:")));
391 column1 = MAX(column1, title->get_w());
393 add_subwindow(title = new BC_Title(x, y, _("W:")));
394 column1 = MAX(column1, title->get_w());
396 add_subwindow(new CWindowCropOK(mwindow, thread->tool_gui, x, y));
400 x1 = new CWindowCoord(thread->tool_gui, x, y, mwindow->edl->session->crop_x1);
401 x1->create_objects();
403 width = new CWindowCoord(thread->tool_gui,
406 mwindow->edl->session->crop_x2 -
407 mwindow->edl->session->crop_x1);
408 width->create_objects();
411 x += x1->get_w() + 10;
414 add_subwindow(title = new BC_Title(x, y, _("Y1:")));
415 column2 = MAX(column2, title->get_w());
417 add_subwindow(title = new BC_Title(x, y, _("H:")));
418 column2 = MAX(column2, title->get_w());
423 y1 = new CWindowCoord(thread->tool_gui, x, y, mwindow->edl->session->crop_y1);
424 y1->create_objects();
426 height = new CWindowCoord(thread->tool_gui,
429 mwindow->edl->session->crop_y2 -
430 mwindow->edl->session->crop_y1);
431 height->create_objects();
435 void CWindowCropGUI::handle_event()
438 new_x1 = atol(x1->get_text());
439 new_y1 = atol(y1->get_text());
440 if(new_x1 != mwindow->edl->session->crop_x1)
442 mwindow->edl->session->crop_x2 = new_x1 +
443 mwindow->edl->session->crop_x2 -
444 mwindow->edl->session->crop_x1;
445 mwindow->edl->session->crop_x1 = new_x1;
447 if(new_y1 != mwindow->edl->session->crop_y1)
449 mwindow->edl->session->crop_y2 = new_y1 +
450 mwindow->edl->session->crop_y2 -
451 mwindow->edl->session->crop_y1;
452 mwindow->edl->session->crop_y1 = atol(y1->get_text());
454 mwindow->edl->session->crop_x2 = atol(width->get_text()) +
455 mwindow->edl->session->crop_x1;
456 mwindow->edl->session->crop_y2 = atol(height->get_text()) +
457 mwindow->edl->session->crop_y1;
459 mwindow->cwindow->gui->lock_window("CWindowCropGUI::handle_event");
460 mwindow->cwindow->gui->canvas->draw_refresh();
461 mwindow->cwindow->gui->unlock_window();
464 void CWindowCropGUI::update()
466 x1->update((int64_t)mwindow->edl->session->crop_x1);
467 y1->update((int64_t)mwindow->edl->session->crop_y1);
468 width->update((int64_t)mwindow->edl->session->crop_x2 -
469 mwindow->edl->session->crop_x1);
470 height->update((int64_t)mwindow->edl->session->crop_y2 -
471 mwindow->edl->session->crop_y1);
479 CWindowEyedropGUI::CWindowEyedropGUI(MWindow *mwindow, CWindowTool *thread)
480 : CWindowToolGUI(mwindow,
482 _(PROGRAM_NAME ": Color"),
488 CWindowEyedropGUI::~CWindowEyedropGUI()
492 void CWindowEyedropGUI::create_objects()
494 int margin = mwindow->theme->widget_border;
498 lock_window("CWindowEyedropGUI::create_objects");
499 BC_Title *title1, *title2, *title3, *title4, *title5, *title6, *title7;
500 add_subwindow(title7 = new BC_Title(x, y, _("Radius:")));
501 y += BC_TextBox::calculate_h(this, MEDIUMFONT, 1, 1) + margin;
503 add_subwindow(title1 = new BC_Title(x, y, _("Red:")));
504 y += title1->get_h() + margin;
505 add_subwindow(title2 = new BC_Title(x, y, _("Green:")));
506 y += title2->get_h() + margin;
507 add_subwindow(title3 = new BC_Title(x, y, _("Blue:")));
508 y += title3->get_h() + margin;
510 add_subwindow(title4 = new BC_Title(x, y, "Y:"));
511 y += title4->get_h() + margin;
512 add_subwindow(title5 = new BC_Title(x, y, "U:"));
513 y += title5->get_h() + margin;
514 add_subwindow(title6 = new BC_Title(x, y, "V:"));
517 radius = new CWindowCoord(this,
520 mwindow->edl->session->eyedrop_radius);
521 radius->create_objects();
522 radius->set_boundaries((int64_t)0, (int64_t)255);
525 add_subwindow(red = new BC_Title(x2, title1->get_y(), "0"));
526 add_subwindow(green = new BC_Title(x2, title2->get_y(), "0"));
527 add_subwindow(blue = new BC_Title(x2, title3->get_y(), "0"));
529 add_subwindow(this->y = new BC_Title(x2, title4->get_y(), "0"));
530 add_subwindow(this->u = new BC_Title(x2, title5->get_y(), "0"));
531 add_subwindow(this->v = new BC_Title(x2, title6->get_y(), "0"));
533 y = title6->get_y() + this->v->get_h() + margin;
534 add_subwindow(sample = new BC_SubWindow(x, y, 50, 50));
539 void CWindowEyedropGUI::update()
541 radius->update((int64_t)mwindow->edl->session->eyedrop_radius);
543 red->update(mwindow->edl->local_session->red);
544 green->update(mwindow->edl->local_session->green);
545 blue->update(mwindow->edl->local_session->blue);
548 YUV::rgb_to_yuv_f(mwindow->edl->local_session->red,
549 mwindow->edl->local_session->green,
550 mwindow->edl->local_session->blue,
558 int red = (int)(CLIP(mwindow->edl->local_session->red, 0, 1) * 0xff);
559 int green = (int)(CLIP(mwindow->edl->local_session->green, 0, 1) * 0xff);
560 int blue = (int)(CLIP(mwindow->edl->local_session->blue, 0, 1) * 0xff);
561 sample->set_color((red << 16) | (green << 8) | blue);
562 sample->draw_box(0, 0, sample->get_w(), sample->get_h());
563 sample->set_color(BLACK);
564 sample->draw_rectangle(0, 0, sample->get_w(), sample->get_h());
568 void CWindowEyedropGUI::handle_event()
570 int new_radius = atoi(radius->get_text());
571 if(new_radius != mwindow->edl->session->eyedrop_radius)
573 CWindowGUI *gui = mwindow->cwindow->gui;
574 if(gui->eyedrop_visible)
576 gui->lock_window("CWindowEyedropGUI::handle_event");
579 gui->canvas->do_eyedrop(rerender, 0, 1);
582 mwindow->edl->session->eyedrop_radius = new_radius;
584 if(gui->eyedrop_visible)
588 gui->canvas->do_eyedrop(rerender, 0, 1);
589 gui->unlock_window();
602 CWindowCameraGUI::CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread)
603 : CWindowToolGUI(mwindow,
605 _(PROGRAM_NAME ": Camera"),
610 CWindowCameraGUI::~CWindowCameraGUI()
614 void CWindowCameraGUI::create_objects()
616 int x = 10, y = 10, x1;
617 Track *track = mwindow->cwindow->calculate_affected_track();
618 FloatAuto *x_auto = 0;
619 FloatAuto *y_auto = 0;
620 FloatAuto *z_auto = 0;
624 lock_window("CWindowCameraGUI::create_objects");
627 mwindow->cwindow->calculate_affected_autos(&x_auto,
637 add_subwindow(title = new BC_Title(x, y, _("X:")));
639 this->x = new CWindowCoord(this,
642 x_auto ? x_auto->value : (float)0);
643 this->x->create_objects();
648 add_subwindow(title = new BC_Title(x, y, _("Y:")));
650 this->y = new CWindowCoord(this,
653 y_auto ? y_auto->value : (float)0);
654 this->y->create_objects();
657 add_subwindow(title = new BC_Title(x, y, _("Z:")));
659 this->z = new CWindowCoord(this,
662 z_auto ? z_auto->value : (float)1);
663 this->z->create_objects();
664 this->z->set_increment(0.01);
668 add_subwindow(button = new CWindowCameraLeft(mwindow, this, x1, y));
669 x1 += button->get_w();
670 add_subwindow(button = new CWindowCameraCenter(mwindow, this, x1, y));
671 x1 += button->get_w();
672 add_subwindow(button = new CWindowCameraRight(mwindow, this, x1, y));
674 y += button->get_h();
676 add_subwindow(button = new CWindowCameraTop(mwindow, this, x1, y));
677 x1 += button->get_w();
678 add_subwindow(button = new CWindowCameraMiddle(mwindow, this, x1, y));
679 x1 += button->get_w();
680 add_subwindow(button = new CWindowCameraBottom(mwindow, this, x1, y));
684 void CWindowCameraGUI::update_preview()
686 mwindow->restart_brender();
687 mwindow->sync_parameters(CHANGE_PARAMS);
689 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
693 mwindow->cwindow->gui->lock_window("CWindowCameraGUI::update_preview");
694 mwindow->cwindow->gui->canvas->draw_refresh();
695 mwindow->cwindow->gui->unlock_window();
699 void CWindowCameraGUI::handle_event()
701 FloatAuto *x_auto = 0;
702 FloatAuto *y_auto = 0;
703 FloatAuto *z_auto = 0;
704 Track *track = mwindow->cwindow->calculate_affected_track();
707 mwindow->undo->update_undo_before(_("camera"), this);
708 if(event_caller == x)
710 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
711 track->automation->autos[AUTOMATION_CAMERA_X],
715 x_auto->value = atof(x->get_text());
720 if(event_caller == y)
722 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
723 track->automation->autos[AUTOMATION_CAMERA_Y],
727 y_auto->value = atof(y->get_text());
732 if(event_caller == z)
734 z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
735 track->automation->autos[AUTOMATION_CAMERA_Z],
739 float zoom = atof(z->get_text());
740 if(zoom > 10) zoom = 10;
742 if(zoom < 0) zoom = 0;
743 // Doesn't allow user to enter from scratch
744 // if(zoom != atof(z->get_text()))
747 z_auto->value = zoom;
748 mwindow->gui->lock_window("CWindowCameraGUI::handle_event");
749 mwindow->gui->draw_overlays(1);
750 mwindow->gui->unlock_window();
755 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
759 void CWindowCameraGUI::update()
761 FloatAuto *x_auto = 0;
762 FloatAuto *y_auto = 0;
763 FloatAuto *z_auto = 0;
764 Track *track = mwindow->cwindow->calculate_affected_track();
768 mwindow->cwindow->calculate_affected_autos(&x_auto,
779 x->update(x_auto->value);
781 y->update(y_auto->value);
783 z->update(z_auto->value);
786 // BezierAuto* CWindowCameraGUI::get_keyframe()
788 // BezierAuto *keyframe = 0;
789 // Track *track = mwindow->cwindow->calculate_affected_track();
791 // keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(
792 // track->automation->autos[AUTOMATION_CAMERA]);
798 CWindowCameraLeft::CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
799 : BC_Button(x, y, mwindow->theme->get_image_set("left_justify"))
802 this->mwindow = mwindow;
803 set_tooltip(_("Left justify"));
805 int CWindowCameraLeft::handle_event()
807 FloatAuto *x_auto = 0;
808 FloatAuto *z_auto = 0;
809 Track *track = mwindow->cwindow->calculate_affected_track();
812 mwindow->cwindow->calculate_affected_autos(&x_auto,
825 track->get_source_dimensions(
826 mwindow->edl->local_session->get_selectionstart(1),
832 mwindow->undo->update_undo_before(_("camera"), 0);
834 (double)track->track_w / z_auto->value / 2 -
836 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
838 gui->update_preview();
846 CWindowCameraCenter::CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
847 : BC_Button(x, y, mwindow->theme->get_image_set("center_justify"))
850 this->mwindow = mwindow;
851 set_tooltip(_("Center horizontal"));
853 int CWindowCameraCenter::handle_event()
855 FloatAuto *x_auto = 0;
856 Track *track = mwindow->cwindow->calculate_affected_track();
858 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
859 track->automation->autos[AUTOMATION_CAMERA_X],
864 mwindow->undo->update_undo_before(_("camera"), 0);
867 gui->update_preview();
868 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
875 CWindowCameraRight::CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
876 : BC_Button(x, y, mwindow->theme->get_image_set("right_justify"))
879 this->mwindow = mwindow;
880 set_tooltip(_("Right justify"));
882 int CWindowCameraRight::handle_event()
884 FloatAuto *x_auto = 0;
885 FloatAuto *z_auto = 0;
886 Track *track = mwindow->cwindow->calculate_affected_track();
889 mwindow->cwindow->calculate_affected_autos(&x_auto,
902 track->get_source_dimensions(
903 mwindow->edl->local_session->get_selectionstart(1),
909 mwindow->undo->update_undo_before(_("camera"), 0);
910 x_auto->value = -((double)track->track_w / z_auto->value / 2 -
913 gui->update_preview();
914 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
922 CWindowCameraTop::CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
923 : BC_Button(x, y, mwindow->theme->get_image_set("top_justify"))
926 this->mwindow = mwindow;
927 set_tooltip(_("Top justify"));
929 int CWindowCameraTop::handle_event()
931 FloatAuto *y_auto = 0;
932 FloatAuto *z_auto = 0;
933 Track *track = mwindow->cwindow->calculate_affected_track();
936 mwindow->cwindow->calculate_affected_autos(0,
949 track->get_source_dimensions(
950 mwindow->edl->local_session->get_selectionstart(1),
956 mwindow->undo->update_undo_before(_("camera"), 0);
957 y_auto->value = (double)track->track_h / z_auto->value / 2 -
960 gui->update_preview();
961 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
969 CWindowCameraMiddle::CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
970 : BC_Button(x, y, mwindow->theme->get_image_set("middle_justify"))
973 this->mwindow = mwindow;
974 set_tooltip(_("Center vertical"));
976 int CWindowCameraMiddle::handle_event()
978 FloatAuto *y_auto = 0;
979 Track *track = mwindow->cwindow->calculate_affected_track();
981 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
982 track->automation->autos[AUTOMATION_CAMERA_Y], 1);
986 mwindow->undo->update_undo_before(_("camera"), 0);
989 gui->update_preview();
990 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
997 CWindowCameraBottom::CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
998 : BC_Button(x, y, mwindow->theme->get_image_set("bottom_justify"))
1001 this->mwindow = mwindow;
1002 set_tooltip(_("Bottom justify"));
1004 int CWindowCameraBottom::handle_event()
1006 FloatAuto *y_auto = 0;
1007 FloatAuto *z_auto = 0;
1008 Track *track = mwindow->cwindow->calculate_affected_track();
1011 mwindow->cwindow->calculate_affected_autos(0,
1021 if(y_auto && z_auto)
1024 track->get_source_dimensions(
1025 mwindow->edl->local_session->get_selectionstart(1),
1031 mwindow->undo->update_undo_before(_("camera"), 0);
1032 y_auto->value = -((double)track->track_h / z_auto->value / 2 -
1035 gui->update_preview();
1036 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1059 CWindowProjectorGUI::CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread)
1060 : CWindowToolGUI(mwindow,
1062 _(PROGRAM_NAME ": Projector"),
1067 CWindowProjectorGUI::~CWindowProjectorGUI()
1070 void CWindowProjectorGUI::create_objects()
1072 int x = 10, y = 10, x1;
1073 Track *track = mwindow->cwindow->calculate_affected_track();
1074 FloatAuto *x_auto = 0;
1075 FloatAuto *y_auto = 0;
1076 FloatAuto *z_auto = 0;
1080 lock_window("CWindowProjectorGUI::create_objects");
1083 mwindow->cwindow->calculate_affected_autos(&x_auto,
1093 add_subwindow(title = new BC_Title(x, y, _("X:")));
1094 x += title->get_w();
1095 this->x = new CWindowCoord(this,
1098 x_auto ? x_auto->value : (float)0);
1099 this->x->create_objects();
1102 add_subwindow(title = new BC_Title(x, y, _("Y:")));
1103 x += title->get_w();
1104 this->y = new CWindowCoord(this,
1107 y_auto ? y_auto->value : (float)0);
1108 this->y->create_objects();
1111 add_subwindow(title = new BC_Title(x, y, _("Z:")));
1112 x += title->get_w();
1113 this->z = new CWindowCoord(this,
1116 z_auto ? z_auto->value : (float)1);
1117 this->z->create_objects();
1118 this->z->set_increment(0.01);
1122 add_subwindow(button = new CWindowProjectorLeft(mwindow, this, x1, y));
1123 x1 += button->get_w();
1124 add_subwindow(button = new CWindowProjectorCenter(mwindow, this, x1, y));
1125 x1 += button->get_w();
1126 add_subwindow(button = new CWindowProjectorRight(mwindow, this, x1, y));
1128 y += button->get_h();
1130 add_subwindow(button = new CWindowProjectorTop(mwindow, this, x1, y));
1131 x1 += button->get_w();
1132 add_subwindow(button = new CWindowProjectorMiddle(mwindow, this, x1, y));
1133 x1 += button->get_w();
1134 add_subwindow(button = new CWindowProjectorBottom(mwindow, this, x1, y));
1138 void CWindowProjectorGUI::update_preview()
1140 mwindow->restart_brender();
1141 mwindow->sync_parameters(CHANGE_PARAMS);
1142 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1146 mwindow->cwindow->gui->lock_window("CWindowProjectorGUI::update_preview");
1147 mwindow->cwindow->gui->canvas->draw_refresh();
1148 mwindow->cwindow->gui->unlock_window();
1151 void CWindowProjectorGUI::handle_event()
1153 FloatAuto *x_auto = 0;
1154 FloatAuto *y_auto = 0;
1155 FloatAuto *z_auto = 0;
1156 Track *track = mwindow->cwindow->calculate_affected_track();
1160 mwindow->undo->update_undo_before(_("projector"), this);
1161 if(event_caller == x)
1163 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1164 track->automation->autos[AUTOMATION_PROJECTOR_X],
1168 x_auto->value = atof(x->get_text());
1173 if(event_caller == y)
1175 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1176 track->automation->autos[AUTOMATION_PROJECTOR_Y],
1180 y_auto->value = atof(y->get_text());
1185 if(event_caller == z)
1187 z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1188 track->automation->autos[AUTOMATION_PROJECTOR_Z],
1192 float zoom = atof(z->get_text());
1193 if(zoom > 10000) zoom = 10000;
1195 if(zoom < 0) zoom = 0;
1196 // if (zoom != atof(z->get_text()))
1198 z_auto->value = zoom;
1200 mwindow->gui->lock_window("CWindowProjectorGUI::handle_event");
1201 mwindow->gui->draw_overlays(1);
1202 mwindow->gui->unlock_window();
1207 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1211 void CWindowProjectorGUI::update()
1213 FloatAuto *x_auto = 0;
1214 FloatAuto *y_auto = 0;
1215 FloatAuto *z_auto = 0;
1216 Track *track = mwindow->cwindow->calculate_affected_track();
1220 mwindow->cwindow->calculate_affected_autos(&x_auto,
1231 x->update(x_auto->value);
1233 y->update(y_auto->value);
1235 z->update(z_auto->value);
1238 // BezierAuto* CWindowProjectorGUI::get_keyframe()
1240 // BezierAuto *keyframe = 0;
1241 // Track *track = mwindow->cwindow->calculate_affected_track();
1243 // keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(
1244 // track->automation->autos[AUTOMATION_PROJECTOR]);
1285 CWindowProjectorLeft::CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1286 : BC_Button(x, y, mwindow->theme->get_image_set("left_justify"))
1289 this->mwindow = mwindow;
1290 set_tooltip(_("Left justify"));
1292 int CWindowProjectorLeft::handle_event()
1294 FloatAuto *x_auto = 0;
1295 FloatAuto *z_auto = 0;
1296 Track *track = mwindow->cwindow->calculate_affected_track();
1299 mwindow->cwindow->calculate_affected_autos(&x_auto,
1308 if(x_auto && z_auto)
1310 mwindow->undo->update_undo_before(_("projector"), 0);
1311 x_auto->value = (double)track->track_w * z_auto->value / 2 -
1312 (double)mwindow->edl->session->output_w / 2;
1314 gui->update_preview();
1315 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1322 CWindowProjectorCenter::CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1323 : BC_Button(x, y, mwindow->theme->get_image_set("center_justify"))
1326 this->mwindow = mwindow;
1327 set_tooltip(_("Center horizontal"));
1329 int CWindowProjectorCenter::handle_event()
1331 FloatAuto *x_auto = 0;
1332 Track *track = mwindow->cwindow->calculate_affected_track();
1334 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1335 track->automation->autos[AUTOMATION_PROJECTOR_X],
1340 mwindow->undo->update_undo_before(_("projector"), 0);
1343 gui->update_preview();
1344 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1351 CWindowProjectorRight::CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1352 : BC_Button(x, y, mwindow->theme->get_image_set("right_justify"))
1355 this->mwindow = mwindow;
1356 set_tooltip(_("Right justify"));
1358 int CWindowProjectorRight::handle_event()
1360 FloatAuto *x_auto = 0;
1361 FloatAuto *z_auto = 0;
1362 Track *track = mwindow->cwindow->calculate_affected_track();
1365 mwindow->cwindow->calculate_affected_autos(&x_auto,
1375 if(x_auto && z_auto)
1377 mwindow->undo->update_undo_before(_("projector"), 0);
1378 x_auto->value = -((double)track->track_w * z_auto->value / 2 -
1379 (double)mwindow->edl->session->output_w / 2);
1381 gui->update_preview();
1382 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1389 CWindowProjectorTop::CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1390 : BC_Button(x, y, mwindow->theme->get_image_set("top_justify"))
1393 this->mwindow = mwindow;
1394 set_tooltip(_("Top justify"));
1396 int CWindowProjectorTop::handle_event()
1398 FloatAuto *y_auto = 0;
1399 FloatAuto *z_auto = 0;
1400 Track *track = mwindow->cwindow->calculate_affected_track();
1403 mwindow->cwindow->calculate_affected_autos(0,
1413 if(y_auto && z_auto)
1415 mwindow->undo->update_undo_before(_("projector"), 0);
1416 y_auto->value = (double)track->track_h * z_auto->value / 2 -
1417 (double)mwindow->edl->session->output_h / 2;
1419 gui->update_preview();
1420 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1427 CWindowProjectorMiddle::CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1428 : BC_Button(x, y, mwindow->theme->get_image_set("middle_justify"))
1431 this->mwindow = mwindow;
1432 set_tooltip(_("Center vertical"));
1434 int CWindowProjectorMiddle::handle_event()
1436 FloatAuto *y_auto = 0;
1437 Track *track = mwindow->cwindow->calculate_affected_track();
1439 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1440 track->automation->autos[AUTOMATION_PROJECTOR_Y], 1);
1444 mwindow->undo->update_undo_before(_("projector"), 0);
1447 gui->update_preview();
1448 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1455 CWindowProjectorBottom::CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1456 : BC_Button(x, y, mwindow->theme->get_image_set("bottom_justify"))
1459 this->mwindow = mwindow;
1460 set_tooltip(_("Bottom justify"));
1462 int CWindowProjectorBottom::handle_event()
1464 FloatAuto *y_auto = 0;
1465 FloatAuto *z_auto = 0;
1466 Track *track = mwindow->cwindow->calculate_affected_track();
1469 mwindow->cwindow->calculate_affected_autos(0,
1479 if(y_auto && z_auto)
1481 mwindow->undo->update_undo_before(_("projector"), 0);
1482 y_auto->value = -((double)track->track_h * z_auto->value / 2 -
1483 (double)mwindow->edl->session->output_h / 2);
1485 gui->update_preview();
1486 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1499 CWindowMaskMode::CWindowMaskMode(MWindow *mwindow,
1500 CWindowToolGUI *gui,
1510 this->mwindow = mwindow;
1514 void CWindowMaskMode::create_objects()
1516 add_item(new BC_MenuItem(mode_to_text(MASK_MULTIPLY_ALPHA)));
1517 add_item(new BC_MenuItem(mode_to_text(MASK_SUBTRACT_ALPHA)));
1520 char* CWindowMaskMode::mode_to_text(int mode)
1524 case MASK_MULTIPLY_ALPHA:
1525 return _("Multiply alpha");
1528 case MASK_SUBTRACT_ALPHA:
1529 return _("Subtract alpha");
1533 return _("Subtract alpha");
1536 int CWindowMaskMode::text_to_mode(char *text)
1538 if(!strcasecmp(text, _("Multiply alpha")))
1539 return MASK_MULTIPLY_ALPHA;
1541 if(!strcasecmp(text, _("Subtract alpha")))
1542 return MASK_SUBTRACT_ALPHA;
1544 return MASK_SUBTRACT_ALPHA;
1547 int CWindowMaskMode::handle_event()
1554 // Get existing keyframe
1555 ((CWindowMaskGUI*)gui)->get_keyframe(track,
1563 mwindow->undo->update_undo_before(_("mask mode"), 0);
1564 #ifdef USE_KEYFRAME_SPANNING
1565 // Create temp keyframe
1566 MaskAuto temp_keyframe(mwindow->edl, autos);
1567 temp_keyframe.copy_data(keyframe);
1569 temp_keyframe.mode = text_to_mode(get_text());
1570 // Commit change to span of keyframes
1571 autos->update_parameter(&temp_keyframe);
1573 ((MaskAuto*)autos->default_auto)->mode =
1574 text_to_mode(get_text());
1576 mwindow->undo->update_undo_after(_("mask mode"), LOAD_AUTOMATION);
1579 //printf("CWindowMaskMode::handle_event 1\n");
1580 gui->update_preview();
1591 CWindowMaskDelete::CWindowMaskDelete(MWindow *mwindow,
1592 CWindowToolGUI *gui,
1595 : BC_GenericButton(x, y, _("Delete"))
1597 this->mwindow = mwindow;
1601 int CWindowMaskDelete::handle_event()
1609 // Get existing keyframe
1610 ((CWindowMaskGUI*)gui)->get_keyframe(track,
1619 mwindow->undo->update_undo_before(_("mask delete"), 0);
1621 #ifdef USE_KEYFRAME_SPANNING
1622 // Create temp keyframe
1623 MaskAuto temp_keyframe(mwindow->edl, autos);
1624 temp_keyframe.copy_data(keyframe);
1626 SubMask *submask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
1627 for(int i = mwindow->cwindow->gui->affected_point;
1628 i < submask->points.total - 1;
1631 *submask->points.values[i] = *submask->points.values[i + 1];
1634 if(submask->points.total)
1636 submask->points.remove_object(
1637 submask->points.values[submask->points.total - 1]);
1639 // Commit change to span of keyframes
1640 ((MaskAutos*)track->automation->autos[AUTOMATION_MASK])->update_parameter(&temp_keyframe);
1642 for(MaskAuto *current = (MaskAuto*)autos->default_auto;
1645 SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
1649 for(int i = mwindow->cwindow->gui->affected_point;
1650 i < submask->points.total - 1;
1653 *submask->points.values[i] = *submask->points.values[i + 1];
1656 if(submask->points.total)
1658 submask->points.remove_object(
1659 submask->points.values[submask->points.total - 1]);
1663 if(current == (MaskAuto*)autos->default_auto)
1664 current = (MaskAuto*)autos->first;
1666 current = (MaskAuto*)NEXT;
1671 gui->update_preview();
1672 mwindow->undo->update_undo_after(_("mask delete"), LOAD_AUTOMATION);
1679 int CWindowMaskDelete::keypress_event()
1681 if(get_keypress() == BACKSPACE ||
1682 get_keypress() == DELETE)
1683 return handle_event();
1688 // CWindowMaskCycleNext::CWindowMaskCycleNext(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1689 // : BC_GenericButton(x, y, _("Cycle next"))
1691 // this->mwindow = mwindow;
1694 // int CWindowMaskCycleNext::handle_event()
1696 // MaskAuto *keyframe;
1698 // MaskPoint *point;
1700 // ((CWindowMaskGUI*)gui)->get_keyframe(track,
1708 // // Should apply to all keyframes
1709 // if(keyframe && mask->points.total)
1711 // temp = mask->points.values[0];
1713 // for(int i = 0; i < mask->points.total - 1; i++)
1715 // mask->points.values[i] = mask->points.values[i + 1];
1717 // mask->points.values[mask->points.total - 1] = temp;
1719 // mwindow->cwindow->gui->affected_point--;
1720 // if(mwindow->cwindow->gui->affected_point < 0)
1721 // mwindow->cwindow->gui->affected_point = mask->points.total - 1;
1724 // gui->update_preview();
1730 // CWindowMaskCyclePrev::CWindowMaskCyclePrev(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1731 // : BC_GenericButton(x, y, _("Cycle prev"))
1733 // this->mwindow = mwindow;
1736 // int CWindowMaskCyclePrev::handle_event()
1738 // MaskAuto *keyframe;
1740 // MaskPoint *point;
1742 // ((CWindowMaskGUI*)gui)->get_keyframe(track,
1748 // // Should apply to all keyframes
1750 // if(keyframe && mask->points.total)
1752 // temp = mask->points.values[mask->points.total - 1];
1754 // for(int i = mask->points.total - 1; i > 0; i--)
1756 // mask->points.values[i] = mask->points.values[i - 1];
1758 // mask->points.values[0] = temp;
1760 // mwindow->cwindow->gui->affected_point++;
1761 // if(mwindow->cwindow->gui->affected_point >= mask->points.total)
1762 // mwindow->cwindow->gui->affected_point = 0;
1765 // gui->update_preview();
1771 CWindowMaskNumber::CWindowMaskNumber(MWindow *mwindow,
1772 CWindowToolGUI *gui,
1775 : BC_TumbleTextBox(gui,
1776 (int64_t)mwindow->edl->session->cwindow_mask,
1778 (int64_t)SUBMASKS - 1,
1783 this->mwindow = mwindow;
1787 CWindowMaskNumber::~CWindowMaskNumber()
1791 int CWindowMaskNumber::handle_event()
1793 mwindow->edl->session->cwindow_mask = atol(get_text());
1795 gui->update_preview();
1803 CWindowMaskFeather::CWindowMaskFeather(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1804 : BC_TumbleTextBox(gui,
1812 this->mwindow = mwindow;
1815 CWindowMaskFeather::~CWindowMaskFeather()
1818 int CWindowMaskFeather::handle_event()
1826 mwindow->undo->update_undo_before(_("mask feather"), this);
1828 // Get existing keyframe
1829 ((CWindowMaskGUI*)gui)->get_keyframe(track,
1834 #ifdef USE_KEYFRAME_SPANNING
1842 #ifdef USE_KEYFRAME_SPANNING
1843 // Create temp keyframe
1844 MaskAuto temp_keyframe(mwindow->edl, autos);
1845 temp_keyframe.copy_data(keyframe);
1847 temp_keyframe.feather = atof(get_text());
1848 // Commit change to span of keyframes
1849 autos->update_parameter(&temp_keyframe);
1851 keyframe->feather = atof(get_text());
1854 gui->update_preview();
1857 mwindow->undo->update_undo_after(_("mask feather"), LOAD_AUTOMATION);
1861 CWindowMaskValue::CWindowMaskValue(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1871 this->mwindow = mwindow;
1875 CWindowMaskValue::~CWindowMaskValue()
1879 int CWindowMaskValue::handle_event()
1887 mwindow->undo->update_undo_before(_("mask value"), this);
1888 ((CWindowMaskGUI*)gui)->get_keyframe(track,
1893 #ifdef USE_KEYFRAME_SPANNING
1901 #ifdef USE_KEYFRAME_SPANNING
1902 // Create temp keyframe
1903 MaskAuto temp_keyframe(mwindow->edl, autos);
1904 temp_keyframe.copy_data(keyframe);
1906 temp_keyframe.value = get_value();
1907 // Commit change to span of keyframes
1908 autos->update_parameter(&temp_keyframe);
1910 keyframe->value = get_value();
1914 gui->update_preview();
1915 mwindow->undo->update_undo_after(_("mask value"), LOAD_AUTOMATION);
1929 CWindowMaskGUI::CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread)
1930 : CWindowToolGUI(mwindow,
1932 _(PROGRAM_NAME ": Mask"),
1936 this->mwindow = mwindow;
1937 this->thread = thread;
1939 CWindowMaskGUI::~CWindowMaskGUI()
1941 lock_window("CWindowMaskGUI::~CWindowMaskGUI");
1947 void CWindowMaskGUI::create_objects()
1949 int x = 10, y = 10, margin = mwindow->theme->widget_border;
1950 //MaskAuto *keyframe = 0;
1951 //Track *track = mwindow->cwindow->calculate_affected_track();
1953 // keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->autos[AUTOMATION_MASK], 0);
1955 lock_window("CWindowMaskGUI::create_objects");
1957 add_subwindow(title = new BC_Title(x, y, _("Mode:")));
1958 add_subwindow(mode = new CWindowMaskMode(mwindow,
1960 x + title->get_w() + margin,
1963 mode->create_objects();
1964 y += mode->get_h() + margin;
1965 add_subwindow(title = new BC_Title(x, y, _("Value:")));
1966 add_subwindow(value = new CWindowMaskValue(mwindow, this, x + title->get_w() + margin, y));
1967 y += value->get_h() + margin;
1968 add_subwindow(delete_point = new CWindowMaskDelete(mwindow, this, x, y));
1969 y += delete_point->get_h() + margin;
1970 add_subwindow(title = new BC_Title(x, y, _("Mask number:")));
1971 number = new CWindowMaskNumber(mwindow,
1973 x + title->get_w() + margin,
1975 number->create_objects();
1976 y += number->get_h() + margin;
1977 add_subwindow(title = new BC_Title(x, y, _("Feather:")));
1978 feather = new CWindowMaskFeather(mwindow,
1980 x + title->get_w() + margin,
1982 feather->create_objects();
1983 y += feather->get_h() + margin;
1984 add_subwindow(title = new BC_Title(x, y, _("X:")));
1985 x += title->get_w() + margin;
1986 this->x = new CWindowCoord(this,
1990 this->x->create_objects();
1991 x += this->x->get_w() + margin;
1992 add_subwindow(title = new BC_Title(x, y, _("Y:")));
1993 x += title->get_w() + margin;
1994 this->y = new CWindowCoord(this,
1998 this->y->create_objects();
2001 y += this->y->get_h() + margin;
2002 add_subwindow(title = new BC_Title(x, y, _("Press Ctrl to move a point")));
2003 y += title->get_h() + margin;
2004 add_subwindow(title = new BC_Title(x, y, _("Press Alt to translate the mask")));
2005 y += title->get_h() + margin;
2006 add_subwindow(title = new BC_Title(x, y, _("Press Shift to edit bezier curve")));
2012 void CWindowMaskGUI::get_keyframe(Track* &track,
2014 MaskAuto* &keyframe,
2022 track = mwindow->cwindow->calculate_affected_track();
2025 autos = (MaskAutos*)track->automation->autos[AUTOMATION_MASK];
2026 keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(
2032 mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
2039 if(mwindow->cwindow->gui->affected_point < mask->points.total &&
2040 mwindow->cwindow->gui->affected_point >= 0)
2042 point = mask->points.values[mwindow->cwindow->gui->affected_point];
2047 void CWindowMaskGUI::update()
2054 //printf("CWindowMaskGUI::update 1\n");
2062 double position = mwindow->edl->local_session->get_selectionstart(1);
2063 position = mwindow->edl->align_to_frame(position, 0);
2066 int64_t position_i = track->to_units(position, 0);
2070 x->update(point->x);
2071 y->update(point->y);
2076 feather->update((int64_t)autos->get_feather(position_i, PLAY_FORWARD));
2077 value->update((int64_t)autos->get_value(position_i, PLAY_FORWARD));
2080 //printf("CWindowMaskGUI::update 1\n");
2082 number->update((int64_t)mwindow->edl->session->cwindow_mask);
2084 //printf("CWindowMaskGUI::update 1\n");
2087 #ifdef USE_KEYFRAME_SPANNING
2089 CWindowMaskMode::mode_to_text(keyframe->mode));
2092 CWindowMaskMode::mode_to_text(((MaskAuto*)autos->default_auto)->mode));
2095 //printf("CWindowMaskGUI::update 2\n");
2098 void CWindowMaskGUI::handle_event()
2112 mwindow->undo->update_undo_before(_("mask point"), this);
2116 #ifdef USE_KEYFRAME_SPANNING
2117 // Create temp keyframe
2118 MaskAuto temp_keyframe(mwindow->edl, autos);
2119 temp_keyframe.copy_data(keyframe);
2120 // Get affected point in temp keyframe
2121 mask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
2122 if(mwindow->cwindow->gui->affected_point < mask->points.total &&
2123 mwindow->cwindow->gui->affected_point >= 0)
2125 point = mask->points.values[mwindow->cwindow->gui->affected_point];
2130 point->x = atof(x->get_text());
2131 point->y = atof(y->get_text());
2132 // Commit to spanned keyframes
2133 autos->update_parameter(&temp_keyframe);
2136 point->x = atof(x->get_text());
2137 point->y = atof(y->get_text());
2142 mwindow->undo->update_undo_after(_("mask point"), LOAD_AUTOMATION);
2145 void CWindowMaskGUI::update_preview()
2147 mwindow->restart_brender();
2148 mwindow->sync_parameters(CHANGE_PARAMS);
2149 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
2153 mwindow->cwindow->gui->lock_window("CWindowMaskGUI::update_preview");
2154 mwindow->cwindow->gui->canvas->draw_refresh();
2155 mwindow->cwindow->gui->unlock_window();
2165 CWindowRulerGUI::CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread)
2166 : CWindowToolGUI(mwindow,
2168 _(PROGRAM_NAME ": Ruler"),
2174 CWindowRulerGUI::~CWindowRulerGUI()
2178 void CWindowRulerGUI::create_objects()
2183 lock_window("CWindowRulerGUI::create_objects");
2184 add_subwindow(title = new BC_Title(x, y, _("Current:")));
2185 add_subwindow(current = new BC_Title(x + title->get_w() + 10, y, ""));
2186 y += title->get_h() + 5;
2188 add_subwindow(title = new BC_Title(x, y, _("Point 1:")));
2189 add_subwindow(point1 = new BC_Title(x + title->get_w() + 10, y, ""));
2190 y += title->get_h() + 5;
2192 add_subwindow(title = new BC_Title(x, y, _("Point 2:")));
2193 add_subwindow(point2 = new BC_Title(x + title->get_w() + 10, y, ""));
2194 y += title->get_h() + 5;
2196 add_subwindow(title = new BC_Title(x, y, _("Distance:")));
2197 add_subwindow(distance = new BC_Title(x + title->get_w() + 10, y, ""));
2198 y += title->get_h() + 5;
2199 add_subwindow(title = new BC_Title(x, y, _("Angle:")));
2200 add_subwindow(angle = new BC_Title(x + title->get_w() + 10, y, ""));
2201 y += title->get_h() + 10;
2202 char string[BCTEXTLEN];
2203 sprintf(string, _("Press Ctrl to lock ruler to the\nnearest 45%c angle."), 0xb0);
2204 add_subwindow(title = new BC_Title(x,
2207 y += title->get_h() + 10;
2208 sprintf(string, _("Press Alt to translate the ruler."));
2209 add_subwindow(title = new BC_Title(x,
2216 void CWindowRulerGUI::update()
2218 double distance_value =
2219 sqrt(SQR(mwindow->edl->session->ruler_x2 - mwindow->edl->session->ruler_x1) +
2220 SQR(mwindow->edl->session->ruler_y2 - mwindow->edl->session->ruler_y1));
2221 double angle_value = atan((mwindow->edl->session->ruler_y2 - mwindow->edl->session->ruler_y1) /
2222 (mwindow->edl->session->ruler_x2 - mwindow->edl->session->ruler_x1)) *
2227 if(EQUIV(distance_value, 0.0))
2237 char string[BCTEXTLEN];
2238 sprintf(string, "%d, %d",
2239 mwindow->session->cwindow_output_x,
2240 mwindow->session->cwindow_output_y);
2241 current->update(string);
2242 sprintf(string, "%.0f, %.0f",
2243 mwindow->edl->session->ruler_x1,
2244 mwindow->edl->session->ruler_y1);
2245 point1->update(string);
2246 sprintf(string, "%.0f, %.0f",
2247 mwindow->edl->session->ruler_x2,
2248 mwindow->edl->session->ruler_y2);
2249 point2->update(string);
2251 sprintf(string, _("%0.01f pixels"), distance_value);
2252 distance->update(string);
2253 sprintf(string, "%0.02f %c", angle_value, 0xb0);
2254 angle->update(string);
2257 void CWindowRulerGUI::handle_event()