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