add sliders to cwdw proj/cam tools, edit id tweaks, deltrk shortcut tweak
[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 track_zoom;
60 }
61
62 void ZoomBar::create_objects()
63 {
64         int xs5 = xS(5), xs10 = xS(10);
65         int x = xS(3), 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->create_objects();
71         sample_zoom->set_tooltip(_("Duration visible in the timeline"));
72         x += sample_zoom->get_w();
73         amp_zoom = new AmpZoomPanel(mwindow, this, x, y);
74         amp_zoom->create_objects();
75         amp_zoom->set_tooltip(_("Audio waveform scale"));
76         x += amp_zoom->get_w();
77         track_zoom = new TrackZoomPanel(mwindow, this, x, y);
78         track_zoom->create_objects();
79         track_zoom->set_tooltip(_("Height of tracks in the timeline"));
80         x += track_zoom->get_w() + xs10;
81
82         int wid = xS(120);
83         for( int i=AUTOGROUPTYPE_AUDIO_FADE; i<=AUTOGROUPTYPE_Y; ++i ) {
84                 int ww = BC_GenericButton::calculate_w(this, AutoTypeMenu::to_text(i));
85                 if( ww > wid ) wid = ww;
86         }
87         add_subwindow(auto_type = new AutoTypeMenu(mwindow, this, x, y, wid));
88         auto_type->create_objects();
89         x += auto_type->get_w() + xs10;
90 #define DEFAULT_TEXT "000.00 to 000.00"
91         add_subwindow(auto_zoom = new AutoZoom(mwindow, this, x, y, 0));
92         x += auto_zoom->get_w();
93         add_subwindow(auto_zoom_text = new ZoomTextBox(
94                 mwindow,
95                 this,
96                 x,
97                 y,
98                 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         track_zoom->update(mwindow->edl->local_session->zoom_track);
213         update_autozoom();
214         update_clocks();
215         return 0;
216 }
217
218 int ZoomBar::update_clocks()
219 {
220         from_value->update_position(mwindow->edl->local_session->get_selectionstart(1));
221         length_value->update_position(mwindow->edl->local_session->get_selectionend(1) -
222                 mwindow->edl->local_session->get_selectionstart(1));
223         to_value->update_position(mwindow->edl->local_session->get_selectionend(1));
224         return 0;
225 }
226
227 TitleAlphaBar::TitleAlphaBar(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
228  : BC_FSlider(x, y, 0, xS(150), xS(200), 0, 1.0, mwindow->session->title_bar_alpha, 0)
229 {
230         this->mwindow = mwindow;
231         this->zoombar = zoombar;
232         set_precision(0.01);
233         enable_show_value(0);
234 }
235
236 int TitleAlphaBar::handle_event()
237 {
238         float v = get_value();
239         mwindow->session->title_bar_alpha = v;
240         zoombar->title_alpha_text->update(v);
241         mwindow->gui->draw_trackmovement();
242         mwindow->gui->flush();
243         return 1;
244 }
245
246 TitleAlphaText::TitleAlphaText(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
247  : BC_TextBox(x, y, xS(48), 1, mwindow->session->title_bar_alpha, 0, MEDIUMFONT, 2)
248 {
249         this->mwindow = mwindow;
250         this->zoombar = zoombar;
251         set_tooltip(_("Title Alpha"));
252 }
253
254 int TitleAlphaText::handle_event()
255 {
256         float v = atof(get_text());
257         mwindow->session->title_bar_alpha = v;
258         zoombar->title_alpha_bar->update(v);
259         mwindow->gui->draw_trackmovement();
260         mwindow->gui->flush();
261         return 1;
262 }
263
264 int ZoomBar::resize_event(int w, int h)
265 {
266 // don't change anything but y and width
267         reposition_window(0, h - this->get_h(), w, this->get_h());
268         return 0;
269 }
270
271
272 // Values for which_one
273 #define SET_FROM 1
274 #define SET_LENGTH 2
275 #define SET_TO 3
276
277
278 int ZoomBar::set_selection(int which_one)
279 {
280         double start_position = mwindow->edl->local_session->get_selectionstart(1);
281         double end_position = mwindow->edl->local_session->get_selectionend(1);
282         double length = end_position - start_position;
283
284 // Fix bogus results
285
286         switch(which_one)
287         {
288                 case SET_LENGTH:
289                         start_position = Units::text_to_seconds(from_value->get_text(),
290                                 mwindow->edl->session->sample_rate,
291                                 mwindow->edl->session->time_format,
292                                 mwindow->edl->session->frame_rate,
293                                 mwindow->edl->session->frames_per_foot);
294                         length = Units::text_to_seconds(length_value->get_text(),
295                                 mwindow->edl->session->sample_rate,
296                                 mwindow->edl->session->time_format,
297                                 mwindow->edl->session->frame_rate,
298                                 mwindow->edl->session->frames_per_foot);
299                         end_position = start_position + length;
300
301                         if(end_position < start_position)
302                         {
303                                 start_position = end_position;
304                                 mwindow->edl->local_session->set_selectionend(
305                                         mwindow->edl->local_session->get_selectionstart(1));
306                         }
307                         break;
308
309                 case SET_FROM:
310                         start_position = Units::text_to_seconds(from_value->get_text(),
311                                 mwindow->edl->session->sample_rate,
312                                 mwindow->edl->session->time_format,
313                                 mwindow->edl->session->frame_rate,
314                                 mwindow->edl->session->frames_per_foot);
315                         end_position = Units::text_to_seconds(to_value->get_text(),
316                                 mwindow->edl->session->sample_rate,
317                                 mwindow->edl->session->time_format,
318                                 mwindow->edl->session->frame_rate,
319                                 mwindow->edl->session->frames_per_foot);
320
321                         if(end_position < start_position)
322                         {
323                                 end_position = start_position;
324                                 mwindow->edl->local_session->set_selectionend(
325                                         mwindow->edl->local_session->get_selectionstart(1));
326                         }
327                         break;
328
329                 case SET_TO:
330                         start_position = Units::text_to_seconds(from_value->get_text(),
331                                 mwindow->edl->session->sample_rate,
332                                 mwindow->edl->session->time_format,
333                                 mwindow->edl->session->frame_rate,
334                                 mwindow->edl->session->frames_per_foot);
335                         end_position = Units::text_to_seconds(to_value->get_text(),
336                                 mwindow->edl->session->sample_rate,
337                                 mwindow->edl->session->time_format,
338                                 mwindow->edl->session->frame_rate,
339                                 mwindow->edl->session->frames_per_foot);
340
341                         if(end_position < start_position)
342                         {
343                                 start_position = end_position;
344                                 mwindow->edl->local_session->set_selectionend(
345                                         mwindow->edl->local_session->get_selectionstart(1));
346                         }
347                         break;
348         }
349
350         mwindow->edl->local_session->set_selectionstart(
351                 mwindow->edl->align_to_frame(start_position, 1));
352         mwindow->edl->local_session->set_selectionend(
353                 mwindow->edl->align_to_frame(end_position, 1));
354
355
356         mwindow->gui->update_timebar_highlights();
357         mwindow->gui->hide_cursor(1);
358         mwindow->gui->show_cursor(1);
359         update();
360         mwindow->sync_parameters(CHANGE_PARAMS);
361         mwindow->gui->flash_canvas(1);
362
363         return 0;
364 }
365
366
367 SampleZoomPanel::SampleZoomPanel(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
368  : ZoomPanel(mwindow, zoombar, mwindow->edl->local_session->zoom_sample,
369                 x, y, xS(130), MIN_ZOOM_TIME, MAX_ZOOM_TIME, ZOOM_TIME)
370 {
371         this->mwindow = mwindow;
372         this->zoombar = zoombar;
373 }
374 int SampleZoomPanel::handle_event()
375 {
376         mwindow->zoom_sample((int64_t)get_value());
377         return 1;
378 }
379
380
381 AmpZoomPanel::AmpZoomPanel(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
382  : ZoomPanel(mwindow, zoombar, mwindow->edl->local_session->zoom_y,
383                 x, y, xS(100), MIN_AMP_ZOOM, MAX_AMP_ZOOM, 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, zoombar, mwindow->edl->local_session->zoom_track,
396                 x, y, xS(90), MIN_TRACK_ZOOM, MAX_TRACK_ZOOM, ZOOM_LONG)
397 {
398         this->mwindow = mwindow;
399         this->zoombar = zoombar;
400 }
401 int TrackZoomPanel::handle_event()
402 {
403         mwindow->zoom_track((int64_t)get_value());
404         zoombar->amp_zoom->update(mwindow->edl->local_session->zoom_y);
405         return 1;
406 }
407
408
409
410
411 AutoZoom::AutoZoom(MWindow *mwindow, ZoomBar *zoombar, int x, int y, int changemax)
412  : BC_Tumbler(x, y, mwindow->theme->get_image_set("zoombar_tumbler"))
413 {
414         this->mwindow = mwindow;
415         this->zoombar = zoombar;
416         this->changemax = changemax;
417         if (changemax)
418                 set_tooltip(_("Automation range maximum"));
419         else
420                 set_tooltip(_("Automation range minimum"));
421 }
422
423 int AutoZoom::handle_up_event()
424 {
425         mwindow->change_currentautorange(mwindow->edl->local_session->zoombar_showautotype,1,changemax);
426
427         mwindow->gui->zoombar->update_autozoom();
428         mwindow->gui->draw_overlays(0);
429         mwindow->gui->update_patchbay();
430         mwindow->gui->flash_canvas(1);
431         return 1;
432 }
433
434 int AutoZoom::handle_down_event()
435 {
436         mwindow->change_currentautorange(mwindow->edl->local_session->zoombar_showautotype,0,changemax);
437
438         mwindow->gui->zoombar->update_autozoom();
439         mwindow->gui->draw_overlays(0);
440         mwindow->gui->update_patchbay();
441         mwindow->gui->flash_canvas(1);
442         return 1;
443 }
444
445
446
447 AutoTypeMenu::AutoTypeMenu(MWindow *mwindow, ZoomBar *zoombar, int x, int y, int wid)
448  : BC_PopupMenu(x, y, wid + xS(24),
449         to_text(mwindow->edl->local_session->zoombar_showautotype), 1, 0, 12)
450 {
451         this->mwindow = mwindow;
452         this->zoombar = zoombar;
453         set_tooltip(_("Automation Type"));
454 }
455
456 void AutoTypeMenu::create_objects()
457 {
458         add_item(new BC_MenuItem(to_text(AUTOGROUPTYPE_AUDIO_FADE)));
459         add_item(new BC_MenuItem(to_text(AUTOGROUPTYPE_VIDEO_FADE)));
460         add_item(new BC_MenuItem(to_text(AUTOGROUPTYPE_ZOOM)));
461         add_item(new BC_MenuItem(to_text(AUTOGROUPTYPE_SPEED)));
462         add_item(new BC_MenuItem(to_text(AUTOGROUPTYPE_X)));
463         add_item(new BC_MenuItem(to_text(AUTOGROUPTYPE_Y)));
464 }
465
466 const char* AutoTypeMenu::to_text(int mode)
467 {
468         switch(mode) {
469         case AUTOGROUPTYPE_AUDIO_FADE: return _("Audio Fade:");
470         case AUTOGROUPTYPE_VIDEO_FADE: return _("Video Fade:");
471         case AUTOGROUPTYPE_ZOOM: return _("Zoom:");
472         case AUTOGROUPTYPE_SPEED: return _("Speed:");
473         case AUTOGROUPTYPE_X: return "X:";
474         case AUTOGROUPTYPE_Y: return "Y:";
475         }
476         return "??";
477 }
478
479 int AutoTypeMenu::from_text(char *text)
480 {
481         if(!strcmp(text, to_text(AUTOGROUPTYPE_AUDIO_FADE))) return AUTOGROUPTYPE_AUDIO_FADE;
482         if(!strcmp(text, to_text(AUTOGROUPTYPE_VIDEO_FADE))) return AUTOGROUPTYPE_VIDEO_FADE;
483         if(!strcmp(text, to_text(AUTOGROUPTYPE_ZOOM))) return AUTOGROUPTYPE_ZOOM;
484         if(!strcmp(text, to_text(AUTOGROUPTYPE_SPEED))) return AUTOGROUPTYPE_SPEED;
485         if(!strcmp(text, to_text(AUTOGROUPTYPE_X))) return AUTOGROUPTYPE_X;
486         if(!strcmp(text, to_text(AUTOGROUPTYPE_Y))) return AUTOGROUPTYPE_Y;
487         return AUTOGROUPTYPE_INT255;
488 }
489
490 int AutoTypeMenu::draw_face(int dx, int color)
491 {
492         BC_PopupMenu::draw_face(dx+xS(8), color);
493         color = mwindow->edl->local_session->zoombar_showautocolor;
494         if( color >= 0 ) {
495                 set_color(color);
496                 int margin = get_margin();
497                 int mx = margin+xS(8), my = 3*margin/8;
498                 int bh = get_h() - 2*my;
499                 draw_box(mx,my, bh,bh);
500         }
501         return 1;
502 }
503
504 int AutoTypeMenu::handle_event()
505 {
506         mwindow->edl->local_session->zoombar_showautotype = from_text(this->get_text());
507         this->zoombar->update_autozoom();
508         return 1;
509 }
510
511
512 ZoomTextBox::ZoomTextBox(MWindow *mwindow, ZoomBar *zoombar, int x, int y, const char *text)
513  : BC_TextBox(x, y, xS(130), 1, text)
514 {
515         this->mwindow = mwindow;
516         this->zoombar = zoombar;
517         set_tooltip(_("Automation range"));
518 }
519
520 int ZoomTextBox::button_press_event()
521 {
522         if (!(get_buttonpress() == 4 || get_buttonpress() == 5)) {
523                 BC_TextBox::button_press_event();
524                 return 0;
525         }
526         if (!is_event_win()) return 0;
527
528         int changemax = 1;
529         if (get_relative_cursor_x() < get_w()/2)
530                 changemax = 0;
531
532         // increment
533         if (get_buttonpress() == 4)
534                 mwindow->change_currentautorange(mwindow->edl->local_session->zoombar_showautotype, 1, changemax);
535
536         // decrement
537         if (get_buttonpress() == 5)
538                 mwindow->change_currentautorange(mwindow->edl->local_session->zoombar_showautotype, 0, changemax);
539
540         mwindow->gui->zoombar->update_autozoom();
541         mwindow->gui->draw_overlays(0);
542         mwindow->gui->update_patchbay();
543         mwindow->gui->flash_canvas(1);
544         return 1;
545 }
546
547 int ZoomTextBox::handle_event()
548 {
549         float min, max;
550         if (sscanf(this->get_text(),"%f to%f",&min, &max) == 2)
551         {
552                 AUTOMATIONVIEWCLAMPS(min, mwindow->edl->local_session->zoombar_showautotype);
553                 AUTOMATIONVIEWCLAMPS(max, mwindow->edl->local_session->zoombar_showautotype);
554                 if (max > min)
555                 {
556                         mwindow->edl->local_session->automation_mins[mwindow->edl->local_session->zoombar_showautotype] = min;
557                         mwindow->edl->local_session->automation_maxs[mwindow->edl->local_session->zoombar_showautotype] = max;
558                         mwindow->gui->zoombar->update_autozoom();
559                         mwindow->gui->draw_overlays(0);
560                         mwindow->gui->update_patchbay();
561                         mwindow->gui->flash_canvas(1);
562                 }
563         }
564         // TODO: Make the text turn red when it's a bad range..
565         return 0;
566 }
567
568
569
570
571
572 FromTextBox::FromTextBox(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
573  : BC_TextBox(x, y, xS(90), 1, "")
574 {
575         this->mwindow = mwindow;
576         this->zoombar = zoombar;
577         set_tooltip(_("Selection start time"));
578 }
579
580 int FromTextBox::handle_event()
581 {
582         if(get_keypress() == NEWLINE)
583         {
584                 zoombar->set_selection(SET_FROM);
585                 return 1;
586         }
587         return 0;
588 }
589
590 int FromTextBox::update_position(double new_position)
591 {
592         Units::totext(string,
593                 new_position,
594                 mwindow->edl->session->time_format,
595                 mwindow->edl->session->sample_rate,
596                 mwindow->edl->session->frame_rate,
597                 mwindow->edl->session->frames_per_foot);
598 //printf("FromTextBox::update_position %f %s\n", new_position, string);
599         update(string);
600         return 0;
601 }
602
603
604
605
606
607
608 LengthTextBox::LengthTextBox(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
609  : BC_TextBox(x, y, xS(90), 1, "")
610 {
611         this->mwindow = mwindow;
612         this->zoombar = zoombar;
613         set_tooltip(_("Selection length"));
614 }
615
616 int LengthTextBox::handle_event()
617 {
618         if(get_keypress() == NEWLINE)
619         {
620                 zoombar->set_selection(SET_LENGTH);
621                 return 1;
622         }
623         return 0;
624 }
625
626 int LengthTextBox::update_position(double new_position)
627 {
628         Units::totext(string,
629                 new_position,
630                 mwindow->edl->session->time_format,
631                 mwindow->edl->session->sample_rate,
632                 mwindow->edl->session->frame_rate,
633                 mwindow->edl->session->frames_per_foot);
634         update(string);
635         return 0;
636 }
637
638
639
640
641
642 ToTextBox::ToTextBox(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
643  : BC_TextBox(x, y, xS(90), 1, "")
644 {
645         this->mwindow = mwindow;
646         this->zoombar = zoombar;
647         set_tooltip(_("Selection end time"));
648 }
649
650 int ToTextBox::handle_event()
651 {
652         if(get_keypress() == NEWLINE)
653         {
654                 zoombar->set_selection(SET_TO);
655                 return 1;
656         }
657         return 0;
658 }
659
660 int ToTextBox::update_position(double new_position)
661 {
662         Units::totext(string, new_position,
663                 mwindow->edl->session->time_format,
664                 mwindow->edl->session->sample_rate,
665                 mwindow->edl->session->frame_rate,
666                 mwindow->edl->session->frames_per_foot);
667         update(string);
668         return 0;
669 }