1 #include "automation.h"
3 #include "bezierauto.h"
4 #include "bezierautos.h"
11 #include "cwindowgui.h"
13 #include "cwindowtool.h"
14 #include "editpanel.h"
16 #include "edlsession.h"
17 #include "floatauto.h"
18 #include "floatautos.h"
20 #include "localsession.h"
21 #include "mainclock.h"
24 #include "mainsession.h"
26 #include "maskautos.h"
27 #include "meterpanel.h"
28 #include "mwindowgui.h"
31 #include "playtransport.h"
33 #include "trackcanvas.h"
35 #include "transportque.h"
41 CWindowGUI::CWindowGUI(MWindow *mwindow, CWindow *cwindow)
42 : BC_Window(PROGRAM_NAME ": Compositor",
43 mwindow->session->cwindow_x,
44 mwindow->session->cwindow_y,
45 mwindow->session->cwindow_w,
46 mwindow->session->cwindow_h,
52 BC_WindowBase::get_resources()->bg_color,
53 mwindow->edl->session->get_cwindow_display())
55 this->mwindow = mwindow;
56 this->cwindow = cwindow;
64 current_operation = CWINDOW_NONE;
69 CWindowGUI::~CWindowGUI()
71 if(tool_panel) delete tool_panel;
73 delete composite_panel;
80 int CWindowGUI::create_objects()
82 set_icon(mwindow->theme->cwindow_icon);
84 mwindow->theme->get_cwindow_sizes(this, mwindow->session->cwindow_controls);
85 mwindow->theme->draw_cwindow_bg(this);
88 // Meters required by composite panel
89 meters = new CWindowMeters(mwindow,
91 mwindow->theme->cmeter_x,
92 mwindow->theme->cmeter_y,
93 mwindow->theme->cmeter_h);
94 meters->create_objects();
97 composite_panel = new CPanel(mwindow,
99 mwindow->theme->ccomposite_x,
100 mwindow->theme->ccomposite_y,
101 mwindow->theme->ccomposite_w,
102 mwindow->theme->ccomposite_h);
103 composite_panel->create_objects();
105 canvas = new CWindowCanvas(mwindow, this);
106 canvas->create_objects(mwindow->edl);
109 add_subwindow(timebar = new CTimeBar(mwindow,
111 mwindow->theme->ctimebar_x,
112 mwindow->theme->ctimebar_y,
113 mwindow->theme->ctimebar_w,
114 mwindow->theme->ctimebar_h));
115 timebar->create_objects();
117 add_subwindow(slider = new CWindowSlider(mwindow,
119 mwindow->theme->cslider_x,
120 mwindow->theme->cslider_y,
121 mwindow->theme->cslider_w));
123 transport = new CWindowTransport(mwindow,
125 mwindow->theme->ctransport_x,
126 mwindow->theme->ctransport_y);
127 transport->create_objects();
128 transport->set_slider(slider);
130 edit_panel = new CWindowEditing(mwindow, cwindow);
131 edit_panel->set_meters(meters);
132 edit_panel->create_objects();
134 // add_subwindow(clock = new MainClock(mwindow,
135 // mwindow->theme->ctime_x,
136 // mwindow->theme->ctime_y));
138 zoom_panel = new CWindowZoom(mwindow,
140 mwindow->theme->czoom_x,
141 mwindow->theme->czoom_y);
142 zoom_panel->create_objects();
143 zoom_panel->zoom_text->add_item(new BC_MenuItem(AUTO_ZOOM));
144 if(!mwindow->edl->session->cwindow_scrollbars) zoom_panel->set_text(AUTO_ZOOM);
146 // destination = new CWindowDestination(mwindow,
148 // mwindow->theme->cdest_x,
149 // mwindow->theme->cdest_y);
150 // destination->create_objects();
152 // Must create after meter panel
153 tool_panel = new CWindowTool(mwindow, this);
154 tool_panel->Thread::start();
156 set_operation(mwindow->edl->session->cwindow_operation);
157 canvas->draw_refresh();
163 int CWindowGUI::translation_event()
165 mwindow->session->cwindow_x = get_x();
166 mwindow->session->cwindow_y = get_y();
170 int CWindowGUI::resize_event(int w, int h)
172 mwindow->session->cwindow_x = get_x();
173 mwindow->session->cwindow_y = get_y();
174 mwindow->session->cwindow_w = w;
175 mwindow->session->cwindow_h = h;
177 //printf("CWindowGUI::resize_event 1\n");
178 mwindow->theme->get_cwindow_sizes(this, mwindow->session->cwindow_controls);
179 mwindow->theme->draw_cwindow_bg(this);
182 //printf("CWindowGUI::resize_event 1\n");
183 composite_panel->reposition_buttons(mwindow->theme->ccomposite_x,
184 mwindow->theme->ccomposite_y);
185 //printf("CWindowGUI::resize_event 1\n");
187 canvas->reposition_window(mwindow->edl,
188 mwindow->theme->ccanvas_x,
189 mwindow->theme->ccanvas_y,
190 mwindow->theme->ccanvas_w,
191 mwindow->theme->ccanvas_h);
193 timebar->resize_event();
195 slider->reposition_window(mwindow->theme->cslider_x,
196 mwindow->theme->cslider_y,
197 mwindow->theme->cslider_w);
198 // Recalibrate pointer motion range
199 slider->set_position();
200 //printf("CWindowGUI::resize_event 1\n");
202 transport->reposition_buttons(mwindow->theme->ctransport_x,
203 mwindow->theme->ctransport_y);
204 //printf("CWindowGUI::resize_event 1\n");
206 edit_panel->reposition_buttons(mwindow->theme->cedit_x,
207 mwindow->theme->cedit_y);
208 //printf("CWindowGUI::resize_event 1\n");
210 // clock->reposition_window(mwindow->theme->ctime_x,
211 // mwindow->theme->ctime_y);
212 //printf("CWindowGUI::resize_event 1\n");
214 zoom_panel->reposition_window(mwindow->theme->czoom_x,
215 mwindow->theme->czoom_y);
216 //printf("CWindowGUI::resize_event 1\n");
218 // destination->reposition_window(mwindow->theme->cdest_x,
219 // mwindow->theme->cdest_y);
220 //printf("CWindowGUI::resize_event 1\n");
222 meters->reposition_window(mwindow->theme->cmeter_x,
223 mwindow->theme->cmeter_y,
224 mwindow->theme->cmeter_h);
225 //printf("CWindowGUI::resize_event 2\n");
227 BC_WindowBase::resize_event(w, h);
237 // Don't refresh the canvas in a load file operation which is going to
238 // refresh it anyway.
239 void CWindowGUI::set_operation(int value)
241 mwindow->edl->session->cwindow_operation = value;
243 composite_panel->set_operation(value);
244 edit_panel->update();
246 tool_panel->start_tool(value);
247 canvas->draw_refresh();
250 void CWindowGUI::update_tool()
252 //printf("CWindowGUI::update_tool 1\n");
253 tool_panel->update_values();
256 int CWindowGUI::close_event()
259 mwindow->session->show_cwindow = 0;
260 mwindow->gui->lock_window("CWindowGUI::close_event");
261 mwindow->gui->mainmenu->show_cwindow->set_checked(0);
262 mwindow->gui->unlock_window();
263 mwindow->save_defaults();
268 int CWindowGUI::keypress_event()
272 //printf("CWindowGUI::keypress_event 1\n");
273 switch(get_keypress())
282 //printf("CWindowGUI::keypress_event 1\n");
283 if(!result) result = transport->keypress_event();
285 //printf("CWindowGUI::keypress_event 2\n");
289 void CWindowGUI::drag_motion()
291 if(get_hidden()) return;
293 if(mwindow->session->current_operation == DRAG_ASSET ||
294 mwindow->session->current_operation == DRAG_VTRANSITION ||
295 mwindow->session->current_operation == DRAG_VEFFECT)
297 int old_status = mwindow->session->ccanvas_highlighted;
298 int cursor_x = get_relative_cursor_x();
299 int cursor_y = get_relative_cursor_y();
301 mwindow->session->ccanvas_highlighted = get_cursor_over_window() &&
302 cursor_x >= canvas->x &&
303 cursor_x < canvas->x + canvas->w &&
304 cursor_y >= canvas->y &&
305 cursor_y < canvas->y + canvas->h;
308 if(old_status != mwindow->session->ccanvas_highlighted)
309 canvas->draw_refresh();
313 int CWindowGUI::drag_stop()
316 if(get_hidden()) return 0;
318 if((mwindow->session->current_operation == DRAG_ASSET ||
319 mwindow->session->current_operation == DRAG_VTRANSITION ||
320 mwindow->session->current_operation == DRAG_VEFFECT) &&
321 mwindow->session->ccanvas_highlighted)
324 mwindow->session->ccanvas_highlighted = 0;
325 canvas->draw_refresh();
331 if(mwindow->session->current_operation == DRAG_ASSET)
333 if(mwindow->session->drag_assets->total)
335 mwindow->gui->lock_window("CWindowGUI::drag_stop 1");
336 mwindow->undo->update_undo_before(_("insert assets"),
339 mwindow->load_assets(mwindow->session->drag_assets,
340 mwindow->edl->local_session->get_selectionstart(),
342 mwindow->session->track_highlighted,
344 mwindow->edl->session->labels_follow_edits,
345 mwindow->edl->session->plugins_follow_edits);
348 if(mwindow->session->drag_clips->total)
350 mwindow->gui->lock_window("CWindowGUI::drag_stop 2");
351 mwindow->undo->update_undo_before(_("insert assets"),
354 mwindow->paste_edls(mwindow->session->drag_clips,
356 mwindow->session->track_highlighted,
357 mwindow->edl->local_session->get_selectionstart(),
358 mwindow->edl->session->labels_follow_edits,
359 mwindow->edl->session->plugins_follow_edits);
362 if(mwindow->session->drag_assets->total ||
363 mwindow->session->drag_clips->total)
365 mwindow->save_backup();
366 mwindow->restart_brender();
367 mwindow->gui->update(1, 1, 1, 1, 0, 1, 0);
368 mwindow->undo->update_undo_after();
369 mwindow->gui->unlock_window();
370 mwindow->sync_parameters(LOAD_ALL);
374 if(mwindow->session->current_operation == DRAG_VEFFECT)
376 //printf("CWindowGUI::drag_stop 1\n");
377 Track *affected_track = cwindow->calculate_affected_track();
378 //printf("CWindowGUI::drag_stop 2\n");
380 mwindow->gui->lock_window("CWindowGUI::drag_stop 3");
381 mwindow->insert_effects_cwindow(affected_track);
382 mwindow->session->current_operation = NO_OPERATION;
383 mwindow->gui->unlock_window();
386 if(mwindow->session->current_operation == DRAG_VTRANSITION)
388 Track *affected_track = cwindow->calculate_affected_track();
389 mwindow->gui->lock_window("CWindowGUI::drag_stop 4");
390 mwindow->paste_transition_cwindow(affected_track);
391 mwindow->session->current_operation = NO_OPERATION;
392 mwindow->gui->unlock_window();
399 CWindowEditing::CWindowEditing(MWindow *mwindow, CWindow *cwindow)
402 mwindow->theme->cedit_x,
403 mwindow->theme->cedit_y,
404 mwindow->edl->session->editing_mode,
421 this->mwindow = mwindow;
422 this->cwindow = cwindow;
425 void CWindowEditing::set_inpoint()
427 mwindow->set_inpoint(0);
430 void CWindowEditing::set_outpoint()
432 mwindow->set_outpoint(0);
439 CWindowMeters::CWindowMeters(MWindow *mwindow, CWindowGUI *gui, int x, int y, int h)
440 : MeterPanel(mwindow,
445 mwindow->edl->session->audio_channels,
446 mwindow->edl->session->cwindow_meter)
448 this->mwindow = mwindow;
452 CWindowMeters::~CWindowMeters()
456 int CWindowMeters::change_status_event()
458 mwindow->edl->session->cwindow_meter = use_meters;
459 mwindow->theme->get_cwindow_sizes(gui, mwindow->session->cwindow_controls);
460 gui->resize_event(gui->get_w(), gui->get_h());
466 #define MIN_ZOOM 0.25
469 CWindowZoom::CWindowZoom(MWindow *mwindow, CWindowGUI *gui, int x, int y)
472 (long)mwindow->edl->session->cwindow_zoom,
480 this->mwindow = mwindow;
484 CWindowZoom::~CWindowZoom()
488 int CWindowZoom::handle_event()
490 if(!strcasecmp(AUTO_ZOOM, get_text()))
492 mwindow->edl->session->cwindow_scrollbars = 0;
496 mwindow->edl->session->cwindow_scrollbars = 1;
499 float old_zoom = mwindow->edl->session->cwindow_zoom;
500 float new_zoom = get_value();
501 float x = gui->canvas->w / 2;
502 float y = gui->canvas->h / 2;
503 gui->canvas->canvas_to_output(mwindow->edl,
507 x -= gui->canvas->w_visible / 2 * old_zoom / new_zoom;
508 y -= gui->canvas->h_visible / 2 * old_zoom / new_zoom;
509 gui->canvas->update_zoom((int)x,
512 gui->canvas->reposition_window(mwindow->edl,
513 mwindow->theme->ccanvas_x,
514 mwindow->theme->ccanvas_y,
515 mwindow->theme->ccanvas_w,
516 mwindow->theme->ccanvas_h);
517 gui->canvas->draw_refresh();
523 CWindowSlider::CWindowSlider(MWindow *mwindow, CWindow *cwindow, int x, int y, int pixels)
524 : BC_PercentageSlider(x,
533 this->mwindow = mwindow;
534 this->cwindow = cwindow;
537 CWindowSlider::~CWindowSlider()
541 int CWindowSlider::handle_event()
544 cwindow->playback_engine->interrupt_playback(1);
545 lock_window("CWindowSlider::handle_event 1");
547 mwindow->gui->lock_window("CWindowSlider::handle_event 2");
548 mwindow->select_point((double)get_value());
549 mwindow->gui->unlock_window();
553 void CWindowSlider::set_position()
555 double new_length = mwindow->edl->tracks->total_playable_length();
556 if(mwindow->edl->local_session->preview_end <= 0 ||
557 mwindow->edl->local_session->preview_end > new_length)
558 mwindow->edl->local_session->preview_end = new_length;
559 if(mwindow->edl->local_session->preview_start >
560 mwindow->edl->local_session->preview_end)
561 mwindow->edl->local_session->preview_start = 0;
565 update(mwindow->theme->cslider_w,
566 mwindow->edl->local_session->selectionstart,
567 mwindow->edl->local_session->preview_start,
568 mwindow->edl->local_session->preview_end);
572 int CWindowSlider::increase_value()
575 cwindow->gui->transport->handle_transport(SINGLE_FRAME_FWD);
576 lock_window("CWindowSlider::increase_value");
580 int CWindowSlider::decrease_value()
583 cwindow->gui->transport->handle_transport(SINGLE_FRAME_REWIND);
584 lock_window("CWindowSlider::decrease_value");
589 // CWindowDestination::CWindowDestination(MWindow *mwindow, CWindowGUI *cwindow, int x, int y)
590 // : BC_PopupTextBox(cwindow,
591 // &cwindow->destinations,
592 // cwindow->destinations.values[cwindow->cwindow->destination]->get_text(),
598 // this->mwindow = mwindow;
599 // this->cwindow = cwindow;
602 // CWindowDestination::~CWindowDestination()
606 // int CWindowDestination::handle_event()
612 CWindowTransport::CWindowTransport(MWindow *mwindow,
616 : PlayTransport(mwindow,
624 EDL* CWindowTransport::get_edl()
629 void CWindowTransport::goto_start()
631 gui->unlock_window();
632 handle_transport(REWIND, 1);
634 mwindow->gui->lock_window("CWindowTransport::goto_start 1");
635 mwindow->goto_start();
636 mwindow->gui->unlock_window();
638 gui->lock_window("CWindowTransport::goto_start 2");
641 void CWindowTransport::goto_end()
643 gui->unlock_window();
644 handle_transport(GOTO_END, 1);
646 mwindow->gui->lock_window("CWindowTransport::goto_end 1");
648 mwindow->gui->unlock_window();
650 gui->lock_window("CWindowTransport::goto_end 2");
655 CWindowCanvas::CWindowCanvas(MWindow *mwindow, CWindowGUI *gui)
657 mwindow->theme->ccanvas_x,
658 mwindow->theme->ccanvas_y,
659 mwindow->theme->ccanvas_w,
660 mwindow->theme->ccanvas_h,
663 mwindow->edl->session->cwindow_scrollbars,
666 this->mwindow = mwindow;
670 void CWindowCanvas::update_zoom(int x, int y, float zoom)
672 use_scrollbars = mwindow->edl->session->cwindow_scrollbars;
674 mwindow->edl->session->cwindow_xscroll = x;
675 mwindow->edl->session->cwindow_yscroll = y;
676 mwindow->edl->session->cwindow_zoom = zoom;
679 int CWindowCanvas::get_xscroll()
681 return mwindow->edl->session->cwindow_xscroll;
684 int CWindowCanvas::get_yscroll()
686 return mwindow->edl->session->cwindow_yscroll;
690 float CWindowCanvas::get_zoom()
692 return mwindow->edl->session->cwindow_zoom;
695 void CWindowCanvas::draw_refresh()
697 if(!canvas->video_is_on())
699 //printf("CWindowCanvas::draw_refresh 1 %f\n", mwindow->edl->session->cwindow_zoom);
700 canvas->clear_box(0, 0, canvas->get_w(), canvas->get_h());
701 //printf("CWindowCanvas::draw_refresh 2\n");
705 int in_x, in_y, in_w, in_h, out_x, out_y, out_w, out_h;
706 //printf("CWindowCanvas::draw_refresh 3\n");
707 get_transfers(mwindow->edl,
718 // printf("CWindowCanvas::draw_refresh %d %d %d %d -> %d %d %d %d\n",
719 // in_x, in_y, in_w, in_h, out_x, out_y, out_w, out_h);
720 //canvas->clear_box(0, 0, canvas->get_w(), canvas->get_h());
723 //printf("CWindowCanvas::draw_refresh 5\n");
724 if(out_w > 0 && out_h > 0 && in_w > 0 && in_h > 0)
725 canvas->draw_vframe(refresh_frame,
735 //printf("CWindowCanvas::draw_refresh 6\n");
739 //printf("CWindowCanvas::draw_refresh 7\n");
740 canvas->clear_box(0, 0, canvas->get_w(), canvas->get_h());
741 //printf("CWindowCanvas::draw_refresh 8\n");
744 //printf("CWindowCanvas::draw_refresh 9\n");
748 //printf("CWindowCanvas::draw_refresh 10\n");
752 #define CROPHANDLE_W 10
753 #define CROPHANDLE_H 10
755 void CWindowCanvas::draw_crophandle(int x, int y)
757 canvas->draw_box(x, y, CROPHANDLE_W, CROPHANDLE_H);
762 #define FIRST_CONTROL_W 20
763 #define FIRST_CONTROL_H 20
765 #define BC_INFINITY 65536
767 #define SQR(x) ((x) * (x))
770 int CWindowCanvas::do_mask(int &redraw,
776 // Retrieve points from top recordable track
777 //printf("CWindowCanvas::do_mask 1\n");
778 Track *track = gui->cwindow->calculate_affected_track();
779 //printf("CWindowCanvas::do_mask 2\n");
782 //printf("CWindowCanvas::do_mask 3\n");
784 MaskAutos *mask_autos = track->automation->mask_autos;
785 long position = track->to_units(mwindow->edl->local_session->selectionstart,
787 ArrayList<MaskPoint*> points;
788 mask_autos->get_points(&points, mwindow->edl->session->cwindow_mask,
791 //printf("CWindowCanvas::do_mask 4\n");
793 // Translate mask to projection
794 BezierAutos *projector_autos = track->automation->projector_autos;
795 FloatAutos *projector_zooms = track->automation->pzoom_autos;
796 BezierAuto *before = 0, *after = 0;
797 FloatAuto *zoom_before = 0, *zoom_after = 0;
798 float projector_x, projector_y, projector_z;
799 // Projector zooms relative to the center of the track output.
800 float half_track_w = (float)track->track_w / 2;
801 float half_track_h = (float)track->track_h / 2;
802 projector_autos->get_center(projector_x,
809 projector_z = projector_zooms->get_value(position,
813 // printf("CWindowCanvas::do_mask 1 %f %f %f\n", projector_x,
818 // Get position of cursor relative to mask
819 float mask_cursor_x = get_cursor_x();
820 float mask_cursor_y = get_cursor_y();
821 canvas_to_output(mwindow->edl, 0, mask_cursor_x, mask_cursor_y);
823 mask_cursor_x -= projector_x;
824 mask_cursor_y -= projector_y;
825 mask_cursor_x = half_track_w + (mask_cursor_x - half_track_w) / projector_z;
826 mask_cursor_y = half_track_h + (mask_cursor_y - half_track_h) / projector_z;
831 gui->x_origin = mask_cursor_x;
832 gui->y_origin = mask_cursor_y;
836 // Points of closest line
837 int shortest_point1 = -1;
838 int shortest_point2 = -1;
840 int shortest_point = -1;
841 // Distance to closest line
842 float shortest_line_distance = BC_INFINITY;
843 // Distance to closest point
844 float shortest_point_distance = BC_INFINITY;
845 int selected_point = -1;
846 int selected_control_point = -1;
847 float selected_control_point_distance = BC_INFINITY;
848 ArrayList<int> x_points;
849 ArrayList<int> y_points;
855 canvas->set_color(WHITE);
856 canvas->set_inverse();
858 //printf("CWindowCanvas::do_mask 1 %d\n", points.total);
860 // Never draw closed polygon and a closed
861 // polygon is harder to add points to.
862 for(int i = 0; i < points.total && !result; i++)
864 MaskPoint *point1 = points.values[i];
865 MaskPoint *point2 = (i >= points.total - 1) ?
867 points.values[i + 1];
868 float x0, x1, x2, x3;
869 float y0, y1, y2, y3;
870 float old_x, old_y, x, y;
871 int segments = (int)(sqrt(SQR(point1->x - point2->x) + SQR(point1->y - point2->y)));
873 //printf("CWindowCanvas::do_mask 1 %f, %f -> %f, %f projectorz=%f\n",
874 //point1->x, point1->y, point2->x, point2->y, projector_z);
875 for(int j = 0; j <= segments && !result; j++)
877 //printf("CWindowCanvas::do_mask 1 %f, %f -> %f, %f\n", x0, y0, x3, y3);
880 x1 = point1->x + point1->control_x2;
881 y1 = point1->y + point1->control_y2;
882 x2 = point2->x + point2->control_x1;
883 y2 = point2->y + point2->control_y1;
887 float t = (float)j / segments;
889 float tpow3 = t * t * t;
891 float invtpow2 = invt * invt;
892 float invtpow3 = invt * invt * invt;
895 + 3 * t * invtpow2 * x1
896 + 3 * tpow2 * invt * x2
899 + 3 * t * invtpow2 * y1
900 + 3 * tpow2 * invt * y2
903 x = half_track_w + (x - half_track_w) * projector_z + projector_x;
904 y = half_track_h + (y - half_track_h) * projector_z + projector_y;
907 // Test new point addition
910 float line_distance =
911 sqrt(SQR(x - mask_cursor_x) + SQR(y - mask_cursor_y));
913 //printf("CWindowCanvas::do_mask 1 x=%f mask_cursor_x=%f y=%f mask_cursor_y=%f %f %f %d, %d\n",
914 //x, mask_cursor_x, y, mask_cursor_y, line_distance, shortest_line_distance, shortest_point1, shortest_point2);
915 if(line_distance < shortest_line_distance ||
918 shortest_line_distance = line_distance;
920 shortest_point2 = (i >= points.total - 1) ? 0 : (i + 1);
921 //printf("CWindowCanvas::do_mask 2 %f %f %d, %d\n", line_distance, shortest_line_distance, shortest_point1, shortest_point2);
925 float point_distance1 =
926 sqrt(SQR(point1->x - mask_cursor_x) + SQR(point1->y - mask_cursor_y));
927 float point_distance2 =
928 sqrt(SQR(point2->x - mask_cursor_x) + SQR(point2->y - mask_cursor_y));
930 if(point_distance1 < shortest_point_distance ||
933 shortest_point_distance = point_distance1;
937 if(point_distance2 < shortest_point_distance ||
940 shortest_point_distance = point_distance2;
941 shortest_point = (i >= points.total - 1) ? 0 : (i + 1);
945 output_to_canvas(mwindow->edl, 0, x, y);
948 #define TEST_BOX(cursor_x, cursor_y, target_x, target_y) \
949 (cursor_x >= target_x - CONTROL_W / 2 && \
950 cursor_x < target_x + CONTROL_W / 2 && \
951 cursor_y >= target_y - CONTROL_H / 2 && \
952 cursor_y < target_y + CONTROL_H / 2)
954 // Test existing point selection
957 float canvas_x = half_track_w + (x0 - half_track_w) * projector_z + projector_x;
958 float canvas_y = half_track_h + (y0 - half_track_h) * projector_z + projector_y;
959 int cursor_x = get_cursor_x();
960 int cursor_y = get_cursor_y();
963 if(gui->shift_down())
965 float control_x = half_track_w + (x1 - half_track_w) * projector_z + projector_x;
966 float control_y = half_track_h + (y1 - half_track_h) * projector_z + projector_y;
967 output_to_canvas(mwindow->edl, 0, control_x, control_y);
970 sqrt(SQR(control_x - cursor_x) + SQR(control_y - cursor_y));
972 if(distance < selected_control_point_distance)
975 selected_control_point = 1;
976 selected_control_point_distance = distance;
981 output_to_canvas(mwindow->edl, 0, canvas_x, canvas_y);
982 if(!gui->ctrl_down())
984 if(TEST_BOX(cursor_x, cursor_y, canvas_x, canvas_y))
991 selected_point = shortest_point;
996 canvas_x = half_track_w + (x3 - half_track_w) * projector_z + projector_x;
997 canvas_y = half_track_h + (y3 - half_track_h) * projector_z + projector_y;
998 if(gui->shift_down())
1000 float control_x = half_track_w + (x2 - half_track_w) * projector_z + projector_x;
1001 float control_y = half_track_h + (y2 - half_track_h) * projector_z + projector_y;
1002 output_to_canvas(mwindow->edl, 0, control_x, control_y);
1005 sqrt(SQR(control_x - cursor_x) + SQR(control_y - cursor_y));
1007 //printf("CWindowCanvas::do_mask %d %f %f\n", i, distance, selected_control_point_distance);
1008 if(distance < selected_control_point_distance)
1010 selected_point = (i < points.total - 1 ? i + 1 : 0);
1011 selected_control_point = 0;
1012 selected_control_point_distance = distance;
1016 if(i < points.total - 1)
1018 output_to_canvas(mwindow->edl, 0, canvas_x, canvas_y);
1019 if(!gui->ctrl_down())
1021 if(TEST_BOX(cursor_x, cursor_y, canvas_x, canvas_y))
1023 selected_point = (i < points.total - 1 ? i + 1 : 0);
1028 selected_point = shortest_point;
1037 // Draw joining line
1040 x_points.append((int)x);
1041 y_points.append((int)y);
1052 // Draw second anchor
1053 if(i < points.total - 1)
1055 if(i == gui->affected_point - 1)
1056 canvas->draw_disc((int)x - CONTROL_W / 2,
1057 (int)y - CONTROL_W / 2,
1061 canvas->draw_circle((int)x - CONTROL_W / 2,
1062 (int)y - CONTROL_W / 2,
1065 // char string[BCTEXTLEN];
1066 // sprintf(string, "%d", (i < points.total - 1 ? i + 1 : 0));
1067 // canvas->draw_text((int)x + CONTROL_W, (int)y + CONTROL_W, string);
1070 // Draw second control point. Discard x2 and y2 after this.
1071 x2 = half_track_w + (x2 - half_track_w) * projector_z + projector_x;
1072 y2 = half_track_h + (y2 - half_track_h) * projector_z + projector_y;
1073 output_to_canvas(mwindow->edl, 0, x2, y2);
1074 canvas->draw_line((int)x, (int)y, (int)x2, (int)y2);
1075 canvas->draw_rectangle((int)x2 - CONTROL_W / 2,
1076 (int)y2 - CONTROL_H / 2,
1086 // Draw first anchor
1089 canvas->draw_disc((int)x - FIRST_CONTROL_W / 2,
1090 (int)y - FIRST_CONTROL_H / 2,
1095 // Draw first control point. Discard x1 and y1 after this.
1098 x1 = half_track_w + (x1 - half_track_w) * projector_z + projector_x;
1099 y1 = half_track_h + (y1 - half_track_h) * projector_z + projector_y;
1100 output_to_canvas(mwindow->edl, 0, x1, y1);
1101 canvas->draw_line((int)x, (int)y, (int)x1, (int)y1);
1102 canvas->draw_rectangle((int)x1 - CONTROL_W / 2,
1103 (int)y1 - CONTROL_H / 2,
1107 x_points.append((int)x);
1108 y_points.append((int)y);
1111 //printf("CWindowCanvas::do_mask 1\n");
1117 //printf("CWindowCanvas::do_mask 1\n");
1121 canvas->draw_polygon(&x_points, &y_points);
1122 canvas->set_opaque();
1124 //printf("CWindowCanvas::do_mask 1\n");
1133 if(button_press && !result)
1135 gui->affected_track = gui->cwindow->calculate_affected_track();
1136 // Get current keyframe
1137 if(gui->affected_track)
1138 gui->affected_auto =
1139 gui->cwindow->calculate_affected_auto(gui->affected_track->automation->mask_autos);
1141 MaskAuto *keyframe = (MaskAuto*)gui->affected_auto;
1142 SubMask *mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
1145 // Translate entire keyframe
1146 if(gui->alt_down() && mask->points.total)
1148 gui->current_operation = CWINDOW_MASK_TRANSLATE;
1149 gui->affected_point = 0;
1152 // Existing point or control point was selected
1153 if(selected_point >= 0)
1155 gui->affected_point = selected_point;
1157 if(selected_control_point == 0)
1158 gui->current_operation = CWINDOW_MASK_CONTROL_IN;
1160 if(selected_control_point == 1)
1161 gui->current_operation = CWINDOW_MASK_CONTROL_OUT;
1163 gui->current_operation = mwindow->edl->session->cwindow_operation;
1166 // No existing point or control point was selected so create a new one
1167 if(!gui->shift_down() && !gui->alt_down())
1169 // Create the template
1170 MaskPoint *point = new MaskPoint;
1171 point->x = mask_cursor_x;
1172 point->y = mask_cursor_y;
1173 point->control_x1 = 0;
1174 point->control_y1 = 0;
1175 point->control_x2 = 0;
1176 point->control_y2 = 0;
1178 mwindow->undo->update_undo_before(_("mask point"), LOAD_AUTOMATION);
1180 if(shortest_point2 < shortest_point1)
1182 shortest_point2 ^= shortest_point1;
1183 shortest_point1 ^= shortest_point2;
1184 shortest_point2 ^= shortest_point1;
1189 // printf("CWindowGUI::do_mask 40\n");
1190 // mwindow->edl->dump();
1191 // printf("CWindowGUI::do_mask 50\n");
1195 //printf("CWindowCanvas::do_mask 1 %f %f %d %d\n",
1196 // shortest_line_distance, shortest_point_distance, shortest_point1, shortest_point2);
1197 //printf("CWindowCanvas::do_mask %d %d\n", shortest_point1, shortest_point2);
1199 // Append to end of list
1200 if(labs(shortest_point1 - shortest_point2) > 1)
1202 // Need to apply the new point to every keyframe
1203 for(MaskAuto *current = (MaskAuto*)mask_autos->default_auto;
1206 SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
1207 MaskPoint *new_point = new MaskPoint;
1208 submask->points.append(new_point);
1209 *new_point = *point;
1210 if(current == (MaskAuto*)mask_autos->default_auto)
1211 current = (MaskAuto*)mask_autos->first;
1213 current = (MaskAuto*)NEXT;
1216 gui->affected_point = mask->points.total - 1;
1220 // Insert between 2 points, shifting back point 2
1221 if(shortest_point1 >= 0 && shortest_point2 >= 0)
1223 for(MaskAuto *current = (MaskAuto*)mask_autos->default_auto;
1226 SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
1227 // In case the keyframe point count isn't synchronized with the rest of the keyframes,
1229 if(submask->points.total >= shortest_point2)
1231 MaskPoint *new_point = new MaskPoint;
1232 submask->points.append(0);
1233 for(int i = submask->points.total - 1;
1234 i > shortest_point2;
1236 submask->points.values[i] = submask->points.values[i - 1];
1237 submask->points.values[shortest_point2] = new_point;
1239 *new_point = *point;
1242 if(current == (MaskAuto*)mask_autos->default_auto)
1243 current = (MaskAuto*)mask_autos->first;
1245 current = (MaskAuto*)NEXT;
1249 gui->affected_point = shortest_point2;
1254 // printf("CWindowGUI::do_mask 20\n");
1255 // mwindow->edl->dump();
1256 // printf("CWindowGUI::do_mask 30\n");
1261 // Create the first point.
1264 //printf("CWindowCanvas::do_mask 1\n");
1265 for(MaskAuto *current = (MaskAuto*)mask_autos->default_auto;
1268 SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
1269 MaskPoint *new_point = new MaskPoint;
1270 submask->points.append(new_point);
1271 *new_point = *point;
1272 if(current == (MaskAuto*)mask_autos->default_auto)
1273 current = (MaskAuto*)mask_autos->first;
1275 current = (MaskAuto*)NEXT;
1278 //printf("CWindowCanvas::do_mask 2\n");
1279 // Create a second point if none existed before
1280 if(mask->points.total < 2)
1282 for(MaskAuto *current = (MaskAuto*)mask_autos->default_auto;
1285 SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
1286 MaskPoint *new_point = new MaskPoint;
1287 submask->points.append(new_point);
1288 *new_point = *point;
1289 if(current == (MaskAuto*)mask_autos->default_auto)
1290 current = (MaskAuto*)mask_autos->first;
1292 current = (MaskAuto*)NEXT;
1295 gui->affected_point = mask->points.total - 1;
1296 //printf("CWindowCanvas::do_mask 3 %d\n", mask->points.total);
1301 gui->current_operation = mwindow->edl->session->cwindow_operation;
1302 // Delete the template
1304 //printf("CWindowGUI::do_mask 1\n");
1305 mwindow->undo->update_undo_after();
1306 //printf("CWindowGUI::do_mask 10\n");
1315 if(button_press && result)
1317 MaskAuto *keyframe = (MaskAuto*)gui->affected_auto;
1318 SubMask *mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
1319 MaskPoint *point = mask->points.values[gui->affected_point];
1320 gui->center_x = point->x;
1321 gui->center_y = point->y;
1322 gui->control_in_x = point->control_x1;
1323 gui->control_in_y = point->control_y1;
1324 gui->control_out_x = point->control_x2;
1325 gui->control_out_y = point->control_y2;
1326 // printf("CWindowCanvas::do_mask 1 %p %p %d\n",
1327 // gui->affected_auto,
1328 // gui->affected_point,
1329 // gui->current_operation);
1332 //printf("CWindowCanvas::do_mask 8\n");
1335 MaskAuto *keyframe = (MaskAuto*)gui->affected_auto;
1336 SubMask *mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
1337 if(gui->affected_point < mask->points.total)
1339 MaskPoint *point = mask->points.values[gui->affected_point];
1340 // float cursor_x = get_cursor_x();
1341 // float cursor_y = get_cursor_y();
1342 // canvas_to_output(mwindow->edl, 0, cursor_x, cursor_y);
1343 float cursor_x = mask_cursor_x;
1344 float cursor_y = mask_cursor_y;
1345 //printf("CWindowCanvas::do_mask 9 %d %d\n", mask->points.total, gui->affected_point);
1347 float last_x = point->x;
1348 float last_y = point->y;
1349 float last_control_x1 = point->control_x1;
1350 float last_control_y1 = point->control_y1;
1351 float last_control_x2 = point->control_x2;
1352 float last_control_y2 = point->control_y2;
1355 switch(gui->current_operation)
1358 point->x = cursor_x - gui->x_origin + gui->center_x;
1359 point->y = cursor_y - gui->y_origin + gui->center_y;
1362 case CWINDOW_MASK_CONTROL_IN:
1363 point->control_x1 = cursor_x - gui->x_origin + gui->control_in_x;
1364 point->control_y1 = cursor_y - gui->y_origin + gui->control_in_y;
1367 case CWINDOW_MASK_CONTROL_OUT:
1368 point->control_x2 = cursor_x - gui->x_origin + gui->control_out_x;
1369 point->control_y2 = cursor_y - gui->y_origin + gui->control_out_y;
1372 case CWINDOW_MASK_TRANSLATE:
1373 for(int i = 0; i < mask->points.total; i++)
1375 mask->points.values[i]->x += cursor_x - gui->x_origin;
1376 mask->points.values[i]->y += cursor_y - gui->y_origin;
1378 gui->x_origin = cursor_x;
1379 gui->y_origin = cursor_y;
1384 if( !EQUIV(last_x, point->x) ||
1385 !EQUIV(last_y, point->y) ||
1386 !EQUIV(last_control_x1, point->control_x1) ||
1387 !EQUIV(last_control_y1, point->control_y1) ||
1388 !EQUIV(last_control_x2, point->control_x2) ||
1389 !EQUIV(last_control_y2, point->control_y2))
1391 mwindow->undo->update_undo_before(_("tweek"), LOAD_AUTOMATION);
1398 //printf("CWindowCanvas::do_mask 2 %d %d %d\n", result, rerender, redraw);
1400 points.remove_all_objects();
1401 //printf("CWindowCanvas::do_mask 20\n");
1405 void CWindowCanvas::draw_overlays()
1407 //printf("CWindowCanvas::draw_overlays 1\n");
1408 if(mwindow->edl->session->safe_regions)
1410 draw_safe_regions();
1413 if(mwindow->edl->session->cwindow_scrollbars)
1415 // Always draw output rectangle
1416 float x1, y1, x2, y2;
1418 x2 = mwindow->edl->session->output_w;
1420 y2 = mwindow->edl->session->output_h;
1421 output_to_canvas(mwindow->edl, 0, x1, y1);
1422 output_to_canvas(mwindow->edl, 0, x2, y2);
1424 canvas->set_inverse();
1425 canvas->set_color(WHITE);
1427 canvas->draw_rectangle((int)x1,
1432 canvas->set_opaque();
1435 if(mwindow->session->ccanvas_highlighted)
1437 canvas->set_color(WHITE);
1438 canvas->set_inverse();
1439 canvas->draw_rectangle(0, 0, canvas->get_w(), canvas->get_h());
1440 canvas->draw_rectangle(1, 1, canvas->get_w() - 2, canvas->get_h() - 2);
1441 canvas->set_opaque();
1444 int temp1 = 0, temp2 = 0;
1445 //printf("CWindowCanvas::draw_overlays 1 %d\n", mwindow->edl->session->cwindow_operation);
1446 switch(mwindow->edl->session->cwindow_operation)
1448 case CWINDOW_CAMERA:
1452 case CWINDOW_PROJECTOR:
1461 do_mask(temp1, temp2, 0, 0, 1);
1464 //printf("CWindowCanvas::draw_overlays 2\n");
1467 void CWindowCanvas::draw_safe_regions()
1469 float action_x1, action_x2, action_y1, action_y2;
1470 float title_x1, title_x2, title_y1, title_y2;
1472 action_x1 = mwindow->edl->session->output_w / 2 - mwindow->edl->session->output_w / 2 * 0.9;
1473 action_x2 = mwindow->edl->session->output_w / 2 + mwindow->edl->session->output_w / 2 * 0.9;
1474 action_y1 = mwindow->edl->session->output_h / 2 - mwindow->edl->session->output_h / 2 * 0.9;
1475 action_y2 = mwindow->edl->session->output_h / 2 + mwindow->edl->session->output_h / 2 * 0.9;
1476 title_x1 = mwindow->edl->session->output_w / 2 - mwindow->edl->session->output_w / 2 * 0.8;
1477 title_x2 = mwindow->edl->session->output_w / 2 + mwindow->edl->session->output_w / 2 * 0.8;
1478 title_y1 = mwindow->edl->session->output_h / 2 - mwindow->edl->session->output_h / 2 * 0.8;
1479 title_y2 = mwindow->edl->session->output_h / 2 + mwindow->edl->session->output_h / 2 * 0.8;
1481 output_to_canvas(mwindow->edl, 0, action_x1, action_y1);
1482 output_to_canvas(mwindow->edl, 0, action_x2, action_y2);
1483 output_to_canvas(mwindow->edl, 0, title_x1, title_y1);
1484 output_to_canvas(mwindow->edl, 0, title_x2, title_y2);
1486 canvas->set_inverse();
1487 canvas->set_color(WHITE);
1489 canvas->draw_rectangle((int)action_x1,
1491 (int)(action_x2 - action_x1),
1492 (int)(action_y2 - action_y1));
1493 canvas->draw_rectangle((int)title_x1,
1495 (int)(title_x2 - title_x1),
1496 (int)(title_y2 - title_y1));
1498 canvas->set_opaque();
1501 void CWindowCanvas::reset_keyframe(int do_camera)
1503 BezierAuto *translate_keyframe = 0;
1504 FloatAuto *zoom_keyframe = 0;
1505 Track *affected_track = 0;
1507 affected_track = gui->cwindow->calculate_affected_track();
1513 translate_keyframe = (BezierAuto*)gui->cwindow->calculate_affected_auto(
1514 affected_track->automation->camera_autos);
1515 zoom_keyframe = (FloatAuto*)gui->cwindow->calculate_affected_auto(
1516 affected_track->automation->czoom_autos);
1520 translate_keyframe = (BezierAuto*)gui->cwindow->calculate_affected_auto(
1521 affected_track->automation->projector_autos);
1522 zoom_keyframe = (FloatAuto*)gui->cwindow->calculate_affected_auto(
1523 affected_track->automation->pzoom_autos);
1526 translate_keyframe->center_x = 0;
1527 translate_keyframe->center_y = 0;
1528 translate_keyframe->center_z = 1;
1529 zoom_keyframe->value = 1;
1531 mwindow->sync_parameters(CHANGE_PARAMS);
1533 // gui->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1540 void CWindowCanvas::reset_camera()
1545 void CWindowCanvas::reset_projector()
1550 int CWindowCanvas::test_crop(int button_press, int &redraw)
1553 int handle_selected = -1;
1554 float x1 = mwindow->edl->session->crop_x1;
1555 float y1 = mwindow->edl->session->crop_y1;
1556 float x2 = mwindow->edl->session->crop_x2;
1557 float y2 = mwindow->edl->session->crop_y2;
1558 float cursor_x = get_cursor_x();
1559 float cursor_y = get_cursor_y();
1560 float canvas_x1 = x1;
1561 float canvas_y1 = y1;
1562 float canvas_x2 = x2;
1563 float canvas_y2 = y2;
1564 float canvas_cursor_x = cursor_x;
1565 float canvas_cursor_y = cursor_y;
1567 canvas_to_output(mwindow->edl, 0, cursor_x, cursor_y);
1568 // Use screen normalized coordinates for hot spot tests.
1569 output_to_canvas(mwindow->edl, 0, canvas_x1, canvas_y1);
1570 output_to_canvas(mwindow->edl, 0, canvas_x2, canvas_y2);
1573 if(gui->current_operation == CWINDOW_CROP)
1575 handle_selected = gui->crop_handle;
1578 if(canvas_cursor_x >= canvas_x1 && canvas_cursor_x < canvas_x1 + CROPHANDLE_W &&
1579 canvas_cursor_y >= canvas_y1 && canvas_cursor_y < canvas_y1 + CROPHANDLE_H)
1581 handle_selected = 0;
1582 gui->crop_origin_x = x1;
1583 gui->crop_origin_y = y1;
1586 if(canvas_cursor_x >= canvas_x2 - CROPHANDLE_W && canvas_cursor_x < canvas_x2 &&
1587 canvas_cursor_y >= canvas_y1 && canvas_cursor_y < canvas_y1 + CROPHANDLE_H)
1589 handle_selected = 1;
1590 gui->crop_origin_x = x2;
1591 gui->crop_origin_y = y1;
1594 if(canvas_cursor_x >= canvas_x1 && canvas_cursor_x < canvas_x1 + CROPHANDLE_W &&
1595 canvas_cursor_y >= canvas_y2 - CROPHANDLE_H && canvas_cursor_y < canvas_y2)
1597 handle_selected = 2;
1598 gui->crop_origin_x = x1;
1599 gui->crop_origin_y = y2;
1602 if(canvas_cursor_x >= canvas_x2 - CROPHANDLE_W && canvas_cursor_x < canvas_x2 &&
1603 canvas_cursor_y >= canvas_y2 - CROPHANDLE_H && canvas_cursor_y < canvas_y2)
1605 handle_selected = 3;
1606 gui->crop_origin_x = x2;
1607 gui->crop_origin_y = y2;
1612 gui->crop_origin_x = cursor_x;
1613 gui->crop_origin_y = cursor_y;
1616 // printf("test crop %d %d\n",
1617 // gui->current_operation,
1618 // handle_selected);
1623 gui->current_operation = CWINDOW_CROP;
1624 gui->crop_handle = handle_selected;
1625 gui->x_origin = cursor_x;
1626 gui->y_origin = cursor_y;
1629 if(handle_selected < 0)
1633 mwindow->edl->session->crop_x1 = (int)x1;
1634 mwindow->edl->session->crop_y1 = (int)y1;
1635 mwindow->edl->session->crop_x2 = (int)x2;
1636 mwindow->edl->session->crop_y2 = (int)y2;
1642 if(gui->current_operation == CWINDOW_CROP)
1644 float x_difference, y_difference;
1645 if(gui->crop_handle >= 0)
1647 float zoom_x, zoom_y, conformed_w, conformed_h;
1648 get_zooms(mwindow->edl, 0, zoom_x, zoom_y, conformed_w, conformed_h);
1649 x_difference = cursor_x - gui->x_origin;
1652 switch(gui->crop_handle)
1655 x1 = gui->crop_origin_x;
1656 y1 = gui->crop_origin_y;
1657 x2 = gui->crop_origin_x;
1658 y2 = gui->crop_origin_y;
1659 if(cursor_x < gui->x_origin)
1661 if(cursor_y < gui->y_origin)
1667 if(cursor_y >= gui->y_origin)
1674 if(cursor_x >= gui->x_origin)
1676 if(cursor_y < gui->y_origin)
1682 if(cursor_y >= gui->y_origin)
1689 // printf("test crop %d %d %d %d\n",
1690 // mwindow->edl->session->crop_x1,
1691 // mwindow->edl->session->crop_y1,
1692 // mwindow->edl->session->crop_x2,
1693 // mwindow->edl->session->crop_y2);
1696 x1 = cursor_x - gui->x_origin + gui->crop_origin_x;
1697 y1 = cursor_y - gui->y_origin + gui->crop_origin_y;
1700 x2 = cursor_x - gui->x_origin + gui->crop_origin_x;
1701 y1 = cursor_y - gui->y_origin + gui->crop_origin_y;
1704 x1 = cursor_x - gui->x_origin + gui->crop_origin_x;
1705 y2 = cursor_y - gui->y_origin + gui->crop_origin_y;
1708 x2 = cursor_x - gui->x_origin + gui->crop_origin_x;
1709 y2 = cursor_y - gui->y_origin + gui->crop_origin_y;
1713 if(!EQUIV(mwindow->edl->session->crop_x1, x1) ||
1714 !EQUIV(mwindow->edl->session->crop_x2, x2) ||
1715 !EQUIV(mwindow->edl->session->crop_y1, y1) ||
1716 !EQUIV(mwindow->edl->session->crop_y2, y2))
1723 switch (gui->crop_handle)
1725 case 0: gui->crop_handle = 1; break;
1726 case 1: gui->crop_handle = 0; break;
1727 case 2: gui->crop_handle = 3; break;
1728 case 3: gui->crop_handle = 2; break;
1738 switch (gui->crop_handle)
1740 case 0: gui->crop_handle = 2; break;
1741 case 1: gui->crop_handle = 3; break;
1742 case 2: gui->crop_handle = 0; break;
1743 case 3: gui->crop_handle = 1; break;
1748 mwindow->edl->session->crop_x1 = (int)x1;
1749 mwindow->edl->session->crop_y1 = (int)y1;
1750 mwindow->edl->session->crop_x2 = (int)x2;
1751 mwindow->edl->session->crop_y2 = (int)y2;
1757 // Update cursor font
1758 if(handle_selected >= 0)
1760 switch(handle_selected)
1763 set_cursor(UPLEFT_RESIZE);
1766 set_cursor(UPRIGHT_RESIZE);
1769 set_cursor(DOWNLEFT_RESIZE);
1772 set_cursor(DOWNRIGHT_RESIZE);
1779 set_cursor(ARROW_CURSOR);
1781 #define CLAMP(x, y, z) ((x) = ((x) < (y) ? (y) : ((x) > (z) ? (z) : (x))))
1785 CLAMP(mwindow->edl->session->crop_x1, 0, mwindow->edl->calculate_output_w(0));
1786 CLAMP(mwindow->edl->session->crop_x2, 0, mwindow->edl->calculate_output_w(0));
1787 CLAMP(mwindow->edl->session->crop_y1, 0, mwindow->edl->calculate_output_h(0));
1788 CLAMP(mwindow->edl->session->crop_y2, 0, mwindow->edl->calculate_output_h(0));
1789 // printf("CWindowCanvas::test_crop %d %d %d %d\n",
1790 // mwindow->edl->session->crop_x2,
1791 // mwindow->edl->session->crop_y2,
1792 // mwindow->edl->calculate_output_w(0),
1793 // mwindow->edl->calculate_output_h(0));
1799 void CWindowCanvas::draw_crop()
1801 canvas->set_inverse();
1802 canvas->set_color(WHITE);
1804 float x1 = mwindow->edl->session->crop_x1;
1805 float y1 = mwindow->edl->session->crop_y1;
1806 float x2 = mwindow->edl->session->crop_x2;
1807 float y2 = mwindow->edl->session->crop_y2;
1809 output_to_canvas(mwindow->edl, 0, x1, y1);
1810 output_to_canvas(mwindow->edl, 0, x2, y2);
1812 if(x2 - x1 && y2 - y1)
1813 canvas->draw_rectangle((int)x1,
1818 draw_crophandle((int)x1, (int)y1);
1819 draw_crophandle((int)x2 - CROPHANDLE_W, (int)y1);
1820 draw_crophandle((int)x1, (int)y2 - CROPHANDLE_H);
1821 draw_crophandle((int)x2 - CROPHANDLE_W, (int)y2 - CROPHANDLE_H);
1822 canvas->set_opaque();
1830 int CWindowCanvas::do_bezier_center(BezierAuto *current,
1831 BezierAutos *camera_autos,
1832 BezierAutos *projector_autos,
1833 FloatAutos *czoom_autos,
1834 FloatAutos *pzoom_autos,
1838 float center_x = 0, center_y = 0, center_z = 0;
1839 BezierAuto *before = 0, *after = 0;
1840 FloatAuto *previous = 0, *next = 0;
1841 VTrack *track = (VTrack*)current->autos->track;
1842 long position = track->to_units(
1843 mwindow->edl->local_session->selectionstart,
1846 // Get center of current frame. Draw everything relative to this.
1849 camera_autos->get_center(center_x,
1856 center_z = czoom_autos->get_value(position,
1861 float projector_x, projector_y, projector_z;
1863 projector_autos->get_center(projector_x,
1870 previous = next = 0;
1871 projector_z = pzoom_autos->get_value(position,
1876 center_x -= projector_x;
1877 center_y -= projector_y;
1878 center_z = projector_z;
1879 //printf("CWindowCanvas::do_bezier_center 1 %p %f %f\n",
1880 //current, projector_y, center_y);
1884 center_z = pzoom_autos->get_value(current->position,
1892 float auto_x = current->center_x - center_x + mwindow->edl->session->output_w / 2;
1893 float auto_y = current->center_y - center_y + mwindow->edl->session->output_h / 2;
1894 float track_x1 = auto_x - track->track_w / 2 * center_z;
1895 float track_y1 = auto_y - track->track_h / 2 * center_z;
1896 float track_x2 = track_x1 + track->track_w * center_z;
1897 float track_y2 = track_y1 + track->track_h * center_z;
1898 float control_in_x = auto_x + current->control_in_x;
1899 float control_in_y = auto_y + current->control_in_y;
1900 float control_out_x = auto_x + current->control_out_x;
1901 float control_out_y = auto_y + current->control_out_y;
1902 int control_point = 0;
1905 output_to_canvas(mwindow->edl, 0, auto_x, auto_y);
1906 output_to_canvas(mwindow->edl, 0, control_out_x, control_out_y);
1907 output_to_canvas(mwindow->edl, 0, control_in_x, control_in_y);
1908 output_to_canvas(mwindow->edl, 0, track_x1, track_y1);
1909 output_to_canvas(mwindow->edl, 0, track_x2, track_y2);
1911 #define DRAW_THING(offset) \
1912 canvas->draw_line((int)control_in_x + offset, \
1913 (int)control_in_y + offset, \
1914 (int)auto_x + offset, \
1915 (int)auto_y + offset); \
1916 canvas->draw_line((int)control_out_x + offset, \
1917 (int)control_out_y + offset, \
1918 (int)auto_x + offset, \
1919 (int)auto_y + offset); \
1920 canvas->draw_rectangle((int)control_in_x - CONTROL_W / 2 + offset, \
1921 (int)control_in_y - CONTROL_H / 2 + offset, \
1924 canvas->draw_rectangle((int)control_out_x - CONTROL_W / 2 + offset, \
1925 (int)control_out_y - CONTROL_H / 2 + offset, \
1931 canvas->draw_line((int)auto_x - BEZIER_W / 2, \
1932 (int)auto_y - BEZIER_H / 2 + offset, \
1933 (int)auto_x + BEZIER_W / 2, \
1934 (int)auto_y + BEZIER_H / 2 + offset); \
1935 canvas->draw_line((int)auto_x - BEZIER_W / 2, \
1936 (int)auto_y + BEZIER_H / 2 + offset, \
1937 (int)auto_x + BEZIER_W / 2, \
1938 (int)auto_y - BEZIER_H / 2 + offset); \
1942 canvas->draw_rectangle((int)track_x1 + offset, \
1943 (int)track_y1 + offset, \
1944 (int)(track_x2 - track_x1), \
1945 (int)(track_y2 - track_y1)); \
1946 canvas->draw_line((int)track_x1 + offset, \
1947 (int)track_y1 + offset, \
1948 (int)track_x2 + offset, \
1949 (int)track_y2 + offset); \
1950 canvas->draw_line((int)track_x2 + offset, \
1951 (int)track_y1 + offset, \
1952 (int)track_x1 + offset, \
1953 (int)track_y2 + offset); \
1959 canvas->set_color(BLACK);
1962 canvas->set_inverse();
1963 if(current->position > position)
1964 canvas->set_color(GREEN);
1966 canvas->set_color(RED);
1969 canvas->set_opaque();
1970 // printf("CWindowCanvas::do_bezier_center 2 %f,%f %f,%f\n",
1978 int cursor_x = get_cursor_x();
1979 int cursor_y = get_cursor_y();
1982 #define SQR(x) ((x) * (x))
1985 float distance1 = sqrt(SQR(cursor_x - control_in_x) +
1986 SQR(cursor_y - control_in_y));
1987 float distance2 = sqrt(SQR(cursor_x - control_out_x) +
1988 SQR(cursor_y - control_out_y));
1989 // printf("CWindowCanvas::do_bezier_center 3 %f,%f %f,%f\n",
1995 control_point = distance2 < distance1;
1998 return control_point;
2003 void CWindowCanvas::draw_bezier_joining(BezierAuto *first,
2005 BezierAutos *camera_autos,
2006 BezierAutos *projector_autos,
2007 FloatAutos *czoom_autos,
2008 FloatAutos *pzoom_autos,
2011 if(first == last) return;
2013 float center_x = 0, center_y = 0, center_z = 0;
2014 BezierAuto *before = 0, *after = 0;
2015 long position = first->autos->track->to_units(
2016 mwindow->edl->local_session->selectionstart,
2019 // Get center of current position. Draw everything relative to this.
2022 camera_autos->get_center(center_x,
2030 float projector_x, projector_y, projector_z;
2032 projector_autos->get_center(projector_x,
2040 center_x -= projector_x;
2041 center_y -= projector_y;
2044 // int segments = 10;
2045 int segments = MAX(canvas->get_w(), canvas->get_h());
2046 int step = (last->position - first->position) / segments;
2048 if(step < 1) step = 1;
2050 for(long frame = first->position;
2051 frame < last->position;
2054 float new_x, new_y, new_z;
2055 float x1, y1, x2, y2;
2057 ((BezierAutos*)(first->autos))->get_center(new_x,
2065 if(frame == first->position)
2071 x1 = old_x - center_x + mwindow->edl->session->output_w / 2;
2072 y1 = old_y - center_y + mwindow->edl->session->output_h / 2;
2073 x2 = new_x - center_x + mwindow->edl->session->output_w / 2;
2074 y2 = new_y - center_y + mwindow->edl->session->output_h / 2;
2075 output_to_canvas(mwindow->edl, 0, x1, y1);
2076 output_to_canvas(mwindow->edl, 0, x2, y2);
2079 // canvas->set_color(BLACK);
2080 // canvas->draw_line((int)x1 + 1, (int)y1 + 1, (int)x2 + 1, (int)y2 + 1);
2082 if(frame >= position)
2083 canvas->set_color(GREEN);
2085 canvas->set_color(RED);
2087 canvas->set_inverse();
2088 canvas->draw_line((int)x1, (int)y1, (int)x2, (int)y2);
2089 canvas->set_opaque();
2097 void CWindowCanvas::draw_bezier(int do_camera)
2099 Track *track = gui->cwindow->calculate_affected_track();
2100 BezierAutos *autos, *camera_autos, *projector_autos;
2101 BezierAuto *first = 0, *mid = 0, *last = 0;
2102 BezierAuto *before = 0, *after = 0;
2103 FloatAutos *czoom_autos, *pzoom_autos;
2105 // No track at initialization
2108 camera_autos = track->automation->camera_autos;
2109 projector_autos = track->automation->projector_autos;
2110 czoom_autos = track->automation->czoom_autos;
2111 pzoom_autos = track->automation->pzoom_autos;
2114 autos = track->automation->camera_autos;
2116 autos = track->automation->projector_autos;
2119 long position = track->to_units(mwindow->edl->local_session->selectionstart,
2123 // Rules for which autos to draw:
2125 // No automation besides default:
2128 // Automation on or after current position only
2129 // mid = first, last = next
2131 // Automation before current position only
2132 // mid = last, first = previous
2134 // Automation on current position only
2137 // Automation before and after current position
2138 // first = previous, mid = next, last = next->next
2140 for(first = (BezierAuto*)autos->last;
2142 first = (BezierAuto*)first->previous)
2143 if(first->position < position)
2148 mid = (BezierAuto*)first->next;
2152 first = (BezierAuto*)first->previous;
2156 mid = (BezierAuto*)autos->first;
2159 last = (BezierAuto*)mid->next;
2161 mid = (BezierAuto*)autos->default_auto;
2167 if(mid) first = (BezierAuto*)mid->previous;
2174 if(mid) last = (BezierAuto*)mid->next;
2177 //printf("draw_bezier 1 %p %p %p\n", first, mid, last);
2181 // Draw joining lines
2183 draw_bezier_joining(first,
2192 draw_bezier_joining(mid,
2200 //printf("draw_bezier 2 %p %p %p\n", first, mid, last);
2203 // Draw centers of autos
2205 do_bezier_center(first,
2213 do_bezier_center(mid,
2221 do_bezier_center(last,
2229 //printf("draw_bezier 3 %p %p %p\n", first, mid, last);
2237 int CWindowCanvas::test_bezier(int button_press,
2245 // Processing drag operation.
2246 // Create keyframe during first cursor motion.
2250 float cursor_x = get_cursor_x();
2251 float cursor_y = get_cursor_y();
2252 canvas_to_output(mwindow->edl, 0, cursor_x, cursor_y);
2254 if(gui->current_operation == CWINDOW_CAMERA ||
2255 gui->current_operation == CWINDOW_PROJECTOR)
2257 if(!gui->ctrl_down() && gui->shift_down() && !gui->translating_zoom)
2259 gui->translating_zoom = 1;
2260 gui->affected_auto = 0;
2263 if(!gui->ctrl_down() && !gui->shift_down() && gui->translating_zoom)
2265 gui->translating_zoom = 0;
2266 gui->affected_auto = 0;
2269 // Get target keyframe
2270 BezierAutos *camera_autos = gui->affected_track->automation->camera_autos;
2271 BezierAutos *projector_autos = gui->affected_track->automation->projector_autos;
2272 FloatAutos *czoom_autos = gui->affected_track->automation->czoom_autos;
2273 FloatAutos *pzoom_autos = gui->affected_track->automation->pzoom_autos;
2274 float last_center_x;
2275 float last_center_y;
2276 float last_center_z;
2279 if(!gui->affected_auto)
2281 mwindow->undo->update_undo_before(_("keyframe"), LOAD_AUTOMATION);
2282 if(mwindow->edl->session->cwindow_operation == CWINDOW_CAMERA)
2284 if(gui->translating_zoom)
2286 gui->affected_auto =
2287 gui->cwindow->calculate_affected_auto((Autos*)czoom_autos, 1);
2290 gui->affected_auto =
2291 gui->cwindow->calculate_affected_auto((Autos*)camera_autos, 1);
2294 if(mwindow->edl->session->cwindow_operation == CWINDOW_PROJECTOR)
2296 if(gui->translating_zoom)
2298 gui->affected_auto =
2299 gui->cwindow->calculate_affected_auto((Autos*)pzoom_autos, 1);
2302 gui->affected_auto =
2303 gui->cwindow->calculate_affected_auto((Autos*)projector_autos, 1);
2308 if(gui->translating_zoom)
2310 gui->center_z = ((FloatAuto*)gui->affected_auto)->value;
2314 gui->center_x = ((BezierAuto*)gui->affected_auto)->center_x;
2315 gui->center_y = ((BezierAuto*)gui->affected_auto)->center_y;
2322 BezierAuto *bezier_keyframe = (BezierAuto*)gui->affected_auto;
2323 FloatAuto *zoom_keyframe = (FloatAuto*)gui->affected_auto;
2325 if(gui->translating_zoom)
2327 last_center_z = zoom_keyframe->value;
2331 last_center_x = bezier_keyframe->center_x;
2332 last_center_y = bezier_keyframe->center_y;
2335 if(gui->translating_zoom)
2337 zoom_keyframe->value = gui->center_z + (cursor_y - gui->y_origin) / 128;
2338 if(!EQUIV(last_center_z, zoom_keyframe->value))
2340 mwindow->undo->update_undo_before(_("tweek"), LOAD_AUTOMATION);
2348 bezier_keyframe->center_x = gui->center_x + cursor_x - gui->x_origin;
2349 bezier_keyframe->center_y = gui->center_y + cursor_y - gui->y_origin;
2350 if(!EQUIV(last_center_x, bezier_keyframe->center_x) ||
2351 !EQUIV(last_center_y, bezier_keyframe->center_y))
2353 mwindow->undo->update_undo_before(_("tweek"), LOAD_AUTOMATION);
2360 if(gui->current_operation == CWINDOW_CAMERA_CONTROL_IN ||
2361 gui->current_operation == CWINDOW_PROJECTOR_CONTROL_IN)
2363 BezierAuto *bezier_keyframe = (BezierAuto*)gui->affected_auto;
2364 float last_control_in_x = bezier_keyframe->control_in_x;
2365 float last_control_in_y = bezier_keyframe->control_in_y;
2366 bezier_keyframe->control_in_x = gui->control_in_x + cursor_x - gui->x_origin;
2367 bezier_keyframe->control_in_y = gui->control_in_y + cursor_y - gui->y_origin;
2369 if(!EQUIV(last_control_in_x, bezier_keyframe->control_in_x) ||
2370 !EQUIV(last_control_in_y, bezier_keyframe->control_in_y))
2372 mwindow->undo->update_undo_before(_("tweek"), LOAD_AUTOMATION);
2378 if(gui->current_operation == CWINDOW_CAMERA_CONTROL_OUT ||
2379 gui->current_operation == CWINDOW_PROJECTOR_CONTROL_OUT)
2381 BezierAuto *bezier_keyframe = (BezierAuto*)gui->affected_auto;
2382 float last_control_out_x = bezier_keyframe->control_out_x;
2383 float last_control_out_y = bezier_keyframe->control_out_y;
2384 bezier_keyframe->control_out_x = gui->control_out_x + cursor_x - gui->x_origin;
2385 bezier_keyframe->control_out_y = gui->control_out_y + cursor_y - gui->y_origin;
2387 if(!EQUIV(last_control_out_x, bezier_keyframe->control_out_x) ||
2388 !EQUIV(last_control_out_y, bezier_keyframe->control_out_y))
2390 mwindow->undo->update_undo_before(_("tweek"), LOAD_AUTOMATION);
2399 // Begin drag operation. Don't create keyframe here.
2401 // Get affected track off of the first recordable video track.
2402 // Calculating based on the alpha channel would require rendering
2403 // each layer and its effects and trapping the result in VirtualVNode before
2404 // compositing onto the output.
2405 gui->affected_track = gui->cwindow->calculate_affected_track();
2406 gui->affected_auto = 0;
2408 if(gui->affected_track)
2410 BezierAutos *camera_autos = gui->affected_track->automation->camera_autos;
2411 BezierAutos *projector_autos = gui->affected_track->automation->projector_autos;
2412 FloatAutos *czoom_autos = gui->affected_track->automation->czoom_autos;
2413 FloatAutos *pzoom_autos = gui->affected_track->automation->pzoom_autos;
2416 if(!gui->ctrl_down())
2418 gui->current_operation =
2419 mwindow->edl->session->cwindow_operation;
2420 gui->affected_auto = 0;
2424 // Get nearest control point
2425 if(mwindow->edl->session->cwindow_operation == CWINDOW_CAMERA)
2426 gui->affected_auto =
2427 gui->cwindow->calculate_affected_auto(camera_autos, 0);
2429 if(mwindow->edl->session->cwindow_operation == CWINDOW_PROJECTOR)
2430 gui->affected_auto =
2431 gui->cwindow->calculate_affected_auto(projector_autos, 0);
2433 //printf("CWindowCanvas::test_bezier 1 %d\n", gui->current_operation);
2434 int control_point = do_bezier_center(
2435 (BezierAuto*)gui->affected_auto,
2440 mwindow->edl->session->cwindow_operation == CWINDOW_CAMERA,
2443 //printf("CWindowCanvas::test_bezier 2 %d\n", control_point);
2444 if(control_point == 0)
2446 if(mwindow->edl->session->cwindow_operation == CWINDOW_CAMERA)
2447 gui->current_operation = CWINDOW_CAMERA_CONTROL_IN;
2449 gui->current_operation = CWINDOW_PROJECTOR_CONTROL_IN;
2453 if(mwindow->edl->session->cwindow_operation == CWINDOW_CAMERA)
2454 gui->current_operation = CWINDOW_CAMERA_CONTROL_OUT;
2456 gui->current_operation = CWINDOW_PROJECTOR_CONTROL_OUT;
2459 BezierAuto *keyframe = (BezierAuto*)gui->affected_auto;
2460 gui->center_x = keyframe->center_x;
2461 gui->center_y = keyframe->center_y;
2462 gui->center_z = keyframe->center_z;
2463 gui->control_in_x = keyframe->control_in_x;
2464 gui->control_in_y = keyframe->control_in_y;
2465 gui->control_out_x = keyframe->control_out_x;
2466 gui->control_out_y = keyframe->control_out_y;
2477 int CWindowCanvas::test_zoom(int &redraw)
2480 float zoom = get_zoom();
2484 if(!mwindow->edl->session->cwindow_scrollbars)
2486 mwindow->edl->session->cwindow_scrollbars = 1;
2495 canvas_to_output(mwindow->edl,
2500 //printf("CWindowCanvas::test_zoom 1 %f %f\n", x, y);
2503 if(get_buttonpress() == 5 ||
2510 x -= w_visible * 2 / 2;
2511 y -= h_visible * 2 / 2;
2525 x -= w_visible / 2 / 2;
2526 y -= h_visible / 2 / 2;
2538 // check_boundaries(mwindow->edl, x_i, y_i, zoom);
2540 //printf("CWindowCanvas::test_zoom 2 %d %d\n", x_i, y_i);
2545 reposition_window(mwindow->edl,
2546 mwindow->theme->ccanvas_x,
2547 mwindow->theme->ccanvas_y,
2548 mwindow->theme->ccanvas_w,
2549 mwindow->theme->ccanvas_h);
2554 gui->zoom_panel->update(zoom);
2560 void CWindowCanvas::calculate_origin()
2562 gui->x_origin = get_cursor_x();
2563 gui->y_origin = get_cursor_y();
2564 //printf("CWindowCanvas::calculate_origin 1 %f %f\n", gui->x_origin, gui->y_origin);
2565 canvas_to_output(mwindow->edl, 0, gui->x_origin, gui->y_origin);
2566 //printf("CWindowCanvas::calculate_origin 2 %f %f\n", gui->x_origin, gui->y_origin);
2570 int CWindowCanvas::cursor_leave_event()
2572 set_cursor(ARROW_CURSOR);
2576 int CWindowCanvas::cursor_enter_event()
2579 switch(mwindow->edl->session->cwindow_operation)
2581 case CWINDOW_CAMERA:
2582 case CWINDOW_PROJECTOR:
2583 set_cursor(MOVE_CURSOR);
2586 set_cursor(MOVE_CURSOR);
2589 test_crop(0, redraw);
2591 case CWINDOW_PROTECT:
2592 set_cursor(ARROW_CURSOR);
2595 set_cursor(CROSS_CURSOR);
2601 int CWindowCanvas::cursor_motion_event()
2603 int redraw = 0, result = 0, rerender = 0, redraw_canvas = 0;
2606 switch(gui->current_operation)
2608 case CWINDOW_SCROLL:
2610 float zoom = get_zoom();
2611 float cursor_x = get_cursor_x();
2612 float cursor_y = get_cursor_y();
2614 float zoom_x, zoom_y, conformed_w, conformed_h;
2615 get_zooms(mwindow->edl, 0, zoom_x, zoom_y, conformed_w, conformed_h);
2616 cursor_x = (float)cursor_x / zoom_x + gui->x_offset;
2617 cursor_y = (float)cursor_y / zoom_y + gui->y_offset;
2621 int x = (int)(gui->x_origin - cursor_x + gui->x_offset);
2622 int y = (int)(gui->y_origin - cursor_y + gui->y_offset);
2627 update_scrollbars();
2633 case CWINDOW_CAMERA:
2634 case CWINDOW_CAMERA_CONTROL_IN:
2635 case CWINDOW_CAMERA_CONTROL_OUT:
2636 result = test_bezier(0, redraw, redraw_canvas, rerender, 1);
2639 case CWINDOW_PROJECTOR:
2640 case CWINDOW_PROJECTOR_CONTROL_IN:
2641 case CWINDOW_PROJECTOR_CONTROL_OUT:
2642 result = test_bezier(0, redraw, redraw_canvas, rerender, 0);
2647 //printf("CWindowCanvas::cursor_motion_event 1 %d %d\n", x, y);
2648 result = test_crop(0, redraw);
2652 case CWINDOW_MASK_CONTROL_IN:
2653 case CWINDOW_MASK_CONTROL_OUT:
2654 case CWINDOW_MASK_TRANSLATE:
2655 result = do_mask(redraw,
2667 switch(mwindow->edl->session->cwindow_operation)
2670 result = test_crop(0, redraw);
2676 // If the window is never unlocked before calling send_command the
2677 // display shouldn't get stuck on the old video frame although it will
2678 // flicker between the old video frame and the new video frame.
2688 mwindow->gui->lock_window("CWindowCanvas::cursor_motion_event 1");
2689 mwindow->gui->canvas->draw_overlays();
2690 mwindow->gui->canvas->flash();
2691 mwindow->gui->unlock_window();
2696 mwindow->restart_brender();
2697 mwindow->sync_parameters(CHANGE_PARAMS);
2698 gui->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
2702 if(!redraw) gui->update_tool();
2707 int CWindowCanvas::button_press_event()
2711 int redraw_canvas = 0;
2714 if(Canvas::button_press_event()) return 1;
2716 gui->translating_zoom = gui->shift_down();
2719 //printf("CWindowCanvas::button_press_event 2 %f %f\n", gui->x_origin, gui->y_origin, gui->x_origin, gui->y_origin);
2721 float zoom_x, zoom_y, conformed_w, conformed_h;
2722 get_zooms(mwindow->edl, 0, zoom_x, zoom_y, conformed_w, conformed_h);
2723 gui->x_offset = get_x_offset(mwindow->edl, 0, zoom_x, conformed_w, conformed_h);
2724 gui->y_offset = get_y_offset(mwindow->edl, 0, zoom_y, conformed_w, conformed_h);
2727 if(get_buttonpress() == 2)
2729 gui->current_operation = CWINDOW_SCROLL;
2735 switch(mwindow->edl->session->cwindow_operation)
2737 case CWINDOW_CAMERA:
2738 result = test_bezier(1, redraw, redraw_canvas, rerender, 1);
2741 case CWINDOW_PROJECTOR:
2742 result = test_bezier(1, redraw, redraw_canvas, rerender, 0);
2746 result = test_zoom(redraw);
2750 result = test_crop(1, redraw);
2754 if(get_buttonpress() == 1)
2755 result = do_mask(redraw, rerender, 1, 0, 0);
2766 if(rerender) /* rerendering can also be caused by press event */
2768 mwindow->restart_brender();
2769 mwindow->sync_parameters(CHANGE_PARAMS);
2770 gui->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
2774 if(!redraw) gui->update_tool();
2779 int CWindowCanvas::button_release_event()
2783 switch(gui->current_operation)
2785 case CWINDOW_SCROLL:
2790 gui->current_operation = CWINDOW_NONE;
2791 mwindow->undo->update_undo_after();
2792 //printf("CWindowCanvas::button_release_event %d\n", result);
2796 void CWindowCanvas::zoom_resize_window(float percentage)
2798 int canvas_w, canvas_h;
2799 calculate_sizes(mwindow->edl->get_aspect_ratio(),
2800 mwindow->edl->calculate_output_w(0),
2801 mwindow->edl->calculate_output_h(0),
2806 new_w = canvas_w + (gui->get_w() - mwindow->theme->ccanvas_w);
2807 new_h = canvas_h + (gui->get_h() - mwindow->theme->ccanvas_h);
2808 gui->resize_window(new_w, new_h);
2809 gui->resize_event(new_w, new_h);
2812 void CWindowCanvas::toggle_controls()
2814 mwindow->session->cwindow_controls = !mwindow->session->cwindow_controls;
2815 gui->resize_event(gui->get_w(), gui->get_h());
2818 int CWindowCanvas::get_cwindow_controls()
2820 return mwindow->session->cwindow_controls;