r193: Heroine Virutal's official release 1.1.9
[cinelerra_cv/ct.git] / hvirtual / cinelerra / batchrender.C
blob36f978d30f1893eeac6de895378f25a4dfa58468
1 #include "asset.h"
2 #include "batchrender.h"
3 #include "confirmsave.h"
4 #include "defaults.h"
5 #include "edl.h"
6 #include "edlsession.h"
7 #include "errorbox.h"
8 #include "filesystem.h"
9 #include "filexml.h"
10 #include "keys.h"
11 #include "language.h"
12 #include "mainsession.h"
13 #include "mwindow.h"
14 #include "mwindowgui.h"
15 #include "packagedispatcher.h"
16 #include "packagerenderer.h"
17 #include "preferences.h"
18 #include "render.h"
19 #include "theme.h"
20 #include "transportque.h"
21 #include "vframe.h"
27 static char *list_titles[] = 
29         "Enabled", 
30         "Output",
31         "EDL",
32         "Elapsed"
35 static int list_widths[] =
37         50,
38         100,
39         200,
40         100
43 BatchRenderMenuItem::BatchRenderMenuItem(MWindow *mwindow)
44  : BC_MenuItem(_("Batch Render..."))
46         this->mwindow = mwindow;
49 int BatchRenderMenuItem::handle_event()
51         mwindow->batch_render->start();
52         return 1;
62 BatchRenderJob::BatchRenderJob(Preferences *preferences)
64         this->preferences = preferences;
65         asset = new Asset;
66         edl_path[0] = 0;
67         strategy = 0;
68         enabled = 1;
69         elapsed = 0;
72 BatchRenderJob::~BatchRenderJob()
74         delete asset;
77 void BatchRenderJob::copy_from(BatchRenderJob *src)
79         asset->copy_from(src->asset, 0);
80         strcpy(edl_path, src->edl_path);
81         strategy = src->strategy;
82         enabled = src->enabled;
83         elapsed = 0;
86 void BatchRenderJob::load(FileXML *file)
88         int result = 0;
90         edl_path[0] = 0;
91         file->tag.get_property("EDL_PATH", edl_path);
92         strategy = file->tag.get_property("STRATEGY", strategy);
93         enabled = file->tag.get_property("ENABLED", enabled);
94         elapsed = file->tag.get_property("ELAPSED", elapsed);
95         fix_strategy();
97         result = file->read_tag();
98         if(!result)
99         {
100                 if(file->tag.title_is("ASSET"))
101                 {
102                         file->tag.get_property("SRC", asset->path);
103                         asset->read(file, 0);
104                 }
105         }
108 void BatchRenderJob::save(FileXML *file)
110         file->tag.set_property("EDL_PATH", edl_path);
111         file->tag.set_property("STRATEGY", strategy);
112         file->tag.set_property("ENABLED", enabled);
113         file->tag.set_property("ELAPSED", elapsed);
114         file->append_tag();
115         file->append_newline();
116         asset->write(file,
117                 0,
118                 "");
119         file->tag.set_title("/JOB");
120         file->append_tag();
121         file->append_newline();
124 void BatchRenderJob::fix_strategy()
126         strategy = Render::fix_strategy(strategy, preferences->use_renderfarm);
138 BatchRenderThread::BatchRenderThread(MWindow *mwindow)
139  : BC_DialogThread()
141         this->mwindow = mwindow;
142         current_job = 0;
143         rendering_job = -1;
144         is_rendering = 0;
145         default_job = 0;
148 BatchRenderThread::BatchRenderThread()
149  : BC_DialogThread()
151         mwindow = 0;
152         current_job = 0;
153         rendering_job = -1;
154         is_rendering = 0;
155         default_job = 0;
158 void BatchRenderThread::handle_close_event(int result)
160 // Save settings
161         char path[BCTEXTLEN];
162         path[0] = 0;
163         save_jobs(path);
164         save_defaults(mwindow->defaults);
165         delete default_job;
166         default_job = 0;
167         jobs.remove_all_objects();
170 BC_Window* BatchRenderThread::new_gui()
172         current_start = 0.0;
173         current_end = 0.0;
174         default_job = new BatchRenderJob(mwindow->preferences);
176         char path[BCTEXTLEN];
177         path[0] = 0;
178         load_jobs(path, mwindow->preferences);
179         load_defaults(mwindow->defaults);
180         this->gui = new BatchRenderGUI(mwindow, 
181                 this,
182                 mwindow->session->batchrender_x,
183                 mwindow->session->batchrender_y,
184                 mwindow->session->batchrender_w,
185                 mwindow->session->batchrender_h);
186         this->gui->create_objects();
187         return this->gui;
191 void BatchRenderThread::load_jobs(char *path, Preferences *preferences)
193         FileXML file;
194         int result = 0;
196         jobs.remove_all_objects();
197         if(path[0])
198                 file.read_from_file(path);
199         else
200                 file.read_from_file(create_path(path));
202         while(!result)
203         {
204                 if(!(result = file.read_tag()))
205                 {
206                         if(file.tag.title_is("JOB"))
207                         {
208                                 BatchRenderJob *job;
209                                 jobs.append(job = new BatchRenderJob(preferences));
210                                 job->load(&file);
211                         }
212                 }
213         }
216 void BatchRenderThread::save_jobs(char *path)
218         FileXML file;
220         for(int i = 0; i < jobs.total; i++)
221         {
222                 file.tag.set_title("JOB");
223                 jobs.values[i]->save(&file);
224         }
226         if(path[0])
227                 file.write_to_file(path);
228         else
229                 file.write_to_file(create_path(path));
232 void BatchRenderThread::load_defaults(Defaults *defaults)
234         if(default_job)
235         {
236                 default_job->asset->load_defaults(defaults,
237                         "BATCHRENDER_",
238                         1,
239                         1,
240                         1,
241                         1,
242                         1);
243                 default_job->fix_strategy();
244         }
246         for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
247         {
248                 char string[BCTEXTLEN];
249                 sprintf(string, "BATCHRENDER_COLUMN%d", i);
250                 column_width[i] = defaults->get(string, list_widths[i]);
251         }
254 void BatchRenderThread::save_defaults(Defaults *defaults)
256         if(default_job)
257         {
258                 default_job->asset->save_defaults(defaults,
259                         "BATCHRENDER_",
260                         1,
261                         1,
262                         1,
263                         1,
264                         1);
265                 defaults->update("BATCHRENDER_STRATEGY", default_job->strategy);
266         }
267         for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
268         {
269                 char string[BCTEXTLEN];
270                 sprintf(string, "BATCHRENDER_COLUMN%d", i);
271                 defaults->update(string, column_width[i]);
272         }
273 //      defaults->update("BATCHRENDER_JOB", current_job);
274         if(mwindow)
275                 mwindow->save_defaults();
276         else
277                 defaults->save();
280 char* BatchRenderThread::create_path(char *string)
282         FileSystem fs;
283         sprintf(string, "%s", BCASTDIR);
284         fs.complete_path(string);
285         strcat(string, BATCH_PATH);
286         return string;
289 void BatchRenderThread::new_job()
291         BatchRenderJob *result = new BatchRenderJob(mwindow->preferences);
292         result->copy_from(get_current_job());
293         jobs.append(result);
294         current_job = jobs.total - 1;
295         gui->create_list(1);
296         gui->change_job();
299 void BatchRenderThread::delete_job()
301         if(current_job < jobs.total && current_job >= 0)
302         {
303                 jobs.remove_object_number(current_job);
304                 if(current_job > 0) current_job--;
305                 gui->create_list(1);
306                 gui->change_job();
307         }
310 BatchRenderJob* BatchRenderThread::get_current_job()
312         BatchRenderJob *result;
313         if(current_job >= jobs.total || current_job < 0)
314         {
315                 result = default_job;
316         }
317         else
318         {
319                 result = jobs.values[current_job];
320         }
321         return result;
325 Asset* BatchRenderThread::get_current_asset()
327         return get_current_job()->asset;
330 char* BatchRenderThread::get_current_edl()
332         return get_current_job()->edl_path;
336 // Test EDL files for existence
337 int BatchRenderThread::test_edl_files()
339         for(int i = 0; i < jobs.total; i++)
340         {
341                 if(jobs.values[i]->enabled)
342                 {
343                         FILE *fd = fopen(jobs.values[i]->edl_path, "r");
344                         if(!fd)
345                         {
346                                 char string[BCTEXTLEN];
347                                 sprintf(string, _("EDL %s not found.\n"), jobs.values[i]->edl_path);
348                                 if(mwindow)
349                                 {
350                                         ErrorBox error_box(PROGRAM_NAME ": Error",
351                                                 mwindow->gui->get_abs_cursor_x(),
352                                                 mwindow->gui->get_abs_cursor_y());
353                                         error_box.create_objects(string);
354                                         error_box.run_window();
355                                         gui->new_batch->enable();
356                                         gui->delete_batch->enable();
357                                 }
358                                 else
359                                 {
360                                         fprintf(stderr, 
361                                                 "%s",
362                                                 string);
363                                 }
365                                 is_rendering = 0;
366                                 return 1;
367                         }
368                         else
369                         {
370                                 fclose(fd);
371                         }
372                 }
373         }
374         return 0;
377 void BatchRenderThread::calculate_dest_paths(ArrayList<char*> *paths,
378         Preferences *preferences,
379         ArrayList<PluginServer*> *plugindb)
381         for(int i = 0; i < jobs.total; i++)
382         {
383                 BatchRenderJob *job = jobs.values[i];
384                 if(job->enabled)
385                 {
386                         PackageDispatcher *packages = new PackageDispatcher;
388 // Load EDL
389                         TransportCommand *command = new TransportCommand;
390                         FileXML *file = new FileXML;
391                         file->read_from_file(job->edl_path);
393 // Use command to calculate range.
394                         command->command = NORMAL_FWD;
395                         command->get_edl()->load_xml(plugindb, 
396                                 file, 
397                                 LOAD_ALL);
398                         command->change_type = CHANGE_ALL;
399                         command->set_playback_range();
400                         command->adjust_playback_range();
402 // Create test packages
403                         packages->create_packages(mwindow,
404                                 command->get_edl(),
405                                 preferences,
406                                 job->strategy, 
407                                 job->asset, 
408                                 command->start_position, 
409                                 command->end_position,
410                                 0);
412 // Append output paths allocated to total
413                         for(int j = 0; j < packages->get_total_packages(); j++)
414                         {
415                                 RenderPackage *package = packages->get_package(j);
416                                 paths->append(strdup(package->path));
417                         }
419 // Delete package harness
420                         delete packages;
421                         delete command;
422                         delete file;
423                 }
424         }
428 void BatchRenderThread::start_rendering(char *config_path,
429         char *batch_path)
431         Defaults *boot_defaults;
432         Preferences *preferences;
433         Render *render;
434         ArrayList<PluginServer*> *plugindb;
436 // Initialize stuff which MWindow does.
437         MWindow::init_defaults(boot_defaults, config_path);
438         load_defaults(boot_defaults);
439         preferences = new Preferences;
440         preferences->load_defaults(boot_defaults);
441         MWindow::init_plugins(preferences, plugindb, 0);
443         load_jobs(batch_path, preferences);
444         save_jobs(batch_path);
445         save_defaults(boot_defaults);
447 // Test EDL files for existence
448         if(test_edl_files()) return;
451 // Predict all destination paths
452         ArrayList<char*> paths;
453         calculate_dest_paths(&paths,
454                 preferences,
455                 plugindb);
457         int result = ConfirmSave::test_files(0, &paths);
458 // Abort on any existing file because it's so hard to set this up.
459         if(result) return;
461         render = new Render(0);
462         render->start_batches(&jobs, 
463                 boot_defaults,
464                 preferences,
465                 plugindb);
468 void BatchRenderThread::start_rendering()
470         if(is_rendering) return;
472         is_rendering = 1;
473         char path[BCTEXTLEN];
474         path[0] = 0;
475         save_jobs(path);
476         save_defaults(mwindow->defaults);
477         gui->new_batch->disable();
478         gui->delete_batch->disable();
480 // Test EDL files for existence
481         if(test_edl_files()) return;
483 // Predict all destination paths
484         ArrayList<char*> paths;
485         calculate_dest_paths(&paths,
486                 mwindow->preferences,
487                 mwindow->plugindb);
489 // Test destination files for overwrite
490         int result = ConfirmSave::test_files(mwindow, &paths);
491         paths.remove_all_objects();
493 // User cancelled
494         if(result)
495         {
496                 is_rendering = 0;
497                 gui->new_batch->enable();
498                 gui->delete_batch->enable();
499                 return;
500         }
502         mwindow->render->start_batches(&jobs);
505 void BatchRenderThread::stop_rendering()
507         if(!is_rendering) return;
508         mwindow->render->stop_operation();
509         is_rendering = 0;
512 void BatchRenderThread::update_active(int number)
514         gui->lock_window("BatchRenderThread::update_active");
515         if(number >= 0)
516         {
517                 current_job = number;
518                 rendering_job = number;
519         }
520         else
521         {
522                 rendering_job = -1;
523                 is_rendering = 0;
524         }
525         gui->create_list(1);
526         gui->unlock_window();
529 void BatchRenderThread::update_done(int number, 
530         int create_list, 
531         double elapsed_time)
533         gui->lock_window("BatchRenderThread::update_done");
534         if(number < 0)
535         {
536                 gui->new_batch->enable();
537                 gui->delete_batch->enable();
538         }
539         else
540         {
541                 jobs.values[number]->enabled = 0;
542                 jobs.values[number]->elapsed = elapsed_time;
543                 if(create_list) gui->create_list(1);
544         }
545         gui->unlock_window();
548 void BatchRenderThread::move_batch(int src, int dst)
550         BatchRenderJob *src_job = jobs.values[src];
551         if(dst < 0) dst = jobs.total - 1;
553         if(dst != src)
554         {
555                 for(int i = src; i < jobs.total - 1; i++)
556                         jobs.values[i] = jobs.values[i + 1];
557 //              if(dst > src) dst--;
558                 for(int i = jobs.total - 1; i > dst; i--)
559                         jobs.values[i] = jobs.values[i - 1];
560                 jobs.values[dst] = src_job;
561                 gui->create_list(1);
562         }
573 BatchRenderGUI::BatchRenderGUI(MWindow *mwindow, 
574         BatchRenderThread *thread,
575         int x,
576         int y,
577         int w,
578         int h)
579  : BC_Window(PROGRAM_NAME ": Batch Render", 
580         x,
581         y,
582         w, 
583         h, 
584         50, 
585         50, 
586         1,
587         0, 
588         1)
590         this->mwindow = mwindow;
591         this->thread = thread;
594 BatchRenderGUI::~BatchRenderGUI()
596         delete format_tools;
600 void BatchRenderGUI::create_objects()
602         mwindow->theme->get_batchrender_sizes(this, get_w(), get_h());
603         create_list(0);
605         int x = mwindow->theme->batchrender_x1;
606         int y = 5;
607         int x1 = mwindow->theme->batchrender_x1;
608         int x2 = mwindow->theme->batchrender_x2;
609         int x3 = mwindow->theme->batchrender_x3;
610         int y1 = y;
611         int y2;
613 // output file
614         add_subwindow(output_path_title = new BC_Title(x1, y, _("Output path:")));
615         y += 20;
616         format_tools = new BatchFormat(mwindow,
617                                         this, 
618                                         thread->get_current_asset());
619         format_tools->create_objects(x, 
620                                                 y, 
621                                                 1, 
622                                                 1, 
623                                                 1, 
624                                                 1, 
625                                                 0, 
626                                                 1, 
627                                                 0, 
628                                                 0, 
629                                                 &thread->get_current_job()->strategy, 
630                                                 0);
632         x2 = x;
633         y2 = y + 10;
634         x += format_tools->get_w();
635         y = y1;
636         x1 = x;
637         x3 = x + 80;
639 // input EDL
640         x = x1;
641         add_subwindow(edl_path_title = new BC_Title(x, y, _("EDL Path:")));
642         y += 20;
643         add_subwindow(edl_path_text = new BatchRenderEDLPath(
644                 thread, 
645                 x, 
646                 y, 
647                 get_w() - x - 40, 
648                 thread->get_current_edl()));
650         x += edl_path_text->get_w();
651         add_subwindow(edl_path_browse = new BrowseButton(
652                 mwindow,
653                 this,
654                 edl_path_text, 
655                 x, 
656                 y, 
657                 thread->get_current_edl(),
658                 _("Input EDL"),
659                 _("Select an EDL to load:"),
660                 0));
662         x = x1;
664         y += 30;
665         add_subwindow(new_batch = new BatchRenderNew(thread, 
666                 x, 
667                 y));
668         x += new_batch->get_w() + 10;
670         add_subwindow(delete_batch = new BatchRenderDelete(thread, 
671                 x, 
672                 y));
673         x += delete_batch->get_w() + 10;
675         x = x2;
676         y = y2;
677         add_subwindow(list_title = new BC_Title(x, y, _("Batches to render:")));
678         y += 20;
679         add_subwindow(batch_list = new BatchRenderList(thread, 
680                 x, 
681                 y,
682                 get_w() - x - 10,
683                 get_h() - y - 50));
685         y += batch_list->get_h() + 10;
686         add_subwindow(start_button = new BatchRenderStart(thread, 
687             x, 
688             y));
689         x = get_w() / 2 -
690                 mwindow->theme->get_image_set("batch_render_stop")[0]->get_w() / 2;
691         add_subwindow(stop_button = new BatchRenderStop(thread, 
692                 x, 
693                 y));
694         x = get_w() - 
695                 mwindow->theme->get_image_set("batch_render_cancel")[0]->get_w() - 
696                 10;
697         add_subwindow(cancel_button = new BatchRenderCancel(thread, 
698                 x, 
699                 y));
701         show_window();
704 int BatchRenderGUI::resize_event(int w, int h)
706         mwindow->session->batchrender_w = w;
707         mwindow->session->batchrender_h = h;
708         mwindow->theme->get_batchrender_sizes(this, w, h);
710         int x = mwindow->theme->batchrender_x1;
711         int y = 5;
712         int x1 = mwindow->theme->batchrender_x1;
713         int x2 = mwindow->theme->batchrender_x2;
714         int x3 = mwindow->theme->batchrender_x3;
715         int y1 = y;
716         int y2;
718         output_path_title->reposition_window(x1, y);
719         y += 20;
720         format_tools->reposition_window(x, y);
721         x2 = x;
722         y2 = y + 10;
723         y = y1;
724         x += format_tools->get_w();
725         x1 = x;
726         x3 = x + 80;
728         x = x1;
729         edl_path_title->reposition_window(x, y);
730         y += 20;
731         edl_path_text->reposition_window(x, y, w - x - 40);
732         x += edl_path_text->get_w();
733         edl_path_browse->reposition_window(x, y);
735         x = x1;
736 //      y += 30;
737 //      status_title->reposition_window(x, y);
738 //      x = x3;
739 //      status_text->reposition_window(x, y);
740 //      x = x1;
741 //      y += 30;
742 //      progress_bar->reposition_window(x, y, w - x - 10);
744         y += 30;
745         new_batch->reposition_window(x, y);
746         x += new_batch->get_w() + 10;
747         delete_batch->reposition_window(x, y);
748         x += delete_batch->get_w() + 10;
750         x = x2;
751         y = y2;
752         list_title->reposition_window(x, y);
753         y += 20;
754         batch_list->reposition_window(x, y, w - x - 10, h - y - 50);
756         y += batch_list->get_h() + 10;
757         start_button->reposition_window(x, y);
758         x = w / 2 - 
759                 mwindow->theme->get_image_set("batch_render_stop")[0]->get_w() / 2;
760         stop_button->reposition_window(x, y);
761         x = w -
762                 mwindow->theme->get_image_set("batch_render_cancel")[0]->get_w() - 
763                 10;
764         cancel_button->reposition_window(x, y);
765         return 1;
768 int BatchRenderGUI::translation_event()
770         mwindow->session->batchrender_x = get_x();
771         mwindow->session->batchrender_y = get_y();
772         return 1;
775 int BatchRenderGUI::close_event()
777 // Stop batch rendering
778         unlock_window();
779         thread->stop_rendering();
780         lock_window("BatchRenderGUI::close_event");
781         set_done(1);
782         return 1;
785 void BatchRenderGUI::create_list(int update_widget)
787         for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
788         {
789                 list_columns[i].remove_all_objects();
790         }
792         for(int i = 0; i < thread->jobs.total; i++)
793         {
794                 BatchRenderJob *job = thread->jobs.values[i];
795                 char string[BCTEXTLEN];
796                 BC_ListBoxItem *enabled = new BC_ListBoxItem(job->enabled ? 
797                         (char*)"X" : 
798                         (char*)" ");
799                 BC_ListBoxItem *item1 = new BC_ListBoxItem(job->asset->path);
800                 BC_ListBoxItem *item2 = new BC_ListBoxItem(job->edl_path);
801                 BC_ListBoxItem *item3;
802                 if(job->elapsed)
803                         item3 = new BC_ListBoxItem(
804                                 Units::totext(string,
805                                         job->elapsed,
806                                         TIME_HMS2));
807                 else
808                         item3 = new BC_ListBoxItem(_("Unknown"));
809                 list_columns[0].append(enabled);
810                 list_columns[1].append(item1);
811                 list_columns[2].append(item2);
812                 list_columns[3].append(item3);
813                 if(i == thread->current_job)
814                 {
815                         enabled->set_selected(1);
816                         item1->set_selected(1);
817                         item2->set_selected(1);
818                         item3->set_selected(1);
819                 }
820                 if(i == thread->rendering_job)
821                 {
822                         enabled->set_color(RED);
823                         item1->set_color(RED);
824                         item2->set_color(RED);
825                         item3->set_color(RED);
826                 }
827         }
829         if(update_widget)
830         {
831                 batch_list->update(list_columns,
832                                                 list_titles,
833                                                 thread->column_width,
834                                                 BATCHRENDER_COLUMNS,
835                                                 batch_list->get_xposition(),
836                                                 batch_list->get_yposition(), 
837                                                 batch_list->get_highlighted_item(),  // Flat index of item cursor is over
838                                                 1,     // set all autoplace flags to 1
839                                                 1);
840         }
843 void BatchRenderGUI::change_job()
845         BatchRenderJob *job = thread->get_current_job();
846         format_tools->update(job->asset, &job->strategy);
847         edl_path_text->update(job->edl_path);
857 BatchFormat::BatchFormat(MWindow *mwindow,
858                         BatchRenderGUI *gui,
859                         Asset *asset)
860  : FormatTools(mwindow, gui, asset)
862         this->gui = gui;
863         this->mwindow = mwindow;
866 BatchFormat::~BatchFormat()
871 int BatchFormat::handle_event()
873         gui->create_list(1);
874         return 1;
887 BatchRenderEDLPath::BatchRenderEDLPath(BatchRenderThread *thread, 
888         int x, 
889         int y, 
890         int w, 
891         char *text)
892  : BC_TextBox(x, 
893                 y, 
894                 w, 
895                 1,
896                 text)
898         this->thread = thread;
902 int BatchRenderEDLPath::handle_event()
904         strcpy(thread->get_current_edl(), get_text());
905         thread->gui->create_list(1);
906         return 1;
914 BatchRenderNew::BatchRenderNew(BatchRenderThread *thread, 
915         int x, 
916         int y)
917  : BC_GenericButton(x, y, _("New"))
919         this->thread = thread;
922 int BatchRenderNew::handle_event()
924         thread->new_job();
925         return 1;
928 BatchRenderDelete::BatchRenderDelete(BatchRenderThread *thread, 
929         int x, 
930         int y)
931  : BC_GenericButton(x, y, _("Delete"))
933         this->thread = thread;
936 int BatchRenderDelete::handle_event()
938         thread->delete_job();
939         return 1;
947 BatchRenderList::BatchRenderList(BatchRenderThread *thread, 
948         int x, 
949         int y,
950         int w,
951         int h)
952  : BC_ListBox(x, 
953         y, 
954         w, 
955         h, 
956         LISTBOX_TEXT,
957         thread->gui->list_columns,
958         list_titles,
959         thread->column_width,
960         BATCHRENDER_COLUMNS,
961         0,
962         0,
963         LISTBOX_SINGLE,
964         ICON_LEFT,
965         1)
967         this->thread = thread;
968         dragging_item = 0;
969         set_process_drag(0);
972 int BatchRenderList::handle_event()
974         return 1;
977 int BatchRenderList::selection_changed()
979         thread->current_job = get_selection_number(0, 0);
980         thread->gui->change_job();
981         if(get_cursor_x() < thread->column_width[0])
982         {
983                 BatchRenderJob *job = thread->get_current_job();
984                 job->enabled = !job->enabled;
985                 thread->gui->create_list(1);
986         }
987         return 1;
990 int BatchRenderList::column_resize_event()
992         for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
993         {
994                 thread->column_width[i] = get_column_width(i);
995         }
996         return 1;
999 int BatchRenderList::drag_start_event()
1001         if(BC_ListBox::drag_start_event())
1002         {
1003                 dragging_item = 1;
1004                 return 1;
1005         }
1007         return 0;
1010 int BatchRenderList::drag_motion_event()
1012         if(BC_ListBox::drag_motion_event())
1013         {
1014                 return 1;
1015         }
1016         return 0;
1019 int BatchRenderList::drag_stop_event()
1021         if(dragging_item)
1022         {
1023                 int src = get_selection_number(0, 0);
1024                 int dst = get_highlighted_item();
1025                 if(src != dst)
1026                 {
1027                         thread->move_batch(src, dst);
1028                 }
1029                 BC_ListBox::drag_stop_event();
1030         }
1045 BatchRenderStart::BatchRenderStart(BatchRenderThread *thread, 
1046         int x, 
1047         int y)
1048  : BC_Button(x, 
1049         y, 
1050         thread->mwindow->theme->get_image_set(_("batch_render_start")))
1052         this->thread = thread;
1055 int BatchRenderStart::handle_event()
1057         thread->start_rendering();
1058         return 1;
1061 BatchRenderStop::BatchRenderStop(BatchRenderThread *thread, 
1062         int x, 
1063         int y)
1064  : BC_Button(x, 
1065         y, 
1066         thread->mwindow->theme->get_image_set(_("batch_render_stop")))
1068         this->thread = thread;
1071 int BatchRenderStop::handle_event()
1073         unlock_window();
1074         thread->stop_rendering();
1075         lock_window("BatchRenderStop::handle_event");
1076         return 1;
1080 BatchRenderCancel::BatchRenderCancel(BatchRenderThread *thread, 
1081         int x, 
1082         int y)
1083  : BC_Button(x, 
1084         y, 
1085         thread->mwindow->theme->get_image_set(_("batch_render_cancel")))
1087         this->thread = thread;
1090 int BatchRenderCancel::handle_event()
1092         unlock_window();
1093         thread->stop_rendering();
1094         lock_window("BatchRenderCancel::handle_event");
1095         thread->gui->set_done(1);
1096         return 1;
1099 int BatchRenderCancel::keypress_event()
1101         if(get_keypress() == ESC) 
1102         {
1103                 unlock_window();
1104                 thread->stop_rendering();
1105                 lock_window("BatchRenderCancel::keypress_event");
1106                 thread->gui->set_done(1);
1107                 return 1;
1108         }
1109         return 0;