r827: Fix a crash when no audio output device can be opened.
[cinelerra_cv.git] / cinelerra / timebar.C
blobda0edd3b9f8ffb161f3c4da9b513360213f8d828
1 #include "bcsignals.h"
2 #include "clip.h"
3 #include "cplayback.h"
4 #include "cursors.h"
5 #include "cwindow.h"
6 #include "edl.h"
7 #include "edlsession.h"
8 #include "filexml.h"
9 #include "fonts.h"
10 #include "labels.h"
11 #include "labeledit.h"
12 #include "localsession.h"
13 #include "maincursor.h"
14 #include "mainundo.h"
15 #include "mbuttons.h"
16 #include "mwindow.h"
17 #include "mwindowgui.h"
18 #include "patchbay.h"
19 #include "preferences.h"
20 #include "recordlabel.h"
21 #include "localsession.h"
22 #include "mainsession.h"
23 #include "theme.h"
24 #include "timebar.h"
25 #include "trackcanvas.h"
26 #include "tracks.h"
27 #include "transportque.h"
28 #include "units.h"
29 #include "vframe.h"
30 #include "vwindow.h"
31 #include "vwindowgui.h"
32 #include "zoombar.h"
35 LabelGUI::LabelGUI(MWindow *mwindow, 
36         TimeBar *timebar, 
37         int64_t pixel, 
38         int y, 
39         double position,
40         VFrame **data)
41  : BC_Toggle(translate_pixel(mwindow, pixel), 
42                 y, 
43                 data ? data : mwindow->theme->label_toggle,
44                 0)
46         this->mwindow = mwindow;
47         this->timebar = timebar;
48         this->gui = 0;
49         this->pixel = pixel;
50         this->position = position;
51         this->label = 0;
54 LabelGUI::~LabelGUI()
58 int LabelGUI::get_y(MWindow *mwindow, TimeBar *timebar)
60         return timebar->get_h() - 
61                 mwindow->theme->label_toggle[0]->get_h();
64 int LabelGUI::translate_pixel(MWindow *mwindow, int pixel)
66         int result = pixel - mwindow->theme->label_toggle[0]->get_w() / 2;
67         return result;
70 void LabelGUI::reposition()
72         reposition_window(translate_pixel(mwindow, pixel), BC_Toggle::get_y());
75 int LabelGUI::button_press_event()
77         if (this->is_event_win() && get_buttonpress() == 3) {
78                 if (label)
79                         timebar->label_edit->edit_label(label);
80         } else {
81                 BC_Toggle::button_press_event();
82         }
83         if (label)
84                 set_tooltip(this->label->textstr);
87 int LabelGUI::handle_event()
89         timebar->select_label(position);
90         return 1;
100 InPointGUI::InPointGUI(MWindow *mwindow, 
101         TimeBar *timebar, 
102         int64_t pixel, 
103         double position)
104  : LabelGUI(mwindow, 
105         timebar, 
106         pixel, 
107         get_y(mwindow, timebar), 
108         position, 
109         mwindow->theme->in_point)
111 //printf("InPointGUI::InPointGUI %d %d\n", pixel, get_y(mwindow, timebar));
113 InPointGUI::~InPointGUI()
116 int InPointGUI::get_y(MWindow *mwindow, TimeBar *timebar)
118         int result;
119         result = timebar->get_h() - 
120                 mwindow->theme->in_point[0]->get_h();
121         return result;
125 OutPointGUI::OutPointGUI(MWindow *mwindow, 
126         TimeBar *timebar, 
127         int64_t pixel, 
128         double position)
129  : LabelGUI(mwindow, 
130         timebar, 
131         pixel, 
132         get_y(mwindow, timebar), 
133         position, 
134         mwindow->theme->out_point)
136 //printf("OutPointGUI::OutPointGUI %d %d\n", pixel, get_y(mwindow, timebar));
138 OutPointGUI::~OutPointGUI()
141 int OutPointGUI::get_y(MWindow *mwindow, TimeBar *timebar)
143         return timebar->get_h() - 
144                 mwindow->theme->out_point[0]->get_h();
148 PresentationGUI::PresentationGUI(MWindow *mwindow, 
149         TimeBar *timebar, 
150         int64_t pixel, 
151         double position)
152  : LabelGUI(mwindow, timebar, pixel, get_y(mwindow, timebar), position)
155 PresentationGUI::~PresentationGUI()
165 TimeBar::TimeBar(MWindow *mwindow, 
166         BC_WindowBase *gui,
167         int x, 
168         int y,
169         int w,
170         int h)
171  : BC_SubWindow(x, y, w, h)
173 //printf("TimeBar::TimeBar %d %d %d %d\n", x, y, w, h);
174         this->gui = gui;
175         this->mwindow = mwindow;
176         label_edit = new LabelEdit(mwindow, mwindow->awindow, 0);
179 TimeBar::~TimeBar()
181         if(in_point) delete in_point;
182         if(out_point) delete out_point;
183         if(label_edit) delete label_edit;
184         labels.remove_all_objects();
185         presentations.remove_all_objects();
188 int TimeBar::create_objects()
190         in_point = 0;
191         out_point = 0;
192         current_operation = TIMEBAR_NONE;
193         update();
194         return 0;
198 int64_t TimeBar::position_to_pixel(double position)
200         get_edl_length();
201         return (int64_t)(position / time_per_pixel);
205 void TimeBar::update_labels()
207         int output = 0;
208         EDL *edl = get_edl();
210         if(edl)
211         {
212                 for(Label *current = edl->labels->first;
213                         current;
214                         current = NEXT)
215                 {
216                         int64_t pixel = position_to_pixel(current->position);
218                         if(pixel >= 0 && pixel < get_w())
219                         {
220 // Create new label
221                                 if(output >= labels.total)
222                                 {
223                                         LabelGUI *new_label;
224                                         add_subwindow(new_label = 
225                                                 new LabelGUI(mwindow, 
226                                                         this, 
227                                                         pixel, 
228                                                         LabelGUI::get_y(mwindow, this), 
229                                                         current->position));
230                                         new_label->set_cursor(ARROW_CURSOR);
231                                         new_label->set_tooltip(current->textstr);
232                                         new_label->label = current;
233                                         labels.append(new_label);
234                                 }
235                                 else
236 // Reposition old label
237                                 {
238                                         LabelGUI *gui = labels.values[output];
239                                         if(gui->pixel != pixel)
240                                         {
241                                                 gui->pixel = pixel;
242                                                 gui->reposition();
243                                         }
244                                         else
245                                         {
246                                                 gui->draw_face();
247                                         }
249                                         labels.values[output]->position = current->position;
250                                         labels.values[output]->set_tooltip(current->textstr);
251                                         labels.values[output]->label = current;
252                                 }
254                                 if(edl->local_session->get_selectionstart(1) <= current->position &&
255                                         edl->local_session->get_selectionend(1) >= current->position)
256                                         labels.values[output]->update(1);
257                                 else
258                                 if(labels.values[output]->get_value())
259                                         labels.values[output]->update(0);
261                                 output++;
262                         }
263                 }
264         }
266 // Delete excess labels
267         while(labels.total > output)
268         {
269                 labels.remove_object();
270         }
273 void TimeBar::update_highlights()
275         for(int i = 0; i < labels.total; i++)
276         {
277                 LabelGUI *label = labels.values[i];
278                 if(mwindow->edl->equivalent(label->position, 
279                                 mwindow->edl->local_session->get_selectionstart(1)) ||
280                         mwindow->edl->equivalent(label->position, 
281                                 mwindow->edl->local_session->get_selectionend(1)))
282                 {
283                         if(!label->get_value()) label->update(1);
284                 }
285                 else
286                         if(label->get_value()) label->update(0);
287         }
289         if(mwindow->edl->equivalent(mwindow->edl->local_session->get_inpoint(), 
290                         mwindow->edl->local_session->get_selectionstart(1)) ||
291                 mwindow->edl->equivalent(mwindow->edl->local_session->get_inpoint(), 
292                         mwindow->edl->local_session->get_selectionend(1)))
293         {
294                 if(in_point) in_point->update(1);
295         }
296         else
297                 if(in_point) in_point->update(0);
299         if(mwindow->edl->equivalent(mwindow->edl->local_session->get_outpoint(), 
300                         mwindow->edl->local_session->get_selectionstart(1)) ||
301                 mwindow->edl->equivalent(mwindow->edl->local_session->get_outpoint(), 
302                         mwindow->edl->local_session->get_selectionend(1)))
303         {
304                 if(out_point) out_point->update(1);
305         }
306         else
307                 if(out_point) out_point->update(0);
310 void TimeBar::update_points()
312         EDL *edl = get_edl();
313         int64_t pixel;
315         if(edl) pixel = position_to_pixel(edl->local_session->get_inpoint());
318         if(in_point)
319         {
320                 if(edl && 
321                         edl->local_session->inpoint_valid() && 
322                         pixel >= 0 && 
323                         pixel < get_w())
324                 {
325                         if(!EQUIV(edl->local_session->get_inpoint(), in_point->position) ||
326                                 in_point->pixel != pixel)
327                         {
328                                 in_point->pixel = pixel;
329                                 in_point->position = edl->local_session->get_inpoint();
330                                 in_point->reposition();
331                         }
332                         else
333                         {
334                                 in_point->draw_face();
335                         }
336                 }
337                 else
338                 {
339                         delete in_point;
340                         in_point = 0;
341                 }
342         }
343         else
344         if(edl && edl->local_session->inpoint_valid() && 
345                 pixel >= 0 && pixel < get_w())
346         {
347                 add_subwindow(in_point = new InPointGUI(mwindow, 
348                         this, 
349                         pixel, 
350                         edl->local_session->get_inpoint()));
351                 in_point->set_cursor(ARROW_CURSOR);
352         }
354         if(edl) pixel = position_to_pixel(edl->local_session->get_outpoint());
356         if(out_point)
357         {
358                 if(edl &&
359                         edl->local_session->outpoint_valid() && 
360                         pixel >= 0 && 
361                         pixel < get_w())
362                 {
363                         if(!EQUIV(edl->local_session->get_outpoint(), out_point->position) ||
364                                 out_point->pixel != pixel) 
365                         {
366                                 out_point->pixel = pixel;
367                                 out_point->position = edl->local_session->get_outpoint();
368                                 out_point->reposition();
369                         }
370                         else
371                         {
372                                 out_point->draw_face();
373                         }
374                 }
375                 else
376                 {
377                         delete out_point;
378                         out_point = 0;
379                 }
380         }
381         else
382         if(edl && 
383                 edl->local_session->outpoint_valid() && 
384                 pixel >= 0 && pixel < get_w())
385         {
386                 add_subwindow(out_point = new OutPointGUI(mwindow, 
387                         this, 
388                         pixel, 
389                         edl->local_session->get_outpoint()));
390                 out_point->set_cursor(ARROW_CURSOR);
391         }
394 void TimeBar::update_presentations()
399 void TimeBar::update(int do_range, int do_others)
401 SET_TRACE
402         draw_time();
403 SET_TRACE
404 // Need to redo these when range is drawn to get the background updated.
405         update_labels();
406 SET_TRACE
407         update_points();
408 SET_TRACE
409         update_presentations();
410 SET_TRACE
411         flash();
412 SET_TRACE
417 int TimeBar::delete_project()
419 //      labels->delete_all();
420         return 0;
423 int TimeBar::save(FileXML *xml)
425 //      labels->save(xml);
426         return 0;
432 void TimeBar::draw_time()
436 EDL* TimeBar::get_edl()
438         return mwindow->edl;
443 void TimeBar::draw_range()
445         int x1 = 0, x2 = 0;
446         if(get_edl())
447         {
448                 get_preview_pixels(x1, x2);
450 //printf("TimeBar::draw_range %f %d %d\n", edl_length, x1, x2);
451                 draw_3segmenth(0, 0, x1, mwindow->theme->timebar_view_data);
452                 draw_top_background(get_parent(), x1, 0, x2 - x1, get_h());
453                 draw_3segmenth(x2, 0, get_w() - x2, mwindow->theme->timebar_view_data);
455                 set_color(BLACK);
456                 draw_line(x1, 0, x1, get_h());
457                 draw_line(x2, 0, x2, get_h());
458                 
459                 EDL *edl;
460                 if(edl = get_edl())
461                 {
462                         int64_t pixel = position_to_pixel(
463                                 edl->local_session->get_selectionstart(1));
464 // Draw insertion point position if this timebar beint64_ts to a window which 
465 // has something other than the master EDL.
466                         set_color(RED);
467                         draw_line(pixel, 0, pixel, get_h());
468                 }
469         }
470         else
471                 draw_top_background(get_parent(), 0, 0, get_w(), get_h());
474 void TimeBar::select_label(double position)
480 int TimeBar::draw()
482         return 0;
485 void TimeBar::get_edl_length()
487         edl_length = 0;
489         if(get_edl())
490         {
491 //printf("TimeBar::get_edl_length 1 %f\n", get_edl()->tracks->total_playable_length());
492                 edl_length = get_edl()->tracks->total_playable_length();
493         }
495 //printf("TimeBar::get_edl_length 2\n");
496         if(!EQUIV(edl_length, 0))
497         {
498 //printf("TimeBar::get_edl_length 3\n");
499                 time_per_pixel = edl_length / get_w();
500 //printf("TimeBar::get_edl_length 4\n");
501         }
502         else
503         {
504                 time_per_pixel = 0;
505         }
506 //printf("TimeBar::get_edl_length 5\n");
509 int TimeBar::get_preview_pixels(int &x1, int &x2)
511         x1 = 0;
512         x2 = 0;
514         get_edl_length();
516         if(get_edl())
517         {
518                 if(!EQUIV(edl_length, 0))
519                 {
520                         if(get_edl()->local_session->preview_end <= 0 ||
521                                 get_edl()->local_session->preview_end > edl_length)
522                                 get_edl()->local_session->preview_end = edl_length;
523                         if(get_edl()->local_session->preview_start > 
524                                 get_edl()->local_session->preview_end)
525                                 get_edl()->local_session->preview_start = 0;
526                         x1 = (int)(get_edl()->local_session->preview_start / time_per_pixel);
527                         x2 = (int)(get_edl()->local_session->preview_end / time_per_pixel);
528                 }
529                 else
530                 {
531                         x1 = 0;
532                         x2 = get_w();
533                 }
534         }
535 // printf("TimeBar::get_preview_pixels %f %f %d %d\n", 
536 //      get_edl()->local_session->preview_start,
537 //      get_edl()->local_session->preview_end,
538 //      x1, 
539 //      x2);
540         return 0;
544 int TimeBar::test_preview(int buttonpress)
546         int result = 0;
547         int x1, x2;
549         get_preview_pixels(x1, x2);
550 //printf("TimeBar::test_preview %d %d %d\n", x1, x2, get_cursor_x());
552         if(get_edl())
553         {
554 // Inside left handle
555                 if(cursor_inside() &&
556                         get_cursor_x() >= x1 - HANDLE_W &&
557                         get_cursor_x() < x1 + HANDLE_W &&
558 // Ignore left handle if both handles are up against the left side
559                         x2 > HANDLE_W)
560                 {
561                         if(buttonpress)
562                         {
563                                 current_operation = TIMEBAR_DRAG_LEFT;
564                                 start_position = get_edl()->local_session->preview_start;
565                                 start_cursor_x = get_cursor_x();
566                                 result = 1;
567                         }
568                         else
569                         if(get_cursor() != LEFT_CURSOR)
570                         {
571                                 result = 1;
572                                 set_cursor(LEFT_CURSOR);
573                         }
574                 }
575                 else
576 // Inside right handle
577                 if(cursor_inside() &&
578                         get_cursor_x() >= x2 - HANDLE_W &&
579                         get_cursor_x() < x2 + HANDLE_W &&
580 // Ignore right handle if both handles are up against the right side
581                         x1 < get_w() - HANDLE_W)
582                 {
583                         if(buttonpress)
584                         {
585                                 current_operation = TIMEBAR_DRAG_RIGHT;
586                                 start_position = get_edl()->local_session->preview_end;
587                                 start_cursor_x = get_cursor_x();
588                                 result = 1;
589                         }
590                         else
591                         if(get_cursor() != RIGHT_CURSOR)
592                         {
593                                 result = 1;
594                                 set_cursor(RIGHT_CURSOR);
595                         }
596                 }
597                 else
598                 if(cursor_inside() &&
599                         get_cursor_x() >= x1 &&
600                         get_cursor_x() < x2)
601                 {
602                         if(buttonpress)
603                         {
604                                 current_operation = TIMEBAR_DRAG_CENTER;
605                                 starting_start_position = get_edl()->local_session->preview_start;
606                                 starting_end_position = get_edl()->local_session->preview_end;
607                                 start_cursor_x = get_cursor_x();
608                                 result = 1;
609                         }
610                         else
611                         {
612                                 result = 1;
613                                 set_cursor(HSEPARATE_CURSOR);
614                         }
615                 }
616                 else
617                 {
618 // Trap all buttonpresses inside timebar
619                         if(cursor_inside() && buttonpress)
620                                 result = 1;
622                         if(get_cursor() == LEFT_CURSOR ||
623                                 get_cursor() == RIGHT_CURSOR)
624                         {
625                                 result = 1;
626                                 set_cursor(ARROW_CURSOR);
627                         }
628                 }
629         }
633         return result;
636 int TimeBar::move_preview(int &redraw)
638         int result = 0;
640         if(current_operation == TIMEBAR_DRAG_LEFT)
641         {
642                 get_edl()->local_session->preview_start = 
643                         start_position + 
644                         time_per_pixel * (get_cursor_x() - start_cursor_x);
645                 CLAMP(get_edl()->local_session->preview_start, 
646                         0, 
647                         get_edl()->local_session->preview_end);
648                 result = 1;
649         }
650         else
651         if(current_operation == TIMEBAR_DRAG_RIGHT)
652         {
653                 get_edl()->local_session->preview_end = 
654                         start_position + 
655                         time_per_pixel * (get_cursor_x() - start_cursor_x);
656                 CLAMP(get_edl()->local_session->preview_end, 
657                         get_edl()->local_session->preview_start, 
658                         edl_length);
659                 result = 1;
660         }
661         else
662         if(current_operation == TIMEBAR_DRAG_CENTER)
663         {
664                 get_edl()->local_session->preview_start = 
665                         starting_start_position +
666                         time_per_pixel * (get_cursor_x() - start_cursor_x);
667                 get_edl()->local_session->preview_end = 
668                         starting_end_position +
669                         time_per_pixel * (get_cursor_x() - start_cursor_x);
670                 if(get_edl()->local_session->preview_start < 0)
671                 {
672                         get_edl()->local_session->preview_end -= get_edl()->local_session->preview_start;
673                         get_edl()->local_session->preview_start = 0;
674                 }
675                 else
676                 if(get_edl()->local_session->preview_end > edl_length)
677                 {
678                         get_edl()->local_session->preview_start -= get_edl()->local_session->preview_end - edl_length;
679                         get_edl()->local_session->preview_end = edl_length;
680                 }
681                 result = 1;
682         }
684 //printf("TimeBar::move_preview %f %f\n", get_edl()->local_session->preview_start, get_edl()->local_session->preview_end);
686         if(result)
687         {
688                 update_preview();
689                 redraw = 1;
690         }
692         return result;
695 void TimeBar::update_preview()
699 int TimeBar::samplemovement()
701         return 0;
704 void TimeBar::stop_playback()
708 int TimeBar::button_press_event()
710         if(is_event_win() && cursor_inside())
711         {
712 // Change time format
713                 if(ctrl_down())
714                 {
715                         if(get_buttonpress() == 1)
716                                 mwindow->next_time_format();
717                         else
718                         if(get_buttonpress() == 2)
719                                 mwindow->prev_time_format();
720                         return 1;
721                 }
722                 else
723                 if(test_preview(1))
724                 {
725                 }
726                 else
727                 {
728                         stop_playback();
730 // Select region between two labels
731                         if(get_double_click())
732                         {
733                                 double position = (double)get_cursor_x() * 
734                                         mwindow->edl->local_session->zoom_sample / 
735                                         mwindow->edl->session->sample_rate + 
736                                         (double)mwindow->edl->local_session->view_start *
737                                         mwindow->edl->local_session->zoom_sample / 
738                                         mwindow->edl->session->sample_rate;
739 // Test labels
740                                 select_region(position);
741                                 return 1;
742                         }
743                         else
744 // Reposition highlight cursor
745                         if(is_event_win() && cursor_inside())
746                         {
747                                 update_cursor();
748                                 mwindow->gui->canvas->activate();
749                                 return 1;
750                         }
751                 }
752         }
753         return 0;
756 int TimeBar::repeat_event(int64_t duration)
758         if(!mwindow->gui->canvas->drag_scroll) return 0;
759         if(duration != BC_WindowBase::get_resources()->scroll_repeat) return 0;
761         int distance = 0;
762         int x_movement = 0;
763         int relative_cursor_x = mwindow->gui->canvas->get_relative_cursor_x();
764         if(current_operation == TIMEBAR_DRAG)
765         {
766                 if(relative_cursor_x >= mwindow->gui->canvas->get_w())
767                 {
768                         distance = relative_cursor_x - mwindow->gui->canvas->get_w();
769                         x_movement = 1;
770                 }
771                 else
772                 if(relative_cursor_x < 0)
773                 {
774                         distance = relative_cursor_x;
775                         x_movement = 1;
776                 }
780                 if(x_movement)
781                 {
782                         update_cursor();
783                         mwindow->samplemovement(mwindow->edl->local_session->view_start + 
784                                 distance);
785                 }
786                 return 1;
787         }
788         return 0;
791 int TimeBar::cursor_motion_event()
793         int result = 0;
794         int redraw = 0;
796         switch(current_operation)
797         {
798                 case TIMEBAR_DRAG:
799                 {
800                         update_cursor();
801 //printf("TimeBar::cursor_motion_event 1\n");
802                         int relative_cursor_x = mwindow->gui->canvas->get_relative_cursor_x();
803                         if(relative_cursor_x >= mwindow->gui->canvas->get_w() || 
804                                 relative_cursor_x < 0)
805                         {
806                                 mwindow->gui->canvas->start_dragscroll();
807                         }
808                         else
809                         if(relative_cursor_x < mwindow->gui->canvas->get_w() && 
810                                 relative_cursor_x >= 0)
811                         {
812                                 mwindow->gui->canvas->stop_dragscroll();
813                         }
814                         result = 1;
815 //printf("TimeBar::cursor_motion_event 10\n");
816                         break;
817                 }
820                 case TIMEBAR_DRAG_LEFT:
821                 case TIMEBAR_DRAG_RIGHT:
822                 case TIMEBAR_DRAG_CENTER:
823                         result = move_preview(redraw);
824                         break;
826                 default:
827 //printf("TimeBar::cursor_motion_event 20\n");
828                         result = test_preview(0);
829 //printf("TimeBar::cursor_motion_event 30\n");
830                         break;
831         }
833         if(redraw)
834         {
835                 update();
836         }
838         return result;
841 int TimeBar::button_release_event()
843 //printf("TimeBar::button_release_event %d\n", current_operation);
844         int result = 0;
845         switch(current_operation)
846         {
847                 case TIMEBAR_DRAG:
848                         mwindow->undo->update_undo(_("select"), LOAD_SESSION, 0, 0);
849                         mwindow->gui->canvas->stop_dragscroll();
850                         current_operation = TIMEBAR_NONE;
851                         result = 1;
852                         break;
854                 default:
855                         if(current_operation != TIMEBAR_NONE)
856                         {
857                                 current_operation = TIMEBAR_NONE;
858                                 result = 1;
859                         }
860                         break;
861         }
862         return result;
865 // Update the selection cursor during a dragging operation
866 void TimeBar::update_cursor()
868         double position = (double)get_cursor_x() * 
869                 mwindow->edl->local_session->zoom_sample / 
870                 mwindow->edl->session->sample_rate + 
871                 (double)mwindow->edl->local_session->view_start * 
872                 mwindow->edl->local_session->zoom_sample / 
873                 mwindow->edl->session->sample_rate;
874         
875         position = mwindow->edl->align_to_frame(position, 0);
876         position = MAX(0, position);
877         current_operation = TIMEBAR_DRAG;
879         mwindow->select_point(position);
880         update_highlights();
884 int TimeBar::select_region(double position)
886         Label *start = 0, *end = 0, *current;
887         for(current = mwindow->edl->labels->first; current; current = NEXT)
888         {
889                 if(current->position > position)
890                 {
891                         end = current;
892                         break;
893                 }
894         }
896         for(current = mwindow->edl->labels->last ; current; current = PREVIOUS)
897         {
898                 if(current->position <= position)
899                 {
900                         start = current;
901                         break;
902                 }
903         }
905 // Select region
906         if(end != start)
907         {
908                 if(!start)
909                         mwindow->edl->local_session->set_selectionstart(0);
910                 else
911                         mwindow->edl->local_session->set_selectionstart(start->position);
913                 if(!end)
914                         mwindow->edl->local_session->set_selectionend(mwindow->edl->tracks->total_length());
915                 else
916                         mwindow->edl->local_session->set_selectionend(end->position);
917         }
918         else
919         if(end || start)
920         {
921                 mwindow->edl->local_session->set_selectionstart(start->position);
922                 mwindow->edl->local_session->set_selectionend(start->position);
923         }
925 // Que the CWindow
926         mwindow->cwindow->update(1, 0, 0);
927         mwindow->gui->cursor->hide();
928         mwindow->gui->cursor->draw();
929         mwindow->gui->canvas->flash();
930         mwindow->gui->canvas->activate();
931         mwindow->gui->zoombar->update();
932         mwindow->undo->update_undo(_("select"), LOAD_SESSION, 0, 0);
933         update_highlights();
934         return 0;
940 int TimeBar::delete_arrows()
942         return 0;