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