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