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