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