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