Merge branch 'ct' of git.pipapo.org:cinelerra-ct into ct
[cinelerra_cv/ct.git] / cinelerra / vwindowgui.C
blobe3e89e05497a1fc524637d2f64e49c6fff20f7e6
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(Assets_list::iterator current = mwindow->edl->assets->begin(); 
113                 current != mwindow->edl->assets->end();
114                 ++current)
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_GC asset;
392                 if (!mwindow->session->drag_assets.empty())
393                         asset = mwindow->session->drag_assets[0];
395                 EDL *edl = mwindow->session->drag_clips->total ?
396                         mwindow->session->drag_clips->values[0] :
397                         0;
398                 
399                 if(asset)
400                         vwindow->change_source(asset);
401                 else
402                 if(edl)
403                         vwindow->change_source(edl);
404                 return 1;
405         }
407         return 0;
414 VWindowMeters::VWindowMeters(MWindow *mwindow, 
415         VWindowGUI *gui, 
416         int x, 
417         int y, 
418         int h)
419  : MeterPanel(mwindow, 
420                 gui,
421                 x,
422                 y,
423                 h,
424                 mwindow->edl->session->audio_channels,
425                 mwindow->edl->session->vwindow_meter)
427         this->mwindow = mwindow;
428         this->gui = gui;
431 VWindowMeters::~VWindowMeters()
435 int VWindowMeters::change_status_event()
437         mwindow->edl->session->vwindow_meter = use_meters;
438 //printf("VWindowMeters::change_status_event 1 %d\n", mwindow->edl->session->vwindow_meter);
439         mwindow->theme->get_vwindow_sizes(gui);
440         gui->resize_event(gui->get_w(), gui->get_h());
441         return 1;
450 VWindowEditing::VWindowEditing(MWindow *mwindow, VWindow *vwindow)
451  : EditPanel(mwindow, 
452                 vwindow->gui, 
453                 mwindow->theme->vedit_x, 
454                 mwindow->theme->vedit_y,
455                 EDITING_ARROW, 
456                 0,
457                 0,
458                 1, 
459                 1,
460                 0,
461                 0,
462                 1, 
463                 0,
464                 0,
465                 0,
466                 0, // locklabels
467                 1,
468                 1,
469                 1,
470                 0,
471                 0)
473         this->mwindow = mwindow;
474         this->vwindow = vwindow;
477 VWindowEditing::~VWindowEditing()
481 void VWindowEditing::copy_selection()
483         vwindow->copy();
486 void VWindowEditing::splice_selection()
488         if(vwindow->get_edl())
489         {
490                 mwindow->gui->lock_window("VWindowEditing::splice_selection");
491                 mwindow->splice(vwindow->get_edl());
492                 mwindow->gui->unlock_window();
493         }
496 void VWindowEditing::overwrite_selection()
498         if(vwindow->get_edl())
499         {
500                 mwindow->gui->lock_window("VWindowEditing::overwrite_selection");
501                 mwindow->overwrite(vwindow->get_edl());
502                 mwindow->gui->unlock_window();
503         }
506 void VWindowEditing::toggle_label()
508         if(vwindow->get_edl())
509         {
510                 EDL *edl = vwindow->get_edl();
511                 edl->labels->toggle_label(edl->local_session->get_selectionstart(1),
512                         edl->local_session->get_selectionend(1));
513                 vwindow->gui->timebar->update();
514         }
517 void VWindowEditing::prev_label()
519         if(vwindow->get_edl())
520         {
521                 EDL *edl = vwindow->get_edl();
522                 vwindow->gui->unlock_window();
523                 vwindow->playback_engine->interrupt_playback(1);
524                 vwindow->gui->lock_window("VWindowEditing::prev_label");
526                 Label *current = edl->labels->prev_label(
527                         edl->local_session->get_selectionstart(1));
528                 
530                 if(!current)
531                 {
532                         edl->local_session->set_selectionstart(0);
533                         edl->local_session->set_selectionend(0);
534                         vwindow->update_position(CHANGE_NONE, 0, 1);
535                         vwindow->gui->timebar->update();
536                 }
537                 else
538                 {
539                         edl->local_session->set_selectionstart(current->position);
540                         edl->local_session->set_selectionend(current->position);
541                         vwindow->update_position(CHANGE_NONE, 0, 1);
542                         vwindow->gui->timebar->update();
543                 }
544         }
547 void VWindowEditing::next_label()
549         if(vwindow->get_edl())
550         {
551                 EDL *edl = vwindow->get_edl();
552                 Label *current = edl->labels->next_label(
553                         edl->local_session->get_selectionstart(1));
554                 if(!current)
555                 {
556                         vwindow->gui->unlock_window();
557                         vwindow->playback_engine->interrupt_playback(1);
558                         vwindow->gui->lock_window("VWindowEditing::next_label 1");
560                         double position = edl->tracks->total_length();
561                         edl->local_session->set_selectionstart(position);
562                         edl->local_session->set_selectionend(position);
563                         vwindow->update_position(CHANGE_NONE, 0, 1);
564                         vwindow->gui->timebar->update();
565                 }
566                 else
567                 {
568                         vwindow->gui->unlock_window();
569                         vwindow->playback_engine->interrupt_playback(1);
570                         vwindow->gui->lock_window("VWindowEditing::next_label 2");
572                         edl->local_session->set_selectionstart(current->position);
573                         edl->local_session->set_selectionend(current->position);
574                         vwindow->update_position(CHANGE_NONE, 0, 1);
575                         vwindow->gui->timebar->update();
576                 }
577         }
580 void VWindowEditing::set_inpoint()
582         vwindow->set_inpoint();
585 void VWindowEditing::set_outpoint()
587         vwindow->set_outpoint();
590 void VWindowEditing::clear_inpoint()
592         vwindow->clear_inpoint();
595 void VWindowEditing::clear_outpoint()
597         vwindow->clear_outpoint();
600 void VWindowEditing::to_clip()
602         if(vwindow->get_edl())
603         {
604                 FileXML file;
605                 EDL *edl = vwindow->get_edl();
606                 double start = edl->local_session->get_selectionstart();
607                 double end = edl->local_session->get_selectionend();
609                 if(EQUIV(start, end))
610                 {
611                         end = edl->tracks->total_length();
612                         start = 0;
613                 }
617                 edl->copy(start, 
618                         end, 
619                         1,
620                         0,
621                         0,
622                         &file,
623                         mwindow->plugindb,
624                         "",
625                         1);
630                 EDL *new_edl = new EDL(mwindow->edl);
631                 new_edl->create_objects();
632                 new_edl->load_xml(mwindow->plugindb, &file, LOAD_ALL);
633                 sprintf(new_edl->local_session->clip_title, _("Clip %d"), mwindow->session->clip_number++);
634                 char string[BCTEXTLEN];
635                 Units::totext(string, 
636                                 end - start, 
637                                 edl->session->time_format, 
638                                 edl->session->sample_rate, 
639                                 edl->session->frame_rate,
640                                 edl->session->frames_per_foot);
642                 sprintf(new_edl->local_session->clip_notes, _("%s\n Created from:\n%s"), string, vwindow->gui->loaded_title);
644                 new_edl->local_session->set_selectionstart(0);
645                 new_edl->local_session->set_selectionend(0);
648 //printf("VWindowEditing::to_clip 1 %s\n", edl->local_session->clip_title);
649                 new_edl->local_session->set_selectionstart(0.0);
650                 new_edl->local_session->set_selectionend(0.0);
651                 vwindow->clip_edit->create_clip(new_edl);
652         }
660 VWindowSlider::VWindowSlider(MWindow *mwindow, 
661         VWindow *vwindow, 
662         VWindowGUI *gui,
663         int x, 
664         int y, 
665         int pixels)
666  : BC_PercentageSlider(x, 
667                         y,
668                         0,
669                         pixels, 
670                         pixels, 
671                         0, 
672                         1, 
673                         0)
675         this->mwindow = mwindow;
676         this->vwindow = vwindow;
677         this->gui = gui;
678         set_precision(0.00001);
679         set_pagination(1.0, 10.0);
682 VWindowSlider::~VWindowSlider()
686 int VWindowSlider::handle_event()
688         unlock_window();
689         vwindow->playback_engine->interrupt_playback(1);
690         lock_window("VWindowSlider::handle_event");
692         vwindow->update_position(CHANGE_NONE, 1, 0);
693         gui->timebar->update();
694         return 1;
697 void VWindowSlider::set_position()
699         EDL *edl = vwindow->get_edl();
700         if(edl)
701         {
702                 double new_length = edl->tracks->total_playable_length();
703                 if(EQUIV(edl->local_session->preview_end, 0))
704                         edl->local_session->preview_end = new_length;
705                 if(edl->local_session->preview_end > new_length)
706                         edl->local_session->preview_end = new_length;
707                 if(edl->local_session->preview_start > new_length)
708                         edl->local_session->preview_start = 0;
710                 update(mwindow->theme->vslider_w, 
711                         edl->local_session->get_selectionstart(1), 
712                         edl->local_session->preview_start, 
713                         edl->local_session->preview_end);
714         }
725 VWindowSource::VWindowSource(MWindow *mwindow, VWindowGUI *vwindow, int x, int y)
726  : BC_PopupTextBox(vwindow, 
727         &vwindow->sources, 
728         "",
729         x, 
730         y, 
731         200, 
732         200)
734         this->mwindow = mwindow;
735         this->vwindow = vwindow;
738 VWindowSource::~VWindowSource()
742 int VWindowSource::handle_event()
744         return 1;
753 VWindowTransport::VWindowTransport(MWindow *mwindow, 
754         VWindowGUI *gui, 
755         int x, 
756         int y)
757  : PlayTransport(mwindow, 
758         gui, 
759         x, 
760         y)
762         this->gui = gui;
765 EDL* VWindowTransport::get_edl()
767         return gui->vwindow->get_edl();
771 void VWindowTransport::goto_start()
773         gui->unlock_window();
774         handle_transport(REWIND, 1);
775         gui->lock_window("VWindowTransport::goto_start");
776         gui->vwindow->goto_start();
779 void VWindowTransport::goto_end()
781         gui->unlock_window();
782         handle_transport(GOTO_END, 1);
783         gui->lock_window("VWindowTransport::goto_end");
784         gui->vwindow->goto_end();
790 VWindowCanvas::VWindowCanvas(MWindow *mwindow, VWindowGUI *gui)
791  : Canvas(mwindow,
792         gui,
793         mwindow->theme->vcanvas_x, 
794         mwindow->theme->vcanvas_y, 
795         mwindow->theme->vcanvas_w, 
796         mwindow->theme->vcanvas_h,
797         0,
798         0,
799         0,
800         0,
801         0,
802         1)
804         this->mwindow = mwindow;
805         this->gui = gui;
808 void VWindowCanvas::zoom_resize_window(float percentage)
810         EDL *edl = mwindow->vwindow->get_edl();
811         if(!edl) edl = mwindow->edl;
813         int canvas_w, canvas_h;
814         calculate_sizes(edl->get_aspect_ratio(), 
815                 edl->session->output_w, 
816                 edl->session->output_h, 
817                 percentage,
818                 canvas_w,
819                 canvas_h);
820         int new_w, new_h;
821         new_w = canvas_w + (gui->get_w() - mwindow->theme->vcanvas_w);
822         new_h = canvas_h + (gui->get_h() - mwindow->theme->vcanvas_h);
823         gui->resize_window(new_w, new_h);
824         gui->resize_event(new_w, new_h);
827 void VWindowCanvas::close_source()
829         mwindow->vwindow->remove_source();
833 void VWindowCanvas::draw_refresh()
835         EDL *edl = gui->vwindow->get_edl();
837         if(!get_canvas()->get_video_on()) get_canvas()->clear_box(0, 0, get_canvas()->get_w(), get_canvas()->get_h());
838         if(!get_canvas()->get_video_on() && refresh_frame && edl)
839         {
840                 float in_x1, in_y1, in_x2, in_y2;
841                 float out_x1, out_y1, out_x2, out_y2;
842                 get_transfers(edl, 
843                         in_x1, 
844                         in_y1, 
845                         in_x2, 
846                         in_y2, 
847                         out_x1, 
848                         out_y1, 
849                         out_x2, 
850                         out_y2);
851                 get_canvas()->draw_vframe(refresh_frame,
852                                 (int)out_x1, 
853                                 (int)out_y1, 
854                                 (int)(out_x2 - out_x1), 
855                                 (int)(out_y2 - out_y1),
856                                 (int)in_x1, 
857                                 (int)in_y1, 
858                                 (int)(in_x2 - in_x1), 
859                                 (int)(in_y2 - in_y1),
860                                 0);
861         }
863         if(!get_canvas()->get_video_on())
864         {
865                 draw_overlays();
866                 get_canvas()->flash();
867         }
870 void VWindowCanvas::draw_overlays()
872         if(mwindow->session->vcanvas_highlighted)
873         {
874                 get_canvas()->set_color(WHITE);
875                 get_canvas()->set_inverse();
876                 get_canvas()->draw_rectangle(0, 0, get_canvas()->get_w(), get_canvas()->get_h());
877                 get_canvas()->draw_rectangle(1, 1, get_canvas()->get_w() - 2, get_canvas()->get_h() - 2);
878                 get_canvas()->set_opaque();
879         }
882 int VWindowCanvas::get_fullscreen()
884         return mwindow->session->vwindow_fullscreen;
887 void VWindowCanvas::set_fullscreen(int value)
889         mwindow->session->vwindow_fullscreen = value;
928 #if 0
929 void VWindowGUI::update_points()
931         EDL *edl = vwindow->get_edl();
933 //printf("VWindowGUI::update_points 1\n");
934         if(!edl) return;
936 //printf("VWindowGUI::update_points 2\n");
937         long pixel = (long)((double)edl->local_session->in_point / 
938                 edl->tracks->total_playable_length() *
939                 (mwindow->theme->vtimebar_w - 
940                         2 * 
941                         mwindow->theme->in_point[0]->get_w())) + 
942                 mwindow->theme->in_point[0]->get_w();
944 //printf("VWindowGUI::update_points 3 %d\n", edl->local_session->in_point);
945         if(in_point)
946         {
947 //printf("VWindowGUI::update_points 3.1\n");
948                 if(edl->local_session->in_point >= 0)
949                 {
950 //printf("VWindowGUI::update_points 4\n");
951                         if(edl->local_session->in_point != in_point->position ||
952                                 in_point->pixel != pixel)
953                         {
954                                 in_point->pixel = pixel;
955                                 in_point->reposition();
956                         }
958 //printf("VWindowGUI::update_points 5\n");
959                         in_point->position = edl->local_session->in_point;
961 //printf("VWindowGUI::update_points 6\n");
962                         if(edl->equivalent(in_point->position, edl->local_session->get_selectionstart(1)) ||
963                                 edl->equivalent(in_point->position, edl->local_session->get_selectionend(1)))
964                                 in_point->update(1);
965                         else
966                                 in_point->update(0);
967 //printf("VWindowGUI::update_points 7\n");
968                 }
969                 else
970                 {
971                         delete in_point;
972                         in_point = 0;
973                 }
974         }
975         else
976         if(edl->local_session->in_point >= 0)
977         {
978 //printf("VWindowGUI::update_points 8 %p\n", mwindow->theme->in_point);
979                 add_subwindow(in_point = 
980                         new VWindowInPoint(mwindow, 
981                                 0, 
982                                 this,
983                                 pixel, 
984                                 edl->local_session->in_point));
985 //printf("VWindowGUI::update_points 9\n");
986         }
987 //printf("VWindowGUI::update_points 10\n");
989         pixel = (long)((double)edl->local_session->out_point / 
990                 (edl->tracks->total_playable_length() + 0.5) *
991                 (mwindow->theme->vtimebar_w - 
992                         2 * 
993                         mwindow->theme->in_point[0]->get_w())) + 
994                 mwindow->theme->in_point[0]->get_w() * 
995                 2;
997         if(out_point)
998         {
999                 if(edl->local_session->out_point >= 0 && pixel >= 0 && pixel <= mwindow->theme->vtimebar_w)
1000                 {
1001                         if(edl->local_session->out_point != out_point->position ||
1002                                 out_point->pixel != pixel) 
1003                         {
1004                                 out_point->pixel = pixel;
1005                                 out_point->reposition();
1006                         }
1007                         out_point->position = edl->local_session->out_point;
1009                         if(edl->equivalent(out_point->position, edl->local_session->get_selectionstart(1)) ||
1010                                 edl->equivalent(out_point->position, edl->local_session->get_selectionend(1)))
1011                                 out_point->update(1);
1012                         else
1013                                 out_point->update(0);
1014                 }
1015                 else
1016                 {
1017                         delete out_point;
1018                         out_point = 0;
1019                 }
1020         }
1021         else
1022         if(edl->local_session->out_point >= 0 && pixel >= 0 && pixel <= mwindow->theme->vtimebar_w)
1023         {
1024                 add_subwindow(out_point = 
1025                         new VWindowOutPoint(mwindow, 
1026                                 0, 
1027                                 this, 
1028                                 pixel, 
1029                                 edl->local_session->out_point));
1030         }
1034 void VWindowGUI::update_labels()
1036         EDL *edl = vwindow->get_edl();
1037         int output = 0;
1039         for(Label *current = edl->labels->first;
1040                 current;
1041                 current = NEXT)
1042         {
1043                 long pixel = (long)((current->position - edl->local_session->view_start) / edl->local_session->zoom_sample);
1045                 if(pixel >= 0 && pixel < mwindow->theme->vtimebar_w)
1046                 {
1047 // Create new label
1048                         if(output >= labels.total)
1049                         {
1050                                 LabelGUI *new_label;
1051                                 add_subwindow(new_label = new LabelGUI(mwindow, this, pixel, 0, current->position));
1052                                 labels.append(new_label);
1053                         }
1054                         else
1055 // Reposition old label
1056                         if(labels.values[output]->pixel != pixel)
1057                         {
1058                                 labels.values[output]->pixel = pixel;
1059                                 labels.values[output]->position = current->position;
1060                                 labels.values[output]->reposition();
1061                         }
1063                         if(mwindow->edl->local_session->get_selectionstart(1) <= current->position &&
1064                                 mwindow->edl->local_session->get_selectionend(1) >= current->position)
1065                                 labels.values[output]->update(1);
1066                         else
1067                         if(labels.values[output]->get_value())
1068                                 labels.values[output]->update(0);
1069                         output++;
1070                 }
1071         }
1073 // Delete excess labels
1074         while(labels.total > output)
1075         {
1076                 labels.remove_object();
1077         }
1082 VWindowInPoint::VWindowInPoint(MWindow *mwindow, 
1083                 TimeBar *timebar, 
1084                 VWindowGUI *gui,
1085                 long pixel, 
1086                 double position)
1087  : InPointGUI(mwindow, 
1088                 timebar, 
1089                 pixel, 
1090                 position)
1092         this->gui = gui;
1095 int VWindowInPoint::handle_event()
1097         EDL *edl = gui->vwindow->get_edl();
1099         if(edl)
1100         {
1101                 double position = edl->align_to_frame(this->position, 0);
1103                 edl->local_session->set_selectionstart(position);
1104                 edl->local_session->set_selectionend(position);
1105                 gui->timebar->update();
1107 // Que the VWindow
1108                 mwindow->vwindow->update_position(CHANGE_NONE, 0, 1);
1109         }
1110         return 1;
1115 VWindowOutPoint::VWindowOutPoint(MWindow *mwindow, 
1116                 TimeBar *timebar, 
1117                 VWindowGUI *gui,
1118                 long pixel, 
1119                 double position)
1120  : OutPointGUI(mwindow, 
1121                 timebar, 
1122                 pixel, 
1123                 position)
1125         this->gui = gui;
1128 int VWindowOutPoint::handle_event()
1130         EDL *edl = gui->vwindow->get_edl();
1132         if(edl)
1133         {
1134                 double position = edl->align_to_frame(this->position, 0);
1136                 edl->local_session->set_selectionstart(position);
1137                 edl->local_session->set_selectionend(position);
1138                 gui->timebar->update();
1140 // Que the VWindow
1141                 mwindow->vwindow->update_position(CHANGE_NONE, 0, 1);
1142         }
1144         return 1;
1149 #endif
1152 //      Local Variables:
1153 //      mode: C++
1154 //      c-file-style: "linux"
1155 //      End: