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