r1009: Move the dependencies to newer package names
[cinelerra_cv/mob.git] / cinelerra / vwindowgui.C
blob6ac027a69135107d30be6fd182d2fad8095c5363
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;
52         strcpy(loaded_title, "");
55 VWindowGUI::~VWindowGUI()
57         delete canvas;
58         delete transport;
61 void VWindowGUI::change_source(EDL *edl, char *title)
63         update_sources(title);
64         char string[BCTEXTLEN];
65         if(title[0]) 
66                 sprintf(string, PROGRAM_NAME ": %s", title);
67         else
68                 sprintf(string, PROGRAM_NAME);
69         strcpy(loaded_title, title);
70         lock_window("VWindowGUI::change_source");
71         slider->set_position();
72         timebar->update();
73         set_title(string);
74         unlock_window();
78 // Get source list from master EDL
79 void VWindowGUI::update_sources(char *title)
81         lock_window("VWindowGUI::update_sources");
83 //printf("VWindowGUI::update_sources 1\n");
84         sources.remove_all_objects();
85 //printf("VWindowGUI::update_sources 2\n");
89         for(int i = 0;
90                 i < mwindow->edl->clips.total;
91                 i++)
92         {
93                 char *clip_title = mwindow->edl->clips.values[i]->local_session->clip_title;
94                 int exists = 0;
96                 for(int j = 0; j < sources.total; j++)
97                 {
98                         if(!strcasecmp(sources.values[j]->get_text(), clip_title))
99                         {
100                                 exists = 1;
101                         }
102                 }
104                 if(!exists)
105                 {
106                         sources.append(new BC_ListBoxItem(clip_title));
107                 }
108         }
109 //printf("VWindowGUI::update_sources 3\n");
111         FileSystem fs;
112         for(Asset *current = mwindow->edl->assets->first; 
113                 current;
114                 current = NEXT)
115         {
116                 char clip_title[BCTEXTLEN];
117                 fs.extract_name(clip_title, current->path);
118                 int exists = 0;
119                 
120                 for(int j = 0; j < sources.total; j++)
121                 {
122                         if(!strcasecmp(sources.values[j]->get_text(), clip_title))
123                         {
124                                 exists = 1;
125                         }
126                 }
127                 
128                 if(!exists)
129                 {
130                         sources.append(new BC_ListBoxItem(clip_title));
131                 }
132         }
134 //printf("VWindowGUI::update_sources 4\n");
136 //      source->update_list(&sources);
137 //      source->update(title);
138         unlock_window();
141 int VWindowGUI::create_objects()
143         in_point = 0;
144         out_point = 0;
145         set_icon(mwindow->theme->get_image("vwindow_icon"));
147 //printf("VWindowGUI::create_objects 1\n");
148         mwindow->theme->get_vwindow_sizes(this);
149         mwindow->theme->draw_vwindow_bg(this);
150         flash();
152         meters = new VWindowMeters(mwindow, 
153                 this,
154                 mwindow->theme->vmeter_x,
155                 mwindow->theme->vmeter_y,
156                 mwindow->theme->vmeter_h);
157         meters->create_objects();
159 //printf("VWindowGUI::create_objects 1\n");
160 // Requires meters to build
161         edit_panel = new VWindowEditing(mwindow, vwindow);
162         edit_panel->set_meters(meters);
163         edit_panel->create_objects();
165 //printf("VWindowGUI::create_objects 1\n");
166         add_subwindow(slider = new VWindowSlider(mwindow, 
167         vwindow, 
168                 this, 
169         mwindow->theme->vslider_x, 
170         mwindow->theme->vslider_y, 
171         mwindow->theme->vslider_w));
173 //printf("VWindowGUI::create_objects 1\n");
174         transport = new VWindowTransport(mwindow, 
175                 this, 
176                 mwindow->theme->vtransport_x, 
177                 mwindow->theme->vtransport_y);
178     transport->create_objects();
179         transport->set_slider(slider);
181 //printf("VWindowGUI::create_objects 1\n");
182 //      add_subwindow(fps_title = new BC_Title(mwindow->theme->vedit_x, y, ""));
183     add_subwindow(clock = new MainClock(mwindow,
184                 mwindow->theme->vtime_x, 
185                 mwindow->theme->vtime_y,
186                 mwindow->theme->vtime_w));
188         canvas = new VWindowCanvas(mwindow, this);
189         canvas->create_objects(mwindow->edl);
193 //printf("VWindowGUI::create_objects 1\n");
194         add_subwindow(timebar = new VTimeBar(mwindow, 
195                 this,
196                 mwindow->theme->vtimebar_x,
197                 mwindow->theme->vtimebar_y,
198                 mwindow->theme->vtimebar_w, 
199                 mwindow->theme->vtimebar_h));
200         timebar->create_objects();
201 //printf("VWindowGUI::create_objects 2\n");
204 //printf("VWindowGUI::create_objects 1\n");
205 //      source = new VWindowSource(mwindow, 
206 //              this, 
207 //              mwindow->theme->vsource_x,
208 //              mwindow->theme->vsource_y);
209 //      source->create_objects();       
210         update_sources(_("None"));
212 //printf("VWindowGUI::create_objects 2\n");
213         deactivate();
214         slider->activate();
215         return 0;
218 int VWindowGUI::resize_event(int w, int h)
220         mwindow->session->vwindow_x = get_x();
221         mwindow->session->vwindow_y = get_y();
222         mwindow->session->vwindow_w = w;
223         mwindow->session->vwindow_h = h;
225         mwindow->theme->get_vwindow_sizes(this);
226         mwindow->theme->draw_vwindow_bg(this);
227         flash();
229         edit_panel->reposition_buttons(mwindow->theme->vedit_x, 
230                 mwindow->theme->vedit_y);
231         slider->reposition_window(mwindow->theme->vslider_x, 
232         mwindow->theme->vslider_y, 
233         mwindow->theme->vslider_w);
234 // Recalibrate pointer motion range
235         slider->set_position();
236         timebar->resize_event();
237         transport->reposition_buttons(mwindow->theme->vtransport_x, 
238                 mwindow->theme->vtransport_y);
239         clock->reposition_window(mwindow->theme->vtime_x, 
240                 mwindow->theme->vtime_y,
241                 mwindow->theme->vtime_w);
242         canvas->reposition_window(0,
243                 mwindow->theme->vcanvas_x, 
244                 mwindow->theme->vcanvas_y, 
245                 mwindow->theme->vcanvas_w, 
246                 mwindow->theme->vcanvas_h);
247 //      source->reposition_window(mwindow->theme->vsource_x,
248 //              mwindow->theme->vsource_y);
249         meters->reposition_window(mwindow->theme->vmeter_x,
250                 mwindow->theme->vmeter_y,
251                 mwindow->theme->vmeter_h);
253         BC_WindowBase::resize_event(w, h);
254         return 1;
261 int VWindowGUI::translation_event()
263         mwindow->session->vwindow_x = get_x();
264         mwindow->session->vwindow_y = get_y();
265         return 0;
268 int VWindowGUI::close_event()
270         hide_window();
271         mwindow->session->show_vwindow = 0;
272         unlock_window();
273         
274         
275         mwindow->gui->lock_window("VWindowGUI::close_event");
276         mwindow->gui->mainmenu->show_vwindow->set_checked(0);
277         mwindow->gui->unlock_window();
279         lock_window("VWindowGUI::close_event");
280         mwindow->save_defaults();
281         return 1;
284 int VWindowGUI::keypress_event()
286         int result = 0;
287         switch(get_keypress())
288         {
289                 case 'w':
290                 case 'W':
291                         close_event();
292                         result = 1;
293                         break;
294                 case 'z':
295                         mwindow->undo_entry(this);
296                         break;
297                 case 'Z':
298                         mwindow->redo_entry(this);
299                         break;
300                 case 'f':
301                         unlock_window();
302                         if(mwindow->session->vwindow_fullscreen)
303                                 canvas->stop_fullscreen();
304                         else
305                                 canvas->start_fullscreen();
306                         lock_window("VWindowGUI::keypress_event 1");
307                         break;
308                 case ESC:
309                         unlock_window();
310                         if(mwindow->session->vwindow_fullscreen)
311                                 canvas->stop_fullscreen();
312                         lock_window("VWindowGUI::keypress_event 2");
313                         break;
314         }
315         if(!result) result = transport->keypress_event();
316         
317         return result;
320 int VWindowGUI::button_press_event()
322         if(canvas->get_canvas())
323                 return canvas->button_press_event_base(canvas->get_canvas());
324         return 0;
327 int VWindowGUI::cursor_leave_event()
329         if(canvas->get_canvas())
330                 return canvas->cursor_leave_event_base(canvas->get_canvas());
331         return 0;
334 int VWindowGUI::cursor_enter_event()
336         if(canvas->get_canvas())
337                 return canvas->cursor_enter_event_base(canvas->get_canvas());
338         return 0;
341 int VWindowGUI::button_release_event()
343         if(canvas->get_canvas())
344                 return canvas->button_release_event();
345         return 0;
348 int VWindowGUI::cursor_motion_event()
350         if(canvas->get_canvas())
351         {
352                 canvas->get_canvas()->unhide_cursor();
353                 return canvas->cursor_motion_event();
354         }
355         return 0;
359 void VWindowGUI::drag_motion()
361         if(get_hidden()) return;
362         if(mwindow->session->current_operation != DRAG_ASSET) return;
364         int old_status = mwindow->session->vcanvas_highlighted;
366         int cursor_x = get_relative_cursor_x();
367         int cursor_y = get_relative_cursor_y();
368         
369         mwindow->session->vcanvas_highlighted = (get_cursor_over_window() &&
370                 cursor_x >= canvas->x &&
371                 cursor_x < canvas->x + canvas->w &&
372                 cursor_y >= canvas->y &&
373                 cursor_y < canvas->y + canvas->h);
374 //printf("VWindowGUI::drag_motion 1 %d\n", mwindow->session->vcanvas_highlighted);
377         if(old_status != mwindow->session->vcanvas_highlighted)
378                 canvas->draw_refresh();
381 int VWindowGUI::drag_stop()
383         if(get_hidden()) return 0;
385         if(mwindow->session->vcanvas_highlighted &&
386                 mwindow->session->current_operation == DRAG_ASSET)
387         {
388                 mwindow->session->vcanvas_highlighted = 0;
389                 canvas->draw_refresh();
391                 Asset *asset = mwindow->session->drag_assets->total ?
392                         mwindow->session->drag_assets->values[0] :
393                         0;
394                 EDL *edl = mwindow->session->drag_clips->total ?
395                         mwindow->session->drag_clips->values[0] :
396                         0;
397                 
398                 if(asset)
399                         vwindow->change_source(asset);
400                 else
401                 if(edl)
402                         vwindow->change_source(edl);
403                 return 1;
404         }
406         return 0;
413 VWindowMeters::VWindowMeters(MWindow *mwindow, 
414         VWindowGUI *gui, 
415         int x, 
416         int y, 
417         int h)
418  : MeterPanel(mwindow, 
419                 gui,
420                 x,
421                 y,
422                 h,
423                 mwindow->edl->session->audio_channels,
424                 mwindow->edl->session->vwindow_meter)
426         this->mwindow = mwindow;
427         this->gui = gui;
430 VWindowMeters::~VWindowMeters()
434 int VWindowMeters::change_status_event()
436         mwindow->edl->session->vwindow_meter = use_meters;
437 //printf("VWindowMeters::change_status_event 1 %d\n", mwindow->edl->session->vwindow_meter);
438         mwindow->theme->get_vwindow_sizes(gui);
439         gui->resize_event(gui->get_w(), gui->get_h());
440         return 1;
449 VWindowEditing::VWindowEditing(MWindow *mwindow, VWindow *vwindow)
450  : EditPanel(mwindow, 
451                 vwindow->gui, 
452                 mwindow->theme->vedit_x, 
453                 mwindow->theme->vedit_y,
454                 EDITING_ARROW, 
455                 0,
456                 0,
457                 1, 
458                 1,
459                 0,
460                 0,
461                 1, 
462                 0,
463                 0,
464                 0,
465                 0, // locklabels
466                 1,
467                 1,
468                 1,
469                 0,
470                 0)
472         this->mwindow = mwindow;
473         this->vwindow = vwindow;
476 VWindowEditing::~VWindowEditing()
480 void VWindowEditing::copy_selection()
482         vwindow->copy();
485 void VWindowEditing::splice_selection()
487         if(vwindow->get_edl())
488         {
489                 mwindow->gui->lock_window("VWindowEditing::splice_selection");
490                 mwindow->splice(vwindow->get_edl());
491                 mwindow->gui->unlock_window();
492         }
495 void VWindowEditing::overwrite_selection()
497         if(vwindow->get_edl())
498         {
499                 mwindow->gui->lock_window("VWindowEditing::overwrite_selection");
500                 mwindow->overwrite(vwindow->get_edl());
501                 mwindow->gui->unlock_window();
502         }
505 void VWindowEditing::toggle_label()
507         if(vwindow->get_edl())
508         {
509                 EDL *edl = vwindow->get_edl();
510                 edl->labels->toggle_label(edl->local_session->get_selectionstart(1),
511                         edl->local_session->get_selectionend(1));
512                 vwindow->gui->timebar->update();
513         }
516 void VWindowEditing::prev_label()
518         if(vwindow->get_edl())
519         {
520                 EDL *edl = vwindow->get_edl();
521                 vwindow->gui->unlock_window();
522                 vwindow->playback_engine->interrupt_playback(1);
523                 vwindow->gui->lock_window("VWindowEditing::prev_label");
525                 Label *current = edl->labels->prev_label(
526                         edl->local_session->get_selectionstart(1));
527                 
529                 if(!current)
530                 {
531                         edl->local_session->set_selectionstart(0);
532                         edl->local_session->set_selectionend(0);
533                         vwindow->update_position(CHANGE_NONE, 0, 1);
534                         vwindow->gui->timebar->update();
535                 }
536                 else
537                 {
538                         edl->local_session->set_selectionstart(current->position);
539                         edl->local_session->set_selectionend(current->position);
540                         vwindow->update_position(CHANGE_NONE, 0, 1);
541                         vwindow->gui->timebar->update();
542                 }
543         }
546 void VWindowEditing::next_label()
548         if(vwindow->get_edl())
549         {
550                 EDL *edl = vwindow->get_edl();
551                 Label *current = edl->labels->next_label(
552                         edl->local_session->get_selectionstart(1));
553                 if(!current)
554                 {
555                         vwindow->gui->unlock_window();
556                         vwindow->playback_engine->interrupt_playback(1);
557                         vwindow->gui->lock_window("VWindowEditing::next_label 1");
559                         double position = edl->tracks->total_length();
560                         edl->local_session->set_selectionstart(position);
561                         edl->local_session->set_selectionend(position);
562                         vwindow->update_position(CHANGE_NONE, 0, 1);
563                         vwindow->gui->timebar->update();
564                 }
565                 else
566                 {
567                         vwindow->gui->unlock_window();
568                         vwindow->playback_engine->interrupt_playback(1);
569                         vwindow->gui->lock_window("VWindowEditing::next_label 2");
571                         edl->local_session->set_selectionstart(current->position);
572                         edl->local_session->set_selectionend(current->position);
573                         vwindow->update_position(CHANGE_NONE, 0, 1);
574                         vwindow->gui->timebar->update();
575                 }
576         }
579 void VWindowEditing::set_inpoint()
581         vwindow->set_inpoint();
584 void VWindowEditing::set_outpoint()
586         vwindow->set_outpoint();
589 void VWindowEditing::clear_inpoint()
591         vwindow->clear_inpoint();
594 void VWindowEditing::clear_outpoint()
596         vwindow->clear_outpoint();
599 void VWindowEditing::to_clip()
601         if(vwindow->get_edl())
602         {
603                 FileXML file;
604                 EDL *edl = vwindow->get_edl();
605                 double start = edl->local_session->get_selectionstart();
606                 double end = edl->local_session->get_selectionend();
608                 if(EQUIV(start, end))
609                 {
610                         end = edl->tracks->total_length();
611                         start = 0;
612                 }
616                 edl->copy(start, 
617                         end, 
618                         1,
619                         0,
620                         0,
621                         &file,
622                         mwindow->plugindb,
623                         "",
624                         1);
629                 EDL *new_edl = new EDL(mwindow->edl);
630                 new_edl->create_objects();
631                 new_edl->load_xml(mwindow->plugindb, &file, LOAD_ALL);
632                 sprintf(new_edl->local_session->clip_title, _("Clip %d"), mwindow->session->clip_number++);
633                 char string[BCTEXTLEN];
634                 Units::totext(string, 
635                                 end - start, 
636                                 edl->session->time_format, 
637                                 edl->session->sample_rate, 
638                                 edl->session->frame_rate,
639                                 edl->session->frames_per_foot);
641                 sprintf(new_edl->local_session->clip_notes, _("%s\n Created from:\n%s"), string, vwindow->gui->loaded_title);
643                 new_edl->local_session->set_selectionstart(0);
644                 new_edl->local_session->set_selectionend(0);
647 //printf("VWindowEditing::to_clip 1 %s\n", edl->local_session->clip_title);
648                 new_edl->local_session->set_selectionstart(0.0);
649                 new_edl->local_session->set_selectionend(0.0);
650                 vwindow->clip_edit->create_clip(new_edl);
651         }
659 VWindowSlider::VWindowSlider(MWindow *mwindow, 
660         VWindow *vwindow, 
661         VWindowGUI *gui,
662         int x, 
663         int y, 
664         int pixels)
665  : BC_PercentageSlider(x, 
666                         y,
667                         0,
668                         pixels, 
669                         pixels, 
670                         0, 
671                         1, 
672                         0)
674         this->mwindow = mwindow;
675         this->vwindow = vwindow;
676         this->gui = gui;
677         set_precision(0.00001);
678         set_pagination(1.0, 10.0);
681 VWindowSlider::~VWindowSlider()
685 int VWindowSlider::handle_event()
687         unlock_window();
688         vwindow->playback_engine->interrupt_playback(1);
689         lock_window("VWindowSlider::handle_event");
691         vwindow->update_position(CHANGE_NONE, 1, 0);
692         gui->timebar->update();
693         return 1;
696 void VWindowSlider::set_position()
698         EDL *edl = vwindow->get_edl();
699         if(edl)
700         {
701                 double new_length = edl->tracks->total_playable_length();
702                 if(EQUIV(edl->local_session->preview_end, 0))
703                         edl->local_session->preview_end = new_length;
704                 if(edl->local_session->preview_end > new_length)
705                         edl->local_session->preview_end = new_length;
706                 if(edl->local_session->preview_start > new_length)
707                         edl->local_session->preview_start = 0;
709                 update(mwindow->theme->vslider_w, 
710                         edl->local_session->get_selectionstart(1), 
711                         edl->local_session->preview_start, 
712                         edl->local_session->preview_end);
713         }
724 VWindowSource::VWindowSource(MWindow *mwindow, VWindowGUI *vwindow, int x, int y)
725  : BC_PopupTextBox(vwindow, 
726         &vwindow->sources, 
727         "",
728         x, 
729         y, 
730         200, 
731         200)
733         this->mwindow = mwindow;
734         this->vwindow = vwindow;
737 VWindowSource::~VWindowSource()
741 int VWindowSource::handle_event()
743         return 1;
752 VWindowTransport::VWindowTransport(MWindow *mwindow, 
753         VWindowGUI *gui, 
754         int x, 
755         int y)
756  : PlayTransport(mwindow, 
757         gui, 
758         x, 
759         y)
761         this->gui = gui;
764 EDL* VWindowTransport::get_edl()
766         return gui->vwindow->get_edl();
770 void VWindowTransport::goto_start()
772         gui->unlock_window();
773         handle_transport(REWIND, 1);
774         gui->lock_window("VWindowTransport::goto_start");
775         gui->vwindow->goto_start();
778 void VWindowTransport::goto_end()
780         gui->unlock_window();
781         handle_transport(GOTO_END, 1);
782         gui->lock_window("VWindowTransport::goto_end");
783         gui->vwindow->goto_end();
789 VWindowCanvas::VWindowCanvas(MWindow *mwindow, VWindowGUI *gui)
790  : Canvas(mwindow,
791         gui,
792         mwindow->theme->vcanvas_x, 
793         mwindow->theme->vcanvas_y, 
794         mwindow->theme->vcanvas_w, 
795         mwindow->theme->vcanvas_h,
796         0,
797         0,
798         0,
799         0,
800         0,
801         1)
803         this->mwindow = mwindow;
804         this->gui = gui;
807 void VWindowCanvas::zoom_resize_window(float percentage)
809         EDL *edl = mwindow->vwindow->get_edl();
810         if(!edl) edl = mwindow->edl;
812         int canvas_w, canvas_h;
813         calculate_sizes(edl->get_aspect_ratio(), 
814                 edl->session->output_w, 
815                 edl->session->output_h, 
816                 percentage,
817                 canvas_w,
818                 canvas_h);
819         int new_w, new_h;
820         new_w = canvas_w + (gui->get_w() - mwindow->theme->vcanvas_w);
821         new_h = canvas_h + (gui->get_h() - mwindow->theme->vcanvas_h);
822         gui->resize_window(new_w, new_h);
823         gui->resize_event(new_w, new_h);
826 void VWindowCanvas::close_source()
828         mwindow->vwindow->remove_source();
832 void VWindowCanvas::draw_refresh()
834         EDL *edl = gui->vwindow->get_edl();
836         if(!get_canvas()->get_video_on()) get_canvas()->clear_box(0, 0, get_canvas()->get_w(), get_canvas()->get_h());
837         if(!get_canvas()->get_video_on() && refresh_frame && edl)
838         {
839                 float in_x1, in_y1, in_x2, in_y2;
840                 float out_x1, out_y1, out_x2, out_y2;
841                 get_transfers(edl, 
842                         in_x1, 
843                         in_y1, 
844                         in_x2, 
845                         in_y2, 
846                         out_x1, 
847                         out_y1, 
848                         out_x2, 
849                         out_y2);
850                 get_canvas()->draw_vframe(refresh_frame,
851                                 (int)out_x1, 
852                                 (int)out_y1, 
853                                 (int)(out_x2 - out_x1), 
854                                 (int)(out_y2 - out_y1),
855                                 (int)in_x1, 
856                                 (int)in_y1, 
857                                 (int)(in_x2 - in_x1), 
858                                 (int)(in_y2 - in_y1),
859                                 0);
860         }
862         if(!get_canvas()->get_video_on())
863         {
864                 draw_overlays();
865                 get_canvas()->flash();
866         }
869 void VWindowCanvas::draw_overlays()
871         if(mwindow->session->vcanvas_highlighted)
872         {
873                 get_canvas()->set_color(WHITE);
874                 get_canvas()->set_inverse();
875                 get_canvas()->draw_rectangle(0, 0, get_canvas()->get_w(), get_canvas()->get_h());
876                 get_canvas()->draw_rectangle(1, 1, get_canvas()->get_w() - 2, get_canvas()->get_h() - 2);
877                 get_canvas()->set_opaque();
878         }
881 int VWindowCanvas::get_fullscreen()
883         return mwindow->session->vwindow_fullscreen;
886 void VWindowCanvas::set_fullscreen(int value)
888         mwindow->session->vwindow_fullscreen = value;
927 #if 0
928 void VWindowGUI::update_points()
930         EDL *edl = vwindow->get_edl();
932 //printf("VWindowGUI::update_points 1\n");
933         if(!edl) return;
935 //printf("VWindowGUI::update_points 2\n");
936         long pixel = (long)((double)edl->local_session->in_point / 
937                 edl->tracks->total_playable_length() *
938                 (mwindow->theme->vtimebar_w - 
939                         2 * 
940                         mwindow->theme->in_point[0]->get_w())) + 
941                 mwindow->theme->in_point[0]->get_w();
943 //printf("VWindowGUI::update_points 3 %d\n", edl->local_session->in_point);
944         if(in_point)
945         {
946 //printf("VWindowGUI::update_points 3.1\n");
947                 if(edl->local_session->in_point >= 0)
948                 {
949 //printf("VWindowGUI::update_points 4\n");
950                         if(edl->local_session->in_point != in_point->position ||
951                                 in_point->pixel != pixel)
952                         {
953                                 in_point->pixel = pixel;
954                                 in_point->reposition();
955                         }
957 //printf("VWindowGUI::update_points 5\n");
958                         in_point->position = edl->local_session->in_point;
960 //printf("VWindowGUI::update_points 6\n");
961                         if(edl->equivalent(in_point->position, edl->local_session->get_selectionstart(1)) ||
962                                 edl->equivalent(in_point->position, edl->local_session->get_selectionend(1)))
963                                 in_point->update(1);
964                         else
965                                 in_point->update(0);
966 //printf("VWindowGUI::update_points 7\n");
967                 }
968                 else
969                 {
970                         delete in_point;
971                         in_point = 0;
972                 }
973         }
974         else
975         if(edl->local_session->in_point >= 0)
976         {
977 //printf("VWindowGUI::update_points 8 %p\n", mwindow->theme->in_point);
978                 add_subwindow(in_point = 
979                         new VWindowInPoint(mwindow, 
980                                 0, 
981                                 this,
982                                 pixel, 
983                                 edl->local_session->in_point));
984 //printf("VWindowGUI::update_points 9\n");
985         }
986 //printf("VWindowGUI::update_points 10\n");
988         pixel = (long)((double)edl->local_session->out_point / 
989                 (edl->tracks->total_playable_length() + 0.5) *
990                 (mwindow->theme->vtimebar_w - 
991                         2 * 
992                         mwindow->theme->in_point[0]->get_w())) + 
993                 mwindow->theme->in_point[0]->get_w() * 
994                 2;
996         if(out_point)
997         {
998                 if(edl->local_session->out_point >= 0 && pixel >= 0 && pixel <= mwindow->theme->vtimebar_w)
999                 {
1000                         if(edl->local_session->out_point != out_point->position ||
1001                                 out_point->pixel != pixel) 
1002                         {
1003                                 out_point->pixel = pixel;
1004                                 out_point->reposition();
1005                         }
1006                         out_point->position = edl->local_session->out_point;
1008                         if(edl->equivalent(out_point->position, edl->local_session->get_selectionstart(1)) ||
1009                                 edl->equivalent(out_point->position, edl->local_session->get_selectionend(1)))
1010                                 out_point->update(1);
1011                         else
1012                                 out_point->update(0);
1013                 }
1014                 else
1015                 {
1016                         delete out_point;
1017                         out_point = 0;
1018                 }
1019         }
1020         else
1021         if(edl->local_session->out_point >= 0 && pixel >= 0 && pixel <= mwindow->theme->vtimebar_w)
1022         {
1023                 add_subwindow(out_point = 
1024                         new VWindowOutPoint(mwindow, 
1025                                 0, 
1026                                 this, 
1027                                 pixel, 
1028                                 edl->local_session->out_point));
1029         }
1033 void VWindowGUI::update_labels()
1035         EDL *edl = vwindow->get_edl();
1036         int output = 0;
1038         for(Label *current = edl->labels->first;
1039                 current;
1040                 current = NEXT)
1041         {
1042                 long pixel = (long)((current->position - edl->local_session->view_start) / edl->local_session->zoom_sample);
1044                 if(pixel >= 0 && pixel < mwindow->theme->vtimebar_w)
1045                 {
1046 // Create new label
1047                         if(output >= labels.total)
1048                         {
1049                                 LabelGUI *new_label;
1050                                 add_subwindow(new_label = new LabelGUI(mwindow, this, pixel, 0, current->position));
1051                                 labels.append(new_label);
1052                         }
1053                         else
1054 // Reposition old label
1055                         if(labels.values[output]->pixel != pixel)
1056                         {
1057                                 labels.values[output]->pixel = pixel;
1058                                 labels.values[output]->position = current->position;
1059                                 labels.values[output]->reposition();
1060                         }
1062                         if(mwindow->edl->local_session->get_selectionstart(1) <= current->position &&
1063                                 mwindow->edl->local_session->get_selectionend(1) >= current->position)
1064                                 labels.values[output]->update(1);
1065                         else
1066                         if(labels.values[output]->get_value())
1067                                 labels.values[output]->update(0);
1068                         output++;
1069                 }
1070         }
1072 // Delete excess labels
1073         while(labels.total > output)
1074         {
1075                 labels.remove_object();
1076         }
1081 VWindowInPoint::VWindowInPoint(MWindow *mwindow, 
1082                 TimeBar *timebar, 
1083                 VWindowGUI *gui,
1084                 long pixel, 
1085                 double position)
1086  : InPointGUI(mwindow, 
1087                 timebar, 
1088                 pixel, 
1089                 position)
1091         this->gui = gui;
1094 int VWindowInPoint::handle_event()
1096         EDL *edl = gui->vwindow->get_edl();
1098         if(edl)
1099         {
1100                 double position = edl->align_to_frame(this->position, 0);
1102                 edl->local_session->set_selectionstart(position);
1103                 edl->local_session->set_selectionend(position);
1104                 gui->timebar->update();
1106 // Que the VWindow
1107                 mwindow->vwindow->update_position(CHANGE_NONE, 0, 1);
1108         }
1109         return 1;
1114 VWindowOutPoint::VWindowOutPoint(MWindow *mwindow, 
1115                 TimeBar *timebar, 
1116                 VWindowGUI *gui,
1117                 long pixel, 
1118                 double position)
1119  : OutPointGUI(mwindow, 
1120                 timebar, 
1121                 pixel, 
1122                 position)
1124         this->gui = gui;
1127 int VWindowOutPoint::handle_event()
1129         EDL *edl = gui->vwindow->get_edl();
1131         if(edl)
1132         {
1133                 double position = edl->align_to_frame(this->position, 0);
1135                 edl->local_session->set_selectionstart(position);
1136                 edl->local_session->set_selectionend(position);
1137                 gui->timebar->update();
1139 // Que the VWindow
1140                 mwindow->vwindow->update_position(CHANGE_NONE, 0, 1);
1141         }
1143         return 1;
1148 #endif