4 * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "automation.h"
24 #include "bcsignals.h"
28 #include "cplayback.h"
31 #include "cwindowgui.h"
33 #include "cwindowtool.h"
34 #include "editpanel.h"
36 #include "edlsession.h"
37 #include "floatauto.h"
38 #include "floatautos.h"
41 #include "localsession.h"
42 #include "mainclock.h"
45 #include "mainsession.h"
47 #include "maskautos.h"
49 #include "meterpanel.h"
50 #include "mwindowgui.h"
53 #include "playback3d.h"
54 #include "playtransport.h"
56 #include "trackcanvas.h"
58 #include "transportque.h"
62 static double my_zoom_table[] =
75 static int total_zooms = sizeof(my_zoom_table) / sizeof(double);
78 CWindowGUI::CWindowGUI(MWindow *mwindow, CWindow *cwindow)
79 : BC_Window(_(PROGRAM_NAME ": Compositor"),
80 mwindow->session->cwindow_x,
81 mwindow->session->cwindow_y,
82 mwindow->session->cwindow_w,
83 mwindow->session->cwindow_h,
89 BC_WindowBase::get_resources()->bg_color,
90 mwindow->get_cwindow_display())
92 this->mwindow = mwindow;
93 this->cwindow = cwindow;
95 affected_x = affected_y = affected_z = 0;
97 orig_mask_keyframe = new MaskAuto(0, 0);
99 x_offset = y_offset = 0;
100 x_origin = y_origin = 0;
101 current_operation = CWINDOW_NONE;
105 crop_handle = -1; crop_translate = 0;
106 crop_origin_x = crop_origin_y = 0;
107 crop_origin_x1 = crop_origin_y1 = 0;
108 crop_origin_x2 = crop_origin_y2 = 0;
110 eyedrop_x = eyedrop_y = 0;
111 ruler_origin_x = ruler_origin_y = 0;
112 ruler_handle = -1; ruler_translate = 0;
113 center_x = center_y = center_z = 0;
114 control_in_x = control_in_y = 0;
115 control_out_x = control_out_y = 0;
116 translating_zoom = 0;
120 CWindowGUI::~CWindowGUI()
122 if(tool_panel) delete tool_panel;
124 delete composite_panel;
131 delete orig_mask_keyframe;
134 void CWindowGUI::create_objects()
136 lock_window("CWindowGUI::create_objects");
137 set_icon(mwindow->theme->get_image("cwindow_icon"));
139 active = new BC_Pixmap(this, mwindow->theme->get_image("cwindow_active"));
140 inactive = new BC_Pixmap(this, mwindow->theme->get_image("cwindow_inactive"));
142 mwindow->theme->get_cwindow_sizes(this, mwindow->session->cwindow_controls);
143 mwindow->theme->draw_cwindow_bg(this);
146 // Meters required by composite panel
147 meters = new CWindowMeters(mwindow,
149 mwindow->theme->cmeter_x,
150 mwindow->theme->cmeter_y,
151 mwindow->theme->cmeter_h);
152 meters->create_objects();
155 composite_panel = new CPanel(mwindow,
157 mwindow->theme->ccomposite_x,
158 mwindow->theme->ccomposite_y,
159 mwindow->theme->ccomposite_w,
160 mwindow->theme->ccomposite_h);
161 composite_panel->create_objects();
163 canvas = new CWindowCanvas(mwindow, this);
165 canvas->create_objects(mwindow->edl);
166 canvas->use_cwindow();
169 add_subwindow(timebar = new CTimeBar(mwindow,
171 mwindow->theme->ctimebar_x,
172 mwindow->theme->ctimebar_y,
173 mwindow->theme->ctimebar_w,
174 mwindow->theme->ctimebar_h));
175 timebar->create_objects();
178 add_subwindow(slider = new CWindowSlider(mwindow,
180 mwindow->theme->cslider_x,
181 mwindow->theme->cslider_y,
182 mwindow->theme->cslider_w));
185 transport = new CWindowTransport(mwindow,
187 mwindow->theme->ctransport_x,
188 mwindow->theme->ctransport_y);
189 transport->create_objects();
191 transport->set_slider(slider);
194 edit_panel = new CWindowEditing(mwindow, cwindow);
195 edit_panel->set_meters(meters);
196 edit_panel->create_objects();
198 // add_subwindow(clock = new MainClock(mwindow,
199 // mwindow->theme->ctime_x,
200 // mwindow->theme->ctime_y));
202 zoom_panel = new CWindowZoom(mwindow,
204 mwindow->theme->czoom_x,
205 mwindow->theme->czoom_y,
206 mwindow->theme->czoom_w);
207 zoom_panel->create_objects();
208 zoom_panel->zoom_text->add_item(new BC_MenuItem(auto_zoom = _(AUTO_ZOOM)));
209 if( !mwindow->edl->session->cwindow_scrollbars )
210 zoom_panel->set_text(auto_zoom);
212 // destination = new CWindowDestination(mwindow,
214 // mwindow->theme->cdest_x,
215 // mwindow->theme->cdest_y);
216 // destination->create_objects();
218 // Must create after meter panel
219 tool_panel = new CWindowTool(mwindow, this);
220 tool_panel->Thread::start();
223 set_operation(mwindow->edl->session->cwindow_operation);
227 canvas->draw_refresh(0);
234 int CWindowGUI::translation_event()
236 mwindow->session->cwindow_x = get_x();
237 mwindow->session->cwindow_y = get_y();
241 int CWindowGUI::resize_event(int w, int h)
243 mwindow->session->cwindow_x = get_x();
244 mwindow->session->cwindow_y = get_y();
245 mwindow->session->cwindow_w = w;
246 mwindow->session->cwindow_h = h;
248 mwindow->theme->get_cwindow_sizes(this, mwindow->session->cwindow_controls);
249 mwindow->theme->draw_cwindow_bg(this);
252 composite_panel->reposition_buttons(mwindow->theme->ccomposite_x,
253 mwindow->theme->ccomposite_y, mwindow->theme->ccomposite_h);
255 canvas->reposition_window(mwindow->edl,
256 mwindow->theme->ccanvas_x,
257 mwindow->theme->ccanvas_y,
258 mwindow->theme->ccanvas_w,
259 mwindow->theme->ccanvas_h);
261 timebar->resize_event();
264 slider->reposition_window(mwindow->theme->cslider_x,
265 mwindow->theme->cslider_y,
266 mwindow->theme->cslider_w);
267 // Recalibrate pointer motion range
268 slider->set_position();
271 transport->reposition_buttons(mwindow->theme->ctransport_x,
272 mwindow->theme->ctransport_y);
274 edit_panel->reposition_buttons(mwindow->theme->cedit_x,
275 mwindow->theme->cedit_y);
277 // clock->reposition_window(mwindow->theme->ctime_x,
278 // mwindow->theme->ctime_y);
280 zoom_panel->reposition_window(mwindow->theme->czoom_x,
281 mwindow->theme->czoom_y);
283 // destination->reposition_window(mwindow->theme->cdest_x,
284 // mwindow->theme->cdest_y);
286 meters->reposition_window(mwindow->theme->cmeter_x,
287 mwindow->theme->cmeter_y,
289 mwindow->theme->cmeter_h);
293 BC_WindowBase::resize_event(w, h);
297 int CWindowGUI::button_press_event()
299 if(canvas->get_canvas())
300 return canvas->button_press_event_base(canvas->get_canvas());
304 int CWindowGUI::cursor_leave_event()
306 if(canvas->get_canvas())
307 return canvas->cursor_leave_event_base(canvas->get_canvas());
311 int CWindowGUI::cursor_enter_event()
313 if(canvas->get_canvas())
314 return canvas->cursor_enter_event_base(canvas->get_canvas());
318 int CWindowGUI::button_release_event()
320 if(canvas->get_canvas())
321 return canvas->button_release_event();
325 int CWindowGUI::cursor_motion_event()
327 if(canvas->get_canvas())
329 canvas->get_canvas()->unhide_cursor();
330 return canvas->cursor_motion_event();
341 void CWindowGUI::draw_status(int flush)
343 if( (canvas->get_canvas() && canvas->get_canvas()->get_video_on()) ||
344 canvas->is_processing )
347 mwindow->theme->cstatus_x,
348 mwindow->theme->cstatus_y);
352 draw_pixmap(inactive,
353 mwindow->theme->cstatus_x,
354 mwindow->theme->cstatus_y);
358 // printf("CWindowGUI::draw_status %d %d %d\n", __LINE__, mwindow->theme->cstatus_x,
359 // mwindow->theme->cstatus_y);
360 flash(mwindow->theme->cstatus_x,
361 mwindow->theme->cstatus_y,
367 float CWindowGUI::get_auto_zoom()
369 float conformed_w, conformed_h;
370 mwindow->edl->calculate_conformed_dimensions(0, conformed_w, conformed_h);
371 float zoom_x = canvas->w / conformed_w;
372 float zoom_y = canvas->h / conformed_h;
373 return zoom_x < zoom_y ? zoom_x : zoom_y;
376 void CWindowGUI::zoom_canvas(double value, int update_menu)
379 float zoom = !value ? get_auto_zoom() : value;
380 mwindow->edl->session->cwindow_scrollbars = !value ? 0 : 1;
382 float cx = canvas->get_xscroll() + 0.5f*canvas->w_visible;
383 float cy = canvas->get_yscroll() + 0.5f*canvas->h_visible;
384 float output_x = cx, output_y = cy;
385 canvas->output_to_canvas(mwindow->edl, 0, cx, cy);
386 x = output_x - cx / zoom;
387 y = output_y - cy / zoom;
389 canvas->update_zoom((int)(x+0.5), (int)(y+0.5), zoom);
392 zoom_panel->update(value);
393 if( mwindow->edl->session->cwindow_operation == CWINDOW_ZOOM )
394 composite_panel->cpanel_zoom->update(zoom);
396 canvas->reposition_window(mwindow->edl,
397 mwindow->theme->ccanvas_x, mwindow->theme->ccanvas_y,
398 mwindow->theme->ccanvas_w, mwindow->theme->ccanvas_h);
399 canvas->draw_refresh();
404 void CWindowGUI::set_operation(int value)
406 mwindow->edl->session->cwindow_operation = value;
408 composite_panel->set_operation(value);
409 edit_panel->update();
411 tool_panel->start_tool(value);
412 canvas->draw_refresh();
415 void CWindowGUI::update_tool()
417 tool_panel->update_values();
420 int CWindowGUI::close_event()
422 cwindow->hide_window();
427 int CWindowGUI::keypress_event()
431 switch(get_keypress())
449 if(mwindow->session->cwindow_fullscreen)
450 canvas->stop_fullscreen();
452 canvas->start_fullscreen();
453 lock_window("CWindowGUI::keypress_event 1");
457 mwindow->gui->lock_window("CWindowGUI::keypress_event 2");
459 mwindow->gui->unlock_window();
460 lock_window("CWindowGUI::keypress_event 2");
464 mwindow->gui->lock_window("CWindowGUI::keypress_event 2");
465 mwindow->clear_entry();
466 mwindow->gui->unlock_window();
467 lock_window("CWindowGUI::keypress_event 3");
471 if(mwindow->session->cwindow_fullscreen)
472 canvas->stop_fullscreen();
473 lock_window("CWindowGUI::keypress_event 4");
477 int alt_down = this->alt_down();
478 int shift_down = this->shift_down();
481 mwindow->gui->lock_window("CWindowGUI::keypress_event 2");
483 mwindow->prev_edit_handle(shift_down);
485 mwindow->move_left();
486 mwindow->gui->unlock_window();
487 lock_window("CWindowGUI::keypress_event 2");
493 int alt_down = this->alt_down();
494 int shift_down = this->shift_down();
497 mwindow->gui->lock_window("CWindowGUI::keypress_event 2");
499 mwindow->next_edit_handle(shift_down);
501 mwindow->move_right();
502 mwindow->gui->unlock_window();
503 lock_window("CWindowGUI::keypress_event 2");
509 if(!result) result = transport->keypress_event();
515 void CWindowGUI::reset_affected()
522 void CWindowGUI::keyboard_zoomin()
524 // if(mwindow->edl->session->cwindow_scrollbars)
526 zoom_panel->zoom_tumbler->handle_up_event();
533 void CWindowGUI::keyboard_zoomout()
535 // if(mwindow->edl->session->cwindow_scrollbars)
537 zoom_panel->zoom_tumbler->handle_down_event();
545 void CWindowGUI::drag_motion()
547 if(get_hidden()) return;
549 if(mwindow->session->current_operation != DRAG_ASSET &&
550 mwindow->session->current_operation != DRAG_VTRANSITION &&
551 mwindow->session->current_operation != DRAG_VEFFECT) return;
552 int need_highlight = cursor_above() && get_cursor_over_window();
553 if( highlighted == need_highlight ) return;
554 highlighted = need_highlight;
555 canvas->draw_refresh();
558 int CWindowGUI::drag_stop()
561 if(get_hidden()) return 0;
562 if( !highlighted ) return 0;
563 if( mwindow->session->current_operation != DRAG_ASSET &&
564 mwindow->session->current_operation != DRAG_VTRANSITION &&
565 mwindow->session->current_operation != DRAG_VEFFECT) return 0;
567 canvas->draw_refresh();
570 if(mwindow->session->current_operation == DRAG_ASSET)
572 if(mwindow->session->drag_assets->total ||
573 mwindow->session->drag_clips->total)
575 mwindow->gui->lock_window("CWindowGUI::drag_stop 5");
576 mwindow->undo->update_undo_before(_("insert assets"), 0);
577 mwindow->gui->unlock_window();
580 if(mwindow->session->drag_assets->total)
582 mwindow->gui->lock_window("CWindowGUI::drag_stop 1");
584 mwindow->load_assets(mwindow->session->drag_assets,
585 mwindow->edl->local_session->get_selectionstart(),
587 mwindow->session->track_highlighted,
589 mwindow->edl->session->labels_follow_edits,
590 mwindow->edl->session->plugins_follow_edits,
591 mwindow->edl->session->autos_follow_edits,
595 if(mwindow->session->drag_clips->total)
597 mwindow->gui->lock_window("CWindowGUI::drag_stop 2");
599 mwindow->paste_edls(mwindow->session->drag_clips,
601 mwindow->session->track_highlighted,
602 mwindow->edl->local_session->get_selectionstart(),
603 mwindow->edl->session->labels_follow_edits,
604 mwindow->edl->session->plugins_follow_edits,
605 mwindow->edl->session->autos_follow_edits,
609 if(mwindow->session->drag_assets->total ||
610 mwindow->session->drag_clips->total)
612 mwindow->save_backup();
613 mwindow->restart_brender();
614 mwindow->gui->update(1, 1, 1, 1, 0, 1, 0);
615 mwindow->undo->update_undo_after(_("insert assets"), LOAD_ALL);
616 mwindow->gui->unlock_window();
617 mwindow->sync_parameters(LOAD_ALL);
621 if(mwindow->session->current_operation == DRAG_VEFFECT)
623 //printf("CWindowGUI::drag_stop 1\n");
624 Track *affected_track = cwindow->calculate_affected_track();
625 //printf("CWindowGUI::drag_stop 2\n");
627 mwindow->gui->lock_window("CWindowGUI::drag_stop 3");
628 mwindow->insert_effects_cwindow(affected_track);
629 mwindow->session->current_operation = NO_OPERATION;
630 mwindow->gui->unlock_window();
633 if(mwindow->session->current_operation == DRAG_VTRANSITION)
635 Track *affected_track = cwindow->calculate_affected_track();
636 mwindow->gui->lock_window("CWindowGUI::drag_stop 4");
637 mwindow->paste_transition_cwindow(affected_track);
638 mwindow->session->current_operation = NO_OPERATION;
639 mwindow->gui->unlock_window();
645 void CWindowGUI::update_meters()
647 if(mwindow->edl->session->cwindow_meter != meters->visible)
649 meters->set_meters(meters->meter_count, mwindow->edl->session->cwindow_meter);
650 mwindow->theme->get_cwindow_sizes(this, mwindow->session->cwindow_controls);
651 resize_event(get_w(), get_h());
655 void CWindowGUI::stop_transport(const char *lock_msg)
657 if( lock_msg ) unlock_window();
658 mwindow->stop_transport();
659 if( lock_msg ) lock_window(lock_msg);
663 CWindowEditing::CWindowEditing(MWindow *mwindow, CWindow *cwindow)
666 mwindow->theme->cedit_x,
667 mwindow->theme->cedit_y,
668 mwindow->edl->session->editing_mode,
687 this->mwindow = mwindow;
688 this->cwindow = cwindow;
691 #define CWrapper(fn) void CWindowEditing::fn() { \
692 mwindow->gui->lock_window("CWrapper::" #fn); \
694 mwindow->gui->unlock_window(); \
697 CWrapper(copy_selection)
698 CWrapper(splice_selection)
699 CWrapper(overwrite_selection)
700 CWrapper(set_inpoint)
701 CWrapper(set_outpoint)
702 CWrapper(unset_inoutpoint)
703 CWrapper(toggle_label)
709 void CWindowEditing::to_clip()
711 mwindow->to_clip(mwindow->edl, _("composer window: "));
715 CWindowMeters::CWindowMeters(MWindow *mwindow,
720 : MeterPanel(mwindow,
726 mwindow->edl->session->audio_channels,
727 mwindow->edl->session->cwindow_meter,
731 this->mwindow = mwindow;
735 CWindowMeters::~CWindowMeters()
739 int CWindowMeters::change_status_event(int new_status)
741 mwindow->edl->session->cwindow_meter = new_status;
742 gui->update_meters();
749 CWindowZoom::CWindowZoom(MWindow *mwindow, CWindowGUI *gui, int x, int y, int w)
750 : ZoomPanel(mwindow, gui, (double)mwindow->edl->session->cwindow_zoom,
751 x, y, w, my_zoom_table, total_zooms, ZOOM_PERCENTAGE)
753 this->mwindow = mwindow;
757 CWindowZoom::~CWindowZoom()
761 void CWindowZoom::update(double value)
763 char string[BCSTRLEN];
764 const char *cp = string;
767 int frac = value >= 1.0f ? 1 :
769 value >= .01f ? 3 : 4;
770 sprintf(string, "x %.*f", frac, value);
774 ZoomPanel::update(cp);
777 int CWindowZoom::handle_event()
779 double value = !strcasecmp(gui->auto_zoom, get_text()) ? 0 : get_value();
780 gui->zoom_canvas(value, 0);
787 CWindowSlider::CWindowSlider(MWindow *mwindow, CWindow *cwindow, int x, int y, int pixels)
788 : BC_PercentageSlider(x,
797 this->mwindow = mwindow;
798 this->cwindow = cwindow;
799 set_precision(0.00001);
802 CWindowSlider::~CWindowSlider()
806 int CWindowSlider::handle_event()
808 cwindow->update_position((double)get_value());
812 void CWindowSlider::set_position()
814 double new_length = mwindow->edl->tracks->total_length();
815 // if(mwindow->edl->local_session->preview_end <= 0 ||
816 // mwindow->edl->local_session->preview_end > new_length)
817 // mwindow->edl->local_session->preview_end = new_length;
818 // if(mwindow->edl->local_session->preview_start >
819 // mwindow->edl->local_session->preview_end)
820 // mwindow->edl->local_session->preview_start = 0;
823 update(mwindow->theme->cslider_w,
824 mwindow->edl->local_session->get_selectionstart(1),
827 // mwindow->edl->local_session->preview_start,
828 // mwindow->edl->local_session->preview_end);
832 int CWindowSlider::increase_value()
835 cwindow->gui->transport->handle_transport(SINGLE_FRAME_FWD);
836 lock_window("CWindowSlider::increase_value");
840 int CWindowSlider::decrease_value()
843 cwindow->gui->transport->handle_transport(SINGLE_FRAME_REWIND);
844 lock_window("CWindowSlider::decrease_value");
849 // CWindowDestination::CWindowDestination(MWindow *mwindow, CWindowGUI *cwindow, int x, int y)
850 // : BC_PopupTextBox(cwindow,
851 // &cwindow->destinations,
852 // cwindow->destinations.values[cwindow->cwindow->destination]->get_text(),
858 // this->mwindow = mwindow;
859 // this->cwindow = cwindow;
862 // CWindowDestination::~CWindowDestination()
866 // int CWindowDestination::handle_event()
877 CWindowTransport::CWindowTransport(MWindow *mwindow,
881 : PlayTransport(mwindow,
889 EDL* CWindowTransport::get_edl()
894 void CWindowTransport::goto_start()
896 gui->unlock_window();
897 handle_transport(REWIND, 1);
899 mwindow->gui->lock_window("CWindowTransport::goto_start 1");
900 mwindow->goto_start();
901 mwindow->gui->unlock_window();
903 gui->lock_window("CWindowTransport::goto_start 2");
906 void CWindowTransport::goto_end()
908 gui->unlock_window();
909 handle_transport(GOTO_END, 1);
911 mwindow->gui->lock_window("CWindowTransport::goto_end 1");
913 mwindow->gui->unlock_window();
915 gui->lock_window("CWindowTransport::goto_end 2");
920 CWindowCanvas::CWindowCanvas(MWindow *mwindow, CWindowGUI *gui)
923 mwindow->theme->ccanvas_x,
924 mwindow->theme->ccanvas_y,
925 mwindow->theme->ccanvas_w,
926 mwindow->theme->ccanvas_h,
929 mwindow->edl->session->cwindow_scrollbars)
931 this->mwindow = mwindow;
935 void CWindowCanvas::status_event()
940 int CWindowCanvas::get_fullscreen()
942 return mwindow->session->cwindow_fullscreen;
945 void CWindowCanvas::set_fullscreen(int value)
947 mwindow->session->cwindow_fullscreen = value;
951 void CWindowCanvas::update_zoom(int x, int y, float zoom)
953 use_scrollbars = mwindow->edl->session->cwindow_scrollbars;
955 mwindow->edl->session->cwindow_xscroll = x;
956 mwindow->edl->session->cwindow_yscroll = y;
957 mwindow->edl->session->cwindow_zoom = zoom;
960 void CWindowCanvas::zoom_auto()
962 gui->zoom_canvas(0, 1);
965 int CWindowCanvas::get_xscroll()
967 return mwindow->edl->session->cwindow_xscroll;
970 int CWindowCanvas::get_yscroll()
972 return mwindow->edl->session->cwindow_yscroll;
976 float CWindowCanvas::get_zoom()
978 return mwindow->edl->session->cwindow_zoom;
981 void CWindowCanvas::draw_refresh(int flush)
983 if(get_canvas() && !get_canvas()->get_video_on())
986 if(refresh_frame && refresh_frame->get_w()>0 && refresh_frame->get_h()>0)
988 float in_x1, in_y1, in_x2, in_y2;
989 float out_x1, out_y1, out_x2, out_y2;
990 get_transfers(mwindow->edl,
1000 if(!EQUIV(out_x1, 0) ||
1001 !EQUIV(out_y1, 0) ||
1002 !EQUIV(out_x2, get_canvas()->get_w()) ||
1003 !EQUIV(out_y2, get_canvas()->get_h()))
1005 get_canvas()->clear_box(0,
1007 get_canvas()->get_w(),
1008 get_canvas()->get_h());
1011 //printf("CWindowCanvas::draw_refresh %.2f %.2f %.2f %.2f -> %.2f %.2f %.2f %.2f\n",
1012 //in_x1, in_y1, in_x2, in_y2, out_x1, out_y1, out_x2, out_y2);
1015 if(out_x2 > out_x1 &&
1020 // Can't use OpenGL here because it is called asynchronously of the
1021 // playback operation.
1022 get_canvas()->draw_vframe(refresh_frame,
1025 (int)(out_x2 - out_x1),
1026 (int)(out_y2 - out_y1),
1029 (int)(in_x2 - in_x1),
1030 (int)(in_y2 - in_y1),
1036 get_canvas()->clear_box(0,
1038 get_canvas()->get_w(),
1039 get_canvas()->get_h());
1043 get_canvas()->flash(flush);
1045 //printf("CWindowCanvas::draw_refresh 10\n");
1048 #define CROPHANDLE_W 10
1049 #define CROPHANDLE_H 10
1051 void CWindowCanvas::draw_crophandle(int x, int y)
1053 get_canvas()->draw_box(x, y, CROPHANDLE_W, CROPHANDLE_H);
1061 #define CONTROL_W 10
1062 #define CONTROL_H 10
1063 #define FIRST_CONTROL_W 20
1064 #define FIRST_CONTROL_H 20
1066 #define BC_INFINITY 65536
1068 #define RULERHANDLE_W 16
1069 #define RULERHANDLE_H 16
1073 int CWindowCanvas::do_ruler(int draw,
1079 float x1 = mwindow->edl->session->ruler_x1;
1080 float y1 = mwindow->edl->session->ruler_y1;
1081 float x2 = mwindow->edl->session->ruler_x2;
1082 float y2 = mwindow->edl->session->ruler_y2;
1083 float canvas_x1 = x1;
1084 float canvas_y1 = y1;
1085 float canvas_x2 = x2;
1086 float canvas_y2 = y2;
1087 float output_x = get_cursor_x();
1088 float output_y = get_cursor_y();
1089 float canvas_cursor_x = output_x;
1090 float canvas_cursor_y = output_y;
1092 canvas_to_output(mwindow->edl, 0, output_x, output_y);
1093 output_to_canvas(mwindow->edl, 0, canvas_x1, canvas_y1);
1094 output_to_canvas(mwindow->edl, 0, canvas_x2, canvas_y2);
1095 mwindow->session->cwindow_output_x = roundf(output_x);
1096 mwindow->session->cwindow_output_y = roundf(output_y);
1098 if(button_press && get_buttonpress() == 1)
1100 gui->ruler_handle = -1;
1101 gui->ruler_translate = 0;
1104 gui->ruler_translate = 1;
1105 gui->ruler_origin_x = x1;
1106 gui->ruler_origin_y = y1;
1109 if(canvas_cursor_x >= canvas_x1 - RULERHANDLE_W / 2 &&
1110 canvas_cursor_x < canvas_x1 + RULERHANDLE_W / 2 &&
1111 canvas_cursor_y >= canvas_y1 - RULERHANDLE_W &&
1112 canvas_cursor_y < canvas_y1 + RULERHANDLE_H / 2)
1114 gui->ruler_handle = 0;
1115 gui->ruler_origin_x = x1;
1116 gui->ruler_origin_y = y1;
1119 if(canvas_cursor_x >= canvas_x2 - RULERHANDLE_W / 2 &&
1120 canvas_cursor_x < canvas_x2 + RULERHANDLE_W / 2 &&
1121 canvas_cursor_y >= canvas_y2 - RULERHANDLE_W &&
1122 canvas_cursor_y < canvas_y2 + RULERHANDLE_H / 2)
1124 gui->ruler_handle = 1;
1125 gui->ruler_origin_x = x2;
1126 gui->ruler_origin_y = y2;
1130 // Start new selection
1131 if(!gui->ruler_translate &&
1132 (gui->ruler_handle < 0 ||
1137 do_ruler(1, 0, 0, 0);
1138 get_canvas()->flash();
1139 gui->ruler_handle = 1;
1140 mwindow->edl->session->ruler_x1 = output_x;
1141 mwindow->edl->session->ruler_y1 = output_y;
1142 mwindow->edl->session->ruler_x2 = output_x;
1143 mwindow->edl->session->ruler_y2 = output_y;
1144 gui->ruler_origin_x = mwindow->edl->session->ruler_x2;
1145 gui->ruler_origin_y = mwindow->edl->session->ruler_y2;
1148 gui->x_origin = output_x;
1149 gui->y_origin = output_y;
1150 gui->current_operation = CWINDOW_RULER;
1151 gui->tool_panel->raise_window();
1157 if(gui->current_operation == CWINDOW_RULER)
1159 if(gui->ruler_translate)
1162 do_ruler(1, 0, 0, 0);
1163 float x_difference = mwindow->edl->session->ruler_x1;
1164 float y_difference = mwindow->edl->session->ruler_y1;
1165 mwindow->edl->session->ruler_x1 = output_x - gui->x_origin + gui->ruler_origin_x;
1166 mwindow->edl->session->ruler_y1 = output_y - gui->y_origin + gui->ruler_origin_y;
1167 x_difference -= mwindow->edl->session->ruler_x1;
1168 y_difference -= mwindow->edl->session->ruler_y1;
1169 mwindow->edl->session->ruler_x2 -= x_difference;
1170 mwindow->edl->session->ruler_y2 -= y_difference;
1172 do_ruler(1, 0, 0, 0);
1173 get_canvas()->flash();
1177 switch(gui->ruler_handle)
1180 do_ruler(1, 0, 0, 0);
1181 mwindow->edl->session->ruler_x1 = output_x - gui->x_origin + gui->ruler_origin_x;
1182 mwindow->edl->session->ruler_y1 = output_y - gui->y_origin + gui->ruler_origin_y;
1183 if(gui->alt_down() || gui->ctrl_down())
1185 double angle_value = fabs(atan((mwindow->edl->session->ruler_y2 - mwindow->edl->session->ruler_y1) /
1186 (mwindow->edl->session->ruler_x2 - mwindow->edl->session->ruler_x1)) *
1190 double distance_value =
1191 sqrt(SQR(mwindow->edl->session->ruler_x2 - mwindow->edl->session->ruler_x1) +
1192 SQR(mwindow->edl->session->ruler_y2 - mwindow->edl->session->ruler_y1));
1193 if(angle_value < 22)
1194 mwindow->edl->session->ruler_y1 = mwindow->edl->session->ruler_y2;
1196 if(angle_value > 67)
1197 mwindow->edl->session->ruler_x1 = mwindow->edl->session->ruler_x2;
1199 if(mwindow->edl->session->ruler_x1 < mwindow->edl->session->ruler_x2 &&
1200 mwindow->edl->session->ruler_y1 < mwindow->edl->session->ruler_y2)
1202 mwindow->edl->session->ruler_x1 = mwindow->edl->session->ruler_x2 - distance_value / 1.414214;
1203 mwindow->edl->session->ruler_y1 = mwindow->edl->session->ruler_y2 - distance_value / 1.414214;
1206 if(mwindow->edl->session->ruler_x1 < mwindow->edl->session->ruler_x2 && mwindow->edl->session->ruler_y1 > mwindow->edl->session->ruler_y2)
1208 mwindow->edl->session->ruler_x1 = mwindow->edl->session->ruler_x2 - distance_value / 1.414214;
1209 mwindow->edl->session->ruler_y1 = mwindow->edl->session->ruler_y2 + distance_value / 1.414214;
1212 if(mwindow->edl->session->ruler_x1 > mwindow->edl->session->ruler_x2 &&
1213 mwindow->edl->session->ruler_y1 < mwindow->edl->session->ruler_y2)
1215 mwindow->edl->session->ruler_x1 = mwindow->edl->session->ruler_x2 + distance_value / 1.414214;
1216 mwindow->edl->session->ruler_y1 = mwindow->edl->session->ruler_y2 - distance_value / 1.414214;
1220 mwindow->edl->session->ruler_x1 = mwindow->edl->session->ruler_x2 + distance_value / 1.414214;
1221 mwindow->edl->session->ruler_y1 = mwindow->edl->session->ruler_y2 + distance_value / 1.414214;
1224 do_ruler(1, 0, 0, 0);
1225 get_canvas()->flash();
1230 do_ruler(1, 0, 0, 0);
1231 mwindow->edl->session->ruler_x2 = output_x - gui->x_origin + gui->ruler_origin_x;
1232 mwindow->edl->session->ruler_y2 = output_y - gui->y_origin + gui->ruler_origin_y;
1233 if(gui->alt_down() || gui->ctrl_down())
1235 double angle_value = fabs(atan((mwindow->edl->session->ruler_y2 - mwindow->edl->session->ruler_y1) /
1236 (mwindow->edl->session->ruler_x2 - mwindow->edl->session->ruler_x1)) *
1240 double distance_value =
1241 sqrt(SQR(mwindow->edl->session->ruler_x2 - mwindow->edl->session->ruler_x1) +
1242 SQR(mwindow->edl->session->ruler_y2 - mwindow->edl->session->ruler_y1));
1243 if(angle_value < 22)
1244 mwindow->edl->session->ruler_y2 = mwindow->edl->session->ruler_y1;
1246 if(angle_value > 67)
1247 mwindow->edl->session->ruler_x2 = mwindow->edl->session->ruler_x1;
1249 if(mwindow->edl->session->ruler_x2 < mwindow->edl->session->ruler_x1 &&
1250 mwindow->edl->session->ruler_y2 < mwindow->edl->session->ruler_y1)
1252 mwindow->edl->session->ruler_x2 = mwindow->edl->session->ruler_x1 - distance_value / 1.414214;
1253 mwindow->edl->session->ruler_y2 = mwindow->edl->session->ruler_y1 - distance_value / 1.414214;
1256 if(mwindow->edl->session->ruler_x2 < mwindow->edl->session->ruler_x1 &&
1257 mwindow->edl->session->ruler_y2 > mwindow->edl->session->ruler_y1)
1259 mwindow->edl->session->ruler_x2 = mwindow->edl->session->ruler_x1 - distance_value / 1.414214;
1260 mwindow->edl->session->ruler_y2 = mwindow->edl->session->ruler_y1 + distance_value / 1.414214;
1263 if(mwindow->edl->session->ruler_x2 > mwindow->edl->session->ruler_x1 && mwindow->edl->session->ruler_y2 < mwindow->edl->session->ruler_y1)
1265 mwindow->edl->session->ruler_x2 = mwindow->edl->session->ruler_x1 + distance_value / 1.414214;
1266 mwindow->edl->session->ruler_y2 = mwindow->edl->session->ruler_y1 - distance_value / 1.414214;
1270 mwindow->edl->session->ruler_x2 = mwindow->edl->session->ruler_x1 + distance_value / 1.414214;
1271 mwindow->edl->session->ruler_y2 = mwindow->edl->session->ruler_y1 + distance_value / 1.414214;
1274 do_ruler(1, 0, 0, 0);
1275 get_canvas()->flash();
1279 //printf("CWindowCanvas::do_ruler 2 %f %f %f %f\n", gui->ruler_x1, gui->ruler_y1, gui->ruler_x2, gui->ruler_y2);
1283 // printf("CWindowCanvas::do_ruler 2 %f %f %f %f\n",
1288 if(canvas_cursor_x >= canvas_x1 - RULERHANDLE_W / 2 &&
1289 canvas_cursor_x < canvas_x1 + RULERHANDLE_W / 2 &&
1290 canvas_cursor_y >= canvas_y1 - RULERHANDLE_W &&
1291 canvas_cursor_y < canvas_y1 + RULERHANDLE_H / 2)
1293 set_cursor(UPRIGHT_ARROW_CURSOR);
1296 if(canvas_cursor_x >= canvas_x2 - RULERHANDLE_W / 2 &&
1297 canvas_cursor_x < canvas_x2 + RULERHANDLE_W / 2 &&
1298 canvas_cursor_y >= canvas_y2 - RULERHANDLE_W &&
1299 canvas_cursor_y < canvas_y2 + RULERHANDLE_H / 2)
1301 set_cursor(UPRIGHT_ARROW_CURSOR);
1304 set_cursor(CROSS_CURSOR);
1306 // Update current position
1311 // Assume no ruler measurement if 0 length
1312 if(draw && (!EQUIV(x2, x1) || !EQUIV(y2, y1)))
1314 get_canvas()->set_inverse();
1315 get_canvas()->set_color(WHITE);
1316 get_canvas()->draw_line((int)canvas_x1,
1320 get_canvas()->draw_line(roundf(canvas_x1) - RULERHANDLE_W / 2,
1322 roundf(canvas_x1) + RULERHANDLE_W / 2,
1324 get_canvas()->draw_line(roundf(canvas_x1),
1325 roundf(canvas_y1) - RULERHANDLE_H / 2,
1327 roundf(canvas_y1) + RULERHANDLE_H / 2);
1328 get_canvas()->draw_line(roundf(canvas_x2) - RULERHANDLE_W / 2,
1330 roundf(canvas_x2) + RULERHANDLE_W / 2,
1332 get_canvas()->draw_line(roundf(canvas_x2),
1333 roundf(canvas_y2) - RULERHANDLE_H / 2,
1335 roundf(canvas_y2) + RULERHANDLE_H / 2);
1336 get_canvas()->set_opaque();
1343 static inline double line_dist(float cx,float cy, float tx,float ty)
1345 double dx = tx-cx, dy = ty-cy;
1346 return sqrt(dx*dx + dy*dy);
1349 static inline bool test_bbox(int cx, int cy, int tx, int ty)
1351 // printf("test_bbox %d,%d - %d,%d = %f\n",cx,cy,tx,ty,line_dist(cx,cy,tx,ty));
1352 return (llabs(cx-tx) < CONTROL_W/2 && llabs(cy-ty) < CONTROL_H/2);
1356 int CWindowCanvas::do_mask(int &redraw, int &rerender,
1357 int button_press, int cursor_motion, int draw)
1359 // Retrieve points from top recordable track
1360 //printf("CWindowCanvas::do_mask 1\n");
1361 Track *track = gui->cwindow->calculate_affected_track();
1362 //printf("CWindowCanvas::do_mask 2\n");
1364 if(!track) return 0;
1365 //printf("CWindowCanvas::do_mask 3\n");
1367 MaskAutos *mask_autos = (MaskAutos*)track->automation->autos[AUTOMATION_MASK];
1368 int64_t position = track->to_units(
1369 mwindow->edl->local_session->get_selectionstart(1),
1371 ArrayList<MaskPoint*> points;
1373 // Determine the points based on whether
1374 // new keyframes will be generated or drawing is performed.
1375 // If keyframe generation occurs, use the interpolated mask.
1376 // If no keyframe generation occurs, use the previous mask.
1377 int use_interpolated = 0;
1378 if(button_press || cursor_motion) {
1379 #ifdef USE_KEYFRAME_SPANNING
1380 double selection_start = mwindow->edl->local_session->get_selectionstart(0);
1381 double selection_end = mwindow->edl->local_session->get_selectionend(0);
1384 mask_autos->get_prev_auto(track->to_units(selection_start, 0),
1385 PLAY_FORWARD, first, 1);
1387 mask_autos->get_prev_auto(track->to_units(selection_end, 0),
1388 PLAY_FORWARD, last, 1);
1390 if(last == first && (!mwindow->edl->session->auto_keyframes))
1391 use_interpolated = 0;
1393 // If keyframe spanning occurs, use the interpolated points.
1394 // If new keyframe is generated, use the interpolated points.
1395 use_interpolated = 1;
1398 if(mwindow->edl->session->auto_keyframes)
1399 use_interpolated = 1;
1403 use_interpolated = 1;
1405 if(use_interpolated) {
1406 // Interpolate the points to get exactly what is being rendered at this position.
1407 mask_autos->get_points(&points,
1408 mwindow->edl->session->cwindow_mask,
1413 // Use the prev mask
1415 mask_autos->get_prev_auto(position,
1419 ((MaskAuto*)prev)->get_points(&points,
1420 mwindow->edl->session->cwindow_mask);
1423 // Projector zooms relative to the center of the track output.
1424 float half_track_w = (float)track->track_w / 2;
1425 float half_track_h = (float)track->track_h / 2;
1426 // Translate mask to projection
1427 float projector_x, projector_y, projector_z;
1428 track->automation->get_projector(
1429 &projector_x, &projector_y, &projector_z,
1430 position, PLAY_FORWARD);
1433 // Get position of cursor relative to mask
1434 float cursor_x = get_cursor_x(), cursor_y = get_cursor_y();
1435 float mask_cursor_x = cursor_x, mask_cursor_y = cursor_y;
1436 canvas_to_output(mwindow->edl, 0, mask_cursor_x, mask_cursor_y);
1438 projector_x += mwindow->edl->session->output_w / 2;
1439 projector_y += mwindow->edl->session->output_h / 2;
1440 mask_cursor_x = (mask_cursor_x - projector_x) / projector_z + half_track_w;
1441 mask_cursor_y = (mask_cursor_y - projector_y) / projector_z + half_track_h;
1443 // Fix cursor origin
1445 gui->x_origin = mask_cursor_x;
1446 gui->y_origin = mask_cursor_y;
1450 // Points of closest line
1451 int shortest_point1 = -1;
1452 int shortest_point2 = -1;
1454 int shortest_point = -1;
1455 // Distance to closest line
1456 float shortest_line_distance = BC_INFINITY;
1457 // Distance to closest point
1458 float shortest_point_distance = BC_INFINITY;
1459 int selected_point = -1;
1460 int selected_control_point = -1;
1461 float selected_control_point_distance = BC_INFINITY;
1462 ArrayList<int> x_points;
1463 ArrayList<int> y_points;
1465 if(!cursor_motion) {
1467 get_canvas()->set_color(WHITE);
1468 get_canvas()->set_inverse();
1470 //printf("CWindowCanvas::do_mask 1 %d\n", points.size());
1472 // Never draw closed polygon and a closed
1473 // polygon is harder to add points to.
1474 for(int i = 0; i < points.size() && !result; i++) {
1475 MaskPoint *point1 = points.get(i);
1476 MaskPoint *point2 = (i >= points.size() - 1) ?
1477 points.get(0) : points.get(i + 1);
1479 float point_distance1 = line_dist(point1->x,point1->y, mask_cursor_x,mask_cursor_y);
1480 if(point_distance1 < shortest_point_distance || shortest_point < 0) {
1481 shortest_point_distance = point_distance1;
1485 float point_distance2 = line_dist(point2->x,point2->y, mask_cursor_x,mask_cursor_y);
1486 if(point_distance2 < shortest_point_distance || shortest_point < 0) {
1487 shortest_point_distance = point_distance2;
1488 shortest_point = (i >= points.size() - 1) ? 0 : (i + 1);
1492 int segments = 1 + line_dist(point1->x,point1->y, point2->x,point2->y);
1494 //printf("CWindowCanvas::do_mask 1 %f, %f -> %f, %f projectorz=%f\n",
1495 //point1->x, point1->y, point2->x, point2->y, projector_z);
1496 for(int j = 0; j <= segments && !result; j++) {
1497 //printf("CWindowCanvas::do_mask 1 %f, %f -> %f, %f\n", x0, y0, x3, y3);
1498 float x0 = point1->x, y0 = point1->y;
1499 float x1 = point1->x + point1->control_x2;
1500 float y1 = point1->y + point1->control_y2;
1501 float x2 = point2->x + point2->control_x1;
1502 float y2 = point2->y + point2->control_y1;
1503 float x3 = point2->x, y3 = point2->y;
1504 float canvas_x0 = (x0 - half_track_w) * projector_z + projector_x;
1505 float canvas_y0 = (y0 - half_track_h) * projector_z + projector_y;
1506 float canvas_x1 = (x1 - half_track_w) * projector_z + projector_x;
1507 float canvas_y1 = (y1 - half_track_h) * projector_z + projector_y;
1508 float canvas_x2 = (x2 - half_track_w) * projector_z + projector_x;
1509 float canvas_y2 = (y2 - half_track_h) * projector_z + projector_y;
1510 float canvas_x3 = (x3 - half_track_w) * projector_z + projector_x;
1511 float canvas_y3 = (y3 - half_track_h) * projector_z + projector_y;
1513 float t = (float)j / segments;
1514 float tpow2 = t * t;
1515 float tpow3 = t * t * t;
1517 float invtpow2 = invt * invt;
1518 float invtpow3 = invt * invt * invt;
1520 float x = ( invtpow3 * x0
1521 + 3 * t * invtpow2 * x1
1522 + 3 * tpow2 * invt * x2
1524 float y = ( invtpow3 * y0
1525 + 3 * t * invtpow2 * y1
1526 + 3 * tpow2 * invt * y2
1528 float canvas_x = (x - half_track_w) * projector_z + projector_x;
1529 float canvas_y = (y - half_track_h) * projector_z + projector_y;
1530 // Test new point addition
1532 float line_distance = line_dist(x,y, mask_cursor_x,mask_cursor_y);
1534 //printf("CWindowCanvas::do_mask 1 x=%f cursor_x=%f y=%f cursor_y=%f %f %f %d, %d\n",
1535 // x, cursor_x, y, cursor_y, line_distance, shortest_line_distance, shortest_point1, shortest_point2);
1536 if(line_distance < shortest_line_distance ||
1537 shortest_point1 < 0) {
1538 shortest_line_distance = line_distance;
1539 shortest_point1 = i;
1540 shortest_point2 = (i >= points.size() - 1) ? 0 : (i + 1);
1541 //printf("CWindowCanvas::do_mask 2 %f %f %d, %d\n",
1542 // line_distance, shortest_line_distance, shortest_point1, shortest_point2);
1545 // Test existing point selection
1547 if(gui->ctrl_down()) {
1548 float distance = line_dist(x1,y1, mask_cursor_x,mask_cursor_y);
1550 if(distance < selected_control_point_distance) {
1552 selected_control_point = 1;
1553 selected_control_point_distance = distance;
1557 if(!gui->shift_down()) {
1558 output_to_canvas(mwindow->edl, 0, canvas_x0, canvas_y0);
1559 if(test_bbox(cursor_x, cursor_y, canvas_x0, canvas_y0)) {
1564 selected_point = shortest_point;
1567 // Test second point
1568 if(gui->ctrl_down()) {
1569 float distance = line_dist(x2,y2, mask_cursor_x,mask_cursor_y);
1571 //printf("CWindowCanvas::do_mask %d %f %f\n", i, distance, selected_control_point_distance);
1572 if(distance < selected_control_point_distance) {
1573 selected_point = (i < points.size() - 1 ? i + 1 : 0);
1574 selected_control_point = 0;
1575 selected_control_point_distance = distance;
1578 else if(i < points.size() - 1) {
1579 if(!gui->shift_down()) {
1580 output_to_canvas(mwindow->edl, 0, canvas_x3, canvas_y3);
1581 if(test_bbox(cursor_x, cursor_y, canvas_x3, canvas_y3)) {
1582 selected_point = (i < points.size() - 1 ? i + 1 : 0);
1586 selected_point = shortest_point;
1591 output_to_canvas(mwindow->edl, 0, canvas_x, canvas_y);
1595 if(draw) { // Draw joining line
1596 x_points.append((int)canvas_x);
1597 y_points.append((int)canvas_y);
1601 if(draw) { // Draw second anchor
1602 if(i < points.size() - 1) {
1603 if(i == gui->affected_point - 1)
1604 get_canvas()->draw_disc(
1605 (int)canvas_x - CONTROL_W / 2,
1606 (int)canvas_y - CONTROL_W / 2,
1607 CONTROL_W, CONTROL_H);
1609 get_canvas()->draw_circle(
1610 (int)canvas_x - CONTROL_W / 2,
1611 (int)canvas_y - CONTROL_W / 2,
1612 CONTROL_W, CONTROL_H);
1613 // char string[BCTEXTLEN];
1614 // sprintf(string, "%d", (i < points.size() - 1 ? i + 1 : 0));
1615 // canvas->draw_text((int)canvas_x + CONTROL_W, (int)canvas_y + CONTROL_W, string);
1617 // Draw second control point.
1618 output_to_canvas(mwindow->edl, 0, canvas_x2, canvas_y2);
1619 get_canvas()->draw_line(
1620 (int)canvas_x, (int)canvas_y,
1621 (int)canvas_x2, (int)canvas_y2);
1622 get_canvas()->draw_rectangle(
1623 (int)canvas_x2 - CONTROL_W / 2,
1624 (int)canvas_y2 - CONTROL_H / 2,
1625 CONTROL_W, CONTROL_H);
1630 // Draw first anchor
1631 if(i == 0 && draw) {
1632 char mask_label[BCSTRLEN];
1633 sprintf(mask_label, "%d",
1634 mwindow->edl->session->cwindow_mask);
1635 get_canvas()->draw_text(
1636 (int)canvas_x - FIRST_CONTROL_W,
1637 (int)canvas_y - FIRST_CONTROL_H,
1640 get_canvas()->draw_disc(
1641 (int)canvas_x - FIRST_CONTROL_W / 2,
1642 (int)canvas_y - FIRST_CONTROL_H / 2,
1643 FIRST_CONTROL_W, FIRST_CONTROL_H);
1646 // Draw first control point.
1648 output_to_canvas(mwindow->edl, 0, canvas_x1, canvas_y1);
1649 get_canvas()->draw_line(
1650 (int)canvas_x, (int)canvas_y,
1651 (int)canvas_x1, (int)canvas_y1);
1652 get_canvas()->draw_rectangle(
1653 (int)canvas_x1 - CONTROL_W / 2,
1654 (int)canvas_y1 - CONTROL_H / 2,
1655 CONTROL_W, CONTROL_H);
1657 x_points.append((int)canvas_x);
1658 y_points.append((int)canvas_y);
1661 //printf("CWindowCanvas::do_mask 1\n");
1665 //printf("CWindowCanvas::do_mask 1\n");
1668 get_canvas()->draw_polygon(&x_points, &y_points);
1669 get_canvas()->set_opaque();
1671 //printf("CWindowCanvas::do_mask 1\n");
1674 if(button_press && !result) {
1675 gui->affected_track = gui->cwindow->calculate_affected_track();
1677 // Get keyframe outside the EDL to edit. This must be rendered
1678 // instead of the EDL keyframes when it exists. Then it must be
1679 // applied to the EDL keyframes on buttonrelease.
1680 if(gui->affected_track) {
1681 #ifdef USE_KEYFRAME_SPANNING
1682 // Make copy of current parameters in local keyframe
1683 gui->mask_keyframe =
1684 (MaskAuto*)gui->cwindow->calculate_affected_auto(
1687 gui->orig_mask_keyframe->copy_data(gui->mask_keyframe);
1690 gui->mask_keyframe =
1691 (MaskAuto*)gui->cwindow->calculate_affected_auto(
1696 SubMask *mask = gui->mask_keyframe->get_submask(mwindow->edl->session->cwindow_mask);
1699 // Translate entire keyframe
1700 if(gui->alt_down() && mask->points.size()) {
1701 mwindow->undo->update_undo_before(_("mask translate"), 0);
1702 gui->current_operation = CWINDOW_MASK_TRANSLATE;
1703 gui->affected_point = 0;
1706 // Existing point or control point was selected
1707 if(selected_point >= 0) {
1708 mwindow->undo->update_undo_before(_("mask adjust"), 0);
1709 gui->affected_point = selected_point;
1711 if(selected_control_point == 0)
1712 gui->current_operation = CWINDOW_MASK_CONTROL_IN;
1714 if(selected_control_point == 1)
1715 gui->current_operation = CWINDOW_MASK_CONTROL_OUT;
1717 gui->current_operation = mwindow->edl->session->cwindow_operation;
1719 else // No existing point or control point was selected so create a new one
1720 if(!gui->ctrl_down() && !gui->alt_down()) {
1721 mwindow->undo->update_undo_before(_("mask point"), 0);
1722 // Create the template
1723 MaskPoint *point = new MaskPoint;
1724 point->x = mask_cursor_x;
1725 point->y = mask_cursor_y;
1726 point->control_x1 = 0;
1727 point->control_y1 = 0;
1728 point->control_x2 = 0;
1729 point->control_y2 = 0;
1732 if(shortest_point2 < shortest_point1) {
1733 shortest_point2 ^= shortest_point1;
1734 shortest_point1 ^= shortest_point2;
1735 shortest_point2 ^= shortest_point1;
1740 // printf("CWindowGUI::do_mask 40\n");
1741 // mwindow->edl->dump();
1742 // printf("CWindowGUI::do_mask 50\n");
1746 //printf("CWindowCanvas::do_mask 1 %f %f %d %d\n",
1747 // shortest_line_distance, shortest_point_distance, shortest_point1, shortest_point2);
1748 //printf("CWindowCanvas::do_mask %d %d\n", shortest_point1, shortest_point2);
1750 // Append to end of list
1751 if( shortest_point1 == shortest_point2 ||
1752 labs(shortest_point1 - shortest_point2) > 1) {
1753 #ifdef USE_KEYFRAME_SPANNING
1755 MaskPoint *new_point = new MaskPoint;
1756 points.append(new_point);
1757 *new_point = *point;
1758 gui->affected_point = points.size() - 1;
1762 // Need to apply the new point to every keyframe
1763 for(MaskAuto *current = (MaskAuto*)mask_autos->default_auto; current; ) {
1764 SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
1765 MaskPoint *new_point = new MaskPoint;
1766 submask->points.append(new_point);
1767 *new_point = *point;
1768 if(current == (MaskAuto*)mask_autos->default_auto)
1769 current = (MaskAuto*)mask_autos->first;
1771 current = (MaskAuto*)NEXT;
1773 gui->affected_point = mask->points.size() - 1;
1779 // Insert between 2 points, shifting back point 2
1780 if(shortest_point1 >= 0 && shortest_point2 >= 0) {
1782 #ifdef USE_KEYFRAME_SPANNING
1783 // In case the keyframe point count isn't synchronized with the rest of the keyframes,
1785 if(points.size() >= shortest_point2) {
1786 MaskPoint *new_point = new MaskPoint;
1788 for(int i = points.size() - 1;
1789 i > shortest_point2;
1791 points.values[i] = points.values[i - 1];
1792 points.values[shortest_point2] = new_point;
1794 *new_point = *point;
1799 for(MaskAuto *current = (MaskAuto*)mask_autos->default_auto; current; ) {
1800 SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
1801 // In case the keyframe point count isn't synchronized with the rest of the keyframes,
1803 if(submask->points.size() >= shortest_point2) {
1804 MaskPoint *new_point = new MaskPoint;
1805 submask->points.append(0);
1806 for(int i = submask->points.size() - 1;
1807 i > shortest_point2;
1809 submask->points.values[i] = submask->points.values[i - 1];
1810 submask->points.values[shortest_point2] = new_point;
1812 *new_point = *point;
1815 if(current == (MaskAuto*)mask_autos->default_auto)
1816 current = (MaskAuto*)mask_autos->first;
1818 current = (MaskAuto*)NEXT;
1822 gui->affected_point = shortest_point2;
1827 // printf("CWindowGUI::do_mask 20\n");
1828 // mwindow->edl->dump();
1829 // printf("CWindowGUI::do_mask 30\n");
1832 //printf("CWindowCanvas::do_mask 1\n");
1833 // Create the first point.
1834 #ifdef USE_KEYFRAME_SPANNING
1835 MaskPoint *new_point = new MaskPoint;
1836 points.append(new_point);
1837 *new_point = *point;
1838 gui->affected_point = points.size() - 1;
1840 for(MaskAuto *current = (MaskAuto*)mask_autos->default_auto; current; ) {
1841 SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
1842 MaskPoint *new_point = new MaskPoint;
1843 submask->points.append(new_point);
1844 *new_point = *point;
1845 if(current == (MaskAuto*)mask_autos->default_auto)
1846 current = (MaskAuto*)mask_autos->first;
1848 current = (MaskAuto*)NEXT;
1850 gui->affected_point = points.size() - 1;
1853 //printf("CWindowCanvas::do_mask 3 %d\n", mask->points.size());
1856 gui->current_operation = mwindow->edl->session->cwindow_operation;
1857 // Delete the template
1866 if(button_press && result) {
1867 #ifdef USE_KEYFRAME_SPANNING
1868 MaskPoint *point = points.values[gui->affected_point];
1869 gui->center_x = point->x;
1870 gui->center_y = point->y;
1871 gui->control_in_x = point->control_x1;
1872 gui->control_in_y = point->control_y1;
1873 gui->control_out_x = point->control_x2;
1874 gui->control_out_y = point->control_y2;
1875 gui->tool_panel->raise_window();
1877 SubMask *mask = gui->mask_keyframe->get_submask(mwindow->edl->session->cwindow_mask);
1878 MaskPoint *point = mask->points.values[gui->affected_point];
1879 gui->center_x = point->x;
1880 gui->center_y = point->y;
1881 gui->control_in_x = point->control_x1;
1882 gui->control_in_y = point->control_y1;
1883 gui->control_out_x = point->control_x2;
1884 gui->control_out_y = point->control_y2;
1885 gui->tool_panel->raise_window();
1889 //printf("CWindowCanvas::do_mask 8\n");
1892 #ifdef USE_KEYFRAME_SPANNING
1893 // Must update the reference keyframes for every cursor motion
1894 gui->mask_keyframe =
1895 (MaskAuto*)gui->cwindow->calculate_affected_auto(
1898 gui->orig_mask_keyframe->copy_data(gui->mask_keyframe);
1901 //printf("CWindowCanvas::do_mask %d %d\n", __LINE__, gui->affected_point);
1903 SubMask *mask = gui->mask_keyframe->get_submask(mwindow->edl->session->cwindow_mask);
1904 if( gui->affected_point >= 0 && gui->affected_point < mask->points.size() &&
1905 gui->current_operation != CWINDOW_NONE) {
1906 // mwindow->undo->update_undo_before(_("mask point"), this);
1907 #ifdef USE_KEYFRAME_SPANNING
1908 MaskPoint *point = points.get(gui->affected_point);
1910 MaskPoint *point = mask->points.get(gui->affected_point);
1912 // canvas_to_output(mwindow->edl, 0, cursor_x, cursor_y);
1913 //printf("CWindowCanvas::do_mask 9 %d %d\n", mask->points.size(), gui->affected_point);
1915 float last_x = point->x;
1916 float last_y = point->y;
1917 float last_control_x1 = point->control_x1;
1918 float last_control_y1 = point->control_y1;
1919 float last_control_x2 = point->control_x2;
1920 float last_control_y2 = point->control_y2;
1922 switch(gui->current_operation) {
1924 //printf("CWindowCanvas::do_mask %d %d\n", __LINE__, gui->affected_point);
1925 point->x = mask_cursor_x - gui->x_origin + gui->center_x;
1926 point->y = mask_cursor_y - gui->y_origin + gui->center_y;
1929 case CWINDOW_MASK_CONTROL_IN:
1930 point->control_x1 = mask_cursor_x - gui->x_origin + gui->control_in_x;
1931 point->control_y1 = mask_cursor_y - gui->y_origin + gui->control_in_y;
1934 case CWINDOW_MASK_CONTROL_OUT:
1935 point->control_x2 = mask_cursor_x - gui->x_origin + gui->control_out_x;
1936 point->control_y2 = mask_cursor_y - gui->y_origin + gui->control_out_y;
1939 case CWINDOW_MASK_TRANSLATE:
1940 #ifdef USE_KEYFRAME_SPANNING
1941 for(int i = 0; i < points.size(); i++) {
1942 points.values[i]->x += mask_cursor_x - gui->x_origin;
1943 points.values[i]->y += mask_cursor_y - gui->y_origin;
1946 for(int i = 0; i < mask->points.size(); i++) {
1947 mask->points.values[i]->x += mask_cursor_x - gui->x_origin;
1948 mask->points.values[i]->y += mask_cursor_y - gui->y_origin;
1951 gui->x_origin = mask_cursor_x;
1952 gui->y_origin = mask_cursor_y;
1956 if( !EQUIV(last_x, point->x) ||
1957 !EQUIV(last_y, point->y) ||
1958 !EQUIV(last_control_x1, point->control_x1) ||
1959 !EQUIV(last_control_y1, point->control_y1) ||
1960 !EQUIV(last_control_x2, point->control_x2) ||
1961 !EQUIV(last_control_y2, point->control_y2)) {
1967 if(gui->current_operation == CWINDOW_NONE) {
1968 // printf("CWindowCanvas::do_mask %d\n", __LINE__);
1970 for(int i = 0; i < points.size() && !over_point; i++) {
1971 MaskPoint *point = points.get(i);
1972 float x0 = point->x;
1973 float y0 = point->y;
1974 float x1 = point->x + point->control_x1;
1975 float y1 = point->y + point->control_y1;
1976 float x2 = point->x + point->control_x2;
1977 float y2 = point->y + point->control_y2;
1978 float canvas_x0 = (x0 - half_track_w) * projector_z + projector_x;
1979 float canvas_y0 = (y0 - half_track_h) * projector_z + projector_y;
1981 output_to_canvas(mwindow->edl, 0, canvas_x0, canvas_y0);
1982 if(test_bbox(cursor_x, cursor_y, canvas_x0, canvas_y0)) {
1986 if(!over_point && gui->ctrl_down()) {
1987 float canvas_x1 = (x1 - half_track_w) * projector_z + projector_x;
1988 float canvas_y1 = (y1 - half_track_h) * projector_z + projector_y;
1989 output_to_canvas(mwindow->edl, 0, canvas_x1, canvas_y1);
1990 if(test_bbox(cursor_x, cursor_y, canvas_x1, canvas_y1)) {
1994 float canvas_x2 = (x2 - half_track_w) * projector_z + projector_x;
1995 float canvas_y2 = (y2 - half_track_h) * projector_z + projector_y;
1996 output_to_canvas(mwindow->edl, 0, canvas_x2, canvas_y2);
1997 if(test_bbox(cursor_x, cursor_y, canvas_x2, canvas_y2)) {
2004 set_cursor( over_point ? ARROW_CURSOR : CROSS_CURSOR );
2009 //printf("CWindowCanvas::do_mask 2 %d %d %d\n", result, rerender, redraw);
2012 #ifdef USE_KEYFRAME_SPANNING
2013 // Must commit change after operation.
2014 if(rerender && track) {
2015 // Swap EDL keyframe with original.
2016 // Apply new values to keyframe span
2017 MaskAuto temp_keyframe(mwindow->edl, mask_autos);
2018 temp_keyframe.copy_data(gui->mask_keyframe);
2019 // Apply interpolated points back to keyframe
2020 temp_keyframe.set_points(&points, mwindow->edl->session->cwindow_mask);
2021 gui->mask_keyframe->copy_data(gui->orig_mask_keyframe);
2022 mask_autos->update_parameter(&temp_keyframe);
2026 points.remove_all_objects();
2027 //printf("CWindowCanvas::do_mask 20\n");
2031 int CWindowCanvas::do_eyedrop(int &rerender, int button_press, int draw)
2034 int radius = mwindow->edl->session->eyedrop_radius;
2042 if(refresh_frame && refresh_frame->get_w()>0 && refresh_frame->get_h()>0)
2047 row1 = gui->eyedrop_y - radius;
2048 row2 = gui->eyedrop_y + radius;
2049 column1 = gui->eyedrop_x - radius;
2050 column2 = gui->eyedrop_x + radius;
2052 CLAMP(row1, 0, refresh_frame->get_h() - 1);
2053 CLAMP(row2, 0, refresh_frame->get_h() - 1);
2054 CLAMP(column1, 0, refresh_frame->get_w() - 1);
2055 CLAMP(column2, 0, refresh_frame->get_w() - 1);
2057 if(row2 <= row1) row2 = row1 + 1;
2058 if(column2 <= column1) column2 = column1 + 1;
2065 output_to_canvas(mwindow->edl, 0, x1, y1);
2066 output_to_canvas(mwindow->edl, 0, x2, y2);
2067 //printf("CWindowCanvas::do_eyedrop %d %f %f %f %f\n", __LINE__, x1, x2, y1, y2);
2069 if(x2 - x1 >= 1 && y2 - y1 >= 1)
2071 get_canvas()->set_inverse();
2072 get_canvas()->set_color(WHITE);
2074 get_canvas()->draw_rectangle((int)x1,
2079 get_canvas()->set_opaque();
2080 get_canvas()->flash();
2088 gui->current_operation = CWINDOW_EYEDROP;
2089 gui->tool_panel->raise_window();
2092 if(gui->current_operation == CWINDOW_EYEDROP)
2094 mwindow->undo->update_undo_before(_("Eyedrop"), this);
2096 // Get color out of frame.
2097 // Doesn't work during playback because that bypasses the refresh frame.
2098 if(refresh_frame && refresh_frame->get_w()>0 && refresh_frame->get_h()>0)
2100 float cursor_x = get_cursor_x();
2101 float cursor_y = get_cursor_y();
2102 canvas_to_output(mwindow->edl, 0, cursor_x, cursor_y);
2103 CLAMP(cursor_x, 0, refresh_frame->get_w() - 1);
2104 CLAMP(cursor_y, 0, refresh_frame->get_h() - 1);
2106 row1 = cursor_y - radius;
2107 row2 = cursor_y + radius;
2108 column1 = cursor_x - radius;
2109 column2 = cursor_x + radius;
2110 CLAMP(row1, 0, refresh_frame->get_h() - 1);
2111 CLAMP(row2, 0, refresh_frame->get_h() - 1);
2112 CLAMP(column1, 0, refresh_frame->get_w() - 1);
2113 CLAMP(column2, 0, refresh_frame->get_w() - 1);
2114 if(row2 <= row1) row2 = row1 + 1;
2115 if(column2 <= column1) column2 = column1 + 1;
2119 if(gui->eyedrop_visible)
2122 do_eyedrop(temp, 0, 1);
2123 gui->eyedrop_visible = 0;
2126 gui->eyedrop_x = cursor_x;
2127 gui->eyedrop_y = cursor_y;
2132 do_eyedrop(temp, 0, 1);
2133 gui->eyedrop_visible = 1;
2136 // Decompression coefficients straight out of jpeglib
2137 #define V_TO_R 1.40200
2138 #define V_TO_G -0.71414
2140 #define U_TO_G -0.34414
2141 #define U_TO_B 1.77200
2143 #define GET_COLOR(type, components, max, do_yuv) \
2145 type *row = (type*)(refresh_frame->get_rows()[i]) + \
2147 float red = (float)*row++ / max; \
2148 float green = (float)*row++ / max; \
2149 float blue = (float)*row++ / max; \
2152 float r = red + V_TO_R * (blue - 0.5); \
2153 float g = red + U_TO_G * (green - 0.5) + V_TO_G * (blue - 0.5); \
2154 float b = red + U_TO_B * (green - 0.5); \
2155 mwindow->edl->local_session->red += r; \
2156 mwindow->edl->local_session->green += g; \
2157 mwindow->edl->local_session->blue += b; \
2158 if(r > mwindow->edl->local_session->red_max) mwindow->edl->local_session->red_max = r; \
2159 if(g > mwindow->edl->local_session->green_max) mwindow->edl->local_session->green_max = g; \
2160 if(b > mwindow->edl->local_session->blue_max) mwindow->edl->local_session->blue_max = b; \
2164 mwindow->edl->local_session->red += red; \
2165 mwindow->edl->local_session->green += green; \
2166 mwindow->edl->local_session->blue += blue; \
2167 if(red > mwindow->edl->local_session->red_max) mwindow->edl->local_session->red_max = red; \
2168 if(green > mwindow->edl->local_session->green_max) mwindow->edl->local_session->green_max = green; \
2169 if(blue > mwindow->edl->local_session->blue_max) mwindow->edl->local_session->blue_max = blue; \
2175 mwindow->edl->local_session->red = 0;
2176 mwindow->edl->local_session->green = 0;
2177 mwindow->edl->local_session->blue = 0;
2178 mwindow->edl->local_session->red_max = 0;
2179 mwindow->edl->local_session->green_max = 0;
2180 mwindow->edl->local_session->blue_max = 0;
2181 for(int i = row1; i < row2; i++)
2183 for(int j = column1; j < column2; j++)
2185 switch(refresh_frame->get_color_model())
2188 GET_COLOR(unsigned char, 3, 0xff, 1);
2191 GET_COLOR(unsigned char, 4, 0xff, 1);
2194 GET_COLOR(uint16_t, 3, 0xffff, 1);
2196 case BC_YUVA16161616:
2197 GET_COLOR(uint16_t, 4, 0xffff, 1);
2200 GET_COLOR(unsigned char, 3, 0xff, 0);
2203 GET_COLOR(unsigned char, 4, 0xff, 0);
2206 GET_COLOR(float, 3, 1.0, 0);
2209 GET_COLOR(float, 4, 1.0, 0);
2215 mwindow->edl->local_session->red /= (row2 - row1) * (column2 - column1);
2216 mwindow->edl->local_session->green /= (row2 - row1) * (column2 - column1);
2217 mwindow->edl->local_session->blue /= (row2 - row1) * (column2 - column1);
2222 mwindow->edl->local_session->red = 0;
2223 mwindow->edl->local_session->green = 0;
2224 mwindow->edl->local_session->blue = 0;
2225 gui->eyedrop_visible = 0;
2234 // Can't rerender since the color value is from the output of any effect it
2237 mwindow->undo->update_undo_after(_("Eyedrop"), LOAD_SESSION);
2243 void CWindowCanvas::draw_overlays()
2245 if(mwindow->edl->session->safe_regions)
2247 draw_safe_regions();
2250 if(mwindow->edl->session->cwindow_scrollbars)
2252 // Always draw output rectangle
2253 float x1, y1, x2, y2;
2255 x2 = mwindow->edl->session->output_w;
2257 y2 = mwindow->edl->session->output_h;
2258 output_to_canvas(mwindow->edl, 0, x1, y1);
2259 output_to_canvas(mwindow->edl, 0, x2, y2);
2261 get_canvas()->set_inverse();
2262 get_canvas()->set_color(WHITE);
2264 get_canvas()->draw_rectangle((int)x1,
2269 get_canvas()->set_opaque();
2272 if(gui->highlighted)
2274 get_canvas()->set_color(WHITE);
2275 get_canvas()->set_inverse();
2276 get_canvas()->draw_rectangle(0, 0, get_canvas()->get_w(), get_canvas()->get_h());
2277 get_canvas()->draw_rectangle(1, 1, get_canvas()->get_w() - 2, get_canvas()->get_h() - 2);
2278 get_canvas()->set_opaque();
2281 int temp1 = 0, temp2 = 0;
2282 //printf("CWindowCanvas::draw_overlays 1 %d\n", mwindow->edl->session->cwindow_operation);
2283 switch(mwindow->edl->session->cwindow_operation)
2285 case CWINDOW_CAMERA:
2289 case CWINDOW_PROJECTOR:
2298 do_mask(temp1, temp2, 0, 0, 1);
2302 do_ruler(1, 0, 0, 0);
2305 case CWINDOW_EYEDROP:
2306 if(gui->eyedrop_visible)
2309 do_eyedrop(rerender, 0, 1);
2310 gui->eyedrop_visible = 1;
2316 void CWindowCanvas::draw_safe_regions()
2318 float action_x1, action_x2, action_y1, action_y2;
2319 float title_x1, title_x2, title_y1, title_y2;
2321 action_x1 = mwindow->edl->session->output_w / 2 - mwindow->edl->session->output_w / 2 * 0.9;
2322 action_x2 = mwindow->edl->session->output_w / 2 + mwindow->edl->session->output_w / 2 * 0.9;
2323 action_y1 = mwindow->edl->session->output_h / 2 - mwindow->edl->session->output_h / 2 * 0.9;
2324 action_y2 = mwindow->edl->session->output_h / 2 + mwindow->edl->session->output_h / 2 * 0.9;
2325 title_x1 = mwindow->edl->session->output_w / 2 - mwindow->edl->session->output_w / 2 * 0.8;
2326 title_x2 = mwindow->edl->session->output_w / 2 + mwindow->edl->session->output_w / 2 * 0.8;
2327 title_y1 = mwindow->edl->session->output_h / 2 - mwindow->edl->session->output_h / 2 * 0.8;
2328 title_y2 = mwindow->edl->session->output_h / 2 + mwindow->edl->session->output_h / 2 * 0.8;
2330 output_to_canvas(mwindow->edl, 0, action_x1, action_y1);
2331 output_to_canvas(mwindow->edl, 0, action_x2, action_y2);
2332 output_to_canvas(mwindow->edl, 0, title_x1, title_y1);
2333 output_to_canvas(mwindow->edl, 0, title_x2, title_y2);
2335 get_canvas()->set_inverse();
2336 get_canvas()->set_color(WHITE);
2338 get_canvas()->draw_rectangle((int)action_x1,
2340 (int)(action_x2 - action_x1),
2341 (int)(action_y2 - action_y1));
2342 get_canvas()->draw_rectangle((int)title_x1,
2344 (int)(title_x2 - title_x1),
2345 (int)(title_y2 - title_y1));
2347 get_canvas()->set_opaque();
2350 void CWindowCanvas::reset_keyframe(int do_camera)
2352 FloatAuto *x_keyframe = 0;
2353 FloatAuto *y_keyframe = 0;
2354 FloatAuto *z_keyframe = 0;
2355 Track *affected_track = 0;
2357 affected_track = gui->cwindow->calculate_affected_track();
2361 gui->cwindow->calculate_affected_autos(&x_keyframe,
2370 x_keyframe->set_value(0);
2371 y_keyframe->set_value(0);
2372 z_keyframe->set_value(1);
2374 mwindow->sync_parameters(CHANGE_PARAMS);
2379 void CWindowCanvas::reset_camera()
2384 void CWindowCanvas::reset_projector()
2389 int CWindowCanvas::test_crop(int button_press, int &redraw)
2392 int handle_selected = -1;
2393 float x1 = mwindow->edl->session->crop_x1;
2394 float y1 = mwindow->edl->session->crop_y1;
2395 float x2 = mwindow->edl->session->crop_x2;
2396 float y2 = mwindow->edl->session->crop_y2;
2397 float cursor_x = get_cursor_x();
2398 float cursor_y = get_cursor_y();
2399 float canvas_x1 = x1;
2400 float canvas_y1 = y1;
2401 float canvas_x2 = x2;
2402 float canvas_y2 = y2;
2403 float canvas_cursor_x = cursor_x;
2404 float canvas_cursor_y = cursor_y;
2406 canvas_to_output(mwindow->edl, 0, cursor_x, cursor_y);
2407 // Use screen normalized coordinates for hot spot tests.
2408 output_to_canvas(mwindow->edl, 0, canvas_x1, canvas_y1);
2409 output_to_canvas(mwindow->edl, 0, canvas_x2, canvas_y2);
2412 if(gui->current_operation == CWINDOW_CROP)
2414 handle_selected = gui->crop_handle;
2417 if(canvas_cursor_x >= canvas_x1 && canvas_cursor_x < canvas_x1 + CROPHANDLE_W &&
2418 canvas_cursor_y >= canvas_y1 && canvas_cursor_y < canvas_y1 + CROPHANDLE_H)
2420 handle_selected = 0;
2421 gui->crop_origin_x = x1;
2422 gui->crop_origin_y = y1;
2425 if(canvas_cursor_x >= canvas_x2 - CROPHANDLE_W && canvas_cursor_x < canvas_x2 &&
2426 canvas_cursor_y >= canvas_y1 && canvas_cursor_y < canvas_y1 + CROPHANDLE_H)
2428 handle_selected = 1;
2429 gui->crop_origin_x = x2;
2430 gui->crop_origin_y = y1;
2433 if(canvas_cursor_x >= canvas_x1 && canvas_cursor_x < canvas_x1 + CROPHANDLE_W &&
2434 canvas_cursor_y >= canvas_y2 - CROPHANDLE_H && canvas_cursor_y < canvas_y2)
2436 handle_selected = 2;
2437 gui->crop_origin_x = x1;
2438 gui->crop_origin_y = y2;
2441 if(canvas_cursor_x >= canvas_x2 - CROPHANDLE_W && canvas_cursor_x < canvas_x2 &&
2442 canvas_cursor_y >= canvas_y2 - CROPHANDLE_H && canvas_cursor_y < canvas_y2)
2444 handle_selected = 3;
2445 gui->crop_origin_x = x2;
2446 gui->crop_origin_y = y2;
2451 gui->crop_origin_x = cursor_x;
2452 gui->crop_origin_y = cursor_y;
2455 // printf("test crop %d %d\n",
2456 // gui->current_operation,
2457 // handle_selected);
2464 gui->crop_translate = 1;
2465 gui->crop_origin_x1 = x1;
2466 gui->crop_origin_y1 = y1;
2467 gui->crop_origin_x2 = x2;
2468 gui->crop_origin_y2 = y2;
2471 gui->crop_translate = 0;
2473 gui->current_operation = CWINDOW_CROP;
2474 gui->crop_handle = handle_selected;
2475 gui->x_origin = cursor_x;
2476 gui->y_origin = cursor_y;
2477 gui->tool_panel->raise_window();
2480 if(handle_selected < 0 && !gui->crop_translate)
2484 mwindow->edl->session->crop_x1 = (int)x1;
2485 mwindow->edl->session->crop_y1 = (int)y1;
2486 mwindow->edl->session->crop_x2 = (int)x2;
2487 mwindow->edl->session->crop_y2 = (int)y2;
2492 // Translate all 4 points
2493 if(gui->current_operation == CWINDOW_CROP && gui->crop_translate)
2495 x1 = cursor_x - gui->x_origin + gui->crop_origin_x1;
2496 y1 = cursor_y - gui->y_origin + gui->crop_origin_y1;
2497 x2 = cursor_x - gui->x_origin + gui->crop_origin_x2;
2498 y2 = cursor_y - gui->y_origin + gui->crop_origin_y2;
2500 mwindow->edl->session->crop_x1 = (int)x1;
2501 mwindow->edl->session->crop_y1 = (int)y1;
2502 mwindow->edl->session->crop_x2 = (int)x2;
2503 mwindow->edl->session->crop_y2 = (int)y2;
2509 if(gui->current_operation == CWINDOW_CROP)
2511 switch(gui->crop_handle)
2514 x1 = gui->crop_origin_x;
2515 y1 = gui->crop_origin_y;
2516 x2 = gui->crop_origin_x;
2517 y2 = gui->crop_origin_y;
2518 if(cursor_x < gui->x_origin)
2520 if(cursor_y < gui->y_origin)
2526 if(cursor_y >= gui->y_origin)
2533 if(cursor_x >= gui->x_origin)
2535 if(cursor_y < gui->y_origin)
2541 if(cursor_y >= gui->y_origin)
2548 // printf("test crop %d %d %d %d\n",
2549 // mwindow->edl->session->crop_x1,
2550 // mwindow->edl->session->crop_y1,
2551 // mwindow->edl->session->crop_x2,
2552 // mwindow->edl->session->crop_y2);
2555 x1 = cursor_x - gui->x_origin + gui->crop_origin_x;
2556 y1 = cursor_y - gui->y_origin + gui->crop_origin_y;
2559 x2 = cursor_x - gui->x_origin + gui->crop_origin_x;
2560 y1 = cursor_y - gui->y_origin + gui->crop_origin_y;
2563 x1 = cursor_x - gui->x_origin + gui->crop_origin_x;
2564 y2 = cursor_y - gui->y_origin + gui->crop_origin_y;
2567 x2 = cursor_x - gui->x_origin + gui->crop_origin_x;
2568 y2 = cursor_y - gui->y_origin + gui->crop_origin_y;
2572 if(!EQUIV(mwindow->edl->session->crop_x1, x1) ||
2573 !EQUIV(mwindow->edl->session->crop_x2, x2) ||
2574 !EQUIV(mwindow->edl->session->crop_y1, y1) ||
2575 !EQUIV(mwindow->edl->session->crop_y2, y2))
2582 switch (gui->crop_handle)
2584 case 0: gui->crop_handle = 1; break;
2585 case 1: gui->crop_handle = 0; break;
2586 case 2: gui->crop_handle = 3; break;
2587 case 3: gui->crop_handle = 2; break;
2597 switch (gui->crop_handle)
2599 case 0: gui->crop_handle = 2; break;
2600 case 1: gui->crop_handle = 3; break;
2601 case 2: gui->crop_handle = 0; break;
2602 case 3: gui->crop_handle = 1; break;
2607 mwindow->edl->session->crop_x1 = (int)x1;
2608 mwindow->edl->session->crop_y1 = (int)y1;
2609 mwindow->edl->session->crop_x2 = (int)x2;
2610 mwindow->edl->session->crop_y2 = (int)y2;
2616 // Update cursor font
2617 if(handle_selected >= 0)
2619 switch(handle_selected)
2622 set_cursor(UPLEFT_RESIZE);
2625 set_cursor(UPRIGHT_RESIZE);
2628 set_cursor(DOWNLEFT_RESIZE);
2631 set_cursor(DOWNRIGHT_RESIZE);
2638 set_cursor(ARROW_CURSOR);
2640 #define CLAMP(x, y, z) ((x) = ((x) < (y) ? (y) : ((x) > (z) ? (z) : (x))))
2644 CLAMP(mwindow->edl->session->crop_x1, 0, mwindow->edl->session->output_w);
2645 CLAMP(mwindow->edl->session->crop_x2, 0, mwindow->edl->session->output_w);
2646 CLAMP(mwindow->edl->session->crop_y1, 0, mwindow->edl->session->output_h);
2647 CLAMP(mwindow->edl->session->crop_y2, 0, mwindow->edl->session->output_h);
2648 // printf("CWindowCanvas::test_crop %d %d %d %d\n",
2649 // mwindow->edl->session->crop_x2,
2650 // mwindow->edl->session->crop_y2,
2651 // mwindow->edl->calculate_output_w(0),
2652 // mwindow->edl->calculate_output_h(0));
2658 void CWindowCanvas::draw_crop()
2660 get_canvas()->set_inverse();
2661 get_canvas()->set_color(WHITE);
2663 float x1 = mwindow->edl->session->crop_x1;
2664 float y1 = mwindow->edl->session->crop_y1;
2665 float x2 = mwindow->edl->session->crop_x2;
2666 float y2 = mwindow->edl->session->crop_y2;
2668 output_to_canvas(mwindow->edl, 0, x1, y1);
2669 output_to_canvas(mwindow->edl, 0, x2, y2);
2671 if(x2 - x1 && y2 - y1)
2672 get_canvas()->draw_rectangle((int)x1,
2677 draw_crophandle((int)x1, (int)y1);
2678 draw_crophandle((int)x2 - CROPHANDLE_W, (int)y1);
2679 draw_crophandle((int)x1, (int)y2 - CROPHANDLE_H);
2680 draw_crophandle((int)x2 - CROPHANDLE_W, (int)y2 - CROPHANDLE_H);
2681 get_canvas()->set_opaque();
2691 void CWindowCanvas::draw_bezier(int do_camera)
2693 Track *track = gui->cwindow->calculate_affected_track();
2700 int64_t position = track->to_units(
2701 mwindow->edl->local_session->get_selectionstart(1),
2704 track->automation->get_projector(¢er_x,
2710 // center_x += track->track_w / 2;
2711 // center_y += track->track_h / 2;
2712 center_x += mwindow->edl->session->output_w / 2;
2713 center_y += mwindow->edl->session->output_h / 2;
2714 float track_x1 = center_x - track->track_w / 2 * center_z;
2715 float track_y1 = center_y - track->track_h / 2 * center_z;
2716 float track_x2 = track_x1 + track->track_w * center_z;
2717 float track_y2 = track_y1 + track->track_h * center_z;
2719 output_to_canvas(mwindow->edl, 0, track_x1, track_y1);
2720 output_to_canvas(mwindow->edl, 0, track_x2, track_y2);
2722 #define DRAW_PROJECTION(offset) \
2723 get_canvas()->draw_rectangle((int)track_x1 + offset, \
2724 (int)track_y1 + offset, \
2725 (int)(track_x2 - track_x1), \
2726 (int)(track_y2 - track_y1)); \
2727 get_canvas()->draw_line((int)track_x1 + offset, \
2728 (int)track_y1 + offset, \
2729 (int)track_x2 + offset, \
2730 (int)track_y2 + offset); \
2731 get_canvas()->draw_line((int)track_x2 + offset, \
2732 (int)track_y1 + offset, \
2733 (int)track_x1 + offset, \
2734 (int)track_y2 + offset); \
2738 get_canvas()->set_color(BLACK);
2741 // canvas->set_inverse();
2743 get_canvas()->set_color(GREEN);
2745 get_canvas()->set_color(RED);
2748 // canvas->set_opaque();
2752 int CWindowCanvas::test_bezier(int button_press,
2760 // Processing drag operation.
2761 // Create keyframe during first cursor motion.
2765 float cursor_x = get_cursor_x();
2766 float cursor_y = get_cursor_y();
2767 canvas_to_output(mwindow->edl, 0, cursor_x, cursor_y);
2769 if(gui->current_operation == CWINDOW_CAMERA ||
2770 gui->current_operation == CWINDOW_PROJECTOR)
2772 if(!gui->ctrl_down() && gui->shift_down() && !gui->translating_zoom)
2774 gui->translating_zoom = 1;
2775 gui->reset_affected();
2778 if(!gui->ctrl_down() && !gui->shift_down() && gui->translating_zoom)
2780 gui->translating_zoom = 0;
2781 gui->reset_affected();
2784 // Get target keyframe
2785 float last_center_x;
2786 float last_center_y;
2787 float last_center_z;
2790 if(!gui->affected_x && !gui->affected_y && !gui->affected_z)
2792 FloatAutos *affected_x_autos;
2793 FloatAutos *affected_y_autos;
2794 FloatAutos *affected_z_autos;
2795 if(!gui->affected_track) return 0;
2796 double position = mwindow->edl->local_session->get_selectionstart(1);
2797 int64_t track_position = gui->affected_track->to_units(position, 0);
2799 if(mwindow->edl->session->cwindow_operation == CWINDOW_CAMERA)
2801 affected_x_autos = (FloatAutos*)gui->affected_track->automation->autos[AUTOMATION_CAMERA_X];
2802 affected_y_autos = (FloatAutos*)gui->affected_track->automation->autos[AUTOMATION_CAMERA_Y];
2803 affected_z_autos = (FloatAutos*)gui->affected_track->automation->autos[AUTOMATION_CAMERA_Z];
2807 affected_x_autos = (FloatAutos*)gui->affected_track->automation->autos[AUTOMATION_PROJECTOR_X];
2808 affected_y_autos = (FloatAutos*)gui->affected_track->automation->autos[AUTOMATION_PROJECTOR_Y];
2809 affected_z_autos = (FloatAutos*)gui->affected_track->automation->autos[AUTOMATION_PROJECTOR_Z];
2813 if(gui->translating_zoom)
2815 FloatAuto *previous = 0;
2816 FloatAuto *next = 0;
2817 float new_z = affected_z_autos->get_value(
2823 (FloatAuto*)gui->cwindow->calculate_affected_auto(
2824 affected_z_autos, 1, &created, 0);
2826 gui->affected_z->set_value(new_z);
2832 FloatAuto *previous = 0;
2833 FloatAuto *next = 0;
2834 float new_x = affected_x_autos->get_value(
2841 float new_y = affected_y_autos->get_value(
2847 (FloatAuto*)gui->cwindow->calculate_affected_auto(
2848 affected_x_autos, 1, &created, 0);
2850 gui->affected_x->set_value(new_x);
2854 (FloatAuto*)gui->cwindow->calculate_affected_auto(
2855 affected_y_autos, 1, &created, 0);
2857 gui->affected_y->set_value(new_y);
2864 if(gui->translating_zoom)
2866 gui->center_z = gui->affected_z->get_value();
2870 gui->center_x = gui->affected_x->get_value();
2871 gui->center_y = gui->affected_y->get_value();
2878 if(gui->translating_zoom)
2880 last_center_z = gui->affected_z->get_value();
2881 float z = gui->center_z + (cursor_y - gui->y_origin) / 128;
2883 if(!EQUIV(last_center_z, z))
2889 gui->affected_z->set_value(z);
2893 last_center_x = gui->affected_x->get_value();
2894 last_center_y = gui->affected_y->get_value();
2895 float x = gui->center_x + cursor_x - gui->x_origin;
2896 float y = gui->center_y + cursor_y - gui->y_origin;
2897 gui->affected_x->set_value(x);
2898 gui->affected_y->set_value(y);
2899 if( !EQUIV(last_center_x, x) || !EQUIV(last_center_y, y) )
2905 gui->affected_x->set_value(x);
2906 gui->affected_y->set_value(y);
2913 // Begin drag operation. Don't create keyframe here.
2915 // Get affected track off of the first recordable video track.
2916 // Calculating based on the alpha channel would require recording what layer
2917 // each output pixel belongs to as they're rendered and stacked. Forget it.
2918 gui->affected_track = gui->cwindow->calculate_affected_track();
2919 gui->reset_affected();
2921 if(gui->affected_track)
2923 if(gui->current_operation == CWINDOW_CAMERA)
2924 mwindow->undo->update_undo_before(_("camera"), this);
2926 mwindow->undo->update_undo_before(_("projector"), this);
2928 gui->current_operation =
2929 mwindow->edl->session->cwindow_operation;
2930 gui->tool_panel->raise_window();
2939 int CWindowCanvas::test_zoom(int &redraw)
2945 if( mwindow->edl->session->cwindow_scrollbars ) {
2946 if( *gui->zoom_panel->get_text() != 'x' ) {
2947 // Find current zoom in table
2948 int idx = total_zooms; float old_zoom = get_zoom();
2949 while( --idx >= 0 && !EQUIV(my_zoom_table[idx], old_zoom) );
2951 idx += get_buttonpress() == 5 ||
2952 gui->ctrl_down() || gui->shift_down() ? -1 : +1 ;
2953 CLAMP(idx, 0, total_zooms-1);
2954 zoom = my_zoom_table[idx];
2957 x = get_cursor_x(); y = get_cursor_y();
2959 mwindow->edl->session->cwindow_scrollbars = 0;
2960 gui->zoom_panel->update(0);
2961 zoom = gui->get_auto_zoom();
2964 gui->zoom_panel->ZoomPanel::update(zoom);
2965 float output_x = x, output_y = y;
2966 canvas_to_output(mwindow->edl, 0, output_x, output_y);
2967 x = output_x - x / zoom;
2968 y = output_y - y / zoom;
2972 mwindow->edl->session->cwindow_scrollbars = 1;
2973 x = (mwindow->edl->session->output_w - w) / 2;
2974 y = (mwindow->edl->session->output_h - h) / 2;
2977 update_zoom((int)x, (int)y, zoom);
2979 gui->composite_panel->cpanel_zoom->update(zoom);
2981 reposition_window(mwindow->edl,
2982 mwindow->theme->ccanvas_x, mwindow->theme->ccanvas_y,
2983 mwindow->theme->ccanvas_w, mwindow->theme->ccanvas_h);
2984 redraw = 1; result = 1;
2990 void CWindowCanvas::calculate_origin()
2992 gui->x_origin = get_cursor_x();
2993 gui->y_origin = get_cursor_y();
2994 //printf("CWindowCanvas::calculate_origin 1 %f %f\n", gui->x_origin, gui->y_origin);
2995 canvas_to_output(mwindow->edl, 0, gui->x_origin, gui->y_origin);
2996 //printf("CWindowCanvas::calculate_origin 2 %f %f\n", gui->x_origin, gui->y_origin);
3000 int CWindowCanvas::cursor_leave_event()
3002 set_cursor(ARROW_CURSOR);
3006 int CWindowCanvas::cursor_enter_event()
3009 switch(mwindow->edl->session->cwindow_operation)
3011 case CWINDOW_CAMERA:
3012 case CWINDOW_PROJECTOR:
3013 set_cursor(MOVE_CURSOR);
3016 set_cursor(MOVE_CURSOR);
3019 test_crop(0, redraw);
3021 case CWINDOW_PROTECT:
3022 set_cursor(ARROW_CURSOR);
3026 set_cursor(CROSS_CURSOR);
3028 case CWINDOW_EYEDROP:
3029 set_cursor(CROSS_CURSOR);
3035 int CWindowCanvas::cursor_motion_event()
3037 int redraw = 0, result = 0, rerender = 0, redraw_canvas = 0;
3040 //printf("CWindowCanvas::cursor_motion_event %d current_operation=%d\n", __LINE__, gui->current_operation);
3041 switch(gui->current_operation)
3043 case CWINDOW_SCROLL:
3045 float zoom = get_zoom();
3046 float cursor_x = get_cursor_x();
3047 float cursor_y = get_cursor_y();
3049 float zoom_x, zoom_y, conformed_w, conformed_h;
3050 get_zooms(mwindow->edl, 0, zoom_x, zoom_y, conformed_w, conformed_h);
3051 cursor_x = (float)cursor_x / zoom_x + gui->x_offset;
3052 cursor_y = (float)cursor_y / zoom_y + gui->y_offset;
3056 int x = (int)(gui->x_origin - cursor_x + gui->x_offset);
3057 int y = (int)(gui->y_origin - cursor_y + gui->y_offset);
3062 update_scrollbars(0);
3069 result = do_ruler(0, 1, 0, 0);
3072 case CWINDOW_CAMERA:
3073 result = test_bezier(0, redraw, redraw_canvas, rerender, 1);
3076 case CWINDOW_PROJECTOR:
3077 result = test_bezier(0, redraw, redraw_canvas, rerender, 0);
3082 result = test_crop(0, redraw);
3083 // printf("CWindowCanvas::cursor_motion_event %d result=%d redraw=%d\n",
3090 case CWINDOW_MASK_CONTROL_IN:
3091 case CWINDOW_MASK_CONTROL_OUT:
3092 case CWINDOW_MASK_TRANSLATE:
3094 result = do_mask(redraw,
3101 case CWINDOW_EYEDROP:
3102 result = do_eyedrop(rerender, 0, 0);
3111 // cursor font changes
3114 // printf("CWindowCanvas::cursor_motion_event %d cwindow_operation=%d\n",
3116 // mwindow->edl->session->cwindow_operation);
3117 switch(mwindow->edl->session->cwindow_operation)
3120 result = test_crop(0, redraw);
3123 result = do_ruler(0, 1, 0, 0);
3126 result = do_mask(redraw,
3136 // If the window is never unlocked before calling send_command the
3137 // display shouldn't get stuck on the old video frame although it will
3138 // flicker between the old video frame and the new video frame.
3148 gui->unlock_window();
3151 mwindow->gui->lock_window("CWindowCanvas::cursor_motion_event 1");
3152 mwindow->gui->draw_overlays(1);
3153 mwindow->gui->unlock_window();
3155 gui->lock_window("CWindowCanvas::cursor_motion_event 1");
3160 gui->unlock_window();
3161 mwindow->restart_brender();
3162 mwindow->sync_parameters(CHANGE_PARAMS);
3163 mwindow->cwindow->refresh_frame(CHANGE_NONE);
3164 if(!redraw) gui->update_tool();
3165 gui->lock_window("CWindowCanvas::cursor_motion_event 2");
3170 int CWindowCanvas::button_press_event()
3174 int redraw_canvas = 0;
3177 if(Canvas::button_press_event()) return 1;
3179 gui->translating_zoom = gui->shift_down();
3182 //printf("CWindowCanvas::button_press_event 2 %f %f\n", gui->x_origin, gui->y_origin, gui->x_origin, gui->y_origin);
3184 float zoom_x, zoom_y, conformed_w, conformed_h;
3185 get_zooms(mwindow->edl, 0, zoom_x, zoom_y, conformed_w, conformed_h);
3186 gui->x_offset = get_x_offset(mwindow->edl, 0, zoom_x, conformed_w, conformed_h);
3187 gui->y_offset = get_y_offset(mwindow->edl, 0, zoom_y, conformed_w, conformed_h);
3190 if(get_buttonpress() == 2)
3192 gui->current_operation = CWINDOW_SCROLL;
3198 switch(mwindow->edl->session->cwindow_operation)
3201 result = do_ruler(0, 0, 1, 0);
3204 case CWINDOW_CAMERA:
3205 result = test_bezier(1, redraw, redraw_canvas, rerender, 1);
3208 case CWINDOW_PROJECTOR:
3209 result = test_bezier(1, redraw, redraw_canvas, rerender, 0);
3213 result = test_zoom(redraw);
3217 result = test_crop(1, redraw);
3221 if(get_buttonpress() == 1)
3222 result = do_mask(redraw, rerender, 1, 0, 0);
3225 case CWINDOW_EYEDROP:
3226 result = do_eyedrop(rerender, 1, 0);
3234 gui->unlock_window();
3237 mwindow->gui->lock_window("CWindowCanvas::button_press_event 1");
3238 mwindow->gui->draw_overlays(1);
3239 mwindow->gui->unlock_window();
3242 gui->lock_window("CWindowCanvas::button_press_event 1");
3245 // rerendering can also be caused by press event
3248 gui->unlock_window();
3250 mwindow->restart_brender();
3251 mwindow->sync_parameters(CHANGE_PARAMS);
3252 mwindow->cwindow->refresh_frame(CHANGE_NONE);
3253 if(!redraw) gui->update_tool();
3254 gui->lock_window("CWindowCanvas::button_press_event 2");
3259 int CWindowCanvas::button_release_event()
3263 switch(gui->current_operation)
3265 case CWINDOW_SCROLL:
3270 do_ruler(0, 0, 0, 1);
3273 case CWINDOW_CAMERA:
3274 mwindow->undo->update_undo_after(_("camera"), LOAD_AUTOMATION);
3277 case CWINDOW_PROJECTOR:
3278 mwindow->undo->update_undo_after(_("projector"), LOAD_AUTOMATION);
3282 case CWINDOW_MASK_CONTROL_IN:
3283 case CWINDOW_MASK_CONTROL_OUT:
3284 case CWINDOW_MASK_TRANSLATE:
3285 // Finish mask operation
3286 gui->mask_keyframe = 0;
3287 mwindow->undo->update_undo_after(_("mask"), LOAD_AUTOMATION);
3290 result = Canvas::button_release_event();
3294 gui->current_operation = CWINDOW_NONE;
3298 void CWindowCanvas::zoom_resize_window(float percentage)
3300 int canvas_w, canvas_h;
3304 // Get required canvas size
3305 calculate_sizes(mwindow->edl->get_aspect_ratio(),
3306 mwindow->edl->session->output_w,
3307 mwindow->edl->session->output_h,
3312 // Estimate window size from current borders
3313 new_w = canvas_w + (gui->get_w() - mwindow->theme->ccanvas_w);
3314 new_h = canvas_h + (gui->get_h() - mwindow->theme->ccanvas_h);
3316 //printf("CWindowCanvas::zoom_resize_window %d %d %d\n", __LINE__, new_w, new_h);
3317 mwindow->session->cwindow_w = new_w;
3318 mwindow->session->cwindow_h = new_h;
3320 mwindow->theme->get_cwindow_sizes(gui,
3321 mwindow->session->cwindow_controls);
3323 // Estimate again from new borders
3324 new_w = canvas_w + (mwindow->session->cwindow_w - mwindow->theme->ccanvas_w);
3325 new_h = canvas_h + (mwindow->session->cwindow_h - mwindow->theme->ccanvas_h);
3326 //printf("CWindowCanvas::zoom_resize_window %d %d %d\n", __LINE__, new_w, new_h);
3328 gui->resize_window(new_w, new_h);
3329 gui->resize_event(new_w, new_h);
3332 void CWindowCanvas::toggle_controls()
3334 mwindow->session->cwindow_controls = !mwindow->session->cwindow_controls;
3335 gui->resize_event(gui->get_w(), gui->get_h());
3338 int CWindowCanvas::get_cwindow_controls()
3340 return mwindow->session->cwindow_controls;