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);
345 file.write_to_file(path);
347 file.write_to_file(create_path(path));
350 void BatchRenderThread::load_defaults(BC_Hash *defaults)
354 default_job->asset->load_defaults(defaults,
355 "BATCHRENDER_", 1, 1, 1, 1, 1);
356 default_job->fix_strategy();
359 for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
361 char string[BCTEXTLEN];
362 sprintf(string, "BATCHRENDER_COLUMN%d", i);
363 column_width[i] = defaults->get(string, list_widths[i]);
367 void BatchRenderThread::save_defaults(BC_Hash *defaults)
371 default_job->asset->save_defaults(defaults,
372 "BATCHRENDER_", 1, 1, 1, 1, 1);
373 defaults->update("BATCHRENDER_STRATEGY", default_job->strategy);
375 for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
377 char string[BCTEXTLEN];
378 sprintf(string, "BATCHRENDER_COLUMN%d", i);
379 defaults->update(string, column_width[i]);
381 // defaults->update("BATCHRENDER_JOB", current_job);
383 mwindow->save_defaults();
388 char* BatchRenderThread::create_path(char *string)
391 sprintf(string, "%s/", File::get_config_path());
392 fs.complete_path(string);
393 strcat(string, BATCH_PATH);
397 void BatchRenderThread::new_job()
399 BatchRenderJob *result = new BatchRenderJob(mwindow->preferences);
400 result->copy_from(get_current_job());
402 current_job = jobs.total - 1;
407 void BatchRenderThread::delete_job()
409 if(current_job < jobs.total && current_job >= 0)
411 jobs.remove_object_number(current_job);
412 if(current_job > 0) current_job--;
418 void BatchRenderThread::use_current_edl()
420 // printf("BatchRenderThread::use_current_edl %d %p %s\n",
422 // mwindow->edl->path,
423 // mwindow->edl->path);
425 strcpy(get_current_edl(), mwindow->edl->path);
427 gui->edl_path_text->update(get_current_edl());
430 void BatchRenderThread::update_selected_edl()
433 char *path = get_current_edl();
434 EDL *edl = mwindow->edl;
435 edl->save_xml(&xml_file, path, 0, 0);
436 xml_file.terminate_string();
437 if( xml_file.write_to_file(path) ) {
439 sprintf(msg, _("Unable to save: %s"), path);
440 MainError::show_error(msg);
444 BatchRenderJob* BatchRenderThread::get_current_job()
446 BatchRenderJob *result;
447 if(current_job >= jobs.total || current_job < 0)
449 result = default_job;
453 result = jobs.values[current_job];
459 Asset* BatchRenderThread::get_current_asset()
461 return get_current_job()->asset;
464 char* BatchRenderThread::get_current_edl()
466 return get_current_job()->edl_path;
470 // Test EDL files for existence
471 int BatchRenderThread::test_edl_files()
473 int not_equiv = 0, ret = 0;
474 const char *path = 0;
476 for( int i=0; !ret && i<jobs.size(); ++i ) {
477 if( !jobs.values[i]->enabled ) continue;
478 const char *path = jobs.values[i]->edl_path;
479 int is_script = *path == '@' ? 1 : 0;
480 if( is_script ) ++path;
481 FILE *fp = fopen(path, "r");
483 if( warn && mwindow && !is_script ) {
484 fseek(fp, 0, SEEK_END);
485 int64_t sz = ftell(fp);
486 fseek(fp, 0, SEEK_SET);
487 char *bfr = new char[sz+1];
488 int64_t len = fread(bfr, 1, sz+1, fp);
490 FileXML file; file.set_shared_input(bfr, len);
491 EDL *edl = new EDL; edl->create_objects();
492 edl->load_xml(&file, LOAD_ALL);
493 double pos = edl->equivalent_output(mwindow->edl);
494 if( pos >= 0 ) ++not_equiv;
508 char string[BCTEXTLEN];
509 sprintf(string, _("EDL %s not found.\n"), path);
511 ErrorBox error_box(_(PROGRAM_NAME ": Error"),
512 mwindow->gui->get_abs_cursor_x(1),
513 mwindow->gui->get_abs_cursor_y(1));
514 error_box.create_objects(string);
515 error_box.run_window();
516 gui->button_enable();
519 fprintf(stderr, "%s", string);
523 else if( warn && mwindow && not_equiv > 0 ) {
524 fprintf(stderr, _("%d job EDLs do not match session edl\n"), not_equiv);
525 char string[BCTEXTLEN], *sp = string;
526 sp += sprintf(sp, _("%d job EDLs do not match session edl\n"),not_equiv);
527 sp += sprintf(sp, _("press cancel to abandon batch render"));
528 mwindow->show_warning(&warn, string);
529 if( mwindow->wait_warning() ) {
530 gui->button_enable();
534 gui->warning->update(warn);
540 void BatchRenderThread::calculate_dest_paths(ArrayList<char*> *paths,
541 Preferences *preferences)
543 for(int i = 0; i < jobs.total; i++)
545 BatchRenderJob *job = jobs.values[i];
546 if(job->enabled && *job->edl_path != '@')
548 PackageDispatcher *packages = new PackageDispatcher;
551 TransportCommand *command = new TransportCommand;
552 FileXML *file = new FileXML;
553 file->read_from_file(job->edl_path);
555 // Use command to calculate range.
556 command->command = NORMAL_FWD;
557 command->get_edl()->load_xml(file,
559 command->change_type = CHANGE_ALL;
560 command->set_playback_range();
561 command->playback_range_adjust_inout();
563 // Create test packages
564 packages->create_packages(mwindow,
569 command->start_position,
570 command->end_position,
573 // Append output paths allocated to total
574 packages->get_package_paths(paths);
576 // Delete package harness
585 void BatchRenderThread::start_rendering(char *config_path,
588 BC_Hash *boot_defaults;
589 Preferences *preferences;
591 BC_Signals *signals = new BC_Signals;
592 // XXX the above stuff is leaked,
594 // Initialize stuff which MWindow does.
595 signals->initialize();
596 MWindow::init_defaults(boot_defaults, config_path);
597 load_defaults(boot_defaults);
598 preferences = new Preferences;
599 preferences->load_defaults(boot_defaults);
600 MWindow::init_plugins(0, preferences);
601 char font_path[BCTEXTLEN];
602 strcpy(font_path, preferences->plugin_dir);
603 strcat(font_path, "/" FONT_SEARCHPATH);
604 BC_Resources::init_fontconfig(font_path);
605 BC_WindowBase::get_resources()->vframe_shm = 1;
608 load_jobs(batch_path, preferences);
609 save_jobs(batch_path);
610 save_defaults(boot_defaults);
613 // Test EDL files for existence
614 if(test_edl_files()) return;
618 // Predict all destination paths
619 ArrayList<char*> paths;
620 paths.set_array_delete();
621 calculate_dest_paths(&paths, preferences);
624 int result = ConfirmSave::test_files(0, &paths);
625 paths.remove_all_objects();
626 // Abort on any existing file because it's so hard to set this up.
630 render = new Render(0);
632 render->start_batches(&jobs,
638 void BatchRenderThread::start_rendering()
640 if(is_rendering) return;
643 char path[BCTEXTLEN];
646 save_defaults(mwindow->defaults);
647 gui->button_disable();
649 // Test EDL files for existence
650 if(test_edl_files()) return;
652 // Predict all destination paths
653 ArrayList<char*> paths;
654 calculate_dest_paths(&paths,
655 mwindow->preferences);
657 // Test destination files for overwrite
658 int result = ConfirmSave::test_files(mwindow, &paths);
659 paths.remove_all_objects();
665 gui->button_enable();
669 mwindow->render->start_batches(&jobs);
672 void BatchRenderThread::stop_rendering()
674 if(!is_rendering) return;
675 mwindow->render->stop_operation();
679 void BatchRenderThread::update_active(int number)
681 gui->lock_window("BatchRenderThread::update_active");
684 current_job = number;
685 rendering_job = number;
693 gui->unlock_window();
696 void BatchRenderThread::update_done(int number,
700 gui->lock_window("BatchRenderThread::update_done");
703 gui->button_enable();
707 jobs.values[number]->enabled = 0;
708 jobs.values[number]->elapsed = elapsed_time;
709 if(create_list) gui->create_list(1);
711 gui->unlock_window();
714 void BatchRenderThread::move_batch(int src, int dst)
716 BatchRenderJob *src_job = jobs.values[src];
717 if(dst < 0) dst = jobs.total - 1;
721 for(int i = src; i < jobs.total - 1; i++)
722 jobs.values[i] = jobs.values[i + 1];
723 // if(dst > src) dst--;
724 for(int i = jobs.total - 1; i > dst; i--)
725 jobs.values[i] = jobs.values[i - 1];
726 jobs.values[dst] = src_job;
737 BatchRenderGUI::BatchRenderGUI(MWindow *mwindow,
738 BatchRenderThread *thread, int x, int y, int w, int h)
739 : BC_Window(_(PROGRAM_NAME ": Batch Render"),
740 x, y, w, h, 50, 50, 1, 0, 1)
742 this->mwindow = mwindow;
743 this->thread = thread;
746 BatchRenderGUI::~BatchRenderGUI()
748 lock_window("BatchRenderGUI::~BatchRenderGUI");
754 void BatchRenderGUI::create_objects()
756 lock_window("BatchRenderGUI::create_objects");
757 mwindow->theme->get_batchrender_sizes(this, get_w(), get_h());
760 int x = mwindow->theme->batchrender_x1;
762 int x1 = x, x2 = get_w()/2 + 10; // mwindow->theme->batchrender_x2;
766 add_subwindow(output_path_title = new BC_Title(x1, y1, _("Output path:")));
767 y1 += output_path_title->get_h() + mwindow->theme->widget_border;
769 format_tools = new BatchFormat(mwindow, this, thread->get_current_asset());
770 format_tools->set_w(get_w() / 2);
771 format_tools->create_objects(x1, y1, 1, 1, 1, 1, 0, 1, 0, 0,
772 &thread->get_current_job()->strategy, 0);
775 add_subwindow(edl_path_title = new BC_Title(x2, y2, _("EDL Path:")));
776 y2 += edl_path_title->get_h() + mwindow->theme->widget_border;
779 add_subwindow(edl_path_text = new BatchRenderEDLPath( thread,
780 x, y, get_w()-x - 40, thread->get_current_edl()));
781 x = x2 + edl_path_text->get_w();
782 add_subwindow(edl_path_browse = new BrowseButton(
783 mwindow, this, edl_path_text, x, y, thread->get_current_edl(),
784 _("Input EDL"), _("Select an EDL to load:"), 0));
785 y2 = y + edl_path_browse->get_h() + mwindow->theme->widget_border;
788 add_subwindow(update_selected_edl = new BatchRenderUpdateEDL(thread, x, y));
789 y += update_selected_edl->get_h() + mwindow->theme->widget_border;
790 add_subwindow(use_current_edl = new BatchRenderCurrentEDL(thread, x, y));
791 y += use_current_edl->get_h() + mwindow->theme->widget_border;
792 if( !mwindow->edl || !mwindow->edl->path[0] ) use_current_edl->disable();
793 add_subwindow(new_batch = new BatchRenderNew(thread, x, y));
794 x += new_batch->get_w() + mwindow->theme->widget_border;
795 add_subwindow(delete_batch = new BatchRenderDelete(thread, x, y));
796 x = x2; y += delete_batch->get_h() + mwindow->theme->widget_border;
797 add_subwindow(savelist_batch = new BatchRenderSaveList(thread, x, y));
798 x += savelist_batch->get_w() + mwindow->theme->widget_border;
799 add_subwindow(loadlist_batch = new BatchRenderLoadList(thread, x, y));
800 y += loadlist_batch->get_h() + mwindow->theme->widget_border;
801 add_subwindow(warning = new BatchRenderWarning(thread, x2, y));
802 y2 = y + warning->get_h() + mwindow->theme->widget_border;
803 if( y2 > y1 ) y1 = y2;
804 x = mwindow->theme->batchrender_x1, y = y1;
806 add_subwindow(list_title = new BC_Title(x, y, _("Batches to render:")));
807 y += list_title->get_h() + mwindow->theme->widget_border;
809 y1 -= 15 + BC_GenericButton::calculate_h() + mwindow->theme->widget_border;
810 add_subwindow(batch_list = new BatchRenderList(thread, x, y,
811 get_w() - x - 10, y1 - y));
812 y += batch_list->get_h() + mwindow->theme->widget_border;
814 add_subwindow(start_button = new BatchRenderStart(thread, x, y));
815 x = get_w() / 2 - BC_GenericButton::calculate_w(this, _("Stop")) / 2;
816 add_subwindow(stop_button = new BatchRenderStop(thread, x, y));
817 x = get_w() - BC_GenericButton::calculate_w(this, _("Close")) - 10;
818 add_subwindow(cancel_button = new BatchRenderCancel(thread, x, y));
824 void BatchRenderGUI::button_disable()
826 new_batch->disable();
827 delete_batch->disable();
828 use_current_edl->disable();
829 update_selected_edl->disable();
832 void BatchRenderGUI::button_enable()
835 delete_batch->enable();
836 if( mwindow->edl && mwindow->edl->path[0] )
837 use_current_edl->enable();
838 update_selected_edl->enable();
841 int BatchRenderGUI::resize_event(int w, int h)
843 mwindow->session->batchrender_w = w;
844 mwindow->session->batchrender_h = h;
845 mwindow->theme->get_batchrender_sizes(this, w, h);
847 int x = mwindow->theme->batchrender_x1;
849 int x1 = x, x2 = get_w()/2 + 10; // mwindow->theme->batchrender_x2;
853 output_path_title->reposition_window(x1, y1);
854 y1 += output_path_title->get_h() + mwindow->theme->widget_border;
855 format_tools->reposition_window(x1, y1);
859 edl_path_title->reposition_window(x, y);
860 y += edl_path_title->get_h() + mwindow->theme->widget_border;
861 edl_path_text->reposition_window(x, y, w - x - 40);
862 x += edl_path_text->get_w();
863 edl_path_browse->reposition_window(x, y);
864 y2 = y + edl_path_browse->get_h() + mwindow->theme->widget_border;
867 update_selected_edl->reposition_window(x, y);
868 y += update_selected_edl->get_h() + mwindow->theme->widget_border;
869 use_current_edl->reposition_window(x, y);
870 y += use_current_edl->get_h() + mwindow->theme->widget_border;
871 new_batch->reposition_window(x, y);
872 x += new_batch->get_w() + mwindow->theme->widget_border;
873 delete_batch->reposition_window(x, y);
875 x = x2; y += delete_batch->get_h() + mwindow->theme->widget_border;
876 savelist_batch->reposition_window(x, y);
877 x += savelist_batch->get_w() + mwindow->theme->widget_border;
878 loadlist_batch->reposition_window(x, y);
879 y += loadlist_batch->get_h() + mwindow->theme->widget_border;
881 y1 = 15 + BC_GenericButton::calculate_h() + mwindow->theme->widget_border;
882 y2 = get_h() - y1 - batch_list->get_h();
883 y2 -= list_title->get_h() + mwindow->theme->widget_border;
885 x = mwindow->theme->batchrender_x1; y = y2;
886 list_title->reposition_window(x, y);
887 y += list_title->get_h() + mwindow->theme->widget_border;
888 batch_list->reposition_window(x, y, w - x - 10, h - y - y1);
889 y += batch_list->get_h() + mwindow->theme->widget_border;
891 start_button->reposition_window(x, y);
892 x = w / 2 - stop_button->get_w() / 2;
893 stop_button->reposition_window(x, y);
894 x = w - cancel_button->get_w() - 10;
895 cancel_button->reposition_window(x, y);
899 int BatchRenderGUI::translation_event()
901 mwindow->session->batchrender_x = get_x();
902 mwindow->session->batchrender_y = get_y();
906 int BatchRenderGUI::close_event()
908 // Stop batch rendering
910 thread->stop_rendering();
911 lock_window("BatchRenderGUI::close_event");
916 void BatchRenderGUI::create_list(int update_widget)
918 for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
920 list_columns[i].remove_all_objects();
923 for(int i = 0; i < thread->jobs.total; i++)
925 BatchRenderJob *job = thread->jobs.values[i];
926 char string[BCTEXTLEN];
927 BC_ListBoxItem *enabled = new BC_ListBoxItem(job->enabled ?
930 BC_ListBoxItem *item1 = new BC_ListBoxItem(job->asset->path);
931 BC_ListBoxItem *item2 = new BC_ListBoxItem(job->edl_path);
932 BC_ListBoxItem *item3;
934 item3 = new BC_ListBoxItem(
935 Units::totext(string,
939 item3 = new BC_ListBoxItem(_("Unknown"));
940 list_columns[0].append(enabled);
941 list_columns[1].append(item1);
942 list_columns[2].append(item2);
943 list_columns[3].append(item3);
944 if(i == thread->current_job)
946 enabled->set_selected(1);
947 item1->set_selected(1);
948 item2->set_selected(1);
949 item3->set_selected(1);
951 if(i == thread->rendering_job)
953 enabled->set_color(RED);
954 item1->set_color(RED);
955 item2->set_color(RED);
956 item3->set_color(RED);
962 batch_list->update(list_columns,
964 thread->column_width,
966 batch_list->get_xposition(),
967 batch_list->get_yposition(),
968 batch_list->get_highlighted_item(), // Flat index of item cursor is over
969 1, // set all autoplace flags to 1
974 void BatchRenderGUI::change_job()
976 BatchRenderJob *job = thread->get_current_job();
977 format_tools->update(job->asset, &job->strategy);
978 edl_path_text->update(job->edl_path);
988 BatchFormat::BatchFormat(MWindow *mwindow,
991 : FormatTools(mwindow, gui, asset)
994 this->mwindow = mwindow;
997 BatchFormat::~BatchFormat()
1002 int BatchFormat::handle_event()
1004 gui->create_list(1);
1018 BatchRenderEDLPath::BatchRenderEDLPath(BatchRenderThread *thread,
1029 this->thread = thread;
1033 int BatchRenderEDLPath::handle_event()
1036 calculate_suggestions(thread->file_entries);
1038 strcpy(thread->get_current_edl(), get_text());
1039 thread->gui->create_list(1);
1048 BatchRenderNew::BatchRenderNew(BatchRenderThread *thread,
1051 : BC_GenericButton(x, y, _("New"))
1053 this->thread = thread;
1056 int BatchRenderNew::handle_event()
1062 BatchRenderDelete::BatchRenderDelete(BatchRenderThread *thread,
1065 : BC_GenericButton(x, y, _("Delete"))
1067 this->thread = thread;
1070 int BatchRenderDelete::handle_event()
1072 thread->delete_job();
1078 BatchRenderSaveList::BatchRenderSaveList(BatchRenderThread *thread,
1081 : BC_GenericButton(x, y, _("Save List"))
1083 this->thread = thread;
1084 set_tooltip(_("Save a Batch Render List"));
1086 startup_lock = new Mutex("BatchRenderSaveList::startup_lock");
1089 BatchRenderSaveList::~BatchRenderSaveList()
1091 startup_lock->lock("BatchRenderSaveList::~BrowseButton");
1096 gui->unlock_window();
1098 startup_lock->unlock();
1100 delete startup_lock;
1103 int BatchRenderSaveList::handle_event()
1105 if(Thread::running())
1110 gui->raise_window();
1111 gui->unlock_window();
1115 startup_lock->lock("BatchRenderSaveList::handle_event 1");
1117 startup_lock->lock("BatchRenderSaveList::handle_event 2");
1118 startup_lock->unlock();
1122 void BatchRenderSaveList::run()
1124 char default_path[BCTEXTLEN];
1125 sprintf(default_path, "~");
1126 BC_FileBox filewindow(100,
1128 this->thread->mwindow->defaults->get("DEFAULT_BATCHLOADPATH", default_path),
1129 _("Save Batch Render List"),
1130 _("Enter a Batch Render filename to save as:"),
1138 startup_lock->unlock();
1139 filewindow.create_objects();
1141 int result2 = filewindow.run_window();
1145 this->thread->save_jobs(filewindow.get_submitted_path());
1146 this->thread->mwindow->defaults->update("DEFAULT_BATCHLOADPATH", filewindow.get_submitted_path());
1149 this->thread->gui->flush();
1150 startup_lock->lock("BatchRenderLoadList::run");
1152 startup_lock->unlock();
1155 int BatchRenderSaveList::keypress_event() {
1156 if (get_keypress() == 's' ||
1157 get_keypress() == 'S') return handle_event();
1164 BatchRenderLoadList::BatchRenderLoadList(BatchRenderThread *thread,
1167 : BC_GenericButton(x, y, _("Load List")),
1170 this->thread = thread;
1171 set_tooltip(_("Load a previously saved Batch Render List"));
1173 startup_lock = new Mutex("BatchRenderLoadList::startup_lock");
1176 BatchRenderLoadList::~BatchRenderLoadList()
1178 startup_lock->lock("BatchRenderLoadList::~BrowseButton");
1183 gui->unlock_window();
1185 startup_lock->unlock();
1187 delete startup_lock;
1190 int BatchRenderLoadList::handle_event()
1192 if(Thread::running())
1197 gui->raise_window();
1198 gui->unlock_window();
1202 startup_lock->lock("BatchRenderLoadList::handle_event 1");
1204 startup_lock->lock("BatchRenderLoadList::handle_event 2");
1205 startup_lock->unlock();
1209 void BatchRenderLoadList::run()
1211 char default_path[BCTEXTLEN];
1212 sprintf(default_path, "~");
1213 BC_FileBox filewindow(100,
1215 this->thread->mwindow->defaults->get("DEFAULT_BATCHLOADPATH", default_path),
1216 _("Load Batch Render List"),
1217 _("Enter a Batch Render filename to load from:"),
1225 startup_lock->unlock();
1226 filewindow.create_objects();
1228 int result2 = filewindow.run_window();
1232 this->thread->load_jobs(filewindow.get_submitted_path(),this->thread->mwindow->preferences);
1233 this->thread->gui->create_list(1);
1234 this->thread->mwindow->defaults->update("DEFAULT_BATCHLOADPATH", filewindow.get_submitted_path());
1237 this->thread->gui->flush();
1238 startup_lock->lock("BatchRenderLoadList::run");
1240 startup_lock->unlock();
1243 int BatchRenderLoadList::keypress_event() {
1244 if (get_keypress() == 'o' ||
1245 get_keypress() == 'O') return handle_event();
1249 BatchRenderCurrentEDL::BatchRenderCurrentEDL(BatchRenderThread *thread,
1252 : BC_GenericButton(x, y, _("Use Current EDL"))
1254 this->thread = thread;
1257 int BatchRenderCurrentEDL::handle_event()
1259 thread->use_current_edl();
1263 BatchRenderUpdateEDL::BatchRenderUpdateEDL(BatchRenderThread *thread,
1266 : BC_GenericButton(x, y, _("Save to EDL Path"))
1268 this->thread = thread;
1271 int BatchRenderUpdateEDL::handle_event()
1273 thread->update_selected_edl();
1280 BatchRenderList::BatchRenderList(BatchRenderThread *thread,
1290 thread->gui->list_columns,
1292 thread->column_width,
1293 BATCHRENDER_COLUMNS,
1300 this->thread = thread;
1302 set_process_drag(0);
1305 int BatchRenderList::handle_event()
1310 int BatchRenderList::selection_changed()
1312 thread->current_job = get_selection_number(0, 0);
1313 thread->gui->change_job();
1314 if(get_cursor_x() < thread->column_width[0])
1316 BatchRenderJob *job = thread->get_current_job();
1317 job->enabled = !job->enabled;
1318 thread->gui->create_list(1);
1323 int BatchRenderList::column_resize_event()
1325 for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
1327 thread->column_width[i] = get_column_width(i);
1332 int BatchRenderList::drag_start_event()
1334 if(BC_ListBox::drag_start_event())
1343 int BatchRenderList::drag_motion_event()
1345 if(BC_ListBox::drag_motion_event())
1352 int BatchRenderList::drag_stop_event()
1356 int src = get_selection_number(0, 0);
1357 int dst = get_highlighted_item();
1360 thread->move_batch(src, dst);
1362 BC_ListBox::drag_stop_event();
1379 BatchRenderStart::BatchRenderStart(BatchRenderThread *thread,
1382 : BC_GenericButton(x,
1386 this->thread = thread;
1389 int BatchRenderStart::handle_event()
1391 thread->start_rendering();
1395 BatchRenderStop::BatchRenderStop(BatchRenderThread *thread,
1398 : BC_GenericButton(x,
1402 this->thread = thread;
1405 int BatchRenderStop::handle_event()
1408 thread->stop_rendering();
1409 lock_window("BatchRenderStop::handle_event");
1414 BatchRenderWarning::BatchRenderWarning(BatchRenderThread *thread, int x, int y)
1415 : BC_CheckBox(x, y, thread->warn, _("warn if jobs/session mismatched"))
1417 this->thread = thread;
1420 int BatchRenderWarning::handle_event()
1422 thread->warn = get_value();
1427 BatchRenderCancel::BatchRenderCancel(BatchRenderThread *thread,
1430 : BC_GenericButton(x,
1434 this->thread = thread;
1437 int BatchRenderCancel::handle_event()
1440 thread->stop_rendering();
1441 lock_window("BatchRenderCancel::handle_event");
1442 thread->gui->set_done(1);
1446 int BatchRenderCancel::keypress_event()
1448 if(get_keypress() == ESC)
1451 thread->stop_rendering();
1452 lock_window("BatchRenderCancel::keypress_event");
1453 thread->gui->set_done(1);