r854: Merge 2.1:
[cinelerra_cv/ct.git] / cinelerra / vwindowgui.C
blob99fa38cc9b7b5f394a1b0513a9bc5d37e5974c76
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 "keys.h"
14 #include "labels.h"
15 #include "language.h"
16 #include "localsession.h"
17 #include "mainclock.h"
18 #include "mainmenu.h"
19 #include "mainsession.h"
20 #include "mainundo.h"
21 #include "meterpanel.h"
22 #include "mwindowgui.h"
23 #include "mwindow.h"
24 #include "playtransport.h"
25 #include "preferences.h"
26 #include "theme.h"
27 #include "timebar.h"
28 #include "tracks.h"
29 #include "vframe.h"
30 #include "vplayback.h"
31 #include "vtimebar.h"
32 #include "vwindowgui.h"
33 #include "vwindow.h"
38 VWindowGUI::VWindowGUI(MWindow *mwindow, VWindow *vwindow)
39  : BC_Window(PROGRAM_NAME ": Viewer",
40         mwindow->session->vwindow_x,
41         mwindow->session->vwindow_y,
42         mwindow->session->vwindow_w,
43         mwindow->session->vwindow_h,
44         100,
45         100,
46         1,
47         1,
48         1)
50         this->mwindow = mwindow;
51         this->vwindow = vwindow;
54 VWindowGUI::~VWindowGUI()
56         delete canvas;
57         delete transport;
60 void VWindowGUI::change_source(EDL *edl, char *title)
62         update_sources(title);
63         char string[BCTEXTLEN];
64         if(title[0]) 
65                 sprintf(string, PROGRAM_NAME ": %s", title);
66         else
67                 sprintf(string, PROGRAM_NAME);
69         lock_window("VWindowGUI::change_source");
70         slider->set_position();
71         timebar->update();
72         set_title(string);
73         unlock_window();
77 // Get source list from master EDL
78 void VWindowGUI::update_sources(char *title)
80         lock_window("VWindowGUI::update_sources");
82 //printf("VWindowGUI::update_sources 1\n");
83         sources.remove_all_objects();
84 //printf("VWindowGUI::update_sources 2\n");
88         for(int i = 0;
89                 i < mwindow->edl->clips.total;
90                 i++)
91         {
92                 char *clip_title = mwindow->edl->clips.values[i]->local_session->clip_title;
93                 int exists = 0;
95                 for(int j = 0; j < sources.total; j++)
96                 {
97                         if(!strcasecmp(sources.values[j]->get_text(), clip_title))
98                         {
99                                 exists = 1;
100                         }
101                 }
103                 if(!exists)
104                 {
105                         sources.append(new BC_ListBoxItem(clip_title));
106                 }
107         }
108 //printf("VWindowGUI::update_sources 3\n");
110         FileSystem fs;
111         for(Asset *current = mwindow->edl->assets->first; 
112                 current;
113                 current = NEXT)
114         {
115                 char clip_title[BCTEXTLEN];
116                 fs.extract_name(clip_title, current->path);
117                 int exists = 0;
118                 
119                 for(int j = 0; j < sources.total; j++)
120                 {
121                         if(!strcasecmp(sources.values[j]->get_text(), clip_title))
122                         {
123                                 exists = 1;
124                         }
125                 }
126                 
127                 if(!exists)
128                 {
129                         sources.append(new BC_ListBoxItem(clip_title));
130                 }
131         }
133 //printf("VWindowGUI::update_sources 4\n");
135 //      source->update_list(&sources);
136 //      source->update(title);
137         unlock_window();
140 int VWindowGUI::create_objects()
142         in_point = 0;
143         out_point = 0;
144         set_icon(mwindow->theme->get_image("vwindow_icon"));
146 //printf("VWindowGUI::create_objects 1\n");
147         mwindow->theme->get_vwindow_sizes(this);
148         mwindow->theme->draw_vwindow_bg(this);
149         flash();
151         meters = new VWindowMeters(mwindow, 
152                 this,
153                 mwindow->theme->vmeter_x,
154                 mwindow->theme->vmeter_y,
155                 mwindow->theme->vmeter_h);
156         meters->create_objects();
158 //printf("VWindowGUI::create_objects 1\n");
159 // Requires meters to build
160         edit_panel = new VWindowEditing(mwindow, vwindow);
161         edit_panel->set_meters(meters);
162         edit_panel->create_objects();
164 //printf("VWindowGUI::create_objects 1\n");
165         add_subwindow(slider = new VWindowSlider(mwindow, 
166         vwindow, 
167                 this, 
168         mwindow->theme->vslider_x, 
169         mwindow->theme->vslider_y, 
170         mwindow->theme->vslider_w));
172 //printf("VWindowGUI::create_objects 1\n");
173         transport = new VWindowTransport(mwindow, 
174                 this, 
175                 mwindow->theme->vtransport_x, 
176                 mwindow->theme->vtransport_y);
177     transport->create_objects();
178         transport->set_slider(slider);
180 //printf("VWindowGUI::create_objects 1\n");
181 //      add_subwindow(fps_title = new BC_Title(mwindow->theme->vedit_x, y, ""));
182     add_subwindow(clock = new MainClock(mwindow,
183                 mwindow->theme->vtime_x, 
184                 mwindow->theme->vtime_y,
185                 mwindow->theme->vtime_w));
187         canvas = new VWindowCanvas(mwindow, this);
188         canvas->create_objects(mwindow->edl);
192 //printf("VWindowGUI::create_objects 1\n");
193         add_subwindow(timebar = new VTimeBar(mwindow, 
194                 this,
195                 mwindow->theme->vtimebar_x,
196                 mwindow->theme->vtimebar_y,
197                 mwindow->theme->vtimebar_w, 
198                 mwindow->theme->vtimebar_h));
199         timebar->create_objects();
200 //printf("VWindowGUI::create_objects 2\n");
203 //printf("VWindowGUI::create_objects 1\n");
204 //      source = new VWindowSource(mwindow, 
205 //              this, 
206 //              mwindow->theme->vsource_x,
207 //              mwindow->theme->vsource_y);
208 //      source->create_objects();       
209         update_sources(_("None"));
211 //printf("VWindowGUI::create_objects 2\n");
212         deactivate();
213         slider->activate();
214         return 0;
217 int VWindowGUI::resize_event(int w, int h)
219         mwindow->session->vwindow_x = get_x();
220         mwindow->session->vwindow_y = get_y();
221         mwindow->session->vwindow_w = w;
222         mwindow->session->vwindow_h = h;
224         mwindow->theme->get_vwindow_sizes(this);
225         mwindow->theme->draw_vwindow_bg(this);
226         flash();
228         edit_panel->reposition_buttons(mwindow->theme->vedit_x, 
229                 mwindow->theme->vedit_y);
230         slider->reposition_window(mwindow->theme->vslider_x, 
231         mwindow->theme->vslider_y, 
232         mwindow->theme->vslider_w);
233 // Recalibrate pointer motion range
234         slider->set_position();
235         timebar->resize_event();
236         transport->reposition_buttons(mwindow->theme->vtransport_x, 
237                 mwindow->theme->vtransport_y);
238         clock->reposition_window(mwindow->theme->vtime_x, 
239                 mwindow->theme->vtime_y,
240                 mwindow->theme->vtime_w);
241         canvas->reposition_window(0,
242                 mwindow->theme->vcanvas_x, 
243                 mwindow->theme->vcanvas_y, 
244                 mwindow->theme->vcanvas_w, 
245                 mwindow->theme->vcanvas_h);
246 //      source->reposition_window(mwindow->theme->vsource_x,
247 //              mwindow->theme->vsource_y);
248         meters->reposition_window(mwindow->theme->vmeter_x,
249                 mwindow->theme->vmeter_y,
250                 mwindow->theme->vmeter_h);
252         BC_WindowBase::resize_event(w, h);
253         return 1;
260 int VWindowGUI::translation_event()
262         mwindow->session->vwindow_x = get_x();
263         mwindow->session->vwindow_y = get_y();
264         return 0;
267 int VWindowGUI::close_event()
269         hide_window();
270         mwindow->session->show_vwindow = 0;
271         unlock_window();
272         
273         
274         mwindow->gui->lock_window("VWindowGUI::close_event");
275         mwindow->gui->mainmenu->show_vwindow->set_checked(0);
276         mwindow->gui->unlock_window();
278         lock_window("VWindowGUI::close_event");
279         mwindow->save_defaults();
280         return 1;
283 int VWindowGUI::keypress_event()
285         int result = 0;
286         switch(get_keypress())
287         {
288                 case 'w':
289                 case 'W':
290                         close_event();
291                         result = 1;
292                         break;
293                 case 'z':
294                         mwindow->undo_entry(this);
295                         break;
296                 case 'Z':
297                         mwindow->redo_entry(this);
298                         break;
299                 case 'f':
300                         unlock_window();
301                         if(mwindow->session->vwindow_fullscreen)
302                                 canvas->stop_fullscreen();
303                         else
304                                 canvas->start_fullscreen();
305                         lock_window("VWindowGUI::keypress_event 1");
306                         break;
307                 case ESC:
308                         unlock_window();
309                         if(mwindow->session->vwindow_fullscreen)
310                                 canvas->stop_fullscreen();
311                         lock_window("VWindowGUI::keypress_event 2");
312                         break;
313         }
314         if(!result) result = transport->keypress_event();
315         
316         return result;
319 int VWindowGUI::button_press_event()
321         if(canvas->get_canvas())
322                 return canvas->button_press_event_base(canvas->get_canvas());
323         return 0;
326 int VWindowGUI::cursor_leave_event()
328         if(canvas->get_canvas())
329                 return canvas->cursor_leave_event_base(canvas->get_canvas());
330         return 0;
333 int VWindowGUI::cursor_enter_event()
335         if(canvas->get_canvas())
336                 return canvas->cursor_enter_event_base(canvas->get_canvas());
337         return 0;
340 int VWindowGUI::button_release_event()
342         if(canvas->get_canvas())
343                 return canvas->button_release_event();
344         return 0;
347 int VWindowGUI::cursor_motion_event()
349         if(canvas->get_canvas())
350         {
351                 canvas->get_canvas()->unhide_cursor();
352                 return canvas->cursor_motion_event();
353         }
354         return 0;
358 void VWindowGUI::drag_motion()
360         if(get_hidden()) return;
361         if(mwindow->session->current_operation != DRAG_ASSET) return;
363         int old_status = mwindow->session->vcanvas_highlighted;
365         int cursor_x = get_relative_cursor_x();
366         int cursor_y = get_relative_cursor_y();
367         
368         mwindow->session->vcanvas_highlighted = (get_cursor_over_window() &&
369                 cursor_x >= canvas->x &&
370                 cursor_x < canvas->x + canvas->w &&
371                 cursor_y >= canvas->y &&
372                 cursor_y < canvas->y + canvas->h);
373 //printf("VWindowGUI::drag_motion 1 %d\n", mwindow->session->vcanvas_highlighted);
376         if(old_status != mwindow->session->vcanvas_highlighted)
377                 canvas->draw_refresh();
380 int VWindowGUI::drag_stop()
382         if(get_hidden()) return 0;
384         if(mwindow->session->vcanvas_highlighted &&
385                 mwindow->session->current_operation == DRAG_ASSET)
386         {
387                 mwindow->session->vcanvas_highlighted = 0;
388                 canvas->draw_refresh();
390                 Asset *asset = mwindow->session->drag_assets->total ?
391                         mwindow->session->drag_assets->values[0] :
392                         0;
393                 EDL *edl = mwindow->session->drag_clips->total ?
394                         mwindow->session->drag_clips->values[0] :
395                         0;
396                 
397                 if(asset)
398                         vwindow->change_source(asset);
399                 else
400                 if(edl)
401                         vwindow->change_source(edl);
402                 return 1;
403         }
405         return 0;
412 VWindowMeters::VWindowMeters(MWindow *mwindow, 
413         VWindowGUI *gui, 
414         int x, 
415         int y, 
416         int h)
417  : MeterPanel(mwindow, 
418                 gui,
419                 x,
420                 y,
421                 h,
422                 mwindow->edl->session->audio_channels,
423                 mwindow->edl->session->vwindow_meter)
425         this->mwindow = mwindow;
426         this->gui = gui;
429 VWindowMeters::~VWindowMeters()
433 int VWindowMeters::change_status_event()
435         mwindow->edl->session->vwindow_meter = use_meters;
436 //printf("VWindowMeters::change_status_event 1 %d\n", mwindow->edl->session->vwindow_meter);
437         mwindow->theme->get_vwindow_sizes(gui);
438         gui->resize_event(gui->get_w(), gui->get_h());
439         return 1;
448 VWindowEditing::VWindowEditing(MWindow *mwindow, VWindow *vwindow)
449  : EditPanel(mwindow, 
450                 vwindow->gui, 
451                 mwindow->theme->vedit_x, 
452                 mwindow->theme->vedit_y,
453                 EDITING_ARROW, 
454                 0,
455                 0,
456                 1, 
457                 1,
458                 0,
459                 0,
460                 1, 
461                 0,
462                 0,
463                 0,
464                 1,
465                 1,
466                 1,
467                 0,
468                 0)
470         this->mwindow = mwindow;
471         this->vwindow = vwindow;
474 VWindowEditing::~VWindowEditing()
478 void VWindowEditing::copy_selection()
480         vwindow->copy();
483 void VWindowEditing::splice_selection()
485         if(vwindow->get_edl())
486         {
487                 mwindow->gui->lock_window("VWindowEditing::splice_selection");
488                 mwindow->splice(vwindow->get_edl());
489                 mwindow->gui->unlock_window();
490         }
493 void VWindowEditing::overwrite_selection()
495         if(vwindow->get_edl())
496         {
497                 mwindow->gui->lock_window("VWindowEditing::overwrite_selection");
498                 mwindow->overwrite(vwindow->get_edl());
499                 mwindow->gui->unlock_window();
500         }
503 void VWindowEditing::toggle_label()
505         if(vwindow->get_edl())
506         {
507                 EDL *edl = vwindow->get_edl();
508                 edl->labels->toggle_label(edl->local_session->get_selectionstart(1),
509                         edl->local_session->get_selectionend(1));
510                 vwindow->gui->timebar->update();
511         }
514 void VWindowEditing::prev_label()
516         if(vwindow->get_edl())
517         {
518                 EDL *edl = vwindow->get_edl();
519                 vwindow->gui->unlock_window();
520                 vwindow->playback_engine->interrupt_playback(1);
521                 vwindow->gui->lock_window("VWindowEditing::prev_label");
523                 Label *current = edl->labels->prev_label(
524                         edl->local_session->get_selectionstart(1));
525                 
527                 if(!current)
528                 {
529                         edl->local_session->set_selectionstart(0);
530                         edl->local_session->set_selectionend(0);
531                         vwindow->update_position(CHANGE_NONE, 0, 1);
532                         vwindow->gui->timebar->update();
533                 }
534                 else
535                 {
536                         edl->local_session->set_selectionstart(current->position);
537                         edl->local_session->set_selectionend(current->position);
538                         vwindow->update_position(CHANGE_NONE, 0, 1);
539                         vwindow->gui->timebar->update();
540                 }
541         }
544 void VWindowEditing::next_label()
546         if(vwindow->get_edl())
547         {
548                 EDL *edl = vwindow->get_edl();
549                 Label *current = edl->labels->next_label(
550                         edl->local_session->get_selectionstart(1));
551                 if(!current)
552                 {
553                         vwindow->gui->unlock_window();
554                         vwindow->playback_engine->interrupt_playback(1);
555                         vwindow->gui->lock_window("VWindowEditing::next_label 1");
557                         double position = edl->tracks->total_length();
558                         edl->local_session->set_selectionstart(position);
559                         edl->local_session->set_selectionend(position);
560                         vwindow->update_position(CHANGE_NONE, 0, 1);
561                         vwindow->gui->timebar->update();
562                 }
563                 else
564                 {
565                         vwindow->gui->unlock_window();
566                         vwindow->playback_engine->interrupt_playback(1);
567                         vwindow->gui->lock_window("VWindowEditing::next_label 2");
569                         edl->local_session->set_selectionstart(current->position);
570                         edl->local_session->set_selectionend(current->position);
571                         vwindow->update_position(CHANGE_NONE, 0, 1);
572                         vwindow->gui->timebar->update();
573                 }
574         }
577 void VWindowEditing::set_inpoint()
579         vwindow->set_inpoint();
582 void VWindowEditing::set_outpoint()
584         vwindow->set_outpoint();
587 void VWindowEditing::clear_inpoint()
589         vwindow->clear_inpoint();
592 void VWindowEditing::clear_outpoint()
594         vwindow->clear_outpoint();
597 void VWindowEditing::to_clip()
599         if(vwindow->get_edl())
600         {
601                 FileXML file;
602                 EDL *edl = vwindow->get_edl();
603                 double start = edl->local_session->get_selectionstart();
604                 double end = edl->local_session->get_selectionend();
606                 if(EQUIV(start, end))
607                 {
608                         end = edl->tracks->total_length();
609                         start = 0;
610                 }
614                 edl->copy(start, 
615                         end, 
616                         1,
617                         0,
618                         0,
619                         &file,
620                         mwindow->plugindb,
621                         "",
622                         1);
627                 EDL *new_edl = new EDL(mwindow->edl);
628                 new_edl->create_objects();
629                 new_edl->load_xml(mwindow->plugindb, &file, LOAD_ALL);
630                 sprintf(new_edl->local_session->clip_title, _("Clip %d"), mwindow->session->clip_number++);
631                 new_edl->local_session->set_selectionstart(0);
632                 new_edl->local_session->set_selectionend(0);
635 //printf("VWindowEditing::to_clip 1 %s\n", edl->local_session->clip_title);
636                 new_edl->local_session->set_selectionstart(0.0);
637                 new_edl->local_session->set_selectionend(0.0);
638                 vwindow->clip_edit->create_clip(new_edl);
639         }
647 VWindowSlider::VWindowSlider(MWindow *mwindow, 
648         VWindow *vwindow, 
649         VWindowGUI *gui,
650         int x, 
651         int y, 
652         int pixels)
653  : BC_PercentageSlider(x, 
654                         y,
655                         0,
656                         pixels, 
657                         pixels, 
658                         0, 
659                         1, 
660                         0)
662         this->mwindow = mwindow;
663         this->vwindow = vwindow;
664         this->gui = gui;
665         set_precision(0.00001);
668 VWindowSlider::~VWindowSlider()
672 int VWindowSlider::handle_event()
674         unlock_window();
675         vwindow->playback_engine->interrupt_playback(1);
676         lock_window("VWindowSlider::handle_event");
678         vwindow->update_position(CHANGE_NONE, 1, 0);
679         gui->timebar->update();
680         return 1;
683 void VWindowSlider::set_position()
685         EDL *edl = vwindow->get_edl();
686         if(edl)
687         {
688                 double new_length = edl->tracks->total_playable_length();
689                 if(EQUIV(edl->local_session->preview_end, 0))
690                         edl->local_session->preview_end = new_length;
691                 if(edl->local_session->preview_end > new_length)
692                         edl->local_session->preview_end = new_length;
693                 if(edl->local_session->preview_start > new_length)
694                         edl->local_session->preview_start = 0;
696                 update(mwindow->theme->vslider_w, 
697                         edl->local_session->get_selectionstart(1), 
698                         edl->local_session->preview_start, 
699                         edl->local_session->preview_end);
700         }
711 VWindowSource::VWindowSource(MWindow *mwindow, VWindowGUI *vwindow, int x, int y)
712  : BC_PopupTextBox(vwindow, 
713         &vwindow->sources, 
714         "",
715         x, 
716         y, 
717         200, 
718         200)
720         this->mwindow = mwindow;
721         this->vwindow = vwindow;
724 VWindowSource::~VWindowSource()
728 int VWindowSource::handle_event()
730         return 1;
739 VWindowTransport::VWindowTransport(MWindow *mwindow, 
740         VWindowGUI *gui, 
741         int x, 
742         int y)
743  : PlayTransport(mwindow, 
744         gui, 
745         x, 
746         y)
748         this->gui = gui;
751 EDL* VWindowTransport::get_edl()
753         return gui->vwindow->get_edl();
757 void VWindowTransport::goto_start()
759         gui->unlock_window();
760         handle_transport(REWIND, 1);
761         gui->lock_window("VWindowTransport::goto_start");
762         gui->vwindow->goto_start();
765 void VWindowTransport::goto_end()
767         gui->unlock_window();
768         handle_transport(GOTO_END, 1);
769         gui->lock_window("VWindowTransport::goto_end");
770         gui->vwindow->goto_end();
776 VWindowCanvas::VWindowCanvas(MWindow *mwindow, VWindowGUI *gui)
777  : Canvas(mwindow,
778         gui,
779         mwindow->theme->vcanvas_x, 
780         mwindow->theme->vcanvas_y, 
781         mwindow->theme->vcanvas_w, 
782         mwindow->theme->vcanvas_h,
783         0,
784         0,
785         0,
786         0,
787         0,
788         1)
790         this->mwindow = mwindow;
791         this->gui = gui;
794 void VWindowCanvas::zoom_resize_window(float percentage)
796         EDL *edl = mwindow->vwindow->get_edl();
797         if(!edl) edl = mwindow->edl;
799         int canvas_w, canvas_h;
800         calculate_sizes(edl->get_aspect_ratio(), 
801                 edl->session->output_w, 
802                 edl->session->output_h, 
803                 percentage,
804                 canvas_w,
805                 canvas_h);
806         int new_w, new_h;
807         new_w = canvas_w + (gui->get_w() - mwindow->theme->vcanvas_w);
808         new_h = canvas_h + (gui->get_h() - mwindow->theme->vcanvas_h);
809         gui->resize_window(new_w, new_h);
810         gui->resize_event(new_w, new_h);
813 void VWindowCanvas::close_source()
815         mwindow->vwindow->remove_source();
819 void VWindowCanvas::draw_refresh()
821         EDL *edl = gui->vwindow->get_edl();
823         if(!get_canvas()->get_video_on()) get_canvas()->clear_box(0, 0, get_canvas()->get_w(), get_canvas()->get_h());
824         if(!get_canvas()->get_video_on() && refresh_frame && edl)
825         {
826                 float in_x1, in_y1, in_x2, in_y2;
827                 float out_x1, out_y1, out_x2, out_y2;
828                 get_transfers(edl, 
829                         in_x1, 
830                         in_y1, 
831                         in_x2, 
832                         in_y2, 
833                         out_x1, 
834                         out_y1, 
835                         out_x2, 
836                         out_y2);
837                 get_canvas()->draw_vframe(refresh_frame,
838                                 (int)out_x1, 
839                                 (int)out_y1, 
840                                 (int)(out_x2 - out_x1), 
841                                 (int)(out_y2 - out_y1),
842                                 (int)in_x1, 
843                                 (int)in_y1, 
844                                 (int)(in_x2 - in_x1), 
845                                 (int)(in_y2 - in_y1),
846                                 0);
847         }
849         if(!get_canvas()->get_video_on())
850         {
851                 draw_overlays();
852                 get_canvas()->flash();
853         }
856 void VWindowCanvas::draw_overlays()
858         if(mwindow->session->vcanvas_highlighted)
859         {
860                 get_canvas()->set_color(WHITE);
861                 get_canvas()->set_inverse();
862                 get_canvas()->draw_rectangle(0, 0, get_canvas()->get_w(), get_canvas()->get_h());
863                 get_canvas()->draw_rectangle(1, 1, get_canvas()->get_w() - 2, get_canvas()->get_h() - 2);
864                 get_canvas()->set_opaque();
865         }
868 int VWindowCanvas::get_fullscreen()
870         return mwindow->session->vwindow_fullscreen;
873 void VWindowCanvas::set_fullscreen(int value)
875         mwindow->session->vwindow_fullscreen = value;
914 #if 0
915 void VWindowGUI::update_points()
917         EDL *edl = vwindow->get_edl();
919 //printf("VWindowGUI::update_points 1\n");
920         if(!edl) return;
922 //printf("VWindowGUI::update_points 2\n");
923         long pixel = (long)((double)edl->local_session->in_point / 
924                 edl->tracks->total_playable_length() *
925                 (mwindow->theme->vtimebar_w - 
926                         2 * 
927                         mwindow->theme->in_point[0]->get_w())) + 
928                 mwindow->theme->in_point[0]->get_w();
930 //printf("VWindowGUI::update_points 3 %d\n", edl->local_session->in_point);
931         if(in_point)
932         {
933 //printf("VWindowGUI::update_points 3.1\n");
934                 if(edl->local_session->in_point >= 0)
935                 {
936 //printf("VWindowGUI::update_points 4\n");
937                         if(edl->local_session->in_point != in_point->position ||
938                                 in_point->pixel != pixel)
939                         {
940                                 in_point->pixel = pixel;
941                                 in_point->reposition();
942                         }
944 //printf("VWindowGUI::update_points 5\n");
945                         in_point->position = edl->local_session->in_point;
947 //printf("VWindowGUI::update_points 6\n");
948                         if(edl->equivalent(in_point->position, edl->local_session->get_selectionstart(1)) ||
949                                 edl->equivalent(in_point->position, edl->local_session->get_selectionend(1)))
950                                 in_point->update(1);
951                         else
952                                 in_point->update(0);
953 //printf("VWindowGUI::update_points 7\n");
954                 }
955                 else
956                 {
957                         delete in_point;
958                         in_point = 0;
959                 }
960         }
961         else
962         if(edl->local_session->in_point >= 0)
963         {
964 //printf("VWindowGUI::update_points 8 %p\n", mwindow->theme->in_point);
965                 add_subwindow(in_point = 
966                         new VWindowInPoint(mwindow, 
967                                 0, 
968                                 this,
969                                 pixel, 
970                                 edl->local_session->in_point));
971 //printf("VWindowGUI::update_points 9\n");
972         }
973 //printf("VWindowGUI::update_points 10\n");
975         pixel = (long)((double)edl->local_session->out_point / 
976                 (edl->tracks->total_playable_length() + 0.5) *
977                 (mwindow->theme->vtimebar_w - 
978                         2 * 
979                         mwindow->theme->in_point[0]->get_w())) + 
980                 mwindow->theme->in_point[0]->get_w() * 
981                 2;
983         if(out_point)
984         {
985                 if(edl->local_session->out_point >= 0 && pixel >= 0 && pixel <= mwindow->theme->vtimebar_w)
986                 {
987                         if(edl->local_session->out_point != out_point->position ||
988                                 out_point->pixel != pixel) 
989                         {
990                                 out_point->pixel = pixel;
991                                 out_point->reposition();
992                         }
993                         out_point->position = edl->local_session->out_point;
995                         if(edl->equivalent(out_point->position, edl->local_session->get_selectionstart(1)) ||
996                                 edl->equivalent(out_point->position, edl->local_session->get_selectionend(1)))
997                                 out_point->update(1);
998                         else
999                                 out_point->update(0);
1000                 }
1001                 else
1002                 {
1003                         delete out_point;
1004                         out_point = 0;
1005                 }
1006         }
1007         else
1008         if(edl->local_session->out_point >= 0 && pixel >= 0 && pixel <= mwindow->theme->vtimebar_w)
1009         {
1010                 add_subwindow(out_point = 
1011                         new VWindowOutPoint(mwindow, 
1012                                 0, 
1013                                 this, 
1014                                 pixel, 
1015                                 edl->local_session->out_point));
1016         }
1020 void VWindowGUI::update_labels()
1022         EDL *edl = vwindow->get_edl();
1023         int output = 0;
1025         for(Label *current = edl->labels->first;
1026                 current;
1027                 current = NEXT)
1028         {
1029                 long pixel = (long)((current->position - edl->local_session->view_start) / edl->local_session->zoom_sample);
1031                 if(pixel >= 0 && pixel < mwindow->theme->vtimebar_w)
1032                 {
1033 // Create new label
1034                         if(output >= labels.total)
1035                         {
1036                                 LabelGUI *new_label;
1037                                 add_subwindow(new_label = new LabelGUI(mwindow, this, pixel, 0, current->position));
1038                                 labels.append(new_label);
1039                         }
1040                         else
1041 // Reposition old label
1042                         if(labels.values[output]->pixel != pixel)
1043                         {
1044                                 labels.values[output]->pixel = pixel;
1045                                 labels.values[output]->position = current->position;
1046                                 labels.values[output]->reposition();
1047                         }
1049                         if(mwindow->edl->local_session->get_selectionstart(1) <= current->position &&
1050                                 mwindow->edl->local_session->get_selectionend(1) >= current->position)
1051                                 labels.values[output]->update(1);
1052                         else
1053                         if(labels.values[output]->get_value())
1054                                 labels.values[output]->update(0);
1055                         output++;
1056                 }
1057         }
1059 // Delete excess labels
1060         while(labels.total > output)
1061         {
1062                 labels.remove_object();
1063         }
1068 VWindowInPoint::VWindowInPoint(MWindow *mwindow, 
1069                 TimeBar *timebar, 
1070                 VWindowGUI *gui,
1071                 long pixel, 
1072                 double position)
1073  : InPointGUI(mwindow, 
1074                 timebar, 
1075                 pixel, 
1076                 position)
1078         this->gui = gui;
1081 int VWindowInPoint::handle_event()
1083         EDL *edl = gui->vwindow->get_edl();
1085         if(edl)
1086         {
1087                 double position = edl->align_to_frame(this->position, 0);
1089                 edl->local_session->set_selectionstart(position);
1090                 edl->local_session->set_selectionend(position);
1091                 gui->timebar->update();
1093 // Que the VWindow
1094                 mwindow->vwindow->update_position(CHANGE_NONE, 0, 1);
1095         }
1096         return 1;
1101 VWindowOutPoint::VWindowOutPoint(MWindow *mwindow, 
1102                 TimeBar *timebar, 
1103                 VWindowGUI *gui,
1104                 long pixel, 
1105                 double position)
1106  : OutPointGUI(mwindow, 
1107                 timebar, 
1108                 pixel, 
1109                 position)
1111         this->gui = gui;
1114 int VWindowOutPoint::handle_event()
1116         EDL *edl = gui->vwindow->get_edl();
1118         if(edl)
1119         {
1120                 double position = edl->align_to_frame(this->position, 0);
1122                 edl->local_session->set_selectionstart(position);
1123                 edl->local_session->set_selectionend(position);
1124                 gui->timebar->update();
1126 // Que the VWindow
1127                 mwindow->vwindow->update_position(CHANGE_NONE, 0, 1);
1128         }
1130         return 1;
1135 #endif