4 * Copyright (C) 2011 Adam Williams <broadcast at earthling dot net>
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.
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.
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
23 #include "batchrender.h"
24 #include "bcdisplayinfo.h"
25 #include "bcsignals.h"
26 #include "confirmsave.h"
32 #include "edlsession.h"
35 #include "filesystem.h"
41 #include "mainerror.h"
43 #include "mainsession.h"
46 #include "mwindowgui.h"
47 #include "packagedispatcher.h"
48 #include "packagerenderer.h"
50 #include "pluginset.h"
51 #include "preferences.h"
55 #include "transportque.h"
59 static const char *list_titles[] =
67 static int list_widths[] =
75 BatchRenderMenuItem::BatchRenderMenuItem(MWindow *mwindow)
76 : BC_MenuItem(_("Batch Render..."), _("Shift-B"), 'B')
79 this->mwindow = mwindow;
82 int BatchRenderMenuItem::handle_event()
84 mwindow->batch_render->start();
95 BatchRenderJob::BatchRenderJob(Preferences *preferences, int strategy)
97 this->preferences = preferences;
98 this->strategy = strategy;
106 BatchRenderJob::~BatchRenderJob()
108 asset->Garbage::remove_user();
111 void BatchRenderJob::copy_from(BatchRenderJob *src)
113 asset->copy_from(src->asset, 0);
114 strcpy(edl_path, src->edl_path);
115 strategy = src->strategy;
116 enabled = src->enabled;
120 void BatchRenderJob::load(FileXML *file)
125 file->tag.get_property("EDL_PATH", edl_path);
126 strategy = file->tag.get_property("STRATEGY", get_strategy());
127 enabled = file->tag.get_property("ENABLED", enabled);
128 elapsed = file->tag.get_property("ELAPSED", elapsed);
130 result = file->read_tag();
133 if(file->tag.title_is("ASSET"))
135 file->tag.get_property("SRC", asset->path);
136 asset->read(file, 0);
137 // The compression parameters are stored in the defaults to reduce
138 // coding maintenance. The defaults must now be stuffed into the XML for
141 defaults.load_string(file->read_text());
142 asset->load_defaults(&defaults,
148 void BatchRenderJob::save(FileXML *file)
150 file->tag.set_property("EDL_PATH", edl_path);
151 file->tag.set_property("STRATEGY", get_strategy());
152 file->tag.set_property("ENABLED", enabled);
153 file->tag.set_property("ELAPSED", elapsed);
155 file->append_newline();
160 // The compression parameters are stored in the defaults to reduce
161 // coding maintenance. The defaults must now be stuffed into the XML for
164 asset->save_defaults(&defaults,
172 defaults.save_string(string);
173 file->append_text(string);
175 file->tag.set_title("/JOB");
177 file->append_newline();
180 int BatchRenderJob::get_strategy()
182 return strategy >= 0 ? strategy :
183 Render::get_strategy(preferences->use_renderfarm, file_per_label);
187 BatchRenderThread::BatchRenderThread(MWindow *mwindow)
190 this->mwindow = mwindow;
202 BatchRenderThread::BatchRenderThread()
217 BatchRenderThread::~BatchRenderThread()
220 delete boot_defaults;
225 void BatchRenderThread::reset(const char *path)
228 strcpy(batch_path, path);
233 delete default_job; default_job = 0;
234 jobs.remove_all_objects();
237 void BatchRenderThread::handle_close_event(int result)
240 save_jobs(batch_path);
241 save_defaults(mwindow->defaults);
245 BC_Window* BatchRenderThread::new_gui()
249 default_job = new BatchRenderJob(mwindow->preferences);
250 load_jobs(batch_path, mwindow->preferences);
251 load_defaults(mwindow->defaults);
252 this->gui = new BatchRenderGUI(mwindow,
254 mwindow->session->batchrender_x,
255 mwindow->session->batchrender_y,
256 mwindow->session->batchrender_w,
257 mwindow->session->batchrender_h);
258 this->gui->create_objects();
263 void BatchRenderThread::load_jobs(char *path, Preferences *preferences)
268 jobs.remove_all_objects();
269 if( !path ) path = batch_path;
270 if( !path[0] ) create_path(path);
271 file.read_from_file(path);
275 if(!(result = file.read_tag()))
277 if(file.tag.title_is("JOBS"))
279 warn = file.tag.get_property("WARN", 1);
281 else if(file.tag.title_is("JOB"))
284 jobs.append(job = new BatchRenderJob(preferences));
291 void BatchRenderThread::save_jobs(char *path)
294 file.tag.set_title("JOBS");
295 file.tag.set_property("WARN", warn);
297 file.append_newline();
299 for(int i = 0; i < jobs.total; i++)
301 file.tag.set_title("JOB");
302 jobs.values[i]->save(&file);
304 file.tag.set_title("/JOBS");
306 file.append_newline();
308 if( !path ) path = batch_path;
309 if( !path[0] ) create_path(path);
310 file.write_to_file(path);
313 void BatchRenderThread::load_defaults(BC_Hash *defaults)
317 default_job->asset->load_defaults(defaults,
318 "BATCHRENDER_", 1, 1, 1, 1, 1);
321 for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
323 char string[BCTEXTLEN];
324 sprintf(string, "BATCHRENDER_COLUMN%d", i);
325 column_width[i] = defaults->get(string, list_widths[i]);
329 void BatchRenderThread::save_defaults(BC_Hash *defaults)
332 default_job->asset->save_defaults(defaults,
333 "BATCHRENDER_", 1, 1, 1, 1, 1);
335 for( int i=0; i<BATCHRENDER_COLUMNS; ++i ) {
336 char string[BCTEXTLEN];
337 sprintf(string, "BATCHRENDER_COLUMN%d", i);
338 defaults->update(string, column_width[i]);
340 // defaults->update("BATCHRENDER_JOB", current_job);
342 mwindow->save_defaults();
347 char* BatchRenderThread::create_path(char *string)
350 sprintf(string, "%s/", File::get_config_path());
351 fs.complete_path(string);
352 strcat(string, BATCH_PATH);
356 void BatchRenderThread::new_job()
358 BatchRenderJob *result = new BatchRenderJob(mwindow->preferences);
359 result->copy_from(get_current_job());
361 current_job = jobs.total - 1;
366 void BatchRenderThread::delete_job()
368 if(current_job < jobs.total && current_job >= 0)
370 jobs.remove_object_number(current_job);
371 if(current_job > 0) current_job--;
377 void BatchRenderThread::use_current_edl()
379 // printf("BatchRenderThread::use_current_edl %d %p %s\n",
381 // mwindow->edl->path,
382 // mwindow->edl->path);
384 strcpy(get_current_edl(), mwindow->edl->path);
386 gui->edl_path_text->update(get_current_edl());
389 void BatchRenderThread::update_selected_edl()
392 char *path = get_current_edl();
393 EDL *edl = mwindow->edl;
394 edl->save_xml(&xml_file, path, 0, 0);
395 xml_file.terminate_string();
396 if( xml_file.write_to_file(path) ) {
398 sprintf(msg, _("Unable to save: %s"), path);
399 MainError::show_error(msg);
403 BatchRenderJob* BatchRenderThread::get_current_job()
405 BatchRenderJob *result;
406 if(current_job >= jobs.total || current_job < 0)
408 result = default_job;
412 result = jobs.values[current_job];
418 Asset* BatchRenderThread::get_current_asset()
420 return get_current_job()->asset;
423 char* BatchRenderThread::get_current_edl()
425 return get_current_job()->edl_path;
429 // Test EDL files for existence
430 int BatchRenderThread::test_edl_files()
432 int not_equiv = 0, ret = 0;
433 const char *path = 0;
435 for( int i=0; !ret && i<jobs.size(); ++i ) {
436 if( !jobs.values[i]->enabled ) continue;
437 const char *path = jobs.values[i]->edl_path;
438 int is_script = *path == '@' ? 1 : 0;
439 if( is_script ) ++path;
440 FILE *fp = fopen(path, "r");
442 if( warn && mwindow && !is_script ) {
443 fseek(fp, 0, SEEK_END);
444 int64_t sz = ftell(fp);
445 fseek(fp, 0, SEEK_SET);
446 char *bfr = new char[sz+1];
447 int64_t len = fread(bfr, 1, sz+1, fp);
449 FileXML file; file.set_shared_input(bfr, len);
450 EDL *edl = new EDL; edl->create_objects();
451 edl->load_xml(&file, LOAD_ALL);
452 double pos = edl->equivalent_output(mwindow->edl);
453 if( pos >= 0 ) ++not_equiv;
467 char string[BCTEXTLEN];
468 sprintf(string, _("EDL %s not found.\n"), path);
470 ErrorBox error_box(_(PROGRAM_NAME ": Error"),
471 mwindow->gui->get_abs_cursor_x(1),
472 mwindow->gui->get_abs_cursor_y(1));
473 error_box.create_objects(string);
474 error_box.run_window();
475 gui->button_enable();
478 fprintf(stderr, "%s", string);
482 else if( warn && mwindow && not_equiv > 0 ) {
483 fprintf(stderr, _("%d job EDLs do not match session edl\n"), not_equiv);
484 char string[BCTEXTLEN], *sp = string;
485 sp += sprintf(sp, _("%d job EDLs do not match session edl\n"),not_equiv);
486 sp += sprintf(sp, _("press cancel to abandon batch render"));
487 mwindow->show_warning(&warn, string);
488 if( mwindow->wait_warning() ) {
489 gui->button_enable();
493 gui->warning->update(warn);
499 void BatchRenderThread::calculate_dest_paths(ArrayList<char*> *paths,
500 Preferences *preferences)
502 for(int i = 0; i < jobs.total; i++)
504 BatchRenderJob *job = jobs.values[i];
505 if(job->enabled && *job->edl_path != '@')
507 PackageDispatcher *packages = new PackageDispatcher;
510 TransportCommand *command = new TransportCommand;
511 FileXML *file = new FileXML;
512 file->read_from_file(job->edl_path);
514 // Use command to calculate range.
515 command->command = NORMAL_FWD;
516 command->get_edl()->load_xml(file,
518 command->change_type = CHANGE_ALL;
519 command->set_playback_range();
520 command->playback_range_adjust_inout();
522 // Create test packages
523 packages->create_packages(mwindow,
528 command->start_position,
529 command->end_position,
532 // Append output paths allocated to total
533 packages->get_package_paths(paths);
535 // Delete package harness
544 void BatchRenderThread::start_rendering(char *config_path,
547 BC_Hash *boot_defaults;
548 Preferences *preferences;
550 BC_Signals *signals = new BC_Signals;
551 // XXX the above stuff is leaked,
553 // Initialize stuff which MWindow does.
554 signals->initialize("/tmp/cinelerra_batch%d.dmp");
555 MWindow::init_defaults(boot_defaults, config_path);
556 load_defaults(boot_defaults);
557 preferences = new Preferences;
558 preferences->load_defaults(boot_defaults);
559 BC_Signals::set_trap_hook(trap_hook, this);
560 BC_Signals::set_catch_segv(preferences->trap_sigsegv);
561 BC_Signals::set_catch_intr(0);
562 if( preferences->trap_sigsegv ) {
563 BC_Trace::enable_locks();
566 BC_Trace::disable_locks();
569 MWindow::init_plugins(0, preferences);
570 char font_path[BCTEXTLEN];
571 strcpy(font_path, preferences->plugin_dir);
572 strcat(font_path, "/" FONT_SEARCHPATH);
573 BC_Resources::init_fontconfig(font_path);
574 BC_WindowBase::get_resources()->vframe_shm = 1;
577 strcpy(this->batch_path, batch_path);
578 load_jobs(batch_path, preferences);
579 save_jobs(batch_path);
580 save_defaults(boot_defaults);
583 // Test EDL files for existence
584 if(test_edl_files()) return;
588 // Predict all destination paths
589 ArrayList<char*> paths;
590 paths.set_array_delete();
591 calculate_dest_paths(&paths, preferences);
594 int result = ConfirmSave::test_files(0, &paths);
595 paths.remove_all_objects();
596 // Abort on any existing file because it's so hard to set this up.
600 render = new Render(0);
602 render->start_batches(&jobs,
608 void BatchRenderThread::start_rendering()
610 if(is_rendering) return;
613 save_jobs(batch_path);
614 save_defaults(mwindow->defaults);
615 gui->button_disable();
617 // Test EDL files for existence
618 if(test_edl_files()) return;
620 // Predict all destination paths
621 ArrayList<char*> paths;
622 calculate_dest_paths(&paths,
623 mwindow->preferences);
625 // Test destination files for overwrite
626 int result = ConfirmSave::test_files(mwindow, &paths);
627 paths.remove_all_objects();
633 gui->button_enable();
637 mwindow->render->start_batches(&jobs);
640 void BatchRenderThread::stop_rendering()
642 if(!is_rendering) return;
643 mwindow->render->stop_operation();
647 void BatchRenderThread::update_active(int number)
649 gui->lock_window("BatchRenderThread::update_active");
652 current_job = number;
653 rendering_job = number;
661 gui->unlock_window();
664 void BatchRenderThread::update_done(int number,
668 gui->lock_window("BatchRenderThread::update_done");
671 gui->button_enable();
675 jobs.values[number]->enabled = 0;
676 jobs.values[number]->elapsed = elapsed_time;
677 if(create_list) gui->create_list(1);
679 gui->unlock_window();
682 void BatchRenderThread::move_batch(int src, int dst)
684 BatchRenderJob *src_job = jobs.values[src];
685 if(dst < 0) dst = jobs.total - 1;
689 for(int i = src; i < jobs.total - 1; i++)
690 jobs.values[i] = jobs.values[i + 1];
691 // if(dst > src) dst--;
692 for(int i = jobs.total - 1; i > dst; i--)
693 jobs.values[i] = jobs.values[i - 1];
694 jobs.values[dst] = src_job;
699 void BatchRenderThread::trap_hook(FILE *fp, void *vp)
701 MWindow *mwindow = ((BatchRenderThread *)vp)->mwindow;
702 fprintf(fp, "\nEDL:\n");
703 mwindow->dump_edl(fp);
704 fprintf(fp, "\nUNDO:\n");
705 mwindow->dump_undo(fp);
706 fprintf(fp, "\nEXE:\n");
707 mwindow->dump_exe(fp);
714 BatchRenderGUI::BatchRenderGUI(MWindow *mwindow,
715 BatchRenderThread *thread, int x, int y, int w, int h)
716 : BC_Window(_(PROGRAM_NAME ": Batch Render"),
717 x, y, w, h, 730, 400, 1, 0, 1)
719 this->mwindow = mwindow;
720 this->thread = thread;
723 BatchRenderGUI::~BatchRenderGUI()
725 lock_window("BatchRenderGUI::~BatchRenderGUI");
731 void BatchRenderGUI::create_objects()
733 lock_window("BatchRenderGUI::create_objects");
734 mwindow->theme->get_batchrender_sizes(this, get_w(), get_h());
737 int x = mwindow->theme->batchrender_x1;
739 int x1 = x, x2 = get_w()/2 + 10; // mwindow->theme->batchrender_x2;
743 add_subwindow(output_path_title = new BC_Title(x1, y1, _("Output path:")));
744 y1 += output_path_title->get_h() + mwindow->theme->widget_border;
746 format_tools = new BatchFormat(mwindow, this, thread->get_current_asset());
747 format_tools->set_w(get_w() / 2);
748 format_tools->create_objects(x1, y1, 1, 1, 1, 1, 0, 1, 0, 0,
749 &thread->get_current_job()->file_per_label, 0);
752 add_subwindow(edl_path_title = new BC_Title(x2, y2, _("EDL Path:")));
753 y2 += edl_path_title->get_h() + mwindow->theme->widget_border;
756 add_subwindow(edl_path_text = new BatchRenderEDLPath( thread,
757 x, y, get_w()-x - 40, thread->get_current_edl()));
758 x = x2 + edl_path_text->get_w();
759 add_subwindow(edl_path_browse = new BrowseButton(
760 mwindow->theme, this, edl_path_text, x, y, thread->get_current_edl(),
761 _("Input EDL"), _("Select an EDL to load:"), 0));
762 y2 = y + edl_path_browse->get_h() + mwindow->theme->widget_border;
765 add_subwindow(update_selected_edl = new BatchRenderUpdateEDL(thread, x, y));
766 y += update_selected_edl->get_h() + mwindow->theme->widget_border;
767 add_subwindow(use_current_edl = new BatchRenderCurrentEDL(thread, x, y));
768 y += use_current_edl->get_h() + mwindow->theme->widget_border;
769 if( !mwindow->edl || !mwindow->edl->path[0] ) use_current_edl->disable();
770 add_subwindow(new_batch = new BatchRenderNew(thread, x, y));
771 x += new_batch->get_w() + mwindow->theme->widget_border;
772 add_subwindow(delete_batch = new BatchRenderDelete(thread, x, y));
773 x = x2; y += delete_batch->get_h() + mwindow->theme->widget_border;
774 add_subwindow(savelist_batch = new BatchRenderSaveList(thread, x, y));
775 x += savelist_batch->get_w() + mwindow->theme->widget_border;
776 add_subwindow(loadlist_batch = new BatchRenderLoadList(thread, x, y));
777 y += loadlist_batch->get_h() + mwindow->theme->widget_border;
778 add_subwindow(warning = new BatchRenderWarning(thread, x2, y));
779 y2 = y + warning->get_h() + mwindow->theme->widget_border;
780 if( y2 > y1 ) y1 = y2;
781 x = mwindow->theme->batchrender_x1, y = y1;
783 add_subwindow(list_title = new BC_Title(x, y, _("Batches to render:")));
784 x1 = x + list_title->get_w() + mwindow->theme->widget_border;;
785 add_subwindow(batch_path = new BC_Title(x1, y, thread->batch_path, MEDIUMFONT));
786 y += list_title->get_h() + mwindow->theme->widget_border;
788 y1 -= 15 + BC_GenericButton::calculate_h() + mwindow->theme->widget_border;
789 add_subwindow(batch_list = new BatchRenderList(thread, x, y,
790 get_w() - x - 10, y1 - y));
791 y += batch_list->get_h() + mwindow->theme->widget_border;
793 add_subwindow(start_button = new BatchRenderStart(thread, x, y));
794 x = get_w() / 2 - BC_GenericButton::calculate_w(this, _("Stop")) / 2;
795 add_subwindow(stop_button = new BatchRenderStop(thread, x, y));
796 x = get_w() - BC_GenericButton::calculate_w(this, _("Close")) - 10;
797 add_subwindow(cancel_button = new BatchRenderCancel(thread, x, y));
803 void BatchRenderGUI::button_disable()
805 new_batch->disable();
806 delete_batch->disable();
807 use_current_edl->disable();
808 update_selected_edl->disable();
811 void BatchRenderGUI::button_enable()
814 delete_batch->enable();
815 if( mwindow->edl && mwindow->edl->path[0] )
816 use_current_edl->enable();
817 update_selected_edl->enable();
820 int BatchRenderGUI::resize_event(int w, int h)
822 mwindow->session->batchrender_w = w;
823 mwindow->session->batchrender_h = h;
824 mwindow->theme->get_batchrender_sizes(this, w, h);
826 int x = mwindow->theme->batchrender_x1;
828 int x1 = x, x2 = get_w()/2 + 10; // mwindow->theme->batchrender_x2;
832 output_path_title->reposition_window(x1, y1);
833 y1 += output_path_title->get_h() + mwindow->theme->widget_border;
834 format_tools->reposition_window(x1, y1);
838 edl_path_title->reposition_window(x, y);
839 y += edl_path_title->get_h() + mwindow->theme->widget_border;
840 edl_path_text->reposition_window(x, y, w - x - 40);
841 x += edl_path_text->get_w();
842 edl_path_browse->reposition_window(x, y);
843 y2 = y + edl_path_browse->get_h() + mwindow->theme->widget_border;
846 update_selected_edl->reposition_window(x, y);
847 y += update_selected_edl->get_h() + mwindow->theme->widget_border;
848 use_current_edl->reposition_window(x, y);
849 y += use_current_edl->get_h() + mwindow->theme->widget_border;
850 new_batch->reposition_window(x, y);
851 x += new_batch->get_w() + mwindow->theme->widget_border;
852 delete_batch->reposition_window(x, y);
854 x = x2; y += delete_batch->get_h() + mwindow->theme->widget_border;
855 savelist_batch->reposition_window(x, y);
856 x += savelist_batch->get_w() + mwindow->theme->widget_border;
857 loadlist_batch->reposition_window(x, y);
858 y += loadlist_batch->get_h() + mwindow->theme->widget_border;
859 warning->reposition_window(x2, y);
861 y1 = 15 + BC_GenericButton::calculate_h() + mwindow->theme->widget_border;
862 y2 = get_h() - y1 - batch_list->get_h();
863 y2 -= list_title->get_h() + mwindow->theme->widget_border;
865 x = mwindow->theme->batchrender_x1; y = y2;
866 list_title->reposition_window(x, y);
867 y += list_title->get_h() + mwindow->theme->widget_border;
868 batch_list->reposition_window(x, y, w - x - 10, h - y - y1);
869 y += batch_list->get_h() + mwindow->theme->widget_border;
871 start_button->reposition_window(x, y);
872 x = w / 2 - stop_button->get_w() / 2;
873 stop_button->reposition_window(x, y);
874 x = w - cancel_button->get_w() - 10;
875 cancel_button->reposition_window(x, y);
879 int BatchRenderGUI::translation_event()
881 mwindow->session->batchrender_x = get_x();
882 mwindow->session->batchrender_y = get_y();
886 int BatchRenderGUI::close_event()
888 // Stop batch rendering
890 thread->stop_rendering();
891 lock_window("BatchRenderGUI::close_event");
896 void BatchRenderGUI::create_list(int update_widget)
898 for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
900 list_columns[i].remove_all_objects();
903 for(int i = 0; i < thread->jobs.total; i++)
905 BatchRenderJob *job = thread->jobs.values[i];
906 char string[BCTEXTLEN];
907 BC_ListBoxItem *enabled = new BC_ListBoxItem(job->enabled ?
910 BC_ListBoxItem *item1 = new BC_ListBoxItem(job->asset->path);
911 BC_ListBoxItem *item2 = new BC_ListBoxItem(job->edl_path);
912 BC_ListBoxItem *item3;
914 item3 = new BC_ListBoxItem(
915 Units::totext(string,
919 item3 = new BC_ListBoxItem(_("Unknown"));
920 list_columns[0].append(enabled);
921 list_columns[1].append(item1);
922 list_columns[2].append(item2);
923 list_columns[3].append(item3);
924 if(i == thread->current_job)
926 enabled->set_selected(1);
927 item1->set_selected(1);
928 item2->set_selected(1);
929 item3->set_selected(1);
931 if(i == thread->rendering_job)
933 enabled->set_color(RED);
934 item1->set_color(RED);
935 item2->set_color(RED);
936 item3->set_color(RED);
942 batch_list->update(list_columns,
944 thread->column_width,
946 batch_list->get_xposition(),
947 batch_list->get_yposition(),
948 batch_list->get_highlighted_item(), // Flat index of item cursor is over
949 1, // set all autoplace flags to 1
954 void BatchRenderGUI::change_job()
956 BatchRenderJob *job = thread->get_current_job();
957 format_tools->update(job->asset, &job->file_per_label);
958 edl_path_text->update(job->edl_path);
968 BatchFormat::BatchFormat(MWindow *mwindow,
971 : FormatTools(mwindow, gui, asset)
974 this->mwindow = mwindow;
977 BatchFormat::~BatchFormat()
982 int BatchFormat::handle_event()
998 BatchRenderEDLPath::BatchRenderEDLPath(BatchRenderThread *thread,
1009 this->thread = thread;
1013 int BatchRenderEDLPath::handle_event()
1015 calculate_suggestions();
1016 strcpy(thread->get_current_edl(), get_text());
1017 thread->gui->create_list(1);
1026 BatchRenderNew::BatchRenderNew(BatchRenderThread *thread,
1029 : BC_GenericButton(x, y, _("New"))
1031 this->thread = thread;
1034 int BatchRenderNew::handle_event()
1040 BatchRenderDelete::BatchRenderDelete(BatchRenderThread *thread,
1043 : BC_GenericButton(x, y, _("Delete"))
1045 this->thread = thread;
1048 int BatchRenderDelete::handle_event()
1050 thread->delete_job();
1056 BatchRenderSaveList::BatchRenderSaveList(BatchRenderThread *thread,
1059 : BC_GenericButton(x, y, _("Save Jobs"))
1061 this->thread = thread;
1062 set_tooltip(_("Save a Batch Render List"));
1064 startup_lock = new Mutex("BatchRenderSaveList::startup_lock");
1067 BatchRenderSaveList::~BatchRenderSaveList()
1069 startup_lock->lock("BatchRenderSaveList::~BrowseButton");
1074 gui->unlock_window();
1076 startup_lock->unlock();
1078 delete startup_lock;
1081 int BatchRenderSaveList::handle_event()
1083 if(Thread::running())
1088 gui->raise_window();
1089 gui->unlock_window();
1093 startup_lock->lock("BatchRenderSaveList::handle_event 1");
1095 startup_lock->lock("BatchRenderSaveList::handle_event 2");
1096 startup_lock->unlock();
1100 void BatchRenderSaveList::run()
1102 char default_path[BCTEXTLEN];
1103 sprintf(default_path, "~");
1104 thread->mwindow->defaults->get("DEFAULT_BATCHLOADPATH", default_path);
1105 BC_FileBox filewindow(100, 100, default_path, _("Save Batch Render List"),
1106 _("Enter a Batch Render filename to save as:"),
1110 startup_lock->unlock();
1111 filewindow.create_objects();
1113 int result2 = filewindow.run_window();
1115 strcpy(thread->batch_path, filewindow.get_submitted_path());
1116 thread->gui->batch_path->update(thread->batch_path);
1117 thread->mwindow->defaults->update("DEFAULT_BATCHLOADPATH", thread->batch_path);
1118 thread->save_jobs(thread->batch_path);
1121 this->thread->gui->flush();
1122 startup_lock->lock("BatchRenderLoadList::run");
1124 startup_lock->unlock();
1127 int BatchRenderSaveList::keypress_event() {
1128 if (get_keypress() == 's' ||
1129 get_keypress() == 'S') return handle_event();
1136 BatchRenderLoadList::BatchRenderLoadList(BatchRenderThread *thread,
1139 : BC_GenericButton(x, y, _("Load Jobs")),
1142 this->thread = thread;
1143 set_tooltip(_("Load a previously saved Batch Render List"));
1145 startup_lock = new Mutex("BatchRenderLoadList::startup_lock");
1148 BatchRenderLoadList::~BatchRenderLoadList()
1150 startup_lock->lock("BatchRenderLoadList::~BrowseButton");
1154 gui->unlock_window();
1156 startup_lock->unlock();
1158 delete startup_lock;
1161 int BatchRenderLoadList::handle_event()
1163 if(Thread::running()) {
1166 gui->raise_window();
1167 gui->unlock_window();
1171 startup_lock->lock("BatchRenderLoadList::handle_event 1");
1173 startup_lock->lock("BatchRenderLoadList::handle_event 2");
1174 startup_lock->unlock();
1178 void BatchRenderLoadList::run()
1180 char default_path[BCTEXTLEN];
1181 sprintf(default_path, "~");
1182 thread->mwindow->defaults->get("DEFAULT_BATCHLOADPATH", default_path);
1183 BC_FileBox filewindow(100, 100, default_path, _("Load Batch Render List"),
1184 _("Enter a Batch Render filename to load from:"),
1188 startup_lock->unlock();
1189 filewindow.create_objects();
1191 int result2 = filewindow.run_window();
1193 strcpy(thread->batch_path, filewindow.get_submitted_path());
1194 thread->gui->batch_path->update(thread->batch_path);
1195 thread->mwindow->defaults->update("DEFAULT_BATCHLOADPATH", thread->batch_path);
1196 thread->load_jobs(thread->batch_path, thread->mwindow->preferences);
1197 thread->gui->create_list(1);
1198 thread->current_job = 0;
1199 thread->gui->change_job();
1202 thread->gui->flush();
1203 startup_lock->lock("BatchRenderLoadList::run");
1205 startup_lock->unlock();
1208 int BatchRenderLoadList::keypress_event() {
1209 if (get_keypress() == 'o' ||
1210 get_keypress() == 'O') return handle_event();
1214 BatchRenderCurrentEDL::BatchRenderCurrentEDL(BatchRenderThread *thread,
1217 : BC_GenericButton(x, y, _("Use Current EDL"))
1219 this->thread = thread;
1222 int BatchRenderCurrentEDL::handle_event()
1224 thread->use_current_edl();
1228 BatchRenderUpdateEDL::BatchRenderUpdateEDL(BatchRenderThread *thread,
1231 : BC_GenericButton(x, y, _("Save to EDL Path"))
1233 this->thread = thread;
1236 int BatchRenderUpdateEDL::handle_event()
1238 thread->update_selected_edl();
1245 BatchRenderList::BatchRenderList(BatchRenderThread *thread,
1255 thread->gui->list_columns,
1257 thread->column_width,
1258 BATCHRENDER_COLUMNS,
1265 this->thread = thread;
1267 set_process_drag(0);
1270 int BatchRenderList::handle_event()
1275 int BatchRenderList::selection_changed()
1277 thread->current_job = get_selection_number(0, 0);
1278 thread->gui->change_job();
1279 if(get_cursor_x() < thread->column_width[0])
1281 BatchRenderJob *job = thread->get_current_job();
1282 job->enabled = !job->enabled;
1283 thread->gui->create_list(1);
1288 int BatchRenderList::column_resize_event()
1290 for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
1292 thread->column_width[i] = get_column_width(i);
1297 int BatchRenderList::drag_start_event()
1299 if(BC_ListBox::drag_start_event())
1308 int BatchRenderList::drag_motion_event()
1310 if(BC_ListBox::drag_motion_event())
1317 int BatchRenderList::drag_stop_event()
1321 int src = get_selection_number(0, 0);
1322 int dst = get_highlighted_item();
1325 thread->move_batch(src, dst);
1327 BC_ListBox::drag_stop_event();
1344 BatchRenderStart::BatchRenderStart(BatchRenderThread *thread,
1347 : BC_GenericButton(x,
1351 this->thread = thread;
1354 int BatchRenderStart::handle_event()
1356 thread->start_rendering();
1360 BatchRenderStop::BatchRenderStop(BatchRenderThread *thread,
1363 : BC_GenericButton(x,
1367 this->thread = thread;
1370 int BatchRenderStop::handle_event()
1373 thread->stop_rendering();
1374 lock_window("BatchRenderStop::handle_event");
1379 BatchRenderWarning::BatchRenderWarning(BatchRenderThread *thread, int x, int y)
1380 : BC_CheckBox(x, y, thread->warn, _("warn if jobs/session mismatched"))
1382 this->thread = thread;
1385 int BatchRenderWarning::handle_event()
1387 thread->warn = get_value();
1392 BatchRenderCancel::BatchRenderCancel(BatchRenderThread *thread,
1395 : BC_GenericButton(x,
1399 this->thread = thread;
1402 int BatchRenderCancel::handle_event()
1405 thread->stop_rendering();
1406 lock_window("BatchRenderCancel::handle_event");
1407 thread->gui->set_done(1);
1411 int BatchRenderCancel::keypress_event()
1413 if(get_keypress() == ESC)
1416 thread->stop_rendering();
1417 lock_window("BatchRenderCancel::keypress_event");
1418 thread->gui->set_done(1);