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;
209 BatchRenderThread::BatchRenderThread()
224 BatchRenderThread::~BatchRenderThread()
227 delete boot_defaults;
232 void BatchRenderThread::reset(const char *path)
235 strcpy(batch_path, path);
240 delete default_job; default_job = 0;
241 jobs.remove_all_objects();
244 void BatchRenderThread::handle_close_event(int result)
247 save_jobs(batch_path);
248 save_defaults(mwindow->defaults);
252 BC_Window* BatchRenderThread::new_gui()
256 default_job = new BatchRenderJob(mwindow->preferences);
257 load_jobs(batch_path, mwindow->preferences);
258 load_defaults(mwindow->defaults);
259 this->gui = new BatchRenderGUI(mwindow,
261 mwindow->session->batchrender_x,
262 mwindow->session->batchrender_y,
263 mwindow->session->batchrender_w,
264 mwindow->session->batchrender_h);
265 this->gui->create_objects();
270 void BatchRenderThread::load_jobs(char *path, Preferences *preferences)
275 jobs.remove_all_objects();
276 if( !path ) path = batch_path;
277 if( !path[0] ) create_path(path);
278 file.read_from_file(path);
282 if(!(result = file.read_tag()))
284 if(file.tag.title_is("JOBS"))
286 warn = file.tag.get_property("WARN", 1);
288 else if(file.tag.title_is("JOB"))
291 jobs.append(job = new BatchRenderJob(preferences));
298 void BatchRenderThread::save_jobs(char *path)
301 file.tag.set_title("JOBS");
302 file.tag.set_property("WARN", warn);
304 file.append_newline();
306 for(int i = 0; i < jobs.total; i++)
308 file.tag.set_title("JOB");
309 jobs.values[i]->save(&file);
311 file.tag.set_title("/JOBS");
313 file.append_newline();
315 if( !path ) path = batch_path;
316 if( !path[0] ) create_path(path);
317 file.write_to_file(path);
320 void BatchRenderThread::load_defaults(BC_Hash *defaults)
324 default_job->asset->load_defaults(defaults,
325 "BATCHRENDER_", 1, 1, 1, 1, 1);
326 default_job->fix_strategy();
329 for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
331 char string[BCTEXTLEN];
332 sprintf(string, "BATCHRENDER_COLUMN%d", i);
333 column_width[i] = defaults->get(string, list_widths[i]);
337 void BatchRenderThread::save_defaults(BC_Hash *defaults)
341 default_job->asset->save_defaults(defaults,
342 "BATCHRENDER_", 1, 1, 1, 1, 1);
343 defaults->update("BATCHRENDER_STRATEGY", default_job->strategy);
345 for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
347 char string[BCTEXTLEN];
348 sprintf(string, "BATCHRENDER_COLUMN%d", i);
349 defaults->update(string, column_width[i]);
351 // defaults->update("BATCHRENDER_JOB", current_job);
353 mwindow->save_defaults();
358 char* BatchRenderThread::create_path(char *string)
361 sprintf(string, "%s/", File::get_config_path());
362 fs.complete_path(string);
363 strcat(string, BATCH_PATH);
367 void BatchRenderThread::new_job()
369 BatchRenderJob *result = new BatchRenderJob(mwindow->preferences);
370 result->copy_from(get_current_job());
372 current_job = jobs.total - 1;
377 void BatchRenderThread::delete_job()
379 if(current_job < jobs.total && current_job >= 0)
381 jobs.remove_object_number(current_job);
382 if(current_job > 0) current_job--;
388 void BatchRenderThread::use_current_edl()
390 // printf("BatchRenderThread::use_current_edl %d %p %s\n",
392 // mwindow->edl->path,
393 // mwindow->edl->path);
395 strcpy(get_current_edl(), mwindow->edl->path);
397 gui->edl_path_text->update(get_current_edl());
400 void BatchRenderThread::update_selected_edl()
403 char *path = get_current_edl();
404 EDL *edl = mwindow->edl;
405 edl->save_xml(&xml_file, path, 0, 0);
406 xml_file.terminate_string();
407 if( xml_file.write_to_file(path) ) {
409 sprintf(msg, _("Unable to save: %s"), path);
410 MainError::show_error(msg);
414 BatchRenderJob* BatchRenderThread::get_current_job()
416 BatchRenderJob *result;
417 if(current_job >= jobs.total || current_job < 0)
419 result = default_job;
423 result = jobs.values[current_job];
429 Asset* BatchRenderThread::get_current_asset()
431 return get_current_job()->asset;
434 char* BatchRenderThread::get_current_edl()
436 return get_current_job()->edl_path;
440 // Test EDL files for existence
441 int BatchRenderThread::test_edl_files()
443 int not_equiv = 0, ret = 0;
444 const char *path = 0;
446 for( int i=0; !ret && i<jobs.size(); ++i ) {
447 if( !jobs.values[i]->enabled ) continue;
448 const char *path = jobs.values[i]->edl_path;
449 int is_script = *path == '@' ? 1 : 0;
450 if( is_script ) ++path;
451 FILE *fp = fopen(path, "r");
453 if( warn && mwindow && !is_script ) {
454 fseek(fp, 0, SEEK_END);
455 int64_t sz = ftell(fp);
456 fseek(fp, 0, SEEK_SET);
457 char *bfr = new char[sz+1];
458 int64_t len = fread(bfr, 1, sz+1, fp);
460 FileXML file; file.set_shared_input(bfr, len);
461 EDL *edl = new EDL; edl->create_objects();
462 edl->load_xml(&file, LOAD_ALL);
463 double pos = edl->equivalent_output(mwindow->edl);
464 if( pos >= 0 ) ++not_equiv;
478 char string[BCTEXTLEN];
479 sprintf(string, _("EDL %s not found.\n"), path);
481 ErrorBox error_box(_(PROGRAM_NAME ": Error"),
482 mwindow->gui->get_abs_cursor_x(1),
483 mwindow->gui->get_abs_cursor_y(1));
484 error_box.create_objects(string);
485 error_box.run_window();
486 gui->button_enable();
489 fprintf(stderr, "%s", string);
493 else if( warn && mwindow && not_equiv > 0 ) {
494 fprintf(stderr, _("%d job EDLs do not match session edl\n"), not_equiv);
495 char string[BCTEXTLEN], *sp = string;
496 sp += sprintf(sp, _("%d job EDLs do not match session edl\n"),not_equiv);
497 sp += sprintf(sp, _("press cancel to abandon batch render"));
498 mwindow->show_warning(&warn, string);
499 if( mwindow->wait_warning() ) {
500 gui->button_enable();
504 gui->warning->update(warn);
510 void BatchRenderThread::calculate_dest_paths(ArrayList<char*> *paths,
511 Preferences *preferences)
513 for(int i = 0; i < jobs.total; i++)
515 BatchRenderJob *job = jobs.values[i];
516 if(job->enabled && *job->edl_path != '@')
518 PackageDispatcher *packages = new PackageDispatcher;
521 TransportCommand *command = new TransportCommand;
522 FileXML *file = new FileXML;
523 file->read_from_file(job->edl_path);
525 // Use command to calculate range.
526 command->command = NORMAL_FWD;
527 command->get_edl()->load_xml(file,
529 command->change_type = CHANGE_ALL;
530 command->set_playback_range();
531 command->playback_range_adjust_inout();
533 // Create test packages
534 packages->create_packages(mwindow,
539 command->start_position,
540 command->end_position,
543 // Append output paths allocated to total
544 packages->get_package_paths(paths);
546 // Delete package harness
555 void BatchRenderThread::start_rendering(char *config_path,
558 BC_Hash *boot_defaults;
559 Preferences *preferences;
561 BC_Signals *signals = new BC_Signals;
562 // XXX the above stuff is leaked,
564 // Initialize stuff which MWindow does.
565 signals->initialize("/tmp/cinelerra_batch%d.dmp");
566 MWindow::init_defaults(boot_defaults, config_path);
567 load_defaults(boot_defaults);
568 preferences = new Preferences;
569 preferences->load_defaults(boot_defaults);
570 BC_Signals::set_trap_hook(trap_hook, this);
571 BC_Signals::set_catch_segv(preferences->trap_sigsegv);
572 BC_Signals::set_catch_intr(0);
573 if( preferences->trap_sigsegv ) {
574 BC_Trace::enable_locks();
577 BC_Trace::disable_locks();
580 MWindow::init_plugins(0, preferences);
581 char font_path[BCTEXTLEN];
582 strcpy(font_path, preferences->plugin_dir);
583 strcat(font_path, "/" FONT_SEARCHPATH);
584 BC_Resources::init_fontconfig(font_path);
585 BC_WindowBase::get_resources()->vframe_shm = 1;
588 strcpy(this->batch_path, batch_path);
589 load_jobs(batch_path, preferences);
590 save_jobs(batch_path);
591 save_defaults(boot_defaults);
594 // Test EDL files for existence
595 if(test_edl_files()) return;
599 // Predict all destination paths
600 ArrayList<char*> paths;
601 paths.set_array_delete();
602 calculate_dest_paths(&paths, preferences);
605 int result = ConfirmSave::test_files(0, &paths);
606 paths.remove_all_objects();
607 // Abort on any existing file because it's so hard to set this up.
611 render = new Render(0);
613 render->start_batches(&jobs,
619 void BatchRenderThread::start_rendering()
621 if(is_rendering) return;
624 save_jobs(batch_path);
625 save_defaults(mwindow->defaults);
626 gui->button_disable();
628 // Test EDL files for existence
629 if(test_edl_files()) return;
631 // Predict all destination paths
632 ArrayList<char*> paths;
633 calculate_dest_paths(&paths,
634 mwindow->preferences);
636 // Test destination files for overwrite
637 int result = ConfirmSave::test_files(mwindow, &paths);
638 paths.remove_all_objects();
644 gui->button_enable();
648 mwindow->render->start_batches(&jobs);
651 void BatchRenderThread::stop_rendering()
653 if(!is_rendering) return;
654 mwindow->render->stop_operation();
658 void BatchRenderThread::update_active(int number)
660 gui->lock_window("BatchRenderThread::update_active");
663 current_job = number;
664 rendering_job = number;
672 gui->unlock_window();
675 void BatchRenderThread::update_done(int number,
679 gui->lock_window("BatchRenderThread::update_done");
682 gui->button_enable();
686 jobs.values[number]->enabled = 0;
687 jobs.values[number]->elapsed = elapsed_time;
688 if(create_list) gui->create_list(1);
690 gui->unlock_window();
693 void BatchRenderThread::move_batch(int src, int dst)
695 BatchRenderJob *src_job = jobs.values[src];
696 if(dst < 0) dst = jobs.total - 1;
700 for(int i = src; i < jobs.total - 1; i++)
701 jobs.values[i] = jobs.values[i + 1];
702 // if(dst > src) dst--;
703 for(int i = jobs.total - 1; i > dst; i--)
704 jobs.values[i] = jobs.values[i - 1];
705 jobs.values[dst] = src_job;
710 void BatchRenderThread::trap_hook(FILE *fp, void *vp)
712 MWindow *mwindow = ((BatchRenderThread *)vp)->mwindow;
713 fprintf(fp, "\nEDL:\n");
714 mwindow->dump_edl(fp);
715 fprintf(fp, "\nUNDO:\n");
716 mwindow->dump_undo(fp);
717 fprintf(fp, "\nEXE:\n");
718 mwindow->dump_exe(fp);
725 BatchRenderGUI::BatchRenderGUI(MWindow *mwindow,
726 BatchRenderThread *thread, int x, int y, int w, int h)
727 : BC_Window(_(PROGRAM_NAME ": Batch Render"),
728 x, y, w, h, 730, 400, 1, 0, 1)
730 this->mwindow = mwindow;
731 this->thread = thread;
734 BatchRenderGUI::~BatchRenderGUI()
736 lock_window("BatchRenderGUI::~BatchRenderGUI");
742 void BatchRenderGUI::create_objects()
744 lock_window("BatchRenderGUI::create_objects");
745 mwindow->theme->get_batchrender_sizes(this, get_w(), get_h());
748 int x = mwindow->theme->batchrender_x1;
750 int x1 = x, x2 = get_w()/2 + 10; // mwindow->theme->batchrender_x2;
754 add_subwindow(output_path_title = new BC_Title(x1, y1, _("Output path:")));
755 y1 += output_path_title->get_h() + mwindow->theme->widget_border;
757 format_tools = new BatchFormat(mwindow, this, thread->get_current_asset());
758 format_tools->set_w(get_w() / 2);
759 format_tools->create_objects(x1, y1, 1, 1, 1, 1, 0, 1, 0, 0,
760 &thread->get_current_job()->strategy, 0);
763 add_subwindow(edl_path_title = new BC_Title(x2, y2, _("EDL Path:")));
764 y2 += edl_path_title->get_h() + mwindow->theme->widget_border;
767 add_subwindow(edl_path_text = new BatchRenderEDLPath( thread,
768 x, y, get_w()-x - 40, thread->get_current_edl()));
769 x = x2 + edl_path_text->get_w();
770 add_subwindow(edl_path_browse = new BrowseButton(
771 mwindow->theme, this, edl_path_text, x, y, thread->get_current_edl(),
772 _("Input EDL"), _("Select an EDL to load:"), 0));
773 y2 = y + edl_path_browse->get_h() + mwindow->theme->widget_border;
776 add_subwindow(update_selected_edl = new BatchRenderUpdateEDL(thread, x, y));
777 y += update_selected_edl->get_h() + mwindow->theme->widget_border;
778 add_subwindow(use_current_edl = new BatchRenderCurrentEDL(thread, x, y));
779 y += use_current_edl->get_h() + mwindow->theme->widget_border;
780 if( !mwindow->edl || !mwindow->edl->path[0] ) use_current_edl->disable();
781 add_subwindow(new_batch = new BatchRenderNew(thread, x, y));
782 x += new_batch->get_w() + mwindow->theme->widget_border;
783 add_subwindow(delete_batch = new BatchRenderDelete(thread, x, y));
784 x = x2; y += delete_batch->get_h() + mwindow->theme->widget_border;
785 y += mwindow->theme->widget_border;
786 add_subwindow(savelist_batch = new BatchRenderSaveList(thread, x, y));
787 x += savelist_batch->get_w() + mwindow->theme->widget_border;
788 add_subwindow(loadlist_batch = new BatchRenderLoadList(thread, x, y));
789 y += loadlist_batch->get_h() + mwindow->theme->widget_border;
790 add_subwindow(warning = new BatchRenderWarning(thread, x2, y));
791 y2 = y + warning->get_h() + mwindow->theme->widget_border;
792 if( y2 > y1 ) y1 = y2;
793 x = mwindow->theme->batchrender_x1, y = y1;
795 add_subwindow(list_title = new BC_Title(x, y, _("Batches to render:")));
796 x1 = x + list_title->get_w() + mwindow->theme->widget_border;;
797 add_subwindow(batch_path = new BC_Title(x1, y, thread->batch_path, MEDIUMFONT));
798 y += list_title->get_h() + mwindow->theme->widget_border;
800 y1 -= 15 + BC_GenericButton::calculate_h() + mwindow->theme->widget_border;
801 add_subwindow(batch_list = new BatchRenderList(thread, x, y,
802 get_w() - x - 10, y1 - y));
803 y += batch_list->get_h() + mwindow->theme->widget_border;
805 add_subwindow(start_button = new BatchRenderStart(thread, x, y));
806 x = get_w() / 2 - BC_GenericButton::calculate_w(this, _("Stop")) / 2;
807 add_subwindow(stop_button = new BatchRenderStop(thread, x, y));
808 x = get_w() - BC_GenericButton::calculate_w(this, _("Close")) - 10;
809 add_subwindow(cancel_button = new BatchRenderCancel(thread, x, y));
815 void BatchRenderGUI::button_disable()
817 new_batch->disable();
818 delete_batch->disable();
819 use_current_edl->disable();
820 update_selected_edl->disable();
823 void BatchRenderGUI::button_enable()
826 delete_batch->enable();
827 if( mwindow->edl && mwindow->edl->path[0] )
828 use_current_edl->enable();
829 update_selected_edl->enable();
832 int BatchRenderGUI::resize_event(int w, int h)
834 mwindow->session->batchrender_w = w;
835 mwindow->session->batchrender_h = h;
836 mwindow->theme->get_batchrender_sizes(this, w, h);
838 int x = mwindow->theme->batchrender_x1;
840 int x1 = x, x2 = get_w()/2 + 10; // mwindow->theme->batchrender_x2;
844 output_path_title->reposition_window(x1, y1);
845 y1 += output_path_title->get_h() + mwindow->theme->widget_border;
846 format_tools->reposition_window(x1, y1);
850 edl_path_title->reposition_window(x, y);
851 y += edl_path_title->get_h() + mwindow->theme->widget_border;
852 edl_path_text->reposition_window(x, y, w - x - 40);
853 x += edl_path_text->get_w();
854 edl_path_browse->reposition_window(x, y);
855 y2 = y + edl_path_browse->get_h() + mwindow->theme->widget_border;
858 update_selected_edl->reposition_window(x, y);
859 y += update_selected_edl->get_h() + mwindow->theme->widget_border;
860 use_current_edl->reposition_window(x, y);
861 y += use_current_edl->get_h() + mwindow->theme->widget_border;
862 new_batch->reposition_window(x, y);
863 x += new_batch->get_w() + mwindow->theme->widget_border;
864 delete_batch->reposition_window(x, y);
866 x = x2; y += delete_batch->get_h() + mwindow->theme->widget_border;
867 savelist_batch->reposition_window(x, y);
868 x += savelist_batch->get_w() + mwindow->theme->widget_border;
869 loadlist_batch->reposition_window(x, y);
870 y += loadlist_batch->get_h() + mwindow->theme->widget_border;
871 warning->reposition_window(x, y);
873 y1 = 15 + BC_GenericButton::calculate_h() + mwindow->theme->widget_border;
874 y2 = get_h() - y1 - batch_list->get_h();
875 y2 -= list_title->get_h() + mwindow->theme->widget_border;
877 x = mwindow->theme->batchrender_x1; y = y2;
878 list_title->reposition_window(x, y);
879 y += list_title->get_h() + mwindow->theme->widget_border;
880 batch_list->reposition_window(x, y, w - x - 10, h - y - y1);
881 y += batch_list->get_h() + mwindow->theme->widget_border;
883 start_button->reposition_window(x, y);
884 x = w / 2 - stop_button->get_w() / 2;
885 stop_button->reposition_window(x, y);
886 x = w - cancel_button->get_w() - 10;
887 cancel_button->reposition_window(x, y);
891 int BatchRenderGUI::translation_event()
893 mwindow->session->batchrender_x = get_x();
894 mwindow->session->batchrender_y = get_y();
898 int BatchRenderGUI::close_event()
900 // Stop batch rendering
902 thread->stop_rendering();
903 lock_window("BatchRenderGUI::close_event");
908 void BatchRenderGUI::create_list(int update_widget)
910 for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
912 list_columns[i].remove_all_objects();
915 for(int i = 0; i < thread->jobs.total; i++)
917 BatchRenderJob *job = thread->jobs.values[i];
918 char string[BCTEXTLEN];
919 BC_ListBoxItem *enabled = new BC_ListBoxItem(job->enabled ?
922 BC_ListBoxItem *item1 = new BC_ListBoxItem(job->asset->path);
923 BC_ListBoxItem *item2 = new BC_ListBoxItem(job->edl_path);
924 BC_ListBoxItem *item3;
926 item3 = new BC_ListBoxItem(
927 Units::totext(string,
931 item3 = new BC_ListBoxItem(_("Unknown"));
932 list_columns[0].append(enabled);
933 list_columns[1].append(item1);
934 list_columns[2].append(item2);
935 list_columns[3].append(item3);
936 if(i == thread->current_job)
938 enabled->set_selected(1);
939 item1->set_selected(1);
940 item2->set_selected(1);
941 item3->set_selected(1);
943 if(i == thread->rendering_job)
945 enabled->set_color(RED);
946 item1->set_color(RED);
947 item2->set_color(RED);
948 item3->set_color(RED);
954 batch_list->update(list_columns,
956 thread->column_width,
958 batch_list->get_xposition(),
959 batch_list->get_yposition(),
960 batch_list->get_highlighted_item(), // Flat index of item cursor is over
961 1, // set all autoplace flags to 1
966 void BatchRenderGUI::change_job()
968 BatchRenderJob *job = thread->get_current_job();
969 format_tools->update(job->asset, &job->strategy);
970 edl_path_text->update(job->edl_path);
980 BatchFormat::BatchFormat(MWindow *mwindow,
983 : FormatTools(mwindow, gui, asset)
986 this->mwindow = mwindow;
989 BatchFormat::~BatchFormat()
994 int BatchFormat::handle_event()
1010 BatchRenderEDLPath::BatchRenderEDLPath(BatchRenderThread *thread,
1021 this->thread = thread;
1025 int BatchRenderEDLPath::handle_event()
1027 calculate_suggestions();
1028 strcpy(thread->get_current_edl(), get_text());
1029 thread->gui->create_list(1);
1038 BatchRenderNew::BatchRenderNew(BatchRenderThread *thread,
1041 : BC_GenericButton(x, y, _("New"))
1043 this->thread = thread;
1046 int BatchRenderNew::handle_event()
1052 BatchRenderDelete::BatchRenderDelete(BatchRenderThread *thread,
1055 : BC_GenericButton(x, y, _("Delete"))
1057 this->thread = thread;
1060 int BatchRenderDelete::handle_event()
1062 thread->delete_job();
1068 BatchRenderSaveList::BatchRenderSaveList(BatchRenderThread *thread,
1071 : BC_GenericButton(x, y, _("Save Jobs"))
1073 this->thread = thread;
1074 set_tooltip(_("Save a Batch Render List"));
1076 startup_lock = new Mutex("BatchRenderSaveList::startup_lock");
1079 BatchRenderSaveList::~BatchRenderSaveList()
1081 startup_lock->lock("BatchRenderSaveList::~BrowseButton");
1086 gui->unlock_window();
1088 startup_lock->unlock();
1090 delete startup_lock;
1093 int BatchRenderSaveList::handle_event()
1095 if(Thread::running())
1100 gui->raise_window();
1101 gui->unlock_window();
1105 startup_lock->lock("BatchRenderSaveList::handle_event 1");
1107 startup_lock->lock("BatchRenderSaveList::handle_event 2");
1108 startup_lock->unlock();
1112 void BatchRenderSaveList::run()
1114 char default_path[BCTEXTLEN];
1115 sprintf(default_path, "~");
1116 thread->mwindow->defaults->get("DEFAULT_BATCHLOADPATH", default_path);
1117 BC_FileBox filewindow(100, 100, default_path, _("Save Batch Render List"),
1118 _("Enter a Batch Render filename to save as:"),
1122 startup_lock->unlock();
1123 filewindow.create_objects();
1125 int result2 = filewindow.run_window();
1127 strcpy(thread->batch_path, filewindow.get_submitted_path());
1128 thread->gui->batch_path->update(thread->batch_path);
1129 thread->mwindow->defaults->update("DEFAULT_BATCHLOADPATH", thread->batch_path);
1130 thread->save_jobs(thread->batch_path);
1133 this->thread->gui->flush();
1134 startup_lock->lock("BatchRenderLoadList::run");
1136 startup_lock->unlock();
1139 int BatchRenderSaveList::keypress_event() {
1140 if (get_keypress() == 's' ||
1141 get_keypress() == 'S') return handle_event();
1148 BatchRenderLoadList::BatchRenderLoadList(BatchRenderThread *thread,
1151 : BC_GenericButton(x, y, _("Load Jobs")),
1154 this->thread = thread;
1155 set_tooltip(_("Load a previously saved Batch Render List"));
1157 startup_lock = new Mutex("BatchRenderLoadList::startup_lock");
1160 BatchRenderLoadList::~BatchRenderLoadList()
1162 startup_lock->lock("BatchRenderLoadList::~BrowseButton");
1166 gui->unlock_window();
1168 startup_lock->unlock();
1170 delete startup_lock;
1173 int BatchRenderLoadList::handle_event()
1175 if(Thread::running()) {
1178 gui->raise_window();
1179 gui->unlock_window();
1183 startup_lock->lock("BatchRenderLoadList::handle_event 1");
1185 startup_lock->lock("BatchRenderLoadList::handle_event 2");
1186 startup_lock->unlock();
1190 void BatchRenderLoadList::run()
1192 char default_path[BCTEXTLEN];
1193 sprintf(default_path, "~");
1194 thread->mwindow->defaults->get("DEFAULT_BATCHLOADPATH", default_path);
1195 BC_FileBox filewindow(100, 100, default_path, _("Load Batch Render List"),
1196 _("Enter a Batch Render filename to load from:"),
1200 startup_lock->unlock();
1201 filewindow.create_objects();
1203 int result2 = filewindow.run_window();
1205 strcpy(thread->batch_path, filewindow.get_submitted_path());
1206 thread->gui->batch_path->update(thread->batch_path);
1207 thread->mwindow->defaults->update("DEFAULT_BATCHLOADPATH", thread->batch_path);
1208 thread->load_jobs(thread->batch_path, thread->mwindow->preferences);
1209 thread->gui->create_list(1);
1212 thread->gui->flush();
1213 startup_lock->lock("BatchRenderLoadList::run");
1215 startup_lock->unlock();
1218 int BatchRenderLoadList::keypress_event() {
1219 if (get_keypress() == 'o' ||
1220 get_keypress() == 'O') return handle_event();
1224 BatchRenderCurrentEDL::BatchRenderCurrentEDL(BatchRenderThread *thread,
1227 : BC_GenericButton(x, y, _("Use Current EDL"))
1229 this->thread = thread;
1232 int BatchRenderCurrentEDL::handle_event()
1234 thread->use_current_edl();
1238 BatchRenderUpdateEDL::BatchRenderUpdateEDL(BatchRenderThread *thread,
1241 : BC_GenericButton(x, y, _("Save to EDL Path"))
1243 this->thread = thread;
1246 int BatchRenderUpdateEDL::handle_event()
1248 thread->update_selected_edl();
1255 BatchRenderList::BatchRenderList(BatchRenderThread *thread,
1265 thread->gui->list_columns,
1267 thread->column_width,
1268 BATCHRENDER_COLUMNS,
1275 this->thread = thread;
1277 set_process_drag(0);
1280 int BatchRenderList::handle_event()
1285 int BatchRenderList::selection_changed()
1287 thread->current_job = get_selection_number(0, 0);
1288 thread->gui->change_job();
1289 if(get_cursor_x() < thread->column_width[0])
1291 BatchRenderJob *job = thread->get_current_job();
1292 job->enabled = !job->enabled;
1293 thread->gui->create_list(1);
1298 int BatchRenderList::column_resize_event()
1300 for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
1302 thread->column_width[i] = get_column_width(i);
1307 int BatchRenderList::drag_start_event()
1309 if(BC_ListBox::drag_start_event())
1318 int BatchRenderList::drag_motion_event()
1320 if(BC_ListBox::drag_motion_event())
1327 int BatchRenderList::drag_stop_event()
1331 int src = get_selection_number(0, 0);
1332 int dst = get_highlighted_item();
1335 thread->move_batch(src, dst);
1337 BC_ListBox::drag_stop_event();
1354 BatchRenderStart::BatchRenderStart(BatchRenderThread *thread,
1357 : BC_GenericButton(x,
1361 this->thread = thread;
1364 int BatchRenderStart::handle_event()
1366 thread->start_rendering();
1370 BatchRenderStop::BatchRenderStop(BatchRenderThread *thread,
1373 : BC_GenericButton(x,
1377 this->thread = thread;
1380 int BatchRenderStop::handle_event()
1383 thread->stop_rendering();
1384 lock_window("BatchRenderStop::handle_event");
1389 BatchRenderWarning::BatchRenderWarning(BatchRenderThread *thread, int x, int y)
1390 : BC_CheckBox(x, y, thread->warn, _("warn if jobs/session mismatched"))
1392 this->thread = thread;
1395 int BatchRenderWarning::handle_event()
1397 thread->warn = get_value();
1402 BatchRenderCancel::BatchRenderCancel(BatchRenderThread *thread,
1405 : BC_GenericButton(x,
1409 this->thread = thread;
1412 int BatchRenderCancel::handle_event()
1415 thread->stop_rendering();
1416 lock_window("BatchRenderCancel::handle_event");
1417 thread->gui->set_done(1);
1421 int BatchRenderCancel::keypress_event()
1423 if(get_keypress() == ESC)
1426 thread->stop_rendering();
1427 lock_window("BatchRenderCancel::keypress_event");
1428 thread->gui->set_done(1);