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"
34 #include "filesystem.h"
40 #include "mainerror.h"
42 #include "mainsession.h"
45 #include "mwindowgui.h"
46 #include "packagedispatcher.h"
47 #include "packagerenderer.h"
49 #include "pluginset.h"
50 #include "preferences.h"
54 #include "transportque.h"
58 static const char *list_titles[] =
66 static int list_widths[] =
74 BatchRenderMenuItem::BatchRenderMenuItem(MWindow *mwindow)
75 : BC_MenuItem(_("Batch Render..."), _("Shift-B"), 'B')
78 this->mwindow = mwindow;
81 int BatchRenderMenuItem::handle_event()
83 mwindow->batch_render->start();
94 BatchRenderJob::BatchRenderJob(Preferences *preferences)
96 this->preferences = preferences;
104 BatchRenderJob::~BatchRenderJob()
106 asset->Garbage::remove_user();
109 void BatchRenderJob::copy_from(BatchRenderJob *src)
111 asset->copy_from(src->asset, 0);
112 strcpy(edl_path, src->edl_path);
113 strategy = src->strategy;
114 enabled = src->enabled;
118 void BatchRenderJob::load(FileXML *file)
123 file->tag.get_property("EDL_PATH", edl_path);
124 strategy = file->tag.get_property("STRATEGY", strategy);
125 enabled = file->tag.get_property("ENABLED", enabled);
126 elapsed = file->tag.get_property("ELAPSED", elapsed);
129 result = file->read_tag();
132 if(file->tag.title_is("ASSET"))
134 file->tag.get_property("SRC", asset->path);
135 asset->read(file, 0);
136 // The compression parameters are stored in the defaults to reduce
137 // coding maintenance. The defaults must now be stuffed into the XML for
140 defaults.load_string(file->read_text());
141 asset->load_defaults(&defaults,
152 void BatchRenderJob::save(FileXML *file)
154 file->tag.set_property("EDL_PATH", edl_path);
155 file->tag.set_property("STRATEGY", strategy);
156 file->tag.set_property("ENABLED", enabled);
157 file->tag.set_property("ELAPSED", elapsed);
159 file->append_newline();
164 // The compression parameters are stored in the defaults to reduce
165 // coding maintenance. The defaults must now be stuffed into the XML for
168 asset->save_defaults(&defaults,
176 defaults.save_string(string);
177 file->append_text(string);
179 file->tag.set_title("/JOB");
181 file->append_newline();
184 void BatchRenderJob::fix_strategy()
186 strategy = Render::fix_strategy(strategy, preferences->use_renderfarm);
198 BatchRenderThread::BatchRenderThread(MWindow *mwindow)
201 this->mwindow = mwindow;
212 BatchRenderThread::BatchRenderThread()
226 BatchRenderThread::~BatchRenderThread()
229 delete boot_defaults;
233 file_entries->remove_all_objects();
238 void BatchRenderThread::reset()
242 delete default_job; default_job = 0;
243 jobs.remove_all_objects();
245 file_entries->remove_all_objects();
246 delete file_entries; file_entries = 0;
250 void BatchRenderThread::handle_close_event(int result)
253 char path[BCTEXTLEN];
256 save_defaults(mwindow->defaults);
260 BC_Window* BatchRenderThread::new_gui()
264 default_job = new BatchRenderJob(mwindow->preferences);
269 file_entries = new ArrayList<BC_ListBoxItem*>;
271 char string[BCTEXTLEN];
272 // Load current directory
273 fs.update(getcwd(string, BCTEXTLEN));
274 for(int i = 0; i < fs.total_files(); i++)
276 file_entries->append(
278 fs.get_entry(i)->get_name()));
282 char path[BCTEXTLEN];
284 load_jobs(path, mwindow->preferences);
285 load_defaults(mwindow->defaults);
286 this->gui = new BatchRenderGUI(mwindow,
288 mwindow->session->batchrender_x,
289 mwindow->session->batchrender_y,
290 mwindow->session->batchrender_w,
291 mwindow->session->batchrender_h);
292 this->gui->create_objects();
297 void BatchRenderThread::load_jobs(char *path, Preferences *preferences)
302 jobs.remove_all_objects();
304 file.read_from_file(path);
306 file.read_from_file(create_path(path));
310 if(!(result = file.read_tag()))
312 if(file.tag.title_is("JOB"))
315 jobs.append(job = new BatchRenderJob(preferences));
322 void BatchRenderThread::save_jobs(char *path)
326 for(int i = 0; i < jobs.total; i++)
328 file.tag.set_title("JOB");
329 jobs.values[i]->save(&file);
333 file.write_to_file(path);
335 file.write_to_file(create_path(path));
338 void BatchRenderThread::load_defaults(BC_Hash *defaults)
342 default_job->asset->load_defaults(defaults,
349 default_job->fix_strategy();
352 for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
354 char string[BCTEXTLEN];
355 sprintf(string, "BATCHRENDER_COLUMN%d", i);
356 column_width[i] = defaults->get(string, list_widths[i]);
360 void BatchRenderThread::save_defaults(BC_Hash *defaults)
364 default_job->asset->save_defaults(defaults,
371 defaults->update("BATCHRENDER_STRATEGY", default_job->strategy);
373 for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
375 char string[BCTEXTLEN];
376 sprintf(string, "BATCHRENDER_COLUMN%d", i);
377 defaults->update(string, column_width[i]);
379 // defaults->update("BATCHRENDER_JOB", current_job);
381 mwindow->save_defaults();
386 char* BatchRenderThread::create_path(char *string)
389 sprintf(string, "%s", BCASTDIR);
390 fs.complete_path(string);
391 strcat(string, BATCH_PATH);
395 void BatchRenderThread::new_job()
397 BatchRenderJob *result = new BatchRenderJob(mwindow->preferences);
398 result->copy_from(get_current_job());
400 current_job = jobs.total - 1;
405 void BatchRenderThread::delete_job()
407 if(current_job < jobs.total && current_job >= 0)
409 jobs.remove_object_number(current_job);
410 if(current_job > 0) current_job--;
416 void BatchRenderThread::use_current_edl()
418 // printf("BatchRenderThread::use_current_edl %d %p %s\n",
420 // mwindow->edl->path,
421 // mwindow->edl->path);
423 strcpy(get_current_edl(), mwindow->edl->path);
425 gui->edl_path_text->update(get_current_edl());
428 void BatchRenderThread::update_selected_edl()
431 char *path = get_current_edl();
432 EDL *edl = mwindow->edl;
433 edl->save_xml(&xml_file, path, 0, 0);
434 xml_file.terminate_string();
435 if( xml_file.write_to_file(path) ) {
437 sprintf(msg, _("Unable to save: %s"), path);
438 MainError::show_error(msg);
442 BatchRenderJob* BatchRenderThread::get_current_job()
444 BatchRenderJob *result;
445 if(current_job >= jobs.total || current_job < 0)
447 result = default_job;
451 result = jobs.values[current_job];
457 Asset* BatchRenderThread::get_current_asset()
459 return get_current_job()->asset;
462 char* BatchRenderThread::get_current_edl()
464 return get_current_job()->edl_path;
468 // Test EDL files for existence
469 int BatchRenderThread::test_edl_files()
471 for(int i = 0; i < jobs.total; i++)
473 if(jobs.values[i]->enabled)
475 const char *path = jobs.values[i]->edl_path;
476 if( *path == '@' ) ++path;
477 FILE *fd = fopen(path, "r");
480 char string[BCTEXTLEN];
481 sprintf(string, _("EDL %s not found.\n"), jobs.values[i]->edl_path);
484 ErrorBox error_box(_(PROGRAM_NAME ": Error"),
485 mwindow->gui->get_abs_cursor_x(1),
486 mwindow->gui->get_abs_cursor_y(1));
487 error_box.create_objects(string);
488 error_box.run_window();
489 gui->button_enable();
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();
566 MWindow::init_defaults(boot_defaults, config_path);
567 load_defaults(boot_defaults);
568 preferences = new Preferences;
569 preferences->load_defaults(boot_defaults);
570 MWindow::init_plugins(0, preferences);
571 char font_path[BCTEXTLEN];
572 strcpy(font_path, preferences->plugin_dir);
573 strcat(font_path, "/" FONT_SEARCHPATH);
574 BC_Resources::init_fontconfig(font_path);
575 BC_WindowBase::get_resources()->vframe_shm = 1;
578 load_jobs(batch_path, preferences);
579 save_jobs(batch_path);
580 save_defaults(boot_defaults);
583 // Test EDL files for existence
584 if(test_edl_files()) return;
588 // Predict all destination paths
589 ArrayList<char*> paths;
590 paths.set_array_delete();
591 calculate_dest_paths(&paths, preferences);
594 int result = ConfirmSave::test_files(0, &paths);
595 paths.remove_all_objects();
596 // Abort on any existing file because it's so hard to set this up.
600 render = new Render(0);
602 render->start_batches(&jobs,
608 void BatchRenderThread::start_rendering()
610 if(is_rendering) return;
613 char path[BCTEXTLEN];
616 save_defaults(mwindow->defaults);
617 gui->button_disable();
619 // Test EDL files for existence
620 if(test_edl_files()) return;
622 // Predict all destination paths
623 ArrayList<char*> paths;
624 calculate_dest_paths(&paths,
625 mwindow->preferences);
627 // Test destination files for overwrite
628 int result = ConfirmSave::test_files(mwindow, &paths);
629 paths.remove_all_objects();
635 gui->button_enable();
639 mwindow->render->start_batches(&jobs);
642 void BatchRenderThread::stop_rendering()
644 if(!is_rendering) return;
645 mwindow->render->stop_operation();
649 void BatchRenderThread::update_active(int number)
651 gui->lock_window("BatchRenderThread::update_active");
654 current_job = number;
655 rendering_job = number;
663 gui->unlock_window();
666 void BatchRenderThread::update_done(int number,
670 gui->lock_window("BatchRenderThread::update_done");
673 gui->button_enable();
677 jobs.values[number]->enabled = 0;
678 jobs.values[number]->elapsed = elapsed_time;
679 if(create_list) gui->create_list(1);
681 gui->unlock_window();
684 void BatchRenderThread::move_batch(int src, int dst)
686 BatchRenderJob *src_job = jobs.values[src];
687 if(dst < 0) dst = jobs.total - 1;
691 for(int i = src; i < jobs.total - 1; i++)
692 jobs.values[i] = jobs.values[i + 1];
693 // if(dst > src) dst--;
694 for(int i = jobs.total - 1; i > dst; i--)
695 jobs.values[i] = jobs.values[i - 1];
696 jobs.values[dst] = src_job;
707 BatchRenderGUI::BatchRenderGUI(MWindow *mwindow,
708 BatchRenderThread *thread,
713 : BC_Window(_(PROGRAM_NAME ": Batch Render"),
724 this->mwindow = mwindow;
725 this->thread = thread;
728 BatchRenderGUI::~BatchRenderGUI()
730 lock_window("BatchRenderGUI::~BatchRenderGUI");
736 void BatchRenderGUI::create_objects()
738 lock_window("BatchRenderGUI::create_objects");
739 mwindow->theme->get_batchrender_sizes(this, get_w(), get_h());
742 int x = mwindow->theme->batchrender_x1;
744 int x1 = x, x2 = get_w()/2 + 10; // mwindow->theme->batchrender_x2;
748 add_subwindow(output_path_title = new BC_Title(x1, y1, _("Output path:")));
749 y1 += output_path_title->get_h() + mwindow->theme->widget_border;
751 format_tools = new BatchFormat(mwindow, this, thread->get_current_asset());
752 format_tools->set_w(get_w() / 2);
753 format_tools->create_objects(x1, y1, 1, 1, 1, 1, 0, 1, 0, 0,
754 &thread->get_current_job()->strategy, 0);
757 add_subwindow(edl_path_title = new BC_Title(x2, y2, _("EDL Path:")));
758 y2 += edl_path_title->get_h() + mwindow->theme->widget_border;
761 add_subwindow(edl_path_text = new BatchRenderEDLPath( thread,
762 x, y, get_w()-x - 40, thread->get_current_edl()));
763 x = x2 + edl_path_text->get_w();
764 add_subwindow(edl_path_browse = new BrowseButton(
765 mwindow, this, edl_path_text, x, y, thread->get_current_edl(),
766 _("Input EDL"), _("Select an EDL to load:"), 0));
767 y2 = y + edl_path_browse->get_h() + mwindow->theme->widget_border;
770 add_subwindow(update_selected_edl = new BatchRenderUpdateEDL(thread, x, y));
771 y += update_selected_edl->get_h() + mwindow->theme->widget_border;
772 add_subwindow(use_current_edl = new BatchRenderCurrentEDL(thread, x, y));
773 y += use_current_edl->get_h() + mwindow->theme->widget_border;
774 if( !mwindow->edl || !mwindow->edl->path[0] ) use_current_edl->disable();
775 add_subwindow(new_batch = new BatchRenderNew(thread, x, y));
776 x += new_batch->get_w() + mwindow->theme->widget_border;
777 add_subwindow(delete_batch = new BatchRenderDelete(thread, x, y));
778 x = x2; y += delete_batch->get_h() + mwindow->theme->widget_border;
779 add_subwindow(savelist_batch = new BatchRenderSaveList(thread, x, y));
780 x += savelist_batch->get_w() + mwindow->theme->widget_border;
781 add_subwindow(loadlist_batch = new BatchRenderLoadList(thread, x, y));
782 y2 = y + loadlist_batch->get_h() + mwindow->theme->widget_border;
783 if( y2 > y1 ) y1 = y2;
784 x = mwindow->theme->batchrender_x1, y = y1;
786 add_subwindow(list_title = new BC_Title(x, y, _("Batches to render:")));
787 y += list_title->get_h() + mwindow->theme->widget_border;
789 y1 -= 15 + BC_GenericButton::calculate_h() + mwindow->theme->widget_border;
790 add_subwindow(batch_list = new BatchRenderList(thread, x, y,
791 get_w() - x - 10, y1 - y));
792 y += batch_list->get_h() + mwindow->theme->widget_border;
794 add_subwindow(start_button = new BatchRenderStart(thread, x, y));
795 x = get_w() / 2 - BC_GenericButton::calculate_w(this, _("Stop")) / 2;
796 add_subwindow(stop_button = new BatchRenderStop(thread, x, y));
797 x = get_w() - BC_GenericButton::calculate_w(this, _("Close")) - 10;
798 add_subwindow(cancel_button = new BatchRenderCancel(thread, x, y));
804 void BatchRenderGUI::button_disable()
806 new_batch->disable();
807 delete_batch->disable();
808 use_current_edl->disable();
809 update_selected_edl->disable();
812 void BatchRenderGUI::button_enable()
815 delete_batch->enable();
816 if( mwindow->edl && mwindow->edl->path[0] )
817 use_current_edl->enable();
818 update_selected_edl->enable();
821 int BatchRenderGUI::resize_event(int w, int h)
823 mwindow->session->batchrender_w = w;
824 mwindow->session->batchrender_h = h;
825 mwindow->theme->get_batchrender_sizes(this, w, h);
827 int x = mwindow->theme->batchrender_x1;
829 int x1 = x, x2 = get_w()/2 + 10; // mwindow->theme->batchrender_x2;
833 output_path_title->reposition_window(x1, y1);
834 y1 += output_path_title->get_h() + mwindow->theme->widget_border;
835 format_tools->reposition_window(x1, y1);
839 edl_path_title->reposition_window(x, y);
840 y += edl_path_title->get_h() + mwindow->theme->widget_border;
841 edl_path_text->reposition_window(x, y, w - x - 40);
842 x += edl_path_text->get_w();
843 edl_path_browse->reposition_window(x, y);
844 y2 = y + edl_path_browse->get_h() + mwindow->theme->widget_border;
847 update_selected_edl->reposition_window(x, y);
848 y += update_selected_edl->get_h() + mwindow->theme->widget_border;
849 use_current_edl->reposition_window(x, y);
850 y += use_current_edl->get_h() + mwindow->theme->widget_border;
851 new_batch->reposition_window(x, y);
852 x += new_batch->get_w() + mwindow->theme->widget_border;
853 delete_batch->reposition_window(x, y);
855 x = x2; y += delete_batch->get_h() + mwindow->theme->widget_border;
856 savelist_batch->reposition_window(x, y);
857 x += savelist_batch->get_w() + mwindow->theme->widget_border;
858 loadlist_batch->reposition_window(x, y);
859 y += loadlist_batch->get_h() + mwindow->theme->widget_border;
861 y1 = 15 + BC_GenericButton::calculate_h() + mwindow->theme->widget_border;
862 y2 = get_h() - y1 - batch_list->get_h();
863 y2 -= list_title->get_h() + mwindow->theme->widget_border;
865 x = mwindow->theme->batchrender_x1; y = y2;
866 list_title->reposition_window(x, y);
867 y += list_title->get_h() + mwindow->theme->widget_border;
868 batch_list->reposition_window(x, y, w - x - 10, h - y - y1);
869 y += batch_list->get_h() + mwindow->theme->widget_border;
871 start_button->reposition_window(x, y);
872 x = w / 2 - stop_button->get_w() / 2;
873 stop_button->reposition_window(x, y);
874 x = w - cancel_button->get_w() - 10;
875 cancel_button->reposition_window(x, y);
879 int BatchRenderGUI::translation_event()
881 mwindow->session->batchrender_x = get_x();
882 mwindow->session->batchrender_y = get_y();
886 int BatchRenderGUI::close_event()
888 // Stop batch rendering
890 thread->stop_rendering();
891 lock_window("BatchRenderGUI::close_event");
896 void BatchRenderGUI::create_list(int update_widget)
898 for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
900 list_columns[i].remove_all_objects();
903 for(int i = 0; i < thread->jobs.total; i++)
905 BatchRenderJob *job = thread->jobs.values[i];
906 char string[BCTEXTLEN];
907 BC_ListBoxItem *enabled = new BC_ListBoxItem(job->enabled ?
910 BC_ListBoxItem *item1 = new BC_ListBoxItem(job->asset->path);
911 BC_ListBoxItem *item2 = new BC_ListBoxItem(job->edl_path);
912 BC_ListBoxItem *item3;
914 item3 = new BC_ListBoxItem(
915 Units::totext(string,
919 item3 = new BC_ListBoxItem(_("Unknown"));
920 list_columns[0].append(enabled);
921 list_columns[1].append(item1);
922 list_columns[2].append(item2);
923 list_columns[3].append(item3);
924 if(i == thread->current_job)
926 enabled->set_selected(1);
927 item1->set_selected(1);
928 item2->set_selected(1);
929 item3->set_selected(1);
931 if(i == thread->rendering_job)
933 enabled->set_color(RED);
934 item1->set_color(RED);
935 item2->set_color(RED);
936 item3->set_color(RED);
942 batch_list->update(list_columns,
944 thread->column_width,
946 batch_list->get_xposition(),
947 batch_list->get_yposition(),
948 batch_list->get_highlighted_item(), // Flat index of item cursor is over
949 1, // set all autoplace flags to 1
954 void BatchRenderGUI::change_job()
956 BatchRenderJob *job = thread->get_current_job();
957 format_tools->update(job->asset, &job->strategy);
958 edl_path_text->update(job->edl_path);
968 BatchFormat::BatchFormat(MWindow *mwindow,
971 : FormatTools(mwindow, gui, asset)
974 this->mwindow = mwindow;
977 BatchFormat::~BatchFormat()
982 int BatchFormat::handle_event()
998 BatchRenderEDLPath::BatchRenderEDLPath(BatchRenderThread *thread,
1009 this->thread = thread;
1013 int BatchRenderEDLPath::handle_event()
1016 calculate_suggestions(thread->file_entries);
1018 strcpy(thread->get_current_edl(), get_text());
1019 thread->gui->create_list(1);
1028 BatchRenderNew::BatchRenderNew(BatchRenderThread *thread,
1031 : BC_GenericButton(x, y, _("New"))
1033 this->thread = thread;
1036 int BatchRenderNew::handle_event()
1042 BatchRenderDelete::BatchRenderDelete(BatchRenderThread *thread,
1045 : BC_GenericButton(x, y, _("Delete"))
1047 this->thread = thread;
1050 int BatchRenderDelete::handle_event()
1052 thread->delete_job();
1058 BatchRenderSaveList::BatchRenderSaveList(BatchRenderThread *thread,
1061 : BC_GenericButton(x, y, _("Save List"))
1063 this->thread = thread;
1064 set_tooltip(_("Save a Batch Render List"));
1066 startup_lock = new Mutex("BatchRenderSaveList::startup_lock");
1069 BatchRenderSaveList::~BatchRenderSaveList()
1071 startup_lock->lock("BatchRenderSaveList::~BrowseButton");
1076 gui->unlock_window();
1078 startup_lock->unlock();
1080 delete startup_lock;
1083 int BatchRenderSaveList::handle_event()
1085 if(Thread::running())
1090 gui->raise_window();
1091 gui->unlock_window();
1095 startup_lock->lock("BatchRenderSaveList::handle_event 1");
1097 startup_lock->lock("BatchRenderSaveList::handle_event 2");
1098 startup_lock->unlock();
1102 void BatchRenderSaveList::run()
1104 char default_path[BCTEXTLEN];
1105 sprintf(default_path, "~");
1106 BC_FileBox filewindow(100,
1108 this->thread->mwindow->defaults->get("DEFAULT_BATCHLOADPATH", default_path),
1109 _("Save Batch Render List"),
1110 _("Enter a Batch Render filename to save as:"),
1118 startup_lock->unlock();
1119 filewindow.create_objects();
1121 int result2 = filewindow.run_window();
1125 this->thread->save_jobs(filewindow.get_submitted_path());
1126 this->thread->mwindow->defaults->update("DEFAULT_BATCHLOADPATH", filewindow.get_submitted_path());
1129 this->thread->gui->flush();
1130 startup_lock->lock("BatchRenderLoadList::run");
1132 startup_lock->unlock();
1135 int BatchRenderSaveList::keypress_event() {
1136 if (get_keypress() == 's' ||
1137 get_keypress() == 'S') return handle_event();
1144 BatchRenderLoadList::BatchRenderLoadList(BatchRenderThread *thread,
1147 : BC_GenericButton(x, y, _("Load List")),
1150 this->thread = thread;
1151 set_tooltip(_("Load a previously saved Batch Render List"));
1153 startup_lock = new Mutex("BatchRenderLoadList::startup_lock");
1156 BatchRenderLoadList::~BatchRenderLoadList()
1158 startup_lock->lock("BatchRenderLoadList::~BrowseButton");
1163 gui->unlock_window();
1165 startup_lock->unlock();
1167 delete startup_lock;
1170 int BatchRenderLoadList::handle_event()
1172 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 BC_FileBox filewindow(100,
1195 this->thread->mwindow->defaults->get("DEFAULT_BATCHLOADPATH", default_path),
1196 _("Load Batch Render List"),
1197 _("Enter a Batch Render filename to load from:"),
1205 startup_lock->unlock();
1206 filewindow.create_objects();
1208 int result2 = filewindow.run_window();
1212 this->thread->load_jobs(filewindow.get_submitted_path(),this->thread->mwindow->preferences);
1213 this->thread->gui->create_list(1);
1214 this->thread->mwindow->defaults->update("DEFAULT_BATCHLOADPATH", filewindow.get_submitted_path());
1217 this->thread->gui->flush();
1218 startup_lock->lock("BatchRenderLoadList::run");
1220 startup_lock->unlock();
1223 int BatchRenderLoadList::keypress_event() {
1224 if (get_keypress() == 'o' ||
1225 get_keypress() == 'O') return handle_event();
1229 BatchRenderCurrentEDL::BatchRenderCurrentEDL(BatchRenderThread *thread,
1232 : BC_GenericButton(x, y, _("Use Current EDL"))
1234 this->thread = thread;
1237 int BatchRenderCurrentEDL::handle_event()
1239 thread->use_current_edl();
1243 BatchRenderUpdateEDL::BatchRenderUpdateEDL(BatchRenderThread *thread,
1246 : BC_GenericButton(x, y, _("Save to EDL Path"))
1248 this->thread = thread;
1251 int BatchRenderUpdateEDL::handle_event()
1253 thread->update_selected_edl();
1260 BatchRenderList::BatchRenderList(BatchRenderThread *thread,
1270 thread->gui->list_columns,
1272 thread->column_width,
1273 BATCHRENDER_COLUMNS,
1280 this->thread = thread;
1282 set_process_drag(0);
1285 int BatchRenderList::handle_event()
1290 int BatchRenderList::selection_changed()
1292 thread->current_job = get_selection_number(0, 0);
1293 thread->gui->change_job();
1294 if(get_cursor_x() < thread->column_width[0])
1296 BatchRenderJob *job = thread->get_current_job();
1297 job->enabled = !job->enabled;
1298 thread->gui->create_list(1);
1303 int BatchRenderList::column_resize_event()
1305 for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
1307 thread->column_width[i] = get_column_width(i);
1312 int BatchRenderList::drag_start_event()
1314 if(BC_ListBox::drag_start_event())
1323 int BatchRenderList::drag_motion_event()
1325 if(BC_ListBox::drag_motion_event())
1332 int BatchRenderList::drag_stop_event()
1336 int src = get_selection_number(0, 0);
1337 int dst = get_highlighted_item();
1340 thread->move_batch(src, dst);
1342 BC_ListBox::drag_stop_event();
1359 BatchRenderStart::BatchRenderStart(BatchRenderThread *thread,
1362 : BC_GenericButton(x,
1366 this->thread = thread;
1369 int BatchRenderStart::handle_event()
1371 thread->start_rendering();
1375 BatchRenderStop::BatchRenderStop(BatchRenderThread *thread,
1378 : BC_GenericButton(x,
1382 this->thread = thread;
1385 int BatchRenderStop::handle_event()
1388 thread->stop_rendering();
1389 lock_window("BatchRenderStop::handle_event");
1394 BatchRenderCancel::BatchRenderCancel(BatchRenderThread *thread,
1397 : BC_GenericButton(x,
1401 this->thread = thread;
1404 int BatchRenderCancel::handle_event()
1407 thread->stop_rendering();
1408 lock_window("BatchRenderCancel::handle_event");
1409 thread->gui->set_done(1);
1413 int BatchRenderCancel::keypress_event()
1415 if(get_keypress() == ESC)
1418 thread->stop_rendering();
1419 lock_window("BatchRenderCancel::keypress_event");
1420 thread->gui->set_done(1);