• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files

hvirtual/cinelerra/batchrender.C

Go to the documentation of this file.
00001 #include "asset.h"
00002 #include "batchrender.h"
00003 #include "bcsignals.h"
00004 #include "confirmsave.h"
00005 #include "bchash.h"
00006 #include "edl.h"
00007 #include "edlsession.h"
00008 #include "errorbox.h"
00009 #include "filesystem.h"
00010 #include "filexml.h"
00011 #include "keys.h"
00012 #include "language.h"
00013 #include "mainsession.h"
00014 #include "mutex.h"
00015 #include "mwindow.h"
00016 #include "mwindowgui.h"
00017 #include "packagedispatcher.h"
00018 #include "packagerenderer.h"
00019 #include "preferences.h"
00020 #include "render.h"
00021 #include "theme.h"
00022 #include "transportque.h"
00023 #include "vframe.h"
00024 
00025 
00026 
00027 
00028 
00029 static char *list_titles[] = 
00030 {
00031         N_("Enabled"), 
00032         N_("Output"),
00033         N_("EDL"),
00034         N_("Elapsed")
00035 };
00036 
00037 static int list_widths[] =
00038 {
00039         50,
00040         100,
00041         200,
00042         100
00043 };
00044 
00045 BatchRenderMenuItem::BatchRenderMenuItem(MWindow *mwindow)
00046  : BC_MenuItem(_("Batch Render..."), "Shift-B", 'B')
00047 {
00048         set_shift(1); 
00049         this->mwindow = mwindow;
00050 }
00051 
00052 int BatchRenderMenuItem::handle_event()
00053 {
00054         mwindow->batch_render->start();
00055         return 1;
00056 }
00057 
00058 
00059 
00060 
00061 
00062 
00063 
00064 
00065 BatchRenderJob::BatchRenderJob(Preferences *preferences)
00066 {
00067         this->preferences = preferences;
00068         asset = new Asset;
00069         edl_path[0] = 0;
00070         strategy = 0;
00071         enabled = 1;
00072         elapsed = 0;
00073 }
00074 
00075 BatchRenderJob::~BatchRenderJob()
00076 {
00077         Garbage::delete_object(asset);
00078 }
00079 
00080 void BatchRenderJob::copy_from(BatchRenderJob *src)
00081 {
00082         asset->copy_from(src->asset, 0);
00083         strcpy(edl_path, src->edl_path);
00084         strategy = src->strategy;
00085         enabled = src->enabled;
00086         elapsed = 0;
00087 }
00088 
00089 void BatchRenderJob::load(FileXML *file)
00090 {
00091         int result = 0;
00092 
00093         edl_path[0] = 0;
00094         file->tag.get_property("EDL_PATH", edl_path);
00095         strategy = file->tag.get_property("STRATEGY", strategy);
00096         enabled = file->tag.get_property("ENABLED", enabled);
00097         elapsed = file->tag.get_property("ELAPSED", elapsed);
00098         fix_strategy();
00099 
00100         result = file->read_tag();
00101         if(!result)
00102         {
00103                 if(file->tag.title_is("ASSET"))
00104                 {
00105                         file->tag.get_property("SRC", asset->path);
00106                         asset->read(file, 0);
00107 // The compression parameters are stored in the defaults to reduce
00108 // coding maintenance.  The defaults must now be stuffed into the XML for
00109 // unique storage.
00110                         BC_Hash defaults;
00111                         defaults.load_string(file->read_text());
00112                         asset->load_defaults(&defaults,
00113                                 "",
00114                                 0,
00115                                 1,
00116                                 0,
00117                                 0,
00118                                 0);
00119                 }
00120         }
00121 }
00122 
00123 void BatchRenderJob::save(FileXML *file)
00124 {
00125 TRACE("BatchRenderJob::save 1");
00126         file->tag.set_property("EDL_PATH", edl_path);
00127 TRACE("BatchRenderJob::save 1");
00128         file->tag.set_property("STRATEGY", strategy);
00129 TRACE("BatchRenderJob::save 1");
00130         file->tag.set_property("ENABLED", enabled);
00131 TRACE("BatchRenderJob::save 1");
00132         file->tag.set_property("ELAPSED", elapsed);
00133 TRACE("BatchRenderJob::save 1");
00134         file->append_tag();
00135 TRACE("BatchRenderJob::save 1");
00136         file->append_newline();
00137 TRACE("BatchRenderJob::save 1");
00138         asset->write(file,
00139                 0,
00140                 "");
00141 
00142 // The compression parameters are stored in the defaults to reduce
00143 // coding maintenance.  The defaults must now be stuffed into the XML for
00144 // unique storage.
00145         BC_Hash defaults;
00146         asset->save_defaults(&defaults, 
00147                 "",
00148                 0,
00149                 1,
00150                 0,
00151                 0,
00152                 0);
00153         char *string;
00154         defaults.save_string(string);
00155         file->append_text(string);
00156         delete [] string;
00157 TRACE("BatchRenderJob::save 1");
00158         file->tag.set_title("/JOB");
00159 TRACE("BatchRenderJob::save 1");
00160         file->append_tag();
00161 TRACE("BatchRenderJob::save 1");
00162         file->append_newline();
00163 TRACE("BatchRenderJob::save 10");
00164 }
00165 
00166 void BatchRenderJob::fix_strategy()
00167 {
00168         strategy = Render::fix_strategy(strategy, preferences->use_renderfarm);
00169 }
00170 
00171 
00172 
00173 
00174 
00175 
00176 
00177 
00178 
00179 
00180 BatchRenderThread::BatchRenderThread(MWindow *mwindow)
00181  : BC_DialogThread()
00182 {
00183         this->mwindow = mwindow;
00184         current_job = 0;
00185         rendering_job = -1;
00186         is_rendering = 0;
00187         default_job = 0;
00188 }
00189 
00190 BatchRenderThread::BatchRenderThread()
00191  : BC_DialogThread()
00192 {
00193         mwindow = 0;
00194         current_job = 0;
00195         rendering_job = -1;
00196         is_rendering = 0;
00197         default_job = 0;
00198 }
00199 
00200 void BatchRenderThread::handle_close_event(int result)
00201 {
00202 // Save settings
00203 TRACE("BatchRenderThread::handle_close_event 1");
00204         char path[BCTEXTLEN];
00205 TRACE("BatchRenderThread::handle_close_event 1");
00206         path[0] = 0;
00207 TRACE("BatchRenderThread::handle_close_event 1");
00208         save_jobs(path);
00209 TRACE("BatchRenderThread::handle_close_event 1");
00210         save_defaults(mwindow->defaults);
00211 TRACE("BatchRenderThread::handle_close_event 1");
00212         delete default_job;
00213 TRACE("BatchRenderThread::handle_close_event 1");
00214         default_job = 0;
00215 TRACE("BatchRenderThread::handle_close_event 1");
00216         jobs.remove_all_objects();
00217 TRACE("BatchRenderThread::handle_close_event 100");
00218 }
00219 
00220 BC_Window* BatchRenderThread::new_gui()
00221 {
00222         current_start = 0.0;
00223         current_end = 0.0;
00224         default_job = new BatchRenderJob(mwindow->preferences);
00225 
00226         char path[BCTEXTLEN];
00227         path[0] = 0;
00228         load_jobs(path, mwindow->preferences);
00229         load_defaults(mwindow->defaults);
00230         this->gui = new BatchRenderGUI(mwindow, 
00231                 this,
00232                 mwindow->session->batchrender_x,
00233                 mwindow->session->batchrender_y,
00234                 mwindow->session->batchrender_w,
00235                 mwindow->session->batchrender_h);
00236         this->gui->create_objects();
00237         return this->gui;
00238 }
00239 
00240 
00241 void BatchRenderThread::load_jobs(char *path, Preferences *preferences)
00242 {
00243         FileXML file;
00244         int result = 0;
00245 
00246         jobs.remove_all_objects();
00247         if(path[0])
00248                 file.read_from_file(path);
00249         else
00250                 file.read_from_file(create_path(path));
00251 
00252         while(!result)
00253         {
00254                 if(!(result = file.read_tag()))
00255                 {
00256                         if(file.tag.title_is("JOB"))
00257                         {
00258                                 BatchRenderJob *job;
00259                                 jobs.append(job = new BatchRenderJob(preferences));
00260                                 job->load(&file);
00261                         }
00262                 }
00263         }
00264 }
00265 
00266 void BatchRenderThread::save_jobs(char *path)
00267 {
00268         FileXML file;
00269 
00270         for(int i = 0; i < jobs.total; i++)
00271         {
00272                 file.tag.set_title("JOB");
00273                 jobs.values[i]->save(&file);
00274         }
00275 
00276         if(path[0])
00277                 file.write_to_file(path);
00278         else
00279                 file.write_to_file(create_path(path));
00280 }
00281 
00282 void BatchRenderThread::load_defaults(BC_Hash *defaults)
00283 {
00284         if(default_job)
00285         {
00286                 default_job->asset->load_defaults(defaults,
00287                         "BATCHRENDER_",
00288                         1,
00289                         1,
00290                         1,
00291                         1,
00292                         1);
00293                 default_job->fix_strategy();
00294         }
00295 
00296         for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
00297         {
00298                 char string[BCTEXTLEN];
00299                 sprintf(string, "BATCHRENDER_COLUMN%d", i);
00300                 column_width[i] = defaults->get(string, list_widths[i]);
00301         }
00302 }
00303 
00304 void BatchRenderThread::save_defaults(BC_Hash *defaults)
00305 {
00306         if(default_job)
00307         {
00308                 default_job->asset->save_defaults(defaults,
00309                         "BATCHRENDER_",
00310                         1,
00311                         1,
00312                         1,
00313                         1,
00314                         1);
00315                 defaults->update("BATCHRENDER_STRATEGY", default_job->strategy);
00316         }
00317         for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
00318         {
00319                 char string[BCTEXTLEN];
00320                 sprintf(string, "BATCHRENDER_COLUMN%d", i);
00321                 defaults->update(string, column_width[i]);
00322         }
00323 //      defaults->update("BATCHRENDER_JOB", current_job);
00324         if(mwindow)
00325                 mwindow->save_defaults();
00326         else
00327                 defaults->save();
00328 }
00329 
00330 char* BatchRenderThread::create_path(char *string)
00331 {
00332         FileSystem fs;
00333         sprintf(string, "%s", BCASTDIR);
00334         fs.complete_path(string);
00335         strcat(string, BATCH_PATH);
00336         return string;
00337 }
00338 
00339 void BatchRenderThread::new_job()
00340 {
00341         BatchRenderJob *result = new BatchRenderJob(mwindow->preferences);
00342         result->copy_from(get_current_job());
00343         jobs.append(result);
00344         current_job = jobs.total - 1;
00345         gui->create_list(1);
00346         gui->change_job();
00347 }
00348 
00349 void BatchRenderThread::delete_job()
00350 {
00351         if(current_job < jobs.total && current_job >= 0)
00352         {
00353                 jobs.remove_object_number(current_job);
00354                 if(current_job > 0) current_job--;
00355                 gui->create_list(1);
00356                 gui->change_job();
00357         }
00358 }
00359 
00360 BatchRenderJob* BatchRenderThread::get_current_job()
00361 {
00362         BatchRenderJob *result;
00363         if(current_job >= jobs.total || current_job < 0)
00364         {
00365                 result = default_job;
00366         }
00367         else
00368         {
00369                 result = jobs.values[current_job];
00370         }
00371         return result;
00372 }
00373 
00374 
00375 Asset* BatchRenderThread::get_current_asset()
00376 {
00377         return get_current_job()->asset;
00378 }
00379 
00380 char* BatchRenderThread::get_current_edl()
00381 {
00382         return get_current_job()->edl_path;
00383 }
00384 
00385 
00386 // Test EDL files for existence
00387 int BatchRenderThread::test_edl_files()
00388 {
00389         for(int i = 0; i < jobs.total; i++)
00390         {
00391                 if(jobs.values[i]->enabled)
00392                 {
00393                         FILE *fd = fopen(jobs.values[i]->edl_path, "r");
00394                         if(!fd)
00395                         {
00396                                 char string[BCTEXTLEN];
00397                                 sprintf(string, _("EDL %s not found.\n"), jobs.values[i]->edl_path);
00398                                 if(mwindow)
00399                                 {
00400                                         ErrorBox error_box(PROGRAM_NAME ": Error",
00401                                                 mwindow->gui->get_abs_cursor_x(1),
00402                                                 mwindow->gui->get_abs_cursor_y(1));
00403                                         error_box.create_objects(string);
00404                                         error_box.run_window();
00405                                         gui->new_batch->enable();
00406                                         gui->delete_batch->enable();
00407                                 }
00408                                 else
00409                                 {
00410                                         fprintf(stderr, 
00411                                                 "%s",
00412                                                 string);
00413                                 }
00414 
00415                                 is_rendering = 0;
00416                                 return 1;
00417                         }
00418                         else
00419                         {
00420                                 fclose(fd);
00421                         }
00422                 }
00423         }
00424         return 0;
00425 }
00426 
00427 void BatchRenderThread::calculate_dest_paths(ArrayList<char*> *paths,
00428         Preferences *preferences,
00429         ArrayList<PluginServer*> *plugindb)
00430 {
00431         for(int i = 0; i < jobs.total; i++)
00432         {
00433                 BatchRenderJob *job = jobs.values[i];
00434                 if(job->enabled)
00435                 {
00436                         PackageDispatcher *packages = new PackageDispatcher;
00437 
00438 // Load EDL
00439                         TransportCommand *command = new TransportCommand;
00440                         FileXML *file = new FileXML;
00441                         file->read_from_file(job->edl_path);
00442 
00443 // Use command to calculate range.
00444                         command->command = NORMAL_FWD;
00445                         command->get_edl()->load_xml(plugindb, 
00446                                 file, 
00447                                 LOAD_ALL);
00448                         command->change_type = CHANGE_ALL;
00449                         command->set_playback_range();
00450                         command->playback_range_adjust_inout();
00451 
00452 // Create test packages
00453                         packages->create_packages(mwindow,
00454                                 command->get_edl(),
00455                                 preferences,
00456                                 job->strategy, 
00457                                 job->asset, 
00458                                 command->start_position, 
00459                                 command->end_position,
00460                                 0);
00461 
00462 // Append output paths allocated to total
00463                         packages->get_package_paths(paths);
00464 
00465 // Delete package harness
00466                         delete packages;
00467                         delete command;
00468                         delete file;
00469                 }
00470         }
00471 }
00472 
00473 
00474 void BatchRenderThread::start_rendering(char *config_path,
00475         char *batch_path)
00476 {
00477         BC_Hash *boot_defaults;
00478         Preferences *preferences;
00479         Render *render;
00480         ArrayList<PluginServer*> *plugindb;
00481 
00482 // Initialize stuff which MWindow does.
00483         MWindow::init_defaults(boot_defaults, config_path);
00484         load_defaults(boot_defaults);
00485         preferences = new Preferences;
00486         preferences->load_defaults(boot_defaults);
00487         MWindow::init_plugins(preferences, plugindb, 0);
00488 
00489         load_jobs(batch_path, preferences);
00490         save_jobs(batch_path);
00491         save_defaults(boot_defaults);
00492 
00493 // Test EDL files for existence
00494         if(test_edl_files()) return;
00495 
00496 
00497 // Predict all destination paths
00498         ArrayList<char*> paths;
00499         calculate_dest_paths(&paths,
00500                 preferences,
00501                 plugindb);
00502 
00503         int result = ConfirmSave::test_files(0, &paths);
00504         paths.remove_all_objects();
00505 
00506 // Abort on any existing file because it's so hard to set this up.
00507         if(result) return;
00508 
00509         render = new Render(0);
00510         render->start_batches(&jobs, 
00511                 boot_defaults,
00512                 preferences,
00513                 plugindb);
00514 }
00515 
00516 void BatchRenderThread::start_rendering()
00517 {
00518         if(is_rendering) return;
00519 
00520         is_rendering = 1;
00521         char path[BCTEXTLEN];
00522         path[0] = 0;
00523         save_jobs(path);
00524         save_defaults(mwindow->defaults);
00525         gui->new_batch->disable();
00526         gui->delete_batch->disable();
00527 
00528 // Test EDL files for existence
00529         if(test_edl_files()) return;
00530 
00531 // Predict all destination paths
00532         ArrayList<char*> paths;
00533         calculate_dest_paths(&paths,
00534                 mwindow->preferences,
00535                 mwindow->plugindb);
00536 
00537 // Test destination files for overwrite
00538         int result = ConfirmSave::test_files(mwindow, &paths);
00539         paths.remove_all_objects();
00540 
00541 // User cancelled
00542         if(result)
00543         {
00544                 is_rendering = 0;
00545                 gui->new_batch->enable();
00546                 gui->delete_batch->enable();
00547                 return;
00548         }
00549 
00550         mwindow->render->start_batches(&jobs);
00551 }
00552 
00553 void BatchRenderThread::stop_rendering()
00554 {
00555         if(!is_rendering) return;
00556         mwindow->render->stop_operation();
00557         is_rendering = 0;
00558 }
00559 
00560 void BatchRenderThread::update_active(int number)
00561 {
00562         gui->lock_window("BatchRenderThread::update_active");
00563         if(number >= 0)
00564         {
00565                 current_job = number;
00566                 rendering_job = number;
00567         }
00568         else
00569         {
00570                 rendering_job = -1;
00571                 is_rendering = 0;
00572         }
00573         gui->create_list(1);
00574         gui->unlock_window();
00575 }
00576 
00577 void BatchRenderThread::update_done(int number, 
00578         int create_list, 
00579         double elapsed_time)
00580 {
00581         gui->lock_window("BatchRenderThread::update_done");
00582         if(number < 0)
00583         {
00584                 gui->new_batch->enable();
00585                 gui->delete_batch->enable();
00586         }
00587         else
00588         {
00589                 jobs.values[number]->enabled = 0;
00590                 jobs.values[number]->elapsed = elapsed_time;
00591                 if(create_list) gui->create_list(1);
00592         }
00593         gui->unlock_window();
00594 }
00595 
00596 void BatchRenderThread::move_batch(int src, int dst)
00597 {
00598         BatchRenderJob *src_job = jobs.values[src];
00599         if(dst < 0) dst = jobs.total - 1;
00600 
00601         if(dst != src)
00602         {
00603                 for(int i = src; i < jobs.total - 1; i++)
00604                         jobs.values[i] = jobs.values[i + 1];
00605 //              if(dst > src) dst--;
00606                 for(int i = jobs.total - 1; i > dst; i--)
00607                         jobs.values[i] = jobs.values[i - 1];
00608                 jobs.values[dst] = src_job;
00609                 gui->create_list(1);
00610         }
00611 }
00612 
00613 
00614 
00615 
00616 
00617 
00618 
00619 
00620 
00621 BatchRenderGUI::BatchRenderGUI(MWindow *mwindow, 
00622         BatchRenderThread *thread,
00623         int x,
00624         int y,
00625         int w,
00626         int h)
00627  : BC_Window(PROGRAM_NAME ": Batch Render", 
00628         x,
00629         y,
00630         w, 
00631         h, 
00632         50, 
00633         50, 
00634         1,
00635         0, 
00636         1)
00637 {
00638         this->mwindow = mwindow;
00639         this->thread = thread;
00640 }
00641 
00642 BatchRenderGUI::~BatchRenderGUI()
00643 {
00644         delete format_tools;
00645 }
00646 
00647 
00648 void BatchRenderGUI::create_objects()
00649 {
00650         mwindow->theme->get_batchrender_sizes(this, get_w(), get_h());
00651         create_list(0);
00652 
00653         int x = mwindow->theme->batchrender_x1;
00654         int y = 5;
00655         int x1 = mwindow->theme->batchrender_x1;
00656         int x2 = mwindow->theme->batchrender_x2;
00657         int x3 = mwindow->theme->batchrender_x3;
00658         int y1 = y;
00659         int y2;
00660 
00661 // output file
00662         add_subwindow(output_path_title = new BC_Title(x1, y, _("Output path:")));
00663         y += 20;
00664         format_tools = new BatchFormat(mwindow,
00665                                         this, 
00666                                         thread->get_current_asset());
00667         format_tools->create_objects(x, 
00668                                                 y, 
00669                                                 1, 
00670                                                 1, 
00671                                                 1, 
00672                                                 1, 
00673                                                 0, 
00674                                                 1, 
00675                                                 0, 
00676                                                 0, 
00677                                                 &thread->get_current_job()->strategy, 
00678                                                 0);
00679 
00680         x2 = x;
00681         y2 = y + 10;
00682         x += format_tools->get_w();
00683         y = y1;
00684         x1 = x;
00685         x3 = x + 80;
00686 
00687 // input EDL
00688         x = x1;
00689         add_subwindow(edl_path_title = new BC_Title(x, y, _("EDL Path:")));
00690         y += 20;
00691         add_subwindow(edl_path_text = new BatchRenderEDLPath(
00692                 thread, 
00693                 x, 
00694                 y, 
00695                 get_w() - x - 40, 
00696                 thread->get_current_edl()));
00697 
00698         x += edl_path_text->get_w();
00699         add_subwindow(edl_path_browse = new BrowseButton(
00700                 mwindow,
00701                 this,
00702                 edl_path_text, 
00703                 x, 
00704                 y, 
00705                 thread->get_current_edl(),
00706                 _("Input EDL"),
00707                 _("Select an EDL to load:"),
00708                 0));
00709 
00710         x = x1;
00711 
00712         y += 45;
00713         add_subwindow(new_batch = new BatchRenderNew(thread, 
00714                 x, 
00715                 y));
00716         x += new_batch->get_w() + 10;
00717 
00718         add_subwindow(delete_batch = new BatchRenderDelete(thread, 
00719                 x, 
00720                 y));
00721         x += delete_batch->get_w() + 10;
00722 
00723         add_subwindow(savelist_batch = new BatchRenderSaveList(thread, 
00724                 x, 
00725                 y));
00726         x += savelist_batch->get_w() + 10;
00727 
00728         add_subwindow(loadlist_batch = new BatchRenderLoadList(thread, 
00729                 x, 
00730                 y));
00731         x += loadlist_batch->get_w() + 10;
00732 
00733 
00734         x = x2;
00735         y = y2;
00736         add_subwindow(list_title = new BC_Title(x, y, _("Batches to render:")));
00737         y += 20;
00738         add_subwindow(batch_list = new BatchRenderList(thread, 
00739                 x, 
00740                 y,
00741                 get_w() - x - 10,
00742                 get_h() - y - BC_GenericButton::calculate_h() - 15));
00743 
00744         y += batch_list->get_h() + 10;
00745         add_subwindow(start_button = new BatchRenderStart(thread, 
00746             x, 
00747             y));
00748         x = get_w() / 2 -
00749                 BC_GenericButton::calculate_w(this, _("Stop")) / 2;
00750         add_subwindow(stop_button = new BatchRenderStop(thread, 
00751                 x, 
00752                 y));
00753         x = get_w() - 
00754                 BC_GenericButton::calculate_w(this, _("Close")) - 
00755                 10;
00756         add_subwindow(cancel_button = new BatchRenderCancel(thread, 
00757                 x, 
00758                 y));
00759 
00760         show_window();
00761 }
00762 
00763 int BatchRenderGUI::resize_event(int w, int h)
00764 {
00765         mwindow->session->batchrender_w = w;
00766         mwindow->session->batchrender_h = h;
00767         mwindow->theme->get_batchrender_sizes(this, w, h);
00768 
00769         int x = mwindow->theme->batchrender_x1;
00770         int y = 5;
00771         int x1 = mwindow->theme->batchrender_x1;
00772         int x2 = mwindow->theme->batchrender_x2;
00773         int x3 = mwindow->theme->batchrender_x3;
00774         int y1 = y;
00775         int y2;
00776 
00777         output_path_title->reposition_window(x1, y);
00778         y += 20;
00779         format_tools->reposition_window(x, y);
00780         x2 = x;
00781         y2 = y + 10;
00782         y = y1;
00783         x += format_tools->get_w();
00784         x1 = x;
00785         x3 = x + 80;
00786 
00787         x = x1;
00788         edl_path_title->reposition_window(x, y);
00789         y += 20;
00790         edl_path_text->reposition_window(x, y, w - x - 40);
00791         x += edl_path_text->get_w();
00792         edl_path_browse->reposition_window(x, y);
00793 
00794         x = x1;
00795 //      y += 30;
00796 //      status_title->reposition_window(x, y);
00797 //      x = x3;
00798 //      status_text->reposition_window(x, y);
00799 //      x = x1;
00800 //      y += 30;
00801 //      progress_bar->reposition_window(x, y, w - x - 10);
00802 
00803         y += 30;
00804         new_batch->reposition_window(x, y);
00805         x += new_batch->get_w() + 10;
00806         delete_batch->reposition_window(x, y);
00807         x += delete_batch->get_w() + 10;
00808 
00809         x = x2;
00810         y = y2;
00811         int y_margin = get_h() - batch_list->get_h();
00812         list_title->reposition_window(x, y);
00813         y += 20;
00814         batch_list->reposition_window(x, y, w - x - 10, h - y_margin);
00815 
00816         y += batch_list->get_h() + 10;
00817         start_button->reposition_window(x, y);
00818         x = w / 2 - 
00819                 stop_button->get_w() / 2;
00820         stop_button->reposition_window(x, y);
00821         x = w -
00822                 cancel_button->get_w() - 
00823                 10;
00824         cancel_button->reposition_window(x, y);
00825         return 1;
00826 }
00827 
00828 int BatchRenderGUI::translation_event()
00829 {
00830         mwindow->session->batchrender_x = get_x();
00831         mwindow->session->batchrender_y = get_y();
00832         return 1;
00833 }
00834 
00835 int BatchRenderGUI::close_event()
00836 {
00837 // Stop batch rendering
00838         unlock_window();
00839         thread->stop_rendering();
00840         lock_window("BatchRenderGUI::close_event");
00841         set_done(1);
00842         return 1;
00843 }
00844 
00845 void BatchRenderGUI::create_list(int update_widget)
00846 {
00847         for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
00848         {
00849                 list_columns[i].remove_all_objects();
00850         }
00851 
00852         for(int i = 0; i < thread->jobs.total; i++)
00853         {
00854                 BatchRenderJob *job = thread->jobs.values[i];
00855                 char string[BCTEXTLEN];
00856                 BC_ListBoxItem *enabled = new BC_ListBoxItem(job->enabled ? 
00857                         (char*)"X" : 
00858                         (char*)" ");
00859                 BC_ListBoxItem *item1 = new BC_ListBoxItem(job->asset->path);
00860                 BC_ListBoxItem *item2 = new BC_ListBoxItem(job->edl_path);
00861                 BC_ListBoxItem *item3;
00862                 if(job->elapsed)
00863                         item3 = new BC_ListBoxItem(
00864                                 Units::totext(string,
00865                                         job->elapsed,
00866                                         TIME_HMS2));
00867                 else
00868                         item3 = new BC_ListBoxItem(_("Unknown"));
00869                 list_columns[0].append(enabled);
00870                 list_columns[1].append(item1);
00871                 list_columns[2].append(item2);
00872                 list_columns[3].append(item3);
00873                 if(i == thread->current_job)
00874                 {
00875                         enabled->set_selected(1);
00876                         item1->set_selected(1);
00877                         item2->set_selected(1);
00878                         item3->set_selected(1);
00879                 }
00880                 if(i == thread->rendering_job)
00881                 {
00882                         enabled->set_color(RED);
00883                         item1->set_color(RED);
00884                         item2->set_color(RED);
00885                         item3->set_color(RED);
00886                 }
00887         }
00888 
00889         if(update_widget)
00890         {
00891                 batch_list->update(list_columns,
00892                                                 list_titles,
00893                                                 thread->column_width,
00894                                                 BATCHRENDER_COLUMNS,
00895                                                 batch_list->get_xposition(),
00896                                                 batch_list->get_yposition(), 
00897                                                 batch_list->get_highlighted_item(),  // Flat index of item cursor is over
00898                                                 1,     // set all autoplace flags to 1
00899                                                 1);
00900         }
00901 }
00902 
00903 void BatchRenderGUI::change_job()
00904 {
00905         BatchRenderJob *job = thread->get_current_job();
00906         format_tools->update(job->asset, &job->strategy);
00907         edl_path_text->update(job->edl_path);
00908 }
00909 
00910 
00911 
00912 
00913 
00914 
00915 
00916 
00917 BatchFormat::BatchFormat(MWindow *mwindow,
00918                         BatchRenderGUI *gui,
00919                         Asset *asset)
00920  : FormatTools(mwindow, gui, asset)
00921 {
00922         this->gui = gui;
00923         this->mwindow = mwindow;
00924 }
00925 
00926 BatchFormat::~BatchFormat()
00927 {
00928 }
00929 
00930 
00931 int BatchFormat::handle_event()
00932 {
00933         gui->create_list(1);
00934         return 1;
00935 }
00936 
00937 
00938 
00939 
00940 
00941 
00942 
00943 
00944 
00945 
00946 
00947 BatchRenderEDLPath::BatchRenderEDLPath(