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