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