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,
153 void BatchRenderJob::save(FileXML *file)
155 file->tag.set_property("EDL_PATH", edl_path);
156 file->tag.set_property("STRATEGY", strategy);
157 file->tag.set_property("ENABLED", enabled);
158 file->tag.set_property("ELAPSED", elapsed);
160 file->append_newline();
165 // The compression parameters are stored in the defaults to reduce
166 // coding maintenance. The defaults must now be stuffed into the XML for
169 asset->save_defaults(&defaults,
177 defaults.save_string(string);
178 file->append_text(string);
180 file->tag.set_title("/JOB");
182 file->append_newline();
185 void BatchRenderJob::fix_strategy()
187 strategy = Render::fix_strategy(strategy, preferences->use_renderfarm);
199 BatchRenderThread::BatchRenderThread(MWindow *mwindow)
202 this->mwindow = mwindow;
214 BatchRenderThread::BatchRenderThread()
229 BatchRenderThread::~BatchRenderThread()
232 delete boot_defaults;
236 file_entries->remove_all_objects();
241 void BatchRenderThread::reset(int warn)
243 if( warn ) this->warn = 1;
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 char path[BCTEXTLEN];
260 save_defaults(mwindow->defaults);
264 BC_Window* BatchRenderThread::new_gui()
268 default_job = new BatchRenderJob(mwindow->preferences);
273 file_entries = new ArrayList<BC_ListBoxItem*>;
275 char string[BCTEXTLEN];
276 // Load current directory
277 fs.update(getcwd(string, BCTEXTLEN));
278 for(int i = 0; i < fs.total_files(); i++)
280 file_entries->append(
282 fs.get_entry(i)->get_name()));
286 char path[BCTEXTLEN];
288 load_jobs(path, mwindow->preferences);
289 load_defaults(mwindow->defaults);
290 this->gui = new BatchRenderGUI(mwindow,
292 mwindow->session->batchrender_x,
293 mwindow->session->batchrender_y,
294 mwindow->session->batchrender_w,
295 mwindow->session->batchrender_h);
296 this->gui->create_objects();
301 void BatchRenderThread::load_jobs(char *path, Preferences *preferences)
306 jobs.remove_all_objects();
308 file.read_from_file(path);
310 file.read_from_file(create_path(path));
314 if(!(result = file.read_tag()))
316 if(file.tag.title_is("JOBS"))
318 warn = file.tag.get_property("WARN", 1);
320 else if(file.tag.title_is("JOB"))
323 jobs.append(job = new BatchRenderJob(preferences));
330 void BatchRenderThread::save_jobs(char *path)
333 file.tag.set_title("JOBS");
334 file.tag.set_property("WARN", warn);
336 file.append_newline();
338 for(int i = 0; i < jobs.total; i++)
340 file.tag.set_title("JOB");
341 jobs.values[i]->save(&file);
343 file.tag.set_title("/JOBS");
345 file.append_newline();
348 file.write_to_file(path);
350 file.write_to_file(create_path(path));
353 void BatchRenderThread::load_defaults(BC_Hash *defaults)
357 default_job->asset->load_defaults(defaults,
358 "BATCHRENDER_", 1, 1, 1, 1, 1);
359 default_job->fix_strategy();
362 for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
364 char string[BCTEXTLEN];
365 sprintf(string, "BATCHRENDER_COLUMN%d", i);
366 column_width[i] = defaults->get(string, list_widths[i]);
370 void BatchRenderThread::save_defaults(BC_Hash *defaults)
374 default_job->asset->save_defaults(defaults,
375 "BATCHRENDER_", 1, 1, 1, 1, 1);
376 defaults->update("BATCHRENDER_STRATEGY", default_job->strategy);
378 for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
380 char string[BCTEXTLEN];
381 sprintf(string, "BATCHRENDER_COLUMN%d", i);
382 defaults->update(string, column_width[i]);
384 // defaults->update("BATCHRENDER_JOB", current_job);
386 mwindow->save_defaults();
391 char* BatchRenderThread::create_path(char *string)
394 sprintf(string, "%s/", File::get_config_path());
395 fs.complete_path(string);
396 strcat(string, BATCH_PATH);
400 void BatchRenderThread::new_job()
402 BatchRenderJob *result = new BatchRenderJob(mwindow->preferences);
403 result->copy_from(get_current_job());
405 current_job = jobs.total - 1;
410 void BatchRenderThread::delete_job()
412 if(current_job < jobs.total && current_job >= 0)
414 jobs.remove_object_number(current_job);
415 if(current_job > 0) current_job--;
421 void BatchRenderThread::use_current_edl()
423 // printf("BatchRenderThread::use_current_edl %d %p %s\n",
425 // mwindow->edl->path,
426 // mwindow->edl->path);
428 strcpy(get_current_edl(), mwindow->edl->path);
430 gui->edl_path_text->update(get_current_edl());
433 void BatchRenderThread::update_selected_edl()
436 char *path = get_current_edl();
437 EDL *edl = mwindow->edl;
438 edl->save_xml(&xml_file, path, 0, 0);
439 xml_file.terminate_string();
440 if( xml_file.write_to_file(path) ) {
442 sprintf(msg, _("Unable to save: %s"), path);
443 MainError::show_error(msg);
447 BatchRenderJob* BatchRenderThread::get_current_job()
449 BatchRenderJob *result;
450 if(current_job >= jobs.total || current_job < 0)
452 result = default_job;
456 result = jobs.values[current_job];
462 Asset* BatchRenderThread::get_current_asset()
464 return get_current_job()->asset;
467 char* BatchRenderThread::get_current_edl()
469 return get_current_job()->edl_path;
473 // Test EDL files for existence
474 int BatchRenderThread::test_edl_files()
476 int not_equiv = 0, ret = 0;
477 const char *path = 0;
479 for( int i=0; !ret && i<jobs.size(); ++i ) {
480 if( !jobs.values[i]->enabled ) continue;
481 const char *path = jobs.values[i]->edl_path;
482 int is_script = *path == '@' ? 1 : 0;
483 if( is_script ) ++path;
484 FILE *fp = fopen(path, "r");
486 if( warn && mwindow && !is_script ) {
487 fseek(fp, 0, SEEK_END);
488 int64_t sz = ftell(fp);
489 fseek(fp, 0, SEEK_SET);
490 char *bfr = new char[sz+1];
491 int64_t len = fread(bfr, 1, sz+1, fp);
493 FileXML file; file.set_shared_input(bfr, len);
494 EDL *edl = new EDL; edl->create_objects();
495 edl->load_xml(&file, LOAD_ALL);
496 double pos = edl->equivalent_output(mwindow->edl);
497 if( pos >= 0 ) ++not_equiv;
511 char string[BCTEXTLEN];
512 sprintf(string, _("EDL %s not found.\n"), path);
514 ErrorBox error_box(_(PROGRAM_NAME ": Error"),
515 mwindow->gui->get_abs_cursor_x(1),
516 mwindow->gui->get_abs_cursor_y(1));
517 error_box.create_objects(string);
518 error_box.run_window();
519 gui->button_enable();
522 fprintf(stderr, "%s", string);
526 else if( warn && mwindow && not_equiv > 0 ) {
527 fprintf(stderr, _("%d job EDLs do not match session edl\n"), not_equiv);
528 char string[BCTEXTLEN], *sp = string;
529 sp += sprintf(sp, _("%d job EDLs do not match session edl\n"),not_equiv);
530 sp += sprintf(sp, _("press cancel to abandon batch render"));
531 mwindow->show_warning(&warn, string);
532 if( mwindow->wait_warning() ) {
533 gui->button_enable();
537 gui->warning->update(warn);
543 void BatchRenderThread::calculate_dest_paths(ArrayList<char*> *paths,
544 Preferences *preferences)
546 for(int i = 0; i < jobs.total; i++)
548 BatchRenderJob *job = jobs.values[i];
549 if(job->enabled && *job->edl_path != '@')
551 PackageDispatcher *packages = new PackageDispatcher;
554 TransportCommand *command = new TransportCommand;
555 FileXML *file = new FileXML;
556 file->read_from_file(job->edl_path);
558 // Use command to calculate range.
559 command->command = NORMAL_FWD;
560 command->get_edl()->load_xml(file,
562 command->change_type = CHANGE_ALL;
563 command->set_playback_range();
564 command->playback_range_adjust_inout();
566 // Create test packages
567 packages->create_packages(mwindow,
572 command->start_position,
573 command->end_position,
576 // Append output paths allocated to total
577 packages->get_package_paths(paths);
579 // Delete package harness
588 void BatchRenderThread::start_rendering(char *config_path,
591 BC_Hash *boot_defaults;
592 Preferences *preferences;
594 BC_Signals *signals = new BC_Signals;
595 // XXX the above stuff is leaked,
597 // Initialize stuff which MWindow does.
598 signals->initialize("/tmp/cinelerra_batch%d.dmp");
599 MWindow::init_defaults(boot_defaults, config_path);
600 load_defaults(boot_defaults);
601 preferences = new Preferences;
602 preferences->load_defaults(boot_defaults);
603 BC_Signals::set_trap_hook(trap_hook, this);
604 BC_Signals::set_catch_segv(preferences->trap_sigsegv);
605 BC_Signals::set_catch_intr(0);
606 if( preferences->trap_sigsegv ) {
607 BC_Trace::enable_locks();
610 BC_Trace::disable_locks();
613 MWindow::init_plugins(0, preferences);
614 char font_path[BCTEXTLEN];
615 strcpy(font_path, preferences->plugin_dir);
616 strcat(font_path, "/" FONT_SEARCHPATH);
617 BC_Resources::init_fontconfig(font_path);
618 BC_WindowBase::get_resources()->vframe_shm = 1;
621 load_jobs(batch_path, preferences);
622 save_jobs(batch_path);
623 save_defaults(boot_defaults);
626 // Test EDL files for existence
627 if(test_edl_files()) return;
631 // Predict all destination paths
632 ArrayList<char*> paths;
633 paths.set_array_delete();
634 calculate_dest_paths(&paths, preferences);
637 int result = ConfirmSave::test_files(0, &paths);
638 paths.remove_all_objects();
639 // Abort on any existing file because it's so hard to set this up.
643 render = new Render(0);
645 render->start_batches(&jobs,
651 void BatchRenderThread::start_rendering()
653 if(is_rendering) return;
656 char path[BCTEXTLEN];
659 save_defaults(mwindow->defaults);
660 gui->button_disable();
662 // Test EDL files for existence
663 if(test_edl_files()) return;
665 // Predict all destination paths
666 ArrayList<char*> paths;
667 calculate_dest_paths(&paths,
668 mwindow->preferences);
670 // Test destination files for overwrite
671 int result = ConfirmSave::test_files(mwindow, &paths);
672 paths.remove_all_objects();
678 gui->button_enable();
682 mwindow->render->start_batches(&jobs);
685 void BatchRenderThread::stop_rendering()
687 if(!is_rendering) return;
688 mwindow->render->stop_operation();
692 void BatchRenderThread::update_active(int number)
694 gui->lock_window("BatchRenderThread::update_active");
697 current_job = number;
698 rendering_job = number;
706 gui->unlock_window();
709 void BatchRenderThread::update_done(int number,
713 gui->lock_window("BatchRenderThread::update_done");
716 gui->button_enable();
720 jobs.values[number]->enabled = 0;
721 jobs.values[number]->elapsed = elapsed_time;
722 if(create_list) gui->create_list(1);
724 gui->unlock_window();
727 void BatchRenderThread::move_batch(int src, int dst)
729 BatchRenderJob *src_job = jobs.values[src];
730 if(dst < 0) dst = jobs.total - 1;
734 for(int i = src; i < jobs.total - 1; i++)
735 jobs.values[i] = jobs.values[i + 1];
736 // if(dst > src) dst--;
737 for(int i = jobs.total - 1; i > dst; i--)
738 jobs.values[i] = jobs.values[i - 1];
739 jobs.values[dst] = src_job;
744 void BatchRenderThread::trap_hook(FILE *fp, void *vp)
746 MWindow *mwindow = ((BatchRenderThread *)vp)->mwindow;
747 fprintf(fp, "\nEDL:\n");
748 mwindow->dump_edl(fp);
749 fprintf(fp, "\nUNDO:\n");
750 mwindow->dump_undo(fp);
751 fprintf(fp, "\nEXE:\n");
752 mwindow->dump_exe(fp);
759 BatchRenderGUI::BatchRenderGUI(MWindow *mwindow,
760 BatchRenderThread *thread, int x, int y, int w, int h)
761 : BC_Window(_(PROGRAM_NAME ": Batch Render"),
762 x, y, w, h, 50, 50, 1, 0, 1)
764 this->mwindow = mwindow;
765 this->thread = thread;
768 BatchRenderGUI::~BatchRenderGUI()
770 lock_window("BatchRenderGUI::~BatchRenderGUI");
776 void BatchRenderGUI::create_objects()
778 lock_window("BatchRenderGUI::create_objects");
779 mwindow->theme->get_batchrender_sizes(this, get_w(), get_h());
782 int x = mwindow->theme->batchrender_x1;
784 int x1 = x, x2 = get_w()/2 + 10; // mwindow->theme->batchrender_x2;
788 add_subwindow(output_path_title = new BC_Title(x1, y1, _("Output path:")));
789 y1 += output_path_title->get_h() + mwindow->theme->widget_border;
791 format_tools = new BatchFormat(mwindow, this, thread->get_current_asset());
792 format_tools->set_w(get_w() / 2);
793 format_tools->create_objects(x1, y1, 1, 1, 1, 1, 0, 1, 0, 0,
794 &thread->get_current_job()->strategy, 0);
797 add_subwindow(edl_path_title = new BC_Title(x2, y2, _("EDL Path:")));
798 y2 += edl_path_title->get_h() + mwindow->theme->widget_border;
801 add_subwindow(edl_path_text = new BatchRenderEDLPath( thread,
802 x, y, get_w()-x - 40, thread->get_current_edl()));
803 x = x2 + edl_path_text->get_w();
804 add_subwindow(edl_path_browse = new BrowseButton(
805 mwindow->theme, this, edl_path_text, x, y, thread->get_current_edl(),
806 _("Input EDL"), _("Select an EDL to load:"), 0));
807 y2 = y + edl_path_browse->get_h() + mwindow->theme->widget_border;
810 add_subwindow(update_selected_edl = new BatchRenderUpdateEDL(thread, x, y));
811 y += update_selected_edl->get_h() + mwindow->theme->widget_border;
812 add_subwindow(use_current_edl = new BatchRenderCurrentEDL(thread, x, y));
813 y += use_current_edl->get_h() + mwindow->theme->widget_border;
814 if( !mwindow->edl || !mwindow->edl->path[0] ) use_current_edl->disable();
815 add_subwindow(new_batch = new BatchRenderNew(thread, x, y));
816 x += new_batch->get_w() + mwindow->theme->widget_border;
817 add_subwindow(delete_batch = new BatchRenderDelete(thread, x, y));
818 x = x2; y += delete_batch->get_h() + mwindow->theme->widget_border;
819 add_subwindow(savelist_batch = new BatchRenderSaveList(thread, x, y));
820 x += savelist_batch->get_w() + mwindow->theme->widget_border;
821 add_subwindow(loadlist_batch = new BatchRenderLoadList(thread, x, y));
822 y += loadlist_batch->get_h() + mwindow->theme->widget_border;
823 add_subwindow(warning = new BatchRenderWarning(thread, x2, y));
824 y2 = y + warning->get_h() + mwindow->theme->widget_border;
825 if( y2 > y1 ) y1 = y2;
826 x = mwindow->theme->batchrender_x1, y = y1;
828 add_subwindow(list_title = new BC_Title(x, y, _("Batches to render:")));
829 y += list_title->get_h() + mwindow->theme->widget_border;
831 y1 -= 15 + BC_GenericButton::calculate_h() + mwindow->theme->widget_border;
832 add_subwindow(batch_list = new BatchRenderList(thread, x, y,
833 get_w() - x - 10, y1 - y));
834 y += batch_list->get_h() + mwindow->theme->widget_border;
836 add_subwindow(start_button = new BatchRenderStart(thread, x, y));
837 x = get_w() / 2 - BC_GenericButton::calculate_w(this, _("Stop")) / 2;
838 add_subwindow(stop_button = new BatchRenderStop(thread, x, y));
839 x = get_w() - BC_GenericButton::calculate_w(this, _("Close")) - 10;
840 add_subwindow(cancel_button = new BatchRenderCancel(thread, x, y));
846 void BatchRenderGUI::button_disable()
848 new_batch->disable();
849 delete_batch->disable();
850 use_current_edl->disable();
851 update_selected_edl->disable();
854 void BatchRenderGUI::button_enable()
857 delete_batch->enable();
858 if( mwindow->edl && mwindow->edl->path[0] )
859 use_current_edl->enable();
860 update_selected_edl->enable();
863 int BatchRenderGUI::resize_event(int w, int h)
865 mwindow->session->batchrender_w = w;
866 mwindow->session->batchrender_h = h;
867 mwindow->theme->get_batchrender_sizes(this, w, h);
869 int x = mwindow->theme->batchrender_x1;
871 int x1 = x, x2 = get_w()/2 + 10; // mwindow->theme->batchrender_x2;
875 output_path_title->reposition_window(x1, y1);
876 y1 += output_path_title->get_h() + mwindow->theme->widget_border;
877 format_tools->reposition_window(x1, y1);
881 edl_path_title->reposition_window(x, y);
882 y += edl_path_title->get_h() + mwindow->theme->widget_border;
883 edl_path_text->reposition_window(x, y, w - x - 40);
884 x += edl_path_text->get_w();
885 edl_path_browse->reposition_window(x, y);
886 y2 = y + edl_path_browse->get_h() + mwindow->theme->widget_border;
889 update_selected_edl->reposition_window(x, y);
890 y += update_selected_edl->get_h() + mwindow->theme->widget_border;
891 use_current_edl->reposition_window(x, y);
892 y += use_current_edl->get_h() + mwindow->theme->widget_border;
893 new_batch->reposition_window(x, y);
894 x += new_batch->get_w() + mwindow->theme->widget_border;
895 delete_batch->reposition_window(x, y);
897 x = x2; y += delete_batch->get_h() + mwindow->theme->widget_border;
898 savelist_batch->reposition_window(x, y);
899 x += savelist_batch->get_w() + mwindow->theme->widget_border;
900 loadlist_batch->reposition_window(x, y);
901 y += loadlist_batch->get_h() + mwindow->theme->widget_border;
903 y1 = 15 + BC_GenericButton::calculate_h() + mwindow->theme->widget_border;
904 y2 = get_h() - y1 - batch_list->get_h();
905 y2 -= list_title->get_h() + mwindow->theme->widget_border;
907 x = mwindow->theme->batchrender_x1; y = y2;
908 list_title->reposition_window(x, y);
909 y += list_title->get_h() + mwindow->theme->widget_border;
910 batch_list->reposition_window(x, y, w - x - 10, h - y - y1);
911 y += batch_list->get_h() + mwindow->theme->widget_border;
913 start_button->reposition_window(x, y);
914 x = w / 2 - stop_button->get_w() / 2;
915 stop_button->reposition_window(x, y);
916 x = w - cancel_button->get_w() - 10;
917 cancel_button->reposition_window(x, y);
921 int BatchRenderGUI::translation_event()
923 mwindow->session->batchrender_x = get_x();
924 mwindow->session->batchrender_y = get_y();
928 int BatchRenderGUI::close_event()
930 // Stop batch rendering
932 thread->stop_rendering();
933 lock_window("BatchRenderGUI::close_event");
938 void BatchRenderGUI::create_list(int update_widget)
940 for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
942 list_columns[i].remove_all_objects();
945 for(int i = 0; i < thread->jobs.total; i++)
947 BatchRenderJob *job = thread->jobs.values[i];
948 char string[BCTEXTLEN];
949 BC_ListBoxItem *enabled = new BC_ListBoxItem(job->enabled ?
952 BC_ListBoxItem *item1 = new BC_ListBoxItem(job->asset->path);
953 BC_ListBoxItem *item2 = new BC_ListBoxItem(job->edl_path);
954 BC_ListBoxItem *item3;
956 item3 = new BC_ListBoxItem(
957 Units::totext(string,
961 item3 = new BC_ListBoxItem(_("Unknown"));
962 list_columns[0].append(enabled);
963 list_columns[1].append(item1);
964 list_columns[2].append(item2);
965 list_columns[3].append(item3);
966 if(i == thread->current_job)
968 enabled->set_selected(1);
969 item1->set_selected(1);
970 item2->set_selected(1);
971 item3->set_selected(1);
973 if(i == thread->rendering_job)
975 enabled->set_color(RED);
976 item1->set_color(RED);
977 item2->set_color(RED);
978 item3->set_color(RED);
984 batch_list->update(list_columns,
986 thread->column_width,
988 batch_list->get_xposition(),
989 batch_list->get_yposition(),
990 batch_list->get_highlighted_item(), // Flat index of item cursor is over
991 1, // set all autoplace flags to 1
996 void BatchRenderGUI::change_job()
998 BatchRenderJob *job = thread->get_current_job();
999 format_tools->update(job->asset, &job->strategy);
1000 edl_path_text->update(job->edl_path);
1010 BatchFormat::BatchFormat(MWindow *mwindow,
1011 BatchRenderGUI *gui,
1013 : FormatTools(mwindow, gui, asset)
1016 this->mwindow = mwindow;
1019 BatchFormat::~BatchFormat()
1024 int BatchFormat::handle_event()
1026 gui->create_list(1);
1040 BatchRenderEDLPath::BatchRenderEDLPath(BatchRenderThread *thread,
1051 this->thread = thread;
1055 int BatchRenderEDLPath::handle_event()
1058 calculate_suggestions(thread->file_entries);
1060 strcpy(thread->get_current_edl(), get_text());
1061 thread->gui->create_list(1);
1070 BatchRenderNew::BatchRenderNew(BatchRenderThread *thread,
1073 : BC_GenericButton(x, y, _("New"))
1075 this->thread = thread;
1078 int BatchRenderNew::handle_event()
1084 BatchRenderDelete::BatchRenderDelete(BatchRenderThread *thread,
1087 : BC_GenericButton(x, y, _("Delete"))
1089 this->thread = thread;
1092 int BatchRenderDelete::handle_event()
1094 thread->delete_job();
1100 BatchRenderSaveList::BatchRenderSaveList(BatchRenderThread *thread,
1103 : BC_GenericButton(x, y, _("Save List"))
1105 this->thread = thread;
1106 set_tooltip(_("Save a Batch Render List"));
1108 startup_lock = new Mutex("BatchRenderSaveList::startup_lock");
1111 BatchRenderSaveList::~BatchRenderSaveList()
1113 startup_lock->lock("BatchRenderSaveList::~BrowseButton");
1118 gui->unlock_window();
1120 startup_lock->unlock();
1122 delete startup_lock;
1125 int BatchRenderSaveList::handle_event()
1127 if(Thread::running())
1132 gui->raise_window();
1133 gui->unlock_window();
1137 startup_lock->lock("BatchRenderSaveList::handle_event 1");
1139 startup_lock->lock("BatchRenderSaveList::handle_event 2");
1140 startup_lock->unlock();
1144 void BatchRenderSaveList::run()
1146 char default_path[BCTEXTLEN];
1147 sprintf(default_path, "~");
1148 BC_FileBox filewindow(100, 100,
1149 this->thread->mwindow->defaults->get("DEFAULT_BATCHLOADPATH", default_path),
1150 _("Save Batch Render List"), _("Enter a Batch Render filename to save as:"),
1154 startup_lock->unlock();
1155 filewindow.create_objects();
1157 int result2 = filewindow.run_window();
1161 this->thread->save_jobs(filewindow.get_submitted_path());
1162 this->thread->mwindow->defaults->update("DEFAULT_BATCHLOADPATH", filewindow.get_submitted_path());
1165 this->thread->gui->flush();
1166 startup_lock->lock("BatchRenderLoadList::run");
1168 startup_lock->unlock();
1171 int BatchRenderSaveList::keypress_event() {
1172 if (get_keypress() == 's' ||
1173 get_keypress() == 'S') return handle_event();
1180 BatchRenderLoadList::BatchRenderLoadList(BatchRenderThread *thread,
1183 : BC_GenericButton(x, y, _("Load List")),
1186 this->thread = thread;
1187 set_tooltip(_("Load a previously saved Batch Render List"));
1189 startup_lock = new Mutex("BatchRenderLoadList::startup_lock");
1192 BatchRenderLoadList::~BatchRenderLoadList()
1194 startup_lock->lock("BatchRenderLoadList::~BrowseButton");
1199 gui->unlock_window();
1201 startup_lock->unlock();
1203 delete startup_lock;
1206 int BatchRenderLoadList::handle_event()
1208 if(Thread::running())
1213 gui->raise_window();
1214 gui->unlock_window();
1218 startup_lock->lock("BatchRenderLoadList::handle_event 1");
1220 startup_lock->lock("BatchRenderLoadList::handle_event 2");
1221 startup_lock->unlock();
1225 void BatchRenderLoadList::run()
1227 char default_path[BCTEXTLEN];
1228 sprintf(default_path, "~");
1229 BC_FileBox filewindow(100,
1231 this->thread->mwindow->defaults->get("DEFAULT_BATCHLOADPATH", default_path),
1232 _("Load Batch Render List"),
1233 _("Enter a Batch Render filename to load from:"),
1241 startup_lock->unlock();
1242 filewindow.create_objects();
1244 int result2 = filewindow.run_window();
1248 this->thread->load_jobs(filewindow.get_submitted_path(),this->thread->mwindow->preferences);
1249 this->thread->gui->create_list(1);
1250 this->thread->mwindow->defaults->update("DEFAULT_BATCHLOADPATH", filewindow.get_submitted_path());
1253 this->thread->gui->flush();
1254 startup_lock->lock("BatchRenderLoadList::run");
1256 startup_lock->unlock();
1259 int BatchRenderLoadList::keypress_event() {
1260 if (get_keypress() == 'o' ||
1261 get_keypress() == 'O') return handle_event();
1265 BatchRenderCurrentEDL::BatchRenderCurrentEDL(BatchRenderThread *thread,
1268 : BC_GenericButton(x, y, _("Use Current EDL"))
1270 this->thread = thread;
1273 int BatchRenderCurrentEDL::handle_event()
1275 thread->use_current_edl();
1279 BatchRenderUpdateEDL::BatchRenderUpdateEDL(BatchRenderThread *thread,
1282 : BC_GenericButton(x, y, _("Save to EDL Path"))
1284 this->thread = thread;
1287 int BatchRenderUpdateEDL::handle_event()
1289 thread->update_selected_edl();
1296 BatchRenderList::BatchRenderList(BatchRenderThread *thread,
1306 thread->gui->list_columns,
1308 thread->column_width,
1309 BATCHRENDER_COLUMNS,
1316 this->thread = thread;
1318 set_process_drag(0);
1321 int BatchRenderList::handle_event()
1326 int BatchRenderList::selection_changed()
1328 thread->current_job = get_selection_number(0, 0);
1329 thread->gui->change_job();
1330 if(get_cursor_x() < thread->column_width[0])
1332 BatchRenderJob *job = thread->get_current_job();
1333 job->enabled = !job->enabled;
1334 thread->gui->create_list(1);
1339 int BatchRenderList::column_resize_event()
1341 for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
1343 thread->column_width[i] = get_column_width(i);
1348 int BatchRenderList::drag_start_event()
1350 if(BC_ListBox::drag_start_event())
1359 int BatchRenderList::drag_motion_event()
1361 if(BC_ListBox::drag_motion_event())
1368 int BatchRenderList::drag_stop_event()
1372 int src = get_selection_number(0, 0);
1373 int dst = get_highlighted_item();
1376 thread->move_batch(src, dst);
1378 BC_ListBox::drag_stop_event();
1395 BatchRenderStart::BatchRenderStart(BatchRenderThread *thread,
1398 : BC_GenericButton(x,
1402 this->thread = thread;
1405 int BatchRenderStart::handle_event()
1407 thread->start_rendering();
1411 BatchRenderStop::BatchRenderStop(BatchRenderThread *thread,
1414 : BC_GenericButton(x,
1418 this->thread = thread;
1421 int BatchRenderStop::handle_event()
1424 thread->stop_rendering();
1425 lock_window("BatchRenderStop::handle_event");
1430 BatchRenderWarning::BatchRenderWarning(BatchRenderThread *thread, int x, int y)
1431 : BC_CheckBox(x, y, thread->warn, _("warn if jobs/session mismatched"))
1433 this->thread = thread;
1436 int BatchRenderWarning::handle_event()
1438 thread->warn = get_value();
1443 BatchRenderCancel::BatchRenderCancel(BatchRenderThread *thread,
1446 : BC_GenericButton(x,
1450 this->thread = thread;
1453 int BatchRenderCancel::handle_event()
1456 thread->stop_rendering();
1457 lock_window("BatchRenderCancel::handle_event");
1458 thread->gui->set_done(1);
1462 int BatchRenderCancel::keypress_event()
1464 if(get_keypress() == ESC)
1467 thread->stop_rendering();
1468 lock_window("BatchRenderCancel::keypress_event");
1469 thread->gui->set_done(1);