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