r689: Fixed that changes made by dragging a control would often store each
[cinelerra_cv.git] / cinelerra / batchrender.C
blob0bdacfbd6ce5bf834b5ff52774124bb5e62834f7
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                         for(int j = 0; j < packages->get_total_packages(); j++)
463                         {
464                                 RenderPackage *package = packages->get_package(j);
465                                 paths->append(strdup(package->path));
466                         }
468 // Delete package harness
469                         delete packages;
470                         delete command;
471                         delete file;
472                 }
473         }
477 void BatchRenderThread::start_rendering(char *config_path,
478         char *batch_path)
480         Defaults *boot_defaults;
481         Preferences *preferences;
482         Render *render;
483         ArrayList<PluginServer*> *plugindb;
485 // Initialize stuff which MWindow does.
486         MWindow::init_defaults(boot_defaults, config_path);
487         load_defaults(boot_defaults);
488         preferences = new Preferences;
489         preferences->load_defaults(boot_defaults);
490         MWindow::init_plugins(preferences, plugindb, 0);
492         load_jobs(batch_path, preferences);
493         save_jobs(batch_path);
494         save_defaults(boot_defaults);
496 // Test EDL files for existence
497         if(test_edl_files()) return;
500 // Predict all destination paths
501         ArrayList<char*> paths;
502         calculate_dest_paths(&paths,
503                 preferences,
504                 plugindb);
506         int result = ConfirmSave::test_files(0, &paths);
507 // Abort on any existing file because it's so hard to set this up.
508         if(result) return;
510         render = new Render(0);
511         render->start_batches(&jobs, 
512                 boot_defaults,
513                 preferences,
514                 plugindb);
517 void BatchRenderThread::start_rendering()
519         if(is_rendering) return;
521         is_rendering = 1;
522         char path[BCTEXTLEN];
523         path[0] = 0;
524         save_jobs(path);
525         save_defaults(mwindow->defaults);
526         gui->new_batch->disable();
527         gui->delete_batch->disable();
529 // Test EDL files for existence
530         if(test_edl_files()) return;
532 // Predict all destination paths
533         ArrayList<char*> paths;
534         calculate_dest_paths(&paths,
535                 mwindow->preferences,
536                 mwindow->plugindb);
538 // Test destination files for overwrite
539         int result = ConfirmSave::test_files(mwindow, &paths);
540         paths.remove_all_objects();
542 // User cancelled
543         if(result)
544         {
545                 is_rendering = 0;
546                 gui->new_batch->enable();
547                 gui->delete_batch->enable();
548                 return;
549         }
551         mwindow->render->start_batches(&jobs);
554 void BatchRenderThread::stop_rendering()
556         if(!is_rendering) return;
557         mwindow->render->stop_operation();
558         is_rendering = 0;
561 void BatchRenderThread::update_active(int number)
563         gui->lock_window("BatchRenderThread::update_active");
564         if(number >= 0)
565         {
566                 current_job = number;
567                 rendering_job = number;
568         }
569         else
570         {
571                 rendering_job = -1;
572                 is_rendering = 0;
573         }
574         gui->create_list(1);
575         gui->unlock_window();
578 void BatchRenderThread::update_done(int number, 
579         int create_list, 
580         double elapsed_time)
582         gui->lock_window("BatchRenderThread::update_done");
583         if(number < 0)
584         {
585                 gui->new_batch->enable();
586                 gui->delete_batch->enable();
587         }
588         else
589         {
590                 jobs.values[number]->enabled = 0;
591                 jobs.values[number]->elapsed = elapsed_time;
592                 if(create_list) gui->create_list(1);
593         }
594         gui->unlock_window();
597 void BatchRenderThread::move_batch(int src, int dst)
599         BatchRenderJob *src_job = jobs.values[src];
600         if(dst < 0) dst = jobs.total - 1;
602         if(dst != src)
603         {
604                 for(int i = src; i < jobs.total - 1; i++)
605                         jobs.values[i] = jobs.values[i + 1];
606 //              if(dst > src) dst--;
607                 for(int i = jobs.total - 1; i > dst; i--)
608                         jobs.values[i] = jobs.values[i - 1];
609                 jobs.values[dst] = src_job;
610                 gui->create_list(1);
611         }
622 BatchRenderGUI::BatchRenderGUI(MWindow *mwindow, 
623         BatchRenderThread *thread,
624         int x,
625         int y,
626         int w,
627         int h)
628  : BC_Window(PROGRAM_NAME ": Batch Render", 
629         x,
630         y,
631         w, 
632         h, 
633         50, 
634         50, 
635         1,
636         0, 
637         1)
639         this->mwindow = mwindow;
640         this->thread = thread;
643 BatchRenderGUI::~BatchRenderGUI()
645         delete format_tools;
649 void BatchRenderGUI::create_objects()
651         mwindow->theme->get_batchrender_sizes(this, get_w(), get_h());
652         create_list(0);
654         int x = mwindow->theme->batchrender_x1;
655         int y = 5;
656         int x1 = mwindow->theme->batchrender_x1;
657         int x2 = mwindow->theme->batchrender_x2;
658         int x3 = mwindow->theme->batchrender_x3;
659         int y1 = y;
660         int y2;
662 // output file
663         add_subwindow(output_path_title = new BC_Title(x1, y, _("Output path:")));
664         y += 20;
665         format_tools = new BatchFormat(mwindow,
666                                         this, 
667                                         thread->get_current_asset());
668         format_tools->create_objects(x, 
669                                                 y, 
670                                                 1, 
671                                                 1, 
672                                                 1, 
673                                                 1, 
674                                                 0, 
675                                                 1, 
676                                                 0, 
677                                                 0, 
678                                                 &thread->get_current_job()->strategy, 
679                                                 0);
681         x2 = x;
682         y2 = y + 10;
683         x += format_tools->get_w();
684         y = y1;
685         x1 = x;
686         x3 = x + 80;
688 // input EDL
689         x = x1;
690         add_subwindow(edl_path_title = new BC_Title(x, y, _("EDL Path:")));
691         y += 20;
692         add_subwindow(edl_path_text = new BatchRenderEDLPath(
693                 thread, 
694                 x, 
695                 y, 
696                 get_w() - x - 40, 
697                 thread->get_current_edl()));
699         x += edl_path_text->get_w();
700         add_subwindow(edl_path_browse = new BrowseButton(
701                 mwindow,
702                 this,
703                 edl_path_text, 
704                 x, 
705                 y, 
706                 thread->get_current_edl(),
707                 _("Input EDL"),
708                 _("Select an EDL to load:"),
709                 0));
711         x = x1;
713         y += 30;
714         add_subwindow(new_batch = new BatchRenderNew(thread, 
715                 x, 
716                 y));
717         x += new_batch->get_w() + 10;
719         add_subwindow(delete_batch = new BatchRenderDelete(thread, 
720                 x, 
721                 y));
722         x += delete_batch->get_w() + 10;
724         x = x2;
725         y = y2;
726         add_subwindow(list_title = new BC_Title(x, y, _("Batches to render:")));
727         y += 20;
728         add_subwindow(batch_list = new BatchRenderList(thread, 
729                 x, 
730                 y,
731                 get_w() - x - 10,
732                 get_h() - y - BC_GenericButton::calculate_h() - 15));
734         y += batch_list->get_h() + 10;
735         add_subwindow(start_button = new BatchRenderStart(thread, 
736             x, 
737             y));
738         x = get_w() / 2 -
739                 BC_GenericButton::calculate_w(this, _("Stop")) / 2;
740         add_subwindow(stop_button = new BatchRenderStop(thread, 
741                 x, 
742                 y));
743         x = get_w() - 
744                 BC_GenericButton::calculate_w(this, _("Cancel")) - 
745                 10;
746         add_subwindow(cancel_button = new BatchRenderCancel(thread, 
747                 x, 
748                 y));
750         show_window();
753 int BatchRenderGUI::resize_event(int w, int h)
755         mwindow->session->batchrender_w = w;
756         mwindow->session->batchrender_h = h;
757         mwindow->theme->get_batchrender_sizes(this, w, h);
759         int x = mwindow->theme->batchrender_x1;
760         int y = 5;
761         int x1 = mwindow->theme->batchrender_x1;
762         int x2 = mwindow->theme->batchrender_x2;
763         int x3 = mwindow->theme->batchrender_x3;
764         int y1 = y;
765         int y2;
767         output_path_title->reposition_window(x1, y);
768         y += 20;
769         format_tools->reposition_window(x, y);
770         x2 = x;
771         y2 = y + 10;
772         y = y1;
773         x += format_tools->get_w();
774         x1 = x;
775         x3 = x + 80;
777         x = x1;
778         edl_path_title->reposition_window(x, y);
779         y += 20;
780         edl_path_text->reposition_window(x, y, w - x - 40);
781         x += edl_path_text->get_w();
782         edl_path_browse->reposition_window(x, y);
784         x = x1;
785 //      y += 30;
786 //      status_title->reposition_window(x, y);
787 //      x = x3;
788 //      status_text->reposition_window(x, y);
789 //      x = x1;
790 //      y += 30;
791 //      progress_bar->reposition_window(x, y, w - x - 10);
793         y += 30;
794         new_batch->reposition_window(x, y);
795         x += new_batch->get_w() + 10;
796         delete_batch->reposition_window(x, y);
797         x += delete_batch->get_w() + 10;
799         x = x2;
800         y = y2;
801         int y_margin = get_h() - batch_list->get_h();
802         list_title->reposition_window(x, y);
803         y += 20;
804         batch_list->reposition_window(x, y, w - x - 10, h - y_margin);
806         y += batch_list->get_h() + 10;
807         start_button->reposition_window(x, y);
808         x = w / 2 - 
809                 stop_button->get_w() / 2;
810         stop_button->reposition_window(x, y);
811         x = w -
812                 cancel_button->get_w() - 
813                 10;
814         cancel_button->reposition_window(x, y);
815         return 1;
818 int BatchRenderGUI::translation_event()
820         mwindow->session->batchrender_x = get_x();
821         mwindow->session->batchrender_y = get_y();
822         return 1;
825 int BatchRenderGUI::close_event()
827 // Stop batch rendering
828         unlock_window();
829         thread->stop_rendering();
830         lock_window("BatchRenderGUI::close_event");
831         set_done(1);
832         return 1;
835 void BatchRenderGUI::create_list(int update_widget)
837         for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
838         {
839                 list_columns[i].remove_all_objects();
840         }
842         for(int i = 0; i < thread->jobs.total; i++)
843         {
844                 BatchRenderJob *job = thread->jobs.values[i];
845                 char string[BCTEXTLEN];
846                 BC_ListBoxItem *enabled = new BC_ListBoxItem(job->enabled ? 
847                         (char*)"X" : 
848                         (char*)" ");
849                 BC_ListBoxItem *item1 = new BC_ListBoxItem(job->asset->path);
850                 BC_ListBoxItem *item2 = new BC_ListBoxItem(job->edl_path);
851                 BC_ListBoxItem *item3;
852                 if(job->elapsed)
853                         item3 = new BC_ListBoxItem(
854                                 Units::totext(string,
855                                         job->elapsed,
856                                         TIME_HMS2));
857                 else
858                         item3 = new BC_ListBoxItem(_("Unknown"));
859                 list_columns[0].append(enabled);
860                 list_columns[1].append(item1);
861                 list_columns[2].append(item2);
862                 list_columns[3].append(item3);
863                 if(i == thread->current_job)
864                 {
865                         enabled->set_selected(1);
866                         item1->set_selected(1);
867                         item2->set_selected(1);
868                         item3->set_selected(1);
869                 }
870                 if(i == thread->rendering_job)
871                 {
872                         enabled->set_color(RED);
873                         item1->set_color(RED);
874                         item2->set_color(RED);
875                         item3->set_color(RED);
876                 }
877         }
879         if(update_widget)
880         {
881                 batch_list->update(list_columns,
882                                                 list_titles,
883                                                 thread->column_width,
884                                                 BATCHRENDER_COLUMNS,
885                                                 batch_list->get_xposition(),
886                                                 batch_list->get_yposition(), 
887                                                 batch_list->get_highlighted_item(),  // Flat index of item cursor is over
888                                                 1,     // set all autoplace flags to 1
889                                                 1);
890         }
893 void BatchRenderGUI::change_job()
895         BatchRenderJob *job = thread->get_current_job();
896         format_tools->update(job->asset, &job->strategy);
897         edl_path_text->update(job->edl_path);
907 BatchFormat::BatchFormat(MWindow *mwindow,
908                         BatchRenderGUI *gui,
909                         Asset *asset)
910  : FormatTools(mwindow, gui, asset)
912         this->gui = gui;
913         this->mwindow = mwindow;
916 BatchFormat::~BatchFormat()
921 int BatchFormat::handle_event()
923         gui->create_list(1);
924         return 1;
937 BatchRenderEDLPath::BatchRenderEDLPath(BatchRenderThread *thread, 
938         int x, 
939         int y, 
940         int w, 
941         char *text)
942  : BC_TextBox(x, 
943                 y, 
944                 w, 
945                 1,
946                 text)
948         this->thread = thread;
952 int BatchRenderEDLPath::handle_event()
954         strcpy(thread->get_current_edl(), get_text());
955         thread->gui->create_list(1);
956         return 1;
964 BatchRenderNew::BatchRenderNew(BatchRenderThread *thread, 
965         int x, 
966         int y)
967  : BC_GenericButton(x, y, _("New"))
969         this->thread = thread;
972 int BatchRenderNew::handle_event()
974         thread->new_job();
975         return 1;
978 BatchRenderDelete::BatchRenderDelete(BatchRenderThread *thread, 
979         int x, 
980         int y)
981  : BC_GenericButton(x, y, _("Delete"))
983         this->thread = thread;
986 int BatchRenderDelete::handle_event()
988         thread->delete_job();
989         return 1;
997 BatchRenderList::BatchRenderList(BatchRenderThread *thread, 
998         int x, 
999         int y,
1000         int w,
1001         int h)
1002  : BC_ListBox(x, 
1003         y, 
1004         w, 
1005         h, 
1006         LISTBOX_TEXT,
1007         thread->gui->list_columns,
1008         list_titles,
1009         thread->column_width,
1010         BATCHRENDER_COLUMNS,
1011         0,
1012         0,
1013         LISTBOX_SINGLE,
1014         ICON_LEFT,
1015         1)
1017         this->thread = thread;
1018         dragging_item = 0;
1019         set_process_drag(0);
1022 int BatchRenderList::handle_event()
1024         return 1;
1027 int BatchRenderList::selection_changed()
1029         thread->current_job = get_selection_number(0, 0);
1030         thread->gui->change_job();
1031         if(get_cursor_x() < thread->column_width[0])
1032         {
1033                 BatchRenderJob *job = thread->get_current_job();
1034                 job->enabled = !job->enabled;
1035                 thread->gui->create_list(1);
1036         }
1037         return 1;
1040 int BatchRenderList::column_resize_event()
1042         for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
1043         {
1044                 thread->column_width[i] = get_column_width(i);
1045         }
1046         return 1;
1049 int BatchRenderList::drag_start_event()
1051         if(BC_ListBox::drag_start_event())
1052         {
1053                 dragging_item = 1;
1054                 return 1;
1055         }
1057         return 0;
1060 int BatchRenderList::drag_motion_event()
1062         if(BC_ListBox::drag_motion_event())
1063         {
1064                 return 1;
1065         }
1066         return 0;
1069 int BatchRenderList::drag_stop_event()
1071         if(dragging_item)
1072         {
1073                 int src = get_selection_number(0, 0);
1074                 int dst = get_highlighted_item();
1075                 if(src != dst)
1076                 {
1077                         thread->move_batch(src, dst);
1078                 }
1079                 BC_ListBox::drag_stop_event();
1080         }
1095 BatchRenderStart::BatchRenderStart(BatchRenderThread *thread, 
1096         int x, 
1097         int y)
1098  : BC_GenericButton(x, 
1099         y, 
1100         _("Start"))
1102         this->thread = thread;
1105 int BatchRenderStart::handle_event()
1107         thread->start_rendering();
1108         return 1;
1111 BatchRenderStop::BatchRenderStop(BatchRenderThread *thread, 
1112         int x, 
1113         int y)
1114  : BC_GenericButton(x, 
1115         y, 
1116         _("Stop"))
1118         this->thread = thread;
1121 int BatchRenderStop::handle_event()
1123         unlock_window();
1124         thread->stop_rendering();
1125         lock_window("BatchRenderStop::handle_event");
1126         return 1;
1130 BatchRenderCancel::BatchRenderCancel(BatchRenderThread *thread, 
1131         int x, 
1132         int y)
1133  : BC_GenericButton(x, 
1134         y, 
1135         _("Cancel"))
1137         this->thread = thread;
1140 int BatchRenderCancel::handle_event()
1142         unlock_window();
1143         thread->stop_rendering();
1144         lock_window("BatchRenderCancel::handle_event");
1145         thread->gui->set_done(1);
1146         return 1;
1149 int BatchRenderCancel::keypress_event()
1151         if(get_keypress() == ESC) 
1152         {
1153                 unlock_window();
1154                 thread->stop_rendering();
1155                 lock_window("BatchRenderCancel::keypress_event");
1156                 thread->gui->set_done(1);
1157                 return 1;
1158         }
1159         return 0;