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 add_subwindow(savelist_batch = new BatchRenderSaveList(thread, x, y));
786 x += savelist_batch->get_w() + mwindow->theme->widget_border;
787 add_subwindow(loadlist_batch = new BatchRenderLoadList(thread, x, y));
788 y += loadlist_batch->get_h() + mwindow->theme->widget_border;
789 add_subwindow(warning = new BatchRenderWarning(thread, x2, y));
790 y2 = y + warning->get_h() + mwindow->theme->widget_border;
791 if( y2 > y1 ) y1 = y2;
792 x = mwindow->theme->batchrender_x1, y = y1;
794 add_subwindow(list_title = new BC_Title(x, y, _("Batches to render:")));
795 x1 = x + list_title->get_w() + mwindow->theme->widget_border;;
796 add_subwindow(batch_path = new BC_Title(x1, y, thread->batch_path, MEDIUMFONT));
797 y += list_title->get_h() + mwindow->theme->widget_border;
799 y1 -= 15 + BC_GenericButton::calculate_h() + mwindow->theme->widget_border;
800 add_subwindow(batch_list = new BatchRenderList(thread, x, y,
801 get_w() - x - 10, y1 - y));
802 y += batch_list->get_h() + mwindow->theme->widget_border;
804 add_subwindow(start_button = new BatchRenderStart(thread, x, y));
805 x = get_w() / 2 - BC_GenericButton::calculate_w(this, _("Stop")) / 2;
806 add_subwindow(stop_button = new BatchRenderStop(thread, x, y));
807 x = get_w() - BC_GenericButton::calculate_w(this, _("Close")) - 10;
808 add_subwindow(cancel_button = new BatchRenderCancel(thread, x, y));
814 void BatchRenderGUI::button_disable()
816 new_batch->disable();
817 delete_batch->disable();
818 use_current_edl->disable();
819 update_selected_edl->disable();
822 void BatchRenderGUI::button_enable()
825 delete_batch->enable();
826 if( mwindow->edl && mwindow->edl->path[0] )
827 use_current_edl->enable();
828 update_selected_edl->enable();
831 int BatchRenderGUI::resize_event(int w, int h)
833 mwindow->session->batchrender_w = w;
834 mwindow->session->batchrender_h = h;
835 mwindow->theme->get_batchrender_sizes(this, w, h);
837 int x = mwindow->theme->batchrender_x1;
839 int x1 = x, x2 = get_w()/2 + 10; // mwindow->theme->batchrender_x2;
843 output_path_title->reposition_window(x1, y1);
844 y1 += output_path_title->get_h() + mwindow->theme->widget_border;
845 format_tools->reposition_window(x1, y1);
849 edl_path_title->reposition_window(x, y);
850 y += edl_path_title->get_h() + mwindow->theme->widget_border;
851 edl_path_text->reposition_window(x, y, w - x - 40);
852 x += edl_path_text->get_w();
853 edl_path_browse->reposition_window(x, y);
854 y2 = y + edl_path_browse->get_h() + mwindow->theme->widget_border;
857 update_selected_edl->reposition_window(x, y);
858 y += update_selected_edl->get_h() + mwindow->theme->widget_border;
859 use_current_edl->reposition_window(x, y);
860 y += use_current_edl->get_h() + mwindow->theme->widget_border;
861 new_batch->reposition_window(x, y);
862 x += new_batch->get_w() + mwindow->theme->widget_border;
863 delete_batch->reposition_window(x, y);
865 x = x2; y += delete_batch->get_h() + mwindow->theme->widget_border;
866 savelist_batch->reposition_window(x, y);
867 x += savelist_batch->get_w() + mwindow->theme->widget_border;
868 loadlist_batch->reposition_window(x, y);
869 y += loadlist_batch->get_h() + mwindow->theme->widget_border;
870 warning->reposition_window(x2, y);
872 y1 = 15 + BC_GenericButton::calculate_h() + mwindow->theme->widget_border;
873 y2 = get_h() - y1 - batch_list->get_h();
874 y2 -= list_title->get_h() + mwindow->theme->widget_border;
876 x = mwindow->theme->batchrender_x1; y = y2;
877 list_title->reposition_window(x, y);
878 y += list_title->get_h() + mwindow->theme->widget_border;
879 batch_list->reposition_window(x, y, w - x - 10, h - y - y1);
880 y += batch_list->get_h() + mwindow->theme->widget_border;
882 start_button->reposition_window(x, y);
883 x = w / 2 - stop_button->get_w() / 2;
884 stop_button->reposition_window(x, y);
885 x = w - cancel_button->get_w() - 10;
886 cancel_button->reposition_window(x, y);
890 int BatchRenderGUI::translation_event()
892 mwindow->session->batchrender_x = get_x();
893 mwindow->session->batchrender_y = get_y();
897 int BatchRenderGUI::close_event()
899 // Stop batch rendering
901 thread->stop_rendering();
902 lock_window("BatchRenderGUI::close_event");
907 void BatchRenderGUI::create_list(int update_widget)
909 for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
911 list_columns[i].remove_all_objects();
914 for(int i = 0; i < thread->jobs.total; i++)
916 BatchRenderJob *job = thread->jobs.values[i];
917 char string[BCTEXTLEN];
918 BC_ListBoxItem *enabled = new BC_ListBoxItem(job->enabled ?
921 BC_ListBoxItem *item1 = new BC_ListBoxItem(job->asset->path);
922 BC_ListBoxItem *item2 = new BC_ListBoxItem(job->edl_path);
923 BC_ListBoxItem *item3;
925 item3 = new BC_ListBoxItem(
926 Units::totext(string,
930 item3 = new BC_ListBoxItem(_("Unknown"));
931 list_columns[0].append(enabled);
932 list_columns[1].append(item1);
933 list_columns[2].append(item2);
934 list_columns[3].append(item3);
935 if(i == thread->current_job)
937 enabled->set_selected(1);
938 item1->set_selected(1);
939 item2->set_selected(1);
940 item3->set_selected(1);
942 if(i == thread->rendering_job)
944 enabled->set_color(RED);
945 item1->set_color(RED);
946 item2->set_color(RED);
947 item3->set_color(RED);
953 batch_list->update(list_columns,
955 thread->column_width,
957 batch_list->get_xposition(),
958 batch_list->get_yposition(),
959 batch_list->get_highlighted_item(), // Flat index of item cursor is over
960 1, // set all autoplace flags to 1
965 void BatchRenderGUI::change_job()
967 BatchRenderJob *job = thread->get_current_job();
968 format_tools->update(job->asset, &job->strategy);
969 edl_path_text->update(job->edl_path);
979 BatchFormat::BatchFormat(MWindow *mwindow,
982 : FormatTools(mwindow, gui, asset)
985 this->mwindow = mwindow;
988 BatchFormat::~BatchFormat()
993 int BatchFormat::handle_event()
1009 BatchRenderEDLPath::BatchRenderEDLPath(BatchRenderThread *thread,
1020 this->thread = thread;
1024 int BatchRenderEDLPath::handle_event()
1026 calculate_suggestions();
1027 strcpy(thread->get_current_edl(), get_text());
1028 thread->gui->create_list(1);
1037 BatchRenderNew::BatchRenderNew(BatchRenderThread *thread,
1040 : BC_GenericButton(x, y, _("New"))
1042 this->thread = thread;
1045 int BatchRenderNew::handle_event()
1051 BatchRenderDelete::BatchRenderDelete(BatchRenderThread *thread,
1054 : BC_GenericButton(x, y, _("Delete"))
1056 this->thread = thread;
1059 int BatchRenderDelete::handle_event()
1061 thread->delete_job();
1067 BatchRenderSaveList::BatchRenderSaveList(BatchRenderThread *thread,
1070 : BC_GenericButton(x, y, _("Save Jobs"))
1072 this->thread = thread;
1073 set_tooltip(_("Save a Batch Render List"));
1075 startup_lock = new Mutex("BatchRenderSaveList::startup_lock");
1078 BatchRenderSaveList::~BatchRenderSaveList()
1080 startup_lock->lock("BatchRenderSaveList::~BrowseButton");
1085 gui->unlock_window();
1087 startup_lock->unlock();
1089 delete startup_lock;
1092 int BatchRenderSaveList::handle_event()
1094 if(Thread::running())
1099 gui->raise_window();
1100 gui->unlock_window();
1104 startup_lock->lock("BatchRenderSaveList::handle_event 1");
1106 startup_lock->lock("BatchRenderSaveList::handle_event 2");
1107 startup_lock->unlock();
1111 void BatchRenderSaveList::run()
1113 char default_path[BCTEXTLEN];
1114 sprintf(default_path, "~");
1115 thread->mwindow->defaults->get("DEFAULT_BATCHLOADPATH", default_path);
1116 BC_FileBox filewindow(100, 100, default_path, _("Save Batch Render List"),
1117 _("Enter a Batch Render filename to save as:"),
1121 startup_lock->unlock();
1122 filewindow.create_objects();
1124 int result2 = filewindow.run_window();
1126 strcpy(thread->batch_path, filewindow.get_submitted_path());
1127 thread->gui->batch_path->update(thread->batch_path);
1128 thread->mwindow->defaults->update("DEFAULT_BATCHLOADPATH", thread->batch_path);
1129 thread->save_jobs(thread->batch_path);
1132 this->thread->gui->flush();
1133 startup_lock->lock("BatchRenderLoadList::run");
1135 startup_lock->unlock();
1138 int BatchRenderSaveList::keypress_event() {
1139 if (get_keypress() == 's' ||
1140 get_keypress() == 'S') return handle_event();
1147 BatchRenderLoadList::BatchRenderLoadList(BatchRenderThread *thread,
1150 : BC_GenericButton(x, y, _("Load Jobs")),
1153 this->thread = thread;
1154 set_tooltip(_("Load a previously saved Batch Render List"));
1156 startup_lock = new Mutex("BatchRenderLoadList::startup_lock");
1159 BatchRenderLoadList::~BatchRenderLoadList()
1161 startup_lock->lock("BatchRenderLoadList::~BrowseButton");
1165 gui->unlock_window();
1167 startup_lock->unlock();
1169 delete startup_lock;
1172 int BatchRenderLoadList::handle_event()
1174 if(Thread::running()) {
1177 gui->raise_window();
1178 gui->unlock_window();
1182 startup_lock->lock("BatchRenderLoadList::handle_event 1");
1184 startup_lock->lock("BatchRenderLoadList::handle_event 2");
1185 startup_lock->unlock();
1189 void BatchRenderLoadList::run()
1191 char default_path[BCTEXTLEN];
1192 sprintf(default_path, "~");
1193 thread->mwindow->defaults->get("DEFAULT_BATCHLOADPATH", default_path);
1194 BC_FileBox filewindow(100, 100, default_path, _("Load Batch Render List"),
1195 _("Enter a Batch Render filename to load from:"),
1199 startup_lock->unlock();
1200 filewindow.create_objects();
1202 int result2 = filewindow.run_window();
1204 strcpy(thread->batch_path, filewindow.get_submitted_path());
1205 thread->gui->batch_path->update(thread->batch_path);
1206 thread->mwindow->defaults->update("DEFAULT_BATCHLOADPATH", thread->batch_path);
1207 thread->load_jobs(thread->batch_path, thread->mwindow->preferences);
1208 thread->gui->create_list(1);
1209 thread->current_job = 0;
1210 thread->gui->change_job();
1213 thread->gui->flush();
1214 startup_lock->lock("BatchRenderLoadList::run");
1216 startup_lock->unlock();
1219 int BatchRenderLoadList::keypress_event() {
1220 if (get_keypress() == 'o' ||
1221 get_keypress() == 'O') return handle_event();
1225 BatchRenderCurrentEDL::BatchRenderCurrentEDL(BatchRenderThread *thread,
1228 : BC_GenericButton(x, y, _("Use Current EDL"))
1230 this->thread = thread;
1233 int BatchRenderCurrentEDL::handle_event()
1235 thread->use_current_edl();
1239 BatchRenderUpdateEDL::BatchRenderUpdateEDL(BatchRenderThread *thread,
1242 : BC_GenericButton(x, y, _("Save to EDL Path"))
1244 this->thread = thread;
1247 int BatchRenderUpdateEDL::handle_event()
1249 thread->update_selected_edl();
1256 BatchRenderList::BatchRenderList(BatchRenderThread *thread,
1266 thread->gui->list_columns,
1268 thread->column_width,
1269 BATCHRENDER_COLUMNS,
1276 this->thread = thread;
1278 set_process_drag(0);
1281 int BatchRenderList::handle_event()
1286 int BatchRenderList::selection_changed()
1288 thread->current_job = get_selection_number(0, 0);
1289 thread->gui->change_job();
1290 if(get_cursor_x() < thread->column_width[0])
1292 BatchRenderJob *job = thread->get_current_job();
1293 job->enabled = !job->enabled;
1294 thread->gui->create_list(1);
1299 int BatchRenderList::column_resize_event()
1301 for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
1303 thread->column_width[i] = get_column_width(i);
1308 int BatchRenderList::drag_start_event()
1310 if(BC_ListBox::drag_start_event())
1319 int BatchRenderList::drag_motion_event()
1321 if(BC_ListBox::drag_motion_event())
1328 int BatchRenderList::drag_stop_event()
1332 int src = get_selection_number(0, 0);
1333 int dst = get_highlighted_item();
1336 thread->move_batch(src, dst);
1338 BC_ListBox::drag_stop_event();
1355 BatchRenderStart::BatchRenderStart(BatchRenderThread *thread,
1358 : BC_GenericButton(x,
1362 this->thread = thread;
1365 int BatchRenderStart::handle_event()
1367 thread->start_rendering();
1371 BatchRenderStop::BatchRenderStop(BatchRenderThread *thread,
1374 : BC_GenericButton(x,
1378 this->thread = thread;
1381 int BatchRenderStop::handle_event()
1384 thread->stop_rendering();
1385 lock_window("BatchRenderStop::handle_event");
1390 BatchRenderWarning::BatchRenderWarning(BatchRenderThread *thread, int x, int y)
1391 : BC_CheckBox(x, y, thread->warn, _("warn if jobs/session mismatched"))
1393 this->thread = thread;
1396 int BatchRenderWarning::handle_event()
1398 thread->warn = get_value();
1403 BatchRenderCancel::BatchRenderCancel(BatchRenderThread *thread,
1406 : BC_GenericButton(x,
1410 this->thread = thread;
1413 int BatchRenderCancel::handle_event()
1416 thread->stop_rendering();
1417 lock_window("BatchRenderCancel::handle_event");
1418 thread->gui->set_done(1);
1422 int BatchRenderCancel::keypress_event()
1424 if(get_keypress() == ESC)
1427 thread->stop_rendering();
1428 lock_window("BatchRenderCancel::keypress_event");
1429 thread->gui->set_done(1);