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