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)
97 this->preferences = preferences;
105 BatchRenderJob::~BatchRenderJob()
107 asset->Garbage::remove_user();
110 void BatchRenderJob::copy_from(BatchRenderJob *src)
112 asset->copy_from(src->asset, 0);
113 strcpy(edl_path, src->edl_path);
114 strategy = src->strategy;
115 enabled = src->enabled;
119 void BatchRenderJob::load(FileXML *file)
124 file->tag.get_property("EDL_PATH", edl_path);
125 strategy = file->tag.get_property("STRATEGY", strategy);
126 enabled = file->tag.get_property("ENABLED", enabled);
127 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", 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 void BatchRenderJob::fix_strategy()
182 strategy = Render::fix_strategy(strategy, preferences->use_renderfarm);
194 BatchRenderThread::BatchRenderThread(MWindow *mwindow)
197 this->mwindow = mwindow;
210 BatchRenderThread::BatchRenderThread()
226 BatchRenderThread::~BatchRenderThread()
229 delete boot_defaults;
233 file_entries->remove_all_objects();
238 void BatchRenderThread::reset(const char *path)
241 strcpy(batch_path, path);
246 delete default_job; default_job = 0;
247 jobs.remove_all_objects();
249 file_entries->remove_all_objects();
250 delete file_entries; file_entries = 0;
254 void BatchRenderThread::handle_close_event(int result)
257 save_jobs(batch_path);
258 save_defaults(mwindow->defaults);
262 BC_Window* BatchRenderThread::new_gui()
266 default_job = new BatchRenderJob(mwindow->preferences);
271 file_entries = new ArrayList<BC_ListBoxItem*>;
273 char string[BCTEXTLEN];
274 // Load current directory
275 fs.update(getcwd(string, BCTEXTLEN));
276 for(int i = 0; i < fs.total_files(); i++)
278 file_entries->append(
280 fs.get_entry(i)->get_name()));
284 load_jobs(batch_path, mwindow->preferences);
285 load_defaults(mwindow->defaults);
286 this->gui = new BatchRenderGUI(mwindow,
288 mwindow->session->batchrender_x,
289 mwindow->session->batchrender_y,
290 mwindow->session->batchrender_w,
291 mwindow->session->batchrender_h);
292 this->gui->create_objects();
297 void BatchRenderThread::load_jobs(char *path, Preferences *preferences)
302 jobs.remove_all_objects();
303 if( !path ) path = batch_path;
304 if( !path[0] ) create_path(path);
305 file.read_from_file(path);
309 if(!(result = file.read_tag()))
311 if(file.tag.title_is("JOBS"))
313 warn = file.tag.get_property("WARN", 1);
315 else if(file.tag.title_is("JOB"))
318 jobs.append(job = new BatchRenderJob(preferences));
325 void BatchRenderThread::save_jobs(char *path)
328 file.tag.set_title("JOBS");
329 file.tag.set_property("WARN", warn);
331 file.append_newline();
333 for(int i = 0; i < jobs.total; i++)
335 file.tag.set_title("JOB");
336 jobs.values[i]->save(&file);
338 file.tag.set_title("/JOBS");
340 file.append_newline();
342 if( !path ) path = batch_path;
343 if( !path[0] ) create_path(path);
344 file.write_to_file(path);
347 void BatchRenderThread::load_defaults(BC_Hash *defaults)
351 default_job->asset->load_defaults(defaults,
352 "BATCHRENDER_", 1, 1, 1, 1, 1);
353 default_job->fix_strategy();
356 for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
358 char string[BCTEXTLEN];
359 sprintf(string, "BATCHRENDER_COLUMN%d", i);
360 column_width[i] = defaults->get(string, list_widths[i]);
364 void BatchRenderThread::save_defaults(BC_Hash *defaults)
368 default_job->asset->save_defaults(defaults,
369 "BATCHRENDER_", 1, 1, 1, 1, 1);
370 defaults->update("BATCHRENDER_STRATEGY", default_job->strategy);
372 for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
374 char string[BCTEXTLEN];
375 sprintf(string, "BATCHRENDER_COLUMN%d", i);
376 defaults->update(string, column_width[i]);
378 // defaults->update("BATCHRENDER_JOB", current_job);
380 mwindow->save_defaults();
385 char* BatchRenderThread::create_path(char *string)
388 sprintf(string, "%s/", File::get_config_path());
389 fs.complete_path(string);
390 strcat(string, BATCH_PATH);
394 void BatchRenderThread::new_job()
396 BatchRenderJob *result = new BatchRenderJob(mwindow->preferences);
397 result->copy_from(get_current_job());
399 current_job = jobs.total - 1;
404 void BatchRenderThread::delete_job()
406 if(current_job < jobs.total && current_job >= 0)
408 jobs.remove_object_number(current_job);
409 if(current_job > 0) current_job--;
415 void BatchRenderThread::use_current_edl()
417 // printf("BatchRenderThread::use_current_edl %d %p %s\n",
419 // mwindow->edl->path,
420 // mwindow->edl->path);
422 strcpy(get_current_edl(), mwindow->edl->path);
424 gui->edl_path_text->update(get_current_edl());
427 void BatchRenderThread::update_selected_edl()
430 char *path = get_current_edl();
431 EDL *edl = mwindow->edl;
432 edl->save_xml(&xml_file, path, 0, 0);
433 xml_file.terminate_string();
434 if( xml_file.write_to_file(path) ) {
436 sprintf(msg, _("Unable to save: %s"), path);
437 MainError::show_error(msg);
441 BatchRenderJob* BatchRenderThread::get_current_job()
443 BatchRenderJob *result;
444 if(current_job >= jobs.total || current_job < 0)
446 result = default_job;
450 result = jobs.values[current_job];
456 Asset* BatchRenderThread::get_current_asset()
458 return get_current_job()->asset;
461 char* BatchRenderThread::get_current_edl()
463 return get_current_job()->edl_path;
467 // Test EDL files for existence
468 int BatchRenderThread::test_edl_files()
470 int not_equiv = 0, ret = 0;
471 const char *path = 0;
473 for( int i=0; !ret && i<jobs.size(); ++i ) {
474 if( !jobs.values[i]->enabled ) continue;
475 const char *path = jobs.values[i]->edl_path;
476 int is_script = *path == '@' ? 1 : 0;
477 if( is_script ) ++path;
478 FILE *fp = fopen(path, "r");
480 if( warn && mwindow && !is_script ) {
481 fseek(fp, 0, SEEK_END);
482 int64_t sz = ftell(fp);
483 fseek(fp, 0, SEEK_SET);
484 char *bfr = new char[sz+1];
485 int64_t len = fread(bfr, 1, sz+1, fp);
487 FileXML file; file.set_shared_input(bfr, len);
488 EDL *edl = new EDL; edl->create_objects();
489 edl->load_xml(&file, LOAD_ALL);
490 double pos = edl->equivalent_output(mwindow->edl);
491 if( pos >= 0 ) ++not_equiv;
505 char string[BCTEXTLEN];
506 sprintf(string, _("EDL %s not found.\n"), path);
508 ErrorBox error_box(_(PROGRAM_NAME ": Error"),
509 mwindow->gui->get_abs_cursor_x(1),
510 mwindow->gui->get_abs_cursor_y(1));
511 error_box.create_objects(string);
512 error_box.run_window();
513 gui->button_enable();
516 fprintf(stderr, "%s", string);
520 else if( warn && mwindow && not_equiv > 0 ) {
521 fprintf(stderr, _("%d job EDLs do not match session edl\n"), not_equiv);
522 char string[BCTEXTLEN], *sp = string;
523 sp += sprintf(sp, _("%d job EDLs do not match session edl\n"),not_equiv);
524 sp += sprintf(sp, _("press cancel to abandon batch render"));
525 mwindow->show_warning(&warn, string);
526 if( mwindow->wait_warning() ) {
527 gui->button_enable();
531 gui->warning->update(warn);
537 void BatchRenderThread::calculate_dest_paths(ArrayList<char*> *paths,
538 Preferences *preferences)
540 for(int i = 0; i < jobs.total; i++)
542 BatchRenderJob *job = jobs.values[i];
543 if(job->enabled && *job->edl_path != '@')
545 PackageDispatcher *packages = new PackageDispatcher;
548 TransportCommand *command = new TransportCommand;
549 FileXML *file = new FileXML;
550 file->read_from_file(job->edl_path);
552 // Use command to calculate range.
553 command->command = NORMAL_FWD;
554 command->get_edl()->load_xml(file,
556 command->change_type = CHANGE_ALL;
557 command->set_playback_range();
558 command->playback_range_adjust_inout();
560 // Create test packages
561 packages->create_packages(mwindow,
566 command->start_position,
567 command->end_position,
570 // Append output paths allocated to total
571 packages->get_package_paths(paths);
573 // Delete package harness
582 void BatchRenderThread::start_rendering(char *config_path,
585 BC_Hash *boot_defaults;
586 Preferences *preferences;
588 BC_Signals *signals = new BC_Signals;
589 // XXX the above stuff is leaked,
591 // Initialize stuff which MWindow does.
592 signals->initialize("/tmp/cinelerra_batch%d.dmp");
593 MWindow::init_defaults(boot_defaults, config_path);
594 load_defaults(boot_defaults);
595 preferences = new Preferences;
596 preferences->load_defaults(boot_defaults);
597 BC_Signals::set_trap_hook(trap_hook, this);
598 BC_Signals::set_catch_segv(preferences->trap_sigsegv);
599 BC_Signals::set_catch_intr(0);
600 if( preferences->trap_sigsegv ) {
601 BC_Trace::enable_locks();
604 BC_Trace::disable_locks();
607 MWindow::init_plugins(0, preferences);
608 char font_path[BCTEXTLEN];
609 strcpy(font_path, preferences->plugin_dir);
610 strcat(font_path, "/" FONT_SEARCHPATH);
611 BC_Resources::init_fontconfig(font_path);
612 BC_WindowBase::get_resources()->vframe_shm = 1;
615 strcpy(this->batch_path, batch_path);
616 load_jobs(batch_path, preferences);
617 save_jobs(batch_path);
618 save_defaults(boot_defaults);
621 // Test EDL files for existence
622 if(test_edl_files()) return;
626 // Predict all destination paths
627 ArrayList<char*> paths;
628 paths.set_array_delete();
629 calculate_dest_paths(&paths, preferences);
632 int result = ConfirmSave::test_files(0, &paths);
633 paths.remove_all_objects();
634 // Abort on any existing file because it's so hard to set this up.
638 render = new Render(0);
640 render->start_batches(&jobs,
646 void BatchRenderThread::start_rendering()
648 if(is_rendering) return;
651 save_jobs(batch_path);
652 save_defaults(mwindow->defaults);
653 gui->button_disable();
655 // Test EDL files for existence
656 if(test_edl_files()) return;
658 // Predict all destination paths
659 ArrayList<char*> paths;
660 calculate_dest_paths(&paths,
661 mwindow->preferences);
663 // Test destination files for overwrite
664 int result = ConfirmSave::test_files(mwindow, &paths);
665 paths.remove_all_objects();
671 gui->button_enable();
675 mwindow->render->start_batches(&jobs);
678 void BatchRenderThread::stop_rendering()
680 if(!is_rendering) return;
681 mwindow->render->stop_operation();
685 void BatchRenderThread::update_active(int number)
687 gui->lock_window("BatchRenderThread::update_active");
690 current_job = number;
691 rendering_job = number;
699 gui->unlock_window();
702 void BatchRenderThread::update_done(int number,
706 gui->lock_window("BatchRenderThread::update_done");
709 gui->button_enable();
713 jobs.values[number]->enabled = 0;
714 jobs.values[number]->elapsed = elapsed_time;
715 if(create_list) gui->create_list(1);
717 gui->unlock_window();
720 void BatchRenderThread::move_batch(int src, int dst)
722 BatchRenderJob *src_job = jobs.values[src];
723 if(dst < 0) dst = jobs.total - 1;
727 for(int i = src; i < jobs.total - 1; i++)
728 jobs.values[i] = jobs.values[i + 1];
729 // if(dst > src) dst--;
730 for(int i = jobs.total - 1; i > dst; i--)
731 jobs.values[i] = jobs.values[i - 1];
732 jobs.values[dst] = src_job;
737 void BatchRenderThread::trap_hook(FILE *fp, void *vp)
739 MWindow *mwindow = ((BatchRenderThread *)vp)->mwindow;
740 fprintf(fp, "\nEDL:\n");
741 mwindow->dump_edl(fp);
742 fprintf(fp, "\nUNDO:\n");
743 mwindow->dump_undo(fp);
744 fprintf(fp, "\nEXE:\n");
745 mwindow->dump_exe(fp);
752 BatchRenderGUI::BatchRenderGUI(MWindow *mwindow,
753 BatchRenderThread *thread, int x, int y, int w, int h)
754 : BC_Window(_(PROGRAM_NAME ": Batch Render"),
755 x, y, w, h, 730, 400, 1, 0, 1)
757 this->mwindow = mwindow;
758 this->thread = thread;
761 BatchRenderGUI::~BatchRenderGUI()
763 lock_window("BatchRenderGUI::~BatchRenderGUI");
769 void BatchRenderGUI::create_objects()
771 lock_window("BatchRenderGUI::create_objects");
772 mwindow->theme->get_batchrender_sizes(this, get_w(), get_h());
775 int x = mwindow->theme->batchrender_x1;
777 int x1 = x, x2 = get_w()/2 + 10; // mwindow->theme->batchrender_x2;
781 add_subwindow(output_path_title = new BC_Title(x1, y1, _("Output path:")));
782 y1 += output_path_title->get_h() + mwindow->theme->widget_border;
784 format_tools = new BatchFormat(mwindow, this, thread->get_current_asset());
785 format_tools->set_w(get_w() / 2);
786 format_tools->create_objects(x1, y1, 1, 1, 1, 1, 0, 1, 0, 0,
787 &thread->get_current_job()->strategy, 0);
790 add_subwindow(edl_path_title = new BC_Title(x2, y2, _("EDL Path:")));
791 y2 += edl_path_title->get_h() + mwindow->theme->widget_border;
794 add_subwindow(edl_path_text = new BatchRenderEDLPath( thread,
795 x, y, get_w()-x - 40, thread->get_current_edl()));
796 x = x2 + edl_path_text->get_w();
797 add_subwindow(edl_path_browse = new BrowseButton(
798 mwindow->theme, this, edl_path_text, x, y, thread->get_current_edl(),
799 _("Input EDL"), _("Select an EDL to load:"), 0));
800 y2 = y + edl_path_browse->get_h() + mwindow->theme->widget_border;
803 add_subwindow(update_selected_edl = new BatchRenderUpdateEDL(thread, x, y));
804 y += update_selected_edl->get_h() + mwindow->theme->widget_border;
805 add_subwindow(use_current_edl = new BatchRenderCurrentEDL(thread, x, y));
806 y += use_current_edl->get_h() + mwindow->theme->widget_border;
807 if( !mwindow->edl || !mwindow->edl->path[0] ) use_current_edl->disable();
808 add_subwindow(new_batch = new BatchRenderNew(thread, x, y));
809 x += new_batch->get_w() + mwindow->theme->widget_border;
810 add_subwindow(delete_batch = new BatchRenderDelete(thread, x, y));
811 x = x2; y += delete_batch->get_h() + mwindow->theme->widget_border;
812 y += mwindow->theme->widget_border;
813 add_subwindow(savelist_batch = new BatchRenderSaveList(thread, x, y));
814 x += savelist_batch->get_w() + mwindow->theme->widget_border;
815 add_subwindow(loadlist_batch = new BatchRenderLoadList(thread, x, y));
816 y += loadlist_batch->get_h() + mwindow->theme->widget_border;
817 add_subwindow(warning = new BatchRenderWarning(thread, x2, y));
818 y2 = y + warning->get_h() + mwindow->theme->widget_border;
819 if( y2 > y1 ) y1 = y2;
820 x = mwindow->theme->batchrender_x1, y = y1;
822 add_subwindow(list_title = new BC_Title(x, y, _("Batches to render:")));
823 x1 = x + list_title->get_w() + mwindow->theme->widget_border;;
824 add_subwindow(batch_path = new BC_Title(x1, y, thread->batch_path, MEDIUMFONT));
825 y += list_title->get_h() + mwindow->theme->widget_border;
827 y1 -= 15 + BC_GenericButton::calculate_h() + mwindow->theme->widget_border;
828 add_subwindow(batch_list = new BatchRenderList(thread, x, y,
829 get_w() - x - 10, y1 - y));
830 y += batch_list->get_h() + mwindow->theme->widget_border;
832 add_subwindow(start_button = new BatchRenderStart(thread, x, y));
833 x = get_w() / 2 - BC_GenericButton::calculate_w(this, _("Stop")) / 2;
834 add_subwindow(stop_button = new BatchRenderStop(thread, x, y));
835 x = get_w() - BC_GenericButton::calculate_w(this, _("Close")) - 10;
836 add_subwindow(cancel_button = new BatchRenderCancel(thread, x, y));
842 void BatchRenderGUI::button_disable()
844 new_batch->disable();
845 delete_batch->disable();
846 use_current_edl->disable();
847 update_selected_edl->disable();
850 void BatchRenderGUI::button_enable()
853 delete_batch->enable();
854 if( mwindow->edl && mwindow->edl->path[0] )
855 use_current_edl->enable();
856 update_selected_edl->enable();
859 int BatchRenderGUI::resize_event(int w, int h)
861 mwindow->session->batchrender_w = w;
862 mwindow->session->batchrender_h = h;
863 mwindow->theme->get_batchrender_sizes(this, w, h);
865 int x = mwindow->theme->batchrender_x1;
867 int x1 = x, x2 = get_w()/2 + 10; // mwindow->theme->batchrender_x2;
871 output_path_title->reposition_window(x1, y1);
872 y1 += output_path_title->get_h() + mwindow->theme->widget_border;
873 format_tools->reposition_window(x1, y1);
877 edl_path_title->reposition_window(x, y);
878 y += edl_path_title->get_h() + mwindow->theme->widget_border;
879 edl_path_text->reposition_window(x, y, w - x - 40);
880 x += edl_path_text->get_w();
881 edl_path_browse->reposition_window(x, y);
882 y2 = y + edl_path_browse->get_h() + mwindow->theme->widget_border;
885 update_selected_edl->reposition_window(x, y);
886 y += update_selected_edl->get_h() + mwindow->theme->widget_border;
887 use_current_edl->reposition_window(x, y);
888 y += use_current_edl->get_h() + mwindow->theme->widget_border;
889 new_batch->reposition_window(x, y);
890 x += new_batch->get_w() + mwindow->theme->widget_border;
891 delete_batch->reposition_window(x, y);
893 x = x2; y += delete_batch->get_h() + mwindow->theme->widget_border;
894 savelist_batch->reposition_window(x, y);
895 x += savelist_batch->get_w() + mwindow->theme->widget_border;
896 loadlist_batch->reposition_window(x, y);
897 y += loadlist_batch->get_h() + mwindow->theme->widget_border;
898 warning->reposition_window(x, y);
900 y1 = 15 + BC_GenericButton::calculate_h() + mwindow->theme->widget_border;
901 y2 = get_h() - y1 - batch_list->get_h();
902 y2 -= list_title->get_h() + mwindow->theme->widget_border;
904 x = mwindow->theme->batchrender_x1; y = y2;
905 list_title->reposition_window(x, y);
906 y += list_title->get_h() + mwindow->theme->widget_border;
907 batch_list->reposition_window(x, y, w - x - 10, h - y - y1);
908 y += batch_list->get_h() + mwindow->theme->widget_border;
910 start_button->reposition_window(x, y);
911 x = w / 2 - stop_button->get_w() / 2;
912 stop_button->reposition_window(x, y);
913 x = w - cancel_button->get_w() - 10;
914 cancel_button->reposition_window(x, y);
918 int BatchRenderGUI::translation_event()
920 mwindow->session->batchrender_x = get_x();
921 mwindow->session->batchrender_y = get_y();
925 int BatchRenderGUI::close_event()
927 // Stop batch rendering
929 thread->stop_rendering();
930 lock_window("BatchRenderGUI::close_event");
935 void BatchRenderGUI::create_list(int update_widget)
937 for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
939 list_columns[i].remove_all_objects();
942 for(int i = 0; i < thread->jobs.total; i++)
944 BatchRenderJob *job = thread->jobs.values[i];
945 char string[BCTEXTLEN];
946 BC_ListBoxItem *enabled = new BC_ListBoxItem(job->enabled ?
949 BC_ListBoxItem *item1 = new BC_ListBoxItem(job->asset->path);
950 BC_ListBoxItem *item2 = new BC_ListBoxItem(job->edl_path);
951 BC_ListBoxItem *item3;
953 item3 = new BC_ListBoxItem(
954 Units::totext(string,
958 item3 = new BC_ListBoxItem(_("Unknown"));
959 list_columns[0].append(enabled);
960 list_columns[1].append(item1);
961 list_columns[2].append(item2);
962 list_columns[3].append(item3);
963 if(i == thread->current_job)
965 enabled->set_selected(1);
966 item1->set_selected(1);
967 item2->set_selected(1);
968 item3->set_selected(1);
970 if(i == thread->rendering_job)
972 enabled->set_color(RED);
973 item1->set_color(RED);
974 item2->set_color(RED);
975 item3->set_color(RED);
981 batch_list->update(list_columns,
983 thread->column_width,
985 batch_list->get_xposition(),
986 batch_list->get_yposition(),
987 batch_list->get_highlighted_item(), // Flat index of item cursor is over
988 1, // set all autoplace flags to 1
993 void BatchRenderGUI::change_job()
995 BatchRenderJob *job = thread->get_current_job();
996 format_tools->update(job->asset, &job->strategy);
997 edl_path_text->update(job->edl_path);
1007 BatchFormat::BatchFormat(MWindow *mwindow,
1008 BatchRenderGUI *gui,
1010 : FormatTools(mwindow, gui, asset)
1013 this->mwindow = mwindow;
1016 BatchFormat::~BatchFormat()
1021 int BatchFormat::handle_event()
1023 gui->create_list(1);
1037 BatchRenderEDLPath::BatchRenderEDLPath(BatchRenderThread *thread,
1048 this->thread = thread;
1052 int BatchRenderEDLPath::handle_event()
1055 calculate_suggestions(thread->file_entries);
1057 strcpy(thread->get_current_edl(), get_text());
1058 thread->gui->create_list(1);
1067 BatchRenderNew::BatchRenderNew(BatchRenderThread *thread,
1070 : BC_GenericButton(x, y, _("New"))
1072 this->thread = thread;
1075 int BatchRenderNew::handle_event()
1081 BatchRenderDelete::BatchRenderDelete(BatchRenderThread *thread,
1084 : BC_GenericButton(x, y, _("Delete"))
1086 this->thread = thread;
1089 int BatchRenderDelete::handle_event()
1091 thread->delete_job();
1097 BatchRenderSaveList::BatchRenderSaveList(BatchRenderThread *thread,
1100 : BC_GenericButton(x, y, _("Save Jobs"))
1102 this->thread = thread;
1103 set_tooltip(_("Save a Batch Render List"));
1105 startup_lock = new Mutex("BatchRenderSaveList::startup_lock");
1108 BatchRenderSaveList::~BatchRenderSaveList()
1110 startup_lock->lock("BatchRenderSaveList::~BrowseButton");
1115 gui->unlock_window();
1117 startup_lock->unlock();
1119 delete startup_lock;
1122 int BatchRenderSaveList::handle_event()
1124 if(Thread::running())
1129 gui->raise_window();
1130 gui->unlock_window();
1134 startup_lock->lock("BatchRenderSaveList::handle_event 1");
1136 startup_lock->lock("BatchRenderSaveList::handle_event 2");
1137 startup_lock->unlock();
1141 void BatchRenderSaveList::run()
1143 char default_path[BCTEXTLEN];
1144 sprintf(default_path, "~");
1145 thread->mwindow->defaults->get("DEFAULT_BATCHLOADPATH", default_path);
1146 BC_FileBox filewindow(100, 100, default_path, _("Save Batch Render List"),
1147 _("Enter a Batch Render filename to save as:"),
1151 startup_lock->unlock();
1152 filewindow.create_objects();
1154 int result2 = filewindow.run_window();
1156 strcpy(thread->batch_path, filewindow.get_submitted_path());
1157 thread->gui->batch_path->update(thread->batch_path);
1158 thread->mwindow->defaults->update("DEFAULT_BATCHLOADPATH", thread->batch_path);
1159 thread->save_jobs(thread->batch_path);
1162 this->thread->gui->flush();
1163 startup_lock->lock("BatchRenderLoadList::run");
1165 startup_lock->unlock();
1168 int BatchRenderSaveList::keypress_event() {
1169 if (get_keypress() == 's' ||
1170 get_keypress() == 'S') return handle_event();
1177 BatchRenderLoadList::BatchRenderLoadList(BatchRenderThread *thread,
1180 : BC_GenericButton(x, y, _("Load Jobs")),
1183 this->thread = thread;
1184 set_tooltip(_("Load a previously saved Batch Render List"));
1186 startup_lock = new Mutex("BatchRenderLoadList::startup_lock");
1189 BatchRenderLoadList::~BatchRenderLoadList()
1191 startup_lock->lock("BatchRenderLoadList::~BrowseButton");
1195 gui->unlock_window();
1197 startup_lock->unlock();
1199 delete startup_lock;
1202 int BatchRenderLoadList::handle_event()
1204 if(Thread::running()) {
1207 gui->raise_window();
1208 gui->unlock_window();
1212 startup_lock->lock("BatchRenderLoadList::handle_event 1");
1214 startup_lock->lock("BatchRenderLoadList::handle_event 2");
1215 startup_lock->unlock();
1219 void BatchRenderLoadList::run()
1221 char default_path[BCTEXTLEN];
1222 sprintf(default_path, "~");
1223 thread->mwindow->defaults->get("DEFAULT_BATCHLOADPATH", default_path);
1224 BC_FileBox filewindow(100, 100, default_path, _("Load Batch Render List"),
1225 _("Enter a Batch Render filename to load from:"),
1229 startup_lock->unlock();
1230 filewindow.create_objects();
1232 int result2 = filewindow.run_window();
1234 strcpy(thread->batch_path, filewindow.get_submitted_path());
1235 thread->gui->batch_path->update(thread->batch_path);
1236 thread->mwindow->defaults->update("DEFAULT_BATCHLOADPATH", thread->batch_path);
1237 thread->load_jobs(thread->batch_path, thread->mwindow->preferences);
1238 thread->gui->create_list(1);
1241 thread->gui->flush();
1242 startup_lock->lock("BatchRenderLoadList::run");
1244 startup_lock->unlock();
1247 int BatchRenderLoadList::keypress_event() {
1248 if (get_keypress() == 'o' ||
1249 get_keypress() == 'O') return handle_event();
1253 BatchRenderCurrentEDL::BatchRenderCurrentEDL(BatchRenderThread *thread,
1256 : BC_GenericButton(x, y, _("Use Current EDL"))
1258 this->thread = thread;
1261 int BatchRenderCurrentEDL::handle_event()
1263 thread->use_current_edl();
1267 BatchRenderUpdateEDL::BatchRenderUpdateEDL(BatchRenderThread *thread,
1270 : BC_GenericButton(x, y, _("Save to EDL Path"))
1272 this->thread = thread;
1275 int BatchRenderUpdateEDL::handle_event()
1277 thread->update_selected_edl();
1284 BatchRenderList::BatchRenderList(BatchRenderThread *thread,
1294 thread->gui->list_columns,
1296 thread->column_width,
1297 BATCHRENDER_COLUMNS,
1304 this->thread = thread;
1306 set_process_drag(0);
1309 int BatchRenderList::handle_event()
1314 int BatchRenderList::selection_changed()
1316 thread->current_job = get_selection_number(0, 0);
1317 thread->gui->change_job();
1318 if(get_cursor_x() < thread->column_width[0])
1320 BatchRenderJob *job = thread->get_current_job();
1321 job->enabled = !job->enabled;
1322 thread->gui->create_list(1);
1327 int BatchRenderList::column_resize_event()
1329 for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
1331 thread->column_width[i] = get_column_width(i);
1336 int BatchRenderList::drag_start_event()
1338 if(BC_ListBox::drag_start_event())
1347 int BatchRenderList::drag_motion_event()
1349 if(BC_ListBox::drag_motion_event())
1356 int BatchRenderList::drag_stop_event()
1360 int src = get_selection_number(0, 0);
1361 int dst = get_highlighted_item();
1364 thread->move_batch(src, dst);
1366 BC_ListBox::drag_stop_event();
1383 BatchRenderStart::BatchRenderStart(BatchRenderThread *thread,
1386 : BC_GenericButton(x,
1390 this->thread = thread;
1393 int BatchRenderStart::handle_event()
1395 thread->start_rendering();
1399 BatchRenderStop::BatchRenderStop(BatchRenderThread *thread,
1402 : BC_GenericButton(x,
1406 this->thread = thread;
1409 int BatchRenderStop::handle_event()
1412 thread->stop_rendering();
1413 lock_window("BatchRenderStop::handle_event");
1418 BatchRenderWarning::BatchRenderWarning(BatchRenderThread *thread, int x, int y)
1419 : BC_CheckBox(x, y, thread->warn, _("warn if jobs/session mismatched"))
1421 this->thread = thread;
1424 int BatchRenderWarning::handle_event()
1426 thread->warn = get_value();
1431 BatchRenderCancel::BatchRenderCancel(BatchRenderThread *thread,
1434 : BC_GenericButton(x,
1438 this->thread = thread;
1441 int BatchRenderCancel::handle_event()
1444 thread->stop_rendering();
1445 lock_window("BatchRenderCancel::handle_event");
1446 thread->gui->set_done(1);
1450 int BatchRenderCancel::keypress_event()
1452 if(get_keypress() == ESC)
1455 thread->stop_rendering();
1456 lock_window("BatchRenderCancel::keypress_event");
1457 thread->gui->set_done(1);