4 * Copyright (C) 2008-2017 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;
95 void Canvas::lock_canvas(const char *location)
97 canvas_lock->lock(location);
100 void Canvas::unlock_canvas()
102 canvas_lock->unlock();
105 int Canvas::is_locked()
107 return canvas_lock->is_locked();
111 BC_WindowBase* Canvas::get_canvas()
113 if(get_fullscreen() && canvas_fullscreen)
114 return canvas_fullscreen;
115 return canvas_auxwindow ? canvas_auxwindow : canvas_subwindow;
118 void Canvas::use_auxwindow(BC_WindowBase *aux)
120 canvas_auxwindow = aux;
123 void Canvas::use_cwindow()
125 canvas_menu->use_cwindow();
126 fullscreen_menu->use_cwindow();
129 void Canvas::use_rwindow()
131 canvas_menu->use_rwindow();
134 void Canvas::use_vwindow()
136 canvas_menu->use_vwindow();
139 int Canvas::get_fullscreen()
141 return is_fullscreen;
144 void Canvas::set_fullscreen(int value)
146 is_fullscreen = value;
149 // Get dimensions given a zoom
150 void Canvas::calculate_sizes(float aspect_ratio,
157 // Horizontal stretch
158 if((float)output_w / output_h <= aspect_ratio)
160 w = (int)((float)output_h * aspect_ratio * zoom);
161 h = (int)((float)output_h * zoom);
166 h = (int)((float)output_w / aspect_ratio * zoom);
167 w = (int)((float)output_w * zoom);
171 float Canvas::get_x_offset(EDL *edl,
181 // If the projection is smaller than the canvas, this forces it in the center.
182 // if(conformed_w < w_visible)
183 // return -(float)(w_visible - conformed_w) / 2;
185 return (float)get_xscroll();
188 return ((float)-get_canvas()->get_w() / zoom_x +
189 edl->session->output_w) / 2;
194 int canvas_w = get_canvas()->get_w();
195 int canvas_h = get_canvas()->get_h();
199 if((float)out_w / out_h > conformed_w / conformed_h)
201 out_w = (int)(out_h * conformed_w / conformed_h + 0.5);
205 return -(canvas_w - out_w) / 2 / zoom_x;
211 float Canvas::get_y_offset(EDL *edl,
221 // If the projection is smaller than the canvas, this forces it in the center.
222 // if(conformed_h < h_visible)
223 // return -(float)(h_visible - conformed_h) / 2;
225 return (float)get_yscroll();
228 return ((float)-get_canvas()->get_h() / zoom_y +
229 edl->session->output_h) / 2;
234 int canvas_w = get_canvas()->get_w();
235 int canvas_h = get_canvas()->get_h();
239 if((float)out_w / out_h <= conformed_w / conformed_h)
241 out_h = (int)((float)out_w / (conformed_w / conformed_h) + 0.5);
244 //printf("Canvas::get_y_offset 1 %d %d %f\n", out_h, canvas_h, -((float)canvas_h - out_h) / 2);
246 return -((float)canvas_h - out_h) / 2 / zoom_y;
252 // This may not be used anymore
253 void Canvas::check_boundaries(EDL *edl, int &x, int &y, float &zoom)
255 if(x + w_visible > w_needed) x = w_needed - w_visible;
256 if(y + h_visible > h_needed) y = h_needed - h_visible;
262 void Canvas::update_scrollbars(int flush)
266 if(xscroll) xscroll->update_length(w_needed, get_xscroll(), w_visible, flush);
267 if(yscroll) yscroll->update_length(h_needed, get_yscroll(), h_visible, flush);
271 void Canvas::get_zooms(EDL *edl,
278 edl->calculate_conformed_dimensions(single_channel,
284 zoom_x = get_zoom() *
286 edl->session->output_w;
287 zoom_y = get_zoom() *
289 edl->session->output_h;
294 int canvas_w = get_canvas()->get_w();
295 int canvas_h = get_canvas()->get_h();
300 if((float)out_w / out_h > conformed_w / conformed_h)
302 out_w = (int)((float)out_h * conformed_w / conformed_h + 0.5);
306 out_h = (int)((float)out_w / (conformed_w / conformed_h) + 0.5);
309 zoom_x = (float)out_w / edl->session->output_w;
310 zoom_y = (float)out_h / edl->session->output_h;
311 //printf("get zooms 2 %d %d %f %f\n", canvas_w, canvas_h, conformed_w, conformed_h);
315 // Convert a coordinate on the canvas to a coordinate on the output
316 void Canvas::canvas_to_output(EDL *edl, int single_channel, float &x, float &y)
318 float zoom_x, zoom_y, conformed_w, conformed_h;
319 get_zooms(edl, single_channel, zoom_x, zoom_y, conformed_w, conformed_h);
321 //printf("Canvas::canvas_to_output y=%f zoom_y=%f y_offset=%f\n",
322 // y, zoom_y, get_y_offset(edl, single_channel, zoom_y, conformed_w, conformed_h));
324 x = (float)x / zoom_x + get_x_offset(edl, single_channel, zoom_x, conformed_w, conformed_h);
325 y = (float)y / zoom_y + get_y_offset(edl, single_channel, zoom_y, conformed_w, conformed_h);
328 void Canvas::output_to_canvas(EDL *edl, int single_channel, float &x, float &y)
330 float zoom_x, zoom_y, conformed_w, conformed_h;
331 get_zooms(edl, single_channel, zoom_x, zoom_y, conformed_w, conformed_h);
333 //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));
335 x = (float)zoom_x * (x - get_x_offset(edl, single_channel, zoom_x, conformed_w, conformed_h));
336 y = (float)zoom_y * (y - get_y_offset(edl, single_channel, zoom_y, conformed_w, conformed_h));
341 void Canvas::get_transfers(EDL *edl,
342 float &output_x1, float &output_y1, float &output_x2, float &output_y2,
343 float &canvas_x1, float &canvas_y1, float &canvas_x2, float &canvas_y2,
344 int canvas_w, int canvas_h)
346 //printf("Canvas::get_transfers %d canvas_w=%d canvas_h=%d\n",
347 // __LINE__, canvas_w, canvas_h);
348 // automatic canvas size detection
349 if(canvas_w < 0) canvas_w = get_canvas()->get_w();
350 if(canvas_h < 0) canvas_h = get_canvas()->get_h();
352 // Canvas is zoomed to a portion of the output frame
355 float in_x1, in_y1, in_x2, in_y2;
356 float out_x1, out_y1, out_x2, out_y2;
357 float zoom_x, zoom_y, conformed_w, conformed_h;
359 get_zooms(edl, 0, zoom_x, zoom_y, conformed_w, conformed_h);
369 canvas_to_output(edl, 0, in_x1, in_y1);
370 canvas_to_output(edl, 0, in_x2, in_y2);
372 //printf("Canvas::get_transfers 1 %.0f %.0f %.0f %.0f -> %.0f %.0f %.0f %.0f\n",
373 //in_x1, in_y1, in_x2, in_y2, out_x1, out_y1, out_x2, out_y2);
377 out_x1 += -in_x1 * zoom_x;
383 out_y1 += -in_y1 * zoom_y;
387 int output_w = get_output_w(edl);
388 int output_h = get_output_h(edl);
392 out_x2 -= (in_x2 - output_w) * zoom_x;
398 out_y2 -= (in_y2 - output_h) * zoom_y;
401 // printf("Canvas::get_transfers 2 %.0f %.0f %.0f %.0f -> %.0f %.0f %.0f %.0f\n",
402 // in_x1, in_y1, in_x2, in_y2, out_x1, out_y1, out_x2, out_y2);
414 // if(!scrollbars_exist())
416 // out_x = canvas_w / 2 - out_w / 2;
417 // out_y = canvas_h / 2 - out_h / 2;
422 // The output frame is normalized to the canvas
424 // Default canvas coords fill the entire canvas
427 canvas_x2 = canvas_w;
428 canvas_y2 = canvas_h;
432 // Use EDL aspect ratio to shrink one of the canvas dimensions
433 float out_w = canvas_x2 - canvas_x1;
434 float out_h = canvas_y2 - canvas_y1;
435 if(out_w / out_h > edl->get_aspect_ratio())
437 out_w = (int)(out_h * edl->get_aspect_ratio() + 0.5);
438 canvas_x1 = canvas_w / 2 - out_w / 2;
442 out_h = (int)(out_w / edl->get_aspect_ratio() + 0.5);
443 canvas_y1 = canvas_h / 2 - out_h / 2;
444 // printf("Canvas::get_transfers %d canvas_h=%d out_h=%f canvas_y1=%f\n",
450 canvas_x2 = canvas_x1 + out_w;
451 canvas_y2 = canvas_y1 + out_h;
453 // Get output frame coords from EDL
456 output_x2 = get_output_w(edl);
457 output_y2 = get_output_h(edl);
460 // No EDL to get aspect ratio or output frame coords from
464 output_x2 = this->output_w;
465 output_y2 = this->output_h;
469 // Clamp to minimum value
470 output_x1 = MAX(0, output_x1);
471 output_y1 = MAX(0, output_y1);
472 output_x2 = MAX(output_x1, output_x2);
473 output_y2 = MAX(output_y1, output_y2);
474 canvas_x1 = MAX(0, canvas_x1);
475 canvas_y1 = MAX(0, canvas_y1);
476 canvas_x2 = MAX(canvas_x1, canvas_x2);
477 canvas_y2 = MAX(canvas_y1, canvas_y2);
478 // printf("Canvas::get_transfers %d %f,%f %f,%f -> %f,%f %f,%f\n",
490 int Canvas::scrollbars_exist()
492 return(use_scrollbars && (xscroll || yscroll));
495 int Canvas::get_output_w(EDL *edl)
497 return !edl ? 0 : edl->session->output_w;
500 int Canvas::get_output_h(EDL *edl)
502 return !edl ? 0 : edl->session->output_h;
507 void Canvas::get_scrollbars(EDL *edl,
513 int need_xscroll = 0;
514 int need_yscroll = 0;
516 float zoom_x, zoom_y, conformed_w, conformed_h;
520 w_needed = edl->session->output_w;
521 h_needed = edl->session->output_h;
522 w_visible = w_needed;
523 h_visible = h_needed;
525 //printf("Canvas::get_scrollbars 1 %d %d\n", get_xscroll(), get_yscroll());
527 if( use_scrollbars ) {
528 w_needed = edl->session->output_w;
529 h_needed = edl->session->output_h;
530 get_zooms(edl, 0, zoom_x, zoom_y, conformed_w, conformed_h);
531 //printf("Canvas::get_scrollbars 2 %d %d\n", get_xscroll(), get_yscroll());
533 w_visible = (int)(canvas_w / zoom_x);
534 h_visible = (int)(canvas_h / zoom_y);
535 if( w_needed > w_visible ) {
537 canvas_h -= BC_ScrollBar::get_span(SCROLL_HORIZ);
540 if( h_needed > h_visible ) {
542 canvas_w -= BC_ScrollBar::get_span(SCROLL_VERT);
544 //printf("Canvas::get_scrollbars %d %d %d %d %d %d\n", canvas_w, canvas_h, w_needed, h_needed, w_visible, h_visible);
545 //printf("Canvas::get_scrollbars 3 %d %d\n", get_xscroll(), get_yscroll());
547 w_visible = (int)(canvas_w / zoom_x);
548 h_visible = (int)(canvas_h / zoom_y);
553 xscroll = new CanvasXScroll(edl, this, canvas_x, canvas_y + canvas_h,
554 w_needed, get_xscroll(), w_visible, canvas_w);
555 subwindow->add_subwindow(xscroll);
556 xscroll->show_window(0);
559 xscroll->reposition_window(canvas_x, canvas_y + canvas_h, canvas_w);
561 if( xscroll->get_length() != w_needed ||
562 xscroll->get_handlelength() != w_visible )
563 xscroll->update_length(w_needed, get_xscroll(), w_visible, 0);
566 delete xscroll; xscroll = 0;
568 //printf("Canvas::get_scrollbars 4 %d %d\n", get_xscroll(), get_yscroll());
572 yscroll = new CanvasYScroll(edl, this, canvas_x + canvas_w, canvas_y,
573 h_needed, get_yscroll(), h_visible, canvas_h);
574 subwindow->add_subwindow(yscroll);
575 yscroll->show_window(0);
578 yscroll->reposition_window(canvas_x + canvas_w, canvas_y, canvas_h);
580 if( yscroll->get_length() != edl->session->output_h ||
581 yscroll->get_handlelength() != h_visible )
582 yscroll->update_length(h_needed, get_yscroll(), h_visible, 0);
585 delete yscroll; yscroll = 0;
587 //printf("Canvas::get_scrollbars 5 %d %d\n", get_xscroll(), get_yscroll());
591 void Canvas::update_geometry(EDL *edl, int x, int y, int w, int h)
594 if( this->x != x || this->y != y ||
595 this->w != w || this->h != h ) redraw = 1;
597 int vx = x, vy = y, vw = w, vh = h;
598 get_scrollbars(edl, vx, vy, vw, vh);
599 if( vx != view_x || vy != view_y ||
600 vw != view_w || vh != view_h ) redraw = 1;
602 if( !redraw ) return;
603 reposition_window(edl, x, y, w, y);
606 void Canvas::reposition_window(EDL *edl, int x, int y, int w, int h)
608 this->x = view_x = x; this->y = view_y = y;
609 this->w = view_w = w; this->h = view_h = h;
610 //printf("Canvas::reposition_window 1\n");
611 get_scrollbars(edl, view_x, view_y, view_w, view_h);
612 //printf("Canvas::reposition_window %d %d %d %d\n", view_x, view_y, view_w, view_h);
615 canvas_subwindow->reposition_window(view_x, view_y, view_w, view_h);
617 // Need to clear out the garbage in the back
618 if(canvas_subwindow->get_video_on())
620 canvas_subwindow->set_color(BLACK);
621 canvas_subwindow->draw_box(0, 0,
622 get_canvas()->get_w(), get_canvas()->get_h());
623 canvas_subwindow->flash(0);
629 void Canvas::set_cursor(int cursor)
631 get_canvas()->set_cursor(cursor, 0, 1);
634 int Canvas::get_cursor_x()
636 return get_canvas()->get_cursor_x();
639 int Canvas::get_cursor_y()
641 return get_canvas()->get_cursor_y();
644 int Canvas::get_buttonpress()
646 return get_canvas()->get_buttonpress();
650 void Canvas::create_objects(EDL *edl)
656 get_scrollbars(edl, view_x, view_y, view_w, view_h);
658 subwindow->unlock_window();
660 subwindow->lock_window("Canvas::create_objects");
662 subwindow->add_subwindow(canvas_menu = new CanvasPopup(this));
663 canvas_menu->create_objects();
665 subwindow->add_subwindow(fullscreen_menu = new CanvasFullScreenPopup(this));
666 fullscreen_menu->create_objects();
670 int Canvas::button_press_event()
674 if(get_canvas()->get_buttonpress() == 3)
677 fullscreen_menu->activate_menu();
679 canvas_menu->activate_menu();
686 void Canvas::start_single()
692 void Canvas::stop_single()
698 void Canvas::start_video()
702 get_canvas()->start_video();
707 void Canvas::stop_video()
711 get_canvas()->stop_video();
717 void Canvas::start_fullscreen()
723 void Canvas::stop_fullscreen()
729 void Canvas::create_canvas()
732 lock_canvas("Canvas::create_canvas");
735 if(!get_fullscreen())
738 if(canvas_fullscreen)
740 video_on = canvas_fullscreen->get_video_on();
741 canvas_fullscreen->stop_video();
742 canvas_fullscreen->lock_window("Canvas::create_canvas 2");
743 canvas_fullscreen->hide_window();
744 canvas_fullscreen->unlock_window();
747 if(!canvas_auxwindow && !canvas_subwindow)
749 subwindow->add_subwindow(canvas_subwindow = new CanvasOutput(this,
759 BC_WindowBase *wdw = canvas_auxwindow ?
760 canvas_auxwindow : canvas_subwindow;
763 video_on = wdw->get_video_on();
768 wdw->get_fullscreen_geometry(x, y, w, h);
770 if( canvas_fullscreen ) {
771 if( x != canvas_fullscreen->get_x() ||
772 y != canvas_fullscreen->get_y() ||
773 w != canvas_fullscreen->get_w() ||
774 h != canvas_fullscreen->get_h() ) {
775 delete canvas_fullscreen;
776 canvas_fullscreen = 0;
779 if( !canvas_fullscreen )
780 canvas_fullscreen = new CanvasFullScreen(this, w, h);
781 canvas_fullscreen->show_window();
782 canvas_fullscreen->sync_display();
783 canvas_fullscreen->reposition_window(x, y);
787 get_canvas()->lock_window("Canvas::create_canvas 1");
789 get_canvas()->unlock_window();
793 get_canvas()->start_video();
795 get_canvas()->lock_window("Canvas::create_canvas 2");
796 get_canvas()->focus();
797 get_canvas()->unlock_window();
804 int Canvas::cursor_leave_event_base(BC_WindowBase *caller)
807 if(cursor_inside) result = cursor_leave_event();
812 int Canvas::cursor_enter_event_base(BC_WindowBase *caller)
815 if(caller->is_event_win() && caller->cursor_inside())
818 result = cursor_enter_event();
823 int Canvas::button_press_event_base(BC_WindowBase *caller)
825 if(caller->is_event_win() && caller->cursor_inside())
827 return button_press_event();
832 int Canvas::keypress_event(BC_WindowBase *caller)
834 int key = caller->get_keypress();
837 caller->unlock_window();
842 caller->lock_window("Canvas::keypress_event 1");
845 caller->unlock_window();
848 caller->lock_window("Canvas::keypress_event 2");
856 void Canvas::update_refresh(VideoDevice *device, VFrame *output_frame)
858 int best_color_model = output_frame->get_color_model();
860 device->out_config->driver == PLAYBACK_X11_GL &&
861 output_frame->get_opengl_state() != VFrame::RAM;
863 // OpenGL does YUV->RGB in the compositing step
865 best_color_model = BC_RGB888;
866 else if( BC_CModels::has_alpha(best_color_model) ) {
868 BC_CModels::is_float(best_color_model ) ?
870 BC_CModels::is_yuv(best_color_model ) ?
871 ( BC_CModels::calculate_pixelsize(best_color_model) > 8 ?
872 BC_YUV161616 : BC_YUV888 ) :
873 ( BC_CModels::calculate_pixelsize(best_color_model) > 8 ?
874 BC_RGB161616 : BC_RGB888 ) ;
876 int out_w = output_frame->get_w();
877 int out_h = output_frame->get_h();
879 (refresh_frame->get_w() != out_w ||
880 refresh_frame->get_h() != out_h ||
881 refresh_frame->get_color_model() != best_color_model ) ) {
882 // x11 direct render uses BC_BGR8888, use tranfer_from to remap
883 delete refresh_frame; refresh_frame = 0;
886 if( !refresh_frame ) {
888 new VFrame(out_w, out_h, best_color_model);
892 get_canvas()->unlock_window();
895 mwindow->playback_3d->copy_from(this, refresh_frame, output_frame, 0);
896 lock_canvas(" Canvas::output_refresh");
897 get_canvas()->lock_window(" Canvas::output_refresh");
900 refresh_frame->transfer_from(output_frame, -1);
904 void Canvas::clear(int flush)
907 refresh_frame->clear_frame();
908 BC_WindowBase *wdw = get_canvas();
910 wdw->set_bg_color(BLACK);
911 wdw->clear_box(0,0, wdw->get_w(), wdw->get_h());
917 CanvasOutput::CanvasOutput(Canvas *canvas,
922 : BC_SubWindow(x, y, w, h, BLACK)
924 this->canvas = canvas;
927 CanvasOutput::~CanvasOutput()
931 int CanvasOutput::cursor_leave_event()
933 return canvas->cursor_leave_event_base(canvas->get_canvas());
936 int CanvasOutput::cursor_enter_event()
938 return canvas->cursor_enter_event_base(canvas->get_canvas());
941 int CanvasOutput::button_press_event()
943 return canvas->button_press_event_base(canvas->get_canvas());
946 int CanvasOutput::button_release_event()
948 return canvas->button_release_event();
951 int CanvasOutput::cursor_motion_event()
953 return canvas->cursor_motion_event();
956 int CanvasOutput::keypress_event()
958 return canvas->keypress_event(canvas->get_canvas());
963 CanvasFullScreen::CanvasFullScreen(Canvas *canvas, int w, int h)
964 : BC_FullScreen(canvas->subwindow, w, h, BLACK, 0, 0, 0)
966 this->canvas = canvas;
969 CanvasFullScreen::~CanvasFullScreen()
974 CanvasXScroll::CanvasXScroll(EDL *edl, Canvas *canvas, int x, int y,
975 int length, int position, int handle_length, int pixels)
976 : BC_ScrollBar(x, y, SCROLL_HORIZ, pixels, length, position, handle_length)
978 this->canvas = canvas;
981 CanvasXScroll::~CanvasXScroll()
985 int CanvasXScroll::handle_event()
987 //printf("CanvasXScroll::handle_event %d %d %d\n", get_length(), get_value(), get_handlelength());
988 canvas->update_zoom(get_value(), canvas->get_yscroll(), canvas->get_zoom());
989 canvas->draw_refresh();
994 CanvasYScroll::CanvasYScroll(EDL *edl, Canvas *canvas, int x, int y,
995 int length, int position, int handle_length, int pixels)
996 : BC_ScrollBar(x, y, SCROLL_VERT, pixels, length, position, handle_length)
998 this->canvas = canvas;
1001 CanvasYScroll::~CanvasYScroll()
1005 int CanvasYScroll::handle_event()
1007 //printf("CanvasYScroll::handle_event %d %d\n", get_value(), get_length());
1008 canvas->update_zoom(canvas->get_xscroll(), get_value(), canvas->get_zoom());
1009 canvas->draw_refresh();
1014 CanvasFullScreenPopup::CanvasFullScreenPopup(Canvas *canvas)
1015 : BC_PopupMenu(0, 0, 0, "", 0)
1017 this->canvas = canvas;
1021 void CanvasFullScreenPopup::create_objects()
1023 add_item(new CanvasSubWindowItem(canvas));
1026 void CanvasFullScreenPopup::use_cwindow()
1028 add_item(new CanvasPopupAuto(canvas));
1031 CanvasSubWindowItem::CanvasSubWindowItem(Canvas *canvas)
1032 : BC_MenuItem(_("Windowed"), "f", 'f')
1034 this->canvas = canvas;
1037 int CanvasSubWindowItem::handle_event()
1039 // It isn't a problem to delete the canvas from in here because the event
1040 // dispatcher is the canvas subwindow.
1041 canvas->subwindow->unlock_window();
1042 canvas->stop_fullscreen();
1043 canvas->subwindow->lock_window("CanvasSubWindowItem::handle_event");
1048 CanvasPopup::CanvasPopup(Canvas *canvas)
1049 : BC_PopupMenu(0, 0, 0, "", 0)
1051 this->canvas = canvas;
1054 CanvasPopup::~CanvasPopup()
1058 CanvasZoomSize::CanvasZoomSize(Canvas *canvas)
1059 : BC_MenuItem(_("Zoom..."))
1061 this->canvas = canvas;
1064 CanvasSizeSubMenu::CanvasSizeSubMenu(CanvasZoomSize *zoom_size)
1066 this->zoom_size = zoom_size;
1069 void CanvasPopup::create_objects()
1071 add_item(new BC_MenuItem("-"));
1072 add_item(new CanvasFullScreenItem(canvas));
1074 CanvasZoomSize *zoom_size = new CanvasZoomSize(canvas);
1075 add_item(zoom_size);
1076 CanvasSizeSubMenu *submenu = new CanvasSizeSubMenu(zoom_size);
1077 zoom_size->add_submenu(submenu);
1079 submenu->add_submenuitem(new CanvasPopupSize(canvas, _("Zoom 25%"), 0.25));
1080 submenu->add_submenuitem(new CanvasPopupSize(canvas, _("Zoom 33%"), 0.33));
1081 submenu->add_submenuitem(new CanvasPopupSize(canvas, _("Zoom 50%"), 0.5));
1082 submenu->add_submenuitem(new CanvasPopupSize(canvas, _("Zoom 75%"), 0.75));
1083 submenu->add_submenuitem(new CanvasPopupSize(canvas, _("Zoom 100%"), 1.0));
1084 submenu->add_submenuitem(new CanvasPopupSize(canvas, _("Zoom 150%"), 1.5));
1085 submenu->add_submenuitem(new CanvasPopupSize(canvas, _("Zoom 200%"), 2.0));
1086 submenu->add_submenuitem(new CanvasPopupSize(canvas, _("Zoom 300%"), 3.0));
1087 submenu->add_submenuitem(new CanvasPopupSize(canvas, _("Zoom 400%"), 4.0));
1090 void CanvasPopup::use_cwindow()
1092 add_item(new CanvasPopupAuto(canvas));
1093 add_item(new CanvasPopupResetCamera(canvas));
1094 add_item(new CanvasPopupResetProjector(canvas));
1095 add_item(new CanvasPopupCameraKeyframe(canvas));
1096 add_item(new CanvasPopupProjectorKeyframe(canvas));
1097 add_item(toggle_controls = new CanvasToggleControls(canvas));
1100 void CanvasPopup::use_rwindow()
1102 add_item(new CanvasPopupResetTranslation(canvas));
1105 void CanvasPopup::use_vwindow()
1107 add_item(new CanvasPopupRemoveSource(canvas));
1111 CanvasPopupAuto::CanvasPopupAuto(Canvas *canvas)
1112 : BC_MenuItem(_("Zoom Auto"))
1114 this->canvas = canvas;
1117 int CanvasPopupAuto::handle_event()
1119 canvas->zoom_auto();
1124 CanvasPopupSize::CanvasPopupSize(Canvas *canvas, char *text, float percentage)
1127 this->canvas = canvas;
1128 this->percentage = percentage;
1130 CanvasPopupSize::~CanvasPopupSize()
1133 int CanvasPopupSize::handle_event()
1135 canvas->zoom_resize_window(percentage);
1141 CanvasPopupResetCamera::CanvasPopupResetCamera(Canvas *canvas)
1142 : BC_MenuItem(_("Reset camera"), _("F11"), KEY_F11)
1144 this->canvas = canvas;
1146 int CanvasPopupResetCamera::handle_event()
1148 canvas->reset_camera();
1152 CanvasPopupResetProjector::CanvasPopupResetProjector(Canvas *canvas)
1153 : BC_MenuItem(_("Reset projector"), _("F12"), KEY_F12)
1155 this->canvas = canvas;
1157 int CanvasPopupResetProjector::handle_event()
1159 canvas->reset_projector();
1164 CanvasPopupCameraKeyframe::CanvasPopupCameraKeyframe(Canvas *canvas)
1165 : BC_MenuItem(_("Camera keyframe"), _("Shift-F11"), KEY_F11)
1167 this->canvas = canvas;
1170 int CanvasPopupCameraKeyframe::handle_event()
1172 canvas->camera_keyframe();
1176 CanvasPopupProjectorKeyframe::CanvasPopupProjectorKeyframe(Canvas *canvas)
1177 : BC_MenuItem(_("Projector keyframe"), _("Shift-F12"), KEY_F12)
1179 this->canvas = canvas;
1182 int CanvasPopupProjectorKeyframe::handle_event()
1184 canvas->projector_keyframe();
1190 CanvasPopupResetTranslation::CanvasPopupResetTranslation(Canvas *canvas)
1191 : BC_MenuItem(_("Reset translation"))
1193 this->canvas = canvas;
1195 int CanvasPopupResetTranslation::handle_event()
1197 canvas->reset_translation();
1203 CanvasToggleControls::CanvasToggleControls(Canvas *canvas)
1204 : BC_MenuItem(calculate_text(canvas->get_cwindow_controls()))
1206 this->canvas = canvas;
1208 int CanvasToggleControls::handle_event()
1210 canvas->toggle_controls();
1211 set_text(calculate_text(canvas->get_cwindow_controls()));
1215 char* CanvasToggleControls::calculate_text(int cwindow_controls)
1217 if(!cwindow_controls)
1218 return _("Show controls");
1220 return _("Hide controls");
1229 CanvasFullScreenItem::CanvasFullScreenItem(Canvas *canvas)
1230 : BC_MenuItem(_("Fullscreen"), "f", 'f')
1232 this->canvas = canvas;
1234 int CanvasFullScreenItem::handle_event()
1236 canvas->subwindow->unlock_window();
1237 canvas->start_fullscreen();
1238 canvas->subwindow->lock_window("CanvasFullScreenItem::handle_event");
1250 CanvasPopupRemoveSource::CanvasPopupRemoveSource(Canvas *canvas)
1251 : BC_MenuItem(_("Close source"))
1253 this->canvas = canvas;
1255 int CanvasPopupRemoveSource::handle_event()
1257 canvas->close_source();