update internationalization data
[goodguy/history.git] / cinelerra-5.0 / cinelerra / vwindowgui.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 1997-2011 Adam Williams <broadcast at earthling dot net>
5  * 
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.
10  * 
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.
15  * 
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
19  * 
20  */
21
22 #include "asset.h"
23 #include "assets.h"
24 #include "awindowgui.h"
25 #include "awindow.h"
26 #include "canvas.h"
27 #include "clip.h"
28 #include "clipedit.h"
29 #include "edl.h"
30 #include "edlsession.h"
31 #include "filesystem.h"
32 #include "filexml.h"
33 #include "fonts.h"
34 #include "keys.h"
35 #include "labels.h"
36 #include "language.h"
37 #include "localsession.h"
38 #include "mainclock.h"
39 #include "mainmenu.h"
40 #include "mainsession.h"
41 #include "mainundo.h"
42 #include "meterpanel.h"
43 #include "mwindowgui.h"
44 #include "mwindow.h"
45 #include "playtransport.h"
46 #include "preferences.h"
47 #include "theme.h"
48 #include "timebar.h"
49 #include "tracks.h"
50 #include "vframe.h"
51 #include "vplayback.h"
52 #include "vtimebar.h"
53 #include "vwindowgui.h"
54 #include "vwindow.h"
55
56
57
58
59 VWindowGUI::VWindowGUI(MWindow *mwindow, VWindow *vwindow)
60  : BC_Window(_(PROGRAM_NAME ": Viewer"),
61         mwindow->session->vwindow_x,
62         mwindow->session->vwindow_y,
63         mwindow->session->vwindow_w,
64         mwindow->session->vwindow_h,
65         100,
66         100,
67         1,
68         1,
69         0) // Hide it
70 {
71         this->mwindow = mwindow;
72         this->vwindow = vwindow;
73         canvas = 0;
74         transport = 0;
75         edit_panel = 0;
76         meters = 0;
77 //      source = 0;
78 }
79
80 VWindowGUI::~VWindowGUI()
81 {
82         vwindow->playback_engine->interrupt_playback(1);
83         sources.remove_all_objects();
84         labels.remove_all_objects();
85         delete canvas;
86         delete transport;
87         delete edit_panel;
88         delete meters;
89 //      delete source;
90 }
91
92 void VWindowGUI::change_source(EDL *edl, const char *title)
93 {
94 //printf("VWindowGUI::change_source %d\n", __LINE__);
95
96         update_sources(title);
97         char string[BCTEXTLEN];
98
99         if(title[0]) 
100                 sprintf(string, _(PROGRAM_NAME ": %s"), title);
101         else
102                 sprintf(string, _(PROGRAM_NAME ": Viewer"));
103
104         lock_window("VWindowGUI::change_source");
105         timebar->update(0);
106         set_title(string);
107         unlock_window();
108 }
109
110
111 // Get source list from master EDL
112 void VWindowGUI::update_sources(const char *title)
113 {
114         lock_window("VWindowGUI::update_sources");
115
116 //printf("VWindowGUI::update_sources 1\n");
117         sources.remove_all_objects();
118 //printf("VWindowGUI::update_sources 2\n");
119
120
121
122         for(int i = 0;
123                 i < mwindow->edl->clips.total;
124                 i++)
125         {
126                 char *clip_title = mwindow->edl->clips.values[i]->local_session->clip_title;
127                 int exists = 0;
128
129                 for(int j = 0; j < sources.total; j++)
130                 {
131                         if(!strcasecmp(sources.values[j]->get_text(), clip_title))
132                         {
133                                 exists = 1;
134                         }
135                 }
136
137                 if(!exists)
138                 {
139                         sources.append(new BC_ListBoxItem(clip_title));
140                 }
141         }
142 //printf("VWindowGUI::update_sources 3\n");
143
144         FileSystem fs;
145         for(Asset *current = mwindow->edl->assets->first; 
146                 current;
147                 current = NEXT)
148         {
149                 char clip_title[BCTEXTLEN];
150                 fs.extract_name(clip_title, current->path);
151                 int exists = 0;
152                 
153                 for(int j = 0; j < sources.total; j++)
154                 {
155                         if(!strcasecmp(sources.values[j]->get_text(), clip_title))
156                         {
157                                 exists = 1;
158                         }
159                 }
160                 
161                 if(!exists)
162                 {
163                         sources.append(new BC_ListBoxItem(clip_title));
164                 }
165         }
166
167 //printf("VWindowGUI::update_sources 4\n");
168
169 //      source->update_list(&sources);
170 //      source->update(title);
171         unlock_window();
172 }
173
174 void VWindowGUI::create_objects()
175 {
176         in_point = 0;
177         out_point = 0;
178         lock_window("VWindowGUI::create_objects");
179         set_icon(mwindow->theme->get_image("vwindow_icon"));
180
181 //printf("VWindowGUI::create_objects 1\n");
182         mwindow->theme->get_vwindow_sizes(this);
183         mwindow->theme->draw_vwindow_bg(this);
184         flash(0);
185
186         meters = new VWindowMeters(mwindow, 
187                 this,
188                 mwindow->theme->vmeter_x,
189                 mwindow->theme->vmeter_y,
190                 mwindow->theme->vmeter_h);
191         meters->create_objects();
192
193 //printf("VWindowGUI::create_objects 1\n");
194 // Requires meters to build
195         edit_panel = new VWindowEditing(mwindow, vwindow);
196         edit_panel->set_meters(meters);
197         edit_panel->create_objects();
198
199 //printf("VWindowGUI::create_objects 1\n");
200         transport = new VWindowTransport(mwindow, 
201                 this, 
202                 mwindow->theme->vtransport_x, 
203                 mwindow->theme->vtransport_y);
204         transport->create_objects();
205
206 //printf("VWindowGUI::create_objects 1\n");
207 //      add_subwindow(fps_title = new BC_Title(mwindow->theme->vedit_x, y, ""));
208     add_subwindow(clock = new MainClock(mwindow,
209                 mwindow->theme->vtime_x, 
210                 mwindow->theme->vtime_y,
211                 mwindow->theme->vtime_w));
212
213         canvas = new VWindowCanvas(mwindow, this);
214         canvas->create_objects(mwindow->edl);
215         canvas->use_vwindow();
216
217
218 //printf("VWindowGUI::create_objects 1\n");
219         add_subwindow(timebar = new VTimeBar(mwindow, 
220                 this,
221                 mwindow->theme->vtimebar_x,
222                 mwindow->theme->vtimebar_y,
223                 mwindow->theme->vtimebar_w, 
224                 mwindow->theme->vtimebar_h));
225         timebar->create_objects();
226 //printf("VWindowGUI::create_objects 2\n");
227
228
229 //printf("VWindowGUI::create_objects 1\n");
230 //      source = new VWindowSource(mwindow, 
231 //              this, 
232 //              mwindow->theme->vsource_x,
233 //              mwindow->theme->vsource_y);
234 //      source->create_objects();       
235         update_sources(_("None"));
236
237 //printf("VWindowGUI::create_objects 2\n");
238         deactivate();
239
240         show_window();
241         unlock_window();
242 }
243
244 int VWindowGUI::resize_event(int w, int h)
245 {
246         mwindow->session->vwindow_x = get_x();
247         mwindow->session->vwindow_y = get_y();
248         mwindow->session->vwindow_w = w;
249         mwindow->session->vwindow_h = h;
250
251         mwindow->theme->get_vwindow_sizes(this);
252         mwindow->theme->draw_vwindow_bg(this);
253         flash(0);
254
255 //printf("VWindowGUI::resize_event %d %d\n", __LINE__, mwindow->theme->vedit_y);
256         edit_panel->reposition_buttons(mwindow->theme->vedit_x, 
257                 mwindow->theme->vedit_y);
258
259         timebar->resize_event();
260         transport->reposition_buttons(mwindow->theme->vtransport_x, 
261                 mwindow->theme->vtransport_y);
262         clock->reposition_window(mwindow->theme->vtime_x, 
263                 mwindow->theme->vtime_y,
264                 mwindow->theme->vtime_w,
265                 clock->get_h());
266         canvas->reposition_window(0,
267                 mwindow->theme->vcanvas_x, 
268                 mwindow->theme->vcanvas_y, 
269                 mwindow->theme->vcanvas_w, 
270                 mwindow->theme->vcanvas_h);
271 //printf("VWindowGUI::resize_event %d %d\n", __LINE__, mwindow->theme->vcanvas_x);
272 //      source->reposition_window(mwindow->theme->vsource_x,
273 //              mwindow->theme->vsource_y);
274         meters->reposition_window(mwindow->theme->vmeter_x,
275                 mwindow->theme->vmeter_y,
276                 -1,
277                 mwindow->theme->vmeter_h);
278
279         BC_WindowBase::resize_event(w, h);
280         return 1;
281 }
282
283
284
285
286
287 int VWindowGUI::translation_event()
288 {
289         mwindow->session->vwindow_x = get_x();
290         mwindow->session->vwindow_y = get_y();
291         return 0;
292 }
293
294 int VWindowGUI::close_event()
295 {
296         hide_window();
297         int i = mwindow->vwindows.size();
298         while( --i >= 0 && mwindow->vwindows.get(i)->gui != this );
299         if( i > 0 ) {
300                 set_done(0);
301                 return 1; 
302         }
303
304         mwindow->session->show_vwindow = 0;
305         unlock_window();
306
307         mwindow->gui->lock_window("VWindowGUI::close_event");
308         mwindow->gui->mainmenu->show_vwindow->set_checked(0);
309         mwindow->gui->unlock_window();
310
311         lock_window("VWindowGUI::close_event");
312         mwindow->save_defaults();
313         return 1;
314 }
315
316 int VWindowGUI::keypress_event()
317 {
318         int result = 0;
319         switch(get_keypress())
320         {
321                 case 'w':
322                 case 'W':
323                         close_event();
324                         result = 1;
325                         break;
326                 case 'z':
327                         mwindow->undo_entry(this);
328                         break;
329                 case 'Z':
330                         mwindow->redo_entry(this);
331                         break;
332                 case 'f':
333                         unlock_window();
334                         if(mwindow->session->vwindow_fullscreen)
335                                 canvas->stop_fullscreen();
336                         else
337                                 canvas->start_fullscreen();
338                         lock_window("VWindowGUI::keypress_event 1");
339                         break;
340                 case ESC:
341                         unlock_window();
342                         if(mwindow->session->vwindow_fullscreen)
343                                 canvas->stop_fullscreen();
344                         lock_window("VWindowGUI::keypress_event 2");
345                         break;
346         }
347         if(!result) result = transport->keypress_event();
348         
349         return result;
350 }
351
352 int VWindowGUI::button_press_event()
353 {
354         if(canvas->get_canvas())
355                 return canvas->button_press_event_base(canvas->get_canvas());
356         return 0;
357 }
358
359 int VWindowGUI::cursor_leave_event()
360 {
361         if(canvas->get_canvas())
362                 return canvas->cursor_leave_event_base(canvas->get_canvas());
363         return 0;
364 }
365
366 int VWindowGUI::cursor_enter_event()
367 {
368         if(canvas->get_canvas())
369                 return canvas->cursor_enter_event_base(canvas->get_canvas());
370         return 0;
371 }
372
373 int VWindowGUI::button_release_event()
374 {
375         if(canvas->get_canvas())
376                 return canvas->button_release_event();
377         return 0;
378 }
379
380 int VWindowGUI::cursor_motion_event()
381 {
382         if(canvas->get_canvas())
383         {
384                 canvas->get_canvas()->unhide_cursor();
385                 return canvas->cursor_motion_event();
386         }
387         return 0;
388 }
389
390
391 void VWindowGUI::drag_motion()
392 {
393 // Window hidden
394         if(get_hidden()) return;
395         if(mwindow->session->current_operation != DRAG_ASSET) return;
396
397         int old_status = mwindow->session->vcanvas_highlighted;
398
399         int cursor_x = get_relative_cursor_x();
400         int cursor_y = get_relative_cursor_y();
401         
402         mwindow->session->vcanvas_highlighted = (get_cursor_over_window() &&
403                 cursor_x >= canvas->x &&
404                 cursor_x < canvas->x + canvas->w &&
405                 cursor_y >= canvas->y &&
406                 cursor_y < canvas->y + canvas->h);
407
408
409 //printf("VWindowGUI::drag_motion 1 %d %d %d %d %d\n", __LINE__, 
410 // mwindow->session->vcanvas_highlighted, get_cursor_over_window(), cursor_x, cursor_y);
411
412         if(old_status != mwindow->session->vcanvas_highlighted)
413                 canvas->draw_refresh();
414 }
415
416 int VWindowGUI::drag_stop()
417 {
418         if(get_hidden()) return 0;
419
420         if(mwindow->session->vcanvas_highlighted &&
421                 mwindow->session->current_operation == DRAG_ASSET)
422         {
423                 mwindow->session->vcanvas_highlighted = 0;
424                 canvas->draw_refresh();
425
426                 Indexable *indexable = mwindow->session->drag_assets->size() ?
427                         mwindow->session->drag_assets->get(0) :
428                         0;
429                 EDL *edl = mwindow->session->drag_clips->size() ?
430                         mwindow->session->drag_clips->get(0) :
431                         0;
432                 
433                 if(indexable)
434                         vwindow->change_source(indexable);
435                 else
436                 if(edl)
437                         vwindow->change_source(edl);
438                 return 1;
439         }
440
441         return 0;
442 }
443
444
445 void VWindowGUI::update_meters()
446 {
447         if(mwindow->edl->session->vwindow_meter != meters->visible)
448         {
449                 meters->set_meters(meters->meter_count, 
450                         mwindow->edl->session->vwindow_meter);
451                 mwindow->theme->get_vwindow_sizes(this);
452                 resize_event(get_w(), get_h());
453         }
454 }
455
456
457
458 VWindowMeters::VWindowMeters(MWindow *mwindow, 
459         VWindowGUI *gui, 
460         int x, 
461         int y, 
462         int h)
463  : MeterPanel(mwindow, 
464                 gui,
465                 x,
466                 y,
467                 -1,
468                 h,
469                 mwindow->edl->session->audio_channels,
470                 mwindow->edl->session->vwindow_meter,
471                 0,
472                 0)
473 {
474         this->mwindow = mwindow;
475         this->gui = gui;
476 }
477
478 VWindowMeters::~VWindowMeters()
479 {
480 }
481
482 int VWindowMeters::change_status_event(int new_status)
483 {
484         mwindow->edl->session->vwindow_meter = new_status;
485         gui->update_meters();
486         return 1;
487 }
488
489
490
491
492
493
494
495 VWindowEditing::VWindowEditing(MWindow *mwindow, VWindow *vwindow)
496  : EditPanel(mwindow, 
497                 vwindow->gui, 
498                 mwindow->theme->vedit_x, 
499                 mwindow->theme->vedit_y,
500                 EDITING_ARROW, 
501                 0,
502                 0,
503                 1, 
504                 1,
505                 0,
506                 0,
507                 1, 
508                 0,
509                 0,
510                 0,
511                 1,
512                 1,
513                 1,
514                 0,
515                 0,
516                 0)
517 {
518         this->mwindow = mwindow;
519         this->vwindow = vwindow;
520 }
521
522 VWindowEditing::~VWindowEditing()
523 {
524 }
525
526 void VWindowEditing::copy_selection()
527 {
528         vwindow->copy();
529 }
530
531 void VWindowEditing::splice_selection()
532 {
533         if(vwindow->get_edl())
534         {
535                 mwindow->gui->lock_window("VWindowEditing::splice_selection");
536                 mwindow->splice(vwindow->get_edl());
537                 mwindow->gui->unlock_window();
538         }
539 }
540
541 void VWindowEditing::overwrite_selection()
542 {
543         if(vwindow->get_edl())
544         {
545                 mwindow->gui->lock_window("VWindowEditing::overwrite_selection");
546                 mwindow->overwrite(vwindow->get_edl());
547                 mwindow->gui->unlock_window();
548         }
549 }
550
551 void VWindowEditing::toggle_label()
552 {
553         if(vwindow->get_edl())
554         {
555                 EDL *edl = vwindow->get_edl();
556                 edl->labels->toggle_label(edl->local_session->get_selectionstart(1),
557                         edl->local_session->get_selectionend(1));
558                 vwindow->gui->timebar->update(1);
559         }
560 }
561
562 void VWindowEditing::prev_label()
563 {
564         if(vwindow->get_edl())
565         {
566                 EDL *edl = vwindow->get_edl();
567                 vwindow->gui->unlock_window();
568                 vwindow->playback_engine->interrupt_playback(1);
569                 vwindow->gui->lock_window("VWindowEditing::prev_label");
570
571                 Label *current = edl->labels->prev_label(
572                         edl->local_session->get_selectionstart(1));
573                 
574
575                 if(!current)
576                 {
577                         edl->local_session->set_selectionstart(0);
578                         edl->local_session->set_selectionend(0);
579                         vwindow->update_position(CHANGE_NONE, 0, 1, 0);
580                         vwindow->gui->timebar->update(1);
581                 }
582                 else
583                 {
584                         edl->local_session->set_selectionstart(current->position);
585                         edl->local_session->set_selectionend(current->position);
586                         vwindow->update_position(CHANGE_NONE, 0, 1, 0);
587                         vwindow->gui->timebar->update(1);
588                 }
589         }
590 }
591
592 void VWindowEditing::next_label()
593 {
594         if(vwindow->get_edl())
595         {
596                 EDL *edl = vwindow->get_edl();
597                 Label *current = edl->labels->next_label(
598                         edl->local_session->get_selectionstart(1));
599                 if(!current)
600                 {
601                         vwindow->gui->unlock_window();
602                         vwindow->playback_engine->interrupt_playback(1);
603                         vwindow->gui->lock_window("VWindowEditing::next_label 1");
604
605                         double position = edl->tracks->total_length();
606                         edl->local_session->set_selectionstart(position);
607                         edl->local_session->set_selectionend(position);
608                         vwindow->update_position(CHANGE_NONE, 0, 1, 0);
609                         vwindow->gui->timebar->update(1);
610                 }
611                 else
612                 {
613                         vwindow->gui->unlock_window();
614                         vwindow->playback_engine->interrupt_playback(1);
615                         vwindow->gui->lock_window("VWindowEditing::next_label 2");
616
617                         edl->local_session->set_selectionstart(current->position);
618                         edl->local_session->set_selectionend(current->position);
619                         vwindow->update_position(CHANGE_NONE, 0, 1, 0);
620                         vwindow->gui->timebar->update(1);
621                 }
622         }
623 }
624
625 void VWindowEditing::set_inpoint()
626 {
627         vwindow->set_inpoint();
628 }
629
630 void VWindowEditing::set_outpoint()
631 {
632         vwindow->set_outpoint();
633 }
634
635 void VWindowEditing::clear_inpoint()
636 {
637         vwindow->clear_inpoint();
638 }
639
640 void VWindowEditing::clear_outpoint()
641 {
642         vwindow->clear_outpoint();
643 }
644
645 void VWindowEditing::to_clip()
646 {
647         if(vwindow->get_edl())
648         {
649                 FileXML file;
650                 EDL *edl = vwindow->get_edl();
651                 double start = edl->local_session->get_selectionstart();
652                 double end = edl->local_session->get_selectionend();
653
654                 if(EQUIV(start, end))
655                 {
656                         end = edl->tracks->total_length();
657                         start = 0;
658                 }
659
660
661
662                 edl->copy(start, 
663                         end, 
664                         1,
665                         0,
666                         0,
667                         &file,
668                         "",
669                         1);
670
671
672
673
674                 EDL *new_edl = new EDL(mwindow->edl);
675                 new_edl->create_objects();
676                 new_edl->load_xml(&file, LOAD_ALL);
677                 sprintf(new_edl->local_session->clip_title, _("Clip %d"), mwindow->session->clip_number++);
678                 new_edl->local_session->set_selectionstart(0);
679                 new_edl->local_session->set_selectionend(0);
680
681
682 //printf("VWindowEditing::to_clip 1 %s\n", edl->local_session->clip_title);
683
684                 vwindow->clip_edit->create_clip(new_edl);
685         }
686 }
687
688
689
690
691
692
693
694 VWindowSource::VWindowSource(MWindow *mwindow, VWindowGUI *vwindow, int x, int y)
695  : BC_PopupTextBox(vwindow, 
696         &vwindow->sources, 
697         "",
698         x, 
699         y, 
700         200, 
701         200)
702 {
703         this->mwindow = mwindow;
704         this->vwindow = vwindow;
705 }
706
707 VWindowSource::~VWindowSource()
708 {
709 }
710
711 int VWindowSource::handle_event()
712 {
713         return 1;
714 }
715
716
717
718
719
720
721
722 VWindowTransport::VWindowTransport(MWindow *mwindow, 
723         VWindowGUI *gui, 
724         int x, 
725         int y)
726  : PlayTransport(mwindow, 
727         gui, 
728         x, 
729         y)
730 {
731         this->gui = gui;
732 }
733
734 EDL* VWindowTransport::get_edl()
735 {
736         return gui->vwindow->get_edl();
737 }
738
739
740 void VWindowTransport::goto_start()
741 {
742         gui->unlock_window();
743         handle_transport(REWIND, 1);
744         gui->lock_window("VWindowTransport::goto_start");
745         gui->vwindow->goto_start();
746 }
747
748 void VWindowTransport::goto_end()
749 {
750         gui->unlock_window();
751         handle_transport(GOTO_END, 1);
752         gui->lock_window("VWindowTransport::goto_end");
753         gui->vwindow->goto_end();
754 }
755
756
757
758
759 VWindowCanvas::VWindowCanvas(MWindow *mwindow, VWindowGUI *gui)
760  : Canvas(mwindow,
761         gui,
762         mwindow->theme->vcanvas_x, 
763         mwindow->theme->vcanvas_y, 
764         mwindow->theme->vcanvas_w, 
765         mwindow->theme->vcanvas_h,
766         0, 0, 0)
767 {
768 //printf("VWindowCanvas::VWindowCanvas %d %d\n", __LINE__, mwindow->theme->vcanvas_x);
769         this->mwindow = mwindow;
770         this->gui = gui;
771 }
772
773 void VWindowCanvas::zoom_resize_window(float percentage)
774 {
775         EDL *edl = gui->vwindow->get_edl();
776         if(!edl) edl = mwindow->edl;
777
778         int canvas_w, canvas_h;
779         int new_w, new_h;
780
781 // Get required canvas size
782         calculate_sizes(edl->get_aspect_ratio(), 
783                 edl->session->output_w, 
784                 edl->session->output_h, 
785                 percentage,
786                 canvas_w,
787                 canvas_h);
788
789 // Estimate window size from current borders
790         new_w = canvas_w + (gui->get_w() - mwindow->theme->vcanvas_w);
791         new_h = canvas_h + (gui->get_h() - mwindow->theme->vcanvas_h);
792
793         mwindow->session->vwindow_w = new_w;
794         mwindow->session->vwindow_h = new_h;
795
796         mwindow->theme->get_vwindow_sizes(gui);
797
798 // Estimate again from new borders
799         new_w = canvas_w + (mwindow->session->vwindow_w - mwindow->theme->vcanvas_w);
800         new_h = canvas_h + (mwindow->session->vwindow_h - mwindow->theme->vcanvas_h);
801
802
803         gui->resize_window(new_w, new_h);
804         gui->resize_event(new_w, new_h);
805 }
806
807 void VWindowCanvas::close_source()
808 {
809         gui->vwindow->delete_source(1, 1);
810 }
811
812
813 void VWindowCanvas::draw_refresh(int flush)
814 {
815         EDL *edl = gui->vwindow->get_edl();
816
817         if(!get_canvas()->get_video_on()) get_canvas()->clear_box(0, 0, get_canvas()->get_w(), get_canvas()->get_h());
818         if(!get_canvas()->get_video_on() && refresh_frame && edl)
819         {
820                 float in_x1, in_y1, in_x2, in_y2;
821                 float out_x1, out_y1, out_x2, out_y2;
822                 get_transfers(edl, 
823                         in_x1, 
824                         in_y1, 
825                         in_x2, 
826                         in_y2, 
827                         out_x1, 
828                         out_y1, 
829                         out_x2, 
830                         out_y2);
831                 get_canvas()->draw_vframe(refresh_frame,
832                                 (int)out_x1, 
833                                 (int)out_y1, 
834                                 (int)(out_x2 - out_x1), 
835                                 (int)(out_y2 - out_y1),
836                                 (int)in_x1, 
837                                 (int)in_y1, 
838                                 (int)(in_x2 - in_x1), 
839                                 (int)(in_y2 - in_y1),
840                                 0);
841         }
842
843         if(!get_canvas()->get_video_on())
844         {
845                 draw_overlays();
846                 get_canvas()->flash(flush);
847         }
848 }
849
850 void VWindowCanvas::draw_overlays()
851 {
852         if(mwindow->session->vcanvas_highlighted)
853         {
854                 get_canvas()->set_color(WHITE);
855                 get_canvas()->set_inverse();
856                 get_canvas()->draw_rectangle(0, 0, get_canvas()->get_w(), get_canvas()->get_h());
857                 get_canvas()->draw_rectangle(1, 1, get_canvas()->get_w() - 2, get_canvas()->get_h() - 2);
858                 get_canvas()->set_opaque();
859         }
860 }
861
862 int VWindowCanvas::get_fullscreen()
863 {
864         return mwindow->session->vwindow_fullscreen;
865 }
866
867 void VWindowCanvas::set_fullscreen(int value)
868 {
869         mwindow->session->vwindow_fullscreen = value;
870 }
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908 #if 0
909 void VWindowGUI::update_points()
910 {
911         EDL *edl = vwindow->get_edl();
912
913 //printf("VWindowGUI::update_points 1\n");
914         if(!edl) return;
915
916 //printf("VWindowGUI::update_points 2\n");
917         long pixel = (long)((double)edl->local_session->in_point / 
918                 edl->tracks->total_playable_length() *
919                 (mwindow->theme->vtimebar_w - 
920                         2 * 
921                         mwindow->theme->in_point[0]->get_w())) + 
922                 mwindow->theme->in_point[0]->get_w();
923
924 //printf("VWindowGUI::update_points 3 %d\n", edl->local_session->in_point);
925         if(in_point)
926         {
927 //printf("VWindowGUI::update_points 3.1\n");
928                 if(edl->local_session->in_point >= 0)
929                 {
930 //printf("VWindowGUI::update_points 4\n");
931                         if(edl->local_session->in_point != in_point->position ||
932                                 in_point->pixel != pixel)
933                         {
934                                 in_point->pixel = pixel;
935                                 in_point->reposition();
936                         }
937
938 //printf("VWindowGUI::update_points 5\n");
939                         in_point->position = edl->local_session->in_point;
940
941 //printf("VWindowGUI::update_points 6\n");
942                         if(edl->equivalent(in_point->position, edl->local_session->get_selectionstart(1)) ||
943                                 edl->equivalent(in_point->position, edl->local_session->get_selectionend(1)))
944                                 in_point->update(1);
945                         else
946                                 in_point->update(0);
947 //printf("VWindowGUI::update_points 7\n");
948                 }
949                 else
950                 {
951                         delete in_point;
952                         in_point = 0;
953                 }
954         }
955         else
956         if(edl->local_session->in_point >= 0)
957         {
958 //printf("VWindowGUI::update_points 8 %p\n", mwindow->theme->in_point);
959                 add_subwindow(in_point = 
960                         new VWindowInPoint(mwindow, 
961                                 0, 
962                                 this,
963                                 pixel, 
964                                 edl->local_session->in_point));
965 //printf("VWindowGUI::update_points 9\n");
966         }
967 //printf("VWindowGUI::update_points 10\n");
968
969         pixel = (long)((double)edl->local_session->out_point / 
970                 (edl->tracks->total_playable_length() + 0.5) *
971                 (mwindow->theme->vtimebar_w - 
972                         2 * 
973                         mwindow->theme->in_point[0]->get_w())) + 
974                 mwindow->theme->in_point[0]->get_w() * 
975                 2;
976
977         if(out_point)
978         {
979                 if(edl->local_session->out_point >= 0 && pixel >= 0 && pixel <= mwindow->theme->vtimebar_w)
980                 {
981                         if(edl->local_session->out_point != out_point->position ||
982                                 out_point->pixel != pixel) 
983                         {
984                                 out_point->pixel = pixel;
985                                 out_point->reposition();
986                         }
987                         out_point->position = edl->local_session->out_point;
988
989                         if(edl->equivalent(out_point->position, edl->local_session->get_selectionstart(1)) ||
990                                 edl->equivalent(out_point->position, edl->local_session->get_selectionend(1)))
991                                 out_point->update(1);
992                         else
993                                 out_point->update(0);
994                 }
995                 else
996                 {
997                         delete out_point;
998                         out_point = 0;
999                 }
1000         }
1001         else
1002         if(edl->local_session->out_point >= 0 && pixel >= 0 && pixel <= mwindow->theme->vtimebar_w)
1003         {
1004                 add_subwindow(out_point = 
1005                         new VWindowOutPoint(mwindow, 
1006                                 0, 
1007                                 this, 
1008                                 pixel, 
1009                                 edl->local_session->out_point));
1010         }
1011 }
1012
1013
1014 void VWindowGUI::update_labels()
1015 {
1016         EDL *edl = vwindow->get_edl();
1017         int output = 0;
1018
1019         for(Label *current = edl->labels->first;
1020                 current;
1021                 current = NEXT)
1022         {
1023                 long pixel = (long)((current->position - edl->local_session->view_start) / edl->local_session->zoom_sample);
1024
1025                 if(pixel >= 0 && pixel < mwindow->theme->vtimebar_w)
1026                 {
1027 // Create new label
1028                         if(output >= labels.total)
1029                         {
1030                                 LabelGUI *new_label;
1031                                 add_subwindow(new_label = new LabelGUI(mwindow, this, pixel, 0, current->position));
1032                                 labels.append(new_label);
1033                         }
1034                         else
1035 // Reposition old label
1036                         if(labels.values[output]->pixel != pixel)
1037                         {
1038                                 labels.values[output]->pixel = pixel;
1039                                 labels.values[output]->position = current->position;
1040                                 labels.values[output]->reposition();
1041                         }
1042
1043                         if(mwindow->edl->local_session->get_selectionstart(1) <= current->position &&
1044                                 mwindow->edl->local_session->get_selectionend(1) >= current->position)
1045                                 labels.values[output]->update(1);
1046                         else
1047                         if(labels.values[output]->get_value())
1048                                 labels.values[output]->update(0);
1049                         output++;
1050                 }
1051         }
1052
1053 // Delete excess labels
1054         while(labels.total > output)
1055         {
1056                 labels.remove_object();
1057         }
1058 }
1059
1060
1061
1062 VWindowInPoint::VWindowInPoint(MWindow *mwindow, 
1063                 TimeBar *timebar, 
1064                 VWindowGUI *gui,
1065                 long pixel, 
1066                 double position)
1067  : InPointGUI(mwindow, 
1068                 timebar, 
1069                 pixel, 
1070                 position)
1071 {
1072         this->gui = gui;
1073 }
1074
1075 int VWindowInPoint::handle_event()
1076 {
1077         EDL *edl = gui->vwindow->get_edl();
1078
1079         if(edl)
1080         {
1081                 double position = edl->align_to_frame(this->position, 0);
1082
1083                 edl->local_session->set_selectionstart(position);
1084                 edl->local_session->set_selectionend(position);
1085                 gui->timebar->update(1);
1086
1087 // Que the VWindow
1088                 mwindow->vwindow->update_position(CHANGE_NONE, 0, 1, 0);
1089         }
1090         return 1;
1091 }
1092
1093
1094
1095 VWindowOutPoint::VWindowOutPoint(MWindow *mwindow, 
1096                 TimeBar *timebar, 
1097                 VWindowGUI *gui,
1098                 long pixel, 
1099                 double position)
1100  : OutPointGUI(mwindow, 
1101                 timebar, 
1102                 pixel, 
1103                 position)
1104 {
1105         this->gui = gui;
1106 }
1107
1108 int VWindowOutPoint::handle_event()
1109 {
1110         EDL *edl = gui->vwindow->get_edl();
1111
1112         if(edl)
1113         {
1114                 double position = edl->align_to_frame(this->position, 0);
1115
1116                 edl->local_session->set_selectionstart(position);
1117                 edl->local_session->set_selectionend(position);
1118                 gui->timebar->update(1);
1119
1120 // Que the VWindow
1121                 mwindow->vwindow->update_position(CHANGE_NONE, 0, 1, 0);
1122         }
1123
1124         return 1;
1125 }
1126
1127
1128
1129 #endif
1130