00001 #include "bcsignals.h"
00002 #include "canvas.h"
00003 #include "clip.h"
00004 #include "edl.h"
00005 #include "edlsession.h"
00006 #include "keys.h"
00007 #include "language.h"
00008 #include "mainsession.h"
00009 #include "mutex.h"
00010 #include "mwindow.h"
00011 #include "vframe.h"
00012
00013
00014
00015 Canvas::Canvas(MWindow *mwindow,
00016 BC_WindowBase *subwindow,
00017 int x,
00018 int y,
00019 int w,
00020 int h,
00021 int output_w,
00022 int output_h,
00023 int use_scrollbars,
00024 int use_cwindow,
00025 int use_rwindow,
00026 int use_vwindow)
00027 {
00028 reset();
00029
00030 if(x < 10) x = 10;
00031 if(y < 10) y = 10;
00032 this->mwindow = mwindow;
00033 this->subwindow = subwindow;
00034 this->x = x;
00035 this->y = y;
00036 this->w = w;
00037 this->h = h;
00038 this->output_w = output_w;
00039 this->output_h = output_h;
00040 this->use_scrollbars = use_scrollbars;
00041 this->use_cwindow = use_cwindow;
00042 this->use_rwindow = use_rwindow;
00043 this->use_vwindow = use_vwindow;
00044 this->root_w = subwindow->get_root_w(0, 0);
00045 this->root_h = subwindow->get_root_h(0);
00046 canvas_lock = new Mutex("Canvas::canvas_lock", 1);
00047 }
00048
00049 Canvas::~Canvas()
00050 {
00051 if(refresh_frame) delete refresh_frame;
00052 delete canvas_menu;
00053 if(yscroll) delete yscroll;
00054 if(xscroll) delete xscroll;
00055 delete canvas_subwindow;
00056 delete canvas_fullscreen;
00057 delete canvas_lock;
00058 }
00059
00060 void Canvas::reset()
00061 {
00062 use_scrollbars = 0;
00063 output_w = 0;
00064 output_h = 0;
00065 xscroll = 0;
00066 yscroll = 0;
00067 refresh_frame = 0;
00068 canvas_subwindow = 0;
00069 canvas_fullscreen = 0;
00070 is_processing = 0;
00071 cursor_inside = 0;
00072 }
00073
00074 void Canvas::lock_canvas(char *location)
00075 {
00076 canvas_lock->lock(location);
00077 }
00078
00079 void Canvas::unlock_canvas()
00080 {
00081 canvas_lock->unlock();
00082 }
00083
00084 int Canvas::is_locked()
00085 {
00086 return canvas_lock->is_locked();
00087 }
00088
00089
00090 BC_WindowBase* Canvas::get_canvas()
00091 {
00092 if(get_fullscreen() && canvas_fullscreen)
00093 return canvas_fullscreen;
00094 else
00095 return canvas_subwindow;
00096 }
00097
00098
00099
00100 void Canvas::calculate_sizes(float aspect_ratio,
00101 int output_w,
00102 int output_h,
00103 float zoom,
00104 int &w,
00105 int &h)
00106 {
00107
00108 if((float)output_w / output_h <= aspect_ratio)
00109 {
00110 w = (int)((float)output_h * aspect_ratio * zoom);
00111 h = (int)((float)output_h * zoom);
00112 }
00113 else
00114
00115 {
00116 h = (int)((float)output_w / aspect_ratio * zoom);
00117 w = (int)((float)output_w * zoom);
00118 }
00119 }
00120
00121 float Canvas::get_x_offset(EDL *edl,
00122 int single_channel,
00123 float zoom_x,
00124 float conformed_w,
00125 float conformed_h)
00126 {
00127 if(use_scrollbars)
00128 {
00129 if(xscroll)
00130 {
00131
00132
00133
00134
00135 return (float)get_xscroll();
00136 }
00137 else
00138 return ((float)-get_canvas()->get_w() / zoom_x +
00139 edl->session->output_w) / 2;
00140 }
00141 else
00142 {
00143 int out_w, out_h;
00144 int canvas_w = get_canvas()->get_w();
00145 int canvas_h = get_canvas()->get_h();
00146 out_w = canvas_w;
00147 out_h = canvas_h;
00148
00149 if((float)out_w / out_h > conformed_w / conformed_h)
00150 {
00151 out_w = (int)(out_h * conformed_w / conformed_h + 0.5);
00152 }
00153
00154 if(out_w < canvas_w)
00155 return -(canvas_w - out_w) / 2 / zoom_x;
00156 }
00157
00158 return 0;
00159 }
00160
00161 float Canvas::get_y_offset(EDL *edl,
00162 int single_channel,
00163 float zoom_y,
00164 float conformed_w,
00165 float conformed_h)
00166 {
00167 if(use_scrollbars)
00168 {
00169 if(yscroll)
00170 {
00171
00172
00173
00174
00175 return (float)get_yscroll();
00176 }
00177 else
00178 return ((float)-get_canvas()->get_h() / zoom_y +
00179 edl->session->output_h) / 2;
00180 }
00181 else
00182 {
00183 int out_w, out_h;
00184 int canvas_w = get_canvas()->get_w();
00185 int canvas_h = get_canvas()->get_h();
00186 out_w = canvas_w;
00187 out_h = canvas_h;
00188
00189 if((float)out_w / out_h <= conformed_w / conformed_h)
00190 {
00191 out_h = (int)((float)out_w / (conformed_w / conformed_h) + 0.5);
00192 }
00193
00194
00195 if(out_h < canvas_h)
00196 return -((float)canvas_h - out_h) / 2 / zoom_y;
00197 }
00198
00199 return 0;
00200 }
00201
00202
00203 void Canvas::check_boundaries(EDL *edl, int &x, int &y, float &zoom)
00204 {
00205 if(x + w_visible > w_needed) x = w_needed - w_visible;
00206 if(y + h_visible > h_needed) y = h_needed - h_visible;
00207
00208 if(x < 0) x = 0;
00209 if(y < 0) y = 0;
00210 }
00211
00212 void Canvas::update_scrollbars()
00213 {
00214 if(use_scrollbars)
00215 {
00216 if(xscroll) xscroll->update_length(w_needed, get_xscroll(), w_visible);
00217 if(yscroll) yscroll->update_length(h_needed, get_yscroll(), h_visible);
00218 }
00219 }
00220
00221 void Canvas::get_zooms(EDL *edl,
00222 int single_channel,
00223 float &zoom_x,
00224 float &zoom_y,
00225 float &conformed_w,
00226 float &conformed_h)
00227 {
00228 edl->calculate_conformed_dimensions(single_channel,
00229 conformed_w,
00230 conformed_h);
00231
00232 if(use_scrollbars)
00233 {
00234 zoom_x = get_zoom() *
00235 conformed_w /
00236 edl->session->output_w;
00237 zoom_y = get_zoom() *
00238 conformed_h /
00239 edl->session->output_h;
00240 }
00241 else
00242 {
00243 int out_w, out_h;
00244 int canvas_w = get_canvas()->get_w();
00245 int canvas_h = get_canvas()->get_h();
00246
00247 out_w = canvas_w;
00248 out_h = canvas_h;
00249
00250 if((float)out_w / out_h > conformed_w / conformed_h)
00251 {
00252 out_w = (int)((float)out_h * conformed_w / conformed_h + 0.5);
00253 }
00254 else
00255 {
00256 out_h = (int)((float)out_w / (conformed_w / conformed_h) + 0.5);
00257 }
00258
00259 zoom_x = (float)out_w / edl->session->output_w;
00260 zoom_y = (float)out_h / edl->session->output_h;
00261
00262 }
00263 }
00264
00265
00266 void Canvas::canvas_to_output(EDL *edl, int single_channel, float &x, float &y)
00267 {
00268 float zoom_x, zoom_y, conformed_w, conformed_h;
00269 get_zooms(edl, single_channel, zoom_x, zoom_y, conformed_w, conformed_h);
00270
00271
00272
00273
00274 x = (float)x / zoom_x + get_x_offset(edl, single_channel, zoom_x, conformed_w, conformed_h);
00275 y = (float)y / zoom_y + get_y_offset(edl, single_channel, zoom_y, conformed_w, conformed_h);
00276 }
00277
00278 void Canvas::output_to_canvas(EDL *edl, int single_channel, float &x, float &y)
00279 {
00280 float zoom_x, zoom_y, conformed_w, conformed_h;
00281 get_zooms(edl, single_channel, zoom_x, zoom_y, conformed_w, conformed_h);
00282
00283
00284
00285 x = (float)zoom_x * (x - get_x_offset(edl, single_channel, zoom_x, conformed_w, conformed_h));
00286 y = (float)zoom_y * (y - get_y_offset(edl, single_channel, zoom_y, conformed_w, conformed_h));
00287 }
00288
00289
00290
00291 void Canvas::get_transfers(EDL *edl,
00292 float &output_x1,
00293 float &output_y1,
00294 float &output_x2,
00295 float &output_y2,
00296 float &canvas_x1,
00297 float &canvas_y1,
00298 float &canvas_x2,
00299 float &canvas_y2,
00300 int canvas_w,
00301 int canvas_h)
00302 {
00303
00304
00305
00306 if(canvas_w < 0) canvas_w = get_canvas()->get_w();
00307 if(canvas_h < 0) canvas_h = get_canvas()->get_h();
00308
00309
00310 if(use_scrollbars)
00311 {
00312 float in_x1, in_y1, in_x2, in_y2;
00313 float out_x1, out_y1, out_x2, out_y2;
00314 float zoom_x, zoom_y, conformed_w, conformed_h;
00315
00316 get_zooms(edl, 0, zoom_x, zoom_y, conformed_w, conformed_h);
00317 out_x1 = 0;
00318 out_y1 = 0;
00319 out_x2 = canvas_w;
00320 out_y2 = canvas_h;
00321 in_x1 = 0;
00322 in_y1 = 0;
00323 in_x2 = canvas_w;
00324 in_y2 = canvas_h;
00325
00326 canvas_to_output(edl, 0, in_x1, in_y1);
00327 canvas_to_output(edl, 0, in_x2, in_y2);
00328
00329
00330
00331
00332 if(in_x1 < 0)
00333 {
00334 out_x1 += -in_x1 * zoom_x;
00335 in_x1 = 0;
00336 }
00337
00338 if(in_y1 < 0)
00339 {
00340 out_y1 += -in_y1 * zoom_y;
00341 in_y1 = 0;
00342 }
00343
00344 int output_w = get_output_w(edl);
00345 int output_h = get_output_h(edl);
00346
00347 if(in_x2 > output_w)
00348 {
00349 out_x2 -= (in_x2 - output_w) * zoom_x;
00350 in_x2 = output_w;
00351 }
00352
00353 if(in_y2 > output_h)
00354 {
00355 out_y2 -= (in_y2 - output_h) * zoom_y;
00356 in_y2 = output_h;
00357 }
00358
00359
00360
00361 output_x1 = in_x1;
00362 output_y1 = in_y1;
00363 output_x2 = in_x2;
00364 output_y2 = in_y2;
00365 canvas_x1 = out_x1;
00366 canvas_y1 = out_y1;
00367 canvas_x2 = out_x2;
00368 canvas_y2 = out_y2;
00369
00370
00371
00372
00373
00374
00375
00376
00377 }
00378 else
00379
00380 {
00381
00382 canvas_x1 = 0;
00383 canvas_y1 = 0;
00384 canvas_x2 = canvas_w;
00385 canvas_y2 = canvas_h;
00386
00387 if(edl)
00388 {
00389
00390 float out_w = canvas_x2 - canvas_x1;
00391 float out_h = canvas_y2 - canvas_y1;
00392 if(out_w / out_h > edl->get_aspect_ratio())
00393 {
00394 out_w = (int)(out_h * edl->get_aspect_ratio() + 0.5);
00395 canvas_x1 = canvas_w / 2 - out_w / 2;
00396 }
00397 else
00398 {
00399 out_h = (int)(out_w / edl->get_aspect_ratio() + 0.5);
00400 canvas_y1 = canvas_h / 2 - out_h / 2;
00401 }
00402 canvas_x2 = canvas_x1 + out_w;
00403 canvas_y2 = canvas_y1 + out_h;
00404
00405
00406 output_x1 = 0;
00407 output_y1 = 0;
00408 output_x2 = get_output_w(edl);
00409 output_y2 = get_output_h(edl);
00410 }
00411 else
00412
00413 {
00414 output_x1 = 0;
00415 output_y1 = 0;
00416 output_x2 = this->output_w;
00417 output_y2 = this->output_h;
00418 }
00419 }
00420
00421
00422 output_x1 = MAX(0, output_x1);
00423 output_y1 = MAX(0, output_y1);
00424 output_x2 = MAX(output_x1, output_x2);
00425 output_y2 = MAX(output_y1, output_y2);
00426 canvas_x1 = MAX(0, canvas_x1);
00427 canvas_y1 = MAX(0, canvas_y1);
00428 canvas_x2 = MAX(canvas_x1, canvas_x2);
00429 canvas_y2 = MAX(canvas_y1, canvas_y2);
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439 }
00440
00441 int Canvas::scrollbars_exist()
00442 {
00443 return(use_scrollbars && (xscroll || yscroll));
00444 }
00445
00446 int Canvas::get_output_w(EDL *edl)
00447 {
00448 if(use_scrollbars)
00449 return edl->session->output_w;
00450 else
00451 return edl->session->output_w;
00452 }
00453
00454 int Canvas::get_output_h(EDL *edl)
00455 {
00456 if(edl)
00457 {
00458 if(use_scrollbars)
00459 return edl->session->output_h;
00460 else
00461 return edl->session->output_h;
00462 }
00463 }
00464
00465
00466
00467 void Canvas::get_scrollbars(EDL *edl,
00468 int &canvas_x,
00469 int &canvas_y,
00470 int &canvas_w,
00471 int &canvas_h)
00472 {
00473 int need_xscroll = 0;
00474 int need_yscroll = 0;
00475
00476 float zoom_x, zoom_y, conformed_w, conformed_h;
00477
00478 if(edl)
00479 {
00480 w_needed = edl->session->output_w;
00481 h_needed = edl->session->output_h;
00482 w_visible = w_needed;
00483 h_visible = h_needed;
00484 }
00485
00486
00487 if(use_scrollbars)
00488 {
00489 w_needed = edl->session->output_w;
00490 h_needed = edl->session->output_h;
00491 get_zooms(edl, 0, zoom_x, zoom_y, conformed_w, conformed_h);
00492
00493
00494
00495
00496 w_visible = (int)(canvas_w / zoom_x);
00497 h_visible = (int)(canvas_h / zoom_y);
00498
00499
00500
00501 if(1)
00502 {
00503 if(!need_xscroll)
00504 {
00505 need_xscroll = 1;
00506 canvas_h -= BC_ScrollBar::get_span(SCROLL_HORIZ);
00507
00508 }
00509 }
00510 else
00511 need_xscroll = 0;
00512
00513
00514 if(1)
00515 {
00516 if(!need_yscroll)
00517 {
00518 need_yscroll = 1;
00519 canvas_w -= BC_ScrollBar::get_span(SCROLL_VERT);
00520
00521 }
00522 }
00523 else
00524 need_yscroll = 0;
00525
00526
00527
00528
00529 w_visible = (int)(canvas_w / zoom_x);
00530 h_visible = (int)(canvas_h / zoom_y);
00531 }
00532
00533 if(need_xscroll)
00534 {
00535 if(!xscroll)
00536 subwindow->add_subwindow(xscroll = new CanvasXScroll(edl,
00537 this,
00538 canvas_x,
00539 canvas_y + canvas_h,
00540 w_needed,
00541 get_xscroll(),
00542 w_visible,
00543 canvas_w));
00544 else
00545 xscroll->reposition_window(canvas_x, canvas_y + canvas_h, canvas_w);
00546
00547 if(xscroll->get_length() != w_needed ||
00548 xscroll->get_handlelength() != w_visible)
00549 xscroll->update_length(w_needed, get_xscroll(), w_visible);
00550 }
00551 else
00552 {
00553 if(xscroll) delete xscroll;
00554 xscroll = 0;
00555 }
00556
00557
00558 if(need_yscroll)
00559 {
00560 if(!yscroll)
00561 subwindow->add_subwindow(yscroll = new CanvasYScroll(edl,
00562 this,
00563 canvas_x + canvas_w,
00564 canvas_y,
00565 h_needed,
00566 get_yscroll(),
00567 h_visible,
00568 canvas_h));
00569 else
00570 yscroll->reposition_window(canvas_x + canvas_w, canvas_y, canvas_h);
00571
00572 if(yscroll->get_length() != edl->session->output_h ||
00573 yscroll->get_handlelength() != h_visible)
00574 yscroll->update_length(h_needed, get_yscroll(), h_visible);
00575 }
00576 else
00577 {
00578 if(yscroll) delete yscroll;
00579 yscroll = 0;
00580 }
00581
00582 }
00583
00584 void Canvas::reposition_window(EDL *edl, int x, int y, int w, int h)
00585 {
00586 this->x = x;
00587 this->y = y;
00588 this->w = w;
00589 this->h = h;
00590 view_x = x;
00591 view_y = y;
00592 view_w = w;
00593 view_h = h;
00594
00595 get_scrollbars(edl, view_x, view_y, view_w, view_h);
00596
00597 if(canvas_subwindow)
00598 {
00599 canvas_subwindow->reposition_window(view_x, view_y, view_w, view_h);
00600
00601
00602 if(canvas_subwindow->get_video_on())
00603 {
00604 canvas_subwindow->set_color(BLACK);
00605 canvas_subwindow->draw_box(0,
00606 0,
00607 get_canvas()->get_w(),
00608 get_canvas()->get_h());
00609 canvas_subwindow->flash();
00610 }
00611 }
00612
00613
00614 draw_refresh();
00615
00616 }
00617
00618 void Canvas::set_cursor(int cursor)
00619 {
00620 get_canvas()->set_cursor(cursor);
00621 }
00622
00623 int Canvas::get_cursor_x()
00624 {
00625 return get_canvas()->get_cursor_x();
00626 }
00627
00628 int Canvas::get_cursor_y()
00629 {
00630 return get_canvas()->get_cursor_y();
00631 }
00632
00633 int Canvas::get_buttonpress()
00634 {
00635 return get_canvas()->get_buttonpress();
00636 }
00637
00638
00639 int Canvas::create_objects(EDL *edl)
00640 {
00641 view_x = x;
00642 view_y = y;
00643 view_w = w;
00644 view_h = h;
00645 get_scrollbars(edl, view_x, view_y, view_w, view_h);
00646
00647 create_canvas();
00648
00649 subwindow->add_subwindow(canvas_menu = new CanvasPopup(this));
00650 canvas_menu->create_objects();
00651
00652 subwindow->add_subwindow(fullscreen_menu = new CanvasFullScreenPopup(this));
00653 fullscreen_menu->create_objects();
00654
00655 return 0;
00656 }
00657
00658 int Canvas::button_press_event()
00659 {
00660 int result = 0;
00661
00662 if(get_canvas()->get_buttonpress() == 3)
00663 {
00664 if(get_fullscreen())
00665 fullscreen_menu->activate_menu();
00666 else
00667 canvas_menu->activate_menu();
00668 result = 1;
00669 }
00670
00671 return result;
00672 }
00673
00674 void Canvas::start_single()
00675 {
00676 is_processing = 1;
00677 status_event();
00678 }
00679
00680 void Canvas::stop_single()
00681 {
00682 is_processing = 0;
00683 status_event();
00684 }
00685
00686 void Canvas::start_video()
00687 {
00688 if(get_canvas())
00689 {
00690 get_canvas()->start_video();
00691 status_event();
00692 }
00693 }
00694
00695 void Canvas::stop_video()
00696 {
00697 if(get_canvas())
00698 {
00699 get_canvas()->stop_video();
00700 status_event();
00701 }
00702 }
00703
00704
00705 void Canvas::start_fullscreen()
00706 {
00707 set_fullscreen(1);
00708 create_canvas();
00709 }
00710
00711 void Canvas::stop_fullscreen()
00712 {
00713 set_fullscreen(0);
00714 create_canvas();
00715 }
00716
00717 void Canvas::create_canvas()
00718 {
00719 int video_on = 0;
00720 SET_TRACE
00721 lock_canvas("Canvas::create_canvas");
00722 SET_TRACE
00723
00724
00725 if(!get_fullscreen())
00726 {
00727 SET_TRACE
00728 if(canvas_fullscreen)
00729 {
00730 video_on = canvas_fullscreen->get_video_on();
00731 canvas_fullscreen->stop_video();
00732 }
00733 SET_TRACE
00734
00735 if(canvas_fullscreen)
00736 {
00737 canvas_fullscreen->hide_window();
00738
00739
00740 }
00741 SET_TRACE
00742
00743 if(!canvas_subwindow)
00744 {
00745 subwindow->add_subwindow(canvas_subwindow = new CanvasOutput(this,
00746 view_x,
00747 view_y,
00748 view_w,
00749 view_h));
00750 }
00751 SET_TRACE
00752 }
00753 else
00754 {
00755 if(canvas_subwindow)
00756 {
00757 video_on = canvas_subwindow->get_video_on();
00758 canvas_subwindow->stop_video();
00759
00760
00761
00762 }
00763
00764 if(!canvas_fullscreen)
00765 {
00766 canvas_fullscreen = new CanvasFullScreen(this,
00767 root_w,
00768 root_h);
00769 }
00770 else
00771 {
00772 canvas_fullscreen->show_window();
00773 }
00774 }
00775 SET_TRACE
00776
00777 if(!video_on) draw_refresh();
00778 SET_TRACE
00779 if(video_on) get_canvas()->start_video();
00780 SET_TRACE
00781 unlock_canvas();
00782 }
00783
00784
00785
00786 int Canvas::cursor_leave_event_base(BC_WindowBase *caller)
00787 {
00788 int result = 0;
00789 if(cursor_inside) result = cursor_leave_event();
00790 cursor_inside = 0;
00791 return result;
00792 }
00793
00794 int Canvas::cursor_enter_event_base(BC_WindowBase *caller)
00795 {
00796 int result = 0;
00797 if(caller->is_event_win() && caller->cursor_inside())
00798 {
00799 cursor_inside = 1;
00800 result = cursor_enter_event();
00801 }
00802 return result;
00803 }
00804
00805 int Canvas::button_press_event_base(BC_WindowBase *caller)
00806 {
00807 if(caller->is_event_win() && caller->cursor_inside())
00808 {
00809 return button_press_event();
00810 }
00811 return 0;
00812 }
00813
00814 int Canvas::keypress_event(BC_WindowBase *caller)
00815 {
00816 int caller_is_canvas = (caller == get_canvas());
00817 if(caller->get_keypress() == 'f')
00818 {
00819 caller->unlock_window();
00820 if(get_fullscreen())
00821 stop_fullscreen();
00822 else
00823 start_fullscreen();
00824 if(!caller_is_canvas) caller->lock_window("Canvas::keypress_event 1");
00825 return 1;
00826 }
00827 else
00828 if(caller->get_keypress() == ESC)
00829 {
00830 caller->unlock_window();
00831 if(get_fullscreen())
00832 stop_fullscreen();
00833 if(!caller_is_canvas) caller->lock_window("Canvas::keypress_event 2");
00834 return 1;
00835 }
00836 return 0;
00837 }
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855 CanvasOutput::CanvasOutput(Canvas *canvas,
00856 int x,
00857 int y,
00858 int w,
00859 int h)
00860 : BC_SubWindow(x, y, w, h, BLACK)
00861 {
00862 this->canvas = canvas;
00863 }
00864
00865 CanvasOutput::~CanvasOutput()
00866 {
00867 }
00868
00869 int CanvasOutput::cursor_leave_event()
00870 {
00871 return canvas->cursor_leave_event_base(this);
00872 }
00873
00874 int CanvasOutput::cursor_enter_event()
00875 {
00876 return canvas->cursor_enter_event_base(this);
00877 }
00878
00879 int CanvasOutput::button_press_event()
00880 {
00881 return canvas->button_press_event_base(this);
00882 }
00883
00884 int CanvasOutput::button_release_event()
00885 {
00886 return canvas->button_release_event();
00887 }
00888
00889 int CanvasOutput::cursor_motion_event()
00890 {
00891 return canvas->cursor_motion_event();
00892 }
00893
00894 int CanvasOutput::keypress_event()
00895 {
00896 return canvas->keypress_event(this);
00897 }
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911 CanvasFullScreen::CanvasFullScreen(Canvas *canvas,
00912 int w,
00913 int h)
00914 : BC_FullScreen(canvas->subwindow,
00915 w,
00916 h,
00917 BLACK,
00918 0,
00919 0,
00920 0)
00921 {
00922 this->canvas = canvas;
00923 }
00924
00925 CanvasFullScreen::~CanvasFullScreen()
00926 {
00927 }
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941 CanvasXScroll::CanvasXScroll(EDL *edl,
00942 Canvas *canvas,
00943 int x,
00944 int y,
00945 int length,
00946 int position,
00947 int handle_length,
00948 int pixels)
00949 : BC_ScrollBar(x,
00950 y,
00951 SCROLL_HORIZ,
00952 pixels,
00953 length,
00954 position,
00955 handle_length)
00956 {
00957 this->canvas = canvas;
00958 }
00959
00960 CanvasXScroll::~CanvasXScroll()
00961 {
00962 }
00963
00964 int CanvasXScroll::handle_event()
00965 {
00966
00967 canvas->update_zoom(get_value(), canvas->get_yscroll(), canvas->get_zoom());
00968 canvas->draw_refresh();
00969 return 1;
00970 }
00971
00972
00973
00974
00975
00976
00977 CanvasYScroll::CanvasYScroll(EDL *edl,
00978 Canvas *canvas,
00979 int x,
00980 int y,
00981 int length,
00982 int position,
00983 int handle_length,
00984 int pixels)
00985 : BC_ScrollBar(x,
00986 y,
00987 SCROLL_VERT,
00988 pixels,
00989 length,
00990 position,
00991 handle_length)
00992 {
00993 this->canvas = canvas;
00994 }
00995
00996 CanvasYScroll::~CanvasYScroll()
00997 {
00998 }
00999
01000 int CanvasYScroll::handle_event()
01001 {
01002
01003 canvas->update_zoom(canvas->get_xscroll(), get_value(), canvas->get_zoom());
01004 canvas->draw_refresh();
01005 return 1;
01006 }
01007
01008
01009
01010
01011
01012
01013 CanvasFullScreenPopup::CanvasFullScreenPopup(Canvas *canvas)
01014 : BC_PopupMenu(0,
01015 0,
01016 0,
01017 "",
01018 0)
01019 {
01020 this->canvas = canvas;
01021 }
01022
01023
01024 void CanvasFullScreenPopup::create_objects()
01025 {
01026 if(canvas->use_cwindow) add_item(new CanvasPopupAuto(canvas));
01027 add_item(new CanvasSubWindowItem(canvas));
01028 }
01029
01030
01031 CanvasSubWindowItem::CanvasSubWindowItem(Canvas *canvas)
01032 : BC_MenuItem(_("Windowed"), "f", 'f')
01033 {
01034 this->canvas = canvas;
01035 }
01036
01037 int CanvasSubWindowItem::handle_event()
01038 {
01039
01040
01041 canvas->subwindow->unlock_window();
01042 canvas->stop_fullscreen();
01043 canvas->subwindow->lock_window("CanvasSubWindowItem::handle_event");
01044 return 1;
01045 }
01046
01047
01048
01049
01050
01051
01052
01053
01054 CanvasPopup::CanvasPopup(Canvas *canvas)
01055 : BC_PopupMenu(0,
01056 0,
01057 0,
01058 "",
01059 0)
01060 {
01061 this->canvas = canvas;
01062 }
01063
01064 CanvasPopup::~CanvasPopup()
01065 {
01066 }
01067
01068 void CanvasPopup::create_objects()
01069 {
01070 add_item(new CanvasPopupSize(canvas, _("Zoom 25%"), 0.25));
01071 add_item(new CanvasPopupSize(canvas, _("Zoom 33%"), 0.33));
01072 add_item(new CanvasPopupSize(canvas, _("Zoom 50%"), 0.5));
01073 add_item(new CanvasPopupSize(canvas, _("Zoom 75%"), 0.75));
01074 add_item(new CanvasPopupSize(canvas, _("Zoom 100%"), 1.0));
01075 add_item(new CanvasPopupSize(canvas, _("Zoom 150%"), 1.5));
01076 add_item(new CanvasPopupSize(canvas, _("Zoom 200%"), 2.0));
01077 add_item(new CanvasPopupSize(canvas, _("Zoom 300%"), 3.0));
01078 add_item(new CanvasPopupSize(canvas, _("Zoom 400%"), 4.0));
01079 if(canvas->use_cwindow)
01080 {
01081 add_item(new CanvasPopupAuto(canvas));
01082 add_item(new CanvasPopupResetCamera(canvas));
01083 add_item(new CanvasPopupResetProjector(canvas));
01084 add_item(toggle_controls = new CanvasToggleControls(canvas));
01085 }
01086 if(canvas->use_rwindow)
01087 {
01088 add_item(new CanvasPopupResetTranslation(canvas));
01089 }
01090 if(canvas->use_vwindow)
01091 {
01092 add_item(new CanvasPopupRemoveSource(canvas));
01093 }
01094 add_item(new CanvasFullScreenItem(canvas));
01095 }
01096
01097
01098
01099 CanvasPopupAuto::CanvasPopupAuto(Canvas *canvas)
01100 : BC_MenuItem(_("Zoom Auto"))
01101 {
01102 this->canvas = canvas;
01103 }
01104
01105 int CanvasPopupAuto::handle_event()
01106 {
01107 canvas->zoom_auto();
01108 return 1;
01109 }
01110
01111
01112 CanvasPopupSize::CanvasPopupSize(Canvas *canvas, char *text, float percentage)
01113 : BC_MenuItem(text)
01114 {
01115 this->canvas = canvas;
01116 this->percentage = percentage;
01117 }
01118 CanvasPopupSize::~CanvasPopupSize()
01119 {
01120 }
01121 int CanvasPopupSize::handle_event()
01122 {
01123 canvas->zoom_resize_window(percentage);
01124 return 1;
01125 }
01126
01127
01128
01129 CanvasPopupResetCamera::CanvasPopupResetCamera(Canvas *canvas)
01130 : BC_MenuItem(_("Reset camera"))
01131 {
01132 this->canvas = canvas;
01133 }
01134 int CanvasPopupResetCamera::handle_event()
01135 {
01136 canvas->reset_camera();
01137 return 1;
01138 }
01139
01140
01141
01142 CanvasPopupResetProjector::CanvasPopupResetProjector(Canvas *canvas)
01143 : BC_MenuItem(_("Reset projector"))
01144 {
01145 this->canvas = canvas;
01146 }
01147 int CanvasPopupResetProjector::handle_event()
01148 {
01149 canvas->reset_projector();
01150 return 1;
01151 }
01152
01153
01154
01155 CanvasPopupResetTranslation::CanvasPopupResetTranslation(Canvas *canvas)
01156 : BC_MenuItem(_("Reset translation"))
01157 {
01158 this->canvas = canvas;
01159 }
01160 int CanvasPopupResetTranslation::handle_event()
01161 {
01162 canvas->reset_translation();
01163 return 1;
01164 }
01165
01166
01167
01168 CanvasToggleControls::CanvasToggleControls(Canvas *canvas)
01169 : BC_MenuItem(calculate_text(canvas->get_cwindow_controls()))
01170 {
01171 this->canvas = canvas;
01172 }
01173 int CanvasToggleControls::handle_event()
01174 {
01175 canvas->toggle_controls();
01176 set_text(calculate_text(canvas->get_cwindow_controls()));
01177 return 1;
01178 }
01179
01180 char* CanvasToggleControls::calculate_text(int cwindow_controls)
01181 {
01182 if(!cwindow_controls)
01183 return _("Show controls");
01184 else
01185 return _("Hide controls");
01186 }
01187
01188
01189
01190
01191
01192
01193
01194 CanvasFullScreenItem::CanvasFullScreenItem(Canvas *canvas)
01195 : BC_MenuItem(_("Fullscreen"), "f", 'f')
01196 {
01197 this->canvas = canvas;
01198 }
01199 int CanvasFullScreenItem::handle_event()
01200 {
01201 canvas->subwindow->unlock_window();
01202 canvas->start_fullscreen();
01203 canvas->subwindow->lock_window("CanvasFullScreenItem::handle_event");
01204 return 1;
01205 }
01206
01207
01208
01209
01210
01211
01212
01213
01214
01215 CanvasPopupRemoveSource::CanvasPopupRemoveSource(Canvas *canvas)
01216 : BC_MenuItem(_("Close source"))
01217 {
01218 this->canvas = canvas;
01219 }
01220 int CanvasPopupRemoveSource::handle_event()
01221 {
01222 canvas->close_source();
01223 return 1;
01224 }
01225
01226