r602: Fix baver's code... don't insert timecode when show_tc is not set
[cinelerra_cv/mob.git] / cinelerra / canvas.C
blob1afaa20f32bdc77c38da61d5e3a5e78d72af6f81
1 #include "canvas.h"
2 #include "clip.h"
3 #include "edl.h"
4 #include "edlsession.h"
5 #include "language.h"
6 #include "vframe.h"
10 Canvas::Canvas(BC_WindowBase *subwindow, 
11         int x, 
12         int y, 
13         int w, 
14         int h,
15         int output_w,
16         int output_h,
17         int use_scrollbars,
18         int use_cwindow,
19         int use_rwindow,
20         int use_vwindow)
22         reset();
23         this->subwindow = subwindow;
24         this->x = x;
25         this->y = y;
26         this->w = w;
27         this->h = h;
28         this->output_w = output_w;
29         this->output_h = output_h;
30         this->use_scrollbars = use_scrollbars;
31         this->use_cwindow = use_cwindow;
32         this->use_rwindow = use_rwindow;
33         this->use_vwindow = use_vwindow;
36 Canvas::~Canvas()
38         if(refresh_frame) delete refresh_frame;
39         delete canvas_menu;
40         if(yscroll) delete yscroll;
41         if(xscroll) delete xscroll;
42         delete canvas;
45 void Canvas::reset()
47         use_scrollbars = 0;
48         output_w = 0;
49         output_h = 0;
50     xscroll = 0;
51     yscroll = 0;
52         refresh_frame = 0;
53         canvas = 0;
54         is_processing = 0;
57 // Get dimensions given a zoom
58 void Canvas::calculate_sizes(float aspect_ratio, 
59         int output_w, 
60         int output_h, 
61         float zoom, 
62         int &w, 
63         int &h)
65 // Horizontal stretch
66         if((float)output_w / output_h <= aspect_ratio)
67         {
68                 w = (int)((float)output_h * aspect_ratio * zoom);
69                 h = (int)((float)output_h * zoom);
70         }
71         else
72 // Vertical stretch
73         {
74                 h = (int)((float)output_w / aspect_ratio * zoom);
75                 w = (int)((float)output_w * zoom);
76         }
79 float Canvas::get_x_offset(EDL *edl, 
80         int single_channel, 
81         float zoom_x, 
82         float conformed_w,
83         float conformed_h)
85         if(use_scrollbars)
86         {
87                 if(xscroll) 
88                 {
89 // If the projection is smaller than the canvas, this forces it in the center.
90 //                      if(conformed_w < w_visible)
91 //                              return -(float)(w_visible - conformed_w) / 2;
93                         return (float)get_xscroll();
94                 }
95                 else
96                         return ((float)-canvas->get_w() / zoom_x + 
97                                 edl->calculate_output_w(single_channel)) / 2;
98         }
99         else
100         {
101                 int out_w, out_h;
102                 int canvas_w = canvas->get_w();
103                 int canvas_h = canvas->get_h();
104                 out_w = canvas_w;
105                 out_h = canvas_h;
106                 
107                 if((float)out_w / out_h > conformed_w / conformed_h)
108                 {
109                         out_w = (int)(out_h * conformed_w / conformed_h + 0.5);
110                 }
111                 
112                 if(out_w < canvas_w)
113                         return -(canvas_w - out_w) / 2 / zoom_x;
114         }
116         return 0;
119 float Canvas::get_y_offset(EDL *edl, 
120         int single_channel, 
121         float zoom_y, 
122         float conformed_w,
123         float conformed_h)
125         if(use_scrollbars)
126         {
127                 if(yscroll)
128                 {
129 // If the projection is smaller than the canvas, this forces it in the center.
130 //                      if(conformed_h < h_visible)
131 //                              return -(float)(h_visible - conformed_h) / 2;
133                         return (float)get_yscroll();
134                 }
135                 else
136                         return ((float)-canvas->get_h() / zoom_y + 
137                                 edl->calculate_output_h(single_channel)) / 2;
138         }
139         else
140         {
141                 int out_w, out_h;
142                 int canvas_w = canvas->get_w();
143                 int canvas_h = canvas->get_h();
144                 out_w = canvas_w;
145                 out_h = canvas_h;
147                 if((float)out_w / out_h <= conformed_w / conformed_h)
148                 {
149                         out_h = (int)((float)out_w / (conformed_w / conformed_h) + 0.5);
150                 }
152 //printf("Canvas::get_y_offset 1 %d %d %f\n", out_h, canvas_h, -((float)canvas_h - out_h) / 2);
153                 if(out_h < canvas_h)
154                         return -((float)canvas_h - out_h) / 2 / zoom_y;
155         }
157         return 0;
160 // This may not be used anymore
161 void Canvas::check_boundaries(EDL *edl, int &x, int &y, float &zoom)
163         if(x + w_visible > w_needed) x = w_needed - w_visible;
164         if(y + h_visible > h_needed) y = h_needed - h_visible;
166         if(x < 0) x = 0;
167         if(y < 0) y = 0;
170 void Canvas::update_scrollbars()
172         if(use_scrollbars)
173         {
174                 if(xscroll) xscroll->update_length(w_needed, get_xscroll(), w_visible);
175                 if(yscroll) yscroll->update_length(h_needed, get_yscroll(), h_visible);
176         }
179 void Canvas::get_zooms(EDL *edl, 
180         int single_channel, 
181         float &zoom_x, 
182         float &zoom_y,
183         float &conformed_w,
184         float &conformed_h)
186         edl->calculate_conformed_dimensions(single_channel, 
187                 conformed_w, 
188                 conformed_h);
190         if(use_scrollbars)
191         {
192                 zoom_x = get_zoom() * 
193                         conformed_w / 
194                         edl->calculate_output_w(single_channel);
195                 zoom_y = get_zoom() * 
196                         conformed_h / 
197                         edl->calculate_output_h(single_channel);
198         }
199         else
200         {
201                 int out_w, out_h;
202                 int canvas_w = canvas->get_w();
203                 int canvas_h = canvas->get_h();
204         
205                 out_w = canvas_w;
206                 out_h = canvas_h;
208                 if((float)out_w / out_h > conformed_w / conformed_h)
209                 {
210                         out_w = (int)((float)out_h * conformed_w / conformed_h + 0.5);
211                 }
212                 else
213                 {
214                         out_h = (int)((float)out_w / (conformed_w / conformed_h) + 0.5);
215                 }
217                 zoom_x = (float)out_w / edl->calculate_output_w(single_channel);
218                 zoom_y = (float)out_h / edl->calculate_output_h(single_channel);
219 //printf("get zooms 2 %d %d %f %f\n", canvas_w, canvas_h, conformed_w, conformed_h);
220         }
223 // Convert a coordinate on the canvas to a coordinate on the output
224 void Canvas::canvas_to_output(EDL *edl, int single_channel, float &x, float &y)
226         float zoom_x, zoom_y, conformed_w, conformed_h;
227         get_zooms(edl, single_channel, zoom_x, zoom_y, conformed_w, conformed_h);
229 //printf("Canvas::canvas_to_output y=%f zoom_y=%f y_offset=%f\n", 
230 //      y, zoom_y, get_y_offset(edl, single_channel, zoom_y, conformed_w, conformed_h));
232         x = (float)x / zoom_x + get_x_offset(edl, single_channel, zoom_x, conformed_w, conformed_h);
233         y = (float)y / zoom_y + get_y_offset(edl, single_channel, zoom_y, conformed_w, conformed_h);
236 void Canvas::output_to_canvas(EDL *edl, int single_channel, float &x, float &y)
238         float zoom_x, zoom_y, conformed_w, conformed_h;
239         get_zooms(edl, single_channel, zoom_x, zoom_y, conformed_w, conformed_h);
241 //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));
243         x = (float)zoom_x * (x - get_x_offset(edl, single_channel, zoom_x, conformed_w, conformed_h));
244         y = (float)zoom_y * (y - get_y_offset(edl, single_channel, zoom_y, conformed_w, conformed_h));
249 void Canvas::get_transfers(EDL *edl, 
250         int &in_x, 
251         int &in_y, 
252         int &in_w, 
253         int &in_h,
254         int &out_x, 
255         int &out_y, 
256         int &out_w, 
257         int &out_h,
258         int canvas_w,
259         int canvas_h)
261 // printf("Canvas::get_transfers %d %d\n", canvas_w, 
262 //              canvas_h);
263         if(canvas_w < 0) canvas_w = canvas->get_w();
264         if(canvas_h < 0) canvas_h = canvas->get_h();
266         if(use_scrollbars)
267         {
268                 float in_x1, in_y1, in_x2, in_y2;
269                 float out_x1, out_y1, out_x2, out_y2;
270                 float zoom_x, zoom_y, conformed_w, conformed_h;
272                 get_zooms(edl, 0, zoom_x, zoom_y, conformed_w, conformed_h);
273                 out_x1 = 0;
274                 out_y1 = 0;
275                 out_x2 = canvas_w;
276                 out_y2 = canvas_h;
277                 in_x1 = 0;
278                 in_y1 = 0;
279                 in_x2 = canvas_w;
280                 in_y2 = canvas_h;
282                 canvas_to_output(edl, 0, in_x1, in_y1);
283                 canvas_to_output(edl, 0, in_x2, in_y2);
285 //printf("Canvas::get_transfers 1 %.0f %.0f %.0f %.0f -> %.0f %.0f %.0f %.0f\n",
286 //in_x1, in_y1, in_x2, in_y2, out_x1, out_y1, out_x2, out_y2);
288                 if(in_x1 < 0)
289                 {
290                         out_x1 += -in_x1 * zoom_x;
291                         in_x1 = 0;
292                 }
294                 if(in_y1 < 0)
295                 {
296                         out_y1 += -in_y1 * zoom_y;
297                         in_y1 = 0;
298                 }
300                 int output_w = get_output_w(edl);
301                 int output_h = get_output_h(edl);
303                 if(in_x2 > output_w)
304                 {
305                         out_x2 -= (in_x2 - output_w) * zoom_x;
306                         in_x2 = output_w;
307                 }
309                 if(in_y2 > output_h)
310                 {
311                         out_y2 -= (in_y2 - output_h) * zoom_y;
312                         in_y2 = output_h;
313                 }
314 // printf("Canvas::get_transfers 2 %.0f %.0f %.0f %.0f -> %.0f %.0f %.0f %.0f\n",
315 //                      in_x1, in_y1, in_x2, in_y2, out_x1, out_y1, out_x2, out_y2);
317                 in_x = (int)in_x1;
318                 in_y = (int)in_y1;
319                 in_w = (int)(in_x2 - in_x1);
320                 in_h = (int)(in_y2 - in_y1);
321                 out_x = (int)out_x1;
322                 out_y = (int)out_y1;
323                 out_w = (int)(out_x2 - out_x1);
324                 out_h = (int)(out_y2 - out_y1);
326 // Center on canvas
327 //              if(!scrollbars_exist())
328 //              {
329 //                      out_x = canvas_w / 2 - out_w / 2;
330 //                      out_y = canvas_h / 2 - out_h / 2;
331 //              }
333 // printf("Canvas::get_transfers 2 %d %d %d %d -> %d %d %d %d\n",in_x, 
334 //                      in_y, 
335 //                      in_w, 
336 //                      in_h,
337 //                      out_x, 
338 //                      out_y, 
339 //                      out_w, 
340 //                      out_h);
341         }
342         else
343         {
344                 out_x = 0;
345                 out_y = 0;
346                 out_w = canvas_w;
347                 out_h = canvas_h;
349                 if(edl)
350                 {
351                         if((float)out_w / out_h > edl->get_aspect_ratio())
352                         {
353                                 out_w = (int)(out_h * edl->get_aspect_ratio() + 0.5);
354                                 out_x = canvas_w / 2 - out_w / 2;
355                         }
356                         else
357                         {
358                                 out_h = (int)(out_w / edl->get_aspect_ratio() + 0.5);
359                                 out_y = canvas_h / 2 - out_h / 2;
360                         }
361                         in_x = 0;
362                         in_y = 0;
363                         in_w = get_output_w(edl);
364                         in_h = get_output_h(edl);
365                 }
366                 else
367                 {
368                         in_x = 0;
369                         in_y = 0;
370                         in_w = this->output_w;
371                         in_h = this->output_h;
372                 }
373         }
375         in_x = MAX(0, in_x);
376         in_y = MAX(0, in_y);
377         in_w = MAX(0, in_w);
378         in_h = MAX(0, in_h);
379         out_x = MAX(0, out_x);
380         out_y = MAX(0, out_y);
381         out_w = MAX(0, out_w);
382         out_h = MAX(0, out_h);
385 int Canvas::scrollbars_exist()
387         return(use_scrollbars && (xscroll || yscroll));
390 int Canvas::get_output_w(EDL *edl)
392         if(use_scrollbars)
393                 return edl->calculate_output_w(0);
394         else
395                 return edl->session->output_w;
398 int Canvas::get_output_h(EDL *edl)
400         if(edl)
401         {
402                 if(use_scrollbars)
403                         return edl->calculate_output_h(0);
404                 else
405                         return edl->session->output_h;
406         }
411 void Canvas::get_scrollbars(EDL *edl, 
412         int &canvas_x, 
413         int &canvas_y, 
414         int &canvas_w, 
415         int &canvas_h)
417         int need_xscroll = 0;
418         int need_yscroll = 0;
419 //      int done = 0;
420         float zoom_x, zoom_y, conformed_w, conformed_h;
422         if(edl)
423         {
424                 w_needed = edl->calculate_output_w(0);
425                 h_needed = edl->calculate_output_h(0);
426                 w_visible = w_needed;
427                 h_visible = h_needed;
428         }
429 //printf("Canvas::get_scrollbars 1 %d %d\n", get_xscroll(), get_yscroll());
431         if(use_scrollbars)
432         {
433                 w_needed = edl->calculate_output_w(0);
434                 h_needed = edl->calculate_output_h(0);
435                 get_zooms(edl, 0, zoom_x, zoom_y, conformed_w, conformed_h);
436 //printf("Canvas::get_scrollbars 2 %d %d\n", get_xscroll(), get_yscroll());
438 //              while(!done)
439 //              {
440                         w_visible = (int)(canvas_w / zoom_x);
441                         h_visible = (int)(canvas_h / zoom_y);
442 //                      done = 1;
444 //                      if(w_needed > w_visible)
445                         if(1)
446                         {
447                                 if(!need_xscroll)
448                                 {
449                                         need_xscroll = 1;
450                                         canvas_h -= BC_ScrollBar::get_span(SCROLL_HORIZ);
451 //                                      done = 0;
452                                 }
453                         }
454                         else
455                                 need_xscroll = 0;
457 //                      if(h_needed > h_visible)
458                         if(1)
459                         {
460                                 if(!need_yscroll)
461                                 {
462                                         need_yscroll = 1;
463                                         canvas_w -= BC_ScrollBar::get_span(SCROLL_VERT);
464 //                                      done = 0;
465                                 }
466                         }
467                         else
468                                 need_yscroll = 0;
469 //              }
470 //printf("Canvas::get_scrollbars %d %d %d %d %d %d\n", canvas_w, canvas_h, w_needed, h_needed, w_visible, h_visible);
471 //printf("Canvas::get_scrollbars 3 %d %d\n", get_xscroll(), get_yscroll());
473                 w_visible = (int)(canvas_w / zoom_x);
474                 h_visible = (int)(canvas_h / zoom_y);
475         }
477         if(need_xscroll)
478         {
479                 if(!xscroll)
480                         subwindow->add_subwindow(xscroll = new CanvasXScroll(edl, 
481                                 this, 
482                 canvas_x,
483                 canvas_y + canvas_h,
484                                 w_needed,
485                                 get_xscroll(),
486                                 w_visible,
487                                 canvas_w));
488                 else
489                         xscroll->reposition_window(canvas_x, canvas_y + canvas_h, canvas_w);
491                 if(xscroll->get_length() != w_needed ||
492                         xscroll->get_handlelength() != w_visible)
493                         xscroll->update_length(w_needed, get_xscroll(), w_visible);
494         }
495         else
496         {
497                 if(xscroll) delete xscroll;
498                 xscroll = 0;
499         }
500 //printf("Canvas::get_scrollbars 4 %d %d\n", get_xscroll(), get_yscroll());
502         if(need_yscroll)
503         {
504                 if(!yscroll)
505                         subwindow->add_subwindow(yscroll = new CanvasYScroll(edl, 
506                                 this,
507                 canvas_x + canvas_w,
508                 canvas_y,
509                                 h_needed,
510                                 get_yscroll(),
511                                 h_visible,
512                                 canvas_h));
513                 else
514                         yscroll->reposition_window(canvas_x + canvas_w, canvas_y, canvas_h);
516                 if(yscroll->get_length() != edl->calculate_output_h(0) ||
517                         yscroll->get_handlelength() != h_visible)
518                         yscroll->update_length(h_needed, get_yscroll(), h_visible);
519         }
520         else
521         {
522                 if(yscroll) delete yscroll;
523                 yscroll = 0;
524         }
525 //printf("Canvas::get_scrollbars 5 %d %d\n", get_xscroll(), get_yscroll());
528 void Canvas::reposition_window(EDL *edl, int x, int y, int w, int h)
530         this->x = x;
531         this->y = y;
532         this->w = w;
533         this->h = h;
534         int view_x = x, view_y = y, view_w = w, view_h = h;
535 //printf("Canvas::reposition_window 1\n");
536         get_scrollbars(edl, view_x, view_y, view_w, view_h);
537 //printf("Canvas::reposition_window %d %d %d %d\n", view_x, view_y, view_w, view_h);
538         canvas->reposition_window(view_x, view_y, view_w, view_h);
540 // Need to clear out the garbage in the back
541         if(canvas->video_is_on())
542         {
543                 canvas->set_color(BLACK);
544                 canvas->draw_box(0, 0, canvas->get_w(), canvas->get_h());
545                 canvas->flash();
546         }
548         
550         draw_refresh();
551 //printf("Canvas::reposition_window 2\n");
554 void Canvas::set_cursor(int cursor)
556         canvas->set_cursor(cursor);
559 int Canvas::get_cursor_x()
561         return canvas->get_cursor_x();
564 int Canvas::get_cursor_y()
566         return canvas->get_cursor_y();
569 int Canvas::get_buttonpress()
571         return canvas->get_buttonpress();
575 int Canvas::create_objects(EDL *edl)
577         int view_x = x, view_y = y, view_w = w, view_h = h;
578         get_scrollbars(edl, view_x, view_y, view_w, view_h);
580         subwindow->add_subwindow(canvas = new CanvasOutput(edl, 
581                 this, 
582                 view_x, 
583                 view_y, 
584                 view_w, 
585                 view_h));
587         subwindow->add_subwindow(canvas_menu = new CanvasPopup(this));
588         canvas_menu->create_objects();
590         return 0;
593 int Canvas::button_press_event()
595         int result = 0;
597         if(canvas->get_buttonpress() == 3)
598         {
599                 canvas_menu->activate_menu();
600                 result = 1;
601         }
603         return result;
606 void Canvas::start_single()
608         is_processing = 1;
609         status_event();
612 void Canvas::stop_single()
614         is_processing = 0;
615         status_event();
618 void Canvas::start_video()
620         if(canvas)
621         {
622                 canvas->start_video();
623                 status_event();
624         }
627 void Canvas::stop_video()
629         if(canvas)
630         {
631                 canvas->stop_video();
632                 status_event();
633         }
654 CanvasOutput::CanvasOutput(EDL *edl, 
655         Canvas *canvas,
656     int x,
657     int y,
658     int w,
659     int h)
660  : BC_SubWindow(x, y, w, h, 0)
662         this->canvas = canvas;
663         cursor_inside = 0;
666 CanvasOutput::~CanvasOutput()
670 int CanvasOutput::handle_event()
672         return 1;
675 int CanvasOutput::cursor_leave_event()
677         int result = 0;
678         if(cursor_inside) result = canvas->cursor_leave_event();
679         cursor_inside = 0;
680         return result;
683 int CanvasOutput::cursor_enter_event()
685         int result = 0;
686         if(is_event_win() && BC_WindowBase::cursor_inside())
687         {
688                 cursor_inside = 1;
689                 result = canvas->cursor_enter_event();
690         }
691         return result;
694 int CanvasOutput::button_press_event()
696         if(is_event_win() && BC_WindowBase::cursor_inside())
697         {
698                 return canvas->button_press_event();
699         }
700         return 0;
703 int CanvasOutput::button_release_event()
705         return canvas->button_release_event();
708 int CanvasOutput::cursor_motion_event()
710         return canvas->cursor_motion_event();
715 CanvasXScroll::CanvasXScroll(EDL *edl, 
716         Canvas *canvas, 
717     int x, 
718     int y, 
719         int length, 
720         int position, 
721         int handle_length,
722     int pixels)
723  : BC_ScrollBar(x, 
724                 y, 
725                 SCROLL_HORIZ, 
726                 pixels, 
727                 length, 
728                 position, 
729                 handle_length)
731         this->canvas = canvas;
734 CanvasXScroll::~CanvasXScroll()
738 int CanvasXScroll::handle_event()
740 //printf("CanvasXScroll::handle_event %d %d %d\n", get_length(), get_value(), get_handlelength());
741         canvas->update_zoom(get_value(), canvas->get_yscroll(), canvas->get_zoom());
742         canvas->draw_refresh();
743         return 1;
751 CanvasYScroll::CanvasYScroll(EDL *edl, 
752         Canvas *canvas, 
753     int x, 
754     int y, 
755         int length, 
756         int position, 
757         int handle_length,
758     int pixels)
759  : BC_ScrollBar(x, 
760                 y, 
761                 SCROLL_VERT, 
762                 pixels, 
763                 length, 
764                 position, 
765                 handle_length)
767         this->canvas = canvas;
770 CanvasYScroll::~CanvasYScroll()
774 int CanvasYScroll::handle_event()
776 //printf("CanvasYScroll::handle_event %d %d\n", get_value(), get_length());
777         canvas->update_zoom(canvas->get_xscroll(), get_value(), canvas->get_zoom());
778         canvas->draw_refresh();
779         return 1;
785 CanvasPopup::CanvasPopup(Canvas *canvas)
786  : BC_PopupMenu(0, 
787                 0, 
788                 0, 
789                 "", 
790                 0)
792         this->canvas = canvas;
795 CanvasPopup::~CanvasPopup()
799 void CanvasPopup::create_objects()
801         add_item(new CanvasPopupSize(canvas, _("Zoom 25%"), 0.25));
802         add_item(new CanvasPopupSize(canvas, _("Zoom 50%"), 0.5));
803         add_item(new CanvasPopupSize(canvas, _("Zoom 100%"), 1.0));
804         add_item(new CanvasPopupSize(canvas, _("Zoom 200%"), 2.0));
805         if(canvas->use_cwindow)
806         {
807                 add_item(new CanvasPopupResetCamera(canvas));
808                 add_item(new CanvasPopupResetProjector(canvas));
809                 add_item(toggle_controls = new CanvasToggleControls(canvas));
810         }
811         if(canvas->use_rwindow)
812         {
813                 add_item(new CanvasPopupResetTranslation(canvas));
814         }
815         if(canvas->use_vwindow)
816         {
817                 add_item(new CanvasPopupRemoveSource(canvas));
818         }
823 CanvasPopupSize::CanvasPopupSize(Canvas *canvas, char *text, float percentage)
824  : BC_MenuItem(text)
826         this->canvas = canvas;
827         this->percentage = percentage;
829 CanvasPopupSize::~CanvasPopupSize()
832 int CanvasPopupSize::handle_event()
834         canvas->zoom_resize_window(percentage);
835         return 1;
840 CanvasPopupResetCamera::CanvasPopupResetCamera(Canvas *canvas)
841  : BC_MenuItem(_("Reset camera"))
843         this->canvas = canvas;
845 int CanvasPopupResetCamera::handle_event()
847         canvas->reset_camera();
848         return 1;
853 CanvasPopupResetProjector::CanvasPopupResetProjector(Canvas *canvas)
854  : BC_MenuItem(_("Reset projector"))
856         this->canvas = canvas;
858 int CanvasPopupResetProjector::handle_event()
860         canvas->reset_projector();
861         return 1;
866 CanvasPopupResetTranslation::CanvasPopupResetTranslation(Canvas *canvas)
867  : BC_MenuItem(_("Reset translation"))
869         this->canvas = canvas;
871 int CanvasPopupResetTranslation::handle_event()
873         canvas->reset_translation();
874         return 1;
879 CanvasToggleControls::CanvasToggleControls(Canvas *canvas)
880  : BC_MenuItem(calculate_text(canvas->get_cwindow_controls()))
882         this->canvas = canvas;
884 int CanvasToggleControls::handle_event()
886         canvas->toggle_controls();
887         set_text(calculate_text(canvas->get_cwindow_controls()));
888         return 1;
891 char* CanvasToggleControls::calculate_text(int cwindow_controls)
893         if(!cwindow_controls) 
894                 return _("Show controls");
895         else
896                 return _("Hide controls");
902 CanvasPopupRemoveSource::CanvasPopupRemoveSource(Canvas *canvas)
903  : BC_MenuItem(_("Close source"))
905         this->canvas = canvas;
907 int CanvasPopupRemoveSource::handle_event()
909         canvas->close_source();
910         return 1;