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"
37 Canvas::Canvas(MWindow *mwindow,
38 BC_WindowBase *subwindow,
51 this->mwindow = mwindow;
52 this->subwindow = subwindow;
57 this->output_w = output_w;
58 this->output_h = output_h;
59 this->use_scrollbars = use_scrollbars;
60 this->canvas_auxwindow = 0;
61 this->scr_w0 = subwindow->get_screen_w(0, 0);
62 this->root_w = subwindow->get_root_w(0);
63 this->root_h = subwindow->get_root_h(0);
64 canvas_lock = new Mutex("Canvas::canvas_lock", 1);
69 if(refresh_frame) delete refresh_frame;
71 if(yscroll) delete yscroll;
72 if(xscroll) delete xscroll;
73 delete canvas_subwindow;
74 delete canvas_fullscreen;
87 canvas_fullscreen = 0;
92 void Canvas::lock_canvas(const char *location)
94 canvas_lock->lock(location);
97 void Canvas::unlock_canvas()
99 canvas_lock->unlock();
102 int Canvas::is_locked()
104 return canvas_lock->is_locked();
108 BC_WindowBase* Canvas::get_canvas()
110 if(get_fullscreen() && canvas_fullscreen)
111 return canvas_fullscreen;
112 return canvas_auxwindow ? canvas_auxwindow : canvas_subwindow;
115 void Canvas::use_auxwindow(BC_WindowBase *aux)
117 canvas_auxwindow = aux;
120 void Canvas::use_cwindow()
122 canvas_menu->use_cwindow();
123 fullscreen_menu->use_cwindow();
126 void Canvas::use_rwindow()
128 canvas_menu->use_rwindow();
131 void Canvas::use_vwindow()
133 canvas_menu->use_vwindow();
136 // Get dimensions given a zoom
137 void Canvas::calculate_sizes(float aspect_ratio,
144 // Horizontal stretch
145 if((float)output_w / output_h <= aspect_ratio)
147 w = (int)((float)output_h * aspect_ratio * zoom);
148 h = (int)((float)output_h * zoom);
153 h = (int)((float)output_w / aspect_ratio * zoom);
154 w = (int)((float)output_w * zoom);
158 float Canvas::get_x_offset(EDL *edl,
168 // If the projection is smaller than the canvas, this forces it in the center.
169 // if(conformed_w < w_visible)
170 // return -(float)(w_visible - conformed_w) / 2;
172 return (float)get_xscroll();
175 return ((float)-get_canvas()->get_w() / zoom_x +
176 edl->session->output_w) / 2;
181 int canvas_w = get_canvas()->get_w();
182 int canvas_h = get_canvas()->get_h();
186 if((float)out_w / out_h > conformed_w / conformed_h)
188 out_w = (int)(out_h * conformed_w / conformed_h + 0.5);
192 return -(canvas_w - out_w) / 2 / zoom_x;
198 float Canvas::get_y_offset(EDL *edl,
208 // If the projection is smaller than the canvas, this forces it in the center.
209 // if(conformed_h < h_visible)
210 // return -(float)(h_visible - conformed_h) / 2;
212 return (float)get_yscroll();
215 return ((float)-get_canvas()->get_h() / zoom_y +
216 edl->session->output_h) / 2;
221 int canvas_w = get_canvas()->get_w();
222 int canvas_h = get_canvas()->get_h();
226 if((float)out_w / out_h <= conformed_w / conformed_h)
228 out_h = (int)((float)out_w / (conformed_w / conformed_h) + 0.5);
231 //printf("Canvas::get_y_offset 1 %d %d %f\n", out_h, canvas_h, -((float)canvas_h - out_h) / 2);
233 return -((float)canvas_h - out_h) / 2 / zoom_y;
239 // This may not be used anymore
240 void Canvas::check_boundaries(EDL *edl, int &x, int &y, float &zoom)
242 if(x + w_visible > w_needed) x = w_needed - w_visible;
243 if(y + h_visible > h_needed) y = h_needed - h_visible;
249 void Canvas::update_scrollbars(int flush)
253 if(xscroll) xscroll->update_length(w_needed, get_xscroll(), w_visible, flush);
254 if(yscroll) yscroll->update_length(h_needed, get_yscroll(), h_visible, flush);
258 void Canvas::get_zooms(EDL *edl,
265 edl->calculate_conformed_dimensions(single_channel,
271 zoom_x = get_zoom() *
273 edl->session->output_w;
274 zoom_y = get_zoom() *
276 edl->session->output_h;
281 int canvas_w = get_canvas()->get_w();
282 int canvas_h = get_canvas()->get_h();
287 if((float)out_w / out_h > conformed_w / conformed_h)
289 out_w = (int)((float)out_h * conformed_w / conformed_h + 0.5);
293 out_h = (int)((float)out_w / (conformed_w / conformed_h) + 0.5);
296 zoom_x = (float)out_w / edl->session->output_w;
297 zoom_y = (float)out_h / edl->session->output_h;
298 //printf("get zooms 2 %d %d %f %f\n", canvas_w, canvas_h, conformed_w, conformed_h);
302 // Convert a coordinate on the canvas to a coordinate on the output
303 void Canvas::canvas_to_output(EDL *edl, int single_channel, float &x, float &y)
305 float zoom_x, zoom_y, conformed_w, conformed_h;
306 get_zooms(edl, single_channel, zoom_x, zoom_y, conformed_w, conformed_h);
308 //printf("Canvas::canvas_to_output y=%f zoom_y=%f y_offset=%f\n",
309 // y, zoom_y, get_y_offset(edl, single_channel, zoom_y, conformed_w, conformed_h));
311 x = (float)x / zoom_x + get_x_offset(edl, single_channel, zoom_x, conformed_w, conformed_h);
312 y = (float)y / zoom_y + get_y_offset(edl, single_channel, zoom_y, conformed_w, conformed_h);
315 void Canvas::output_to_canvas(EDL *edl, int single_channel, float &x, float &y)
317 float zoom_x, zoom_y, conformed_w, conformed_h;
318 get_zooms(edl, single_channel, zoom_x, zoom_y, conformed_w, conformed_h);
320 //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));
322 x = (float)zoom_x * (x - get_x_offset(edl, single_channel, zoom_x, conformed_w, conformed_h));
323 y = (float)zoom_y * (y - get_y_offset(edl, single_channel, zoom_y, conformed_w, conformed_h));
328 void Canvas::get_transfers(EDL *edl,
329 float &output_x1, float &output_y1, float &output_x2, float &output_y2,
330 float &canvas_x1, float &canvas_y1, float &canvas_x2, float &canvas_y2,
331 int canvas_w, int canvas_h)
333 // printf("Canvas::get_transfers %d %d\n", canvas_w,
335 // automatic canvas size detection
336 if(canvas_w < 0) canvas_w = get_canvas()->get_w();
337 if(canvas_h < 0) canvas_h = get_canvas()->get_h();
339 // Canvas is zoomed to a portion of the output frame
342 float in_x1, in_y1, in_x2, in_y2;
343 float out_x1, out_y1, out_x2, out_y2;
344 float zoom_x, zoom_y, conformed_w, conformed_h;
346 get_zooms(edl, 0, zoom_x, zoom_y, conformed_w, conformed_h);
356 canvas_to_output(edl, 0, in_x1, in_y1);
357 canvas_to_output(edl, 0, in_x2, in_y2);
359 //printf("Canvas::get_transfers 1 %.0f %.0f %.0f %.0f -> %.0f %.0f %.0f %.0f\n",
360 //in_x1, in_y1, in_x2, in_y2, out_x1, out_y1, out_x2, out_y2);
364 out_x1 += -in_x1 * zoom_x;
370 out_y1 += -in_y1 * zoom_y;
374 int output_w = get_output_w(edl);
375 int output_h = get_output_h(edl);
379 out_x2 -= (in_x2 - output_w) * zoom_x;
385 out_y2 -= (in_y2 - output_h) * zoom_y;
388 // printf("Canvas::get_transfers 2 %.0f %.0f %.0f %.0f -> %.0f %.0f %.0f %.0f\n",
389 // in_x1, in_y1, in_x2, in_y2, out_x1, out_y1, out_x2, out_y2);
401 // if(!scrollbars_exist())
403 // out_x = canvas_w / 2 - out_w / 2;
404 // out_y = canvas_h / 2 - out_h / 2;
409 // The output frame is normalized to the canvas
411 // Default canvas coords fill the entire canvas
414 canvas_x2 = canvas_w;
415 canvas_y2 = canvas_h;
419 // Use EDL aspect ratio to shrink one of the canvas dimensions
420 float out_w = canvas_x2 - canvas_x1;
421 float out_h = canvas_y2 - canvas_y1;
422 if(out_w / out_h > edl->get_aspect_ratio())
424 out_w = (int)(out_h * edl->get_aspect_ratio() + 0.5);
425 canvas_x1 = canvas_w / 2 - out_w / 2;
429 out_h = (int)(out_w / edl->get_aspect_ratio() + 0.5);
430 canvas_y1 = canvas_h / 2 - out_h / 2;
432 canvas_x2 = canvas_x1 + out_w;
433 canvas_y2 = canvas_y1 + out_h;
435 // Get output frame coords from EDL
438 output_x2 = get_output_w(edl);
439 output_y2 = get_output_h(edl);
442 // No EDL to get aspect ratio or output frame coords from
446 output_x2 = this->output_w;
447 output_y2 = this->output_h;
451 // Clamp to minimum value
452 output_x1 = MAX(0, output_x1);
453 output_y1 = MAX(0, output_y1);
454 output_x2 = MAX(output_x1, output_x2);
455 output_y2 = MAX(output_y1, output_y2);
456 canvas_x1 = MAX(0, canvas_x1);
457 canvas_y1 = MAX(0, canvas_y1);
458 canvas_x2 = MAX(canvas_x1, canvas_x2);
459 canvas_y2 = MAX(canvas_y1, canvas_y2);
460 // printf("Canvas::get_transfers 2 %f,%f %f,%f -> %f,%f %f,%f\n",
471 int Canvas::scrollbars_exist()
473 return(use_scrollbars && (xscroll || yscroll));
476 int Canvas::get_output_w(EDL *edl)
478 return !edl ? 0 : edl->session->output_w;
481 int Canvas::get_output_h(EDL *edl)
483 return !edl ? 0 : edl->session->output_h;
488 void Canvas::get_scrollbars(EDL *edl,
494 int need_xscroll = 0;
495 int need_yscroll = 0;
497 float zoom_x, zoom_y, conformed_w, conformed_h;
501 w_needed = edl->session->output_w;
502 h_needed = edl->session->output_h;
503 w_visible = w_needed;
504 h_visible = h_needed;
506 //printf("Canvas::get_scrollbars 1 %d %d\n", get_xscroll(), get_yscroll());
510 w_needed = edl->session->output_w;
511 h_needed = edl->session->output_h;
512 get_zooms(edl, 0, zoom_x, zoom_y, conformed_w, conformed_h);
513 //printf("Canvas::get_scrollbars 2 %d %d\n", get_xscroll(), get_yscroll());
517 w_visible = (int)(canvas_w / zoom_x);
518 h_visible = (int)(canvas_h / zoom_y);
521 // if(w_needed > w_visible)
527 canvas_h -= BC_ScrollBar::get_span(SCROLL_HORIZ);
534 // if(h_needed > h_visible)
540 canvas_w -= BC_ScrollBar::get_span(SCROLL_VERT);
547 //printf("Canvas::get_scrollbars %d %d %d %d %d %d\n", canvas_w, canvas_h, w_needed, h_needed, w_visible, h_visible);
548 //printf("Canvas::get_scrollbars 3 %d %d\n", get_xscroll(), get_yscroll());
550 w_visible = (int)(canvas_w / zoom_x);
551 h_visible = (int)(canvas_h / zoom_y);
558 subwindow->add_subwindow(xscroll =
559 new CanvasXScroll(edl, this, canvas_x, canvas_y + canvas_h,
560 w_needed, get_xscroll(), w_visible, canvas_w));
561 xscroll->show_window(0);
564 xscroll->reposition_window(canvas_x, canvas_y + canvas_h, canvas_w);
566 if(xscroll->get_length() != w_needed ||
567 xscroll->get_handlelength() != w_visible)
568 xscroll->update_length(w_needed, get_xscroll(), w_visible, 0);
572 if( xscroll ) { delete xscroll; xscroll = 0; }
574 //printf("Canvas::get_scrollbars 4 %d %d\n", get_xscroll(), get_yscroll());
580 subwindow->add_subwindow(yscroll =
581 new CanvasYScroll(edl, this, canvas_x + canvas_w, canvas_y,
582 h_needed, get_yscroll(), h_visible, canvas_h));
583 yscroll->show_window(0);
586 yscroll->reposition_window(canvas_x + canvas_w, canvas_y, canvas_h);
588 if(yscroll->get_length() != edl->session->output_h ||
589 yscroll->get_handlelength() != h_visible)
590 yscroll->update_length(h_needed, get_yscroll(), h_visible, 0);
594 if( yscroll ) { delete yscroll; yscroll = 0; }
596 //printf("Canvas::get_scrollbars 5 %d %d\n", get_xscroll(), get_yscroll());
599 void Canvas::reposition_window(EDL *edl, int x, int y, int w, int h)
601 this->x = view_x = x; this->y = view_y = y;
602 this->w = view_w = w; this->h = view_h = h;
603 //printf("Canvas::reposition_window 1\n");
604 get_scrollbars(edl, view_x, view_y, view_w, view_h);
605 //printf("Canvas::reposition_window %d %d %d %d\n", view_x, view_y, view_w, view_h);
608 canvas_subwindow->reposition_window(view_x, view_y, view_w, view_h);
610 // Need to clear out the garbage in the back
611 if(canvas_subwindow->get_video_on())
613 canvas_subwindow->set_color(BLACK);
614 canvas_subwindow->draw_box(0, 0,
615 get_canvas()->get_w(), get_canvas()->get_h());
616 canvas_subwindow->flash(0);
624 void Canvas::set_cursor(int cursor)
626 get_canvas()->set_cursor(cursor, 0, 1);
629 int Canvas::get_cursor_x()
631 return get_canvas()->get_cursor_x();
634 int Canvas::get_cursor_y()
636 return get_canvas()->get_cursor_y();
639 int Canvas::get_buttonpress()
641 return get_canvas()->get_buttonpress();
645 void Canvas::create_objects(EDL *edl)
651 get_scrollbars(edl, view_x, view_y, view_w, view_h);
653 subwindow->unlock_window();
655 subwindow->lock_window("Canvas::create_objects");
657 subwindow->add_subwindow(canvas_menu = new CanvasPopup(this));
658 canvas_menu->create_objects();
660 subwindow->add_subwindow(fullscreen_menu = new CanvasFullScreenPopup(this));
661 fullscreen_menu->create_objects();
665 int Canvas::button_release_event()
669 if(get_canvas()->get_buttonpress() == 3)
672 fullscreen_menu->activate_menu();
674 canvas_menu->activate_menu();
681 void Canvas::start_single()
687 void Canvas::stop_single()
693 void Canvas::start_video()
697 get_canvas()->start_video();
702 void Canvas::stop_video()
706 get_canvas()->stop_video();
712 void Canvas::start_fullscreen()
718 void Canvas::stop_fullscreen()
724 void Canvas::create_canvas()
727 lock_canvas("Canvas::create_canvas");
730 if(!get_fullscreen())
733 if(canvas_fullscreen)
735 video_on = canvas_fullscreen->get_video_on();
736 canvas_fullscreen->stop_video();
737 canvas_fullscreen->lock_window("Canvas::create_canvas 2");
738 canvas_fullscreen->hide_window();
739 canvas_fullscreen->unlock_window();
742 if(!canvas_auxwindow && !canvas_subwindow)
744 subwindow->add_subwindow(canvas_subwindow = new CanvasOutput(this,
754 BC_WindowBase *wdw = canvas_auxwindow ?
755 canvas_auxwindow : canvas_subwindow;
758 video_on = wdw->get_video_on();
762 int x = subwindow->get_screen_x(0, -1);
763 int y = subwindow->get_screen_y(0, -1);
766 if( mwindow->screens == 1 && root_w > scr_w0 ) {
768 if( subwindow->get_x() >= scr_w0 ) {
769 // assumes right side is the big one
774 // use same aspect ratio to compute left height
776 h = (w*root_h) / (root_w-scr_w0);
780 if( canvas_fullscreen )
782 if( x != canvas_fullscreen->get_x() ||
783 y != canvas_fullscreen->get_y() ||
784 w != canvas_fullscreen->get_w() ||
785 h != canvas_fullscreen->get_h() ) {
786 delete canvas_fullscreen;
787 canvas_fullscreen = 0;
790 if(!canvas_fullscreen)
792 canvas_fullscreen = new CanvasFullScreen(this, w, h);
796 canvas_fullscreen->reposition_window(x, y);
797 canvas_fullscreen->show_window();
804 get_canvas()->lock_window("Canvas::create_canvas 1");
806 get_canvas()->unlock_window();
809 if(video_on) get_canvas()->start_video();
816 int Canvas::cursor_leave_event_base(BC_WindowBase *caller)
819 if(cursor_inside) result = cursor_leave_event();
824 int Canvas::cursor_enter_event_base(BC_WindowBase *caller)
827 if(caller->is_event_win() && caller->cursor_inside())
830 result = cursor_enter_event();
835 int Canvas::button_press_event_base(BC_WindowBase *caller)
837 if(caller->is_event_win() && caller->cursor_inside())
839 return button_press_event();
844 int Canvas::keypress_event(BC_WindowBase *caller)
846 int caller_is_canvas = (caller == get_canvas());
847 int key = caller->get_keypress();
850 caller->unlock_window();
855 if(!caller_is_canvas) caller->lock_window("Canvas::keypress_event 1");
858 caller->unlock_window();
861 if(!caller_is_canvas) caller->lock_window("Canvas::keypress_event 2");
885 CanvasOutput::CanvasOutput(Canvas *canvas,
890 : BC_SubWindow(x, y, w, h, BLACK)
892 this->canvas = canvas;
895 CanvasOutput::~CanvasOutput()
899 int CanvasOutput::cursor_leave_event()
901 return canvas->cursor_leave_event_base(this);
904 int CanvasOutput::cursor_enter_event()
906 return canvas->cursor_enter_event_base(this);
909 int CanvasOutput::button_press_event()
911 return canvas->button_press_event_base(this);
914 int CanvasOutput::button_release_event()
916 return canvas->button_release_event();
919 int CanvasOutput::cursor_motion_event()
921 return canvas->cursor_motion_event();
924 int CanvasOutput::keypress_event()
926 return canvas->keypress_event(this);
941 CanvasFullScreen::CanvasFullScreen(Canvas *canvas,
944 : BC_FullScreen(canvas->subwindow,
952 this->canvas = canvas;
955 CanvasFullScreen::~CanvasFullScreen()
971 CanvasXScroll::CanvasXScroll(EDL *edl,
987 this->canvas = canvas;
990 CanvasXScroll::~CanvasXScroll()
994 int CanvasXScroll::handle_event()
996 //printf("CanvasXScroll::handle_event %d %d %d\n", get_length(), get_value(), get_handlelength());
997 canvas->update_zoom(get_value(), canvas->get_yscroll(), canvas->get_zoom());
998 canvas->draw_refresh();
1007 CanvasYScroll::CanvasYScroll(EDL *edl,
1023 this->canvas = canvas;
1026 CanvasYScroll::~CanvasYScroll()
1030 int CanvasYScroll::handle_event()
1032 //printf("CanvasYScroll::handle_event %d %d\n", get_value(), get_length());
1033 canvas->update_zoom(canvas->get_xscroll(), get_value(), canvas->get_zoom());
1034 canvas->draw_refresh();
1043 CanvasFullScreenPopup::CanvasFullScreenPopup(Canvas *canvas)
1044 : BC_PopupMenu(0, 0, 0, "", 0)
1046 this->canvas = canvas;
1050 void CanvasFullScreenPopup::create_objects()
1052 add_item(new CanvasSubWindowItem(canvas));
1055 void CanvasFullScreenPopup::use_cwindow()
1057 add_item(new CanvasPopupAuto(canvas));
1060 CanvasSubWindowItem::CanvasSubWindowItem(Canvas *canvas)
1061 : BC_MenuItem(_("Windowed"), "f", 'f')
1063 this->canvas = canvas;
1066 int CanvasSubWindowItem::handle_event()
1068 // It isn't a problem to delete the canvas from in here because the event
1069 // dispatcher is the canvas subwindow.
1070 canvas->subwindow->unlock_window();
1071 canvas->stop_fullscreen();
1072 canvas->subwindow->lock_window("CanvasSubWindowItem::handle_event");
1083 CanvasPopup::CanvasPopup(Canvas *canvas)
1084 : BC_PopupMenu(0, 0, 0, "", 0)
1086 this->canvas = canvas;
1089 CanvasPopup::~CanvasPopup()
1093 void CanvasPopup::create_objects()
1095 add_item(new CanvasFullScreenItem(canvas));
1096 add_item(new CanvasPopupSize(canvas, _("Zoom 25%"), 0.25));
1097 add_item(new CanvasPopupSize(canvas, _("Zoom 33%"), 0.33));
1098 add_item(new CanvasPopupSize(canvas, _("Zoom 50%"), 0.5));
1099 add_item(new CanvasPopupSize(canvas, _("Zoom 75%"), 0.75));
1100 add_item(new CanvasPopupSize(canvas, _("Zoom 100%"), 1.0));
1101 add_item(new CanvasPopupSize(canvas, _("Zoom 150%"), 1.5));
1102 add_item(new CanvasPopupSize(canvas, _("Zoom 200%"), 2.0));
1103 add_item(new CanvasPopupSize(canvas, _("Zoom 300%"), 3.0));
1104 add_item(new CanvasPopupSize(canvas, _("Zoom 400%"), 4.0));
1107 void CanvasPopup::use_cwindow()
1109 add_item(new CanvasPopupAuto(canvas));
1110 add_item(new CanvasPopupResetCamera(canvas));
1111 add_item(new CanvasPopupResetProjector(canvas));
1112 add_item(toggle_controls = new CanvasToggleControls(canvas));
1115 void CanvasPopup::use_rwindow()
1117 add_item(new CanvasPopupResetTranslation(canvas));
1120 void CanvasPopup::use_vwindow()
1122 add_item(new CanvasPopupRemoveSource(canvas));
1126 CanvasPopupAuto::CanvasPopupAuto(Canvas *canvas)
1127 : BC_MenuItem(_("Zoom Auto"))
1129 this->canvas = canvas;
1132 int CanvasPopupAuto::handle_event()
1134 canvas->zoom_auto();
1139 CanvasPopupSize::CanvasPopupSize(Canvas *canvas, char *text, float percentage)
1142 this->canvas = canvas;
1143 this->percentage = percentage;
1145 CanvasPopupSize::~CanvasPopupSize()
1148 int CanvasPopupSize::handle_event()
1150 canvas->zoom_resize_window(percentage);
1156 CanvasPopupResetCamera::CanvasPopupResetCamera(Canvas *canvas)
1157 : BC_MenuItem(_("Reset camera"))
1159 this->canvas = canvas;
1161 int CanvasPopupResetCamera::handle_event()
1163 canvas->reset_camera();
1169 CanvasPopupResetProjector::CanvasPopupResetProjector(Canvas *canvas)
1170 : BC_MenuItem(_("Reset projector"))
1172 this->canvas = canvas;
1174 int CanvasPopupResetProjector::handle_event()
1176 canvas->reset_projector();
1182 CanvasPopupResetTranslation::CanvasPopupResetTranslation(Canvas *canvas)
1183 : BC_MenuItem(_("Reset translation"))
1185 this->canvas = canvas;
1187 int CanvasPopupResetTranslation::handle_event()
1189 canvas->reset_translation();
1195 CanvasToggleControls::CanvasToggleControls(Canvas *canvas)
1196 : BC_MenuItem(calculate_text(canvas->get_cwindow_controls()))
1198 this->canvas = canvas;
1200 int CanvasToggleControls::handle_event()
1202 canvas->toggle_controls();
1203 set_text(calculate_text(canvas->get_cwindow_controls()));
1207 char* CanvasToggleControls::calculate_text(int cwindow_controls)
1209 if(!cwindow_controls)
1210 return _("Show controls");
1212 return _("Hide controls");
1221 CanvasFullScreenItem::CanvasFullScreenItem(Canvas *canvas)
1222 : BC_MenuItem(_("Fullscreen"), "f", 'f')
1224 this->canvas = canvas;
1226 int CanvasFullScreenItem::handle_event()
1228 canvas->subwindow->unlock_window();
1229 canvas->start_fullscreen();
1230 canvas->subwindow->lock_window("CanvasFullScreenItem::handle_event");
1242 CanvasPopupRemoveSource::CanvasPopupRemoveSource(Canvas *canvas)
1243 : BC_MenuItem(_("Close source"))
1245 this->canvas = canvas;
1247 int CanvasPopupRemoveSource::handle_event()
1249 canvas->close_source();