merged hv7 mod
[goodguy/history.git] / cinelerra-5.1 / cinelerra / formattools.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2010-2013 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 "asset.h"
23 #include "bcsignals.h"
24 #include "clip.h"
25 #include "guicast.h"
26 #include "file.h"
27 #include "filesystem.h"
28 #include "formattools.h"
29 #include "language.h"
30 #include "libdv.h"
31 #include "libmjpeg.h"
32 #include "maxchannels.h"
33 #include "mwindow.h"
34 #include "preferences.h"
35 #include "theme.h"
36 #include "videodevice.inc"
37 #include <string.h>
38 #include <unistd.h>
39 #include <ctype.h>
40
41
42 FormatTools::FormatTools(MWindow *mwindow,
43                                 BC_WindowBase *window,
44                                 Asset *asset)
45 {
46         this->mwindow = mwindow;
47         this->window = window;
48         this->asset = asset;
49         this->plugindb = mwindow->plugindb;
50
51         aparams_button = 0;
52         vparams_button = 0;
53         aparams_thread = 0;
54         vparams_thread = 0;
55         channels_tumbler = 0;
56         audio_switch = 0;
57         video_switch = 0;
58         path_textbox = 0;
59         path_button = 0;
60         path_recent = 0;
61         format_title = 0;
62         format_button = 0;
63         format_text = 0;
64         audio_title = 0;
65         video_title = 0;
66         channels_title = 0;
67         channels_button = 0;
68         multiple_files = 0;
69         w = window->get_w();
70
71         recording = 0;
72         use_brender = 0;
73         do_audio = 0;
74         do_video = 0;
75         prompt_audio = 0;
76         prompt_audio_channels = 0;
77         prompt_video = 0;
78         prompt_video_compression = 0;
79         strategy = 0;
80         locked_compressor = 0;
81         video_driver = 0;
82 }
83
84 FormatTools::~FormatTools()
85 {
86         delete path_recent;
87 SET_TRACE
88         delete path_button;
89 SET_TRACE
90         delete path_textbox;
91 SET_TRACE
92         delete format_button;
93 SET_TRACE
94
95         if(aparams_button) delete aparams_button;
96 SET_TRACE
97         if(vparams_button) delete vparams_button;
98 SET_TRACE
99         if(aparams_thread) delete aparams_thread;
100 SET_TRACE
101         if(vparams_thread) delete vparams_thread;
102 SET_TRACE
103         if(channels_tumbler) delete channels_tumbler;
104 }
105
106 void FormatTools::create_objects(
107                 int &init_x, int &init_y,
108                 int do_audio, int do_video,   // Include support for audio, video
109                 int prompt_audio, int prompt_video, // Include checkbox for audio, video
110                 int prompt_audio_channels,
111                 int prompt_video_compression,
112                 const char *locked_compressor,
113                 int recording,
114                 int *strategy,
115                 int brender,
116                 int horizontal_layout)
117 {
118         int x = init_x;
119         int y = init_y;
120         int ylev = init_y;
121         int margin = mwindow->theme->widget_border;
122
123         this->locked_compressor = locked_compressor;
124         this->recording = recording;
125         this->use_brender = brender;
126         this->do_audio = do_audio;
127         this->do_video = do_video;
128         this->prompt_audio = prompt_audio;
129         this->prompt_audio_channels = prompt_audio_channels;
130         this->prompt_video = prompt_video;
131         this->prompt_video_compression = prompt_video_compression;
132         this->strategy = strategy;
133
134 //printf("FormatTools::create_objects 1\n");
135
136 // Modify strategy depending on render farm
137         if(strategy)
138         {
139                 if(mwindow->preferences->use_renderfarm)
140                 {
141                         if(*strategy == FILE_PER_LABEL)
142                                 *strategy = FILE_PER_LABEL_FARM;
143                         else
144                         if(*strategy == SINGLE_PASS)
145                                 *strategy = SINGLE_PASS_FARM;
146                 }
147                 else
148                 {
149                         if(*strategy == FILE_PER_LABEL_FARM)
150                                 *strategy = FILE_PER_LABEL;
151                         else
152                         if(*strategy == SINGLE_PASS_FARM)
153                                 *strategy = SINGLE_PASS;
154                 }
155         }
156
157         if(!recording)
158         {
159                 int px = x;
160                 window->add_subwindow(path_textbox = new FormatPathText(px, y, this));
161                 px += path_textbox->get_w() + 5;
162                 path_recent = new BC_RecentList("PATH", mwindow->defaults,
163                                         path_textbox, 10, px, y, 300, 100);
164                 window->add_subwindow(path_recent);
165                 path_recent->load_items(File::formattostr(asset->format));
166                 px += path_recent->get_w();
167                 window->add_subwindow(path_button = new BrowseButton(
168                         mwindow->theme, window, path_textbox, px, y, asset->path,
169                         _("Output to file"), _("Select a file to write to:"), 0));
170
171 // Set w for user.
172                 w = MAX(w, 305);
173                 y += path_textbox->get_h() + 10;
174         }
175         else
176         {
177 //              w = x + 305;
178                 w = 305;
179         }
180
181         x = init_x;
182         window->add_subwindow(format_title = new BC_Title(x, y, _("File Format:")));
183         x += format_title->get_w() + margin;
184         window->add_subwindow(format_text = new BC_TextBox(x, y, 160, 1,
185                 File::formattostr(asset->format)));
186         x += format_text->get_w() + margin;
187 //printf("FormatTools::create_objects %d %p\n", __LINE__, window);
188         window->add_subwindow(format_button = new FormatFormat(x, y, this));
189         format_button->create_objects();
190         x += format_button->get_w() + 5;
191         window->add_subwindow(ffmpeg_type = new FFMpegType(x, y, 64, 1, asset->fformat));
192         FFMPEG::set_asset_format(asset, asset->fformat);
193         x += ffmpeg_type->get_w();
194         window->add_subwindow(format_ffmpeg = new FormatFFMPEG(x, y, this));
195         format_ffmpeg->create_objects();
196         x = init_x;
197         y += format_button->get_h() + 10;
198         if( do_audio ) {
199                 window->add_subwindow(audio_title = new BC_Title(x, y, _("Audio:"), LARGEFONT,
200                         BC_WindowBase::get_resources()->audiovideo_color));
201                 x += audio_title->get_w() + margin;
202                 window->add_subwindow(aparams_button = new FormatAParams(mwindow, this, x, y));
203                 x += aparams_button->get_w() + margin;
204                 if(prompt_audio) {
205                         window->add_subwindow(audio_switch = new FormatAudio(x, y, this, asset->audio_data));
206                 }
207                 x = init_x;
208                 ylev = y;
209                 y += aparams_button->get_h() + 10;
210
211 // Audio channels only used for recording.
212 //              if(prompt_audio_channels)
213 //              {
214 //                      window->add_subwindow(channels_title = new BC_Title(x, y, _("Number of audio channels to record:")));
215 //                      x += 260;
216 //                      window->add_subwindow(channels_button = new FormatChannels(x, y, this));
217 //                      x += channels_button->get_w() + 5;
218 //                      window->add_subwindow(channels_tumbler = new BC_ITumbler(channels_button, 1, MAXCHANNELS, x, y));
219 //                      y += channels_button->get_h() + 20;
220 //                      x = init_x;
221 //              }
222
223 //printf("FormatTools::create_objects 6\n");
224                 aparams_thread = new FormatAThread(this);
225         }
226
227 //printf("FormatTools::create_objects 7\n");
228         if( do_video ) {
229                 if( horizontal_layout && do_audio ) {
230                         x += 370;
231                         y = ylev;
232                 }
233
234 //printf("FormatTools::create_objects 8\n");
235                 window->add_subwindow(video_title = new BC_Title(x, y, _("Video:"), LARGEFONT,
236                         BC_WindowBase::get_resources()->audiovideo_color));
237                 x += video_title->get_w() + margin;
238                 if(prompt_video_compression) {
239                         window->add_subwindow(vparams_button = new FormatVParams(mwindow, this, x, y));
240                         x += vparams_button->get_w() + margin;
241                 }
242
243 //printf("FormatTools::create_objects 9\n");
244                 if(prompt_video) {
245                         window->add_subwindow(video_switch = new FormatVideo(x, y, this, asset->video_data));
246                         y += video_switch->get_h();
247                 }
248                 else {
249                         y += vparams_button->get_h();
250                 }
251
252 //printf("FormatTools::create_objects 10\n");
253                 y += 10;
254                 vparams_thread = new FormatVThread(this);
255         }
256
257 //printf("FormatTools::create_objects 11\n");
258
259         x = init_x;
260         if(strategy)
261         {
262                 window->add_subwindow(multiple_files = new FormatMultiple(mwindow, x, y, strategy));
263                 y += multiple_files->get_h() + 10;
264         }
265
266 //printf("FormatTools::create_objects 12\n");
267
268         init_y = y;
269         update_format();
270 }
271
272 void FormatTools::update_driver(int driver)
273 {
274         this->video_driver = driver;
275
276         locked_compressor = 0;
277         switch(driver)
278         {
279                 case CAPTURE_DVB:
280                 case VIDEO4LINUX2MPEG:
281 // Just give the user information about how the stream is going to be
282 // stored but don't change the asset.
283 // Want to be able to revert to user settings.
284                         if(asset->format == FILE_MPEG) break;
285                         asset->format = FILE_MPEG;
286                         format_text->update(File::formattostr(asset->format));
287                         asset->audio_data = 1;
288                         asset->video_data = 1;
289                         audio_switch->update(1);
290                         video_switch->update(1);
291                         break;
292
293                 case CAPTURE_IEC61883:
294                 case CAPTURE_FIREWIRE:
295                 case VIDEO4LINUX2JPEG:
296                 case CAPTURE_JPEG_WEBCAM:
297                         asset->format = FILE_FFMPEG;
298                         format_text->update(File::formattostr(asset->format));
299
300                         switch(driver) {
301                         case CAPTURE_IEC61883:
302                         case CAPTURE_FIREWIRE:
303                                 locked_compressor = (char*)CODEC_TAG_DVSD;
304                                 break;
305
306                         case VIDEO4LINUX2JPEG:
307                                 locked_compressor = (char*)CODEC_TAG_MJPEG;
308                                 break;
309
310                         case CAPTURE_JPEG_WEBCAM:
311                                 locked_compressor = (char*)CODEC_TAG_JPEG;
312                                 break;
313                         }
314                         if( locked_compressor )
315                                 strcpy(asset->vcodec, locked_compressor);
316
317                         audio_switch->update(asset->audio_data);
318                         video_switch->update(asset->video_data);
319                         break;
320
321                 default:
322                         format_text->update(File::formattostr(asset->format));
323                         audio_switch->update(asset->audio_data);
324                         video_switch->update(asset->video_data);
325                         break;
326         }
327         close_format_windows();
328         update_format();
329 }
330
331 void FormatTools::update_format()
332 {
333         if( do_audio && prompt_audio && audio_switch ) {
334                 audio_switch->update(asset->audio_data);
335                 if( File::renders_audio(asset) )
336                         audio_switch->enable();
337                 else
338                         audio_switch->disable();
339         }
340         if( do_video && prompt_video && video_switch ) {
341                 video_switch->update(asset->video_data);
342                 if( File::renders_video(asset) )
343                         video_switch->enable();
344                 else
345                         video_switch->disable();
346         }
347         if( asset->format == FILE_FFMPEG ) {
348                 ffmpeg_type->show();
349                 format_ffmpeg->show();
350         }
351         else {
352                 ffmpeg_type->hide();
353                 format_ffmpeg->hide();
354         }
355 }
356
357 int FormatTools::handle_event()
358 {
359         return 0;
360 }
361
362 Asset* FormatTools::get_asset()
363 {
364         return asset;
365 }
366
367 void FormatTools::update_extension()
368 {
369         const char *extension = File::get_tag(asset->format);
370 // split multiple extensions
371         ArrayList<const char*> extensions;
372         int len = !extension ? -1 : strlen(extension);
373         const char *extension_ptr = extension;
374         for(int i = 0; i <= len; i++)
375         {
376                 if(extension[i] == '/' || extension[i] == 0)
377                 {
378                         extensions.append(extension_ptr);
379                         extension_ptr = extension + i + 1;
380                 }
381         }
382
383         if(extensions.size())
384         {
385                 char *ptr = strrchr(asset->path, '.');
386                 if(!ptr)
387                 {
388                         ptr = asset->path + strlen(asset->path);
389                         *ptr = '.';
390                 }
391                 ptr++;
392
393 // test for equivalent extension
394                 int need_extension = 1;
395                 //int extension_len = 0;
396                 for(int i = 0; i < extensions.size() && need_extension; i++)
397                 {
398                         char *ptr1 = ptr;
399                         extension_ptr = extensions.get(i);
400 // test an extension
401                         need_extension = 0;
402                         while(*ptr1 != 0 && *extension_ptr != 0 && *extension_ptr != '/')
403                         {
404                                 if(tolower(*ptr1) != tolower(*extension_ptr))
405                                 {
406                                         need_extension = 1;
407                                         break;
408                                 }
409                                 ptr1++;
410                                 extension_ptr++;
411                         }
412
413                         if(*ptr1 == 0 &&
414                                 *extension_ptr != 0 &&
415                                 *extension_ptr != '/')
416                                 need_extension = 1;
417                 }
418
419 //printf("FormatTools::update_extension %d %d\n", __LINE__, need_extension);
420 // copy extension
421                 if(need_extension)
422                 {
423                         char *ptr1 = ptr;
424                         extension_ptr = asset->format != FILE_FFMPEG ?
425                                 extensions.get(0) : asset->fformat;
426                         while(*extension_ptr != 0 && *extension_ptr != '/')
427                                 *ptr1++ = *extension_ptr++;
428                         *ptr1 = 0;
429                 }
430
431                 int character1 = ptr - asset->path;
432                 int character2 = strlen(asset->path);
433 //              *(asset->path + character2) = 0;
434                 if(path_textbox)
435                 {
436                         path_textbox->update(asset->path);
437                         path_textbox->set_selection(character1, character2, character2);
438                 }
439         }
440 }
441
442 void FormatTools::update(Asset *asset, int *strategy)
443 {
444         this->asset = asset;
445         this->strategy = strategy;
446
447         if(path_textbox)
448                 path_textbox->update(asset->path);
449         format_text->update(File::formattostr(asset->format));
450         update_format();
451         if(strategy)
452         {
453                 multiple_files->update(strategy);
454         }
455         close_format_windows();
456 }
457
458 void FormatTools::close_format_windows()
459 {
460 // This is done in ~file
461         if( aparams_thread ) {
462                 if( aparams_thread->running() )
463                         aparams_thread->file->close_window();
464                 aparams_thread->join();
465         }
466         if( vparams_thread ) {
467                 if( vparams_thread->running() )
468                         vparams_thread->file->close_window();
469                 vparams_thread->join();
470         }
471 }
472
473 int FormatTools::get_w()
474 {
475         return asset->format != FILE_FFMPEG ? w :
476                 format_ffmpeg->get_x() + format_ffmpeg->get_w();
477 }
478
479 void FormatTools::set_w(int w)
480 {
481         this->w = w;
482 }
483
484 void FormatTools::reposition_window(int &init_x, int &init_y)
485 {
486         int x = init_x;
487         int y = init_y;
488
489         if(path_textbox)
490         {
491                 int px = x;
492                 path_textbox->reposition_window(px, y);
493                 px += path_textbox->get_w() + 5;
494                 path_recent->reposition_window(px, y);
495                 px += path_recent->get_w() + 8;
496                 path_button->reposition_window(px, y);
497                 y += path_textbox->get_h() + 10;
498         }
499
500         format_title->reposition_window(x, y);
501         x += 90;
502         format_text->reposition_window(x, y);
503         x += format_text->get_w();
504         format_button->reposition_window(x, y);
505
506         x = init_x;
507         y += format_button->get_h() + 10;
508
509         if(do_audio)
510         {
511                 audio_title->reposition_window(x, y);
512                 x += 80;
513                 aparams_button->reposition_window(x, y);
514                 x += aparams_button->get_w() + 10;
515                 if(prompt_audio) audio_switch->reposition_window(x, y);
516
517                 x = init_x;
518                 y += aparams_button->get_h() + 10;
519                 if(prompt_audio_channels)
520                 {
521                         channels_title->reposition_window(x, y);
522                         x += 260;
523                         channels_button->reposition_window(x, y);
524                         x += channels_button->get_w() + 5;
525                         channels_tumbler->reposition_window(x, y);
526                         y += channels_button->get_h() + 20;
527                         x = init_x;
528                 }
529         }
530
531
532         if(do_video)
533         {
534                 video_title->reposition_window(x, y);
535                 x += 80;
536                 if(prompt_video_compression)
537                 {
538                         vparams_button->reposition_window(x, y);
539                         x += vparams_button->get_w() + 10;
540                 }
541
542                 if(prompt_video)
543                 {
544                         video_switch->reposition_window(x, y);
545                         y += video_switch->get_h();
546                 }
547                 else
548                 {
549                         y += vparams_button->get_h();
550                 }
551
552                 y += 10;
553                 x = init_x;
554         }
555
556         if(strategy)
557         {
558                 multiple_files->reposition_window(x, y);
559                 y += multiple_files->get_h() + 10;
560         }
561
562         init_y = y;
563 }
564
565
566 int FormatTools::set_audio_options()
567 {
568 //      if(video_driver == CAPTURE_DVB)
569 //      {
570 //              return 0;
571 //      }
572
573         if(!aparams_thread->running())
574         {
575                 aparams_thread->start();
576         }
577         else
578         {
579                 aparams_thread->file->raise_window();
580         }
581         return 0;
582 }
583
584 int FormatTools::set_video_options()
585 {
586 //      if(video_driver == CAPTURE_DVB)
587 //      {
588 //              return 0;
589 //      }
590
591         if(!vparams_thread->running())
592         {
593                 vparams_thread->start();
594         }
595         else
596         {
597                 vparams_thread->file->raise_window();
598         }
599
600         return 0;
601 }
602
603
604
605
606
607 FormatAParams::FormatAParams(MWindow *mwindow, FormatTools *format, int x, int y)
608  : BC_Button(x, y, mwindow->theme->get_image_set("wrench"))
609 {
610         this->format = format;
611         set_tooltip(_("Configure audio compression"));
612 }
613
614 FormatAParams::~FormatAParams()
615 {
616 }
617
618 int FormatAParams::handle_event()
619 {
620         format->set_audio_options();
621         return 1;
622 }
623
624
625
626
627
628 FormatVParams::FormatVParams(MWindow *mwindow, FormatTools *format, int x, int y)
629  : BC_Button(x, y, mwindow->theme->get_image_set("wrench"))
630 {
631         this->format = format;
632         set_tooltip(_("Configure video compression"));
633 }
634
635 FormatVParams::~FormatVParams()
636 {
637 }
638
639 int FormatVParams::handle_event()
640 {
641         format->set_video_options();
642         return 1;
643 }
644
645
646
647
648
649 FormatAThread::FormatAThread(FormatTools *format)
650  : Thread(1, 0, 0)
651 {
652         this->format = format;
653         file = new File;
654         joined = 1;
655 }
656
657 FormatAThread::~FormatAThread()
658 {
659         delete file;  file = 0;
660         join();
661 }
662
663 void FormatAThread::start()
664 {
665         join();
666         joined = 0;
667         Thread::start();
668 }
669
670
671 void FormatAThread::run()
672 {
673         file->get_options(format, 1, 0);
674 }
675
676
677
678
679 FormatVThread::FormatVThread(FormatTools *format)
680  : Thread(1, 0, 0)
681 {
682         this->format = format;
683         file = new File;
684         joined = 1;
685 }
686
687 FormatVThread::~FormatVThread()
688 {
689         delete file;  file = 0;
690         join();
691 }
692
693 void FormatVThread::start()
694 {
695         join();
696         joined = 0;
697         Thread::start();
698 }
699
700 void FormatVThread::run()
701 {
702         file->get_options(format, 0, 1);
703 }
704
705
706
707
708
709 FormatPathText::FormatPathText(int x, int y, FormatTools *format)
710  : BC_TextBox(x, y, format->w - x -
711                 2*format->mwindow->theme->get_image_set("wrench")[0]->get_w() - 20, 1,
712         format->asset->path)
713 {
714         this->format = format;
715 }
716
717 FormatPathText::~FormatPathText()
718 {
719 }
720 int FormatPathText::handle_event()
721 {
722         calculate_suggestions();
723         strcpy(format->asset->path, get_text());
724         format->handle_event();
725         return 1;
726 }
727
728
729
730
731 FormatAudio::FormatAudio(int x, int y, FormatTools *format, int default_)
732  : BC_CheckBox(x,
733         y,
734         default_,
735         (char*)(format->recording ? _("Record audio tracks") : _("Render audio tracks")))
736 {
737         this->format = format;
738 }
739
740 FormatAudio::~FormatAudio() {}
741 int FormatAudio::handle_event()
742 {
743         format->asset->audio_data = get_value();
744         return 1;
745 }
746
747
748 FormatVideo::FormatVideo(int x, int y, FormatTools *format, int default_)
749  : BC_CheckBox(x,
750         y,
751         default_,
752         (char*)(format->recording ? _("Record video tracks") : _("Render video tracks")))
753 {
754 this->format = format;
755 }
756
757 FormatVideo::~FormatVideo() {}
758 int FormatVideo::handle_event()
759 {
760         format->asset->video_data = get_value();
761         return 1;
762 }
763
764
765
766
767 FormatFormat::FormatFormat(int x, int y, FormatTools *format)
768  : FormatPopup(x, y, format->do_audio, format->do_video, format->use_brender)
769 {
770         this->format = format;
771 }
772
773 FormatFormat::~FormatFormat()
774 {
775 }
776
777 int FormatFormat::handle_event()
778 {
779         BC_ListBoxItem *selection = get_selection(0, 0);
780         if( selection ) {
781                 int new_format = File::strtoformat(get_selection(0, 0)->get_text());
782 //              if(new_format != format->asset->format)
783                 {
784                         Asset *asset = format->asset;
785                         asset->format = new_format;
786                         asset->audio_data = File::renders_audio(asset);
787                         asset->video_data = File::renders_video(asset);
788                         asset->ff_audio_options[0] = 0;
789                         asset->ff_video_options[0] = 0;
790                         format->format_text->update(selection->get_text());
791                         if( !format->use_brender )
792                                 format->update_extension();
793                         format->close_format_windows();
794                         if (format->path_recent) format->path_recent->
795                                 load_items(File::formattostr(format->asset->format));
796                         format->update_format();
797                 }
798         }
799         return 1;
800 }
801
802
803 FormatFFMPEG::FormatFFMPEG(int x, int y, FormatTools *format)
804  : FFMPEGPopup(format->plugindb, x, y)
805 {
806         this->format = format;
807 }
808
809 FormatFFMPEG::~FormatFFMPEG()
810 {
811 }
812
813 int FormatFFMPEG::handle_event()
814 {
815         BC_ListBoxItem *selection = get_selection(0, 0);
816         if( selection ) {
817                 char *text = get_selection(0, 0)->get_text();
818                 format->ffmpeg_type->update(text);
819                 format->asset->ff_audio_options[0] = 0;
820                 format->asset->ff_video_options[0] = 0;
821                 FFMPEG::set_asset_format(format->asset, text);
822                 format->update_extension();
823                 format->close_format_windows();
824                 format->update_format();
825         }
826         return 1;
827 }
828
829
830
831
832 FormatChannels::FormatChannels(int x, int y, FormatTools *format)
833  : BC_TextBox(x, y, 100, 1, format->asset->channels)
834 {
835         this->format = format;
836 }
837
838 FormatChannels::~FormatChannels()
839 {
840 }
841
842 int FormatChannels::handle_event()
843 {
844         format->asset->channels = atol(get_text());
845         return 1;
846 }
847
848
849 FormatToTracks::FormatToTracks(int x, int y, int *output)
850  : BC_CheckBox(x, y, *output, _("Overwrite project with output"))
851 {
852         this->output = output;
853 }
854
855 FormatToTracks::~FormatToTracks()
856 {
857 }
858
859 int FormatToTracks::handle_event()
860 {
861         *output = get_value();
862         return 1;
863 }
864
865
866 FormatMultiple::FormatMultiple(MWindow *mwindow, int x, int y, int *output)
867  : BC_CheckBox(x,
868         y,
869         (*output == FILE_PER_LABEL) || (*output == FILE_PER_LABEL_FARM),
870         _("Create new file at each label"))
871 {
872         this->output = output;
873         this->mwindow = mwindow;
874 }
875
876 FormatMultiple::~FormatMultiple()
877 {
878 }
879
880 int FormatMultiple::handle_event()
881 {
882         if(get_value())
883         {
884                 if(mwindow->preferences->use_renderfarm)
885                         *output = FILE_PER_LABEL_FARM;
886                 else
887                         *output = FILE_PER_LABEL;
888         }
889         else
890         {
891                 if(mwindow->preferences->use_renderfarm)
892                         *output = SINGLE_PASS_FARM;
893                 else
894                         *output = SINGLE_PASS;
895         }
896         return 1;
897 }
898
899 void FormatMultiple::update(int *output)
900 {
901         this->output = output;
902         if(*output == FILE_PER_LABEL_FARM ||
903                 *output ==FILE_PER_LABEL)
904                 set_value(1);
905         else
906                 set_value(0);
907 }
908
909