r820: Move from x-devb to xorg-dev
[cinelerra_cv/mob.git] / cinelerra / batchrender.C
blobc8d4a214178861024ebf20a42db98064e14fc43f
1 #include "asset.h"
2 #include "batchrender.h"
3 #include "bcsignals.h"
4 #include "confirmsave.h"
5 #include "defaults.h"
6 #include "edl.h"
7 #include "edlsession.h"
8 #include "errorbox.h"
9 #include "filesystem.h"
10 #include "filexml.h"
11 #include "keys.h"
12 #include "language.h"
13 #include "mainsession.h"
14 #include "mwindow.h"
15 #include "mwindowgui.h"
16 #include "packagedispatcher.h"
17 #include "packagerenderer.h"
18 #include "preferences.h"
19 #include "render.h"
20 #include "theme.h"
21 #include "transportque.h"
22 #include "vframe.h"
28 static char *list_titles[] = 
30         N_("Enabled"), 
31         N_("Output"),
32         N_("EDL"),
33         N_("Elapsed")
36 static int list_widths[] =
38         50,
39         100,
40         200,
41         100
44 BatchRenderMenuItem::BatchRenderMenuItem(MWindow *mwindow)
45  : BC_MenuItem(_("Batch Render..."), "Shift-B", 'B')
47         set_shift(1); 
48         this->mwindow = mwindow;
51 int BatchRenderMenuItem::handle_event()
53         mwindow->batch_render->start();
54         return 1;
64 BatchRenderJob::BatchRenderJob(Preferences *preferences)
66         this->preferences = preferences;
67         asset = new Asset;
68         edl_path[0] = 0;
69         strategy = 0;
70         enabled = 1;
71         elapsed = 0;
74 BatchRenderJob::~BatchRenderJob()
76         delete asset;
79 void BatchRenderJob::copy_from(BatchRenderJob *src)
81         asset->copy_from(src->asset, 0);
82         strcpy(edl_path, src->edl_path);
83         strategy = src->strategy;
84         enabled = src->enabled;
85         elapsed = 0;
88 void BatchRenderJob::load(FileXML *file)
90         int result = 0;
92         edl_path[0] = 0;
93         file->tag.get_property("EDL_PATH", edl_path);
94         strategy = file->tag.get_property("STRATEGY", strategy);
95         enabled = file->tag.get_property("ENABLED", enabled);
96         elapsed = file->tag.get_property("ELAPSED", elapsed);
97         fix_strategy();
99         result = file->read_tag();
100         if(!result)
101         {
102                 if(file->tag.title_is("ASSET"))
103                 {
104                         file->tag.get_property("SRC", asset->path);
105                         asset->read(file, 0);
106 // The compression parameters are stored in the defaults to reduce
107 // coding maintenance.  The defaults must now be stuffed into the XML for
108 // unique storage.
109                         Defaults defaults;
110                         defaults.load_string(file->read_text());
111                         asset->load_defaults(&defaults,
112                                 "",
113                                 0,
114                                 1,
115                                 0,
116                                 0,
117                                 0);
118                 }
119         }
122 void BatchRenderJob::save(FileXML *file)
124 TRACE("BatchRenderJob::save 1");
125         file->tag.set_property("EDL_PATH", edl_path);
126 TRACE("BatchRenderJob::save 1");
127         file->tag.set_property("STRATEGY", strategy);
128 TRACE("BatchRenderJob::save 1");
129         file->tag.set_property("ENABLED", enabled);
130 TRACE("BatchRenderJob::save 1");
131         file->tag.set_property("ELAPSED", elapsed);
132 TRACE("BatchRenderJob::save 1");
133         file->append_tag();
134 TRACE("BatchRenderJob::save 1");
135         file->append_newline();
136 TRACE("BatchRenderJob::save 1");
137         asset->write(file,
138                 0,
139                 "");
141 // The compression parameters are stored in the defaults to reduce
142 // coding maintenance.  The defaults must now be stuffed into the XML for
143 // unique storage.
144         Defaults defaults;
145         asset->save_defaults(&defaults, 
146                 "",
147                 0,
148                 1,
149                 0,
150                 0,
151                 0);
152         char *string;
153         defaults.save_string(string);
154         file->append_text(string);
155         delete [] string;
156 TRACE("BatchRenderJob::save 1");
157         file->tag.set_title("/JOB");
158 TRACE("BatchRenderJob::save 1");
159         file->append_tag();
160 TRACE("BatchRenderJob::save 1");
161         file->append_newline();
162 TRACE("BatchRenderJob::save 10");
165 void BatchRenderJob::fix_strategy()
167         strategy = Render::fix_strategy(strategy, preferences->use_renderfarm);
179 BatchRenderThread::BatchRenderThread(MWindow *mwindow)
180  : BC_DialogThread()
182         this->mwindow = mwindow;
183         current_job = 0;
184         rendering_job = -1;
185         is_rendering = 0;
186         default_job = 0;
189 BatchRenderThread::BatchRenderThread()
190  : BC_DialogThread()
192         mwindow = 0;
193         current_job = 0;
194         rendering_job = -1;
195         is_rendering = 0;
196         default_job = 0;
199 void BatchRenderThread::handle_close_event(int result)
201 // Save settings
202 TRACE("BatchRenderThread::handle_close_event 1");
203         char path[BCTEXTLEN];
204 TRACE("BatchRenderThread::handle_close_event 1");
205         path[0] = 0;
206 TRACE("BatchRenderThread::handle_close_event 1");
207         save_jobs(path);
208 TRACE("BatchRenderThread::handle_close_event 1");
209         save_defaults(mwindow->defaults);
210 TRACE("BatchRenderThread::handle_close_event 1");
211         delete default_job;
212 TRACE("BatchRenderThread::handle_close_event 1");
213         default_job = 0;
214 TRACE("BatchRenderThread::handle_close_event 1");
215         jobs.remove_all_objects();
216 TRACE("BatchRenderThread::handle_close_event 100");
219 BC_Window* BatchRenderThread::new_gui()
221         current_start = 0.0;
222         current_end = 0.0;
223         default_job = new BatchRenderJob(mwindow->preferences);
225         char path[BCTEXTLEN];
226         path[0] = 0;
227         load_jobs(path, mwindow->preferences);
228         load_defaults(mwindow->defaults);
229         this->gui = new BatchRenderGUI(mwindow, 
230                 this,
231                 mwindow->session->batchrender_x,
232                 mwindow->session->batchrender_y,
233                 mwindow->session->batchrender_w,
234                 mwindow->session->batchrender_h);
235         this->gui->create_objects();
236         return this->gui;
240 void BatchRenderThread::load_jobs(char *path, Preferences *preferences)
242         FileXML file;
243         int result = 0;
245         jobs.remove_all_objects();
246         if(path[0])
247                 file.read_from_file(path);
248         else
249                 file.read_from_file(create_path(path));
251         while(!result)
252         {
253                 if(!(result = file.read_tag()))
254                 {
255                         if(file.tag.title_is("JOB"))
256                         {
257                                 BatchRenderJob *job;
258                                 jobs.append(job = new BatchRenderJob(preferences));
259                                 job->load(&file);
260                         }
261                 }
262         }
265 void BatchRenderThread::save_jobs(char *path)
267         FileXML file;
269         for(int i = 0; i < jobs.total; i++)
270         {
271                 file.tag.set_title("JOB");
272                 jobs.values[i]->save(&file);
273         }
275         if(path[0])
276                 file.write_to_file(path);
277         else
278                 file.write_to_file(create_path(path));
281 void BatchRenderThread::load_defaults(Defaults *defaults)
283         if(default_job)
284         {
285                 default_job->asset->load_defaults(defaults,
286                         "BATCHRENDER_",
287                         1,
288                         1,
289                         1,
290                         1,
291                         1);
292                 default_job->fix_strategy();
293         }
295         for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
296         {
297                 char string[BCTEXTLEN];
298                 sprintf(string, "BATCHRENDER_COLUMN%d", i);
299                 column_width[i] = defaults->get(string, list_widths[i]);
300         }
303 void BatchRenderThread::save_defaults(Defaults *defaults)
305         if(default_job)
306         {
307                 default_job->asset->save_defaults(defaults,
308                         "BATCHRENDER_",
309                         1,
310                         1,
311                         1,
312                         1,
313                         1);
314                 defaults->update("BATCHRENDER_STRATEGY", default_job->strategy);
315         }
316         for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
317         {
318                 char string[BCTEXTLEN];
319                 sprintf(string, "BATCHRENDER_COLUMN%d", i);
320                 defaults->update(string, column_width[i]);
321         }
322 //      defaults->update("BATCHRENDER_JOB", current_job);
323         if(mwindow)
324                 mwindow->save_defaults();
325         else
326                 defaults->save();
329 char* BatchRenderThread::create_path(char *string)
331         FileSystem fs;
332         sprintf(string, "%s", BCASTDIR);
333         fs.complete_path(string);
334         strcat(string, BATCH_PATH);
335         return string;
338 void BatchRenderThread::new_job()
340         BatchRenderJob *result = new BatchRenderJob(mwindow->preferences);
341         result->copy_from(get_current_job());
342         jobs.append(result);
343         current_job = jobs.total - 1;
344         gui->create_list(1);
345         gui->change_job();
348 void BatchRenderThread::delete_job()
350         if(current_job < jobs.total && current_job >= 0)
351         {
352                 jobs.remove_object_number(current_job);
353                 if(current_job > 0) current_job--;
354                 gui->create_list(1);
355                 gui->change_job();
356         }
359 BatchRenderJob* BatchRenderThread::get_current_job()
361         BatchRenderJob *result;
362         if(current_job >= jobs.total || current_job < 0)
363         {
364                 result = default_job;
365         }
366         else
367         {
368                 result = jobs.values[current_job];
369         }
370         return result;
374 Asset* BatchRenderThread::get_current_asset()
376         return get_current_job()->asset;
379 char* BatchRenderThread::get_current_edl()
381         return get_current_job()->edl_path;
385 // Test EDL files for existence
386 int BatchRenderThread::test_edl_files()
388         for(int i = 0; i < jobs.total; i++)
389         {
390                 if(jobs.values[i]->enabled)
391                 {
392                         FILE *fd = fopen(jobs.values[i]->edl_path, "r");
393                         if(!fd)
394                         {
395                                 char string[BCTEXTLEN];
396                                 sprintf(string, _("EDL %s not found.\n"), jobs.values[i]->edl_path);
397                                 if(mwindow)
398                                 {
399                                         ErrorBox error_box(PROGRAM_NAME ": Error",
400                                                 mwindow->gui->get_abs_cursor_x(1),
401                                                 mwindow->gui->get_abs_cursor_y(1));
402                                         error_box.create_objects(string);
403                                         error_box.run_window();
404                                         gui->new_batch->enable();
405                                         gui->delete_batch->enable();
406                                 }
407                                 else
408                                 {
409                                         fprintf(stderr, 
410                                                 "%s",
411                                                 string);
412                                 }
414                                 is_rendering = 0;
415                                 return 1;
416                         }
417                         else
418                         {
419                                 fclose(fd);
420                         }
421                 }
422         }
423         return 0;
426 void BatchRenderThread::calculate_dest_paths(ArrayList<char*> *paths,
427         Preferences *preferences,
428         ArrayList<PluginServer*> *plugindb)
430         for(int i = 0; i < jobs.total; i++)
431         {
432                 BatchRenderJob *job = jobs.values[i];
433                 if(job->enabled)
434                 {
435                         PackageDispatcher *packages = new PackageDispatcher;
437 // Load EDL
438                         TransportCommand *command = new TransportCommand;
439                         FileXML *file = new FileXML;
440                         file->read_from_file(job->edl_path);
442 // Use command to calculate range.
443                         command->command = NORMAL_FWD;
444                         command->get_edl()->load_xml(plugindb, 
445                                 file, 
446                                 LOAD_ALL);
447                         command->change_type = CHANGE_ALL;
448                         command->set_playback_range();
449                         command->adjust_playback_range();
451 // Create test packages
452                         packages->create_packages(mwindow,
453                                 command->get_edl(),
454                                 preferences,
455                                 job->strategy, 
456                                 job->asset, 
457                                 command->start_position, 
458                                 command->end_position,
459                                 0);
461 // Append output paths allocated to total
462                         packages->get_package_paths(paths);
464 // Delete package harness
465                         delete packages;
466                         delete command;
467                         delete file;
468                 }
469         }
473 void BatchRenderThread::start_rendering(char *config_path,
474         char *batch_path)
476         Defaults *boot_defaults;
477         Preferences *preferences;
478         Render *render;
479         ArrayList<PluginServer*> *plugindb;
481 // Initialize stuff which MWindow does.
482         MWindow::init_defaults(boot_defaults, config_path);
483         load_defaults(boot_defaults);
484         preferences = new Preferences;
485         preferences->load_defaults(boot_defaults);
486         MWindow::init_plugins(preferences, plugindb, 0);
488         load_jobs(batch_path, preferences);
489         save_jobs(batch_path);
490         save_defaults(boot_defaults);
492 // Test EDL files for existence
493         if(test_edl_files()) return;
496 // Predict all destination paths
497         ArrayList<char*> paths;
498         calculate_dest_paths(&paths,
499                 preferences,
500                 plugindb);
502         int result = ConfirmSave::test_files(0, &paths);
503         paths.remove_all_objects();
505 // Abort on any existing file because it's so hard to set this up.
506         if(result) return;
508         render = new Render(0);
509         render->start_batches(&jobs, 
510                 boot_defaults,
511                 preferences,
512                 plugindb);
515 void BatchRenderThread::start_rendering()
517         if(is_rendering) return;
519         is_rendering = 1;
520         char path[BCTEXTLEN];
521         path[0] = 0;
522         save_jobs(path);
523         save_defaults(mwindow->defaults);
524         gui->new_batch->disable();
525         gui->delete_batch->disable();
527 // Test EDL files for existence
528         if(test_edl_files()) return;
530 // Predict all destination paths
531         ArrayList<char*> paths;
532         calculate_dest_paths(&paths,
533                 mwindow->preferences,
534                 mwindow->plugindb);
536 // Test destination files for overwrite
537         int result = ConfirmSave::test_files(mwindow, &paths);
538         paths.remove_all_objects();
540 // User cancelled
541         if(result)
542         {
543                 is_rendering = 0;
544                 gui->new_batch->enable();
545                 gui->delete_batch->enable();
546                 return;
547         }
549         mwindow->render->start_batches(&jobs);
552 void BatchRenderThread::stop_rendering()
554         if(!is_rendering) return;
555         mwindow->render->stop_operation();
556         is_rendering = 0;
559 void BatchRenderThread::update_active(int number)
561         gui->lock_window("BatchRenderThread::update_active");
562         if(number >= 0)
563         {
564                 current_job = number;
565                 rendering_job = number;
566         }
567         else
568         {
569                 rendering_job = -1;
570                 is_rendering = 0;
571         }
572         gui->create_list(1);
573         gui->unlock_window();
576 void BatchRenderThread::update_done(int number, 
577         int create_list, 
578         double elapsed_time)
580         gui->lock_window("BatchRenderThread::update_done");
581         if(number < 0)
582         {
583                 gui->new_batch->enable();
584                 gui->delete_batch->enable();
585         }
586         else
587         {
588                 jobs.values[number]->enabled = 0;
589                 jobs.values[number]->elapsed = elapsed_time;
590                 if(create_list) gui->create_list(1);
591         }
592         gui->unlock_window();
595 void BatchRenderThread::move_batch(int src, int dst)
597         BatchRenderJob *src_job = jobs.values[src];
598         if(dst < 0) dst = jobs.total - 1;
600         if(dst != src)
601         {
602                 for(int i = src; i < jobs.total - 1; i++)
603                         jobs.values[i] = jobs.values[i + 1];
604 //              if(dst > src) dst--;
605                 for(int i = jobs.total - 1; i > dst; i--)
606                         jobs.values[i] = jobs.values[i - 1];
607                 jobs.values[dst] = src_job;
608                 gui->create_list(1);
609         }
620 BatchRenderGUI::BatchRenderGUI(MWindow *mwindow, 
621         BatchRenderThread *thread,
622         int x,
623         int y,
624         int w,
625         int h)
626  : BC_Window(PROGRAM_NAME ": Batch Render", 
627         x,
628         y,
629         w, 
630         h, 
631         50, 
632         50, 
633         1,
634         0, 
635         1)
637         this->mwindow = mwindow;
638         this->thread = thread;
641 BatchRenderGUI::~BatchRenderGUI()
643         delete format_tools;
647 void BatchRenderGUI::create_objects()
649         mwindow->theme->get_batchrender_sizes(this, get_w(), get_h());
650         create_list(0);
652         int x = mwindow->theme->batchrender_x1;
653         int y = 5;
654         int x1 = mwindow->theme->batchrender_x1;
655         int x2 = mwindow->theme->batchrender_x2;
656         int x3 = mwindow->theme->batchrender_x3;
657         int y1 = y;
658         int y2;
660 // output file
661         add_subwindow(output_path_title = new BC_Title(x1, y, _("Output path:")));
662         y += 20;
663         format_tools = new BatchFormat(mwindow,
664                                         this, 
665                                         thread->get_current_asset());
666         format_tools->create_objects(x, 
667                                                 y, 
668                                                 1, 
669                                                 1, 
670                                                 1, 
671                                                 1, 
672                                                 0, 
673                                                 1, 
674                                                 0, 
675                                                 0, 
676                                                 &thread->get_current_job()->strategy, 
677                                                 0);
679         x2 = x;
680         y2 = y + 10;
681         x += format_tools->get_w();
682         y = y1;
683         x1 = x;
684         x3 = x + 80;
686 // input EDL
687         x = x1;
688         add_subwindow(edl_path_title = new BC_Title(x, y, _("EDL Path:")));
689         y += 20;
690         add_subwindow(edl_path_text = new BatchRenderEDLPath(
691                 thread, 
692                 x, 
693                 y, 
694                 get_w() - x - 40, 
695                 thread->get_current_edl()));
697         x += edl_path_text->get_w();
698         add_subwindow(edl_path_browse = new BrowseButton(
699                 mwindow,
700                 this,
701                 edl_path_text, 
702                 x, 
703                 y, 
704                 thread->get_current_edl(),
705                 _("Input EDL"),
706                 _("Select an EDL to load:"),
707                 0));
709         x = x1;
711         y += 30;
712         add_subwindow(new_batch = new BatchRenderNew(thread, 
713                 x, 
714                 y));
715         x += new_batch->get_w() + 10;
717         add_subwindow(delete_batch = new BatchRenderDelete(thread, 
718                 x, 
719                 y));
720         x += delete_batch->get_w() + 10;
722         x = x2;
723         y = y2;
724         add_subwindow(list_title = new BC_Title(x, y, _("Batches to render:")));
725         y += 20;
726         add_subwindow(batch_list = new BatchRenderList(thread, 
727                 x, 
728                 y,
729                 get_w() - x - 10,
730                 get_h() - y - BC_GenericButton::calculate_h() - 15));
732         y += batch_list->get_h() + 10;
733         add_subwindow(start_button = new BatchRenderStart(thread, 
734             x, 
735             y));
736         x = get_w() / 2 -
737                 BC_GenericButton::calculate_w(this, _("Stop")) / 2;
738         add_subwindow(stop_button = new BatchRenderStop(thread, 
739                 x, 
740                 y));
741         x = get_w() - 
742                 BC_GenericButton::calculate_w(this, _("Cancel")) - 
743                 10;
744         add_subwindow(cancel_button = new BatchRenderCancel(thread, 
745                 x, 
746                 y));
748         show_window();
751 int BatchRenderGUI::resize_event(int w, int h)
753         mwindow->session->batchrender_w = w;
754         mwindow->session->batchrender_h = h;
755         mwindow->theme->get_batchrender_sizes(this, w, h);
757         int x = mwindow->theme->batchrender_x1;
758         int y = 5;
759         int x1 = mwindow->theme->batchrender_x1;
760         int x2 = mwindow->theme->batchrender_x2;
761         int x3 = mwindow->theme->batchrender_x3;
762         int y1 = y;
763         int y2;
765         output_path_title->reposition_window(x1, y);
766         y += 20;
767         format_tools->reposition_window(x, y);
768         x2 = x;
769         y2 = y + 10;
770         y = y1;
771         x += format_tools->get_w();
772         x1 = x;
773         x3 = x + 80;
775         x = x1;
776         edl_path_title->reposition_window(x, y);
777         y += 20;
778         edl_path_text->reposition_window(x, y, w - x - 40);
779         x += edl_path_text->get_w();
780         edl_path_browse->reposition_window(x, y);
782         x = x1;
783 //      y += 30;
784 //      status_title->reposition_window(x, y);
785 //      x = x3;
786 //      status_text->reposition_window(x, y);
787 //      x = x1;
788 //      y += 30;
789 //      progress_bar->reposition_window(x, y, w - x - 10);
791         y += 30;
792         new_batch->reposition_window(x, y);
793         x += new_batch->get_w() + 10;
794         delete_batch->reposition_window(x, y);
795         x += delete_batch->get_w() + 10;
797         x = x2;
798         y = y2;
799         int y_margin = get_h() - batch_list->get_h();
800         list_title->reposition_window(x, y);
801         y += 20;
802         batch_list->reposition_window(x, y, w - x - 10, h - y_margin);
804         y += batch_list->get_h() + 10;
805         start_button->reposition_window(x, y);
806         x = w / 2 - 
807                 stop_button->get_w() / 2;
808         stop_button->reposition_window(x, y);
809         x = w -
810                 cancel_button->get_w() - 
811                 10;
812         cancel_button->reposition_window(x, y);
813         return 1;
816 int BatchRenderGUI::translation_event()
818         mwindow->session->batchrender_x = get_x();
819         mwindow->session->batchrender_y = get_y();
820         return 1;
823 int BatchRenderGUI::close_event()
825 // Stop batch rendering
826         unlock_window();
827         thread->stop_rendering();
828         lock_window("BatchRenderGUI::close_event");
829         set_done(1);
830         return 1;
833 void BatchRenderGUI::create_list(int update_widget)
835         for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
836         {
837                 list_columns[i].remove_all_objects();
838         }
840         for(int i = 0; i < thread->jobs.total; i++)
841         {
842                 BatchRenderJob *job = thread->jobs.values[i];
843                 char string[BCTEXTLEN];
844                 BC_ListBoxItem *enabled = new BC_ListBoxItem(job->enabled ? 
845                         (char*)"X" : 
846                         (char*)" ");
847                 BC_ListBoxItem *item1 = new BC_ListBoxItem(job->asset->path);
848                 BC_ListBoxItem *item2 = new BC_ListBoxItem(job->edl_path);
849                 BC_ListBoxItem *item3;
850                 if(job->elapsed)
851                         item3 = new BC_ListBoxItem(
852                                 Units::totext(string,
853                                         job->elapsed,
854                                         TIME_HMS2));
855                 else
856                         item3 = new BC_ListBoxItem(_("Unknown"));
857                 list_columns[0].append(enabled);
858                 list_columns[1].append(item1);
859                 list_columns[2].append(item2);
860                 list_columns[3].append(item3);
861                 if(i == thread->current_job)
862                 {
863                         enabled->set_selected(1);
864                         item1->set_selected(1);
865                         item2->set_selected(1);
866                         item3->set_selected(1);
867                 }
868                 if(i == thread->rendering_job)
869                 {
870                         enabled->set_color(RED);
871                         item1->set_color(RED);
872                         item2->set_color(RED);
873                         item3->set_color(RED);
874                 }
875         }
877         if(update_widget)
878         {
879                 batch_list->update(list_columns,
880                                                 list_titles,
881                                                 thread->column_width,
882                                                 BATCHRENDER_COLUMNS,
883                                                 batch_list->get_xposition(),
884                                                 batch_list->get_yposition(), 
885                                                 batch_list->get_highlighted_item(),  // Flat index of item cursor is over
886                                                 1,     // set all autoplace flags to 1
887                                                 1);
888         }
891 void BatchRenderGUI::change_job()
893         BatchRenderJob *job = thread->get_current_job();
894         format_tools->update(job->asset, &job->strategy);
895         edl_path_text->update(job->edl_path);
905 BatchFormat::BatchFormat(MWindow *mwindow,
906                         BatchRenderGUI *gui,
907                         Asset *asset)
908  : FormatTools(mwindow, gui, asset)
910         this->gui = gui;
911         this->mwindow = mwindow;
914 BatchFormat::~BatchFormat()
919 int BatchFormat::handle_event()
921         gui->create_list(1);
922         return 1;
935 BatchRenderEDLPath::BatchRenderEDLPath(BatchRenderThread *thread, 
936         int x, 
937         int y, 
938         int w, 
939         char *text)
940  : BC_TextBox(x, 
941                 y, 
942                 w, 
943                 1,
944                 text)
946         this->thread = thread;
950 int BatchRenderEDLPath::handle_event()
952         strcpy(thread->get_current_edl(), get_text());
953         thread->gui->create_list(1);
954         return 1;
962 BatchRenderNew::BatchRenderNew(BatchRenderThread *thread, 
963         int x, 
964         int y)
965  : BC_GenericButton(x, y, _("New"))
967         this->thread = thread;
970 int BatchRenderNew::handle_event()
972         thread->new_job();
973         return 1;
976 BatchRenderDelete::BatchRenderDelete(BatchRenderThread *thread, 
977         int x, 
978         int y)
979  : BC_GenericButton(x, y, _("Delete"))
981         this->thread = thread;
984 int BatchRenderDelete::handle_event()
986         thread->delete_job();
987         return 1;
995 BatchRenderList::BatchRenderList(BatchRenderThread *thread, 
996         int x, 
997         int y,
998         int w,
999         int h)
1000  : BC_ListBox(x, 
1001         y, 
1002         w, 
1003         h, 
1004         LISTBOX_TEXT,
1005         thread->gui->list_columns,
1006         list_titles,
1007         thread->column_width,
1008         BATCHRENDER_COLUMNS,
1009         0,
1010         0,
1011         LISTBOX_SINGLE,
1012         ICON_LEFT,
1013         1)
1015         this->thread = thread;
1016         dragging_item = 0;
1017         set_process_drag(0);
1020 int BatchRenderList::handle_event()
1022         return 1;
1025 int BatchRenderList::selection_changed()
1027         thread->current_job = get_selection_number(0, 0);
1028         thread->gui->change_job();
1029         if(get_cursor_x() < thread->column_width[0])
1030         {
1031                 BatchRenderJob *job = thread->get_current_job();
1032                 job->enabled = !job->enabled;
1033                 thread->gui->create_list(1);
1034         }
1035         return 1;
1038 int BatchRenderList::column_resize_event()
1040         for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
1041         {
1042                 thread->column_width[i] = get_column_width(i);
1043         }
1044         return 1;
1047 int BatchRenderList::drag_start_event()
1049         if(BC_ListBox::drag_start_event())
1050         {
1051                 dragging_item = 1;
1052                 return 1;
1053         }
1055         return 0;
1058 int BatchRenderList::drag_motion_event()
1060         if(BC_ListBox::drag_motion_event())
1061         {
1062                 return 1;
1063         }
1064         return 0;
1067 int BatchRenderList::drag_stop_event()
1069         if(dragging_item)
1070         {
1071                 int src = get_selection_number(0, 0);
1072                 int dst = get_highlighted_item();
1073                 if(src != dst)
1074                 {
1075                         thread->move_batch(src, dst);
1076                 }
1077                 BC_ListBox::drag_stop_event();
1078         }
1093 BatchRenderStart::BatchRenderStart(BatchRenderThread *thread, 
1094         int x, 
1095         int y)
1096  : BC_GenericButton(x, 
1097         y, 
1098         _("Start"))
1100         this->thread = thread;
1103 int BatchRenderStart::handle_event()
1105         thread->start_rendering();
1106         return 1;
1109 BatchRenderStop::BatchRenderStop(BatchRenderThread *thread, 
1110         int x, 
1111         int y)
1112  : BC_GenericButton(x, 
1113         y, 
1114         _("Stop"))
1116         this->thread = thread;
1119 int BatchRenderStop::handle_event()
1121         unlock_window();
1122         thread->stop_rendering();
1123         lock_window("BatchRenderStop::handle_event");
1124         return 1;
1128 BatchRenderCancel::BatchRenderCancel(BatchRenderThread *thread, 
1129         int x, 
1130         int y)
1131  : BC_GenericButton(x, 
1132         y, 
1133         _("Cancel"))
1135         this->thread = thread;
1138 int BatchRenderCancel::handle_event()
1140         unlock_window();
1141         thread->stop_rendering();
1142         lock_window("BatchRenderCancel::handle_event");
1143         thread->gui->set_done(1);
1144         return 1;
1147 int BatchRenderCancel::keypress_event()
1149         if(get_keypress() == ESC) 
1150         {
1151                 unlock_window();
1152                 thread->stop_rendering();
1153                 lock_window("BatchRenderCancel::keypress_event");
1154                 thread->gui->set_done(1);
1155                 return 1;
1156         }
1157         return 0;