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