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