4 #include "formattools.h"
5 #include "maxchannels.h"
7 #include "preferences.h"
13 #define _(String) gettext(String)
14 #define gettext_noop(String) String
15 #define N_(String) gettext_noop (String)
17 FormatTools::FormatTools(MWindow *mwindow,
18 BC_WindowBase *window,
21 this->mwindow = mwindow;
22 this->window = window;
24 this->plugindb = mwindow->plugindb;
31 FormatTools::~FormatTools()
33 delete aparams_thread;
34 delete vparams_thread;
37 int FormatTools::create_objects(int &init_x,
39 int do_audio, // Include support for audio
40 int do_video, // Include support for video
41 int prompt_audio, // Include checkbox for audio
43 int prompt_audio_channels,
44 int prompt_video_compression,
53 this->lock_compressor = lock_compressor;
54 this->recording = recording;
55 this->use_brender = brender;
56 this->do_audio = do_audio;
57 this->do_video = do_video;
58 this->prompt_audio = prompt_audio;
59 this->prompt_audio_channels = prompt_audio_channels;
60 this->prompt_video = prompt_video;
61 this->prompt_video_compression = prompt_video_compression;
62 this->strategy = strategy;
64 //printf("FormatTools::create_objects 1\n");
66 // Modify strategy depending on render farm
69 if(mwindow->preferences->use_renderfarm)
71 if(*strategy == FILE_PER_LABEL)
72 *strategy = FILE_PER_LABEL_FARM;
74 if(*strategy == SINGLE_PASS)
75 *strategy = SINGLE_PASS_FARM;
79 if(*strategy == FILE_PER_LABEL_FARM)
80 *strategy = FILE_PER_LABEL;
82 if(*strategy == SINGLE_PASS_FARM)
83 *strategy = SINGLE_PASS;
87 //printf("FormatTools::create_objects 1\n");
88 window->add_subwindow(path_textbox = new FormatPathText(x, y, this));
90 path_recent = new BC_RecentList("PATH", mwindow->defaults,
91 path_textbox, 10, x, y, 300, 100);
92 window->add_subwindow(path_recent);
93 path_recent->load_items(FILE_FORMAT_PREFIX(asset->format));
96 window->add_subwindow(path_button = new BrowseButton(
104 _("Select a file to write to:"),
107 w = x + path_button->get_w() + 5;
108 //printf("FormatTools::create_objects 2\n");
113 pipe_status = new PipeStatus(x, y, "");
114 window->add_subwindow(pipe_status);
115 pipe_status->set_status(asset);
119 //printf("FormatTools::create_objects 3\n");
120 window->add_subwindow(format_title = new BC_Title(x, y, _("File Format:")));
122 window->add_subwindow(format_text = new BC_TextBox(x,
126 File::formattostr(plugindb, asset->format)));
127 x += format_text->get_w();
128 window->add_subwindow(format_button = new FormatFormat(x,
131 format_button->create_objects();
133 //printf("FormatTools::create_objects 4\n");
135 y += format_button->get_h() + 10;
138 window->add_subwindow(audio_title = new BC_Title(x, y, _("Audio:"), LARGEFONT, BC_WindowBase::get_resources()->audiovideo_color));
140 window->add_subwindow(aparams_button = new FormatAParams(mwindow, this, x, y));
141 x += aparams_button->get_w() + 10;
144 window->add_subwindow(audio_switch = new FormatAudio(x, y, this, asset->audio_data));
147 y += aparams_button->get_h() + 20;
149 //printf("FormatTools::create_objects 5\n");
150 // Audio channels only used for recording.
151 if(prompt_audio_channels)
153 window->add_subwindow(channels_title = new BC_Title(x, y, _("Number of audio channels to record:")));
155 window->add_subwindow(channels_button = new FormatChannels(x, y, this));
156 x += channels_button->get_w() + 5;
157 window->add_subwindow(channels_tumbler = new BC_ITumbler(channels_button, 1, MAXCHANNELS, x, y));
158 y += channels_button->get_h() + 20;
162 //printf("FormatTools::create_objects 6\n");
163 aparams_thread = new FormatAThread(this);
166 //printf("FormatTools::create_objects 7\n");
170 //printf("FormatTools::create_objects 8\n");
171 window->add_subwindow(video_title = new BC_Title(x, y, _("Video:"), LARGEFONT, BC_WindowBase::get_resources()->audiovideo_color));
173 if(prompt_video_compression)
175 window->add_subwindow(vparams_button = new FormatVParams(mwindow, this, x, y));
176 x += vparams_button->get_w() + 10;
179 //printf("FormatTools::create_objects 9\n");
182 window->add_subwindow(video_switch = new FormatVideo(x, y, this, asset->video_data));
183 y += video_switch->get_h();
187 y += vparams_button->get_h();
190 //printf("FormatTools::create_objects 10\n");
192 vparams_thread = new FormatVThread(this, lock_compressor);
195 //printf("FormatTools::create_objects 11\n");
200 window->add_subwindow(multiple_files = new FormatMultiple(mwindow, x, y, strategy));
201 y += multiple_files->get_h() + 10;
204 //printf("FormatTools::create_objects 12\n");
210 int FormatTools::handle_event()
215 Asset* FormatTools::get_asset()
220 void FormatTools::update(Asset *asset, int *strategy)
223 this->strategy = strategy;
225 path_textbox->update(asset->path);
226 format_text->update(File::formattostr(plugindb, asset->format));
227 if(do_audio && audio_switch) audio_switch->update(asset->audio_data);
228 if(do_video && video_switch) video_switch->update(asset->video_data);
231 multiple_files->update(strategy);
233 close_format_windows();
236 void FormatTools::close_format_windows()
238 if(aparams_thread) aparams_thread->file->close_window();
239 if(vparams_thread) vparams_thread->file->close_window();
242 int FormatTools::get_w()
247 void FormatTools::reposition_window(int &init_x, int &init_y)
252 path_textbox->reposition_window(x, y);
254 path_button->reposition_window(x, y);
258 format_title->reposition_window(x, y);
260 format_text->reposition_window(x, y);
261 x += format_text->get_w();
262 format_button->reposition_window(x, y);
265 y += format_button->get_h() + 10;
269 audio_title->reposition_window(x, y);
271 aparams_button->reposition_window(x, y);
272 x += aparams_button->get_w() + 10;
273 if(prompt_audio) audio_switch->reposition_window(x, y);
276 y += aparams_button->get_h() + 20;
277 if(prompt_audio_channels)
279 channels_title->reposition_window(x, y);
281 channels_button->reposition_window(x, y);
282 x += channels_button->get_w() + 5;
283 channels_tumbler->reposition_window(x, y);
284 y += channels_button->get_h() + 20;
292 video_title->reposition_window(x, y);
294 if(prompt_video_compression)
296 vparams_button->reposition_window(x, y);
297 x += vparams_button->get_w() + 10;
302 video_switch->reposition_window(x, y);
303 y += video_switch->get_h();
307 y += vparams_button->get_h();
316 multiple_files->reposition_window(x, y);
317 y += multiple_files->get_h() + 10;
324 int FormatTools::set_audio_options()
326 if(!aparams_thread->running())
328 aparams_thread->start();
332 aparams_thread->file->raise_window();
338 int FormatTools::set_video_options()
340 if(!vparams_thread->running())
342 vparams_thread->start();
346 vparams_thread->file->raise_window();
355 FormatAParams::FormatAParams(MWindow *mwindow, FormatTools *format, int x, int y)
356 : BC_Button(x, y, mwindow->theme->wrench_data)
358 this->format = format;
359 set_tooltip(_("Configure audio compression"));
361 FormatAParams::~FormatAParams()
364 int FormatAParams::handle_event()
366 format->set_audio_options();
369 FormatVParams::FormatVParams(MWindow *mwindow, FormatTools *format, int x, int y)
370 : BC_Button(x, y, mwindow->theme->wrench_data)
372 this->format = format;
373 set_tooltip(_("Configure video compression"));
375 FormatVParams::~FormatVParams()
378 int FormatVParams::handle_event()
380 format->set_video_options();
384 FormatAThread::FormatAThread(FormatTools *format)
387 this->format = format;
391 FormatAThread::~FormatAThread()
396 void FormatAThread::run()
398 file->get_options(format, 1, 0, 0);
404 FormatVThread::FormatVThread(FormatTools *format,
408 this->lock_compressor = lock_compressor;
409 this->format = format;
413 FormatVThread::~FormatVThread()
418 void FormatVThread::run()
420 file->get_options(format, 0, 1, lock_compressor);
423 FormatPathText::FormatPathText(int x, int y, FormatTools *format)
424 : BC_TextBox(x, y, 300, 1, format->asset->path)
426 this->format = format;
428 FormatPathText::~FormatPathText()
431 int FormatPathText::handle_event()
433 strcpy(format->asset->path, get_text());
434 format->handle_event();
440 FormatAudio::FormatAudio(int x, int y, FormatTools *format, int default_)
444 (char*)(format->recording ? _("Record audio tracks") : _("Render audio tracks")))
446 this->format = format;
448 FormatAudio::~FormatAudio() {}
449 int FormatAudio::handle_event()
451 format->asset->audio_data = get_value();
455 FormatVideo::FormatVideo(int x, int y, FormatTools *format, int default_)
459 (char*)(format->recording ? _("Record video tracks") : _("Render video tracks")))
461 this->format = format;
463 FormatVideo::~FormatVideo() {}
464 int FormatVideo::handle_event()
466 format->asset->video_data = get_value();
472 FormatFormat::FormatFormat(int x,
475 : FormatPopup(format->plugindb,
480 this->format = format;
482 FormatFormat::~FormatFormat()
485 int FormatFormat::handle_event()
487 if(get_selection(0, 0) >= 0)
489 int new_format = File::strtoformat(format->plugindb, get_selection(0, 0)->get_text());
490 if(new_format != format->asset->format)
492 // save the state of the old format
493 format->asset->save_format_defaults
494 (format->mwindow->defaults);
496 // close the configure window if open
497 format->close_format_windows();
499 // change to the new format
500 format->asset->format = new_format;
502 // load the state for the new format
503 format->asset->load_format_defaults
504 (format->mwindow->defaults);
506 // update the render window to match
507 format->format_text->
508 update(get_selection(0, 0)->get_text());
509 format->path_textbox->update(format->asset->path);
510 format->pipe_status->set_status(format->asset);
511 format->path_recent->load_items
512 (FILE_FORMAT_PREFIX(format->asset->format));
520 FormatChannels::FormatChannels(int x, int y, FormatTools *format)
521 : BC_TextBox(x, y, 100, 1, format->asset->channels)
523 this->format = format;
525 FormatChannels::~FormatChannels()
528 int FormatChannels::handle_event()
530 format->asset->channels = atol(get_text());
534 FormatToTracks::FormatToTracks(int x, int y, int *output)
535 : BC_CheckBox(x, y, *output, _("Overwrite project with output"))
537 this->output = output;
539 FormatToTracks::~FormatToTracks()
542 int FormatToTracks::handle_event()
544 *output = get_value();
549 FormatMultiple::FormatMultiple(MWindow *mwindow, int x, int y, int *output)
552 (*output == FILE_PER_LABEL) || (*output == FILE_PER_LABEL_FARM),
553 _("Create new file at each label"))
555 this->output = output;
556 this->mwindow = mwindow;
558 FormatMultiple::~FormatMultiple()
561 int FormatMultiple::handle_event()
565 if(mwindow->preferences->use_renderfarm)
566 *output = FILE_PER_LABEL_FARM;
568 *output = FILE_PER_LABEL;
572 if(mwindow->preferences->use_renderfarm)
573 *output = SINGLE_PASS_FARM;
575 *output = SINGLE_PASS;
580 void FormatMultiple::update(int *output)
582 this->output = output;
583 if(*output == FILE_PER_LABEL_FARM ||
584 *output ==FILE_PER_LABEL)