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();
599 MWindow::init_defaults(boot_defaults, config_path);
600 load_defaults(boot_defaults);
601 preferences = new Preferences;
602 preferences->load_defaults(boot_defaults);
603 MWindow::init_plugins(0, preferences);
604 char font_path[BCTEXTLEN];
605 strcpy(font_path, preferences->plugin_dir);
606 strcat(font_path, "/" FONT_SEARCHPATH);
607 BC_Resources::init_fontconfig(font_path);
608 BC_WindowBase::get_resources()->vframe_shm = 1;
611 load_jobs(batch_path, preferences);
612 save_jobs(batch_path);
613 save_defaults(boot_defaults);
616 // Test EDL files for existence
617 if(test_edl_files()) return;
621 // Predict all destination paths
622 ArrayList<char*> paths;
623 paths.set_array_delete();
624 calculate_dest_paths(&paths, preferences);
627 int result = ConfirmSave::test_files(0, &paths);
628 paths.remove_all_objects();
629 // Abort on any existing file because it's so hard to set this up.
633 render = new Render(0);
635 render->start_batches(&jobs,
641 void BatchRenderThread::start_rendering()
643 if(is_rendering) return;
646 char path[BCTEXTLEN];
649 save_defaults(mwindow->defaults);
650 gui->button_disable();
652 // Test EDL files for existence
653 if(test_edl_files()) return;
655 // Predict all destination paths
656 ArrayList<char*> paths;
657 calculate_dest_paths(&paths,
658 mwindow->preferences);
660 // Test destination files for overwrite
661 int result = ConfirmSave::test_files(mwindow, &paths);
662 paths.remove_all_objects();
668 gui->button_enable();
672 mwindow->render->start_batches(&jobs);
675 void BatchRenderThread::stop_rendering()
677 if(!is_rendering) return;
678 mwindow->render->stop_operation();
682 void BatchRenderThread::update_active(int number)
684 gui->lock_window("BatchRenderThread::update_active");
687 current_job = number;
688 rendering_job = number;
696 gui->unlock_window();
699 void BatchRenderThread::update_done(int number,
703 gui->lock_window("BatchRenderThread::update_done");
706 gui->button_enable();
710 jobs.values[number]->enabled = 0;
711 jobs.values[number]->elapsed = elapsed_time;
712 if(create_list) gui->create_list(1);
714 gui->unlock_window();
717 void BatchRenderThread::move_batch(int src, int dst)
719 BatchRenderJob *src_job = jobs.values[src];
720 if(dst < 0) dst = jobs.total - 1;
724 for(int i = src; i < jobs.total - 1; i++)
725 jobs.values[i] = jobs.values[i + 1];
726 // if(dst > src) dst--;
727 for(int i = jobs.total - 1; i > dst; i--)
728 jobs.values[i] = jobs.values[i - 1];
729 jobs.values[dst] = src_job;
740 BatchRenderGUI::BatchRenderGUI(MWindow *mwindow,
741 BatchRenderThread *thread, int x, int y, int w, int h)
742 : BC_Window(_(PROGRAM_NAME ": Batch Render"),
743 x, y, w, h, 50, 50, 1, 0, 1)
745 this->mwindow = mwindow;
746 this->thread = thread;
749 BatchRenderGUI::~BatchRenderGUI()
751 lock_window("BatchRenderGUI::~BatchRenderGUI");
757 void BatchRenderGUI::create_objects()
759 lock_window("BatchRenderGUI::create_objects");
760 mwindow->theme->get_batchrender_sizes(this, get_w(), get_h());
763 int x = mwindow->theme->batchrender_x1;
765 int x1 = x, x2 = get_w()/2 + 10; // mwindow->theme->batchrender_x2;
769 add_subwindow(output_path_title = new BC_Title(x1, y1, _("Output path:")));
770 y1 += output_path_title->get_h() + mwindow->theme->widget_border;
772 format_tools = new BatchFormat(mwindow, this, thread->get_current_asset());
773 format_tools->set_w(get_w() / 2);
774 format_tools->create_objects(x1, y1, 1, 1, 1, 1, 0, 1, 0, 0,
775 &thread->get_current_job()->strategy, 0);
778 add_subwindow(edl_path_title = new BC_Title(x2, y2, _("EDL Path:")));
779 y2 += edl_path_title->get_h() + mwindow->theme->widget_border;
782 add_subwindow(edl_path_text = new BatchRenderEDLPath( thread,
783 x, y, get_w()-x - 40, thread->get_current_edl()));
784 x = x2 + edl_path_text->get_w();
785 add_subwindow(edl_path_browse = new BrowseButton(
786 mwindow, this, edl_path_text, x, y, thread->get_current_edl(),
787 _("Input EDL"), _("Select an EDL to load:"), 0));
788 y2 = y + edl_path_browse->get_h() + mwindow->theme->widget_border;
791 add_subwindow(update_selected_edl = new BatchRenderUpdateEDL(thread, x, y));
792 y += update_selected_edl->get_h() + mwindow->theme->widget_border;
793 add_subwindow(use_current_edl = new BatchRenderCurrentEDL(thread, x, y));
794 y += use_current_edl->get_h() + mwindow->theme->widget_border;
795 if( !mwindow->edl || !mwindow->edl->path[0] ) use_current_edl->disable();
796 add_subwindow(new_batch = new BatchRenderNew(thread, x, y));
797 x += new_batch->get_w() + mwindow->theme->widget_border;
798 add_subwindow(delete_batch = new BatchRenderDelete(thread, x, y));
799 x = x2; y += delete_batch->get_h() + mwindow->theme->widget_border;
800 add_subwindow(savelist_batch = new BatchRenderSaveList(thread, x, y));
801 x += savelist_batch->get_w() + mwindow->theme->widget_border;
802 add_subwindow(loadlist_batch = new BatchRenderLoadList(thread, x, y));
803 y += loadlist_batch->get_h() + mwindow->theme->widget_border;
804 add_subwindow(warning = new BatchRenderWarning(thread, x2, y));
805 y2 = y + warning->get_h() + mwindow->theme->widget_border;
806 if( y2 > y1 ) y1 = y2;
807 x = mwindow->theme->batchrender_x1, y = y1;
809 add_subwindow(list_title = new BC_Title(x, y, _("Batches to render:")));
810 y += list_title->get_h() + mwindow->theme->widget_border;
812 y1 -= 15 + BC_GenericButton::calculate_h() + mwindow->theme->widget_border;
813 add_subwindow(batch_list = new BatchRenderList(thread, x, y,
814 get_w() - x - 10, y1 - y));
815 y += batch_list->get_h() + mwindow->theme->widget_border;
817 add_subwindow(start_button = new BatchRenderStart(thread, x, y));
818 x = get_w() / 2 - BC_GenericButton::calculate_w(this, _("Stop")) / 2;
819 add_subwindow(stop_button = new BatchRenderStop(thread, x, y));
820 x = get_w() - BC_GenericButton::calculate_w(this, _("Close")) - 10;
821 add_subwindow(cancel_button = new BatchRenderCancel(thread, x, y));
827 void BatchRenderGUI::button_disable()
829 new_batch->disable();
830 delete_batch->disable();
831 use_current_edl->disable();
832 update_selected_edl->disable();
835 void BatchRenderGUI::button_enable()
838 delete_batch->enable();
839 if( mwindow->edl && mwindow->edl->path[0] )
840 use_current_edl->enable();
841 update_selected_edl->enable();
844 int BatchRenderGUI::resize_event(int w, int h)
846 mwindow->session->batchrender_w = w;
847 mwindow->session->batchrender_h = h;
848 mwindow->theme->get_batchrender_sizes(this, w, h);
850 int x = mwindow->theme->batchrender_x1;
852 int x1 = x, x2 = get_w()/2 + 10; // mwindow->theme->batchrender_x2;
856 output_path_title->reposition_window(x1, y1);
857 y1 += output_path_title->get_h() + mwindow->theme->widget_border;
858 format_tools->reposition_window(x1, y1);
862 edl_path_title->reposition_window(x, y);
863 y += edl_path_title->get_h() + mwindow->theme->widget_border;
864 edl_path_text->reposition_window(x, y, w - x - 40);
865 x += edl_path_text->get_w();
866 edl_path_browse->reposition_window(x, y);
867 y2 = y + edl_path_browse->get_h() + mwindow->theme->widget_border;
870 update_selected_edl->reposition_window(x, y);
871 y += update_selected_edl->get_h() + mwindow->theme->widget_border;
872 use_current_edl->reposition_window(x, y);
873 y += use_current_edl->get_h() + mwindow->theme->widget_border;
874 new_batch->reposition_window(x, y);
875 x += new_batch->get_w() + mwindow->theme->widget_border;
876 delete_batch->reposition_window(x, y);
878 x = x2; y += delete_batch->get_h() + mwindow->theme->widget_border;
879 savelist_batch->reposition_window(x, y);
880 x += savelist_batch->get_w() + mwindow->theme->widget_border;
881 loadlist_batch->reposition_window(x, y);
882 y += loadlist_batch->get_h() + mwindow->theme->widget_border;
884 y1 = 15 + BC_GenericButton::calculate_h() + mwindow->theme->widget_border;
885 y2 = get_h() - y1 - batch_list->get_h();
886 y2 -= list_title->get_h() + mwindow->theme->widget_border;
888 x = mwindow->theme->batchrender_x1; y = y2;
889 list_title->reposition_window(x, y);
890 y += list_title->get_h() + mwindow->theme->widget_border;
891 batch_list->reposition_window(x, y, w - x - 10, h - y - y1);
892 y += batch_list->get_h() + mwindow->theme->widget_border;
894 start_button->reposition_window(x, y);
895 x = w / 2 - stop_button->get_w() / 2;
896 stop_button->reposition_window(x, y);
897 x = w - cancel_button->get_w() - 10;
898 cancel_button->reposition_window(x, y);
902 int BatchRenderGUI::translation_event()
904 mwindow->session->batchrender_x = get_x();
905 mwindow->session->batchrender_y = get_y();
909 int BatchRenderGUI::close_event()
911 // Stop batch rendering
913 thread->stop_rendering();
914 lock_window("BatchRenderGUI::close_event");
919 void BatchRenderGUI::create_list(int update_widget)
921 for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
923 list_columns[i].remove_all_objects();
926 for(int i = 0; i < thread->jobs.total; i++)
928 BatchRenderJob *job = thread->jobs.values[i];
929 char string[BCTEXTLEN];
930 BC_ListBoxItem *enabled = new BC_ListBoxItem(job->enabled ?
933 BC_ListBoxItem *item1 = new BC_ListBoxItem(job->asset->path);
934 BC_ListBoxItem *item2 = new BC_ListBoxItem(job->edl_path);
935 BC_ListBoxItem *item3;
937 item3 = new BC_ListBoxItem(
938 Units::totext(string,
942 item3 = new BC_ListBoxItem(_("Unknown"));
943 list_columns[0].append(enabled);
944 list_columns[1].append(item1);
945 list_columns[2].append(item2);
946 list_columns[3].append(item3);
947 if(i == thread->current_job)
949 enabled->set_selected(1);
950 item1->set_selected(1);
951 item2->set_selected(1);
952 item3->set_selected(1);
954 if(i == thread->rendering_job)
956 enabled->set_color(RED);
957 item1->set_color(RED);
958 item2->set_color(RED);
959 item3->set_color(RED);
965 batch_list->update(list_columns,
967 thread->column_width,
969 batch_list->get_xposition(),
970 batch_list->get_yposition(),
971 batch_list->get_highlighted_item(), // Flat index of item cursor is over
972 1, // set all autoplace flags to 1
977 void BatchRenderGUI::change_job()
979 BatchRenderJob *job = thread->get_current_job();
980 format_tools->update(job->asset, &job->strategy);
981 edl_path_text->update(job->edl_path);
991 BatchFormat::BatchFormat(MWindow *mwindow,
994 : FormatTools(mwindow, gui, asset)
997 this->mwindow = mwindow;
1000 BatchFormat::~BatchFormat()
1005 int BatchFormat::handle_event()
1007 gui->create_list(1);
1021 BatchRenderEDLPath::BatchRenderEDLPath(BatchRenderThread *thread,
1032 this->thread = thread;
1036 int BatchRenderEDLPath::handle_event()
1039 calculate_suggestions(thread->file_entries);
1041 strcpy(thread->get_current_edl(), get_text());
1042 thread->gui->create_list(1);
1051 BatchRenderNew::BatchRenderNew(BatchRenderThread *thread,
1054 : BC_GenericButton(x, y, _("New"))
1056 this->thread = thread;
1059 int BatchRenderNew::handle_event()
1065 BatchRenderDelete::BatchRenderDelete(BatchRenderThread *thread,
1068 : BC_GenericButton(x, y, _("Delete"))
1070 this->thread = thread;
1073 int BatchRenderDelete::handle_event()
1075 thread->delete_job();
1081 BatchRenderSaveList::BatchRenderSaveList(BatchRenderThread *thread,
1084 : BC_GenericButton(x, y, _("Save List"))
1086 this->thread = thread;
1087 set_tooltip(_("Save a Batch Render List"));
1089 startup_lock = new Mutex("BatchRenderSaveList::startup_lock");
1092 BatchRenderSaveList::~BatchRenderSaveList()
1094 startup_lock->lock("BatchRenderSaveList::~BrowseButton");
1099 gui->unlock_window();
1101 startup_lock->unlock();
1103 delete startup_lock;
1106 int BatchRenderSaveList::handle_event()
1108 if(Thread::running())
1113 gui->raise_window();
1114 gui->unlock_window();
1118 startup_lock->lock("BatchRenderSaveList::handle_event 1");
1120 startup_lock->lock("BatchRenderSaveList::handle_event 2");
1121 startup_lock->unlock();
1125 void BatchRenderSaveList::run()
1127 char default_path[BCTEXTLEN];
1128 sprintf(default_path, "~");
1129 BC_FileBox filewindow(100,
1131 this->thread->mwindow->defaults->get("DEFAULT_BATCHLOADPATH", default_path),
1132 _("Save Batch Render List"),
1133 _("Enter a Batch Render filename to save as:"),
1141 startup_lock->unlock();
1142 filewindow.create_objects();
1144 int result2 = filewindow.run_window();
1148 this->thread->save_jobs(filewindow.get_submitted_path());
1149 this->thread->mwindow->defaults->update("DEFAULT_BATCHLOADPATH", filewindow.get_submitted_path());
1152 this->thread->gui->flush();
1153 startup_lock->lock("BatchRenderLoadList::run");
1155 startup_lock->unlock();
1158 int BatchRenderSaveList::keypress_event() {
1159 if (get_keypress() == 's' ||
1160 get_keypress() == 'S') return handle_event();
1167 BatchRenderLoadList::BatchRenderLoadList(BatchRenderThread *thread,
1170 : BC_GenericButton(x, y, _("Load List")),
1173 this->thread = thread;
1174 set_tooltip(_("Load a previously saved Batch Render List"));
1176 startup_lock = new Mutex("BatchRenderLoadList::startup_lock");
1179 BatchRenderLoadList::~BatchRenderLoadList()
1181 startup_lock->lock("BatchRenderLoadList::~BrowseButton");
1186 gui->unlock_window();
1188 startup_lock->unlock();
1190 delete startup_lock;
1193 int BatchRenderLoadList::handle_event()
1195 if(Thread::running())
1200 gui->raise_window();
1201 gui->unlock_window();
1205 startup_lock->lock("BatchRenderLoadList::handle_event 1");
1207 startup_lock->lock("BatchRenderLoadList::handle_event 2");
1208 startup_lock->unlock();
1212 void BatchRenderLoadList::run()
1214 char default_path[BCTEXTLEN];
1215 sprintf(default_path, "~");
1216 BC_FileBox filewindow(100,
1218 this->thread->mwindow->defaults->get("DEFAULT_BATCHLOADPATH", default_path),
1219 _("Load Batch Render List"),
1220 _("Enter a Batch Render filename to load from:"),
1228 startup_lock->unlock();
1229 filewindow.create_objects();
1231 int result2 = filewindow.run_window();
1235 this->thread->load_jobs(filewindow.get_submitted_path(),this->thread->mwindow->preferences);
1236 this->thread->gui->create_list(1);
1237 this->thread->mwindow->defaults->update("DEFAULT_BATCHLOADPATH", filewindow.get_submitted_path());
1240 this->thread->gui->flush();
1241 startup_lock->lock("BatchRenderLoadList::run");
1243 startup_lock->unlock();
1246 int BatchRenderLoadList::keypress_event() {
1247 if (get_keypress() == 'o' ||
1248 get_keypress() == 'O') return handle_event();
1252 BatchRenderCurrentEDL::BatchRenderCurrentEDL(BatchRenderThread *thread,
1255 : BC_GenericButton(x, y, _("Use Current EDL"))
1257 this->thread = thread;
1260 int BatchRenderCurrentEDL::handle_event()
1262 thread->use_current_edl();
1266 BatchRenderUpdateEDL::BatchRenderUpdateEDL(BatchRenderThread *thread,
1269 : BC_GenericButton(x, y, _("Save to EDL Path"))
1271 this->thread = thread;
1274 int BatchRenderUpdateEDL::handle_event()
1276 thread->update_selected_edl();
1283 BatchRenderList::BatchRenderList(BatchRenderThread *thread,
1293 thread->gui->list_columns,
1295 thread->column_width,
1296 BATCHRENDER_COLUMNS,
1303 this->thread = thread;
1305 set_process_drag(0);
1308 int BatchRenderList::handle_event()
1313 int BatchRenderList::selection_changed()
1315 thread->current_job = get_selection_number(0, 0);
1316 thread->gui->change_job();
1317 if(get_cursor_x() < thread->column_width[0])
1319 BatchRenderJob *job = thread->get_current_job();
1320 job->enabled = !job->enabled;
1321 thread->gui->create_list(1);
1326 int BatchRenderList::column_resize_event()
1328 for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
1330 thread->column_width[i] = get_column_width(i);
1335 int BatchRenderList::drag_start_event()
1337 if(BC_ListBox::drag_start_event())
1346 int BatchRenderList::drag_motion_event()
1348 if(BC_ListBox::drag_motion_event())
1355 int BatchRenderList::drag_stop_event()
1359 int src = get_selection_number(0, 0);
1360 int dst = get_highlighted_item();
1363 thread->move_batch(src, dst);
1365 BC_ListBox::drag_stop_event();
1382 BatchRenderStart::BatchRenderStart(BatchRenderThread *thread,
1385 : BC_GenericButton(x,
1389 this->thread = thread;
1392 int BatchRenderStart::handle_event()
1394 thread->start_rendering();
1398 BatchRenderStop::BatchRenderStop(BatchRenderThread *thread,
1401 : BC_GenericButton(x,
1405 this->thread = thread;
1408 int BatchRenderStop::handle_event()
1411 thread->stop_rendering();
1412 lock_window("BatchRenderStop::handle_event");
1417 BatchRenderWarning::BatchRenderWarning(BatchRenderThread *thread, int x, int y)
1418 : BC_CheckBox(x, y, thread->warn, _("warn if jobs/session mismatched"))
1420 this->thread = thread;
1423 int BatchRenderWarning::handle_event()
1425 thread->warn = get_value();
1430 BatchRenderCancel::BatchRenderCancel(BatchRenderThread *thread,
1433 : BC_GenericButton(x,
1437 this->thread = thread;
1440 int BatchRenderCancel::handle_event()
1443 thread->stop_rendering();
1444 lock_window("BatchRenderCancel::handle_event");
1445 thread->gui->set_done(1);
1449 int BatchRenderCancel::keypress_event()
1451 if(get_keypress() == ESC)
1454 thread->stop_rendering();
1455 lock_window("BatchRenderCancel::keypress_event");
1456 thread->gui->set_done(1);