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