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"
24 #include "condition.h"
26 #include "cplayback.h"
28 #include "cwindowgui.h"
29 #include "cwindowtool.h"
31 #include "edlsession.h"
32 #include "floatauto.h"
33 #include "floatautos.h"
36 #include "localsession.h"
37 #include "mainsession.h"
40 #include "maskautos.h"
43 #include "mwindowgui.h"
46 #include "trackcanvas.h"
47 #include "transportque.h"
50 CWindowTool::CWindowTool(MWindow *mwindow, CWindowGUI *gui)
53 this->mwindow = mwindow;
57 current_tool = CWINDOW_NONE;
59 input_lock = new Condition(0, "CWindowTool::input_lock");
60 output_lock = new Condition(1, "CWindowTool::output_lock");
61 tool_gui_lock = new Mutex("CWindowTool::tool_gui_lock");
64 CWindowTool::~CWindowTool()
75 void CWindowTool::start_tool(int operation)
77 CWindowToolGUI *new_gui = 0;
80 //printf("CWindowTool::start_tool 1\n");
81 if(current_tool != operation)
83 current_tool = operation;
87 new_gui = new CWindowEyedropGUI(mwindow, this);
90 new_gui = new CWindowCropGUI(mwindow, this);
93 new_gui = new CWindowCameraGUI(mwindow, this);
95 case CWINDOW_PROJECTOR:
96 new_gui = new CWindowProjectorGUI(mwindow, this);
99 new_gui = new CWindowMaskGUI(mwindow, this);
102 new_gui = new CWindowRulerGUI(mwindow, this);
110 //printf("CWindowTool::start_tool 1\n");
116 // Wait for previous tool GUI to finish
117 output_lock->lock("CWindowTool::start_tool");
118 this->tool_gui = new_gui;
119 tool_gui->create_objects();
121 if(mwindow->edl->session->tool_window &&
122 mwindow->session->show_cwindow) tool_gui->show_window();
123 tool_gui->lock_window("CWindowTool::start_tool 1");
125 tool_gui->unlock_window();
128 // Signal thread to run next tool GUI
129 input_lock->unlock();
131 //printf("CWindowTool::start_tool 1\n");
136 tool_gui->lock_window("CWindowTool::start_tool");
138 tool_gui->unlock_window();
141 //printf("CWindowTool::start_tool 2\n");
146 void CWindowTool::stop_tool()
150 tool_gui->lock_window("CWindowTool::stop_tool");
151 tool_gui->set_done(0);
152 tool_gui->unlock_window();
156 void CWindowTool::show_tool()
158 if(tool_gui && mwindow->edl->session->tool_window)
160 tool_gui->lock_window("CWindowTool::show_tool");
161 tool_gui->show_window();
162 tool_gui->unlock_window();
166 void CWindowTool::hide_tool()
168 if(tool_gui && mwindow->edl->session->tool_window)
170 tool_gui->lock_window("CWindowTool::show_tool");
171 tool_gui->hide_window();
172 tool_gui->unlock_window();
177 void CWindowTool::run()
181 input_lock->lock("CWindowTool::run");
184 tool_gui->run_window();
185 tool_gui_lock->lock("CWindowTool::run");
188 tool_gui_lock->unlock();
190 output_lock->unlock();
194 void CWindowTool::update_show_window()
198 tool_gui->lock_window("CWindowTool::update_show_window");
200 if(mwindow->edl->session->tool_window)
203 tool_gui->show_window();
206 tool_gui->hide_window();
209 tool_gui->unlock_window();
213 void CWindowTool::raise_window()
217 gui->unlock_window();
218 tool_gui->lock_window("CWindowTool::raise_window");
219 tool_gui->raise_window();
220 tool_gui->unlock_window();
221 gui->lock_window("CWindowTool::raise_window");
225 void CWindowTool::update_values()
227 tool_gui_lock->lock("CWindowTool::update_values");
230 tool_gui->lock_window("CWindowTool::update_values");
233 tool_gui->unlock_window();
235 tool_gui_lock->unlock();
244 CWindowToolGUI::CWindowToolGUI(MWindow *mwindow,
250 mwindow->session->ctool_x,
251 mwindow->session->ctool_y,
260 this->mwindow = mwindow;
261 this->thread = thread;
262 current_operation = 0;
265 CWindowToolGUI::~CWindowToolGUI()
269 int CWindowToolGUI::close_event()
273 mwindow->edl->session->tool_window = 0;
278 thread->gui->lock_window("CWindowToolGUI::close_event");
279 thread->gui->composite_panel->set_operation(mwindow->edl->session->cwindow_operation);
280 thread->gui->flush();
281 thread->gui->unlock_window();
283 lock_window("CWindowToolGUI::close_event");
287 int CWindowToolGUI::keypress_event()
289 if(get_keypress() == 'w' || get_keypress() == 'W')
290 return close_event();
294 int CWindowToolGUI::translation_event()
296 mwindow->session->ctool_x = get_x();
297 mwindow->session->ctool_y = get_y();
306 CWindowCoord::CWindowCoord(CWindowToolGUI *gui, int x, int y, float value)
307 : BC_TumbleTextBox(gui,
318 CWindowCoord::CWindowCoord(CWindowToolGUI *gui, int x, int y, int value)
319 : BC_TumbleTextBox(gui,
329 int CWindowCoord::handle_event()
331 gui->event_caller = this;
337 CWindowCropOK::CWindowCropOK(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
338 : BC_GenericButton(x, y, _("Do it"))
340 this->mwindow = mwindow;
343 int CWindowCropOK::handle_event()
345 mwindow->crop_video();
350 int CWindowCropOK::keypress_event()
352 if(get_keypress() == 0xd)
366 CWindowCropGUI::CWindowCropGUI(MWindow *mwindow, CWindowTool *thread)
367 : CWindowToolGUI(mwindow,
369 _(PROGRAM_NAME ": Crop"),
376 CWindowCropGUI::~CWindowCropGUI()
380 void CWindowCropGUI::create_objects()
385 lock_window("CWindowCropGUI::create_objects");
387 int pad = MAX(BC_TextBox::calculate_h(this, MEDIUMFONT, 1, 1),
388 BC_Title::calculate_h(this, "X")) + 5;
389 add_subwindow(title = new BC_Title(x, y, _("X1:")));
390 column1 = MAX(column1, title->get_w());
392 add_subwindow(title = new BC_Title(x, y, _("W:")));
393 column1 = MAX(column1, title->get_w());
395 add_subwindow(new CWindowCropOK(mwindow, thread->tool_gui, x, y));
399 x1 = new CWindowCoord(thread->tool_gui, x, y, mwindow->edl->session->crop_x1);
400 x1->create_objects();
402 width = new CWindowCoord(thread->tool_gui,
405 mwindow->edl->session->crop_x2 -
406 mwindow->edl->session->crop_x1);
407 width->create_objects();
410 x += x1->get_w() + 10;
413 add_subwindow(title = new BC_Title(x, y, _("Y1:")));
414 column2 = MAX(column2, title->get_w());
416 add_subwindow(title = new BC_Title(x, y, _("H:")));
417 column2 = MAX(column2, title->get_w());
422 y1 = new CWindowCoord(thread->tool_gui, x, y, mwindow->edl->session->crop_y1);
423 y1->create_objects();
425 height = new CWindowCoord(thread->tool_gui,
428 mwindow->edl->session->crop_y2 -
429 mwindow->edl->session->crop_y1);
430 height->create_objects();
434 void CWindowCropGUI::handle_event()
437 new_x1 = atol(x1->get_text());
438 new_y1 = atol(y1->get_text());
439 if(new_x1 != mwindow->edl->session->crop_x1)
441 mwindow->edl->session->crop_x2 = new_x1 +
442 mwindow->edl->session->crop_x2 -
443 mwindow->edl->session->crop_x1;
444 mwindow->edl->session->crop_x1 = new_x1;
446 if(new_y1 != mwindow->edl->session->crop_y1)
448 mwindow->edl->session->crop_y2 = new_y1 +
449 mwindow->edl->session->crop_y2 -
450 mwindow->edl->session->crop_y1;
451 mwindow->edl->session->crop_y1 = atol(y1->get_text());
453 mwindow->edl->session->crop_x2 = atol(width->get_text()) +
454 mwindow->edl->session->crop_x1;
455 mwindow->edl->session->crop_y2 = atol(height->get_text()) +
456 mwindow->edl->session->crop_y1;
458 mwindow->cwindow->gui->lock_window("CWindowCropGUI::handle_event");
459 mwindow->cwindow->gui->canvas->draw_refresh();
460 mwindow->cwindow->gui->unlock_window();
463 void CWindowCropGUI::update()
465 x1->update((int64_t)mwindow->edl->session->crop_x1);
466 y1->update((int64_t)mwindow->edl->session->crop_y1);
467 width->update((int64_t)mwindow->edl->session->crop_x2 -
468 mwindow->edl->session->crop_x1);
469 height->update((int64_t)mwindow->edl->session->crop_y2 -
470 mwindow->edl->session->crop_y1);
478 CWindowEyedropGUI::CWindowEyedropGUI(MWindow *mwindow, CWindowTool *thread)
479 : CWindowToolGUI(mwindow,
481 _(PROGRAM_NAME ": Color"),
487 CWindowEyedropGUI::~CWindowEyedropGUI()
491 void CWindowEyedropGUI::create_objects()
493 int margin = mwindow->theme->widget_border;
497 lock_window("CWindowEyedropGUI::create_objects");
498 BC_Title *title1, *title2, *title3, *title4;
499 add_subwindow(title4 = new BC_Title(x, y, _("Radius:")));
500 y += BC_TextBox::calculate_h(this, MEDIUMFONT, 1, 1) + margin;
502 add_subwindow(title1 = new BC_Title(x, y, _("Red:")));
503 y += title1->get_h() + margin;
504 add_subwindow(title2 = new BC_Title(x, y, _("Green:")));
505 y += title2->get_h() + margin;
506 add_subwindow(title3 = new BC_Title(x, y, _("Blue:")));
509 radius = new CWindowCoord(this,
512 mwindow->edl->session->eyedrop_radius);
513 radius->create_objects();
514 radius->set_boundaries((int64_t)0, (int64_t)255);
517 add_subwindow(red = new BC_Title(x2, title1->get_y(), "0"));
518 add_subwindow(green = new BC_Title(x2, title2->get_y(), "0"));
519 add_subwindow(blue = new BC_Title(x2, title3->get_y(), "0"));
521 y = blue->get_y() + blue->get_h() + margin;
522 add_subwindow(sample = new BC_SubWindow(x, y, 50, 50));
527 void CWindowEyedropGUI::update()
529 radius->update((int64_t)mwindow->edl->session->eyedrop_radius);
531 red->update(mwindow->edl->local_session->red);
532 green->update(mwindow->edl->local_session->green);
533 blue->update(mwindow->edl->local_session->blue);
535 int red = (int)(CLIP(mwindow->edl->local_session->red, 0, 1) * 0xff);
536 int green = (int)(CLIP(mwindow->edl->local_session->green, 0, 1) * 0xff);
537 int blue = (int)(CLIP(mwindow->edl->local_session->blue, 0, 1) * 0xff);
538 sample->set_color((red << 16) | (green << 8) | blue);
539 sample->draw_box(0, 0, sample->get_w(), sample->get_h());
540 sample->set_color(BLACK);
541 sample->draw_rectangle(0, 0, sample->get_w(), sample->get_h());
545 void CWindowEyedropGUI::handle_event()
547 int new_radius = atoi(radius->get_text());
548 if(new_radius != mwindow->edl->session->eyedrop_radius)
550 CWindowGUI *gui = mwindow->cwindow->gui;
551 if(gui->eyedrop_visible)
553 gui->lock_window("CWindowEyedropGUI::handle_event");
556 gui->canvas->do_eyedrop(rerender, 0, 1);
559 mwindow->edl->session->eyedrop_radius = new_radius;
561 if(gui->eyedrop_visible)
565 gui->canvas->do_eyedrop(rerender, 0, 1);
566 gui->unlock_window();
579 CWindowCameraGUI::CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread)
580 : CWindowToolGUI(mwindow,
582 _(PROGRAM_NAME ": Camera"),
587 CWindowCameraGUI::~CWindowCameraGUI()
591 void CWindowCameraGUI::create_objects()
593 int x = 10, y = 10, x1;
594 Track *track = mwindow->cwindow->calculate_affected_track();
595 FloatAuto *x_auto = 0;
596 FloatAuto *y_auto = 0;
597 FloatAuto *z_auto = 0;
601 lock_window("CWindowCameraGUI::create_objects");
604 mwindow->cwindow->calculate_affected_autos(&x_auto,
614 add_subwindow(title = new BC_Title(x, y, _("X:")));
616 this->x = new CWindowCoord(this,
619 x_auto ? x_auto->value : (float)0);
620 this->x->create_objects();
625 add_subwindow(title = new BC_Title(x, y, _("Y:")));
627 this->y = new CWindowCoord(this,
630 y_auto ? y_auto->value : (float)0);
631 this->y->create_objects();
634 add_subwindow(title = new BC_Title(x, y, _("Z:")));
636 this->z = new CWindowCoord(this,
639 z_auto ? z_auto->value : (float)1);
640 this->z->create_objects();
641 this->z->set_increment(0.01);
645 add_subwindow(button = new CWindowCameraLeft(mwindow, this, x1, y));
646 x1 += button->get_w();
647 add_subwindow(button = new CWindowCameraCenter(mwindow, this, x1, y));
648 x1 += button->get_w();
649 add_subwindow(button = new CWindowCameraRight(mwindow, this, x1, y));
651 y += button->get_h();
653 add_subwindow(button = new CWindowCameraTop(mwindow, this, x1, y));
654 x1 += button->get_w();
655 add_subwindow(button = new CWindowCameraMiddle(mwindow, this, x1, y));
656 x1 += button->get_w();
657 add_subwindow(button = new CWindowCameraBottom(mwindow, this, x1, y));
661 void CWindowCameraGUI::update_preview()
663 mwindow->restart_brender();
664 mwindow->sync_parameters(CHANGE_PARAMS);
666 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
670 mwindow->cwindow->gui->lock_window("CWindowCameraGUI::update_preview");
671 mwindow->cwindow->gui->canvas->draw_refresh();
672 mwindow->cwindow->gui->unlock_window();
676 void CWindowCameraGUI::handle_event()
678 FloatAuto *x_auto = 0;
679 FloatAuto *y_auto = 0;
680 FloatAuto *z_auto = 0;
681 Track *track = mwindow->cwindow->calculate_affected_track();
684 mwindow->undo->update_undo_before(_("camera"), this);
685 if(event_caller == x)
687 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
688 track->automation->autos[AUTOMATION_CAMERA_X],
692 x_auto->value = atof(x->get_text());
697 if(event_caller == y)
699 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
700 track->automation->autos[AUTOMATION_CAMERA_Y],
704 y_auto->value = atof(y->get_text());
709 if(event_caller == z)
711 z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
712 track->automation->autos[AUTOMATION_CAMERA_Z],
716 float zoom = atof(z->get_text());
717 if(zoom > 10) zoom = 10;
719 if(zoom < 0) zoom = 0;
720 // Doesn't allow user to enter from scratch
721 // if(zoom != atof(z->get_text()))
724 z_auto->value = zoom;
725 mwindow->gui->lock_window("CWindowCameraGUI::handle_event");
726 mwindow->gui->draw_overlays(1);
727 mwindow->gui->unlock_window();
732 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
736 void CWindowCameraGUI::update()
738 FloatAuto *x_auto = 0;
739 FloatAuto *y_auto = 0;
740 FloatAuto *z_auto = 0;
741 Track *track = mwindow->cwindow->calculate_affected_track();
745 mwindow->cwindow->calculate_affected_autos(&x_auto,
756 x->update(x_auto->value);
758 y->update(y_auto->value);
760 z->update(z_auto->value);
763 // BezierAuto* CWindowCameraGUI::get_keyframe()
765 // BezierAuto *keyframe = 0;
766 // Track *track = mwindow->cwindow->calculate_affected_track();
768 // keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(
769 // track->automation->autos[AUTOMATION_CAMERA]);
775 CWindowCameraLeft::CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
776 : BC_Button(x, y, mwindow->theme->get_image_set("left_justify"))
779 this->mwindow = mwindow;
780 set_tooltip(_("Left justify"));
782 int CWindowCameraLeft::handle_event()
784 FloatAuto *x_auto = 0;
785 FloatAuto *z_auto = 0;
786 Track *track = mwindow->cwindow->calculate_affected_track();
789 mwindow->cwindow->calculate_affected_autos(&x_auto,
802 track->get_source_dimensions(
803 mwindow->edl->local_session->get_selectionstart(1),
809 mwindow->undo->update_undo_before(_("camera"), 0);
811 (double)track->track_w / z_auto->value / 2 -
813 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
815 gui->update_preview();
823 CWindowCameraCenter::CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
824 : BC_Button(x, y, mwindow->theme->get_image_set("center_justify"))
827 this->mwindow = mwindow;
828 set_tooltip(_("Center horizontal"));
830 int CWindowCameraCenter::handle_event()
832 FloatAuto *x_auto = 0;
833 Track *track = mwindow->cwindow->calculate_affected_track();
835 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
836 track->automation->autos[AUTOMATION_CAMERA_X],
841 mwindow->undo->update_undo_before(_("camera"), 0);
844 gui->update_preview();
845 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
852 CWindowCameraRight::CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
853 : BC_Button(x, y, mwindow->theme->get_image_set("right_justify"))
856 this->mwindow = mwindow;
857 set_tooltip(_("Right justify"));
859 int CWindowCameraRight::handle_event()
861 FloatAuto *x_auto = 0;
862 FloatAuto *z_auto = 0;
863 Track *track = mwindow->cwindow->calculate_affected_track();
866 mwindow->cwindow->calculate_affected_autos(&x_auto,
879 track->get_source_dimensions(
880 mwindow->edl->local_session->get_selectionstart(1),
886 mwindow->undo->update_undo_before(_("camera"), 0);
887 x_auto->value = -((double)track->track_w / z_auto->value / 2 -
890 gui->update_preview();
891 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
899 CWindowCameraTop::CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
900 : BC_Button(x, y, mwindow->theme->get_image_set("top_justify"))
903 this->mwindow = mwindow;
904 set_tooltip(_("Top justify"));
906 int CWindowCameraTop::handle_event()
908 FloatAuto *y_auto = 0;
909 FloatAuto *z_auto = 0;
910 Track *track = mwindow->cwindow->calculate_affected_track();
913 mwindow->cwindow->calculate_affected_autos(0,
926 track->get_source_dimensions(
927 mwindow->edl->local_session->get_selectionstart(1),
933 mwindow->undo->update_undo_before(_("camera"), 0);
934 y_auto->value = (double)track->track_h / z_auto->value / 2 -
937 gui->update_preview();
938 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
946 CWindowCameraMiddle::CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
947 : BC_Button(x, y, mwindow->theme->get_image_set("middle_justify"))
950 this->mwindow = mwindow;
951 set_tooltip(_("Center vertical"));
953 int CWindowCameraMiddle::handle_event()
955 FloatAuto *y_auto = 0;
956 Track *track = mwindow->cwindow->calculate_affected_track();
958 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
959 track->automation->autos[AUTOMATION_CAMERA_Y], 1);
963 mwindow->undo->update_undo_before(_("camera"), 0);
966 gui->update_preview();
967 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
974 CWindowCameraBottom::CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
975 : BC_Button(x, y, mwindow->theme->get_image_set("bottom_justify"))
978 this->mwindow = mwindow;
979 set_tooltip(_("Bottom justify"));
981 int CWindowCameraBottom::handle_event()
983 FloatAuto *y_auto = 0;
984 FloatAuto *z_auto = 0;
985 Track *track = mwindow->cwindow->calculate_affected_track();
988 mwindow->cwindow->calculate_affected_autos(0,
1001 track->get_source_dimensions(
1002 mwindow->edl->local_session->get_selectionstart(1),
1008 mwindow->undo->update_undo_before(_("camera"), 0);
1009 y_auto->value = -((double)track->track_h / z_auto->value / 2 -
1012 gui->update_preview();
1013 mwindow->undo->update_undo_after(_("camera"), LOAD_ALL);
1036 CWindowProjectorGUI::CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread)
1037 : CWindowToolGUI(mwindow,
1039 _(PROGRAM_NAME ": Projector"),
1044 CWindowProjectorGUI::~CWindowProjectorGUI()
1047 void CWindowProjectorGUI::create_objects()
1049 int x = 10, y = 10, x1;
1050 Track *track = mwindow->cwindow->calculate_affected_track();
1051 FloatAuto *x_auto = 0;
1052 FloatAuto *y_auto = 0;
1053 FloatAuto *z_auto = 0;
1057 lock_window("CWindowProjectorGUI::create_objects");
1060 mwindow->cwindow->calculate_affected_autos(&x_auto,
1070 add_subwindow(title = new BC_Title(x, y, _("X:")));
1071 x += title->get_w();
1072 this->x = new CWindowCoord(this,
1075 x_auto ? x_auto->value : (float)0);
1076 this->x->create_objects();
1079 add_subwindow(title = new BC_Title(x, y, _("Y:")));
1080 x += title->get_w();
1081 this->y = new CWindowCoord(this,
1084 y_auto ? y_auto->value : (float)0);
1085 this->y->create_objects();
1088 add_subwindow(title = new BC_Title(x, y, _("Z:")));
1089 x += title->get_w();
1090 this->z = new CWindowCoord(this,
1093 z_auto ? z_auto->value : (float)1);
1094 this->z->create_objects();
1095 this->z->set_increment(0.01);
1099 add_subwindow(button = new CWindowProjectorLeft(mwindow, this, x1, y));
1100 x1 += button->get_w();
1101 add_subwindow(button = new CWindowProjectorCenter(mwindow, this, x1, y));
1102 x1 += button->get_w();
1103 add_subwindow(button = new CWindowProjectorRight(mwindow, this, x1, y));
1105 y += button->get_h();
1107 add_subwindow(button = new CWindowProjectorTop(mwindow, this, x1, y));
1108 x1 += button->get_w();
1109 add_subwindow(button = new CWindowProjectorMiddle(mwindow, this, x1, y));
1110 x1 += button->get_w();
1111 add_subwindow(button = new CWindowProjectorBottom(mwindow, this, x1, y));
1115 void CWindowProjectorGUI::update_preview()
1117 mwindow->restart_brender();
1118 mwindow->sync_parameters(CHANGE_PARAMS);
1119 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1123 mwindow->cwindow->gui->lock_window("CWindowProjectorGUI::update_preview");
1124 mwindow->cwindow->gui->canvas->draw_refresh();
1125 mwindow->cwindow->gui->unlock_window();
1128 void CWindowProjectorGUI::handle_event()
1130 FloatAuto *x_auto = 0;
1131 FloatAuto *y_auto = 0;
1132 FloatAuto *z_auto = 0;
1133 Track *track = mwindow->cwindow->calculate_affected_track();
1137 mwindow->undo->update_undo_before(_("projector"), this);
1138 if(event_caller == x)
1140 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1141 track->automation->autos[AUTOMATION_PROJECTOR_X],
1145 x_auto->value = atof(x->get_text());
1150 if(event_caller == y)
1152 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1153 track->automation->autos[AUTOMATION_PROJECTOR_Y],
1157 y_auto->value = atof(y->get_text());
1162 if(event_caller == z)
1164 z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1165 track->automation->autos[AUTOMATION_PROJECTOR_Z],
1169 float zoom = atof(z->get_text());
1170 if(zoom > 10000) zoom = 10000;
1172 if(zoom < 0) zoom = 0;
1173 // if (zoom != atof(z->get_text()))
1175 z_auto->value = zoom;
1177 mwindow->gui->lock_window("CWindowProjectorGUI::handle_event");
1178 mwindow->gui->draw_overlays(1);
1179 mwindow->gui->unlock_window();
1184 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1188 void CWindowProjectorGUI::update()
1190 FloatAuto *x_auto = 0;
1191 FloatAuto *y_auto = 0;
1192 FloatAuto *z_auto = 0;
1193 Track *track = mwindow->cwindow->calculate_affected_track();
1197 mwindow->cwindow->calculate_affected_autos(&x_auto,
1208 x->update(x_auto->value);
1210 y->update(y_auto->value);
1212 z->update(z_auto->value);
1215 // BezierAuto* CWindowProjectorGUI::get_keyframe()
1217 // BezierAuto *keyframe = 0;
1218 // Track *track = mwindow->cwindow->calculate_affected_track();
1220 // keyframe = (BezierAuto*)mwindow->cwindow->calculate_affected_auto(
1221 // track->automation->autos[AUTOMATION_PROJECTOR]);
1262 CWindowProjectorLeft::CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1263 : BC_Button(x, y, mwindow->theme->get_image_set("left_justify"))
1266 this->mwindow = mwindow;
1267 set_tooltip(_("Left justify"));
1269 int CWindowProjectorLeft::handle_event()
1271 FloatAuto *x_auto = 0;
1272 FloatAuto *z_auto = 0;
1273 Track *track = mwindow->cwindow->calculate_affected_track();
1276 mwindow->cwindow->calculate_affected_autos(&x_auto,
1285 if(x_auto && z_auto)
1287 mwindow->undo->update_undo_before(_("projector"), 0);
1288 x_auto->value = (double)track->track_w * z_auto->value / 2 -
1289 (double)mwindow->edl->session->output_w / 2;
1291 gui->update_preview();
1292 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1299 CWindowProjectorCenter::CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1300 : BC_Button(x, y, mwindow->theme->get_image_set("center_justify"))
1303 this->mwindow = mwindow;
1304 set_tooltip(_("Center horizontal"));
1306 int CWindowProjectorCenter::handle_event()
1308 FloatAuto *x_auto = 0;
1309 Track *track = mwindow->cwindow->calculate_affected_track();
1311 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1312 track->automation->autos[AUTOMATION_PROJECTOR_X],
1317 mwindow->undo->update_undo_before(_("projector"), 0);
1320 gui->update_preview();
1321 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1328 CWindowProjectorRight::CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1329 : BC_Button(x, y, mwindow->theme->get_image_set("right_justify"))
1332 this->mwindow = mwindow;
1333 set_tooltip(_("Right justify"));
1335 int CWindowProjectorRight::handle_event()
1337 FloatAuto *x_auto = 0;
1338 FloatAuto *z_auto = 0;
1339 Track *track = mwindow->cwindow->calculate_affected_track();
1342 mwindow->cwindow->calculate_affected_autos(&x_auto,
1352 if(x_auto && z_auto)
1354 mwindow->undo->update_undo_before(_("projector"), 0);
1355 x_auto->value = -((double)track->track_w * z_auto->value / 2 -
1356 (double)mwindow->edl->session->output_w / 2);
1358 gui->update_preview();
1359 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1366 CWindowProjectorTop::CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1367 : BC_Button(x, y, mwindow->theme->get_image_set("top_justify"))
1370 this->mwindow = mwindow;
1371 set_tooltip(_("Top justify"));
1373 int CWindowProjectorTop::handle_event()
1375 FloatAuto *y_auto = 0;
1376 FloatAuto *z_auto = 0;
1377 Track *track = mwindow->cwindow->calculate_affected_track();
1380 mwindow->cwindow->calculate_affected_autos(0,
1390 if(y_auto && z_auto)
1392 mwindow->undo->update_undo_before(_("projector"), 0);
1393 y_auto->value = (double)track->track_h * z_auto->value / 2 -
1394 (double)mwindow->edl->session->output_h / 2;
1396 gui->update_preview();
1397 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1404 CWindowProjectorMiddle::CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1405 : BC_Button(x, y, mwindow->theme->get_image_set("middle_justify"))
1408 this->mwindow = mwindow;
1409 set_tooltip(_("Center vertical"));
1411 int CWindowProjectorMiddle::handle_event()
1413 FloatAuto *y_auto = 0;
1414 Track *track = mwindow->cwindow->calculate_affected_track();
1416 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
1417 track->automation->autos[AUTOMATION_PROJECTOR_Y], 1);
1421 mwindow->undo->update_undo_before(_("projector"), 0);
1424 gui->update_preview();
1425 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1432 CWindowProjectorBottom::CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
1433 : BC_Button(x, y, mwindow->theme->get_image_set("bottom_justify"))
1436 this->mwindow = mwindow;
1437 set_tooltip(_("Bottom justify"));
1439 int CWindowProjectorBottom::handle_event()
1441 FloatAuto *y_auto = 0;
1442 FloatAuto *z_auto = 0;
1443 Track *track = mwindow->cwindow->calculate_affected_track();
1446 mwindow->cwindow->calculate_affected_autos(0,
1456 if(y_auto && z_auto)
1458 mwindow->undo->update_undo_before(_("projector"), 0);
1459 y_auto->value = -((double)track->track_h * z_auto->value / 2 -
1460 (double)mwindow->edl->session->output_h / 2);
1462 gui->update_preview();
1463 mwindow->undo->update_undo_after(_("projector"), LOAD_ALL);
1476 CWindowMaskMode::CWindowMaskMode(MWindow *mwindow,
1477 CWindowToolGUI *gui,
1487 this->mwindow = mwindow;
1491 void CWindowMaskMode::create_objects()
1493 add_item(new BC_MenuItem(mode_to_text(MASK_MULTIPLY_ALPHA)));
1494 add_item(new BC_MenuItem(mode_to_text(MASK_SUBTRACT_ALPHA)));
1497 char* CWindowMaskMode::mode_to_text(int mode)
1501 case MASK_MULTIPLY_ALPHA:
1502 return _("Multiply alpha");
1505 case MASK_SUBTRACT_ALPHA:
1506 return _("Subtract alpha");
1510 return _("Subtract alpha");
1513 int CWindowMaskMode::text_to_mode(char *text)
1515 if(!strcasecmp(text, _("Multiply alpha")))
1516 return MASK_MULTIPLY_ALPHA;
1518 if(!strcasecmp(text, _("Subtract alpha")))
1519 return MASK_SUBTRACT_ALPHA;
1521 return MASK_SUBTRACT_ALPHA;
1524 int CWindowMaskMode::handle_event()
1531 // Get existing keyframe
1532 ((CWindowMaskGUI*)gui)->get_keyframe(track,
1540 mwindow->undo->update_undo_before(_("mask mode"), 0);
1541 #ifdef USE_KEYFRAME_SPANNING
1542 // Create temp keyframe
1543 MaskAuto temp_keyframe(mwindow->edl, autos);
1544 temp_keyframe.copy_data(keyframe);
1546 temp_keyframe.mode = text_to_mode(get_text());
1547 // Commit change to span of keyframes
1548 autos->update_parameter(&temp_keyframe);
1550 ((MaskAuto*)autos->default_auto)->mode =
1551 text_to_mode(get_text());
1553 mwindow->undo->update_undo_after(_("mask mode"), LOAD_AUTOMATION);
1556 //printf("CWindowMaskMode::handle_event 1\n");
1557 gui->update_preview();
1568 CWindowMaskDelete::CWindowMaskDelete(MWindow *mwindow,
1569 CWindowToolGUI *gui,
1572 : BC_GenericButton(x, y, _("Delete"))
1574 this->mwindow = mwindow;
1578 int CWindowMaskDelete::handle_event()
1586 // Get existing keyframe
1587 ((CWindowMaskGUI*)gui)->get_keyframe(track,
1596 mwindow->undo->update_undo_before(_("mask delete"), 0);
1598 #ifdef USE_KEYFRAME_SPANNING
1599 // Create temp keyframe
1600 MaskAuto temp_keyframe(mwindow->edl, autos);
1601 temp_keyframe.copy_data(keyframe);
1603 SubMask *submask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
1604 for(int i = mwindow->cwindow->gui->affected_point;
1605 i < submask->points.total - 1;
1608 *submask->points.values[i] = *submask->points.values[i + 1];
1611 if(submask->points.total)
1613 submask->points.remove_object(
1614 submask->points.values[submask->points.total - 1]);
1616 // Commit change to span of keyframes
1617 ((MaskAutos*)track->automation->autos[AUTOMATION_MASK])->update_parameter(&temp_keyframe);
1619 for(MaskAuto *current = (MaskAuto*)autos->default_auto;
1622 SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
1626 for(int i = mwindow->cwindow->gui->affected_point;
1627 i < submask->points.total - 1;
1630 *submask->points.values[i] = *submask->points.values[i + 1];
1633 if(submask->points.total)
1635 submask->points.remove_object(
1636 submask->points.values[submask->points.total - 1]);
1640 if(current == (MaskAuto*)autos->default_auto)
1641 current = (MaskAuto*)autos->first;
1643 current = (MaskAuto*)NEXT;
1648 gui->update_preview();
1649 mwindow->undo->update_undo_after(_("mask delete"), LOAD_AUTOMATION);
1656 int CWindowMaskDelete::keypress_event()
1658 if(get_keypress() == BACKSPACE ||
1659 get_keypress() == DELETE)
1660 return handle_event();
1665 // CWindowMaskCycleNext::CWindowMaskCycleNext(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1666 // : BC_GenericButton(x, y, _("Cycle next"))
1668 // this->mwindow = mwindow;
1671 // int CWindowMaskCycleNext::handle_event()
1673 // MaskAuto *keyframe;
1675 // MaskPoint *point;
1677 // ((CWindowMaskGUI*)gui)->get_keyframe(track,
1685 // // Should apply to all keyframes
1686 // if(keyframe && mask->points.total)
1688 // temp = mask->points.values[0];
1690 // for(int i = 0; i < mask->points.total - 1; i++)
1692 // mask->points.values[i] = mask->points.values[i + 1];
1694 // mask->points.values[mask->points.total - 1] = temp;
1696 // mwindow->cwindow->gui->affected_point--;
1697 // if(mwindow->cwindow->gui->affected_point < 0)
1698 // mwindow->cwindow->gui->affected_point = mask->points.total - 1;
1701 // gui->update_preview();
1707 // CWindowMaskCyclePrev::CWindowMaskCyclePrev(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1708 // : BC_GenericButton(x, y, _("Cycle prev"))
1710 // this->mwindow = mwindow;
1713 // int CWindowMaskCyclePrev::handle_event()
1715 // MaskAuto *keyframe;
1717 // MaskPoint *point;
1719 // ((CWindowMaskGUI*)gui)->get_keyframe(track,
1725 // // Should apply to all keyframes
1727 // if(keyframe && mask->points.total)
1729 // temp = mask->points.values[mask->points.total - 1];
1731 // for(int i = mask->points.total - 1; i > 0; i--)
1733 // mask->points.values[i] = mask->points.values[i - 1];
1735 // mask->points.values[0] = temp;
1737 // mwindow->cwindow->gui->affected_point++;
1738 // if(mwindow->cwindow->gui->affected_point >= mask->points.total)
1739 // mwindow->cwindow->gui->affected_point = 0;
1742 // gui->update_preview();
1748 CWindowMaskNumber::CWindowMaskNumber(MWindow *mwindow,
1749 CWindowToolGUI *gui,
1752 : BC_TumbleTextBox(gui,
1753 (int64_t)mwindow->edl->session->cwindow_mask,
1755 (int64_t)SUBMASKS - 1,
1760 this->mwindow = mwindow;
1764 CWindowMaskNumber::~CWindowMaskNumber()
1768 int CWindowMaskNumber::handle_event()
1770 mwindow->edl->session->cwindow_mask = atol(get_text());
1772 gui->update_preview();
1780 CWindowMaskFeather::CWindowMaskFeather(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1781 : BC_TumbleTextBox(gui,
1789 this->mwindow = mwindow;
1792 CWindowMaskFeather::~CWindowMaskFeather()
1795 int CWindowMaskFeather::handle_event()
1803 mwindow->undo->update_undo_before(_("mask feather"), this);
1805 // Get existing keyframe
1806 ((CWindowMaskGUI*)gui)->get_keyframe(track,
1811 #ifdef USE_KEYFRAME_SPANNING
1819 #ifdef USE_KEYFRAME_SPANNING
1820 // Create temp keyframe
1821 MaskAuto temp_keyframe(mwindow->edl, autos);
1822 temp_keyframe.copy_data(keyframe);
1824 temp_keyframe.feather = atof(get_text());
1825 // Commit change to span of keyframes
1826 autos->update_parameter(&temp_keyframe);
1828 keyframe->feather = atof(get_text());
1831 gui->update_preview();
1834 mwindow->undo->update_undo_after(_("mask feather"), LOAD_AUTOMATION);
1838 CWindowMaskValue::CWindowMaskValue(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
1848 this->mwindow = mwindow;
1852 CWindowMaskValue::~CWindowMaskValue()
1856 int CWindowMaskValue::handle_event()
1864 mwindow->undo->update_undo_before(_("mask value"), this);
1865 ((CWindowMaskGUI*)gui)->get_keyframe(track,
1870 #ifdef USE_KEYFRAME_SPANNING
1878 #ifdef USE_KEYFRAME_SPANNING
1879 // Create temp keyframe
1880 MaskAuto temp_keyframe(mwindow->edl, autos);
1881 temp_keyframe.copy_data(keyframe);
1883 temp_keyframe.value = get_value();
1884 // Commit change to span of keyframes
1885 autos->update_parameter(&temp_keyframe);
1887 keyframe->value = get_value();
1891 gui->update_preview();
1892 mwindow->undo->update_undo_after(_("mask value"), LOAD_AUTOMATION);
1906 CWindowMaskGUI::CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread)
1907 : CWindowToolGUI(mwindow,
1909 _(PROGRAM_NAME ": Mask"),
1913 this->mwindow = mwindow;
1914 this->thread = thread;
1916 CWindowMaskGUI::~CWindowMaskGUI()
1918 lock_window("CWindowMaskGUI::~CWindowMaskGUI");
1924 void CWindowMaskGUI::create_objects()
1926 int x = 10, y = 10, margin = mwindow->theme->widget_border;
1927 //MaskAuto *keyframe = 0;
1928 //Track *track = mwindow->cwindow->calculate_affected_track();
1930 // keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->autos[AUTOMATION_MASK], 0);
1932 lock_window("CWindowMaskGUI::create_objects");
1934 add_subwindow(title = new BC_Title(x, y, _("Mode:")));
1935 add_subwindow(mode = new CWindowMaskMode(mwindow,
1937 x + title->get_w() + margin,
1940 mode->create_objects();
1941 y += mode->get_h() + margin;
1942 add_subwindow(title = new BC_Title(x, y, _("Value:")));
1943 add_subwindow(value = new CWindowMaskValue(mwindow, this, x + title->get_w() + margin, y));
1944 y += value->get_h() + margin;
1945 add_subwindow(delete_point = new CWindowMaskDelete(mwindow, this, x, y));
1946 y += delete_point->get_h() + margin;
1947 add_subwindow(title = new BC_Title(x, y, _("Mask number:")));
1948 number = new CWindowMaskNumber(mwindow,
1950 x + title->get_w() + margin,
1952 number->create_objects();
1953 y += number->get_h() + margin;
1954 add_subwindow(title = new BC_Title(x, y, _("Feather:")));
1955 feather = new CWindowMaskFeather(mwindow,
1957 x + title->get_w() + margin,
1959 feather->create_objects();
1960 y += feather->get_h() + margin;
1961 add_subwindow(title = new BC_Title(x, y, _("X:")));
1962 x += title->get_w() + margin;
1963 this->x = new CWindowCoord(this,
1967 this->x->create_objects();
1968 x += this->x->get_w() + margin;
1969 add_subwindow(title = new BC_Title(x, y, _("Y:")));
1970 x += title->get_w() + margin;
1971 this->y = new CWindowCoord(this,
1975 this->y->create_objects();
1978 y += this->y->get_h() + margin;
1979 add_subwindow(title = new BC_Title(x, y, _("Press Ctrl to move a point")));
1980 y += title->get_h() + margin;
1981 add_subwindow(title = new BC_Title(x, y, _("Press Alt to translate the mask")));
1982 y += title->get_h() + margin;
1983 add_subwindow(title = new BC_Title(x, y, _("Press Shift to edit bezier curve")));
1989 void CWindowMaskGUI::get_keyframe(Track* &track,
1991 MaskAuto* &keyframe,
1999 track = mwindow->cwindow->calculate_affected_track();
2002 autos = (MaskAutos*)track->automation->autos[AUTOMATION_MASK];
2003 keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(
2009 mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
2016 if(mwindow->cwindow->gui->affected_point < mask->points.total &&
2017 mwindow->cwindow->gui->affected_point >= 0)
2019 point = mask->points.values[mwindow->cwindow->gui->affected_point];
2024 void CWindowMaskGUI::update()
2031 //printf("CWindowMaskGUI::update 1\n");
2039 double position = mwindow->edl->local_session->get_selectionstart(1);
2040 position = mwindow->edl->align_to_frame(position, 0);
2043 int64_t position_i = track->to_units(position, 0);
2047 x->update(point->x);
2048 y->update(point->y);
2053 feather->update((int64_t)autos->get_feather(position_i, PLAY_FORWARD));
2054 value->update((int64_t)autos->get_value(position_i, PLAY_FORWARD));
2057 //printf("CWindowMaskGUI::update 1\n");
2059 number->update((int64_t)mwindow->edl->session->cwindow_mask);
2061 //printf("CWindowMaskGUI::update 1\n");
2064 #ifdef USE_KEYFRAME_SPANNING
2066 CWindowMaskMode::mode_to_text(keyframe->mode));
2069 CWindowMaskMode::mode_to_text(((MaskAuto*)autos->default_auto)->mode));
2072 //printf("CWindowMaskGUI::update 2\n");
2075 void CWindowMaskGUI::handle_event()
2089 mwindow->undo->update_undo_before(_("mask point"), this);
2093 #ifdef USE_KEYFRAME_SPANNING
2094 // Create temp keyframe
2095 MaskAuto temp_keyframe(mwindow->edl, autos);
2096 temp_keyframe.copy_data(keyframe);
2097 // Get affected point in temp keyframe
2098 mask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
2099 if(mwindow->cwindow->gui->affected_point < mask->points.total &&
2100 mwindow->cwindow->gui->affected_point >= 0)
2102 point = mask->points.values[mwindow->cwindow->gui->affected_point];
2107 point->x = atof(x->get_text());
2108 point->y = atof(y->get_text());
2109 // Commit to spanned keyframes
2110 autos->update_parameter(&temp_keyframe);
2113 point->x = atof(x->get_text());
2114 point->y = atof(y->get_text());
2119 mwindow->undo->update_undo_after(_("mask point"), LOAD_AUTOMATION);
2122 void CWindowMaskGUI::update_preview()
2124 mwindow->restart_brender();
2125 mwindow->sync_parameters(CHANGE_PARAMS);
2126 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
2130 mwindow->cwindow->gui->lock_window("CWindowMaskGUI::update_preview");
2131 mwindow->cwindow->gui->canvas->draw_refresh();
2132 mwindow->cwindow->gui->unlock_window();
2142 CWindowRulerGUI::CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread)
2143 : CWindowToolGUI(mwindow,
2145 _(PROGRAM_NAME ": Ruler"),
2151 CWindowRulerGUI::~CWindowRulerGUI()
2155 void CWindowRulerGUI::create_objects()
2160 lock_window("CWindowRulerGUI::create_objects");
2161 add_subwindow(title = new BC_Title(x, y, _("Current:")));
2162 add_subwindow(current = new BC_Title(x + title->get_w() + 10, y, ""));
2163 y += title->get_h() + 5;
2165 add_subwindow(title = new BC_Title(x, y, _("Point 1:")));
2166 add_subwindow(point1 = new BC_Title(x + title->get_w() + 10, y, ""));
2167 y += title->get_h() + 5;
2169 add_subwindow(title = new BC_Title(x, y, _("Point 2:")));
2170 add_subwindow(point2 = new BC_Title(x + title->get_w() + 10, y, ""));
2171 y += title->get_h() + 5;
2173 add_subwindow(title = new BC_Title(x, y, _("Distance:")));
2174 add_subwindow(distance = new BC_Title(x + title->get_w() + 10, y, ""));
2175 y += title->get_h() + 5;
2176 add_subwindow(title = new BC_Title(x, y, _("Angle:")));
2177 add_subwindow(angle = new BC_Title(x + title->get_w() + 10, y, ""));
2178 y += title->get_h() + 10;
2179 char string[BCTEXTLEN];
2180 sprintf(string, _("Press Ctrl to lock ruler to the\nnearest 45%c angle."), 0xb0);
2181 add_subwindow(title = new BC_Title(x,
2184 y += title->get_h() + 10;
2185 sprintf(string, _("Press Alt to translate the ruler."));
2186 add_subwindow(title = new BC_Title(x,
2193 void CWindowRulerGUI::update()
2195 double distance_value =
2196 sqrt(SQR(mwindow->edl->session->ruler_x2 - mwindow->edl->session->ruler_x1) +
2197 SQR(mwindow->edl->session->ruler_y2 - mwindow->edl->session->ruler_y1));
2198 double angle_value = atan((mwindow->edl->session->ruler_y2 - mwindow->edl->session->ruler_y1) /
2199 (mwindow->edl->session->ruler_x2 - mwindow->edl->session->ruler_x1)) *
2204 if(EQUIV(distance_value, 0.0))
2214 char string[BCTEXTLEN];
2215 sprintf(string, "%d, %d",
2216 mwindow->session->cwindow_output_x,
2217 mwindow->session->cwindow_output_y);
2218 current->update(string);
2219 sprintf(string, "%.0f, %.0f",
2220 mwindow->edl->session->ruler_x1,
2221 mwindow->edl->session->ruler_y1);
2222 point1->update(string);
2223 sprintf(string, "%.0f, %.0f",
2224 mwindow->edl->session->ruler_x2,
2225 mwindow->edl->session->ruler_y2);
2226 point2->update(string);
2228 sprintf(string, _("%0.01f pixels"), distance_value);
2229 distance->update(string);
2230 sprintf(string, "%0.02f %c", angle_value, 0xb0);
2231 angle->update(string);
2234 void CWindowRulerGUI::handle_event()