r802: Remove renderframfsclient and renderfarmfsserver .h and .C from Makefile.am...
[cinelerra_cv/mob.git] / cinelerra / vwindowgui.C
blob4f77dc512c75ea4dcb4daad4535f9233d5c22b05
1 #include "asset.h"
2 #include "assets.h"
3 #include "awindowgui.h"
4 #include "awindow.h"
5 #include "canvas.h"
6 #include "clip.h"
7 #include "clipedit.h"
8 #include "edl.h"
9 #include "edlsession.h"
10 #include "filesystem.h"
11 #include "filexml.h"
12 #include "fonts.h"
13 #include "labels.h"
14 #include "language.h"
15 #include "localsession.h"
16 #include "mainclock.h"
17 #include "mainmenu.h"
18 #include "mainsession.h"
19 #include "mainundo.h"
20 #include "meterpanel.h"
21 #include "mwindowgui.h"
22 #include "mwindow.h"
23 #include "playtransport.h"
24 #include "preferences.h"
25 #include "theme.h"
26 #include "timebar.h"
27 #include "tracks.h"
28 #include "vframe.h"
29 #include "vplayback.h"
30 #include "vtimebar.h"
31 #include "vwindowgui.h"
32 #include "vwindow.h"
37 VWindowGUI::VWindowGUI(MWindow *mwindow, VWindow *vwindow)
38  : BC_Window(PROGRAM_NAME ": Viewer",
39         mwindow->session->vwindow_x,
40         mwindow->session->vwindow_y,
41         mwindow->session->vwindow_w,
42         mwindow->session->vwindow_h,
43         100,
44         100,
45         1,
46         1,
47         1)
49         this->mwindow = mwindow;
50         this->vwindow = vwindow;
53 VWindowGUI::~VWindowGUI()
55         delete canvas;
56         delete transport;
59 void VWindowGUI::change_source(EDL *edl, char *title)
61         update_sources(title);
62         char string[BCTEXTLEN];
63         if(title[0]) 
64                 sprintf(string, PROGRAM_NAME ": %s", title);
65         else
66                 sprintf(string, PROGRAM_NAME);
68         lock_window("VWindowGUI::change_source");
69         slider->set_position();
70         timebar->update();
71         set_title(string);
72         unlock_window();
76 // Get source list from master EDL
77 void VWindowGUI::update_sources(char *title)
79         lock_window("VWindowGUI::update_sources");
81 //printf("VWindowGUI::update_sources 1\n");
82         sources.remove_all_objects();
83 //printf("VWindowGUI::update_sources 2\n");
87         for(int i = 0;
88                 i < mwindow->edl->clips.total;
89                 i++)
90         {
91                 char *clip_title = mwindow->edl->clips.values[i]->local_session->clip_title;
92                 int exists = 0;
94                 for(int j = 0; j < sources.total; j++)
95                 {
96                         if(!strcasecmp(sources.values[j]->get_text(), clip_title))
97                         {
98                                 exists = 1;
99                         }
100                 }
102                 if(!exists)
103                 {
104                         sources.append(new BC_ListBoxItem(clip_title));
105                 }
106         }
107 //printf("VWindowGUI::update_sources 3\n");
109         FileSystem fs;
110         for(Asset *current = mwindow->edl->assets->first; 
111                 current;
112                 current = NEXT)
113         {
114                 char clip_title[BCTEXTLEN];
115                 fs.extract_name(clip_title, current->path);
116                 int exists = 0;
117                 
118                 for(int j = 0; j < sources.total; j++)
119                 {
120                         if(!strcasecmp(sources.values[j]->get_text(), clip_title))
121                         {
122                                 exists = 1;
123                         }
124                 }
125                 
126                 if(!exists)
127                 {
128                         sources.append(new BC_ListBoxItem(clip_title));
129                 }
130         }
132 //printf("VWindowGUI::update_sources 4\n");
134 //      source->update_list(&sources);
135 //      source->update(title);
136         unlock_window();
139 int VWindowGUI::create_objects()
141         in_point = 0;
142         out_point = 0;
143         set_icon(mwindow->theme->get_image("vwindow_icon"));
145 //printf("VWindowGUI::create_objects 1\n");
146         mwindow->theme->get_vwindow_sizes(this);
147         mwindow->theme->draw_vwindow_bg(this);
148         flash();
150         meters = new VWindowMeters(mwindow, 
151                 this,
152                 mwindow->theme->vmeter_x,
153                 mwindow->theme->vmeter_y,
154                 mwindow->theme->vmeter_h);
155         meters->create_objects();
157 //printf("VWindowGUI::create_objects 1\n");
158 // Requires meters to build
159         edit_panel = new VWindowEditing(mwindow, vwindow);
160         edit_panel->set_meters(meters);
161         edit_panel->create_objects();
163 //printf("VWindowGUI::create_objects 1\n");
164         add_subwindow(slider = new VWindowSlider(mwindow, 
165         vwindow, 
166                 this, 
167         mwindow->theme->vslider_x, 
168         mwindow->theme->vslider_y, 
169         mwindow->theme->vslider_w));
171 //printf("VWindowGUI::create_objects 1\n");
172         transport = new VWindowTransport(mwindow, 
173                 this, 
174                 mwindow->theme->vtransport_x, 
175                 mwindow->theme->vtransport_y);
176     transport->create_objects();
177         transport->set_slider(slider);
179 //printf("VWindowGUI::create_objects 1\n");
180 //      add_subwindow(fps_title = new BC_Title(mwindow->theme->vedit_x, y, ""));
181     add_subwindow(clock = new MainClock(mwindow,
182                 mwindow->theme->vtime_x, 
183                 mwindow->theme->vtime_y,
184                 mwindow->theme->vtime_w));
186 //printf("VWindowGUI::create_objects 1\n");
187 //      add_subwindow(new BC_Title(mwindow->theme->vzoom_x, mwindow->theme->vzoom_y, "Zoom:"));
188 //      zoom_panel = new VWindowZoom(mwindow, 
189 //              this, 
190 //              mwindow->theme->vzoom_x + 60, 
191 //              mwindow->theme->vzoom_y);
192 //      zoom_panel->create_objects();
193 // 
194         canvas = new VWindowCanvas(mwindow, this);
195         canvas->create_objects(mwindow->edl);
199 //printf("VWindowGUI::create_objects 1\n");
200         add_subwindow(timebar = new VTimeBar(mwindow, 
201                 this,
202                 mwindow->theme->vtimebar_x,
203                 mwindow->theme->vtimebar_y,
204                 mwindow->theme->vtimebar_w, 
205                 mwindow->theme->vtimebar_h));
206         timebar->create_objects();
207 //printf("VWindowGUI::create_objects 2\n");
210 //printf("VWindowGUI::create_objects 1\n");
211 //      source = new VWindowSource(mwindow, 
212 //              this, 
213 //              mwindow->theme->vsource_x,
214 //              mwindow->theme->vsource_y);
215 //      source->create_objects();       
216         update_sources(_("None"));
218 //printf("VWindowGUI::create_objects 2\n");
219         deactivate();
220         slider->activate();
221         return 0;
224 int VWindowGUI::resize_event(int w, int h)
226         mwindow->session->vwindow_x = get_x();
227         mwindow->session->vwindow_y = get_y();
228         mwindow->session->vwindow_w = w;
229         mwindow->session->vwindow_h = h;
231         mwindow->theme->get_vwindow_sizes(this);
232         mwindow->theme->draw_vwindow_bg(this);
233         flash();
235         edit_panel->reposition_buttons(mwindow->theme->vedit_x, 
236                 mwindow->theme->vedit_y);
237         slider->reposition_window(mwindow->theme->vslider_x, 
238         mwindow->theme->vslider_y, 
239         mwindow->theme->vslider_w);
240 // Recalibrate pointer motion range
241         slider->set_position();
242         timebar->resize_event();
243         transport->reposition_buttons(mwindow->theme->vtransport_x, 
244                 mwindow->theme->vtransport_y);
245         clock->reposition_window(mwindow->theme->vtime_x, 
246                 mwindow->theme->vtime_y,
247                 mwindow->theme->vtime_w);
248         canvas->reposition_window(0,
249                 mwindow->theme->vcanvas_x, 
250                 mwindow->theme->vcanvas_y, 
251                 mwindow->theme->vcanvas_w, 
252                 mwindow->theme->vcanvas_h);
253 //      source->reposition_window(mwindow->theme->vsource_x,
254 //              mwindow->theme->vsource_y);
255         meters->reposition_window(mwindow->theme->vmeter_x,
256                 mwindow->theme->vmeter_y,
257                 mwindow->theme->vmeter_h);
259         BC_WindowBase::resize_event(w, h);
260         return 1;
267 int VWindowGUI::translation_event()
269         mwindow->session->vwindow_x = get_x();
270         mwindow->session->vwindow_y = get_y();
271         return 0;
274 int VWindowGUI::close_event()
276         hide_window();
277         mwindow->session->show_vwindow = 0;
278         unlock_window();
279         
280         
281         mwindow->gui->lock_window("VWindowGUI::close_event");
282         mwindow->gui->mainmenu->show_vwindow->set_checked(0);
283         mwindow->gui->unlock_window();
285         lock_window("VWindowGUI::close_event");
286         mwindow->save_defaults();
287         return 1;
290 int VWindowGUI::keypress_event()
292         int result = 0;
293         switch(get_keypress())
294         {
295                 case 'w':
296                 case 'W':
297                         close_event();
298                         result = 1;
299                         break;
300                 case 'z':
301                         mwindow->undo_entry(this);
302                         break;
303                 case 'Z':
304                         mwindow->redo_entry(this);
305                         break;
306         }
307         if(!result) result = transport->keypress_event();
308         
309         return result;
312 void VWindowGUI::drag_motion()
314         if(get_hidden()) return;
315         if(mwindow->session->current_operation != DRAG_ASSET) return;
317         int old_status = mwindow->session->vcanvas_highlighted;
319         int cursor_x = get_relative_cursor_x();
320         int cursor_y = get_relative_cursor_y();
321         
322         mwindow->session->vcanvas_highlighted = (get_cursor_over_window() &&
323                 cursor_x >= canvas->x &&
324                 cursor_x < canvas->x + canvas->w &&
325                 cursor_y >= canvas->y &&
326                 cursor_y < canvas->y + canvas->h);
327 //printf("VWindowGUI::drag_motion 1 %d\n", mwindow->session->vcanvas_highlighted);
330         if(old_status != mwindow->session->vcanvas_highlighted)
331                 canvas->draw_refresh();
334 int VWindowGUI::drag_stop()
336         if(get_hidden()) return 0;
338         if(mwindow->session->vcanvas_highlighted &&
339                 mwindow->session->current_operation == DRAG_ASSET)
340         {
341                 mwindow->session->vcanvas_highlighted = 0;
342                 canvas->draw_refresh();
344                 Asset *asset = mwindow->session->drag_assets->total ?
345                         mwindow->session->drag_assets->values[0] :
346                         0;
347                 EDL *edl = mwindow->session->drag_clips->total ?
348                         mwindow->session->drag_clips->values[0] :
349                         0;
350                 
351                 if(asset)
352                         vwindow->change_source(asset);
353                 else
354                 if(edl)
355                         vwindow->change_source(edl);
356                 return 1;
357         }
359         return 0;
366 VWindowMeters::VWindowMeters(MWindow *mwindow, 
367         VWindowGUI *gui, 
368         int x, 
369         int y, 
370         int h)
371  : MeterPanel(mwindow, 
372                 gui,
373                 x,
374                 y,
375                 h,
376                 mwindow->edl->session->audio_channels,
377                 mwindow->edl->session->vwindow_meter)
379         this->mwindow = mwindow;
380         this->gui = gui;
383 VWindowMeters::~VWindowMeters()
387 int VWindowMeters::change_status_event()
389         mwindow->edl->session->vwindow_meter = use_meters;
390 //printf("VWindowMeters::change_status_event 1 %d\n", mwindow->edl->session->vwindow_meter);
391         mwindow->theme->get_vwindow_sizes(gui);
392         gui->resize_event(gui->get_w(), gui->get_h());
393         return 1;
402 VWindowEditing::VWindowEditing(MWindow *mwindow, VWindow *vwindow)
403  : EditPanel(mwindow, 
404                 vwindow->gui, 
405                 mwindow->theme->vedit_x, 
406                 mwindow->theme->vedit_y,
407                 EDITING_ARROW, 
408                 0,
409                 0,
410                 1, 
411                 1,
412                 0,
413                 0,
414                 1, 
415                 0,
416                 0,
417                 0,
418                 1,
419                 1,
420                 1,
421                 0,
422                 0)
424         this->mwindow = mwindow;
425         this->vwindow = vwindow;
428 VWindowEditing::~VWindowEditing()
432 void VWindowEditing::copy_selection()
434         vwindow->copy();
437 void VWindowEditing::splice_selection()
439         if(vwindow->get_edl())
440         {
441                 mwindow->gui->lock_window("VWindowEditing::splice_selection");
442                 mwindow->splice(vwindow->get_edl());
443                 mwindow->gui->unlock_window();
444         }
447 void VWindowEditing::overwrite_selection()
449         if(vwindow->get_edl())
450         {
451                 mwindow->gui->lock_window("VWindowEditing::overwrite_selection");
452                 mwindow->overwrite(vwindow->get_edl());
453                 mwindow->gui->unlock_window();
454         }
457 void VWindowEditing::toggle_label()
459         if(vwindow->get_edl())
460         {
461                 EDL *edl = vwindow->get_edl();
462                 edl->labels->toggle_label(edl->local_session->get_selectionstart(1),
463                         edl->local_session->get_selectionend(1));
464                 vwindow->gui->timebar->update();
465         }
468 void VWindowEditing::prev_label()
470         if(vwindow->get_edl())
471         {
472                 EDL *edl = vwindow->get_edl();
473                 vwindow->gui->unlock_window();
474                 vwindow->playback_engine->interrupt_playback(1);
475                 vwindow->gui->lock_window("VWindowEditing::prev_label");
477                 Label *current = edl->labels->prev_label(
478                         edl->local_session->get_selectionstart(1));
479                 
481                 if(!current)
482                 {
483                         edl->local_session->set_selectionstart(0);
484                         edl->local_session->set_selectionend(0);
485                         vwindow->update_position(CHANGE_NONE, 0, 1);
486                         vwindow->gui->timebar->update();
487                 }
488                 else
489                 {
490                         edl->local_session->set_selectionstart(current->position);
491                         edl->local_session->set_selectionend(current->position);
492                         vwindow->update_position(CHANGE_NONE, 0, 1);
493                         vwindow->gui->timebar->update();
494                 }
495         }
498 void VWindowEditing::next_label()
500         if(vwindow->get_edl())
501         {
502                 EDL *edl = vwindow->get_edl();
503                 Label *current = edl->labels->next_label(
504                         edl->local_session->get_selectionstart(1));
505                 if(!current)
506                 {
507                         vwindow->gui->unlock_window();
508                         vwindow->playback_engine->interrupt_playback(1);
509                         vwindow->gui->lock_window("VWindowEditing::next_label 1");
511                         double position = edl->tracks->total_length();
512                         edl->local_session->set_selectionstart(position);
513                         edl->local_session->set_selectionend(position);
514                         vwindow->update_position(CHANGE_NONE, 0, 1);
515                         vwindow->gui->timebar->update();
516                 }
517                 else
518                 {
519                         vwindow->gui->unlock_window();
520                         vwindow->playback_engine->interrupt_playback(1);
521                         vwindow->gui->lock_window("VWindowEditing::next_label 2");
523                         edl->local_session->set_selectionstart(current->position);
524                         edl->local_session->set_selectionend(current->position);
525                         vwindow->update_position(CHANGE_NONE, 0, 1);
526                         vwindow->gui->timebar->update();
527                 }
528         }
531 void VWindowEditing::set_inpoint()
533         vwindow->set_inpoint();
536 void VWindowEditing::set_outpoint()
538         vwindow->set_outpoint();
541 void VWindowEditing::clear_inpoint()
543         vwindow->clear_inpoint();
546 void VWindowEditing::clear_outpoint()
548         vwindow->clear_outpoint();
551 void VWindowEditing::to_clip()
553         if(vwindow->get_edl())
554         {
555                 FileXML file;
556                 EDL *edl = vwindow->get_edl();
557                 double start = edl->local_session->get_selectionstart();
558                 double end = edl->local_session->get_selectionend();
560                 if(EQUIV(start, end))
561                 {
562                         end = edl->tracks->total_length();
563                         start = 0;
564                 }
568                 edl->copy(start, 
569                         end, 
570                         1,
571                         0,
572                         0,
573                         &file,
574                         mwindow->plugindb,
575                         "",
576                         1);
581                 EDL *new_edl = new EDL(mwindow->edl);
582                 new_edl->create_objects();
583                 new_edl->load_xml(mwindow->plugindb, &file, LOAD_ALL);
584                 sprintf(new_edl->local_session->clip_title, _("Clip %d"), mwindow->session->clip_number++);
585                 new_edl->local_session->set_selectionstart(0);
586                 new_edl->local_session->set_selectionend(0);
589 //printf("VWindowEditing::to_clip 1 %s\n", edl->local_session->clip_title);
590                 new_edl->local_session->set_selectionstart(0.0);
591                 new_edl->local_session->set_selectionend(0.0);
592                 vwindow->clip_edit->create_clip(new_edl);
593         }
601 VWindowSlider::VWindowSlider(MWindow *mwindow, 
602         VWindow *vwindow, 
603         VWindowGUI *gui,
604         int x, 
605         int y, 
606         int pixels)
607  : BC_PercentageSlider(x, 
608                         y,
609                         0,
610                         pixels, 
611                         pixels, 
612                         0, 
613                         1, 
614                         0)
616         this->mwindow = mwindow;
617         this->vwindow = vwindow;
618         this->gui = gui;
619         set_precision(0.00001);
622 VWindowSlider::~VWindowSlider()
626 int VWindowSlider::handle_event()
628         unlock_window();
629         vwindow->playback_engine->interrupt_playback(1);
630         lock_window("VWindowSlider::handle_event");
632         vwindow->update_position(CHANGE_NONE, 1, 0);
633         gui->timebar->update();
634         return 1;
637 void VWindowSlider::set_position()
639         EDL *edl = vwindow->get_edl();
640         if(edl)
641         {
642                 double new_length = edl->tracks->total_playable_length();
643                 if(EQUIV(edl->local_session->preview_end, 0))
644                         edl->local_session->preview_end = new_length;
645                 if(edl->local_session->preview_end > new_length)
646                         edl->local_session->preview_end = new_length;
647                 if(edl->local_session->preview_start > new_length)
648                         edl->local_session->preview_start = 0;
650                 update(mwindow->theme->vslider_w, 
651                         edl->local_session->get_selectionstart(1), 
652                         edl->local_session->preview_start, 
653                         edl->local_session->preview_end);
654         }
665 VWindowSource::VWindowSource(MWindow *mwindow, VWindowGUI *vwindow, int x, int y)
666  : BC_PopupTextBox(vwindow, 
667         &vwindow->sources, 
668         "",
669         x, 
670         y, 
671         200, 
672         200)
674         this->mwindow = mwindow;
675         this->vwindow = vwindow;
678 VWindowSource::~VWindowSource()
682 int VWindowSource::handle_event()
684         return 1;
693 VWindowTransport::VWindowTransport(MWindow *mwindow, 
694         VWindowGUI *gui, 
695         int x, 
696         int y)
697  : PlayTransport(mwindow, 
698         gui, 
699         x, 
700         y)
702         this->gui = gui;
705 EDL* VWindowTransport::get_edl()
707         return gui->vwindow->get_edl();
711 void VWindowTransport::goto_start()
713         gui->unlock_window();
714         handle_transport(REWIND, 1);
715         gui->lock_window("VWindowTransport::goto_start");
716         gui->vwindow->goto_start();
719 void VWindowTransport::goto_end()
721         gui->unlock_window();
722         handle_transport(GOTO_END, 1);
723         gui->lock_window("VWindowTransport::goto_end");
724         gui->vwindow->goto_end();
730 VWindowCanvas::VWindowCanvas(MWindow *mwindow, VWindowGUI *gui)
731  : Canvas(gui,
732                 mwindow->theme->vcanvas_x, 
733                 mwindow->theme->vcanvas_y, 
734                 mwindow->theme->vcanvas_w, 
735                 mwindow->theme->vcanvas_h,
736                 0,
737                 0,
738                 0,
739                 0,
740                 0,
741                 1)
743         this->mwindow = mwindow;
744         this->gui = gui;
747 void VWindowCanvas::zoom_resize_window(float percentage)
749         EDL *edl = mwindow->vwindow->get_edl();
750         if(!edl) edl = mwindow->edl;
752         int canvas_w, canvas_h;
753         calculate_sizes(edl->get_aspect_ratio(), 
754                 edl->session->output_w, 
755                 edl->session->output_h, 
756                 percentage,
757                 canvas_w,
758                 canvas_h);
759         int new_w, new_h;
760         new_w = canvas_w + (gui->get_w() - mwindow->theme->vcanvas_w);
761         new_h = canvas_h + (gui->get_h() - mwindow->theme->vcanvas_h);
762         gui->resize_window(new_w, new_h);
763         gui->resize_event(new_w, new_h);
766 void VWindowCanvas::close_source()
768         mwindow->vwindow->remove_source();
772 void VWindowCanvas::draw_refresh()
774         EDL *edl = gui->vwindow->get_edl();
776         if(!canvas->video_is_on()) canvas->clear_box(0, 0, canvas->get_w(), canvas->get_h());
777         if(!canvas->video_is_on() && refresh_frame && edl)
778         {
779                 int in_x, in_y, in_w, in_h, out_x, out_y, out_w, out_h;
780                 get_transfers(edl, 
781                         in_x, 
782                         in_y, 
783                         in_w, 
784                         in_h, 
785                         out_x, 
786                         out_y, 
787                         out_w, 
788                         out_h);
789                 canvas->draw_vframe(refresh_frame,
790                                 out_x, 
791                                 out_y, 
792                                 out_w, 
793                                 out_h,
794                                 in_x, 
795                                 in_y, 
796                                 in_w, 
797                                 in_h,
798                                 0);
799         }
801         if(!canvas->video_is_on())
802         {
803                 draw_overlays();
804                 canvas->flash();
805                 canvas->flush();
806         }
809 void VWindowCanvas::draw_overlays()
811         if(mwindow->session->vcanvas_highlighted)
812         {
813                 canvas->set_color(WHITE);
814                 canvas->set_inverse();
815                 canvas->draw_rectangle(0, 0, canvas->get_w(), canvas->get_h());
816                 canvas->draw_rectangle(1, 1, canvas->get_w() - 2, canvas->get_h() - 2);
817                 canvas->set_opaque();
818         }
857 #if 0
858 void VWindowGUI::update_points()
860         EDL *edl = vwindow->get_edl();
862 //printf("VWindowGUI::update_points 1\n");
863         if(!edl) return;
865 //printf("VWindowGUI::update_points 2\n");
866         long pixel = (long)((double)edl->local_session->in_point / 
867                 edl->tracks->total_playable_length() *
868                 (mwindow->theme->vtimebar_w - 
869                         2 * 
870                         mwindow->theme->in_point[0]->get_w())) + 
871                 mwindow->theme->in_point[0]->get_w();
873 //printf("VWindowGUI::update_points 3 %d\n", edl->local_session->in_point);
874         if(in_point)
875         {
876 //printf("VWindowGUI::update_points 3.1\n");
877                 if(edl->local_session->in_point >= 0)
878                 {
879 //printf("VWindowGUI::update_points 4\n");
880                         if(edl->local_session->in_point != in_point->position ||
881                                 in_point->pixel != pixel)
882                         {
883                                 in_point->pixel = pixel;
884                                 in_point->reposition();
885                         }
887 //printf("VWindowGUI::update_points 5\n");
888                         in_point->position = edl->local_session->in_point;
890 //printf("VWindowGUI::update_points 6\n");
891                         if(edl->equivalent(in_point->position, edl->local_session->get_selectionstart(1)) ||
892                                 edl->equivalent(in_point->position, edl->local_session->get_selectionend(1)))
893                                 in_point->update(1);
894                         else
895                                 in_point->update(0);
896 //printf("VWindowGUI::update_points 7\n");
897                 }
898                 else
899                 {
900                         delete in_point;
901                         in_point = 0;
902                 }
903         }
904         else
905         if(edl->local_session->in_point >= 0)
906         {
907 //printf("VWindowGUI::update_points 8 %p\n", mwindow->theme->in_point);
908                 add_subwindow(in_point = 
909                         new VWindowInPoint(mwindow, 
910                                 0, 
911                                 this,
912                                 pixel, 
913                                 edl->local_session->in_point));
914 //printf("VWindowGUI::update_points 9\n");
915         }
916 //printf("VWindowGUI::update_points 10\n");
918         pixel = (long)((double)edl->local_session->out_point / 
919                 (edl->tracks->total_playable_length() + 0.5) *
920                 (mwindow->theme->vtimebar_w - 
921                         2 * 
922                         mwindow->theme->in_point[0]->get_w())) + 
923                 mwindow->theme->in_point[0]->get_w() * 
924                 2;
926         if(out_point)
927         {
928                 if(edl->local_session->out_point >= 0 && pixel >= 0 && pixel <= mwindow->theme->vtimebar_w)
929                 {
930                         if(edl->local_session->out_point != out_point->position ||
931                                 out_point->pixel != pixel) 
932                         {
933                                 out_point->pixel = pixel;
934                                 out_point->reposition();
935                         }
936                         out_point->position = edl->local_session->out_point;
938                         if(edl->equivalent(out_point->position, edl->local_session->get_selectionstart(1)) ||
939                                 edl->equivalent(out_point->position, edl->local_session->get_selectionend(1)))
940                                 out_point->update(1);
941                         else
942                                 out_point->update(0);
943                 }
944                 else
945                 {
946                         delete out_point;
947                         out_point = 0;
948                 }
949         }
950         else
951         if(edl->local_session->out_point >= 0 && pixel >= 0 && pixel <= mwindow->theme->vtimebar_w)
952         {
953                 add_subwindow(out_point = 
954                         new VWindowOutPoint(mwindow, 
955                                 0, 
956                                 this, 
957                                 pixel, 
958                                 edl->local_session->out_point));
959         }
963 void VWindowGUI::update_labels()
965         EDL *edl = vwindow->get_edl();
966         int output = 0;
968         for(Label *current = edl->labels->first;
969                 current;
970                 current = NEXT)
971         {
972                 long pixel = (long)((current->position - edl->local_session->view_start) / edl->local_session->zoom_sample);
974                 if(pixel >= 0 && pixel < mwindow->theme->vtimebar_w)
975                 {
976 // Create new label
977                         if(output >= labels.total)
978                         {
979                                 LabelGUI *new_label;
980                                 add_subwindow(new_label = new LabelGUI(mwindow, this, pixel, 0, current->position));
981                                 labels.append(new_label);
982                         }
983                         else
984 // Reposition old label
985                         if(labels.values[output]->pixel != pixel)
986                         {
987                                 labels.values[output]->pixel = pixel;
988                                 labels.values[output]->position = current->position;
989                                 labels.values[output]->reposition();
990                         }
992                         if(mwindow->edl->local_session->get_selectionstart(1) <= current->position &&
993                                 mwindow->edl->local_session->get_selectionend(1) >= current->position)
994                                 labels.values[output]->update(1);
995                         else
996                         if(labels.values[output]->get_value())
997                                 labels.values[output]->update(0);
998                         output++;
999                 }
1000         }
1002 // Delete excess labels
1003         while(labels.total > output)
1004         {
1005                 labels.remove_object();
1006         }
1011 VWindowInPoint::VWindowInPoint(MWindow *mwindow, 
1012                 TimeBar *timebar, 
1013                 VWindowGUI *gui,
1014                 long pixel, 
1015                 double position)
1016  : InPointGUI(mwindow, 
1017                 timebar, 
1018                 pixel, 
1019                 position)
1021         this->gui = gui;
1024 int VWindowInPoint::handle_event()
1026         EDL *edl = gui->vwindow->get_edl();
1028         if(edl)
1029         {
1030                 double position = edl->align_to_frame(this->position, 0);
1032                 edl->local_session->set_selectionstart(position);
1033                 edl->local_session->set_selectionend(position);
1034                 gui->timebar->update();
1036 // Que the VWindow
1037                 mwindow->vwindow->update_position(CHANGE_NONE, 0, 1);
1038         }
1039         return 1;
1044 VWindowOutPoint::VWindowOutPoint(MWindow *mwindow, 
1045                 TimeBar *timebar, 
1046                 VWindowGUI *gui,
1047                 long pixel, 
1048                 double position)
1049  : OutPointGUI(mwindow, 
1050                 timebar, 
1051                 pixel, 
1052                 position)
1054         this->gui = gui;
1057 int VWindowOutPoint::handle_event()
1059         EDL *edl = gui->vwindow->get_edl();
1061         if(edl)
1062         {
1063                 double position = edl->align_to_frame(this->position, 0);
1065                 edl->local_session->set_selectionstart(position);
1066                 edl->local_session->set_selectionend(position);
1067                 gui->timebar->update();
1069 // Que the VWindow
1070                 mwindow->vwindow->update_position(CHANGE_NONE, 0, 1);
1071         }
1073         return 1;
1078 #endif