Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

canvas.C

Go to the documentation of this file.
00001 #include "canvas.h"
00002 #include "clip.h"
00003 #include "edl.h"
00004 #include "edlsession.h"
00005 #include "language.h"
00006 #include "vframe.h"
00007 
00008 
00009 
00010 Canvas::Canvas(BC_WindowBase *subwindow, 
00011         int x, 
00012         int y, 
00013         int w, 
00014         int h,
00015         int output_w,
00016         int output_h,
00017         int use_scrollbars,
00018         int use_cwindow,
00019         int use_rwindow,
00020         int use_vwindow)
00021 {
00022         reset();
00023         this->subwindow = subwindow;
00024         this->x = x;
00025         this->y = y;
00026         this->w = w;
00027         this->h = h;
00028         this->output_w = output_w;
00029         this->output_h = output_h;
00030         this->use_scrollbars = use_scrollbars;
00031         this->use_cwindow = use_cwindow;
00032         this->use_rwindow = use_rwindow;
00033         this->use_vwindow = use_vwindow;
00034 }
00035 
00036 Canvas::~Canvas()
00037 {
00038         if(refresh_frame) delete refresh_frame;
00039         delete canvas_menu;
00040         if(yscroll) delete yscroll;
00041         if(xscroll) delete xscroll;
00042         delete canvas;
00043 }
00044 
00045 void Canvas::reset()
00046 {
00047         use_scrollbars = 0;
00048         output_w = 0;
00049         output_h = 0;
00050     xscroll = 0;
00051     yscroll = 0;
00052         refresh_frame = 0;
00053         canvas = 0;
00054         is_processing = 0;
00055 }
00056 
00057 // Get dimensions given a zoom
00058 void Canvas::calculate_sizes(float aspect_ratio, 
00059         int output_w, 
00060         int output_h, 
00061         float zoom, 
00062         int &w, 
00063         int &h)
00064 {
00065 // Horizontal stretch
00066         if((float)output_w / output_h <= aspect_ratio)
00067         {
00068                 w = (int)((float)output_h * aspect_ratio * zoom);
00069                 h = (int)((float)output_h * zoom);
00070         }
00071         else
00072 // Vertical stretch
00073         {
00074                 h = (int)((float)output_w / aspect_ratio * zoom);
00075                 w = (int)((float)output_w * zoom);
00076         }
00077 }
00078 
00079 float Canvas::get_x_offset(EDL *edl, 
00080         int single_channel, 
00081         float zoom_x, 
00082         float conformed_w,
00083         float conformed_h)
00084 {
00085         if(use_scrollbars)
00086         {
00087                 if(xscroll) 
00088                 {
00089 // If the projection is smaller than the canvas, this forces it in the center.
00090 //                      if(conformed_w < w_visible)
00091 //                              return -(float)(w_visible - conformed_w) / 2;
00092 
00093                         return (float)get_xscroll();
00094                 }
00095                 else
00096                         return ((float)-canvas->get_w() / zoom_x + 
00097                                 edl->session->output_w) / 2;
00098         }
00099         else
00100         {
00101                 int out_w, out_h;
00102                 int canvas_w = canvas->get_w();
00103                 int canvas_h = canvas->get_h();
00104                 out_w = canvas_w;
00105                 out_h = canvas_h;
00106                 
00107                 if((float)out_w / out_h > conformed_w / conformed_h)
00108                 {
00109                         out_w = (int)(out_h * conformed_w / conformed_h + 0.5);
00110                 }
00111                 
00112                 if(out_w < canvas_w)
00113                         return -(canvas_w - out_w) / 2 / zoom_x;
00114         }
00115 
00116         return 0;
00117 }
00118 
00119 float Canvas::get_y_offset(EDL *edl, 
00120         int single_channel, 
00121         float zoom_y, 
00122         float conformed_w,
00123         float conformed_h)
00124 {
00125         if(use_scrollbars)
00126         {
00127                 if(yscroll)
00128                 {
00129 // If the projection is smaller than the canvas, this forces it in the center.
00130 //                      if(conformed_h < h_visible)
00131 //                              return -(float)(h_visible - conformed_h) / 2;
00132 
00133                         return (float)get_yscroll();
00134                 }
00135                 else
00136                         return ((float)-canvas->get_h() / zoom_y + 
00137                                 edl->session->output_h) / 2;
00138         }
00139         else
00140         {
00141                 int out_w, out_h;
00142                 int canvas_w = canvas->get_w();
00143                 int canvas_h = canvas->get_h();
00144                 out_w = canvas_w;
00145                 out_h = canvas_h;
00146 
00147                 if((float)out_w / out_h <= conformed_w / conformed_h)
00148                 {
00149                         out_h = (int)((float)out_w / (conformed_w / conformed_h) + 0.5);
00150                 }
00151 
00152 //printf("Canvas::get_y_offset 1 %d %d %f\n", out_h, canvas_h, -((float)canvas_h - out_h) / 2);
00153                 if(out_h < canvas_h)
00154                         return -((float)canvas_h - out_h) / 2 / zoom_y;
00155         }
00156 
00157         return 0;
00158 }
00159 
00160 // This may not be used anymore
00161 void Canvas::check_boundaries(EDL *edl, int &x, int &y, float &zoom)
00162 {
00163         if(x + w_visible > w_needed) x = w_needed - w_visible;
00164         if(y + h_visible > h_needed) y = h_needed - h_visible;
00165 
00166         if(x < 0) x = 0;
00167         if(y < 0) y = 0;
00168 }
00169 
00170 void Canvas::update_scrollbars()
00171 {
00172         if(use_scrollbars)
00173         {
00174                 if(xscroll) xscroll->update_length(w_needed, get_xscroll(), w_visible);
00175                 if(yscroll) yscroll->update_length(h_needed, get_yscroll(), h_visible);
00176         }
00177 }
00178 
00179 void Canvas::get_zooms(EDL *edl, 
00180         int single_channel, 
00181         float &zoom_x, 
00182         float &zoom_y,
00183         float &conformed_w,
00184         float &conformed_h)
00185 {
00186         edl->calculate_conformed_dimensions(single_channel, 
00187                 conformed_w, 
00188                 conformed_h);
00189 
00190         if(use_scrollbars)
00191         {
00192                 zoom_x = get_zoom() * 
00193                         conformed_w / 
00194                         edl->session->output_w;
00195                 zoom_y = get_zoom() * 
00196                         conformed_h / 
00197                         edl->session->output_h;
00198         }
00199         else
00200         {
00201                 int out_w, out_h;
00202                 int canvas_w = canvas->get_w();
00203                 int canvas_h = canvas->get_h();
00204         
00205                 out_w = canvas_w;
00206                 out_h = canvas_h;
00207 
00208                 if((float)out_w / out_h > conformed_w / conformed_h)
00209                 {
00210                         out_w = (int)((float)out_h * conformed_w / conformed_h + 0.5);
00211                 }
00212                 else
00213                 {
00214                         out_h = (int)((float)out_w / (conformed_w / conformed_h) + 0.5);
00215                 }
00216 
00217                 zoom_x = (float)out_w / edl->session->output_w;
00218                 zoom_y = (float)out_h / edl->session->output_h;
00219 //printf("get zooms 2 %d %d %f %f\n", canvas_w, canvas_h, conformed_w, conformed_h);
00220         }
00221 }
00222 
00223 // Convert a coordinate on the canvas to a coordinate on the output
00224 void Canvas::canvas_to_output(EDL *edl, int single_channel, float &x, float &y)
00225 {
00226         float zoom_x, zoom_y, conformed_w, conformed_h;
00227         get_zooms(edl, single_channel, zoom_x, zoom_y, conformed_w, conformed_h);
00228 
00229 //printf("Canvas::canvas_to_output y=%f zoom_y=%f y_offset=%f\n", 
00230 //      y, zoom_y, get_y_offset(edl, single_channel, zoom_y, conformed_w, conformed_h));
00231 
00232         x = (float)x / zoom_x + get_x_offset(edl, single_channel, zoom_x, conformed_w, conformed_h);
00233         y = (float)y / zoom_y + get_y_offset(edl, single_channel, zoom_y, conformed_w, conformed_h);
00234 }
00235 
00236 void Canvas::output_to_canvas(EDL *edl, int single_channel, float &x, float &y)
00237 {
00238         float zoom_x, zoom_y, conformed_w, conformed_h;
00239         get_zooms(edl, single_channel, zoom_x, zoom_y, conformed_w, conformed_h);
00240 
00241 //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));
00242 
00243         x = (float)zoom_x * (x - get_x_offset(edl, single_channel, zoom_x, conformed_w, conformed_h));
00244         y = (float)zoom_y * (y - get_y_offset(edl, single_channel, zoom_y, conformed_w, conformed_h));
00245 }
00246 
00247 
00248 
00249 void Canvas::get_transfers(EDL *edl, 
00250         int &in_x, 
00251         int &in_y, 
00252         int &in_w, 
00253         int &in_h,
00254         int &out_x, 
00255         int &out_y, 
00256         int &out_w, 
00257         int &out_h,
00258         int canvas_w,
00259         int canvas_h)
00260 {
00261 // printf("Canvas::get_transfers %d %d\n", canvas_w, 
00262 //              canvas_h);
00263         if(canvas_w < 0) canvas_w = canvas->get_w();
00264         if(canvas_h < 0) canvas_h = canvas->get_h();
00265 
00266         if(use_scrollbars)
00267         {
00268                 float in_x1, in_y1, in_x2, in_y2;
00269                 float out_x1, out_y1, out_x2, out_y2;
00270                 float zoom_x, zoom_y, conformed_w, conformed_h;
00271 
00272                 get_zooms(edl, 0, zoom_x, zoom_y, conformed_w, conformed_h);
00273                 out_x1 = 0;
00274                 out_y1 = 0;
00275                 out_x2 = canvas_w;
00276                 out_y2 = canvas_h;
00277                 in_x1 = 0;
00278                 in_y1 = 0;
00279                 in_x2 = canvas_w;
00280                 in_y2 = canvas_h;
00281 
00282                 canvas_to_output(edl, 0, in_x1, in_y1);
00283                 canvas_to_output(edl, 0, in_x2, in_y2);
00284 
00285 //printf("Canvas::get_transfers 1 %.0f %.0f %.0f %.0f -> %.0f %.0f %.0f %.0f\n",
00286 //in_x1, in_y1, in_x2, in_y2, out_x1, out_y1, out_x2, out_y2);
00287 
00288                 if(in_x1 < 0)
00289                 {
00290                         out_x1 += -in_x1 * zoom_x;
00291                         in_x1 = 0;
00292                 }
00293 
00294                 if(in_y1 < 0)
00295                 {
00296                         out_y1 += -in_y1 * zoom_y;
00297                         in_y1 = 0;
00298                 }
00299 
00300                 int output_w = get_output_w(edl);
00301                 int output_h = get_output_h(edl);
00302 
00303                 if(in_x2 > output_w)
00304                 {
00305                         out_x2 -= (in_x2 - output_w) * zoom_x;
00306                         in_x2 = output_w;
00307                 }
00308 
00309                 if(in_y2 > output_h)
00310                 {
00311                         out_y2 -= (in_y2 - output_h) * zoom_y;
00312                         in_y2 = output_h;
00313                 }
00314 // printf("Canvas::get_transfers 2 %.0f %.0f %.0f %.0f -> %.0f %.0f %.0f %.0f\n",
00315 //                      in_x1, in_y1, in_x2, in_y2, out_x1, out_y1, out_x2, out_y2);
00316 
00317                 in_x = (int)in_x1;
00318                 in_y = (int)in_y1;
00319                 in_w = (int)(in_x2 - in_x1);
00320                 in_h = (int)(in_y2 - in_y1);
00321                 out_x = (int)out_x1;
00322                 out_y = (int)out_y1;
00323                 out_w = (int)(out_x2 - out_x1);
00324                 out_h = (int)(out_y2 - out_y1);
00325 
00326 // Center on canvas
00327 //              if(!scrollbars_exist())
00328 //              {
00329 //                      out_x = canvas_w / 2 - out_w / 2;
00330 //                      out_y = canvas_h / 2 - out_h / 2;
00331 //              }
00332 
00333 // printf("Canvas::get_transfers 2 %d %d %d %d -> %d %d %d %d\n",in_x, 
00334 //                      in_y, 
00335 //                      in_w, 
00336 //                      in_h,
00337 //                      out_x, 
00338 //                      out_y, 
00339 //                      out_w, 
00340 //                      out_h);
00341         }
00342         else
00343         {
00344                 out_x = 0;
00345                 out_y = 0;
00346                 out_w = canvas_w;
00347                 out_h = canvas_h;
00348 
00349                 if(edl)
00350                 {
00351                         if((float)out_w / out_h > edl->get_aspect_ratio())
00352                         {
00353                                 out_w = (int)(out_h * edl->get_aspect_ratio() + 0.5);
00354                                 out_x = canvas_w / 2 - out_w / 2;
00355                         }
00356                         else
00357                         {
00358                                 out_h = (int)(out_w / edl->get_aspect_ratio() + 0.5);
00359                                 out_y = canvas_h / 2 - out_h / 2;
00360                         }
00361                         in_x = 0;
00362                         in_y = 0;
00363                         in_w = get_output_w(edl);
00364                         in_h = get_output_h(edl);
00365                 }
00366                 else
00367                 {
00368                         in_x = 0;
00369                         in_y = 0;
00370                         in_w = this->output_w;
00371                         in_h = this->output_h;
00372                 }
00373         }
00374 
00375         in_x = MAX(0, in_x);
00376         in_y = MAX(0, in_y);
00377         in_w = MAX(0, in_w);
00378         in_h = MAX(0, in_h);
00379         out_x = MAX(0, out_x);
00380         out_y = MAX(0, out_y);
00381         out_w = MAX(0, out_w);
00382         out_h = MAX(0, out_h);
00383 }
00384 
00385 int Canvas::scrollbars_exist()
00386 {
00387         return(use_scrollbars && (xscroll || yscroll));
00388 }
00389 
00390 int Canvas::get_output_w(EDL *edl)
00391 {
00392         if(use_scrollbars)
00393                 return edl->session->output_w;
00394         else
00395                 return edl->session->output_w;
00396 }
00397 
00398 int Canvas::get_output_h(EDL *edl)
00399 {
00400         if(edl)
00401         {
00402                 if(use_scrollbars)
00403                         return edl->session->output_h;
00404                 else
00405                         return edl->session->output_h;
00406         }
00407 }
00408 
00409 
00410 
00411 void Canvas::get_scrollbars(EDL *edl, 
00412         int &canvas_x, 
00413         int &canvas_y, 
00414         int &canvas_w, 
00415         int &canvas_h)
00416 {
00417         int need_xscroll = 0;
00418         int need_yscroll = 0;
00419 //      int done = 0;
00420         float zoom_x, zoom_y, conformed_w, conformed_h;
00421 
00422         if(edl)
00423         {
00424                 w_needed = edl->session->output_w;
00425                 h_needed = edl->session->output_h;
00426                 w_visible = w_needed;
00427                 h_visible = h_needed;
00428         }
00429 //printf("Canvas::get_scrollbars 1 %d %d\n", get_xscroll(), get_yscroll());
00430 
00431         if(use_scrollbars)
00432         {
00433                 w_needed = edl->session->output_w;
00434                 h_needed = edl->session->output_h;
00435                 get_zooms(edl, 0, zoom_x, zoom_y, conformed_w, conformed_h);
00436 //printf("Canvas::get_scrollbars 2 %d %d\n", get_xscroll(), get_yscroll());
00437 
00438 //              while(!done)
00439 //              {
00440                         w_visible = (int)(canvas_w / zoom_x);
00441                         h_visible = (int)(canvas_h / zoom_y);
00442 //                      done = 1;
00443 
00444 //                      if(w_needed > w_visible)
00445                         if(1)
00446                         {
00447                                 if(!need_xscroll)
00448                                 {
00449                                         need_xscroll = 1;
00450                                         canvas_h -= BC_ScrollBar::get_span(SCROLL_HORIZ);
00451 //                                      done = 0;
00452                                 }
00453                         }
00454                         else
00455                                 need_xscroll = 0;
00456 
00457 //                      if(h_needed > h_visible)
00458                         if(1)
00459                         {
00460                                 if(!need_yscroll)
00461                                 {
00462                                         need_yscroll = 1;
00463                                         canvas_w -= BC_ScrollBar::get_span(SCROLL_VERT);
00464 //                                      done = 0;
00465                                 }
00466                         }
00467                         else
00468                                 need_yscroll = 0;
00469 //              }
00470 //printf("Canvas::get_scrollbars %d %d %d %d %d %d\n", canvas_w, canvas_h, w_needed, h_needed, w_visible, h_visible);
00471 //printf("Canvas::get_scrollbars 3 %d %d\n", get_xscroll(), get_yscroll());
00472 
00473                 w_visible = (int)(canvas_w / zoom_x);
00474                 h_visible = (int)(canvas_h / zoom_y);
00475         }
00476 
00477         if(need_xscroll)
00478         {
00479                 if(!xscroll)
00480                         subwindow->add_subwindow(xscroll = new CanvasXScroll(edl, 
00481                                 this, 
00482                 canvas_x,
00483                 canvas_y + canvas_h,
00484                                 w_needed,
00485                                 get_xscroll(),
00486                                 w_visible,
00487                                 canvas_w));
00488                 else
00489                         xscroll->reposition_window(canvas_x, canvas_y + canvas_h, canvas_w);
00490 
00491                 if(xscroll->get_length() != w_needed ||
00492                         xscroll->get_handlelength() != w_visible)
00493                         xscroll->update_length(w_needed, get_xscroll(), w_visible);
00494         }
00495         else
00496         {
00497                 if(xscroll) delete xscroll;
00498                 xscroll = 0;
00499         }
00500 //printf("Canvas::get_scrollbars 4 %d %d\n", get_xscroll(), get_yscroll());
00501 
00502         if(need_yscroll)
00503         {
00504                 if(!yscroll)
00505                         subwindow->add_subwindow(yscroll = new CanvasYScroll(edl, 
00506                                 this,
00507                 canvas_x + canvas_w,
00508                 canvas_y,
00509                                 h_needed,
00510                                 get_yscroll(),
00511                                 h_visible,
00512                                 canvas_h));
00513                 else
00514                         yscroll->reposition_window(canvas_x + canvas_w, canvas_y, canvas_h);
00515 
00516                 if(yscroll->get_length() != edl->session->output_h ||
00517                         yscroll->get_handlelength() != h_visible)
00518                         yscroll->update_length(h_needed, get_yscroll(), h_visible);
00519         }
00520         else
00521         {
00522                 if(yscroll) delete yscroll;
00523                 yscroll = 0;
00524         }
00525 //printf("Canvas::get_scrollbars 5 %d %d\n", get_xscroll(), get_yscroll());
00526 }
00527 
00528 void Canvas::reposition_window(EDL *edl, int x, int y, int w, int h)
00529 {
00530         this->x = x;
00531         this->y = y;
00532         this->w = w;
00533         this->h = h;
00534         int view_x = x, view_y = y, view_w = w, view_h = h;
00535 //printf("Canvas::reposition_window 1\n");
00536         get_scrollbars(edl, view_x, view_y, view_w, view_h);
00537 //printf("Canvas::reposition_window %d %d %d %d\n", view_x, view_y, view_w, view_h);
00538         canvas->reposition_window(view_x, view_y, view_w, view_h);
00539 
00540 // Need to clear out the garbage in the back
00541         if(canvas->video_is_on())
00542         {
00543                 canvas->set_color(BLACK);
00544                 canvas->draw_box(0, 0, canvas->get_w(), canvas->get_h());
00545                 canvas->flash();
00546         }
00547 
00548         
00549 
00550         draw_refresh();
00551 //printf("Canvas::reposition_window 2\n");
00552 }
00553 
00554 void Canvas::set_cursor(int cursor)
00555 {
00556         canvas->set_cursor(cursor);
00557 }
00558 
00559 int Canvas::get_cursor_x()
00560 {
00561         return canvas->get_cursor_x();
00562 }
00563 
00564 int Canvas::get_cursor_y()
00565 {
00566         return canvas->get_cursor_y();
00567 }
00568 
00569 int Canvas::get_buttonpress()
00570 {
00571         return canvas->get_buttonpress();
00572 }
00573 
00574 
00575 int Canvas::create_objects(EDL *edl)
00576 {
00577         int view_x = x, view_y = y, view_w = w, view_h = h;
00578         get_scrollbars(edl, view_x, view_y, view_w, view_h);
00579 
00580         subwindow->add_subwindow(canvas = new CanvasOutput(edl, 
00581                 this, 
00582                 view_x, 
00583                 view_y, 
00584                 view_w, 
00585                 view_h));
00586 
00587         subwindow->add_subwindow(canvas_menu = new CanvasPopup(this));
00588         canvas_menu->create_objects();
00589 
00590         return 0;
00591 }
00592 
00593 int Canvas::button_press_event()
00594 {
00595         int result = 0;
00596 
00597         if(canvas->get_buttonpress() == 3)
00598         {
00599                 canvas_menu->activate_menu();
00600                 result = 1;
00601         }
00602 
00603         return result;
00604 }
00605 
00606 void Canvas::start_single()
00607 {
00608         is_processing = 1;
00609         status_event();
00610 }
00611 
00612 void Canvas::stop_single()
00613 {
00614         is_processing = 0;
00615         status_event();
00616 }
00617 
00618 void Canvas::start_video()
00619 {
00620         if(canvas)
00621         {
00622                 canvas->start_video();
00623                 status_event();
00624         }
00625 }
00626 
00627 void Canvas::stop_video()
00628 {
00629         if(canvas)
00630         {
00631                 canvas->stop_video();
00632                 status_event();
00633         }
00634 }
00635 
00636 
00637 
00638 
00639 
00640 
00641 
00642 
00643 
00644 
00645 
00646 
00647 
00648 
00649 
00650 
00651 
00652 
00653 
00654 CanvasOutput::CanvasOutput(EDL *edl, 
00655         Canvas *canvas,
00656     int x,
00657     int y,
00658     int w,
00659     int h)
00660  : BC_SubWindow(x, y, w, h, 0)
00661 {
00662         this->canvas = canvas;
00663         cursor_inside = 0;
00664 }
00665 
00666 CanvasOutput::~CanvasOutput()
00667 {
00668 }
00669 
00670 int CanvasOutput::handle_event()
00671 {
00672         return 1;
00673 }
00674 
00675 int CanvasOutput::cursor_leave_event()
00676 {
00677         int result = 0;
00678         if(cursor_inside) result = canvas->cursor_leave_event();
00679         cursor_inside = 0;
00680         return result;
00681 }
00682 
00683 int CanvasOutput::cursor_enter_event()
00684 {
00685         int result = 0;
00686         if(is_event_win() && BC_WindowBase::cursor_inside())
00687         {
00688                 cursor_inside = 1;
00689                 result = canvas->cursor_enter_event();
00690         }
00691         return result;
00692 }
00693 
00694 int CanvasOutput::button_press_event()
00695 {
00696         if(is_event_win() && BC_WindowBase::cursor_inside())
00697         {
00698                 return canvas->button_press_event();
00699         }
00700         return 0;
00701 }
00702 
00703 int CanvasOutput::button_release_event()
00704 {
00705         return canvas->button_release_event();
00706 }
00707 
00708 int CanvasOutput::cursor_motion_event()
00709 {
00710         return canvas->cursor_motion_event();
00711 }
00712 
00713 
00714 
00715 CanvasXScroll::CanvasXScroll(EDL *edl, 
00716         Canvas *canvas, 
00717     int x, 
00718     int y, 
00719         int length, 
00720         int position, 
00721         int handle_length,
00722     int pixels)
00723  : BC_ScrollBar(x, 
00724                 y, 
00725                 SCROLL_HORIZ, 
00726                 pixels, 
00727                 length, 
00728                 position, 
00729                 handle_length)
00730 {
00731         this->canvas = canvas;
00732 }
00733 
00734 CanvasXScroll::~CanvasXScroll()
00735 {
00736 }
00737 
00738 int CanvasXScroll::handle_event()
00739 {
00740 //printf("CanvasXScroll::handle_event %d %d %d\n", get_length(), get_value(), get_handlelength());
00741         canvas->update_zoom(get_value(), canvas->get_yscroll(), canvas->get_zoom());
00742         canvas->draw_refresh();
00743         return 1;
00744 }
00745 
00746 
00747 
00748 
00749 
00750 
00751 CanvasYScroll::CanvasYScroll(EDL *edl, 
00752         Canvas *canvas, 
00753     int x, 
00754     int y, 
00755         int length, 
00756         int position, 
00757         int handle_length,
00758     int pixels)
00759  : BC_ScrollBar(x, 
00760                 y, 
00761                 SCROLL_VERT, 
00762                 pixels, 
00763                 length, 
00764                 position, 
00765                 handle_length)
00766 {
00767         this->canvas = canvas;
00768 }
00769 
00770 CanvasYScroll::~CanvasYScroll()
00771 {
00772 }
00773 
00774 int CanvasYScroll::handle_event()
00775 {
00776 //printf("CanvasYScroll::handle_event %d %d\n", get_value(), get_length());
00777         canvas->update_zoom(canvas->get_xscroll(), get_value(), canvas->get_zoom());
00778         canvas->draw_refresh();
00779         return 1;
00780 }
00781 
00782 
00783 
00784 
00785 CanvasPopup::CanvasPopup(Canvas *canvas)
00786  : BC_PopupMenu(0, 
00787                 0, 
00788                 0, 
00789                 "", 
00790                 0)
00791 {
00792         this->canvas = canvas;
00793 }
00794 
00795 CanvasPopup::~CanvasPopup()
00796 {
00797 }
00798 
00799 void CanvasPopup::create_objects()
00800 {
00801         add_item(new CanvasPopupSize(canvas, _("Zoom 25%"), 0.25));
00802         add_item(new CanvasPopupSize(canvas, _("Zoom 33%"), 0.33));
00803         add_item(new CanvasPopupSize(canvas, _("Zoom 50%"), 0.5));
00804         add_item(new CanvasPopupSize(canvas, _("Zoom 75%"), 0.75));
00805         add_item(new CanvasPopupSize(canvas, _("Zoom 100%"), 1.0));
00806         add_item(new CanvasPopupSize(canvas, _("Zoom 150%"), 1.5));
00807         add_item(new CanvasPopupSize(canvas, _("Zoom 200%"), 2.0));
00808         add_item(new CanvasPopupSize(canvas, _("Zoom 300%"), 3.0));
00809         add_item(new CanvasPopupSize(canvas, _("Zoom 400%"), 4.0));
00810         if(canvas->use_cwindow)
00811         {
00812                 add_item(new CanvasPopupResetCamera(canvas));
00813                 add_item(new CanvasPopupResetProjector(canvas));
00814                 add_item(toggle_controls = new CanvasToggleControls(canvas));
00815         }
00816         if(canvas->use_rwindow)
00817         {
00818                 add_item(new CanvasPopupResetTranslation(canvas));
00819         }
00820         if(canvas->use_vwindow)
00821         {
00822                 add_item(new CanvasPopupRemoveSource(canvas));
00823         }
00824 }
00825 
00826 
00827 
00828 CanvasPopupSize::CanvasPopupSize(Canvas *canvas, char *text, float percentage)
00829  : BC_MenuItem(text)
00830 {
00831         this->canvas = canvas;
00832         this->percentage = percentage;
00833 }
00834 CanvasPopupSize::~CanvasPopupSize()
00835 {
00836 }
00837 int CanvasPopupSize::handle_event()
00838 {
00839         canvas->zoom_resize_window(percentage);
00840         return 1;
00841 }
00842 
00843 
00844 
00845 CanvasPopupResetCamera::CanvasPopupResetCamera(Canvas *canvas)
00846  : BC_MenuItem(_("Reset camera"))
00847 {
00848         this->canvas = canvas;
00849 }
00850 int CanvasPopupResetCamera::handle_event()
00851 {
00852         canvas->reset_camera();
00853         return 1;
00854 }
00855 
00856 
00857 
00858 CanvasPopupResetProjector::CanvasPopupResetProjector(Canvas *canvas)
00859  : BC_MenuItem(_("Reset projector"))
00860 {
00861         this->canvas = canvas;
00862 }
00863 int CanvasPopupResetProjector::handle_event()
00864 {
00865         canvas->reset_projector();
00866         return 1;
00867 }
00868 
00869 
00870 
00871 CanvasPopupResetTranslation::CanvasPopupResetTranslation(Canvas *canvas)
00872  : BC_MenuItem(_("Reset translation"))
00873 {
00874         this->canvas = canvas;
00875 }
00876 int CanvasPopupResetTranslation::handle_event()
00877 {
00878         canvas->reset_translation();
00879         return 1;
00880 }
00881 
00882 
00883 
00884 CanvasToggleControls::CanvasToggleControls(Canvas *canvas)
00885  : BC_MenuItem(calculate_text(canvas->get_cwindow_controls()))
00886 {
00887         this->canvas = canvas;
00888 }
00889 int CanvasToggleControls::handle_event()
00890 {
00891         canvas->toggle_controls();
00892         set_text(calculate_text(canvas->get_cwindow_controls()));
00893         return 1;
00894 }
00895 
00896 char* CanvasToggleControls::calculate_text(int cwindow_controls)
00897 {
00898         if(!cwindow_controls) 
00899                 return _("Show controls");
00900         else
00901                 return _("Hide controls");
00902 }
00903 
00904 
00905 
00906 
00907 CanvasPopupRemoveSource::CanvasPopupRemoveSource(Canvas *canvas)
00908  : BC_MenuItem(_("Close source"))
00909 {
00910         this->canvas = canvas;
00911 }
00912 int CanvasPopupRemoveSource::handle_event()
00913 {
00914         canvas->close_source();
00915         return 1;
00916 }
00917 
00918 

Generated on Sun Jan 8 13:38:51 2006 for Cinelerra-svn by  doxygen 1.4.4