4 #include "formattools.h"
5 #include "maxchannels.h"
7 #include "preferences.h"
12 #define _(String) gettext(String)
13 #define gettext_noop(String) String
14 #define N_(String) gettext_noop (String)
16 FormatTools::FormatTools(MWindow *mwindow,
17 BC_WindowBase *window,
20 this->mwindow = mwindow;
21 this->window = window;
23 this->plugindb = mwindow->plugindb;
32 FormatTools::~FormatTools()
38 if(aparams_button) delete aparams_button;
39 if(vparams_button) delete vparams_button;
40 if(aparams_thread) delete aparams_thread;
41 if(vparams_thread) delete vparams_thread;
42 if(channels_tumbler) delete channels_tumbler;
45 int FormatTools::create_objects(int &init_x,
47 int do_audio, // Include support for audio
48 int do_video, // Include support for video
49 int prompt_audio, // Include checkbox for audio
51 int prompt_audio_channels,
52 int prompt_video_compression,
61 this->lock_compressor = lock_compressor;
62 this->recording = recording;
63 this->use_brender = brender;
64 this->do_audio = do_audio;
65 this->do_video = do_video;
66 this->prompt_audio = prompt_audio;
67 this->prompt_audio_channels = prompt_audio_channels;
68 this->prompt_video = prompt_video;
69 this->prompt_video_compression = prompt_video_compression;
70 this->strategy = strategy;
72 //printf("FormatTools::create_objects 1\n");
74 // Modify strategy depending on render farm
77 if(mwindow->preferences->use_renderfarm)
79 if(*strategy == FILE_PER_LABEL)
80 *strategy = FILE_PER_LABEL_FARM;
82 if(*strategy == SINGLE_PASS)
83 *strategy = SINGLE_PASS_FARM;
87 if(*strategy == FILE_PER_LABEL_FARM)
88 *strategy = FILE_PER_LABEL;
90 if(*strategy == SINGLE_PASS_FARM)
91 *strategy = SINGLE_PASS;
95 //printf("FormatTools::create_objects 1\n");
96 window->add_subwindow(path_textbox = new FormatPathText(x, y, this, asset));
98 window->add_subwindow(path_button = new BrowseButton(
106 _("Select a file to write to:"),
109 //printf("FormatTools::create_objects 2\n");
113 //printf("FormatTools::create_objects 3\n");
114 window->add_subwindow(format_title = new BC_Title(x, y, _("File Format:")));
116 window->add_subwindow(format_text = new BC_TextBox(x,
120 File::formattostr(plugindb, asset->format)));
121 x += format_text->get_w();
122 window->add_subwindow(format_button = new FormatFormat(x,
126 format_button->create_objects();
128 //printf("FormatTools::create_objects 4\n");
130 y += format_button->get_h() + 10;
133 window->add_subwindow(audio_title = new BC_Title(x, y, _("Audio:"), LARGEFONT, RED));
135 window->add_subwindow(aparams_button = new FormatAParams(mwindow, this, x, y));
136 x += aparams_button->get_w() + 10;
139 window->add_subwindow(audio_switch = new FormatAudio(x, y, this, asset->audio_data));
142 y += aparams_button->get_h() + 20;
144 //printf("FormatTools::create_objects 5\n");
145 // Audio channels only used for recording.
146 if(prompt_audio_channels)
148 window->add_subwindow(channels_title = new BC_Title(x, y, _("Number of audio channels to record:")));
150 window->add_subwindow(channels_button = new FormatChannels(x, y, asset));
151 x += channels_button->get_w() + 5;
152 window->add_subwindow(channels_tumbler = new BC_ITumbler(channels_button, 1, MAXCHANNELS, x, y));
153 y += channels_button->get_h() + 20;
157 //printf("FormatTools::create_objects 6\n");
158 aparams_thread = new FormatAThread(this);
161 //printf("FormatTools::create_objects 7\n");
165 //printf("FormatTools::create_objects 8\n");
166 window->add_subwindow(video_title = new BC_Title(x, y, _("Video:"), LARGEFONT, RED));
168 if(prompt_video_compression)
170 window->add_subwindow(vparams_button = new FormatVParams(mwindow, this, x, y));
171 x += vparams_button->get_w() + 10;
174 //printf("FormatTools::create_objects 9\n");
177 window->add_subwindow(video_switch = new FormatVideo(x, y, this, asset->video_data));
178 y += video_switch->get_h();
182 y += vparams_button->get_h();
185 //printf("FormatTools::create_objects 10\n");
187 vparams_thread = new FormatVThread(this, lock_compressor);
190 //printf("FormatTools::create_objects 11\n");
195 window->add_subwindow(multiple_files = new FormatMultiple(mwindow, x, y, strategy));
196 y += multiple_files->get_h() + 10;
199 //printf("FormatTools::create_objects 12\n");
205 void FormatTools::reposition_window(int &init_x, int &init_y)
210 path_textbox->reposition_window(x, y);
212 path_button->reposition_window(x, y);
216 format_title->reposition_window(x, y);
218 format_text->reposition_window(x, y);
219 x += format_text->get_w();
220 format_button->reposition_window(x, y);
223 y += format_button->get_h() + 10;
227 audio_title->reposition_window(x, y);
229 aparams_button->reposition_window(x, y);
230 x += aparams_button->get_w() + 10;
231 if(prompt_audio) audio_switch->reposition_window(x, y);
234 y += aparams_button->get_h() + 20;
235 if(prompt_audio_channels)
237 channels_title->reposition_window(x, y);
239 channels_button->reposition_window(x, y);
240 x += channels_button->get_w() + 5;
241 channels_tumbler->reposition_window(x, y);
242 y += channels_button->get_h() + 20;
250 video_title->reposition_window(x, y);
252 if(prompt_video_compression)
254 vparams_button->reposition_window(x, y);
255 x += vparams_button->get_w() + 10;
260 video_switch->reposition_window(x, y);
261 y += video_switch->get_h();
265 y += vparams_button->get_h();
274 multiple_files->reposition_window(x, y);
275 y += multiple_files->get_h() + 10;
282 int FormatTools::set_audio_options()
284 if(!aparams_thread->running())
286 aparams_thread->start();
290 aparams_thread->file->raise_window();
296 int FormatTools::set_video_options()
298 if(!vparams_thread->running())
300 vparams_thread->start();
304 vparams_thread->file->raise_window();
313 FormatAParams::FormatAParams(MWindow *mwindow, FormatTools *format, int x, int y)
314 : BC_Button(x, y, mwindow->theme->wrench_data)
316 this->format = format;
317 set_tooltip(_("Configure audio compression"));
319 FormatAParams::~FormatAParams()
322 int FormatAParams::handle_event()
324 format->set_audio_options();
327 FormatVParams::FormatVParams(MWindow *mwindow, FormatTools *format, int x, int y)
328 : BC_Button(x, y, mwindow->theme->wrench_data)
330 this->format = format;
331 set_tooltip(_("Configure video compression"));
333 FormatVParams::~FormatVParams()
336 int FormatVParams::handle_event()
338 format->set_video_options();
342 FormatAThread::FormatAThread(FormatTools *format)
345 this->format = format;
348 FormatAThread::~FormatAThread()
352 void FormatAThread::run()
354 file->get_options(format->window,
365 FormatVThread::FormatVThread(FormatTools *format,
369 this->lock_compressor = lock_compressor;
370 this->format = format;
373 FormatVThread::~FormatVThread()
377 void FormatVThread::run()
379 file->get_options(format->window,
387 FormatPathText::FormatPathText(int x, int y, FormatTools *format, Asset *asset)
388 : BC_TextBox(x, y, 300, 1, asset->path)
390 this->format = format;
393 FormatPathText::~FormatPathText()
395 int FormatPathText::handle_event()
397 strcpy(asset->path, get_text());
403 FormatAudio::FormatAudio(int x, int y, FormatTools *format, int default_)
407 (char*)(format->recording ? _("Record audio tracks") : _("Render audio tracks")))
409 this->format = format;
411 FormatAudio::~FormatAudio() {}
412 int FormatAudio::handle_event()
414 format->asset->audio_data = get_value();
418 FormatVideo::FormatVideo(int x, int y, FormatTools *format, int default_)
422 (char*)(format->recording ? _("Record video tracks") : _("Render video tracks")))
424 this->format = format;
426 FormatVideo::~FormatVideo() {}
427 int FormatVideo::handle_event()
429 format->asset->video_data = get_value();
435 FormatFormat::FormatFormat(int x,
439 : FormatPopup(format->plugindb,
444 this->format = format;
447 FormatFormat::~FormatFormat()
450 int FormatFormat::handle_event()
452 if(get_selection(0, 0) >= 0)
454 asset->format = File::strtoformat(format->plugindb, get_selection(0, 0)->get_text());
455 format->format_text->update(get_selection(0, 0)->get_text());
456 //printf("FormatFormat::handle_event %d %s\n", asset->format, get_selection(0, 0)->get_text());
463 FormatChannels::FormatChannels(int x, int y, Asset *asset)
464 : BC_TextBox(x, y, 100, 1, asset->channels)
468 FormatChannels::~FormatChannels() {}
469 int FormatChannels::handle_event()
471 asset->channels = atol(get_text());
475 FormatToTracks::FormatToTracks(int x, int y, int *output)
476 : BC_CheckBox(x, y, *output, _("Overwrite project with output"))
478 this->output = output;
480 FormatToTracks::~FormatToTracks()
483 int FormatToTracks::handle_event()
485 *output = get_value();
490 FormatMultiple::FormatMultiple(MWindow *mwindow, int x, int y, int *output)
493 (*output == FILE_PER_LABEL) || (*output == FILE_PER_LABEL_FARM),
494 _("Create new file at each label"))
496 this->output = output;
497 this->mwindow = mwindow;
499 FormatMultiple::~FormatMultiple()
502 int FormatMultiple::handle_event()
506 if(mwindow->preferences->use_renderfarm)
507 *output = FILE_PER_LABEL_FARM;
509 *output = FILE_PER_LABEL;
513 if(mwindow->preferences->use_renderfarm)
514 *output = SINGLE_PASS_FARM;
516 *output = SINGLE_PASS;