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