improve resize flash operation, fixup xv grab/ungrab, fixup label updates
[goodguy/history.git] / cinelerra-5.1 / cinelerra / zoombar.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
5  * 
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * 
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  * 
20  */
21
22 #include "apatchgui.inc"
23 #include "clip.h"
24 #include "edl.h"
25 #include "edlsession.h"
26 #include "language.h"
27 #include "localsession.h"
28 #include "maincursor.h"
29 #include "mwindow.h"
30 #include "mwindowgui.h"
31 #include "mainsession.h"
32 #include "mtimebar.h"
33 #include "preferences.h"
34 #include "theme.h"
35 #include "trackcanvas.h"
36 #include "tracks.h"
37 #include "units.h"
38 #include "vpatchgui.inc"
39 #include "zoombar.h"
40
41
42
43
44 ZoomBar::ZoomBar(MWindow *mwindow, MWindowGUI *gui)
45  : BC_SubWindow(mwindow->theme->mzoom_x,
46         mwindow->theme->mzoom_y,
47         mwindow->theme->mzoom_w,
48         mwindow->theme->mzoom_h) 
49 {
50         this->gui = gui;
51         this->mwindow = mwindow;
52         old_position = 0;
53 }
54
55 ZoomBar::~ZoomBar()
56 {
57         delete sample_zoom;
58         delete amp_zoom;
59         delete track_zoom;
60 }
61
62 void ZoomBar::create_objects()
63 {
64         int x = 3;
65         int y = get_h() / 2 - 
66                 mwindow->theme->get_image_set("zoombar_menu", 0)[0]->get_h() / 2;
67
68         draw_top_background(get_parent(), 0, 0, get_w(), get_h());
69         sample_zoom = new SampleZoomPanel(mwindow, this, x, y);
70         sample_zoom->set_menu_images(mwindow->theme->get_image_set("zoombar_menu", 0));
71         sample_zoom->set_tumbler_images(mwindow->theme->get_image_set("zoombar_tumbler", 0));
72         sample_zoom->create_objects();
73         sample_zoom->zoom_text->set_tooltip(_("Duration visible in the timeline"));
74         sample_zoom->zoom_tumbler->set_tooltip(_("Duration visible in the timeline"));
75         x += sample_zoom->get_w();
76         amp_zoom = new AmpZoomPanel(mwindow, this, x, y);
77         amp_zoom->set_menu_images(mwindow->theme->get_image_set("zoombar_menu", 0));
78         amp_zoom->set_tumbler_images(mwindow->theme->get_image_set("zoombar_tumbler", 0));
79         amp_zoom->create_objects();
80         amp_zoom->zoom_text->set_tooltip(_("Audio waveform scale"));
81         amp_zoom->zoom_tumbler->set_tooltip(_("Audio waveform scale"));
82         x += amp_zoom->get_w();
83         track_zoom = new TrackZoomPanel(mwindow, this, x, y);
84         track_zoom->set_menu_images(mwindow->theme->get_image_set("zoombar_menu", 0));
85         track_zoom->set_tumbler_images(mwindow->theme->get_image_set("zoombar_tumbler", 0));
86         track_zoom->create_objects();
87         track_zoom->zoom_text->set_tooltip(_("Height of tracks in the timeline"));
88         track_zoom->zoom_tumbler->set_tooltip(_("Height of tracks in the timeline"));
89         x += track_zoom->get_w() + 10;
90
91         int wid = 120;
92         for( int i=AUTOGROUPTYPE_AUDIO_FADE; i<=AUTOGROUPTYPE_Y; ++i ) {
93                 int ww = BC_GenericButton::calculate_w(this, AutoTypeMenu::to_text(i));
94                 if( ww > wid ) wid = ww;
95         }
96         add_subwindow(auto_type = new AutoTypeMenu(mwindow, this, x, y, wid));
97         auto_type->create_objects();
98         x += auto_type->get_w() + 10;
99 #define DEFAULT_TEXT "000.00 to 000.00"
100         add_subwindow(auto_zoom = new AutoZoom(mwindow, this, x, y, 0));
101         x += auto_zoom->get_w();
102         add_subwindow(auto_zoom_text = new ZoomTextBox(
103                 mwindow, 
104                 this, 
105                 x, 
106                 y,
107                 DEFAULT_TEXT));
108         x += auto_zoom_text->get_w() + 5;
109         add_subwindow(auto_zoom = new AutoZoom(mwindow, this, x, y, 1));
110         update_autozoom();
111         x += auto_zoom->get_w() + 5;
112
113         add_subwindow(from_value = new FromTextBox(mwindow, this, x, y));
114         x += from_value->get_w() + 5;
115         add_subwindow(length_value = new LengthTextBox(mwindow, this, x, y));
116         x += length_value->get_w() + 5;
117         add_subwindow(to_value = new ToTextBox(mwindow, this, x, y));
118         x += to_value->get_w() + 5;
119
120         update_formatting(from_value);
121         update_formatting(length_value);
122         update_formatting(to_value);
123
124         add_subwindow(playback_value = new BC_Title(x, 100, "--", MEDIUMFONT, RED));
125
126         add_subwindow(zoom_value = new BC_Title(x, 100, "--", MEDIUMFONT, BLACK));
127         update();
128 }
129
130
131 void ZoomBar::update_formatting(BC_TextBox *dst)
132 {
133         dst->set_separators(
134                 Units::format_to_separators(mwindow->edl->session->time_format));
135 }
136
137 void ZoomBar::resize_event()
138 {
139         reposition_window(mwindow->theme->mzoom_x,
140                 mwindow->theme->mzoom_y,
141                 mwindow->theme->mzoom_w,
142                 mwindow->theme->mzoom_h);
143
144         draw_top_background(get_parent(), 0, 0, get_w(), get_h());
145         int x = 3, y = 1;
146         if (sample_zoom) delete sample_zoom;
147         sample_zoom = new SampleZoomPanel(mwindow, this, x, y);
148         sample_zoom->set_menu_images(mwindow->theme->get_image_set("zoombar_menu", 0));
149         sample_zoom->set_tumbler_images(mwindow->theme->get_image_set("zoombar_tumbler", 0));
150         sample_zoom->create_objects();
151 //      x += sample_zoom->get_w();
152 //      amp_zoom->reposition_window(x, y);
153 //      x += amp_zoom->get_w();
154 //      track_zoom->reposition_window(x, y);
155         flash();
156 }
157
158 void ZoomBar::redraw_time_dependancies()
159 {
160 // Recalculate sample zoom menu
161         sample_zoom->update_menu();
162         sample_zoom->update(mwindow->edl->local_session->zoom_sample);
163         update_formatting(from_value);
164         update_formatting(length_value);
165         update_formatting(to_value);
166         update_autozoom();
167         update_clocks();
168 }
169
170 int ZoomBar::draw()
171 {
172         update();
173         return 0;
174 }
175
176 void ZoomBar::update_autozoom()
177 {
178         char string[BCTEXTLEN];
179         switch (mwindow->edl->local_session->zoombar_showautotype) {
180         case AUTOGROUPTYPE_AUDIO_FADE:
181         case AUTOGROUPTYPE_VIDEO_FADE:
182                 sprintf(string, "%0.01f to %0.01f\n", 
183                         mwindow->edl->local_session->automation_mins[mwindow->edl->local_session->zoombar_showautotype],
184                         mwindow->edl->local_session->automation_maxs[mwindow->edl->local_session->zoombar_showautotype]);
185                 break;
186         case AUTOGROUPTYPE_ZOOM:
187         case AUTOGROUPTYPE_SPEED:
188                 sprintf(string, "%0.03f to %0.03f\n", 
189                         mwindow->edl->local_session->automation_mins[mwindow->edl->local_session->zoombar_showautotype],
190                         mwindow->edl->local_session->automation_maxs[mwindow->edl->local_session->zoombar_showautotype]);
191                 break;
192         case AUTOGROUPTYPE_X:
193         case AUTOGROUPTYPE_Y:
194                 sprintf(string, "%0.0f to %.0f\n", 
195                         mwindow->edl->local_session->automation_mins[mwindow->edl->local_session->zoombar_showautotype],
196                         mwindow->edl->local_session->automation_maxs[mwindow->edl->local_session->zoombar_showautotype]);
197                 break;
198         }
199         auto_zoom_text->update(string);
200 }
201
202 int ZoomBar::update()
203 {
204         sample_zoom->update(mwindow->edl->local_session->zoom_sample);
205         amp_zoom->update(mwindow->edl->local_session->zoom_y);
206         track_zoom->update(mwindow->edl->local_session->zoom_track);
207         update_autozoom();
208         update_clocks();
209         return 0;
210 }
211
212 int ZoomBar::update_clocks()
213 {
214         from_value->update_position(mwindow->edl->local_session->get_selectionstart(1));
215         length_value->update_position(mwindow->edl->local_session->get_selectionend(1) - 
216                 mwindow->edl->local_session->get_selectionstart(1));
217         to_value->update_position(mwindow->edl->local_session->get_selectionend(1));
218         return 0;
219 }
220
221 int ZoomBar::update_playback(int64_t new_position)
222 {
223         if(new_position != old_position)
224         {
225                 Units::totext(string, 
226                                 new_position, 
227                                 mwindow->edl->session->sample_rate, 
228                                 mwindow->edl->session->time_format, 
229                                 mwindow->edl->session->frame_rate,
230                                 mwindow->edl->session->frames_per_foot);
231                 playback_value->update(string);
232                 old_position = new_position;
233         }
234         return 0;
235 }
236
237 int ZoomBar::resize_event(int w, int h)
238 {
239 // don't change anything but y and width
240         reposition_window(0, h - this->get_h(), w, this->get_h());
241         return 0;
242 }
243
244
245 // Values for which_one
246 #define SET_FROM 1
247 #define SET_LENGTH 2
248 #define SET_TO 3
249
250
251 int ZoomBar::set_selection(int which_one)
252 {
253         double start_position = mwindow->edl->local_session->get_selectionstart(1);
254         double end_position = mwindow->edl->local_session->get_selectionend(1);
255         double length = end_position - start_position;
256
257 // Fix bogus results
258
259         switch(which_one)
260         {
261                 case SET_LENGTH:
262                         start_position = Units::text_to_seconds(from_value->get_text(), 
263                                 mwindow->edl->session->sample_rate, 
264                                 mwindow->edl->session->time_format, 
265                                 mwindow->edl->session->frame_rate,
266                                 mwindow->edl->session->frames_per_foot);
267                         length = Units::text_to_seconds(length_value->get_text(), 
268                                 mwindow->edl->session->sample_rate, 
269                                 mwindow->edl->session->time_format, 
270                                 mwindow->edl->session->frame_rate,
271                                 mwindow->edl->session->frames_per_foot);
272                         end_position = start_position + length;
273
274                         if(end_position < start_position)
275                         {
276                                 start_position = end_position;
277                                 mwindow->edl->local_session->set_selectionend(
278                                         mwindow->edl->local_session->get_selectionstart(1));
279                         }
280                         break;
281
282                 case SET_FROM:
283                         start_position = Units::text_to_seconds(from_value->get_text(), 
284                                 mwindow->edl->session->sample_rate, 
285                                 mwindow->edl->session->time_format, 
286                                 mwindow->edl->session->frame_rate,
287                                 mwindow->edl->session->frames_per_foot);
288                         end_position = Units::text_to_seconds(to_value->get_text(), 
289                                 mwindow->edl->session->sample_rate, 
290                                 mwindow->edl->session->time_format, 
291                                 mwindow->edl->session->frame_rate,
292                                 mwindow->edl->session->frames_per_foot);
293
294                         if(end_position < start_position)
295                         {
296                                 end_position = start_position;
297                                 mwindow->edl->local_session->set_selectionend(
298                                         mwindow->edl->local_session->get_selectionstart(1));
299                         }
300                         break;
301
302                 case SET_TO:
303                         start_position = Units::text_to_seconds(from_value->get_text(), 
304                                 mwindow->edl->session->sample_rate, 
305                                 mwindow->edl->session->time_format, 
306                                 mwindow->edl->session->frame_rate,
307                                 mwindow->edl->session->frames_per_foot);
308                         end_position = Units::text_to_seconds(to_value->get_text(), 
309                                 mwindow->edl->session->sample_rate, 
310                                 mwindow->edl->session->time_format, 
311                                 mwindow->edl->session->frame_rate,
312                                 mwindow->edl->session->frames_per_foot);
313
314                         if(end_position < start_position)
315                         {
316                                 start_position = end_position;
317                                 mwindow->edl->local_session->set_selectionend(
318                                         mwindow->edl->local_session->get_selectionstart(1));
319                         }
320                         break;
321         }
322
323         mwindow->edl->local_session->set_selectionstart(
324                 mwindow->edl->align_to_frame(start_position, 1));
325         mwindow->edl->local_session->set_selectionend(
326                 mwindow->edl->align_to_frame(end_position, 1));
327
328
329         mwindow->gui->update_timebar_highlights();
330         mwindow->gui->hide_cursor(1);
331         mwindow->gui->show_cursor(1);
332         update();
333         mwindow->sync_parameters(CHANGE_PARAMS);
334         mwindow->gui->flash_canvas(1);
335
336         return 0;
337 }
338
339
340
341
342
343
344
345
346
347
348
349
350 SampleZoomPanel::SampleZoomPanel(MWindow *mwindow, 
351         ZoomBar *zoombar, 
352         int x, 
353         int y)
354  : ZoomPanel(mwindow, 
355         zoombar, 
356         mwindow->edl->local_session->zoom_sample, 
357         x, 
358         y, 
359         110, 
360         MIN_ZOOM_TIME, 
361         MAX_ZOOM_TIME, 
362         ZOOM_TIME)
363 {
364         this->mwindow = mwindow;
365         this->zoombar = zoombar;
366 }
367 int SampleZoomPanel::handle_event()
368 {
369         mwindow->zoom_sample((int64_t)get_value());
370         return 1;
371 }
372
373
374 AmpZoomPanel::AmpZoomPanel(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
375  : ZoomPanel(mwindow, 
376         zoombar, 
377         mwindow->edl->local_session->zoom_y, 
378         x, 
379         y, 
380         80,
381         MIN_AMP_ZOOM, 
382         MAX_AMP_ZOOM, 
383         ZOOM_LONG)
384 {
385         this->mwindow = mwindow;
386         this->zoombar = zoombar;
387 }
388 int AmpZoomPanel::handle_event()
389 {
390         mwindow->zoom_amp((int64_t)get_value());
391         return 1;
392 }
393
394 TrackZoomPanel::TrackZoomPanel(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
395  : ZoomPanel(mwindow, 
396         zoombar, 
397         mwindow->edl->local_session->zoom_track, 
398         x, 
399         y, 
400         70,
401         MIN_TRACK_ZOOM, 
402         MAX_TRACK_ZOOM, 
403         ZOOM_LONG)
404 {
405         this->mwindow = mwindow;
406         this->zoombar = zoombar;
407 }
408 int TrackZoomPanel::handle_event()
409 {
410         mwindow->zoom_track((int64_t)get_value());
411         zoombar->amp_zoom->update(mwindow->edl->local_session->zoom_y);
412         return 1;
413 }
414
415
416
417
418 AutoZoom::AutoZoom(MWindow *mwindow, ZoomBar *zoombar, int x, int y, int changemax)
419  : BC_Tumbler(x,
420         y,
421         mwindow->theme->get_image_set("zoombar_tumbler"))
422 {
423         this->mwindow = mwindow;
424         this->zoombar = zoombar;
425         this->changemax = changemax;
426         if (changemax)
427                 set_tooltip(_("Automation range maximum"));
428         else
429                 set_tooltip(_("Automation range minimum"));
430 }
431
432 int AutoZoom::handle_up_event()
433 {
434         mwindow->change_currentautorange(mwindow->edl->local_session->zoombar_showautotype,1,changemax);
435
436         mwindow->gui->zoombar->update_autozoom();
437         mwindow->gui->draw_overlays(0);
438         mwindow->gui->update_patchbay();
439         mwindow->gui->flash_canvas(1);
440         return 1;
441 }
442
443 int AutoZoom::handle_down_event()
444 {
445         mwindow->change_currentautorange(mwindow->edl->local_session->zoombar_showautotype,0,changemax);
446
447         mwindow->gui->zoombar->update_autozoom();
448         mwindow->gui->draw_overlays(0);
449         mwindow->gui->update_patchbay();
450         mwindow->gui->flash_canvas(1);
451         return 1;
452 }
453
454
455
456 AutoTypeMenu::AutoTypeMenu(MWindow *mwindow, ZoomBar *zoombar, int x, int y, int wid)
457         : BC_PopupMenu(x, y, wid, to_text(mwindow->edl->local_session->zoombar_showautotype), 1)
458 {
459         this->mwindow = mwindow;
460         this->zoombar = zoombar;
461         set_tooltip(_("Automation Type"));
462 }
463
464 void AutoTypeMenu::create_objects()
465 {
466         add_item(new BC_MenuItem(to_text(AUTOGROUPTYPE_AUDIO_FADE)));
467         add_item(new BC_MenuItem(to_text(AUTOGROUPTYPE_VIDEO_FADE)));
468         add_item(new BC_MenuItem(to_text(AUTOGROUPTYPE_ZOOM)));
469         add_item(new BC_MenuItem(to_text(AUTOGROUPTYPE_SPEED)));
470         add_item(new BC_MenuItem(to_text(AUTOGROUPTYPE_X)));
471         add_item(new BC_MenuItem(to_text(AUTOGROUPTYPE_Y)));
472 }
473
474 const char* AutoTypeMenu::to_text(int mode)
475 {
476         switch(mode) {
477         case AUTOGROUPTYPE_AUDIO_FADE: return _("Audio Fade:");
478         case AUTOGROUPTYPE_VIDEO_FADE: return _("Video Fade:");
479         case AUTOGROUPTYPE_ZOOM: return _("Zoom:");
480         case AUTOGROUPTYPE_SPEED: return _("Speed:");
481         case AUTOGROUPTYPE_X: return "X:";
482         case AUTOGROUPTYPE_Y: return "Y:";
483         }
484         return "??";
485 }
486
487 int AutoTypeMenu::from_text(char *text)
488 {
489         if(!strcmp(text, to_text(AUTOGROUPTYPE_AUDIO_FADE))) return AUTOGROUPTYPE_AUDIO_FADE;
490         if(!strcmp(text, to_text(AUTOGROUPTYPE_VIDEO_FADE))) return AUTOGROUPTYPE_VIDEO_FADE;
491         if(!strcmp(text, to_text(AUTOGROUPTYPE_ZOOM))) return AUTOGROUPTYPE_ZOOM;
492         if(!strcmp(text, to_text(AUTOGROUPTYPE_SPEED))) return AUTOGROUPTYPE_SPEED;
493         if(!strcmp(text, to_text(AUTOGROUPTYPE_X))) return AUTOGROUPTYPE_X;
494         if(!strcmp(text, to_text(AUTOGROUPTYPE_Y))) return AUTOGROUPTYPE_Y;
495         return AUTOGROUPTYPE_INT255;
496 }
497
498 int AutoTypeMenu::handle_event()
499 {
500         mwindow->edl->local_session->zoombar_showautotype = from_text(this->get_text());
501         this->zoombar->update_autozoom();
502         return 1;
503 }
504
505
506 ZoomTextBox::ZoomTextBox(MWindow *mwindow, ZoomBar *zoombar, int x, int y, const char *text)
507  : BC_TextBox(x, y, 130, 1, text)
508 {
509         this->mwindow = mwindow;
510         this->zoombar = zoombar;
511         set_tooltip(_("Automation range"));
512 }
513
514 int ZoomTextBox::button_press_event()
515 {
516         if (!(get_buttonpress() == 4 || get_buttonpress() == 5)) {
517                 BC_TextBox::button_press_event();
518                 return 0;
519         }
520         if (!is_event_win()) return 0;
521
522         int changemax = 1;
523         if (get_relative_cursor_x() < get_w()/2)
524                 changemax = 0;
525
526         // increment
527         if (get_buttonpress() == 4)
528                 mwindow->change_currentautorange(mwindow->edl->local_session->zoombar_showautotype, 1, changemax);
529
530         // decrement
531         if (get_buttonpress() == 5)
532                 mwindow->change_currentautorange(mwindow->edl->local_session->zoombar_showautotype, 0, changemax);
533
534         mwindow->gui->zoombar->update_autozoom();
535         mwindow->gui->draw_overlays(0);
536         mwindow->gui->update_patchbay();
537         mwindow->gui->flash_canvas(1);
538         return 1;
539 }
540
541 int ZoomTextBox::handle_event()
542 {
543         float min, max;
544         if (sscanf(this->get_text(),"%f to%f",&min, &max) == 2)
545         {
546                 AUTOMATIONVIEWCLAMPS(min, mwindow->edl->local_session->zoombar_showautotype);
547                 AUTOMATIONVIEWCLAMPS(max, mwindow->edl->local_session->zoombar_showautotype);
548                 if (max > min) 
549                 {
550                         mwindow->edl->local_session->automation_mins[mwindow->edl->local_session->zoombar_showautotype] = min;
551                         mwindow->edl->local_session->automation_maxs[mwindow->edl->local_session->zoombar_showautotype] = max;
552                         mwindow->gui->zoombar->update_autozoom();
553                         mwindow->gui->draw_overlays(0);
554                         mwindow->gui->update_patchbay();
555                         mwindow->gui->flash_canvas(1);
556                 }
557         }
558         // TODO: Make the text turn red when it's a bad range..
559         return 0;
560 }
561
562
563
564
565
566 FromTextBox::FromTextBox(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
567  : BC_TextBox(x, y, 90, 1, "")
568 {
569         this->mwindow = mwindow;
570         this->zoombar = zoombar;
571         set_tooltip(_("Selection start time"));
572 }
573
574 int FromTextBox::handle_event()
575 {
576         if(get_keypress() == 13)
577         {
578                 zoombar->set_selection(SET_FROM);
579                 return 1;
580         }
581         return 0;
582 }
583
584 int FromTextBox::update_position(double new_position)
585 {
586         new_position += mwindow->edl->session->get_frame_offset() / 
587                                                  mwindow->edl->session->frame_rate;;
588         Units::totext(string, 
589                 new_position, 
590                 mwindow->edl->session->time_format, 
591                 mwindow->edl->session->sample_rate, 
592                 mwindow->edl->session->frame_rate,
593                 mwindow->edl->session->frames_per_foot);
594 //printf("FromTextBox::update_position %f %s\n", new_position, string);
595         update(string);
596         return 0;
597 }
598
599
600
601
602
603
604 LengthTextBox::LengthTextBox(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
605  : BC_TextBox(x, y, 90, 1, "")
606 {
607         this->mwindow = mwindow;
608         this->zoombar = zoombar;
609         set_tooltip(_("Selection length"));
610 }
611
612 int LengthTextBox::handle_event()
613 {
614         if(get_keypress() == 13)
615         {
616                 zoombar->set_selection(SET_LENGTH);
617                 return 1;
618         }
619         return 0;
620 }
621
622 int LengthTextBox::update_position(double new_position)
623 {
624         Units::totext(string, 
625                 new_position, 
626                 mwindow->edl->session->time_format, 
627                 mwindow->edl->session->sample_rate, 
628                 mwindow->edl->session->frame_rate,
629                 mwindow->edl->session->frames_per_foot);
630         update(string);
631         return 0;
632 }
633
634
635
636
637
638 ToTextBox::ToTextBox(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
639  : BC_TextBox(x, y, 90, 1, "")
640 {
641         this->mwindow = mwindow;
642         this->zoombar = zoombar;
643         set_tooltip(_("Selection end time"));
644 }
645
646 int ToTextBox::handle_event()
647 {
648         if(get_keypress() == 13)
649         {
650                 zoombar->set_selection(SET_TO);
651                 return 1;
652         }
653         return 0;
654 }
655
656 int ToTextBox::update_position(double new_position)
657 {
658         new_position += mwindow->edl->session->get_frame_offset() /
659                                                  mwindow->edl->session->frame_rate;
660         Units::totext(string, 
661                 new_position, 
662                 mwindow->edl->session->time_format, 
663                 mwindow->edl->session->sample_rate, 
664                 mwindow->edl->session->frame_rate,
665                 mwindow->edl->session->frames_per_foot);
666         update(string);
667         return 0;
668 }