fix audio big btn replay, new proj path, proxy fix, updated Features5
[goodguy/history.git] / cinelerra-5.1 / cinelerra / new.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 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 "browsebutton.h"
23 #include "clip.h"
24 #include "cplayback.h"
25 #include "cwindow.h"
26 #include "bchash.h"
27 #include "edl.h"
28 #include "edlsession.h"
29 #include "filesystem.h"
30 #include "filexml.h"
31 #include "interlacemodes.h"
32 #include "language.h"
33 #include "levelwindow.h"
34 #include "mainerror.h"
35 #include "mainundo.h"
36 #include "mainmenu.h"
37 #include "mutex.h"
38 #include "mwindow.h"
39 #include "mwindowgui.h"
40 #include "new.h"
41 #include "newpresets.h"
42 #include "mainsession.h"
43 #include "patchbay.h"
44 #include "preferences.h"
45 #include "theme.h"
46 #include "transportque.h"
47 #include "track.h"
48 #include "tracks.h"
49 #include "videowindow.h"
50 #include "vplayback.h"
51 #include "vwindow.h"
52
53
54 #include <string.h>
55
56
57 #define WIDTH 640
58 // full height
59 #define HEIGHT0 585
60 // add tracks dialog
61 #define HEIGHT1 240
62 // offset for folder panel
63 #define HEIGHT2 440
64
65 New::New(MWindow *mwindow)
66 {
67         this->mwindow = mwindow;
68         new_edl = 0;
69         thread = 0;
70 }
71
72 New::~New()
73 {
74         delete thread;
75 }
76
77 int New::handle_event()
78 {
79         mwindow->gui->unlock_window();
80         mwindow->edl->save_defaults(mwindow->defaults);
81         create_new_edl();
82         thread->start();
83         mwindow->gui->lock_window("New::handle_event");
84
85         return 1;
86 }
87
88 void New::create_new_edl()
89 {
90         if( !new_edl ) {
91                 new_edl = new EDL;
92                 new_edl->create_objects();
93                 new_edl->load_defaults(mwindow->defaults);
94         }
95 }
96
97
98 int New::create_new_project(int load_mode)
99 {
100         mwindow->stop_playback(0);
101         mwindow->gui->lock_window();
102         mwindow->reset_caches();
103
104         memcpy(new_edl->session->achannel_positions,
105                 &mwindow->preferences->channel_positions[new_edl->session->audio_channels - 1],
106                 sizeof(new_edl->session->achannel_positions));
107         new_edl->session->boundaries();
108         new_edl->create_default_tracks();
109         if( load_mode == LOADMODE_NEW_TRACKS ) {
110                 Tracks *tracks =  mwindow->edl->tracks;
111                 int vindex = tracks->total_video_tracks();
112                 int aindex = tracks->total_audio_tracks();
113                 for( Track *track=new_edl->tracks->first; track; track=track->next ) {
114                         switch( track->data_type ) {
115                         case TRACK_AUDIO:
116                                 sprintf(track->title, _("Audio %d"), ++aindex);
117                                 break;
118                         case TRACK_VIDEO:
119                                 sprintf(track->title, _("Video %d"), ++vindex);
120                                 break;
121                         }
122                 }
123         }
124         mwindow->undo->update_undo_before();
125         mwindow->set_filename(new_edl->path);
126         ArrayList<EDL *>new_edls;
127         new_edls.append(new_edl);
128         mwindow->paste_edls(&new_edls, load_mode, 0,0,0,0,0,0);
129         new_edl->remove_user();
130         new_edl = 0;
131
132 // Load file sequence
133         mwindow->update_project(load_mode);
134         mwindow->session->changes_made = 0;
135         mwindow->undo->update_undo_after(load_mode == LOADMODE_REPLACE ?
136                 _("New Project") : _("Append to Project"), LOAD_ALL);
137         mwindow->gui->unlock_window();
138         return 0;
139 }
140
141 NewProject::NewProject(MWindow *mwindow)
142  : BC_MenuItem(_("New Project..."), "n", 'n'), New(mwindow)
143 {
144 }
145 NewProject::~NewProject()
146 {
147 }
148
149 void NewProject::create_objects()
150 {
151         thread = new NewThread(mwindow, this,
152                 _(PROGRAM_NAME ": New Project"), LOADMODE_REPLACE);
153 }
154
155 AppendTracks::AppendTracks(MWindow *mwindow)
156  : BC_MenuItem(_("Append to Project..."), "N", 'N'), New(mwindow)
157 {
158         set_shift(1);
159 }
160 AppendTracks::~AppendTracks()
161 {
162 }
163
164 void AppendTracks::create_objects()
165 {
166         thread = new NewThread(mwindow, this,
167                 _(PROGRAM_NAME ": Append to Project"), LOADMODE_NEW_TRACKS);
168 }
169
170
171 NewThread::NewThread(MWindow *mwindow, New *new_project,
172                 const char *title, int load_mode)
173  : BC_DialogThread()
174 {
175         this->mwindow = mwindow;
176         this->new_project = new_project;
177         this->title = title;
178         this->load_mode = load_mode;
179         nwindow = 0;
180 }
181
182 NewThread::~NewThread()
183 {
184         close_window();
185 }
186
187 BC_Window* NewThread::new_gui()
188 {
189         mwindow->edl->save_defaults(mwindow->defaults);
190         new_project->create_new_edl();
191         load_defaults();
192
193         mwindow->gui->lock_window("NewThread::new_gui");
194         int x = mwindow->gui->get_pop_cursor_x(0);
195         int y = mwindow->gui->get_pop_cursor_y(0);
196
197         nwindow = new NewWindow(mwindow, this, x, y);
198         nwindow->create_objects();
199         mwindow->gui->unlock_window();
200         return nwindow;
201 }
202
203 void NewThread::handle_done_event(int result)
204 {
205         if( !result ) {
206                 const char *project_folder = nwindow->folder->get_text();
207                 const char *project_name = nwindow->name->get_text();
208                 if( project_folder[0] && project_name[0] ) {
209                         nwindow->recent_folder->add_item("PROJECT", project_folder);
210                         char project_path[BCTEXTLEN], *ep = project_path + sizeof(project_path);
211                         FileSystem fs;  fs.join_names(project_path, project_folder, project_name);
212                         char *bp = strrchr(project_path, '/');
213                         if( !bp ) bp = project_path;
214                         bp = strrchr(bp, '.');
215                         if( !bp ) bp = project_path + strlen(project_path);
216                         if( strcasecmp(bp,".xml") ) snprintf(bp, ep-bp, ".xml");
217                         fs.complete_path(project_path);
218                         EDL *new_edl = new_project->new_edl;
219                         bp = FileSystem::basepath(project_path);
220                         strcpy(new_edl->path, bp);  delete [] bp;
221                 }
222         }
223 }
224
225 void NewThread::handle_close_event(int result)
226 {
227         if( !new_project->new_edl ) return;
228
229         FileSystem fs;
230         char *path = new_project->new_edl->path;
231         char *bp = path;
232         while( !result ) {
233                 while( *bp == '/' ) ++bp;
234                 if( !(bp = strchr(bp, '/')) ) break;
235                 char dir_path[BCTEXTLEN];
236                 int len = bp - path;
237                 strncpy(dir_path, path, len);
238                 dir_path[len] = 0;
239                 if( fs.is_dir(dir_path) ) continue;
240                 if( fs.create_dir(dir_path) ) {
241                         eprintf(_("Cannot create and access project path:\n%s"),
242                                 dir_path);
243                         result = 1;
244                 }
245         }
246
247         if( !result ) {
248                 new_project->new_edl->save_defaults(mwindow->defaults);
249                 mwindow->defaults->save();
250                 new_project->create_new_project(load_mode);
251         }
252         else { // Aborted
253                 new_project->new_edl->Garbage::remove_user();
254                 new_project->new_edl = 0;
255         }
256 }
257
258 int NewThread::load_defaults()
259 {
260         auto_aspect = mwindow->defaults->get("AUTOASPECT", 0);
261         return 0;
262 }
263
264 int NewThread::save_defaults()
265 {
266         mwindow->defaults->update("AUTOASPECT", auto_aspect);
267         return 0;
268 }
269
270 int NewThread::update_aspect()
271 {
272         if( auto_aspect ) {
273                 char string[BCTEXTLEN];
274                 mwindow->create_aspect_ratio(new_project->new_edl->session->aspect_w,
275                         new_project->new_edl->session->aspect_h,
276                         new_project->new_edl->session->output_w,
277                         new_project->new_edl->session->output_h);
278                 sprintf(string, "%.02f", new_project->new_edl->session->aspect_w);
279                 if( nwindow->aspect_w_text ) nwindow->aspect_w_text->update(string);
280                 sprintf(string, "%.02f", new_project->new_edl->session->aspect_h);
281                 if( nwindow->aspect_h_text )nwindow->aspect_h_text->update(string);
282         }
283         return 0;
284 }
285
286
287 NewWindow::NewWindow(MWindow *mwindow, NewThread *new_thread, int x, int y)
288  : BC_Window(new_thread->title, x, y,
289                 WIDTH, new_thread->load_mode == LOADMODE_REPLACE ? HEIGHT0 : HEIGHT1,
290                 -1, -1, 0, 0, 1)
291 {
292         this->mwindow = mwindow;
293         this->new_thread = new_thread;
294         this->new_edl = new_thread->new_project->new_edl;
295         format_presets = 0;
296         atracks = 0;
297         achannels = 0;
298         sample_rate = 0;
299         vtracks = 0;
300         frame_rate = 0;
301         output_w_text = 0;
302         output_h_text = 0;
303         aspect_w_text = 0;
304         aspect_h_text = 0;
305         interlace_pulldown = 0;
306         color_model = 0;
307         folder = 0;
308         name = 0;
309         recent_folder = 0;
310 }
311
312 NewWindow::~NewWindow()
313 {
314         lock_window("NewWindow::~NewWindow");
315         delete format_presets;
316         unlock_window();
317 }
318
319 void NewWindow::create_objects()
320 {
321         int x = 10, y = 10, x1, y1;
322         BC_TextBox *textbox;
323         BC_Title *title;
324
325         lock_window("NewWindow::create_objects");
326         mwindow->theme->draw_new_bg(this);
327
328         add_subwindow( new BC_Title(x, y, new_thread->load_mode == LOADMODE_REPLACE ?
329                         _("Parameters for the new project:") :
330                         _("Parameters for additional tracks:") ) );
331         y += 20;
332
333         format_presets = new NewPresets(mwindow,
334                 this,
335                 x,
336                 y);
337         format_presets->create_objects();
338         x = format_presets->x;
339         y = format_presets->y;
340
341         y += 40;
342         y1 = y;
343         add_subwindow(new BC_Title(x, y, _("Audio"), LARGEFONT));
344         y += 30;
345
346         x1 = x;
347         add_subwindow(new BC_Title(x1, y, _("Tracks:")));
348         x1 += 100;
349         add_subwindow(atracks = new NewATracks(this, "", x1, y));
350         x1 += atracks->get_w();
351         add_subwindow(new NewATracksTumbler(this, x1, y));
352         y += atracks->get_h() + 5;
353
354         if( new_thread->load_mode == LOADMODE_REPLACE ) {
355                 x1 = x;
356                 add_subwindow(new BC_Title(x1, y, _("Channels:")));
357                 x1 += 100;
358                 add_subwindow(achannels = new NewAChannels(this, "", x1, y));
359                 x1 += achannels->get_w();
360                 add_subwindow(new NewAChannelsTumbler(this, x1, y));
361                 y += achannels->get_h() + 5;
362
363                 x1 = x;
364                 add_subwindow(new BC_Title(x1, y, _("Samplerate:")));
365                 x1 += 100;
366                 add_subwindow(sample_rate = new NewSampleRate(this, "", x1, y));
367                 x1 += sample_rate->get_w();
368                 add_subwindow(new SampleRatePulldown(mwindow, sample_rate, x1, y));
369         }
370
371         x += 250;
372         y = y1;
373         add_subwindow(new BC_Title(x, y, _("Video"), LARGEFONT));
374         y += 30;
375         x1 = x;
376         add_subwindow(new BC_Title(x1, y, _("Tracks:")));
377         x1 += 115;
378         add_subwindow(vtracks = new NewVTracks(this, "", x1, y));
379         x1 += vtracks->get_w();
380         add_subwindow(new NewVTracksTumbler(this, x1, y));
381         y += vtracks->get_h() + 5;
382
383         if( new_thread->load_mode == LOADMODE_REPLACE ) {
384 //              x1 = x;
385 //              add_subwindow(new BC_Title(x1, y, _("Channels:")));
386 //              x1 += 100;
387 //              add_subwindow(vchannels = new NewVChannels(this, "", x1, y));
388 //              x1 += vchannels->get_w();
389 //              add_subwindow(new NewVChannelsTumbler(this, x1, y));
390 //              y += vchannels->get_h() + 5;
391                 x1 = x;
392                 add_subwindow(new BC_Title(x1, y, _("Framerate:")));
393                 x1 += 115;
394                 add_subwindow(frame_rate = new NewFrameRate(this, "", x1, y));
395                 x1 += frame_rate->get_w();
396                 add_subwindow(new FrameRatePulldown(mwindow, frame_rate, x1, y));
397                 y += frame_rate->get_h() + 5;
398         }
399 //      x1 = x;
400 //      add_subwindow(new BC_Title(x1, y, _("Canvas size:")));
401 //      x1 += 100;
402 //      add_subwindow(canvas_w_text = new NewTrackW(this, x1, y));
403 //      x1 += canvas_w_text->get_w() + 2;
404 //      add_subwindow(new BC_Title(x1, y, "x"));
405 //      x1 += 10;
406 //      add_subwindow(canvas_h_text = new NewTrackH(this, x1, y));
407 //      x1 += canvas_h_text->get_w();
408 //      add_subwindow(new FrameSizePulldown(mwindow,
409 //              canvas_w_text,
410 //              canvas_h_text,
411 //              x1,
412 //              y));
413 //      x1 += 100;
414 //      add_subwindow(new NewCloneToggle(mwindow, this, x1, y));
415 //      y += canvas_h_text->get_h() + 5;
416
417         x1 = x;
418         add_subwindow(new BC_Title(x1, y, _("Track size:")));
419         x1 += 115;
420         add_subwindow(output_w_text = new NewOutputW(this, x1, y));
421         x1 += output_w_text->get_w() + 2;
422         add_subwindow(new BC_Title(x1, y, "x"));
423         x1 += 10;
424         add_subwindow(output_h_text = new NewOutputH(this, x1, y));
425         x1 += output_h_text->get_w();
426         FrameSizePulldown *pulldown;
427         add_subwindow(pulldown = new FrameSizePulldown(mwindow->theme,
428                 output_w_text,
429                 output_h_text,
430                 x1,
431                 y));
432         x1 += pulldown->get_w() + 10;
433         add_subwindow(new NewSwapExtents(mwindow, this, x1, y));
434         y += output_h_text->get_h() + 5;
435
436         if( new_thread->load_mode == LOADMODE_REPLACE ) {
437                 x1 = x;
438                 add_subwindow(new BC_Title(x1, y, _("Aspect ratio:")));
439                 x1 += 115;
440                 add_subwindow(aspect_w_text = new NewAspectW(this, "", x1, y));
441                 x1 += aspect_w_text->get_w() + 2;
442                 add_subwindow(new BC_Title(x1, y, ":"));
443                 x1 += 10;
444                 add_subwindow(aspect_h_text = new NewAspectH(this, "", x1, y));
445                 x1 += aspect_h_text->get_w();
446                 add_subwindow(new AspectPulldown(mwindow,
447                         aspect_w_text, aspect_h_text, x1, y));
448
449                 x1 = aspect_w_text->get_x();
450                 y += aspect_w_text->get_h() + 5;
451                 add_subwindow(new NewAspectAuto(this, x1, y));
452                 y += 40;
453                 add_subwindow(title = new BC_Title(x, y, _("Color model:")));
454                 x1 = x + title->get_w();
455                 y1 = y;  y += title->get_h() + 10;
456                 add_subwindow(title = new BC_Title(x, y, _("Interlace mode:")));
457                 int x2 = x + title->get_w();
458                 int y2 = y;  y += title->get_h() + 10;
459                 if( x1 < x2 ) x1 = x2;
460                 x1 += 20;
461                 add_subwindow(textbox = new BC_TextBox(x1, y1, 150, 1, ""));
462                 add_subwindow(color_model = new ColormodelPulldown(mwindow,
463                         textbox, &new_edl->session->color_model, x1+textbox->get_w(), y1));
464                 add_subwindow(textbox = new BC_TextBox(x1, y2, 150, 1, ""));
465                 add_subwindow(interlace_pulldown = new InterlacemodePulldown(mwindow,
466                         textbox, &new_edl->session->interlace_mode,
467                         (ArrayList<BC_ListBoxItem*>*)&mwindow->interlace_project_modes,
468                         x1+textbox->get_w(), y2));
469
470                 x = 20;  y = HEIGHT2;
471                 add_subwindow(title = new BC_Title(x, y, _("Create project folder in:")));
472                 x1 = x;  y += title->get_h() + 5;
473                 add_subwindow(folder = new BC_TextBox(x1, y, get_w()-x1-64, 1, ""));
474                 x1 += folder->get_w() + 10;
475                 add_subwindow(recent_folder = new BC_RecentList("FOLDER", mwindow->defaults, folder));
476                 recent_folder->load_items("PROJECT");
477                 x1 = recent_folder->get_x() + recent_folder->get_w();
478                 add_subwindow(new BrowseButton(mwindow->theme, this, folder, x1, y, "",
479                         _("Project Directory"), _("Project Directory Path:"), 1));
480                 y += folder->get_h() + 10;  x1 = x;
481                 add_subwindow(title = new BC_Title(x1, y, _("Project Name:")));
482                 x1 += title->get_w() + 10;
483                 add_subwindow(name = new BC_TextBox(x1, y, get_w()-x1-64, 1, ""));
484         }
485
486         add_subwindow(new BC_OKButton(this,
487                 mwindow->theme->get_image_set("new_ok_images")));
488         add_subwindow(new BC_CancelButton(this,
489                 mwindow->theme->get_image_set("new_cancel_images")));
490         flash();
491         update();
492         show_window();
493         unlock_window();
494 }
495
496 int NewWindow::update()
497 {
498         if( atracks ) atracks->update((int64_t)new_edl->session->audio_tracks);
499         if( achannels ) achannels->update((int64_t)new_edl->session->audio_channels);
500         if( sample_rate ) sample_rate->update((int64_t)new_edl->session->sample_rate);
501         if( vtracks ) vtracks->update((int64_t)new_edl->session->video_tracks);
502         if( frame_rate ) frame_rate->update((float)new_edl->session->frame_rate);
503         if( output_w_text ) output_w_text->update((int64_t)new_edl->session->output_w);
504         if( output_h_text ) output_h_text->update((int64_t)new_edl->session->output_h);
505         if( aspect_w_text ) aspect_w_text->update((float)new_edl->session->aspect_w);
506         if( aspect_h_text ) aspect_h_text->update((float)new_edl->session->aspect_h);
507         if( interlace_pulldown ) interlace_pulldown->update(new_edl->session->interlace_mode);
508         if( color_model ) color_model->update_value(new_edl->session->color_model);
509         return 0;
510 }
511
512
513 NewPresets::NewPresets(MWindow *mwindow, NewWindow *gui, int x, int y)
514  : FormatPresets(mwindow, gui, 0, x, y)
515 {
516 }
517
518 NewPresets::~NewPresets()
519 {
520 }
521
522 int NewPresets::handle_event()
523 {
524         new_gui->update();
525         return 1;
526 }
527
528 EDL* NewPresets::get_edl()
529 {
530         return new_gui->new_edl;
531 }
532
533
534 NewATracks::NewATracks(NewWindow *nwindow, const char *text, int x, int y)
535  : BC_TextBox(x, y, 90, 1, text)
536 {
537         this->nwindow = nwindow;
538 }
539
540 int NewATracks::handle_event()
541 {
542         nwindow->new_edl->session->audio_tracks = atol(get_text());
543         return 1;
544 }
545
546 NewATracksTumbler::NewATracksTumbler(NewWindow *nwindow, int x, int y)
547  : BC_Tumbler(x, y)
548 {
549         this->nwindow = nwindow;
550 }
551 int NewATracksTumbler::handle_up_event()
552 {
553         nwindow->new_edl->session->audio_tracks++;
554         nwindow->new_edl->boundaries();
555         nwindow->update();
556         return 1;
557 }
558 int NewATracksTumbler::handle_down_event()
559 {
560         nwindow->new_edl->session->audio_tracks--;
561         nwindow->new_edl->boundaries();
562         nwindow->update();
563         return 1;
564 }
565
566
567 NewAChannels::NewAChannels(NewWindow *nwindow, const char *text, int x, int y)
568  : BC_TextBox(x, y, 90, 1, text)
569 {
570         this->nwindow = nwindow;
571 }
572
573 int NewAChannels::handle_event()
574 {
575         nwindow->new_edl->session->audio_channels = atol(get_text());
576         return 1;
577 }
578
579
580 NewAChannelsTumbler::NewAChannelsTumbler(NewWindow *nwindow, int x, int y)
581  : BC_Tumbler(x, y)
582 {
583         this->nwindow = nwindow;
584 }
585 int NewAChannelsTumbler::handle_up_event()
586 {
587         nwindow->new_edl->session->audio_channels++;
588         nwindow->new_edl->boundaries();
589         nwindow->update();
590         return 1;
591 }
592 int NewAChannelsTumbler::handle_down_event()
593 {
594         nwindow->new_edl->session->audio_channels--;
595         nwindow->new_edl->boundaries();
596         nwindow->update();
597         return 1;
598 }
599
600
601 NewSampleRate::NewSampleRate(NewWindow *nwindow, const char *text, int x, int y)
602  : BC_TextBox(x, y, 90, 1, text)
603 {
604         this->nwindow = nwindow;
605 }
606
607 int NewSampleRate::handle_event()
608 {
609         nwindow->new_edl->session->sample_rate = atol(get_text());
610         return 1;
611 }
612
613
614 SampleRatePulldown::SampleRatePulldown(MWindow *mwindow, BC_TextBox *output, int x, int y)
615  : BC_ListBox(x, y, 100, 200, LISTBOX_TEXT,
616         &mwindow->theme->sample_rates, 0, 0, 1, 0, 1)
617 {
618         this->mwindow = mwindow;
619         this->output = output;
620 }
621 int SampleRatePulldown::handle_event()
622 {
623         char *text = get_selection(0, 0)->get_text();
624         output->update(text);
625         output->handle_event();
626         return 1;
627 }
628
629
630 NewVTracks::NewVTracks(NewWindow *nwindow, const char *text, int x, int y)
631  : BC_TextBox(x, y, 90, 1, text)
632 {
633         this->nwindow = nwindow;
634 }
635
636 int NewVTracks::handle_event()
637 {
638         nwindow->new_edl->session->video_tracks = atol(get_text());
639         return 1;
640 }
641
642
643 NewVTracksTumbler::NewVTracksTumbler(NewWindow *nwindow, int x, int y)
644  : BC_Tumbler(x, y)
645 {
646         this->nwindow = nwindow;
647 }
648 int NewVTracksTumbler::handle_up_event()
649 {
650         nwindow->new_edl->session->video_tracks++;
651         nwindow->new_edl->boundaries();
652         nwindow->update();
653         return 1;
654 }
655 int NewVTracksTumbler::handle_down_event()
656 {
657         nwindow->new_edl->session->video_tracks--;
658         nwindow->new_edl->boundaries();
659         nwindow->update();
660         return 1;
661 }
662
663
664 NewVChannels::NewVChannels(NewWindow *nwindow, const char *text, int x, int y)
665  : BC_TextBox(x, y, 90, 1, text)
666 {
667         this->nwindow = nwindow;
668 }
669
670 int NewVChannels::handle_event()
671 {
672         nwindow->new_edl->session->video_channels = atol(get_text());
673         return 1;
674 }
675
676
677 NewVChannelsTumbler::NewVChannelsTumbler(NewWindow *nwindow, int x, int y)
678  : BC_Tumbler(x, y)
679 {
680         this->nwindow = nwindow;
681 }
682 int NewVChannelsTumbler::handle_up_event()
683 {
684         nwindow->new_edl->session->video_channels++;
685         nwindow->new_edl->boundaries();
686         nwindow->update();
687         return 1;
688 }
689 int NewVChannelsTumbler::handle_down_event()
690 {
691         nwindow->new_edl->session->video_channels--;
692         nwindow->new_edl->boundaries();
693         nwindow->update();
694         return 1;
695 }
696
697
698 NewFrameRate::NewFrameRate(NewWindow *nwindow, const char *text, int x, int y)
699  : BC_TextBox(x, y, 90, 1, text)
700 {
701         this->nwindow = nwindow;
702 }
703
704 int NewFrameRate::handle_event()
705 {
706         nwindow->new_edl->session->frame_rate = Units::atoframerate(get_text());
707         return 1;
708 }
709
710
711 FrameRatePulldown::FrameRatePulldown(MWindow *mwindow,
712         BC_TextBox *output, int x, int y)
713  : BC_ListBox(x, y, 150, 250, LISTBOX_TEXT,
714         &mwindow->theme->frame_rates, 0, 0, 1, 0, 1)
715 {
716         this->mwindow = mwindow;
717         this->output = output;
718 }
719 int FrameRatePulldown::handle_event()
720 {
721         char *text = get_selection(0, 0)->get_text();
722         output->update(text);
723         output->handle_event();
724         return 1;
725 }
726
727 FrameSizePulldown::FrameSizePulldown(Theme *theme,
728                 BC_TextBox *output_w, BC_TextBox *output_h, int x, int y)
729  : BC_ListBox(x, y, 180, 250, LISTBOX_TEXT,
730         &theme->frame_sizes, 0, 0, 1, 0, 1)
731 {
732         this->theme = theme;
733         this->output_w = output_w;
734         this->output_h = output_h;
735 }
736
737 int FrameSizePulldown::handle_event()
738 {
739         char *text = get_selection(0, 0)->get_text();
740         char string[BCTEXTLEN];
741         int64_t w, h;
742         char *ptr;
743
744         strcpy(string, text);
745         ptr = strrchr(string, 'x');
746         if( ptr ) {
747                 ptr++;
748                 h = atol(ptr);
749
750                 *--ptr = 0;
751                 w = atol(string);
752                 output_w->update(w);
753                 output_h->update(h);
754                 output_w->handle_event();
755                 output_h->handle_event();
756         }
757         return 1;
758 }
759
760
761 NewOutputW::NewOutputW(NewWindow *nwindow, int x, int y)
762  : BC_TextBox(x, y, 70, 1, nwindow->new_edl->session->output_w)
763 {
764         this->nwindow = nwindow;
765 }
766 int NewOutputW::handle_event()
767 {
768         nwindow->new_edl->session->output_w = MAX(1,atol(get_text()));
769         nwindow->new_thread->update_aspect();
770         return 1;
771 }
772
773
774 NewOutputH::NewOutputH(NewWindow *nwindow, int x, int y)
775  : BC_TextBox(x, y, 70, 1, nwindow->new_edl->session->output_h)
776 {
777         this->nwindow = nwindow;
778 }
779 int NewOutputH::handle_event()
780 {
781         nwindow->new_edl->session->output_h = MAX(1, atol(get_text()));
782         nwindow->new_thread->update_aspect();
783         return 1;
784 }
785
786
787 NewAspectW::NewAspectW(NewWindow *nwindow, const char *text, int x, int y)
788  : BC_TextBox(x, y, 70, 1, text)
789 {
790         this->nwindow = nwindow;
791 }
792
793 int NewAspectW::handle_event()
794 {
795         nwindow->new_edl->session->aspect_w = atof(get_text());
796         return 1;
797 }
798
799
800 NewAspectH::NewAspectH(NewWindow *nwindow, const char *text, int x, int y)
801  : BC_TextBox(x, y, 70, 1, text)
802 {
803         this->nwindow = nwindow;
804 }
805
806 int NewAspectH::handle_event()
807 {
808         nwindow->new_edl->session->aspect_h = atof(get_text());
809         return 1;
810 }
811
812
813 AspectPulldown::AspectPulldown(MWindow *mwindow,
814                 BC_TextBox *output_w, BC_TextBox *output_h, int x, int y)
815  : BC_ListBox(x, y, 100, 200, LISTBOX_TEXT,
816         &mwindow->theme->aspect_ratios, 0, 0, 1, 0, 1)
817 {
818         this->mwindow = mwindow;
819         this->output_w = output_w;
820         this->output_h = output_h;
821 }
822
823 int AspectPulldown::handle_event()
824 {
825         char *text = get_selection(0, 0)->get_text();
826         char string[BCTEXTLEN];
827         float w, h;
828         char *ptr;
829
830         strcpy(string, text);
831         ptr = strrchr(string, ':');
832         if( ptr ) {
833                 ptr++;
834                 h = atof(ptr);
835
836                 *--ptr = 0;
837                 w = atof(string);
838                 output_w->update(w);
839                 output_h->update(h);
840                 output_w->handle_event();
841                 output_h->handle_event();
842         }
843         return 1;
844 }
845
846
847 ColormodelItem::ColormodelItem(const char *text, int value)
848  : BC_ListBoxItem(text)
849 {
850         this->value = value;
851 }
852
853 ColormodelPulldown::ColormodelPulldown(MWindow *mwindow,
854                 BC_TextBox *output_text, int *output_value, int x, int y)
855  : BC_ListBox(x, y, 200, 150, LISTBOX_TEXT,
856         (ArrayList<BC_ListBoxItem*>*)&mwindow->colormodels, 0, 0, 1, 0, 1)
857 {
858         this->mwindow = mwindow;
859         this->output_text = output_text;
860         this->output_value = output_value;
861         output_text->update(colormodel_to_text());
862 }
863
864 int ColormodelPulldown::handle_event()
865 {
866         output_text->update(get_selection(0, 0)->get_text());
867         *output_value = ((ColormodelItem*)get_selection(0, 0))->value;
868         return 1;
869 }
870
871 const char* ColormodelPulldown::colormodel_to_text()
872 {
873         for( int i=0; i<mwindow->colormodels.total; ++i )
874                 if( mwindow->colormodels.values[i]->value == *output_value )
875                         return mwindow->colormodels.values[i]->get_text();
876         return _("Unknown");
877 }
878
879 void ColormodelPulldown::update_value(int value)
880 {
881         *output_value = value;
882         output_text->update(colormodel_to_text());
883 }
884
885
886 InterlacemodeItem::InterlacemodeItem(const char *text, int value)
887  : BC_ListBoxItem(text)
888 {
889         this->value = value;
890 }
891
892 InterlacemodePulldown::InterlacemodePulldown(MWindow *mwindow,
893                 BC_TextBox *output_text,
894                 int *output_value,
895                 ArrayList<BC_ListBoxItem*> *data,
896                 int x,
897                 int y)
898  : BC_ListBox(x, y, 200, 150, LISTBOX_TEXT, data, 0, 0, 1, 0, 1)
899 {
900         this->mwindow = mwindow;
901         this->output_text = output_text;
902         this->output_value = output_value;
903         output_text->update(interlacemode_to_text());
904 }
905
906 int InterlacemodePulldown::handle_event()
907 {
908         output_text->update(get_selection(0, 0)->get_text());
909         *output_value = ((InterlacemodeItem*)get_selection(0, 0))->value;
910         return 1;
911 }
912
913 const char* InterlacemodePulldown::interlacemode_to_text()
914 {
915         ilacemode_to_text(this->string,*output_value);
916         return (this->string);
917 }
918
919 int InterlacemodePulldown::update(int interlace_mode)
920 {
921         *output_value = interlace_mode;
922         output_text->update(interlacemode_to_text());
923         return 1;
924 }
925
926
927 NewAspectAuto::NewAspectAuto(NewWindow *nwindow, int x, int y)
928  : BC_CheckBox(x, y, nwindow->new_thread->auto_aspect, _("Auto aspect ratio"))
929 {
930         this->nwindow = nwindow;
931 }
932 NewAspectAuto::~NewAspectAuto()
933 {
934 }
935 int NewAspectAuto::handle_event()
936 {
937         nwindow->new_thread->auto_aspect = get_value();
938         nwindow->new_thread->update_aspect();
939         return 1;
940 }
941
942
943 NewSwapExtents::NewSwapExtents(MWindow *mwindow, NewWindow *gui, int x, int y)
944  : BC_Button(x, y, mwindow->theme->get_image_set("swap_extents"))
945 {
946         this->mwindow = mwindow;
947         this->gui = gui;
948         set_tooltip(_("Swap dimensions"));
949 }
950
951 int NewSwapExtents::handle_event()
952 {
953         int w = gui->new_edl->session->output_w;
954         int h = gui->new_edl->session->output_h;
955         gui->new_edl->session->output_w = h;
956         gui->new_edl->session->output_h = w;
957         gui->output_w_text->update((int64_t)h);
958         gui->output_h_text->update((int64_t)w);
959         gui->new_thread->update_aspect();
960         return 1;
961 }
962