4 * Copyright (C) 2008 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 "bcsignals.h"
26 #include "edlsession.h"
29 #include "mainsession.h"
30 #include "mwindowgui.h"
33 #include "playback3d.h"
34 #include "videodevice.h"
39 Canvas::Canvas(MWindow *mwindow,
40 BC_WindowBase *subwindow,
53 this->mwindow = mwindow;
54 this->subwindow = subwindow;
59 this->output_w = output_w;
60 this->output_h = output_h;
61 this->use_scrollbars = use_scrollbars;
62 this->canvas_auxwindow = 0;
63 this->scr_w0 = subwindow->get_screen_w(0, 0);
64 this->root_w = subwindow->get_root_w(0);
65 this->root_h = subwindow->get_root_h(0);
66 canvas_lock = new Mutex("Canvas::canvas_lock", 1);
71 if(refresh_frame) delete refresh_frame;
73 if(yscroll) delete yscroll;
74 if(xscroll) delete xscroll;
75 delete canvas_subwindow;
76 delete canvas_fullscreen;
89 canvas_fullscreen = 0;
94 void Canvas::lock_canvas(const char *location)
96 canvas_lock->lock(location);
99 void Canvas::unlock_canvas()
101 canvas_lock->unlock();
104 int Canvas::is_locked()
106 return canvas_lock->is_locked();
110 BC_WindowBase* Canvas::get_canvas()
112 if(get_fullscreen() && canvas_fullscreen)
113 return canvas_fullscreen;
114 return canvas_auxwindow ? canvas_auxwindow : canvas_subwindow;
117 void Canvas::use_auxwindow(BC_WindowBase *aux)
119 canvas_auxwindow = aux;
122 void Canvas::use_cwindow()
124 canvas_menu->use_cwindow();
125 fullscreen_menu->use_cwindow();
128 void Canvas::use_rwindow()
130 canvas_menu->use_rwindow();
133 void Canvas::use_vwindow()
135 canvas_menu->use_vwindow();
138 // Get dimensions given a zoom
139 void Canvas::calculate_sizes(float aspect_ratio,
146 // Horizontal stretch
147 if((float)output_w / output_h <= aspect_ratio)
149 w = (int)((float)output_h * aspect_ratio * zoom);
150 h = (int)((float)output_h * zoom);
155 h = (int)((float)output_w / aspect_ratio * zoom);
156 w = (int)((float)output_w * zoom);
160 float Canvas::get_x_offset(EDL *edl,
170 // If the projection is smaller than the canvas, this forces it in the center.
171 // if(conformed_w < w_visible)
172 // return -(float)(w_visible - conformed_w) / 2;
174 return (float)get_xscroll();
177 return ((float)-get_canvas()->get_w() / zoom_x +
178 edl->session->output_w) / 2;
183 int canvas_w = get_canvas()->get_w();
184 int canvas_h = get_canvas()->get_h();
188 if((float)out_w / out_h > conformed_w / conformed_h)
190 out_w = (int)(out_h * conformed_w / conformed_h + 0.5);
194 return -(canvas_w - out_w) / 2 / zoom_x;
200 float Canvas::get_y_offset(EDL *edl,
210 // If the projection is smaller than the canvas, this forces it in the center.
211 // if(conformed_h < h_visible)
212 // return -(float)(h_visible - conformed_h) / 2;
214 return (float)get_yscroll();
217 return ((float)-get_canvas()->get_h() / zoom_y +
218 edl->session->output_h) / 2;
223 int canvas_w = get_canvas()->get_w();
224 int canvas_h = get_canvas()->get_h();
228 if((float)out_w / out_h <= conformed_w / conformed_h)
230 out_h = (int)((float)out_w / (conformed_w / conformed_h) + 0.5);
233 //printf("Canvas::get_y_offset 1 %d %d %f\n", out_h, canvas_h, -((float)canvas_h - out_h) / 2);
235 return -((float)canvas_h - out_h) / 2 / zoom_y;
241 // This may not be used anymore
242 void Canvas::check_boundaries(EDL *edl, int &x, int &y, float &zoom)
244 if(x + w_visible > w_needed) x = w_needed - w_visible;
245 if(y + h_visible > h_needed) y = h_needed - h_visible;
251 void Canvas::update_scrollbars(int flush)
255 if(xscroll) xscroll->update_length(w_needed, get_xscroll(), w_visible, flush);
256 if(yscroll) yscroll->update_length(h_needed, get_yscroll(), h_visible, flush);
260 void Canvas::get_zooms(EDL *edl,
267 edl->calculate_conformed_dimensions(single_channel,
273 zoom_x = get_zoom() *
275 edl->session->output_w;
276 zoom_y = get_zoom() *
278 edl->session->output_h;
283 int canvas_w = get_canvas()->get_w();
284 int canvas_h = get_canvas()->get_h();
289 if((float)out_w / out_h > conformed_w / conformed_h)
291 out_w = (int)((float)out_h * conformed_w / conformed_h + 0.5);
295 out_h = (int)((float)out_w / (conformed_w / conformed_h) + 0.5);
298 zoom_x = (float)out_w / edl->session->output_w;
299 zoom_y = (float)out_h / edl->session->output_h;
300 //printf("get zooms 2 %d %d %f %f\n", canvas_w, canvas_h, conformed_w, conformed_h);
304 // Convert a coordinate on the canvas to a coordinate on the output
305 void Canvas::canvas_to_output(EDL *edl, int single_channel, float &x, float &y)
307 float zoom_x, zoom_y, conformed_w, conformed_h;
308 get_zooms(edl, single_channel, zoom_x, zoom_y, conformed_w, conformed_h);
310 //printf("Canvas::canvas_to_output y=%f zoom_y=%f y_offset=%f\n",
311 // y, zoom_y, get_y_offset(edl, single_channel, zoom_y, conformed_w, conformed_h));
313 x = (float)x / zoom_x + get_x_offset(edl, single_channel, zoom_x, conformed_w, conformed_h);
314 y = (float)y / zoom_y + get_y_offset(edl, single_channel, zoom_y, conformed_w, conformed_h);
317 void Canvas::output_to_canvas(EDL *edl, int single_channel, float &x, float &y)
319 float zoom_x, zoom_y, conformed_w, conformed_h;
320 get_zooms(edl, single_channel, zoom_x, zoom_y, conformed_w, conformed_h);
322 //printf("Canvas::output_to_canvas x=%f zoom_x=%f x_offset=%f\n", x, zoom_x, get_x_offset(edl, single_channel, zoom_x, conformed_w));
324 x = (float)zoom_x * (x - get_x_offset(edl, single_channel, zoom_x, conformed_w, conformed_h));
325 y = (float)zoom_y * (y - get_y_offset(edl, single_channel, zoom_y, conformed_w, conformed_h));
330 void Canvas::get_transfers(EDL *edl,
331 float &output_x1, float &output_y1, float &output_x2, float &output_y2,
332 float &canvas_x1, float &canvas_y1, float &canvas_x2, float &canvas_y2,
333 int canvas_w, int canvas_h)
335 // printf("Canvas::get_transfers %d %d\n", canvas_w,
337 // automatic canvas size detection
338 if(canvas_w < 0) canvas_w = get_canvas()->get_w();
339 if(canvas_h < 0) canvas_h = get_canvas()->get_h();
341 // Canvas is zoomed to a portion of the output frame
344 float in_x1, in_y1, in_x2, in_y2;
345 float out_x1, out_y1, out_x2, out_y2;
346 float zoom_x, zoom_y, conformed_w, conformed_h;
348 get_zooms(edl, 0, zoom_x, zoom_y, conformed_w, conformed_h);
358 canvas_to_output(edl, 0, in_x1, in_y1);
359 canvas_to_output(edl, 0, in_x2, in_y2);
361 //printf("Canvas::get_transfers 1 %.0f %.0f %.0f %.0f -> %.0f %.0f %.0f %.0f\n",
362 //in_x1, in_y1, in_x2, in_y2, out_x1, out_y1, out_x2, out_y2);
366 out_x1 += -in_x1 * zoom_x;
372 out_y1 += -in_y1 * zoom_y;
376 int output_w = get_output_w(edl);
377 int output_h = get_output_h(edl);
381 out_x2 -= (in_x2 - output_w) * zoom_x;
387 out_y2 -= (in_y2 - output_h) * zoom_y;
390 // printf("Canvas::get_transfers 2 %.0f %.0f %.0f %.0f -> %.0f %.0f %.0f %.0f\n",
391 // in_x1, in_y1, in_x2, in_y2, out_x1, out_y1, out_x2, out_y2);
403 // if(!scrollbars_exist())
405 // out_x = canvas_w / 2 - out_w / 2;
406 // out_y = canvas_h / 2 - out_h / 2;
411 // The output frame is normalized to the canvas
413 // Default canvas coords fill the entire canvas
416 canvas_x2 = canvas_w;
417 canvas_y2 = canvas_h;
421 // Use EDL aspect ratio to shrink one of the canvas dimensions
422 float out_w = canvas_x2 - canvas_x1;
423 float out_h = canvas_y2 - canvas_y1;
424 if(out_w / out_h > edl->get_aspect_ratio())
426 out_w = (int)(out_h * edl->get_aspect_ratio() + 0.5);
427 canvas_x1 = canvas_w / 2 - out_w / 2;
431 out_h = (int)(out_w / edl->get_aspect_ratio() + 0.5);
432 canvas_y1 = canvas_h / 2 - out_h / 2;
434 canvas_x2 = canvas_x1 + out_w;
435 canvas_y2 = canvas_y1 + out_h;
437 // Get output frame coords from EDL
440 output_x2 = get_output_w(edl);
441 output_y2 = get_output_h(edl);
444 // No EDL to get aspect ratio or output frame coords from
448 output_x2 = this->output_w;
449 output_y2 = this->output_h;
453 // Clamp to minimum value
454 output_x1 = MAX(0, output_x1);
455 output_y1 = MAX(0, output_y1);
456 output_x2 = MAX(output_x1, output_x2);
457 output_y2 = MAX(output_y1, output_y2);
458 canvas_x1 = MAX(0, canvas_x1);
459 canvas_y1 = MAX(0, canvas_y1);
460 canvas_x2 = MAX(canvas_x1, canvas_x2);
461 canvas_y2 = MAX(canvas_y1, canvas_y2);
462 // printf("Canvas::get_transfers 2 %f,%f %f,%f -> %f,%f %f,%f\n",
473 int Canvas::scrollbars_exist()
475 return(use_scrollbars && (xscroll || yscroll));
478 int Canvas::get_output_w(EDL *edl)
480 return !edl ? 0 : edl->session->output_w;
483 int Canvas::get_output_h(EDL *edl)
485 return !edl ? 0 : edl->session->output_h;
490 void Canvas::get_scrollbars(EDL *edl,
496 int need_xscroll = 0;
497 int need_yscroll = 0;
499 float zoom_x, zoom_y, conformed_w, conformed_h;
503 w_needed = edl->session->output_w;
504 h_needed = edl->session->output_h;
505 w_visible = w_needed;
506 h_visible = h_needed;
508 //printf("Canvas::get_scrollbars 1 %d %d\n", get_xscroll(), get_yscroll());
510 if( use_scrollbars ) {
511 w_needed = edl->session->output_w;
512 h_needed = edl->session->output_h;
513 get_zooms(edl, 0, zoom_x, zoom_y, conformed_w, conformed_h);
514 //printf("Canvas::get_scrollbars 2 %d %d\n", get_xscroll(), get_yscroll());
516 w_visible = (int)(canvas_w / zoom_x);
517 h_visible = (int)(canvas_h / zoom_y);
518 if( w_needed > w_visible ) {
520 canvas_h -= BC_ScrollBar::get_span(SCROLL_HORIZ);
523 if( h_needed > h_visible ) {
525 canvas_w -= BC_ScrollBar::get_span(SCROLL_VERT);
527 //printf("Canvas::get_scrollbars %d %d %d %d %d %d\n", canvas_w, canvas_h, w_needed, h_needed, w_visible, h_visible);
528 //printf("Canvas::get_scrollbars 3 %d %d\n", get_xscroll(), get_yscroll());
530 w_visible = (int)(canvas_w / zoom_x);
531 h_visible = (int)(canvas_h / zoom_y);
536 xscroll = new CanvasXScroll(edl, this, canvas_x, canvas_y + canvas_h,
537 w_needed, get_xscroll(), w_visible, canvas_w);
538 subwindow->add_subwindow(xscroll);
539 xscroll->show_window(0);
542 xscroll->reposition_window(canvas_x, canvas_y + canvas_h, canvas_w);
544 if( xscroll->get_length() != w_needed ||
545 xscroll->get_handlelength() != w_visible )
546 xscroll->update_length(w_needed, get_xscroll(), w_visible, 0);
549 delete xscroll; xscroll = 0;
551 //printf("Canvas::get_scrollbars 4 %d %d\n", get_xscroll(), get_yscroll());
555 yscroll = new CanvasYScroll(edl, this, canvas_x + canvas_w, canvas_y,
556 h_needed, get_yscroll(), h_visible, canvas_h);
557 subwindow->add_subwindow(yscroll);
558 yscroll->show_window(0);
561 yscroll->reposition_window(canvas_x + canvas_w, canvas_y, canvas_h);
563 if( yscroll->get_length() != edl->session->output_h ||
564 yscroll->get_handlelength() != h_visible )
565 yscroll->update_length(h_needed, get_yscroll(), h_visible, 0);
568 delete yscroll; yscroll = 0;
570 //printf("Canvas::get_scrollbars 5 %d %d\n", get_xscroll(), get_yscroll());
573 void Canvas::reposition_window(EDL *edl, int x, int y, int w, int h)
575 this->x = view_x = x; this->y = view_y = y;
576 this->w = view_w = w; this->h = view_h = h;
577 //printf("Canvas::reposition_window 1\n");
578 get_scrollbars(edl, view_x, view_y, view_w, view_h);
579 //printf("Canvas::reposition_window %d %d %d %d\n", view_x, view_y, view_w, view_h);
582 canvas_subwindow->reposition_window(view_x, view_y, view_w, view_h);
584 // Need to clear out the garbage in the back
585 if(canvas_subwindow->get_video_on())
587 canvas_subwindow->set_color(BLACK);
588 canvas_subwindow->draw_box(0, 0,
589 get_canvas()->get_w(), get_canvas()->get_h());
590 canvas_subwindow->flash(0);
598 void Canvas::set_cursor(int cursor)
600 get_canvas()->set_cursor(cursor, 0, 1);
603 int Canvas::get_cursor_x()
605 return get_canvas()->get_cursor_x();
608 int Canvas::get_cursor_y()
610 return get_canvas()->get_cursor_y();
613 int Canvas::get_buttonpress()
615 return get_canvas()->get_buttonpress();
619 void Canvas::create_objects(EDL *edl)
625 get_scrollbars(edl, view_x, view_y, view_w, view_h);
627 subwindow->unlock_window();
629 subwindow->lock_window("Canvas::create_objects");
631 subwindow->add_subwindow(canvas_menu = new CanvasPopup(this));
632 canvas_menu->create_objects();
634 subwindow->add_subwindow(fullscreen_menu = new CanvasFullScreenPopup(this));
635 fullscreen_menu->create_objects();
639 int Canvas::button_press_event()
643 if(get_canvas()->get_buttonpress() == 3)
646 fullscreen_menu->activate_menu();
648 canvas_menu->activate_menu();
655 void Canvas::start_single()
661 void Canvas::stop_single()
667 void Canvas::start_video()
671 get_canvas()->start_video();
676 void Canvas::stop_video()
680 get_canvas()->stop_video();
686 void Canvas::start_fullscreen()
692 void Canvas::stop_fullscreen()
698 void Canvas::create_canvas()
701 lock_canvas("Canvas::create_canvas");
704 if(!get_fullscreen())
707 if(canvas_fullscreen)
709 video_on = canvas_fullscreen->get_video_on();
710 canvas_fullscreen->stop_video();
711 canvas_fullscreen->lock_window("Canvas::create_canvas 2");
712 canvas_fullscreen->hide_window();
713 canvas_fullscreen->unlock_window();
716 if(!canvas_auxwindow && !canvas_subwindow)
718 subwindow->add_subwindow(canvas_subwindow = new CanvasOutput(this,
728 BC_WindowBase *wdw = canvas_auxwindow ?
729 canvas_auxwindow : canvas_subwindow;
732 video_on = wdw->get_video_on();
736 int x = subwindow->get_screen_x(0, -1);
737 int y = subwindow->get_screen_y(0, -1);
740 if( mwindow->screens == 1 && root_w > scr_w0 ) {
742 if( subwindow->get_x() >= scr_w0 ) {
743 // assumes right side is the big one
748 // use same aspect ratio to compute left height
750 h = (w*root_h) / (root_w-scr_w0);
754 if( canvas_fullscreen )
756 if( x != canvas_fullscreen->get_x() ||
757 y != canvas_fullscreen->get_y() ||
758 w != canvas_fullscreen->get_w() ||
759 h != canvas_fullscreen->get_h() ) {
760 delete canvas_fullscreen;
761 canvas_fullscreen = 0;
764 if(!canvas_fullscreen)
766 canvas_fullscreen = new CanvasFullScreen(this, w, h);
770 canvas_fullscreen->reposition_window(x, y);
771 canvas_fullscreen->show_window();
778 get_canvas()->lock_window("Canvas::create_canvas 1");
780 get_canvas()->unlock_window();
783 if(video_on) get_canvas()->start_video();
790 int Canvas::cursor_leave_event_base(BC_WindowBase *caller)
793 if(cursor_inside) result = cursor_leave_event();
798 int Canvas::cursor_enter_event_base(BC_WindowBase *caller)
801 if(caller->is_event_win() && caller->cursor_inside())
804 result = cursor_enter_event();
809 int Canvas::button_press_event_base(BC_WindowBase *caller)
811 if(caller->is_event_win() && caller->cursor_inside())
813 return button_press_event();
818 int Canvas::keypress_event(BC_WindowBase *caller)
820 int caller_is_canvas = (caller == get_canvas());
821 int key = caller->get_keypress();
824 caller->unlock_window();
829 if(!caller_is_canvas) caller->lock_window("Canvas::keypress_event 1");
832 caller->unlock_window();
835 if(!caller_is_canvas) caller->lock_window("Canvas::keypress_event 2");
843 void Canvas::update_refresh(VideoDevice *device, VFrame *output_frame)
845 int best_color_model = output_frame->get_color_model();
847 device->out_config->driver == PLAYBACK_X11_GL &&
848 output_frame->get_opengl_state() == VFrame::SCREEN;
850 // OpenGL does YUV->RGB in the compositing step
852 best_color_model = BC_RGB888;
855 (refresh_frame->get_w() != device->out_w ||
856 refresh_frame->get_h() != device->out_h ||
857 refresh_frame->get_color_model() != best_color_model) ) {
858 delete refresh_frame; refresh_frame = 0;
861 if( !refresh_frame ) {
863 new VFrame(device->out_w, device->out_h, best_color_model);
867 get_canvas()->unlock_window();
870 mwindow->playback_3d->copy_from(this, refresh_frame, output_frame, 0);
871 lock_canvas(" Canvas::output_refresh");
872 get_canvas()->lock_window(" Canvas::output_refresh");
875 refresh_frame->copy_from(output_frame);
882 CanvasOutput::CanvasOutput(Canvas *canvas,
887 : BC_SubWindow(x, y, w, h, BLACK)
889 this->canvas = canvas;
892 CanvasOutput::~CanvasOutput()
896 int CanvasOutput::cursor_leave_event()
898 return canvas->cursor_leave_event_base(this);
901 int CanvasOutput::cursor_enter_event()
903 return canvas->cursor_enter_event_base(this);
906 int CanvasOutput::button_press_event()
908 return canvas->button_press_event_base(this);
911 int CanvasOutput::button_release_event()
913 return canvas->button_release_event();
916 int CanvasOutput::cursor_motion_event()
918 return canvas->cursor_motion_event();
921 int CanvasOutput::keypress_event()
923 return canvas->keypress_event(this);
938 CanvasFullScreen::CanvasFullScreen(Canvas *canvas,
941 : BC_FullScreen(canvas->subwindow,
949 this->canvas = canvas;
952 CanvasFullScreen::~CanvasFullScreen()
968 CanvasXScroll::CanvasXScroll(EDL *edl,
984 this->canvas = canvas;
987 CanvasXScroll::~CanvasXScroll()
991 int CanvasXScroll::handle_event()
993 //printf("CanvasXScroll::handle_event %d %d %d\n", get_length(), get_value(), get_handlelength());
994 canvas->update_zoom(get_value(), canvas->get_yscroll(), canvas->get_zoom());
995 canvas->draw_refresh();
1004 CanvasYScroll::CanvasYScroll(EDL *edl,
1020 this->canvas = canvas;
1023 CanvasYScroll::~CanvasYScroll()
1027 int CanvasYScroll::handle_event()
1029 //printf("CanvasYScroll::handle_event %d %d\n", get_value(), get_length());
1030 canvas->update_zoom(canvas->get_xscroll(), get_value(), canvas->get_zoom());
1031 canvas->draw_refresh();
1040 CanvasFullScreenPopup::CanvasFullScreenPopup(Canvas *canvas)
1041 : BC_PopupMenu(0, 0, 0, "", 0)
1043 this->canvas = canvas;
1047 void CanvasFullScreenPopup::create_objects()
1049 add_item(new CanvasSubWindowItem(canvas));
1052 void CanvasFullScreenPopup::use_cwindow()
1054 add_item(new CanvasPopupAuto(canvas));
1057 CanvasSubWindowItem::CanvasSubWindowItem(Canvas *canvas)
1058 : BC_MenuItem(_("Windowed"), "f", 'f')
1060 this->canvas = canvas;
1063 int CanvasSubWindowItem::handle_event()
1065 // It isn't a problem to delete the canvas from in here because the event
1066 // dispatcher is the canvas subwindow.
1067 canvas->subwindow->unlock_window();
1068 canvas->stop_fullscreen();
1069 canvas->subwindow->lock_window("CanvasSubWindowItem::handle_event");
1080 CanvasPopup::CanvasPopup(Canvas *canvas)
1081 : BC_PopupMenu(0, 0, 0, "", 0)
1083 this->canvas = canvas;
1086 CanvasPopup::~CanvasPopup()
1090 void CanvasPopup::create_objects()
1092 add_item(new BC_MenuItem("-"));
1093 add_item(new CanvasFullScreenItem(canvas));
1094 add_item(new CanvasPopupSize(canvas, _("Zoom 25%"), 0.25));
1095 add_item(new CanvasPopupSize(canvas, _("Zoom 33%"), 0.33));
1096 add_item(new CanvasPopupSize(canvas, _("Zoom 50%"), 0.5));
1097 add_item(new CanvasPopupSize(canvas, _("Zoom 75%"), 0.75));
1098 add_item(new CanvasPopupSize(canvas, _("Zoom 100%"), 1.0));
1099 add_item(new CanvasPopupSize(canvas, _("Zoom 150%"), 1.5));
1100 add_item(new CanvasPopupSize(canvas, _("Zoom 200%"), 2.0));
1101 add_item(new CanvasPopupSize(canvas, _("Zoom 300%"), 3.0));
1102 add_item(new CanvasPopupSize(canvas, _("Zoom 400%"), 4.0));
1105 void CanvasPopup::use_cwindow()
1107 add_item(new CanvasPopupAuto(canvas));
1108 add_item(new CanvasPopupResetCamera(canvas));
1109 add_item(new CanvasPopupResetProjector(canvas));
1110 add_item(toggle_controls = new CanvasToggleControls(canvas));
1113 void CanvasPopup::use_rwindow()
1115 add_item(new CanvasPopupResetTranslation(canvas));
1118 void CanvasPopup::use_vwindow()
1120 add_item(new CanvasPopupRemoveSource(canvas));
1124 CanvasPopupAuto::CanvasPopupAuto(Canvas *canvas)
1125 : BC_MenuItem(_("Zoom Auto"))
1127 this->canvas = canvas;
1130 int CanvasPopupAuto::handle_event()
1132 canvas->zoom_auto();
1137 CanvasPopupSize::CanvasPopupSize(Canvas *canvas, char *text, float percentage)
1140 this->canvas = canvas;
1141 this->percentage = percentage;
1143 CanvasPopupSize::~CanvasPopupSize()
1146 int CanvasPopupSize::handle_event()
1148 canvas->zoom_resize_window(percentage);
1154 CanvasPopupResetCamera::CanvasPopupResetCamera(Canvas *canvas)
1155 : BC_MenuItem(_("Reset camera"))
1157 this->canvas = canvas;
1159 int CanvasPopupResetCamera::handle_event()
1161 canvas->reset_camera();
1167 CanvasPopupResetProjector::CanvasPopupResetProjector(Canvas *canvas)
1168 : BC_MenuItem(_("Reset projector"))
1170 this->canvas = canvas;
1172 int CanvasPopupResetProjector::handle_event()
1174 canvas->reset_projector();
1180 CanvasPopupResetTranslation::CanvasPopupResetTranslation(Canvas *canvas)
1181 : BC_MenuItem(_("Reset translation"))
1183 this->canvas = canvas;
1185 int CanvasPopupResetTranslation::handle_event()
1187 canvas->reset_translation();
1193 CanvasToggleControls::CanvasToggleControls(Canvas *canvas)
1194 : BC_MenuItem(calculate_text(canvas->get_cwindow_controls()))
1196 this->canvas = canvas;
1198 int CanvasToggleControls::handle_event()
1200 canvas->toggle_controls();
1201 set_text(calculate_text(canvas->get_cwindow_controls()));
1205 char* CanvasToggleControls::calculate_text(int cwindow_controls)
1207 if(!cwindow_controls)
1208 return _("Show controls");
1210 return _("Hide controls");
1219 CanvasFullScreenItem::CanvasFullScreenItem(Canvas *canvas)
1220 : BC_MenuItem(_("Fullscreen"), "f", 'f')
1222 this->canvas = canvas;
1224 int CanvasFullScreenItem::handle_event()
1226 canvas->subwindow->unlock_window();
1227 canvas->start_fullscreen();
1228 canvas->subwindow->lock_window("CanvasFullScreenItem::handle_event");
1240 CanvasPopupRemoveSource::CanvasPopupRemoveSource(Canvas *canvas)
1241 : BC_MenuItem(_("Close source"))
1243 this->canvas = canvas;
1245 int CanvasPopupRemoveSource::handle_event()
1247 canvas->close_source();