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,
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);
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);
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 //printf("CWindowGUI::set_operation 1 %d\n", value);
242 mwindow->edl->session->cwindow_operation = value;
243 //printf("CWindowGUI::set_operation 1 %d\n", value);
245 composite_panel->set_operation(value);
246 //printf("CWindowGUI::set_operation 1 %d\n", value);
247 edit_panel->update();
249 tool_panel->start_tool(value);
250 canvas->draw_refresh();
251 //printf("CWindowGUI::set_operation 2 %d\n", value);
254 void CWindowGUI::update_tool()
256 //printf("CWindowGUI::update_tool 1\n");
257 tool_panel->update_values();
260 int CWindowGUI::close_event()
263 mwindow->session->show_cwindow = 0;
264 mwindow->gui->lock_window("CWindowGUI::close_event");
265 mwindow->gui->mainmenu->show_cwindow->set_checked(0);
266 mwindow->gui->unlock_window();
267 mwindow->save_defaults();
272 int CWindowGUI::keypress_event()
276 //printf("CWindowGUI::keypress_event 1\n");
277 switch(get_keypress())
286 //printf("CWindowGUI::keypress_event 1\n");
287 if(!result) result = transport->keypress_event();
289 //printf("CWindowGUI::keypress_event 2\n");
293 void CWindowGUI::drag_motion()
295 if(get_hidden()) return;
297 if(mwindow->session->current_operation == DRAG_ASSET ||
298 mwindow->session->current_operation == DRAG_VTRANSITION ||
299 mwindow->session->current_operation == DRAG_VEFFECT)
301 int old_status = mwindow->session->ccanvas_highlighted;
302 int cursor_x = get_relative_cursor_x();
303 int cursor_y = get_relative_cursor_y();
305 mwindow->session->ccanvas_highlighted = get_cursor_over_window() &&
306 cursor_x >= canvas->x &&
307 cursor_x < canvas->x + canvas->w &&
308 cursor_y >= canvas->y &&
309 cursor_y < canvas->y + canvas->h;
312 if(old_status != mwindow->session->ccanvas_highlighted)
313 canvas->draw_refresh();
317 int CWindowGUI::drag_stop()
320 if(get_hidden()) return 0;
322 if((mwindow->session->current_operation == DRAG_ASSET ||
323 mwindow->session->current_operation == DRAG_VTRANSITION ||
324 mwindow->session->current_operation == DRAG_VEFFECT) &&
325 mwindow->session->ccanvas_highlighted)
328 mwindow->session->ccanvas_highlighted = 0;
329 canvas->draw_refresh();
335 if(mwindow->session->current_operation == DRAG_ASSET)
337 if(mwindow->session->drag_assets->total)
339 mwindow->gui->lock_window("CWindowGUI::drag_stop 1");
340 mwindow->undo->update_undo_before(_("insert assets"),
343 mwindow->load_assets(mwindow->session->drag_assets,
344 mwindow->edl->local_session->get_selectionstart(),
346 mwindow->session->track_highlighted,
348 mwindow->edl->session->labels_follow_edits,
349 mwindow->edl->session->plugins_follow_edits);
352 if(mwindow->session->drag_clips->total)
354 mwindow->gui->lock_window("CWindowGUI::drag_stop 2");
355 mwindow->undo->update_undo_before(_("insert assets"),
358 mwindow->paste_edls(mwindow->session->drag_clips,
360 mwindow->session->track_highlighted,
361 mwindow->edl->local_session->get_selectionstart(),
362 mwindow->edl->session->labels_follow_edits,
363 mwindow->edl->session->plugins_follow_edits);
366 if(mwindow->session->drag_assets->total ||
367 mwindow->session->drag_clips->total)
369 mwindow->save_backup();
370 mwindow->restart_brender();
371 mwindow->gui->update(1, 1, 1, 1, 0, 1, 0);
372 mwindow->undo->update_undo_after();
373 mwindow->gui->unlock_window();
374 mwindow->sync_parameters(LOAD_ALL);
378 if(mwindow->session->current_operation == DRAG_VEFFECT)
380 //printf("CWindowGUI::drag_stop 1\n");
381 Track *affected_track = cwindow->calculate_affected_track();
382 //printf("CWindowGUI::drag_stop 2\n");
384 mwindow->gui->lock_window("CWindowGUI::drag_stop 3");
385 mwindow->insert_effects_cwindow(affected_track);
386 mwindow->session->current_operation = NO_OPERATION;
387 mwindow->gui->unlock_window();
390 if(mwindow->session->current_operation == DRAG_VTRANSITION)
392 Track *affected_track = cwindow->calculate_affected_track();
393 mwindow->gui->lock_window("CWindowGUI::drag_stop 4");
394 mwindow->paste_transition_cwindow(affected_track);
395 mwindow->session->current_operation = NO_OPERATION;
396 mwindow->gui->unlock_window();
403 CWindowEditing::CWindowEditing(MWindow *mwindow, CWindow *cwindow)
406 mwindow->theme->cedit_x,
407 mwindow->theme->cedit_y,
408 mwindow->edl->session->editing_mode,
425 this->mwindow = mwindow;
426 this->cwindow = cwindow;
429 void CWindowEditing::set_inpoint()
431 mwindow->set_inpoint(0);
434 void CWindowEditing::set_outpoint()
436 mwindow->set_outpoint(0);
443 CWindowMeters::CWindowMeters(MWindow *mwindow, CWindowGUI *gui, int x, int y, int h)
444 : MeterPanel(mwindow,
449 mwindow->edl->session->audio_channels,
450 mwindow->edl->session->cwindow_meter)
452 this->mwindow = mwindow;
456 CWindowMeters::~CWindowMeters()
460 int CWindowMeters::change_status_event()
462 //printf("CWindowMeters::change_status_event 1 %d\n", gui->meters->use_meters);
463 mwindow->edl->session->cwindow_meter = use_meters;
464 mwindow->theme->get_cwindow_sizes(gui);
465 gui->resize_event(gui->get_w(), gui->get_h());
471 #define MIN_ZOOM 0.25
474 CWindowZoom::CWindowZoom(MWindow *mwindow, CWindowGUI *gui, int x, int y)
477 (long)mwindow->edl->session->cwindow_zoom,
485 this->mwindow = mwindow;
489 CWindowZoom::~CWindowZoom()
493 int CWindowZoom::handle_event()
495 if(!strcasecmp(AUTO_ZOOM, get_text()))
497 mwindow->edl->session->cwindow_scrollbars = 0;
501 mwindow->edl->session->cwindow_scrollbars = 1;
504 //printf("CWindowZoom::handle_event 1 %d %d\n", gui->canvas->get_xscroll(), gui->canvas->get_yscroll());
505 gui->canvas->update_zoom(gui->canvas->get_xscroll(),
506 gui->canvas->get_yscroll(),
508 //printf("CWindowZoom::handle_event 2 %d %d\n", gui->canvas->get_xscroll(), gui->canvas->get_yscroll());
509 gui->canvas->reposition_window(mwindow->edl,
510 mwindow->theme->ccanvas_x,
511 mwindow->theme->ccanvas_y,
512 mwindow->theme->ccanvas_w,
513 mwindow->theme->ccanvas_h);
514 //printf("CWindowZoom::handle_event 3 %d %d\n", gui->canvas->get_xscroll(), gui->canvas->get_yscroll());
515 gui->canvas->draw_refresh();
516 //printf("CWindowZoom::handle_event 4 %d %d\n", gui->canvas->get_xscroll(), gui->canvas->get_yscroll());
522 CWindowSlider::CWindowSlider(MWindow *mwindow, CWindow *cwindow, int x, int y, int pixels)
523 : BC_PercentageSlider(x,
532 this->mwindow = mwindow;
533 this->cwindow = cwindow;
536 CWindowSlider::~CWindowSlider()
540 int CWindowSlider::handle_event()
543 cwindow->playback_engine->interrupt_playback(1);
544 lock_window("CWindowSlider::handle_event 1");
546 mwindow->gui->lock_window("CWindowSlider::handle_event 2");
547 mwindow->select_point((double)get_value());
548 mwindow->gui->unlock_window();
552 void CWindowSlider::set_position()
554 double new_length = mwindow->edl->tracks->total_playable_length();
555 if(mwindow->edl->local_session->preview_end <= 0 ||
556 mwindow->edl->local_session->preview_end > new_length)
557 mwindow->edl->local_session->preview_end = new_length;
558 if(mwindow->edl->local_session->preview_start >
559 mwindow->edl->local_session->preview_end)
560 mwindow->edl->local_session->preview_start = 0;
564 update(mwindow->theme->cslider_w,
565 mwindow->edl->local_session->selectionstart,
566 mwindow->edl->local_session->preview_start,
567 mwindow->edl->local_session->preview_end);
571 int CWindowSlider::increase_value()
574 cwindow->gui->transport->handle_transport(SINGLE_FRAME_FWD);
575 lock_window("CWindowSlider::increase_value");
579 int CWindowSlider::decrease_value()
582 cwindow->gui->transport->handle_transport(SINGLE_FRAME_REWIND);
583 lock_window("CWindowSlider::decrease_value");
588 // CWindowDestination::CWindowDestination(MWindow *mwindow, CWindowGUI *cwindow, int x, int y)
589 // : BC_PopupTextBox(cwindow,
590 // &cwindow->destinations,
591 // cwindow->destinations.values[cwindow->cwindow->destination]->get_text(),
597 // this->mwindow = mwindow;
598 // this->cwindow = cwindow;
601 // CWindowDestination::~CWindowDestination()
605 // int CWindowDestination::handle_event()
611 CWindowTransport::CWindowTransport(MWindow *mwindow,
615 : PlayTransport(mwindow,
623 EDL* CWindowTransport::get_edl()
628 void CWindowTransport::goto_start()
630 gui->unlock_window();
631 handle_transport(REWIND, 1);
633 mwindow->gui->lock_window("CWindowTransport::goto_start 1");
634 mwindow->goto_start();
635 mwindow->gui->unlock_window();
637 gui->lock_window("CWindowTransport::goto_start 2");
640 void CWindowTransport::goto_end()
642 gui->unlock_window();
643 handle_transport(GOTO_END, 1);
645 mwindow->gui->lock_window("CWindowTransport::goto_end 1");
647 mwindow->gui->unlock_window();
649 gui->lock_window("CWindowTransport::goto_end 2");
654 CWindowCanvas::CWindowCanvas(MWindow *mwindow, CWindowGUI *gui)
656 mwindow->theme->ccanvas_x,
657 mwindow->theme->ccanvas_y,
658 mwindow->theme->ccanvas_w,
659 mwindow->theme->ccanvas_h,
662 mwindow->edl->session->cwindow_scrollbars,
665 this->mwindow = mwindow;
669 void CWindowCanvas::update_zoom(int x, int y, float zoom)
671 use_scrollbars = mwindow->edl->session->cwindow_scrollbars;
673 mwindow->edl->session->cwindow_xscroll = x;
674 mwindow->edl->session->cwindow_yscroll = y;
675 mwindow->edl->session->cwindow_zoom = zoom;
678 int CWindowCanvas::get_xscroll()
680 return mwindow->edl->session->cwindow_xscroll;
683 int CWindowCanvas::get_yscroll()
685 return mwindow->edl->session->cwindow_yscroll;
689 float CWindowCanvas::get_zoom()
691 return mwindow->edl->session->cwindow_zoom;
694 void CWindowCanvas::draw_refresh()
696 if(!canvas->video_is_on())
698 //printf("CWindowCanvas::draw_refresh 1 %f\n", mwindow->edl->session->cwindow_zoom);
699 canvas->clear_box(0, 0, canvas->get_w(), canvas->get_h());
700 //printf("CWindowCanvas::draw_refresh 2\n");
704 int in_x, in_y, in_w, in_h, out_x, out_y, out_w, out_h;
705 //printf("CWindowCanvas::draw_refresh 3\n");
706 get_transfers(mwindow->edl,
717 // printf("CWindowCanvas::draw_refresh %d %d %d %d -> %d %d %d %d\n", in_x, in_y, in_w, in_h, out_x, out_y, out_w, out_h);
718 // canvas->clear_box(0, 0, canvas->get_w(), canvas->get_h());
721 //printf("CWindowCanvas::draw_refresh 5\n");
722 if(out_w > 0 && out_h > 0 && in_w > 0 && in_h > 0)
723 canvas->draw_vframe(refresh_frame,
733 //printf("CWindowCanvas::draw_refresh 6\n");
737 //printf("CWindowCanvas::draw_refresh 7\n");
738 canvas->clear_box(0, 0, canvas->get_w(), canvas->get_h());
739 //printf("CWindowCanvas::draw_refresh 8\n");
742 //printf("CWindowCanvas::draw_refresh 9\n");
746 //printf("CWindowCanvas::draw_refresh 10\n");
750 #define CROPHANDLE_W 10
751 #define CROPHANDLE_H 10
753 void CWindowCanvas::draw_crophandle(int x, int y)
755 canvas->draw_box(x, y, CROPHANDLE_W, CROPHANDLE_H);
760 #define FIRST_CONTROL_W 20
761 #define FIRST_CONTROL_H 20
763 #define BC_INFINITY 65536
765 #define SQR(x) ((x) * (x))
768 int CWindowCanvas::do_mask(int &redraw,
774 // Retrieve points from top recordable track
775 //printf("CWindowCanvas::do_mask 1\n");
776 Track *track = gui->cwindow->calculate_affected_track();
777 //printf("CWindowCanvas::do_mask 2\n");
780 //printf("CWindowCanvas::do_mask 3\n");
782 MaskAutos *mask_autos = track->automation->mask_autos;
783 long position = track->to_units(mwindow->edl->local_session->selectionstart,
785 ArrayList<MaskPoint*> points;
786 mask_autos->get_points(&points, mwindow->edl->session->cwindow_mask,
789 //printf("CWindowCanvas::do_mask 4\n");
791 // Translate mask to projection
792 BezierAutos *projector_autos = track->automation->projector_autos;
793 FloatAutos *projector_zooms = track->automation->pzoom_autos;
794 BezierAuto *before = 0, *after = 0;
795 FloatAuto *zoom_before = 0, *zoom_after = 0;
796 float projector_x, projector_y, projector_z;
797 // Projector zooms relative to the center of the track output.
798 float half_track_w = (float)track->track_w / 2;
799 float half_track_h = (float)track->track_h / 2;
800 projector_autos->get_center(projector_x,
807 projector_z = projector_zooms->get_value(position,
811 // printf("CWindowCanvas::do_mask 1 %f %f %f\n", projector_x,
816 // Get position of cursor relative to mask
817 float mask_cursor_x = get_cursor_x();
818 float mask_cursor_y = get_cursor_y();
819 canvas_to_output(mwindow->edl, 0, mask_cursor_x, mask_cursor_y);
821 mask_cursor_x -= projector_x;
822 mask_cursor_y -= projector_y;
823 mask_cursor_x = half_track_w + (mask_cursor_x - half_track_w) / projector_z;
824 mask_cursor_y = half_track_h + (mask_cursor_y - half_track_h) / projector_z;
829 gui->x_origin = mask_cursor_x;
830 gui->y_origin = mask_cursor_y;
834 // Points of closest line
835 int shortest_point1 = -1;
836 int shortest_point2 = -1;
838 int shortest_point = -1;
839 // Distance to closest line
840 float shortest_line_distance = BC_INFINITY;
841 // Distance to closest point
842 float shortest_point_distance = BC_INFINITY;
843 int selected_point = -1;
844 int selected_control_point = -1;
845 float selected_control_point_distance = BC_INFINITY;
846 ArrayList<int> x_points;
847 ArrayList<int> y_points;
853 canvas->set_color(WHITE);
854 canvas->set_inverse();
856 //printf("CWindowCanvas::do_mask 1 %d\n", points.total);
858 // Never draw closed polygon and a closed
859 // polygon is harder to add points to.
860 for(int i = 0; i < points.total && !result; i++)
862 MaskPoint *point1 = points.values[i];
863 MaskPoint *point2 = (i >= points.total - 1) ?
865 points.values[i + 1];
866 float x0, x1, x2, x3;
867 float y0, y1, y2, y3;
868 float old_x, old_y, x, y;
869 int segments = (int)(sqrt(SQR(point1->x - point2->x) + SQR(point1->y - point2->y)));
871 //printf("CWindowCanvas::do_mask 1 %f, %f -> %f, %f projectorz=%f\n",
872 //point1->x, point1->y, point2->x, point2->y, projector_z);
873 for(int j = 0; j <= segments && !result; j++)
875 //printf("CWindowCanvas::do_mask 1 %f, %f -> %f, %f\n", x0, y0, x3, y3);
878 x1 = point1->x + point1->control_x2;
879 y1 = point1->y + point1->control_y2;
880 x2 = point2->x + point2->control_x1;
881 y2 = point2->y + point2->control_y1;
885 float t = (float)j / segments;
887 float tpow3 = t * t * t;
889 float invtpow2 = invt * invt;
890 float invtpow3 = invt * invt * invt;
893 + 3 * t * invtpow2 * x1
894 + 3 * tpow2 * invt * x2
897 + 3 * t * invtpow2 * y1
898 + 3 * tpow2 * invt * y2
901 x = half_track_w + (x - half_track_w) * projector_z + projector_x;
902 y = half_track_h + (y - half_track_h) * projector_z + projector_y;
905 // Test new point addition
908 float line_distance =
909 sqrt(SQR(x - mask_cursor_x) + SQR(y - mask_cursor_y));
911 //printf("CWindowCanvas::do_mask 1 x=%f mask_cursor_x=%f y=%f mask_cursor_y=%f %f %f %d, %d\n",
912 //x, mask_cursor_x, y, mask_cursor_y, line_distance, shortest_line_distance, shortest_point1, shortest_point2);
913 if(line_distance < shortest_line_distance ||
916 shortest_line_distance = line_distance;
918 shortest_point2 = (i >= points.total - 1) ? 0 : (i + 1);
919 //printf("CWindowCanvas::do_mask 2 %f %f %d, %d\n", line_distance, shortest_line_distance, shortest_point1, shortest_point2);
923 float point_distance1 =
924 sqrt(SQR(point1->x - mask_cursor_x) + SQR(point1->y - mask_cursor_y));
925 float point_distance2 =
926 sqrt(SQR(point2->x - mask_cursor_x) + SQR(point2->y - mask_cursor_y));
928 if(point_distance1 < shortest_point_distance ||
931 shortest_point_distance = point_distance1;
935 if(point_distance2 < shortest_point_distance ||
938 shortest_point_distance = point_distance2;
939 shortest_point = (i >= points.total - 1) ? 0 : (i + 1);
943 output_to_canvas(mwindow->edl, 0, x, y);
946 #define TEST_BOX(cursor_x, cursor_y, target_x, target_y) \
947 (cursor_x >= target_x - CONTROL_W / 2 && \
948 cursor_x < target_x + CONTROL_W / 2 && \
949 cursor_y >= target_y - CONTROL_H / 2 && \
950 cursor_y < target_y + CONTROL_H / 2)
952 // Test existing point selection
955 float canvas_x = half_track_w + (x0 - half_track_w) * projector_z + projector_x;
956 float canvas_y = half_track_h + (y0 - half_track_h) * projector_z + projector_y;
957 int cursor_x = get_cursor_x();
958 int cursor_y = get_cursor_y();
961 if(gui->shift_down())
963 float control_x = half_track_w + (x1 - half_track_w) * projector_z + projector_x;
964 float control_y = half_track_h + (y1 - half_track_h) * projector_z + projector_y;
965 output_to_canvas(mwindow->edl, 0, control_x, control_y);
968 sqrt(SQR(control_x - cursor_x) + SQR(control_y - cursor_y));
970 if(distance < selected_control_point_distance)
973 selected_control_point = 1;
974 selected_control_point_distance = distance;
979 output_to_canvas(mwindow->edl, 0, canvas_x, canvas_y);
980 if(!gui->ctrl_down())
982 if(TEST_BOX(cursor_x, cursor_y, canvas_x, canvas_y))
989 selected_point = shortest_point;
994 canvas_x = half_track_w + (x3 - half_track_w) * projector_z + projector_x;
995 canvas_y = half_track_h + (y3 - half_track_h) * projector_z + projector_y;
996 if(gui->shift_down())
998 float control_x = half_track_w + (x2 - half_track_w) * projector_z + projector_x;
999 float control_y = half_track_h + (y2 - half_track_h) * projector_z + projector_y;
1000 output_to_canvas(mwindow->edl, 0, control_x, control_y);
1003 sqrt(SQR(control_x - cursor_x) + SQR(control_y - cursor_y));
1005 //printf("CWindowCanvas::do_mask %d %f %f\n", i, distance, selected_control_point_distance);
1006 if(distance < selected_control_point_distance)
1008 selected_point = (i < points.total - 1 ? i + 1 : 0);
1009 selected_control_point = 0;
1010 selected_control_point_distance = distance;
1014 if(i < points.total - 1)
1016 output_to_canvas(mwindow->edl, 0, canvas_x, canvas_y);
1017 if(!gui->ctrl_down())
1019 if(TEST_BOX(cursor_x, cursor_y, canvas_x, canvas_y))
1021 selected_point = (i < points.total - 1 ? i + 1 : 0);
1026 selected_point = shortest_point;
1035 // Draw joining line
1038 x_points.append((int)x);
1039 y_points.append((int)y);
1050 // Draw second anchor
1051 if(i < points.total - 1)
1053 if(i == gui->affected_point - 1)
1054 canvas->draw_disc((int)x - CONTROL_W / 2,
1055 (int)y - CONTROL_W / 2,
1059 canvas->draw_circle((int)x - CONTROL_W / 2,
1060 (int)y - CONTROL_W / 2,
1063 // char string[BCTEXTLEN];
1064 // sprintf(string, "%d", (i < points.total - 1 ? i + 1 : 0));
1065 // canvas->draw_text((int)x + CONTROL_W, (int)y + CONTROL_W, string);
1068 // Draw second control point. Discard x2 and y2 after this.
1069 x2 = half_track_w + (x2 - half_track_w) * projector_z + projector_x;
1070 y2 = half_track_h + (y2 - half_track_h) * projector_z + projector_y;
1071 output_to_canvas(mwindow->edl, 0, x2, y2);
1072 canvas->draw_line((int)x, (int)y, (int)x2, (int)y2);
1073 canvas->draw_rectangle((int)x2 - CONTROL_W / 2,
1074 (int)y2 - CONTROL_H / 2,
1084 // Draw first anchor
1087 canvas->draw_disc((int)x - FIRST_CONTROL_W / 2,
1088 (int)y - FIRST_CONTROL_H / 2,
1093 // Draw first control point. Discard x1 and y1 after this.
1096 x1 = half_track_w + (x1 - half_track_w) * projector_z + projector_x;
1097 y1 = half_track_h + (y1 - half_track_h) * projector_z + projector_y;
1098 output_to_canvas(mwindow->edl, 0, x1, y1);
1099 canvas->draw_line((int)x, (int)y, (int)x1, (int)y1);
1100 canvas->draw_rectangle((int)x1 - CONTROL_W / 2,
1101 (int)y1 - CONTROL_H / 2,
1105 x_points.append((int)x);
1106 y_points.append((int)y);
1109 //printf("CWindowCanvas::do_mask 1\n");
1115 //printf("CWindowCanvas::do_mask 1\n");
1119 canvas->draw_polygon(&x_points, &y_points);
1120 canvas->set_opaque();
1122 //printf("CWindowCanvas::do_mask 1\n");
1131 if(button_press && !result)
1133 //printf("CWindowCanvas::do_mask 5\n");
1134 gui->affected_track = gui->cwindow->calculate_affected_track();
1135 // Get current keyframe
1136 if(gui->affected_track)
1137 gui->affected_auto =
1138 gui->cwindow->calculate_affected_auto(gui->affected_track->automation->mask_autos);
1140 MaskAuto *keyframe = (MaskAuto*)gui->affected_auto;
1141 SubMask *mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
1143 //printf("CWindowCanvas::do_mask 6 %d %d\n", gui->alt_down(), mask->points.total);
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;
1192 //printf("CWindowCanvas::do_mask 1 %f %f %d %d\n",
1193 // shortest_line_distance, shortest_point_distance, shortest_point1, shortest_point2);
1194 //printf("CWindowCanvas::do_mask %d %d\n", shortest_point1, shortest_point2);
1196 // Append to end of list
1197 if(labs(shortest_point1 - shortest_point2) > 1)
1199 // Need to apply the new point to every keyframe
1200 for(MaskAuto *current = (MaskAuto*)mask_autos->default_auto;
1203 SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
1204 MaskPoint *new_point = new MaskPoint;
1205 submask->points.append(new_point);
1206 *new_point = *point;
1207 if(current == (MaskAuto*)mask_autos->default_auto)
1208 current = (MaskAuto*)mask_autos->first;
1210 current = (MaskAuto*)NEXT;
1213 gui->affected_point = mask->points.total - 1;
1217 // Insert between 2 points, shifting back point 2
1218 if(shortest_point1 >= 0 && shortest_point2 >= 0)
1220 for(MaskAuto *current = (MaskAuto*)mask_autos->default_auto;
1223 SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
1224 MaskPoint *new_point = new MaskPoint;
1225 submask->points.append(0);
1226 for(int i = submask->points.total - 1;
1227 i > shortest_point2;
1229 submask->points.values[i] = submask->points.values[i - 1];
1230 submask->points.values[shortest_point2] = new_point;
1232 *new_point = *point;
1233 if(current == (MaskAuto*)mask_autos->default_auto)
1234 current = (MaskAuto*)mask_autos->first;
1236 current = (MaskAuto*)NEXT;
1240 gui->affected_point = shortest_point2;
1243 //printf("CWindowCanvas::do_mask 3 %d\n", mask->points.total);
1250 // Create the first point.
1253 //printf("CWindowCanvas::do_mask 1\n");
1254 for(MaskAuto *current = (MaskAuto*)mask_autos->default_auto;
1257 SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
1258 MaskPoint *new_point = new MaskPoint;
1259 submask->points.append(new_point);
1260 *new_point = *point;
1261 if(current == (MaskAuto*)mask_autos->default_auto)
1262 current = (MaskAuto*)mask_autos->first;
1264 current = (MaskAuto*)NEXT;
1267 //printf("CWindowCanvas::do_mask 2\n");
1268 // Create a second point if none existed before
1269 if(mask->points.total < 2)
1271 for(MaskAuto *current = (MaskAuto*)mask_autos->default_auto;
1274 SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
1275 MaskPoint *new_point = new MaskPoint;
1276 submask->points.append(new_point);
1277 *new_point = *point;
1278 if(current == (MaskAuto*)mask_autos->default_auto)
1279 current = (MaskAuto*)mask_autos->first;
1281 current = (MaskAuto*)NEXT;
1284 gui->affected_point = mask->points.total - 1;
1285 //printf("CWindowCanvas::do_mask 3 %d\n", mask->points.total);
1290 //printf("CWindowCanvas::do_mask 2 %d %d %f %f\n", get_cursor_x(), get_cursor_y(), gui->affected_point->x, gui->affected_point->y);
1291 gui->current_operation = mwindow->edl->session->cwindow_operation;
1292 // Delete the template
1294 mwindow->undo->update_undo_after();
1295 //printf("CWindowCanvas::do_mask 4\n");
1301 //printf("CWindowCanvas::do_mask 7\n");
1303 if(button_press && result)
1305 MaskAuto *keyframe = (MaskAuto*)gui->affected_auto;
1306 SubMask *mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
1307 MaskPoint *point = mask->points.values[gui->affected_point];
1308 gui->center_x = point->x;
1309 gui->center_y = point->y;
1310 gui->control_in_x = point->control_x1;
1311 gui->control_in_y = point->control_y1;
1312 gui->control_out_x = point->control_x2;
1313 gui->control_out_y = point->control_y2;
1314 // printf("CWindowCanvas::do_mask 1 %p %p %d\n",
1315 // gui->affected_auto,
1316 // gui->affected_point,
1317 // gui->current_operation);
1320 //printf("CWindowCanvas::do_mask 8\n");
1323 MaskAuto *keyframe = (MaskAuto*)gui->affected_auto;
1324 SubMask *mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
1325 if(gui->affected_point < mask->points.total)
1327 MaskPoint *point = mask->points.values[gui->affected_point];
1328 // float cursor_x = get_cursor_x();
1329 // float cursor_y = get_cursor_y();
1330 // canvas_to_output(mwindow->edl, 0, cursor_x, cursor_y);
1331 float cursor_x = mask_cursor_x;
1332 float cursor_y = mask_cursor_y;
1333 //printf("CWindowCanvas::do_mask 9 %d %d\n", mask->points.total, gui->affected_point);
1335 float last_x = point->x;
1336 float last_y = point->y;
1337 float last_control_x1 = point->control_x1;
1338 float last_control_y1 = point->control_y1;
1339 float last_control_x2 = point->control_x2;
1340 float last_control_y2 = point->control_y2;
1343 switch(gui->current_operation)
1346 point->x = cursor_x - gui->x_origin + gui->center_x;
1347 point->y = cursor_y - gui->y_origin + gui->center_y;
1350 case CWINDOW_MASK_CONTROL_IN:
1351 point->control_x1 = cursor_x - gui->x_origin + gui->control_in_x;
1352 point->control_y1 = cursor_y - gui->y_origin + gui->control_in_y;
1355 case CWINDOW_MASK_CONTROL_OUT:
1356 point->control_x2 = cursor_x - gui->x_origin + gui->control_out_x;
1357 point->control_y2 = cursor_y - gui->y_origin + gui->control_out_y;
1360 case CWINDOW_MASK_TRANSLATE:
1361 for(int i = 0; i < mask->points.total; i++)
1363 mask->points.values[i]->x += cursor_x - gui->x_origin;
1364 mask->points.values[i]->y += cursor_y - gui->y_origin;
1366 gui->x_origin = cursor_x;
1367 gui->y_origin = cursor_y;
1372 if( !EQUIV(last_x, point->x) ||
1373 !EQUIV(last_y, point->y) ||
1374 !EQUIV(last_control_x1, point->control_x1) ||
1375 !EQUIV(last_control_y1, point->control_y1) ||
1376 !EQUIV(last_control_x2, point->control_x2) ||
1377 !EQUIV(last_control_y2, point->control_y2))
1379 mwindow->undo->update_undo_before(_("tweek"), LOAD_AUTOMATION);
1386 //printf("CWindowCanvas::do_mask 2 %d %d %d\n", result, rerender, redraw);
1388 points.remove_all_objects();
1389 //printf("CWindowCanvas::do_mask 20\n");
1393 void CWindowCanvas::draw_overlays()
1395 //printf("CWindowCanvas::draw_overlays 1\n");
1396 if(mwindow->edl->session->safe_regions)
1398 draw_safe_regions();
1401 if(mwindow->edl->session->cwindow_scrollbars)
1403 // Always draw output rectangle
1404 float x1, y1, x2, y2;
1406 x2 = mwindow->edl->session->output_w;
1408 y2 = mwindow->edl->session->output_h;
1409 output_to_canvas(mwindow->edl, 0, x1, y1);
1410 output_to_canvas(mwindow->edl, 0, x2, y2);
1412 canvas->set_inverse();
1413 canvas->set_color(WHITE);
1415 canvas->draw_rectangle((int)x1,
1420 canvas->set_opaque();
1423 if(mwindow->session->ccanvas_highlighted)
1425 canvas->set_color(WHITE);
1426 canvas->set_inverse();
1427 canvas->draw_rectangle(0, 0, canvas->get_w(), canvas->get_h());
1428 canvas->draw_rectangle(1, 1, canvas->get_w() - 2, canvas->get_h() - 2);
1429 canvas->set_opaque();
1432 int temp1 = 0, temp2 = 0;
1433 //printf("CWindowCanvas::draw_overlays 1 %d\n", mwindow->edl->session->cwindow_operation);
1434 switch(mwindow->edl->session->cwindow_operation)
1436 case CWINDOW_CAMERA:
1440 case CWINDOW_PROJECTOR:
1449 do_mask(temp1, temp2, 0, 0, 1);
1452 //printf("CWindowCanvas::draw_overlays 2\n");
1455 void CWindowCanvas::draw_safe_regions()
1457 float action_x1, action_x2, action_y1, action_y2;
1458 float title_x1, title_x2, title_y1, title_y2;
1460 action_x1 = mwindow->edl->session->output_w / 2 - mwindow->edl->session->output_w / 2 * 0.9;
1461 action_x2 = mwindow->edl->session->output_w / 2 + mwindow->edl->session->output_w / 2 * 0.9;
1462 action_y1 = mwindow->edl->session->output_h / 2 - mwindow->edl->session->output_h / 2 * 0.9;
1463 action_y2 = mwindow->edl->session->output_h / 2 + mwindow->edl->session->output_h / 2 * 0.9;
1464 title_x1 = mwindow->edl->session->output_w / 2 - mwindow->edl->session->output_w / 2 * 0.8;
1465 title_x2 = mwindow->edl->session->output_w / 2 + mwindow->edl->session->output_w / 2 * 0.8;
1466 title_y1 = mwindow->edl->session->output_h / 2 - mwindow->edl->session->output_h / 2 * 0.8;
1467 title_y2 = mwindow->edl->session->output_h / 2 + mwindow->edl->session->output_h / 2 * 0.8;
1469 output_to_canvas(mwindow->edl, 0, action_x1, action_y1);
1470 output_to_canvas(mwindow->edl, 0, action_x2, action_y2);
1471 output_to_canvas(mwindow->edl, 0, title_x1, title_y1);
1472 output_to_canvas(mwindow->edl, 0, title_x2, title_y2);
1474 canvas->set_inverse();
1475 canvas->set_color(WHITE);
1477 canvas->draw_rectangle((int)action_x1,
1479 (int)(action_x2 - action_x1),
1480 (int)(action_y2 - action_y1));
1481 canvas->draw_rectangle((int)title_x1,
1483 (int)(title_x2 - title_x1),
1484 (int)(title_y2 - title_y1));
1486 canvas->set_opaque();
1489 void CWindowCanvas::reset_keyframe(int do_camera)
1491 BezierAuto *translate_keyframe = 0;
1492 FloatAuto *zoom_keyframe = 0;
1493 Track *affected_track = 0;
1495 affected_track = gui->cwindow->calculate_affected_track();
1501 translate_keyframe = (BezierAuto*)gui->cwindow->calculate_affected_auto(
1502 affected_track->automation->camera_autos);
1503 zoom_keyframe = (FloatAuto*)gui->cwindow->calculate_affected_auto(
1504 affected_track->automation->czoom_autos);
1508 translate_keyframe = (BezierAuto*)gui->cwindow->calculate_affected_auto(
1509 affected_track->automation->projector_autos);
1510 zoom_keyframe = (FloatAuto*)gui->cwindow->calculate_affected_auto(
1511 affected_track->automation->pzoom_autos);
1514 translate_keyframe->center_x = 0;
1515 translate_keyframe->center_y = 0;
1516 translate_keyframe->center_z = 1;
1517 zoom_keyframe->value = 1;
1519 mwindow->sync_parameters(CHANGE_PARAMS);
1521 // gui->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
1528 void CWindowCanvas::reset_camera()
1533 void CWindowCanvas::reset_projector()
1538 int CWindowCanvas::test_crop(int button_press, int &redraw)
1541 int handle_selected = -1;
1542 float x1 = mwindow->edl->session->crop_x1;
1543 float y1 = mwindow->edl->session->crop_y1;
1544 float x2 = mwindow->edl->session->crop_x2;
1545 float y2 = mwindow->edl->session->crop_y2;
1546 float cursor_x = get_cursor_x();
1547 float cursor_y = get_cursor_y();
1548 float canvas_x1 = x1;
1549 float canvas_y1 = y1;
1550 float canvas_x2 = x2;
1551 float canvas_y2 = y2;
1552 float canvas_cursor_x = cursor_x;
1553 float canvas_cursor_y = cursor_y;
1555 canvas_to_output(mwindow->edl, 0, cursor_x, cursor_y);
1556 // Use screen normalized coordinates for hot spot tests.
1557 output_to_canvas(mwindow->edl, 0, canvas_x1, canvas_y1);
1558 output_to_canvas(mwindow->edl, 0, canvas_x2, canvas_y2);
1560 if(gui->current_operation == CWINDOW_CROP)
1562 handle_selected = gui->crop_handle;
1565 if(canvas_cursor_x >= canvas_x1 && canvas_cursor_x < canvas_x1 + CROPHANDLE_W &&
1566 canvas_cursor_y >= canvas_y1 && canvas_cursor_y < canvas_y1 + CROPHANDLE_H)
1568 handle_selected = 0;
1569 gui->crop_origin_x = x1;
1570 gui->crop_origin_y = y1;
1573 if(canvas_cursor_x >= canvas_x2 - CROPHANDLE_W && canvas_cursor_x < canvas_x2 &&
1574 canvas_cursor_y >= canvas_y1 && canvas_cursor_y < canvas_y1 + CROPHANDLE_H)
1576 handle_selected = 1;
1577 gui->crop_origin_x = x2;
1578 gui->crop_origin_y = y1;
1581 if(canvas_cursor_x >= canvas_x1 && canvas_cursor_x < canvas_x1 + CROPHANDLE_W &&
1582 canvas_cursor_y >= canvas_y2 - CROPHANDLE_H && canvas_cursor_y < canvas_y2)
1584 handle_selected = 2;
1585 gui->crop_origin_x = x1;
1586 gui->crop_origin_y = y2;
1589 if(canvas_cursor_x >= canvas_x2 - CROPHANDLE_W && canvas_cursor_x < canvas_x2 &&
1590 canvas_cursor_y >= canvas_y2 - CROPHANDLE_H && canvas_cursor_y < canvas_y2)
1592 handle_selected = 3;
1593 gui->crop_origin_x = x2;
1594 gui->crop_origin_y = y2;
1599 gui->crop_origin_x = cursor_x;
1600 gui->crop_origin_y = cursor_y;
1603 // printf("test crop %d %d\n",
1604 // gui->current_operation,
1605 // handle_selected);
1610 gui->current_operation = CWINDOW_CROP;
1611 gui->crop_handle = handle_selected;
1612 gui->x_origin = cursor_x;
1613 gui->y_origin = cursor_y;
1616 if(handle_selected < 0)
1620 mwindow->edl->session->crop_x1 = (int)x1;
1621 mwindow->edl->session->crop_y1 = (int)y1;
1622 mwindow->edl->session->crop_x2 = (int)x2;
1623 mwindow->edl->session->crop_y2 = (int)y2;
1629 if(gui->current_operation == CWINDOW_CROP)
1631 float x_difference, y_difference;
1632 if(gui->crop_handle >= 0)
1634 float zoom_x, zoom_y, conformed_w, conformed_h;
1635 get_zooms(mwindow->edl, 0, zoom_x, zoom_y, conformed_w, conformed_h);
1636 x_difference = cursor_x - gui->x_origin;
1639 switch(gui->crop_handle)
1642 x1 = gui->crop_origin_x;
1643 y1 = gui->crop_origin_y;
1644 x2 = gui->crop_origin_x;
1645 y2 = gui->crop_origin_y;
1646 if(cursor_x < gui->x_origin)
1648 if(cursor_y < gui->y_origin)
1654 if(cursor_y >= gui->y_origin)
1661 if(cursor_x >= gui->x_origin)
1663 if(cursor_y < gui->y_origin)
1669 if(cursor_y >= gui->y_origin)
1676 // printf("test crop %d %d %d %d\n",
1677 // mwindow->edl->session->crop_x1,
1678 // mwindow->edl->session->crop_y1,
1679 // mwindow->edl->session->crop_x2,
1680 // mwindow->edl->session->crop_y2);
1683 x1 = cursor_x - gui->x_origin + gui->crop_origin_x;
1684 y1 = cursor_y - gui->y_origin + gui->crop_origin_y;
1687 x2 = cursor_x - gui->x_origin + gui->crop_origin_x;
1688 y1 = cursor_y - gui->y_origin + gui->crop_origin_y;
1691 x1 = cursor_x - gui->x_origin + gui->crop_origin_x;
1692 y2 = cursor_y - gui->y_origin + gui->crop_origin_y;
1695 x2 = cursor_x - gui->x_origin + gui->crop_origin_x;
1696 y2 = cursor_y - gui->y_origin + gui->crop_origin_y;
1700 if(!EQUIV(mwindow->edl->session->crop_x1, x1) ||
1701 !EQUIV(mwindow->edl->session->crop_x2, x2) ||
1702 !EQUIV(mwindow->edl->session->crop_y1, y1) ||
1703 !EQUIV(mwindow->edl->session->crop_y2, y2))
1705 mwindow->edl->session->crop_x1 = (int)x1;
1706 mwindow->edl->session->crop_y1 = (int)y1;
1707 mwindow->edl->session->crop_x2 = (int)x2;
1708 mwindow->edl->session->crop_y2 = (int)y2;
1714 // Update cursor font
1715 if(handle_selected >= 0)
1717 switch(handle_selected)
1720 set_cursor(UPLEFT_RESIZE);
1723 set_cursor(UPRIGHT_RESIZE);
1726 set_cursor(DOWNLEFT_RESIZE);
1729 set_cursor(DOWNRIGHT_RESIZE);
1736 set_cursor(ARROW_CURSOR);
1738 #define CLAMP(x, y, z) ((x) = ((x) < (y) ? (y) : ((x) > (z) ? (z) : (x))))
1742 CLAMP(mwindow->edl->session->crop_x1, 0, mwindow->edl->calculate_output_w(0));
1743 CLAMP(mwindow->edl->session->crop_x2, 0, mwindow->edl->calculate_output_w(0));
1744 CLAMP(mwindow->edl->session->crop_y1, 0, mwindow->edl->calculate_output_h(0));
1745 CLAMP(mwindow->edl->session->crop_y2, 0, mwindow->edl->calculate_output_h(0));
1746 // printf("CWindowCanvas::test_crop %d %d %d %d\n",
1747 // mwindow->edl->session->crop_x2,
1748 // mwindow->edl->session->crop_y2,
1749 // mwindow->edl->calculate_output_w(0),
1750 // mwindow->edl->calculate_output_h(0));
1756 void CWindowCanvas::draw_crop()
1758 canvas->set_inverse();
1759 canvas->set_color(WHITE);
1761 float x1 = mwindow->edl->session->crop_x1;
1762 float y1 = mwindow->edl->session->crop_y1;
1763 float x2 = mwindow->edl->session->crop_x2;
1764 float y2 = mwindow->edl->session->crop_y2;
1766 output_to_canvas(mwindow->edl, 0, x1, y1);
1767 output_to_canvas(mwindow->edl, 0, x2, y2);
1769 if(x2 - x1 && y2 - y1)
1770 canvas->draw_rectangle((int)x1,
1775 draw_crophandle((int)x1, (int)y1);
1776 draw_crophandle((int)x2 - CROPHANDLE_W, (int)y1);
1777 draw_crophandle((int)x1, (int)y2 - CROPHANDLE_H);
1778 draw_crophandle((int)x2 - CROPHANDLE_W, (int)y2 - CROPHANDLE_H);
1779 canvas->set_opaque();
1787 int CWindowCanvas::do_bezier_center(BezierAuto *current,
1788 BezierAutos *camera_autos,
1789 BezierAutos *projector_autos,
1790 FloatAutos *czoom_autos,
1791 FloatAutos *pzoom_autos,
1795 float center_x = 0, center_y = 0, center_z = 0;
1796 BezierAuto *before = 0, *after = 0;
1797 FloatAuto *previous = 0, *next = 0;
1798 VTrack *track = (VTrack*)current->autos->track;
1799 long position = track->to_units(
1800 mwindow->edl->local_session->selectionstart,
1803 // Get center of current frame. Draw everything relative to this.
1806 camera_autos->get_center(center_x,
1813 center_z = czoom_autos->get_value(position,
1818 float projector_x, projector_y, projector_z;
1820 projector_autos->get_center(projector_x,
1827 previous = next = 0;
1828 projector_z = pzoom_autos->get_value(position,
1833 center_x -= projector_x;
1834 center_y -= projector_y;
1835 center_z = projector_z;
1836 //printf("CWindowCanvas::do_bezier_center 1 %p %f %f\n",
1837 //current, projector_y, center_y);
1841 center_z = pzoom_autos->get_value(current->position,
1849 float auto_x = current->center_x - center_x + mwindow->edl->session->output_w / 2;
1850 float auto_y = current->center_y - center_y + mwindow->edl->session->output_h / 2;
1851 float track_x1 = auto_x - track->track_w / 2 * center_z;
1852 float track_y1 = auto_y - track->track_h / 2 * center_z;
1853 float track_x2 = track_x1 + track->track_w * center_z;
1854 float track_y2 = track_y1 + track->track_h * center_z;
1855 float control_in_x = auto_x + current->control_in_x;
1856 float control_in_y = auto_y + current->control_in_y;
1857 float control_out_x = auto_x + current->control_out_x;
1858 float control_out_y = auto_y + current->control_out_y;
1859 int control_point = 0;
1862 output_to_canvas(mwindow->edl, 0, auto_x, auto_y);
1863 output_to_canvas(mwindow->edl, 0, control_out_x, control_out_y);
1864 output_to_canvas(mwindow->edl, 0, control_in_x, control_in_y);
1865 output_to_canvas(mwindow->edl, 0, track_x1, track_y1);
1866 output_to_canvas(mwindow->edl, 0, track_x2, track_y2);
1868 #define DRAW_THING(offset) \
1869 canvas->draw_line((int)control_in_x + offset, \
1870 (int)control_in_y + offset, \
1871 (int)auto_x + offset, \
1872 (int)auto_y + offset); \
1873 canvas->draw_line((int)control_out_x + offset, \
1874 (int)control_out_y + offset, \
1875 (int)auto_x + offset, \
1876 (int)auto_y + offset); \
1877 canvas->draw_rectangle((int)control_in_x - CONTROL_W / 2 + offset, \
1878 (int)control_in_y - CONTROL_H / 2 + offset, \
1881 canvas->draw_rectangle((int)control_out_x - CONTROL_W / 2 + offset, \
1882 (int)control_out_y - CONTROL_H / 2 + offset, \
1888 canvas->draw_line((int)auto_x - BEZIER_W / 2, \
1889 (int)auto_y - BEZIER_H / 2 + offset, \
1890 (int)auto_x + BEZIER_W / 2, \
1891 (int)auto_y + BEZIER_H / 2 + offset); \
1892 canvas->draw_line((int)auto_x - BEZIER_W / 2, \
1893 (int)auto_y + BEZIER_H / 2 + offset, \
1894 (int)auto_x + BEZIER_W / 2, \
1895 (int)auto_y - BEZIER_H / 2 + offset); \
1899 canvas->draw_rectangle((int)track_x1 + offset, \
1900 (int)track_y1 + offset, \
1901 (int)(track_x2 - track_x1), \
1902 (int)(track_y2 - track_y1)); \
1903 canvas->draw_line((int)track_x1 + offset, \
1904 (int)track_y1 + offset, \
1905 (int)track_x2 + offset, \
1906 (int)track_y2 + offset); \
1907 canvas->draw_line((int)track_x2 + offset, \
1908 (int)track_y1 + offset, \
1909 (int)track_x1 + offset, \
1910 (int)track_y2 + offset); \
1915 canvas->set_color(BLACK);
1918 if(current->position > position)
1919 canvas->set_color(GREEN);
1921 canvas->set_color(RED);
1924 // printf("CWindowCanvas::do_bezier_center 2 %f,%f %f,%f\n",
1932 int cursor_x = get_cursor_x();
1933 int cursor_y = get_cursor_y();
1936 #define SQR(x) ((x) * (x))
1939 float distance1 = sqrt(SQR(cursor_x - control_in_x) +
1940 SQR(cursor_y - control_in_y));
1941 float distance2 = sqrt(SQR(cursor_x - control_out_x) +
1942 SQR(cursor_y - control_out_y));
1943 // printf("CWindowCanvas::do_bezier_center 3 %f,%f %f,%f\n",
1949 control_point = distance2 < distance1;
1952 return control_point;
1957 void CWindowCanvas::draw_bezier_joining(BezierAuto *first,
1959 BezierAutos *camera_autos,
1960 BezierAutos *projector_autos,
1961 FloatAutos *czoom_autos,
1962 FloatAutos *pzoom_autos,
1965 if(first == last) return;
1967 float center_x = 0, center_y = 0, center_z = 0;
1968 BezierAuto *before = 0, *after = 0;
1969 long position = first->autos->track->to_units(
1970 mwindow->edl->local_session->selectionstart,
1973 // Get center of current position. Draw everything relative to this.
1976 camera_autos->get_center(center_x,
1984 float projector_x, projector_y, projector_z;
1986 projector_autos->get_center(projector_x,
1994 center_x -= projector_x;
1995 center_y -= projector_y;
1998 // int segments = 10;
1999 int segments = MAX(canvas->get_w(), canvas->get_h());
2000 int step = (last->position - first->position) / segments;
2002 if(step < 1) step = 1;
2004 for(long frame = first->position;
2005 frame < last->position;
2008 float new_x, new_y, new_z;
2009 float x1, y1, x2, y2;
2011 ((BezierAutos*)(first->autos))->get_center(new_x,
2019 if(frame == first->position)
2025 x1 = old_x - center_x + mwindow->edl->session->output_w / 2;
2026 y1 = old_y - center_y + mwindow->edl->session->output_h / 2;
2027 x2 = new_x - center_x + mwindow->edl->session->output_w / 2;
2028 y2 = new_y - center_y + mwindow->edl->session->output_h / 2;
2029 output_to_canvas(mwindow->edl, 0, x1, y1);
2030 output_to_canvas(mwindow->edl, 0, x2, y2);
2032 canvas->set_color(BLACK);
2033 canvas->draw_line((int)x1 + 1, (int)y1 + 1, (int)x2 + 1, (int)y2 + 1);
2035 if(frame >= position)
2036 canvas->set_color(GREEN);
2038 canvas->set_color(RED);
2040 canvas->draw_line((int)x1, (int)y1, (int)x2, (int)y2);
2048 void CWindowCanvas::draw_bezier(int do_camera)
2050 Track *track = gui->cwindow->calculate_affected_track();
2051 BezierAutos *autos, *camera_autos, *projector_autos;
2052 BezierAuto *first = 0, *mid = 0, *last = 0;
2053 BezierAuto *before = 0, *after = 0;
2054 FloatAutos *czoom_autos, *pzoom_autos;
2056 // No track at initialization
2059 camera_autos = track->automation->camera_autos;
2060 projector_autos = track->automation->projector_autos;
2061 czoom_autos = track->automation->czoom_autos;
2062 pzoom_autos = track->automation->pzoom_autos;
2065 autos = track->automation->camera_autos;
2067 autos = track->automation->projector_autos;
2070 long position = track->to_units(mwindow->edl->local_session->selectionstart,
2074 // Rules for which autos to draw:
2076 // No automation besides default:
2079 // Automation on or after current position only
2080 // mid = first, last = next
2082 // Automation before current position only
2083 // mid = last, first = previous
2085 // Automation on current position only
2088 // Automation before and after current position
2089 // first = previous, mid = next, last = next->next
2091 for(first = (BezierAuto*)autos->last;
2093 first = (BezierAuto*)first->previous)
2094 if(first->position < position)
2099 mid = (BezierAuto*)first->next;
2103 first = (BezierAuto*)first->previous;
2107 mid = (BezierAuto*)autos->first;
2110 last = (BezierAuto*)mid->next;
2112 mid = (BezierAuto*)autos->default_auto;
2118 if(mid) first = (BezierAuto*)mid->previous;
2125 if(mid) last = (BezierAuto*)mid->next;
2128 //printf("draw_bezier 1 %p %p %p\n", first, mid, last);
2132 // Draw joining lines
2134 draw_bezier_joining(first,
2143 draw_bezier_joining(mid,
2151 //printf("draw_bezier 2 %p %p %p\n", first, mid, last);
2154 // Draw centers of autos
2156 do_bezier_center(first,
2164 do_bezier_center(mid,
2172 do_bezier_center(last,
2180 //printf("draw_bezier 3 %p %p %p\n", first, mid, last);
2188 int CWindowCanvas::test_bezier(int button_press,
2196 // Processing drag operation.
2197 // Create keyframe during first cursor motion.
2201 float cursor_x = get_cursor_x();
2202 float cursor_y = get_cursor_y();
2203 canvas_to_output(mwindow->edl, 0, cursor_x, cursor_y);
2205 if(gui->current_operation == CWINDOW_CAMERA ||
2206 gui->current_operation == CWINDOW_PROJECTOR)
2208 if(!gui->ctrl_down() && gui->shift_down() && !gui->translating_zoom)
2210 gui->translating_zoom = 1;
2211 gui->affected_auto = 0;
2214 if(!gui->ctrl_down() && !gui->shift_down() && gui->translating_zoom)
2216 gui->translating_zoom = 0;
2217 gui->affected_auto = 0;
2220 // Get target keyframe
2221 BezierAutos *camera_autos = gui->affected_track->automation->camera_autos;
2222 BezierAutos *projector_autos = gui->affected_track->automation->projector_autos;
2223 FloatAutos *czoom_autos = gui->affected_track->automation->czoom_autos;
2224 FloatAutos *pzoom_autos = gui->affected_track->automation->pzoom_autos;
2225 float last_center_x;
2226 float last_center_y;
2227 float last_center_z;
2230 if(!gui->affected_auto)
2232 mwindow->undo->update_undo_before(_("keyframe"), LOAD_AUTOMATION);
2233 if(mwindow->edl->session->cwindow_operation == CWINDOW_CAMERA)
2235 if(gui->translating_zoom)
2237 gui->affected_auto =
2238 gui->cwindow->calculate_affected_auto((Autos*)czoom_autos, 1);
2241 gui->affected_auto =
2242 gui->cwindow->calculate_affected_auto((Autos*)camera_autos, 1);
2245 if(mwindow->edl->session->cwindow_operation == CWINDOW_PROJECTOR)
2247 if(gui->translating_zoom)
2249 gui->affected_auto =
2250 gui->cwindow->calculate_affected_auto((Autos*)pzoom_autos, 1);
2253 gui->affected_auto =
2254 gui->cwindow->calculate_affected_auto((Autos*)projector_autos, 1);
2259 if(gui->translating_zoom)
2261 gui->center_z = ((FloatAuto*)gui->affected_auto)->value;
2265 gui->center_x = ((BezierAuto*)gui->affected_auto)->center_x;
2266 gui->center_y = ((BezierAuto*)gui->affected_auto)->center_y;
2273 BezierAuto *bezier_keyframe = (BezierAuto*)gui->affected_auto;
2274 FloatAuto *zoom_keyframe = (FloatAuto*)gui->affected_auto;
2276 if(gui->translating_zoom)
2278 last_center_z = zoom_keyframe->value;
2282 last_center_x = bezier_keyframe->center_x;
2283 last_center_y = bezier_keyframe->center_y;
2286 if(gui->translating_zoom)
2288 zoom_keyframe->value = gui->center_z + (cursor_y - gui->y_origin) / 128;
2289 if(!EQUIV(last_center_z, zoom_keyframe->value))
2291 mwindow->undo->update_undo_before(_("tweek"), LOAD_AUTOMATION);
2299 bezier_keyframe->center_x = gui->center_x + cursor_x - gui->x_origin;
2300 bezier_keyframe->center_y = gui->center_y + cursor_y - gui->y_origin;
2301 if(!EQUIV(last_center_x, bezier_keyframe->center_x) ||
2302 !EQUIV(last_center_y, bezier_keyframe->center_y))
2304 mwindow->undo->update_undo_before(_("tweek"), LOAD_AUTOMATION);
2311 if(gui->current_operation == CWINDOW_CAMERA_CONTROL_IN ||
2312 gui->current_operation == CWINDOW_PROJECTOR_CONTROL_IN)
2314 BezierAuto *bezier_keyframe = (BezierAuto*)gui->affected_auto;
2315 float last_control_in_x = bezier_keyframe->control_in_x;
2316 float last_control_in_y = bezier_keyframe->control_in_y;
2317 bezier_keyframe->control_in_x = gui->control_in_x + cursor_x - gui->x_origin;
2318 bezier_keyframe->control_in_y = gui->control_in_y + cursor_y - gui->y_origin;
2320 if(!EQUIV(last_control_in_x, bezier_keyframe->control_in_x) ||
2321 !EQUIV(last_control_in_y, bezier_keyframe->control_in_y))
2323 mwindow->undo->update_undo_before(_("tweek"), LOAD_AUTOMATION);
2329 if(gui->current_operation == CWINDOW_CAMERA_CONTROL_OUT ||
2330 gui->current_operation == CWINDOW_PROJECTOR_CONTROL_OUT)
2332 BezierAuto *bezier_keyframe = (BezierAuto*)gui->affected_auto;
2333 float last_control_out_x = bezier_keyframe->control_out_x;
2334 float last_control_out_y = bezier_keyframe->control_out_y;
2335 bezier_keyframe->control_out_x = gui->control_out_x + cursor_x - gui->x_origin;
2336 bezier_keyframe->control_out_y = gui->control_out_y + cursor_y - gui->y_origin;
2338 if(!EQUIV(last_control_out_x, bezier_keyframe->control_out_x) ||
2339 !EQUIV(last_control_out_y, bezier_keyframe->control_out_y))
2341 mwindow->undo->update_undo_before(_("tweek"), LOAD_AUTOMATION);
2350 // Begin drag operation. Don't create keyframe here.
2352 // Get affected track off of the first recordable video track.
2353 // Calculating based on the alpha channel would require rendering
2354 // each layer and its effects and trapping the result in VirtualVNode before
2355 // compositing onto the output.
2356 gui->affected_track = gui->cwindow->calculate_affected_track();
2357 gui->affected_auto = 0;
2359 if(gui->affected_track)
2361 BezierAutos *camera_autos = gui->affected_track->automation->camera_autos;
2362 BezierAutos *projector_autos = gui->affected_track->automation->projector_autos;
2363 FloatAutos *czoom_autos = gui->affected_track->automation->czoom_autos;
2364 FloatAutos *pzoom_autos = gui->affected_track->automation->pzoom_autos;
2367 if(!gui->ctrl_down())
2369 gui->current_operation =
2370 mwindow->edl->session->cwindow_operation;
2371 gui->affected_auto = 0;
2375 // Get nearest control point
2376 if(mwindow->edl->session->cwindow_operation == CWINDOW_CAMERA)
2377 gui->affected_auto =
2378 gui->cwindow->calculate_affected_auto(camera_autos, 0);
2380 if(mwindow->edl->session->cwindow_operation == CWINDOW_PROJECTOR)
2381 gui->affected_auto =
2382 gui->cwindow->calculate_affected_auto(projector_autos, 0);
2384 //printf("CWindowCanvas::test_bezier 1 %d\n", gui->current_operation);
2385 int control_point = do_bezier_center(
2386 (BezierAuto*)gui->affected_auto,
2391 mwindow->edl->session->cwindow_operation == CWINDOW_CAMERA,
2394 //printf("CWindowCanvas::test_bezier 2 %d\n", control_point);
2395 if(control_point == 0)
2397 if(mwindow->edl->session->cwindow_operation == CWINDOW_CAMERA)
2398 gui->current_operation = CWINDOW_CAMERA_CONTROL_IN;
2400 gui->current_operation = CWINDOW_PROJECTOR_CONTROL_IN;
2404 if(mwindow->edl->session->cwindow_operation == CWINDOW_CAMERA)
2405 gui->current_operation = CWINDOW_CAMERA_CONTROL_OUT;
2407 gui->current_operation = CWINDOW_PROJECTOR_CONTROL_OUT;
2410 BezierAuto *keyframe = (BezierAuto*)gui->affected_auto;
2411 gui->center_x = keyframe->center_x;
2412 gui->center_y = keyframe->center_y;
2413 gui->center_z = keyframe->center_z;
2414 gui->control_in_x = keyframe->control_in_x;
2415 gui->control_in_y = keyframe->control_in_y;
2416 gui->control_out_x = keyframe->control_out_x;
2417 gui->control_out_y = keyframe->control_out_y;
2428 int CWindowCanvas::test_zoom(int &redraw)
2431 float zoom = get_zoom();
2435 if(!mwindow->edl->session->cwindow_scrollbars)
2437 mwindow->edl->session->cwindow_scrollbars = 1;
2446 canvas_to_output(mwindow->edl,
2451 //printf("CWindowCanvas::test_zoom 1 %f %f\n", x, y);
2454 if(get_buttonpress() == 5 ||
2461 x -= w_visible * 2 / 2;
2462 y -= h_visible * 2 / 2;
2476 x -= w_visible / 2 / 2;
2477 y -= h_visible / 2 / 2;
2489 // check_boundaries(mwindow->edl, x_i, y_i, zoom);
2491 //printf("CWindowCanvas::test_zoom 2 %d %d\n", x_i, y_i);
2496 reposition_window(mwindow->edl,
2497 mwindow->theme->ccanvas_x,
2498 mwindow->theme->ccanvas_y,
2499 mwindow->theme->ccanvas_w,
2500 mwindow->theme->ccanvas_h);
2505 gui->zoom_panel->update(zoom);
2511 void CWindowCanvas::calculate_origin()
2513 gui->x_origin = get_cursor_x();
2514 gui->y_origin = get_cursor_y();
2515 //printf("CWindowCanvas::calculate_origin 1 %f %f\n", gui->x_origin, gui->y_origin);
2516 canvas_to_output(mwindow->edl, 0, gui->x_origin, gui->y_origin);
2517 //printf("CWindowCanvas::calculate_origin 2 %f %f\n", gui->x_origin, gui->y_origin);
2521 int CWindowCanvas::cursor_leave_event()
2523 set_cursor(ARROW_CURSOR);
2527 int CWindowCanvas::cursor_enter_event()
2530 switch(mwindow->edl->session->cwindow_operation)
2532 case CWINDOW_CAMERA:
2533 case CWINDOW_PROJECTOR:
2534 set_cursor(MOVE_CURSOR);
2537 set_cursor(MOVE_CURSOR);
2540 test_crop(0, redraw);
2542 case CWINDOW_PROTECT:
2543 set_cursor(ARROW_CURSOR);
2546 set_cursor(CROSS_CURSOR);
2552 int CWindowCanvas::cursor_motion_event()
2554 int redraw = 0, result = 0, rerender = 0, redraw_canvas = 0;
2557 switch(gui->current_operation)
2559 case CWINDOW_SCROLL:
2561 float zoom = get_zoom();
2562 float cursor_x = get_cursor_x();
2563 float cursor_y = get_cursor_y();
2565 float zoom_x, zoom_y, conformed_w, conformed_h;
2566 get_zooms(mwindow->edl, 0, zoom_x, zoom_y, conformed_w, conformed_h);
2567 cursor_x = (float)cursor_x / zoom_x + gui->x_offset;
2568 cursor_y = (float)cursor_y / zoom_y + gui->y_offset;
2572 int x = (int)(gui->x_origin - cursor_x + gui->x_offset);
2573 int y = (int)(gui->y_origin - cursor_y + gui->y_offset);
2579 update_scrollbars();
2585 case CWINDOW_CAMERA:
2586 case CWINDOW_CAMERA_CONTROL_IN:
2587 case CWINDOW_CAMERA_CONTROL_OUT:
2588 result = test_bezier(0, redraw, redraw_canvas, rerender, 1);
2591 case CWINDOW_PROJECTOR:
2592 case CWINDOW_PROJECTOR_CONTROL_IN:
2593 case CWINDOW_PROJECTOR_CONTROL_OUT:
2594 result = test_bezier(0, redraw, redraw_canvas, rerender, 0);
2599 //printf("CWindowCanvas::cursor_motion_event 1 %d %d\n", x, y);
2600 result = test_crop(0, redraw);
2604 case CWINDOW_MASK_CONTROL_IN:
2605 case CWINDOW_MASK_CONTROL_OUT:
2606 case CWINDOW_MASK_TRANSLATE:
2607 result = do_mask(redraw,
2619 switch(mwindow->edl->session->cwindow_operation)
2622 result = test_crop(0, redraw);
2628 // If the window is never unlocked before calling send_command the
2629 // display shouldn't get stuck on the old video frame although it will
2630 // flicker between the old video frame and the new video frame.
2640 mwindow->gui->lock_window("CWindowCanvas::cursor_motion_event 1");
2641 mwindow->gui->canvas->draw_overlays();
2642 mwindow->gui->canvas->flash();
2643 mwindow->gui->unlock_window();
2648 mwindow->restart_brender();
2649 mwindow->sync_parameters(CHANGE_PARAMS);
2650 gui->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
2654 if(!redraw) gui->update_tool();
2659 int CWindowCanvas::button_press_event()
2663 int redraw_canvas = 0;
2666 if(Canvas::button_press_event()) return 1;
2668 gui->translating_zoom = gui->shift_down();
2671 //printf("CWindowCanvas::button_press_event 2 %f %f\n", gui->x_origin, gui->y_origin, gui->x_origin, gui->y_origin);
2673 float zoom_x, zoom_y, conformed_w, conformed_h;
2674 get_zooms(mwindow->edl, 0, zoom_x, zoom_y, conformed_w, conformed_h);
2675 gui->x_offset = get_x_offset(mwindow->edl, 0, zoom_x, conformed_w, conformed_h);
2676 gui->y_offset = get_y_offset(mwindow->edl, 0, zoom_y, conformed_w, conformed_h);
2679 if(get_buttonpress() == 2)
2681 gui->current_operation = CWINDOW_SCROLL;
2687 switch(mwindow->edl->session->cwindow_operation)
2689 case CWINDOW_CAMERA:
2690 result = test_bezier(1, redraw, redraw_canvas, rerender, 1);
2693 case CWINDOW_PROJECTOR:
2694 result = test_bezier(1, redraw, redraw_canvas, rerender, 0);
2698 result = test_zoom(redraw);
2702 result = test_crop(1, redraw);
2706 if(get_buttonpress() == 1)
2707 result = do_mask(redraw, rerender, 1, 0, 0);
2720 int CWindowCanvas::button_release_event()
2724 switch(gui->current_operation)
2726 case CWINDOW_SCROLL:
2731 gui->current_operation = CWINDOW_NONE;
2732 mwindow->undo->update_undo_after();
2733 //printf("CWindowCanvas::button_release_event %d\n", result);
2737 void CWindowCanvas::zoom_resize_window(float percentage)
2739 int canvas_w, canvas_h;
2740 calculate_sizes(mwindow->edl->get_aspect_ratio(),
2741 mwindow->edl->calculate_output_w(0),
2742 mwindow->edl->calculate_output_h(0),
2747 new_w = canvas_w + (gui->get_w() - mwindow->theme->ccanvas_w);
2748 new_h = canvas_h + (gui->get_h() - mwindow->theme->ccanvas_h);
2749 gui->resize_window(new_w, new_h);
2750 gui->resize_event(new_w, new_h);