00001 #include "asset.h"
00002 #include "batchrender.h"
00003 #include "bcsignals.h"
00004 #include "confirmsave.h"
00005 #include "defaults.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 "mwindow.h"
00015 #include "mwindowgui.h"
00016 #include "packagedispatcher.h"
00017 #include "packagerenderer.h"
00018 #include "preferences.h"
00019 #include "render.h"
00020 #include "theme.h"
00021 #include "transportque.h"
00022 #include "vframe.h"
00023
00024
00025
00026
00027
00028 static char *list_titles[] =
00029 {
00030 N_("Enabled"),
00031 N_("Output"),
00032 N_("EDL"),
00033 N_("Elapsed")
00034 };
00035
00036 static int list_widths[] =
00037 {
00038 50,
00039 100,
00040 200,
00041 100
00042 };
00043
00044 BatchRenderMenuItem::BatchRenderMenuItem(MWindow *mwindow)
00045 : BC_MenuItem(_("Batch Render..."), "Shift-B", 'B')
00046 {
00047 set_shift(1);
00048 this->mwindow = mwindow;
00049 }
00050
00051 int BatchRenderMenuItem::handle_event()
00052 {
00053 mwindow->batch_render->start();
00054 return 1;
00055 }
00056
00057
00058
00059
00060
00061
00062
00063
00064 BatchRenderJob::BatchRenderJob(Preferences *preferences)
00065 {
00066 this->preferences = preferences;
00067 asset = new Asset;
00068 edl_path[0] = 0;
00069 strategy = 0;
00070 enabled = 1;
00071 elapsed = 0;
00072 }
00073
00074 BatchRenderJob::~BatchRenderJob()
00075 {
00076 delete asset;
00077 }
00078
00079 void BatchRenderJob::copy_from(BatchRenderJob *src)
00080 {
00081 asset->copy_from(src->asset, 0);
00082 strcpy(edl_path, src->edl_path);
00083 strategy = src->strategy;
00084 enabled = src->enabled;
00085 elapsed = 0;
00086 }
00087
00088 void BatchRenderJob::load(FileXML *file)
00089 {
00090 int result = 0;
00091
00092 edl_path[0] = 0;
00093 file->tag.get_property("EDL_PATH", edl_path);
00094 strategy = file->tag.get_property("STRATEGY", strategy);
00095 enabled = file->tag.get_property("ENABLED", enabled);
00096 elapsed = file->tag.get_property("ELAPSED", elapsed);
00097 fix_strategy();
00098
00099 result = file->read_tag();
00100 if(!result)
00101 {
00102 if(file->tag.title_is("ASSET"))
00103 {
00104 file->tag.get_property("SRC", asset->path);
00105 asset->read(file, 0);
00106
00107
00108
00109 Defaults defaults;
00110 defaults.load_string(file->read_text());
00111 asset->load_defaults(&defaults,
00112 "",
00113 0,
00114 1,
00115 0,
00116 0,
00117 0);
00118 }
00119 }
00120 }
00121
00122 void BatchRenderJob::save(FileXML *file)
00123 {
00124 TRACE("BatchRenderJob::save 1");
00125 file->tag.set_property("EDL_PATH", edl_path);
00126 TRACE("BatchRenderJob::save 1");
00127 file->tag.set_property("STRATEGY", strategy);
00128 TRACE("BatchRenderJob::save 1");
00129 file->tag.set_property("ENABLED", enabled);
00130 TRACE("BatchRenderJob::save 1");
00131 file->tag.set_property("ELAPSED", elapsed);
00132 TRACE("BatchRenderJob::save 1");
00133 file->append_tag();
00134 TRACE("BatchRenderJob::save 1");
00135 file->append_newline();
00136 TRACE("BatchRenderJob::save 1");
00137 asset->write(file,
00138 0,
00139 "");
00140
00141
00142
00143
00144 Defaults defaults;
00145 asset->save_defaults(&defaults,
00146 "",
00147 0,
00148 1,
00149 0,
00150 0,
00151 0);
00152 char *string;
00153 defaults.save_string(string);
00154 file->append_text(string);
00155 delete [] string;
00156 TRACE("BatchRenderJob::save 1");
00157 file->tag.set_title("/JOB");
00158 TRACE("BatchRenderJob::save 1");
00159 file->append_tag();
00160 TRACE("BatchRenderJob::save 1");
00161 file->append_newline();
00162 TRACE("BatchRenderJob::save 10");
00163 }
00164
00165 void BatchRenderJob::fix_strategy()
00166 {
00167 strategy = Render::fix_strategy(strategy, preferences->use_renderfarm);
00168 }
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179 BatchRenderThread::BatchRenderThread(MWindow *mwindow)
00180 : BC_DialogThread()
00181 {
00182 this->mwindow = mwindow;
00183 current_job = 0;
00184 rendering_job = -1;
00185 is_rendering = 0;
00186 default_job = 0;
00187 }
00188
00189 BatchRenderThread::BatchRenderThread()
00190 : BC_DialogThread()
00191 {
00192 mwindow = 0;
00193 current_job = 0;
00194 rendering_job = -1;
00195 is_rendering = 0;
00196 default_job = 0;
00197 }
00198
00199 void BatchRenderThread::handle_close_event(int result)
00200 {
00201
00202 TRACE("BatchRenderThread::handle_close_event 1");
00203 char path[BCTEXTLEN];
00204 TRACE("BatchRenderThread::handle_close_event 1");
00205 path[0] = 0;
00206 TRACE("BatchRenderThread::handle_close_event 1");
00207 save_jobs(path);
00208 TRACE("BatchRenderThread::handle_close_event 1");
00209 save_defaults(mwindow->defaults);
00210 TRACE("BatchRenderThread::handle_close_event 1");
00211 delete default_job;
00212 TRACE("BatchRenderThread::handle_close_event 1");
00213 default_job = 0;
00214 TRACE("BatchRenderThread::handle_close_event 1");
00215 jobs.remove_all_objects();
00216 TRACE("BatchRenderThread::handle_close_event 100");
00217 }
00218
00219 BC_Window* BatchRenderThread::new_gui()
00220 {
00221 current_start = 0.0;
00222 current_end = 0.0;
00223 default_job = new BatchRenderJob(mwindow->preferences);
00224
00225 char path[BCTEXTLEN];
00226 path[0] = 0;
00227 load_jobs(path, mwindow->preferences);
00228 load_defaults(mwindow->defaults);
00229 this->gui = new BatchRenderGUI(mwindow,
00230 this,
00231 mwindow->session->batchrender_x,
00232 mwindow->session->batchrender_y,
00233 mwindow->session->batchrender_w,
00234 mwindow->session->batchrender_h);
00235 this->gui->create_objects();
00236 return this->gui;
00237 }
00238
00239
00240 void BatchRenderThread::load_jobs(char *path, Preferences *preferences)
00241 {
00242 FileXML file;
00243 int result = 0;
00244
00245 jobs.remove_all_objects();
00246 if(path[0])
00247 file.read_from_file(path);
00248 else
00249 file.read_from_file(create_path(path));
00250
00251 while(!result)
00252 {
00253 if(!(result = file.read_tag()))
00254 {
00255 if(file.tag.title_is("JOB"))
00256 {
00257 BatchRenderJob *job;
00258 jobs.append(job = new BatchRenderJob(preferences));
00259 job->load(&file);
00260 }
00261 }
00262 }
00263 }
00264
00265 void BatchRenderThread::save_jobs(char *path)
00266 {
00267 FileXML file;
00268
00269 for(int i = 0; i < jobs.total; i++)
00270 {
00271 file.tag.set_title("JOB");
00272 jobs.values[i]->save(&file);
00273 }
00274
00275 if(path[0])
00276 file.write_to_file(path);
00277 else
00278 file.write_to_file(create_path(path));
00279 }
00280
00281 void BatchRenderThread::load_defaults(Defaults *defaults)
00282 {
00283 if(default_job)
00284 {
00285 default_job->asset->load_defaults(defaults,
00286 "BATCHRENDER_",
00287 1,
00288 1,
00289 1,
00290 1,
00291 1);
00292 default_job->fix_strategy();
00293 }
00294
00295 for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
00296 {
00297 char string[BCTEXTLEN];
00298 sprintf(string, "BATCHRENDER_COLUMN%d", i);
00299 column_width[i] = defaults->get(string, list_widths[i]);
00300 }
00301 }
00302
00303 void BatchRenderThread::save_defaults(Defaults *defaults)
00304 {
00305 if(default_job)
00306 {
00307 default_job->asset->save_defaults(defaults,
00308 "BATCHRENDER_",
00309 1,
00310 1,
00311 1,
00312 1,
00313 1);
00314 defaults->update("BATCHRENDER_STRATEGY", default_job->strategy);
00315 }
00316 for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
00317 {
00318 char string[BCTEXTLEN];
00319 sprintf(string, "BATCHRENDER_COLUMN%d", i);
00320 defaults->update(string, column_width[i]);
00321 }
00322
00323 if(mwindow)
00324 mwindow->save_defaults();
00325 else
00326 defaults->save();
00327 }
00328
00329 char* BatchRenderThread::create_path(char *string)
00330 {
00331 FileSystem fs;
00332 sprintf(string, "%s", BCASTDIR);
00333 fs.complete_path(string);
00334 strcat(string, BATCH_PATH);
00335 return string;
00336 }
00337
00338 void BatchRenderThread::new_job()
00339 {
00340 BatchRenderJob *result = new BatchRenderJob(mwindow->preferences);
00341 result->copy_from(get_current_job());
00342 jobs.append(result);
00343 current_job = jobs.total - 1;
00344 gui->create_list(1);
00345 gui->change_job();
00346 }
00347
00348 void BatchRenderThread::delete_job()
00349 {
00350 if(current_job < jobs.total && current_job >= 0)
00351 {
00352 jobs.remove_object_number(current_job);
00353 if(current_job > 0) current_job--;
00354 gui->create_list(1);
00355 gui->change_job();
00356 }
00357 }
00358
00359 BatchRenderJob* BatchRenderThread::get_current_job()
00360 {
00361 BatchRenderJob *result;
00362 if(current_job >= jobs.total || current_job < 0)
00363 {
00364 result = default_job;
00365 }
00366 else
00367 {
00368 result = jobs.values[current_job];
00369 }
00370 return result;
00371 }
00372
00373
00374 Asset* BatchRenderThread::get_current_asset()
00375 {
00376 return get_current_job()->asset;
00377 }
00378
00379 char* BatchRenderThread::get_current_edl()
00380 {
00381 return get_current_job()->edl_path;
00382 }
00383
00384
00385
00386 int BatchRenderThread::test_edl_files()
00387 {
00388 for(int i = 0; i < jobs.total; i++)
00389 {
00390 if(jobs.values[i]->enabled)
00391 {
00392 FILE *fd = fopen(jobs.values[i]->edl_path, "r");
00393 if(!fd)
00394 {
00395 char string[BCTEXTLEN];
00396 sprintf(string, _("EDL %s not found.\n"), jobs.values[i]->edl_path);
00397 if(mwindow)
00398 {
00399 ErrorBox error_box(PROGRAM_NAME ": Error",
00400 mwindow->gui->get_abs_cursor_x(1),
00401 mwindow->gui->get_abs_cursor_y(1));
00402 error_box.create_objects(string);
00403 error_box.run_window();
00404 gui->new_batch->enable();
00405 gui->delete_batch->enable();
00406 }
00407 else
00408 {
00409 fprintf(stderr,
00410 "%s",
00411 string);
00412 }
00413
00414 is_rendering = 0;
00415 return 1;
00416 }
00417 else
00418 {
00419 fclose(fd);
00420 }
00421 }
00422 }
00423 return 0;
00424 }
00425
00426 void BatchRenderThread::calculate_dest_paths(ArrayList<char*> *paths,
00427 Preferences *preferences,
00428 ArrayList<PluginServer*> *plugindb)
00429 {
00430 for(int i = 0; i < jobs.total; i++)
00431 {
00432 BatchRenderJob *job = jobs.values[i];
00433 if(job->enabled)
00434 {
00435 PackageDispatcher *packages = new PackageDispatcher;
00436
00437
00438 TransportCommand *command = new TransportCommand;
00439 FileXML *file = new FileXML;
00440 file->read_from_file(job->edl_path);
00441
00442
00443 command->command = NORMAL_FWD;
00444 command->get_edl()->load_xml(plugindb,
00445 file,
00446 LOAD_ALL);
00447 command->change_type = CHANGE_ALL;
00448 command->set_playback_range();
00449 command->adjust_playback_range();
00450
00451
00452 packages->create_packages(mwindow,
00453 command->get_edl(),
00454 preferences,
00455 job->strategy,
00456 job->asset,
00457 command->start_position,
00458 command->end_position,
00459 0);
00460
00461
00462 for(int j = 0; j < packages->get_total_packages(); j++)
00463 {
00464 RenderPackage *package = packages->get_package(j);
00465 paths->append(strdup(package->path));
00466 }
00467
00468
00469 delete packages;
00470 delete command;
00471 delete file;
00472 }
00473 }
00474 }
00475
00476
00477 void BatchRenderThread::start_rendering(char *config_path,
00478 char *batch_path)
00479 {
00480 Defaults *boot_defaults;
00481 Preferences *preferences;
00482 Render *render;
00483 ArrayList<PluginServer*> *plugindb;
00484
00485
00486 MWindow::init_defaults(boot_defaults, config_path);
00487 load_defaults(boot_defaults);
00488 preferences = new Preferences;
00489 preferences->load_defaults(boot_defaults);
00490 MWindow::init_plugins(preferences, plugindb, 0);
00491
00492 load_jobs(batch_path, preferences);
00493 save_jobs(batch_path);
00494 save_defaults(boot_defaults);
00495
00496
00497 if(test_edl_files()) return;
00498
00499
00500
00501 ArrayList<char*> paths;
00502 calculate_dest_paths(&paths,
00503 preferences,
00504 plugindb);
00505
00506 int result = ConfirmSave::test_files(0, &paths);
00507
00508 if(result) return;
00509
00510 render = new Render(0);
00511 render->start_batches(&jobs,
00512 boot_defaults,
00513 preferences,
00514 plugindb);
00515 }
00516
00517 void BatchRenderThread::start_rendering()
00518 {
00519 if(is_rendering) return;
00520
00521 is_rendering = 1;
00522 char path[BCTEXTLEN];
00523 path[0] = 0;
00524 save_jobs(path);
00525 save_defaults(mwindow->defaults);
00526 gui->new_batch->disable();
00527 gui->delete_batch->disable();
00528
00529
00530 if(test_edl_files()) return;
00531
00532
00533 ArrayList<char*> paths;
00534 calculate_dest_paths(&paths,
00535 mwindow->preferences,
00536 mwindow->plugindb);
00537
00538
00539 int result = ConfirmSave::test_files(mwindow, &paths);
00540 paths.remove_all_objects();
00541
00542
00543 if(result)
00544 {
00545 is_rendering = 0;
00546 gui->new_batch->enable();
00547 gui->delete_batch->enable();
00548 return;
00549 }
00550
00551 mwindow->render->start_batches(&jobs);
00552 }
00553
00554 void BatchRenderThread::stop_rendering()
00555 {
00556 if(!is_rendering) return;
00557 mwindow->render->stop_operation();
00558 is_rendering = 0;
00559 }
00560
00561 void BatchRenderThread::update_active(int number)
00562 {
00563 gui->lock_window("BatchRenderThread::update_active");
00564 if(number >= 0)
00565 {
00566 current_job = number;
00567 rendering_job = number;
00568 }
00569 else
00570 {
00571 rendering_job = -1;
00572 is_rendering = 0;
00573 }
00574 gui->create_list(1);
00575 gui->unlock_window();
00576 }
00577
00578 void BatchRenderThread::update_done(int number,
00579 int create_list,
00580 double elapsed_time)
00581 {
00582 gui->lock_window("BatchRenderThread::update_done");
00583 if(number < 0)
00584 {
00585 gui->new_batch->enable();
00586 gui->delete_batch->enable();
00587 }
00588 else
00589 {
00590 jobs.values[number]->enabled = 0;
00591 jobs.values[number]->elapsed = elapsed_time;
00592 if(create_list) gui->create_list(1);
00593 }
00594 gui->unlock_window();
00595 }
00596
00597 void BatchRenderThread::move_batch(int src, int dst)
00598 {
00599 BatchRenderJob *src_job = jobs.values[src];
00600 if(dst < 0) dst = jobs.total - 1;
00601
00602 if(dst != src)
00603 {
00604 for(int i = src; i < jobs.total - 1; i++)
00605 jobs.values[i] = jobs.values[i + 1];
00606
00607 for(int i = jobs.total - 1; i > dst; i--)
00608 jobs.values[i] = jobs.values[i - 1];
00609 jobs.values[dst] = src_job;
00610 gui->create_list(1);
00611 }
00612 }
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622 BatchRenderGUI::BatchRenderGUI(MWindow *mwindow,
00623 BatchRenderThread *thread,
00624 int x,
00625 int y,
00626 int w,
00627 int h)
00628 : BC_Window(PROGRAM_NAME ": Batch Render",
00629 x,
00630 y,
00631 w,
00632 h,
00633 50,
00634 50,
00635 1,
00636 0,
00637 1)
00638 {
00639 this->mwindow = mwindow;
00640 this->thread = thread;
00641 }
00642
00643 BatchRenderGUI::~BatchRenderGUI()
00644 {
00645 delete format_tools;
00646 }
00647
00648
00649 void BatchRenderGUI::create_objects()
00650 {
00651 mwindow->theme->get_batchrender_sizes(this, get_w(), get_h());
00652 create_list(0);
00653
00654 int x = mwindow->theme->batchrender_x1;
00655 int y = 5;
00656 int x1 = mwindow->theme->batchrender_x1;
00657 int x2 = mwindow->theme->batchrender_x2;
00658 int x3 = mwindow->theme->batchrender_x3;
00659 int y1 = y;
00660 int y2;
00661
00662
00663 add_subwindow(output_path_title = new BC_Title(x1, y, _("Output path:")));
00664 y += 20;
00665 format_tools = new BatchFormat(mwindow,
00666 this,
00667 thread->get_current_asset());
00668 format_tools->create_objects(x,
00669 y,
00670 1,
00671 1,
00672 1,
00673 1,
00674 0,
00675 1,
00676 0,
00677 0,
00678 &thread->get_current_job()->strategy,
00679 0);
00680
00681 x2 = x;
00682 y2 = y + 10;
00683 x += format_tools->get_w();
00684 y = y1;
00685 x1 = x;
00686 x3 = x + 80;
00687
00688
00689 x = x1;
00690 add_subwindow(edl_path_title = new BC_Title(x, y, _("EDL Path:")));
00691 y += 20;
00692 add_subwindow(edl_path_text = new BatchRenderEDLPath(
00693 thread,
00694 x,
00695 y,
00696 get_w() - x - 40,
00697 thread->get_current_edl()));
00698
00699 x += edl_path_text->get_w();
00700 add_subwindow(edl_path_browse = new BrowseButton(
00701 mwindow,
00702 this,
00703 edl_path_text,
00704 x,
00705 y,
00706 thread->get_current_edl(),
00707 _("Input EDL"),
00708 _("Select an EDL to load:"),
00709 0));
00710
00711 x = x1;
00712
00713 y += 30;
00714 add_subwindow(new_batch = new BatchRenderNew(thread,
00715 x,
00716 y));
00717 x += new_batch->get_w() + 10;
00718
00719 add_subwindow(delete_batch = new BatchRenderDelete(thread,
00720 x,
00721 y));
00722 x += delete_batch->get_w() + 10;
00723
00724 x = x2;
00725 y = y2;
00726 add_subwindow(list_title = new BC_Title(x, y, _("Batches to render:")));
00727 y += 20;
00728 add_subwindow(batch_list = new BatchRenderList(thread,
00729 x,
00730 y,
00731 get_w() - x - 10,
00732 get_h() - y - BC_GenericButton::calculate_h() - 15));
00733
00734 y += batch_list->get_h() + 10;
00735 add_subwindow(start_button = new BatchRenderStart(thread,
00736 x,
00737 y));
00738 x = get_w() / 2 -
00739 BC_GenericButton::calculate_w(this, _("Stop")) / 2;
00740 add_subwindow(stop_button = new BatchRenderStop(thread,
00741 x,
00742 y));
00743 x = get_w() -
00744 BC_GenericButton::calculate_w(this, _("Cancel")) -
00745 10;
00746 add_subwindow(cancel_button = new BatchRenderCancel(thread,
00747 x,
00748 y));
00749
00750 show_window();
00751 }
00752
00753 int BatchRenderGUI::resize_event(int w, int h)
00754 {
00755 mwindow->session->batchrender_w = w;
00756 mwindow->session->batchrender_h = h;
00757 mwindow->theme->get_batchrender_sizes(this, w, h);
00758
00759 int x = mwindow->theme->batchrender_x1;
00760 int y = 5;
00761 int x1 = mwindow->theme->batchrender_x1;
00762 int x2 = mwindow->theme->batchrender_x2;
00763 int x3 = mwindow->theme->batchrender_x3;
00764 int y1 = y;
00765 int y2;
00766
00767 output_path_title->reposition_window(x1, y);
00768 y += 20;
00769 format_tools->reposition_window(x, y);
00770 x2 = x;
00771 y2 = y + 10;
00772 y = y1;
00773 x += format_tools->get_w();
00774 x1 = x;
00775 x3 = x + 80;
00776
00777 x = x1;
00778 edl_path_title->reposition_window(x, y);
00779 y += 20;
00780 edl_path_text->reposition_window(x, y, w - x - 40);
00781 x += edl_path_text->get_w();
00782 edl_path_browse->reposition_window(x, y);
00783
00784 x = x1;
00785
00786
00787
00788
00789
00790
00791
00792
00793 y += 30;
00794 new_batch->reposition_window(x, y);
00795 x += new_batch->get_w() + 10;
00796 delete_batch->reposition_window(x, y);
00797 x += delete_batch->get_w() + 10;
00798
00799 x = x2;
00800 y = y2;
00801 int y_margin = get_h() - batch_list->get_h();
00802 list_title->reposition_window(x, y);
00803 y += 20;
00804 batch_list->reposition_window(x, y, w - x - 10, h - y_margin);
00805
00806 y += batch_list->get_h() + 10;
00807 start_button->reposition_window(x, y);
00808 x = w / 2 -
00809 stop_button->get_w() / 2;
00810 stop_button->reposition_window(x, y);
00811 x = w -
00812 cancel_button->get_w() -
00813 10;
00814 cancel_button->reposition_window(x, y);
00815 return 1;
00816 }
00817
00818 int BatchRenderGUI::translation_event()
00819 {
00820 mwindow->session->batchrender_x = get_x();
00821 mwindow->session->batchrender_y = get_y();
00822 return 1;
00823 }
00824
00825 int BatchRenderGUI::close_event()
00826 {
00827
00828 unlock_window();
00829 thread->stop_rendering();
00830 lock_window("BatchRenderGUI::close_event");
00831 set_done(1);
00832 return 1;
00833 }
00834
00835 void BatchRenderGUI::create_list(int update_widget)
00836 {
00837 for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
00838 {
00839 list_columns[i].remove_all_objects();
00840 }
00841
00842 for(int i = 0; i < thread->jobs.total; i++)
00843 {
00844 BatchRenderJob *job = thread->jobs.values[i];
00845 char string[BCTEXTLEN];
00846 BC_ListBoxItem *enabled = new BC_ListBoxItem(job->enabled ?
00847 (char*)"X" :
00848 (char*)" ");
00849 BC_ListBoxItem *item1 = new BC_ListBoxItem(job->asset->path);
00850 BC_ListBoxItem *item2 = new BC_ListBoxItem(job->edl_path);
00851 BC_ListBoxItem *item3;
00852 if(job->elapsed)
00853 item3 = new BC_ListBoxItem(
00854 Units::totext(string,
00855 job->elapsed,
00856 TIME_HMS2));
00857 else
00858 item3 = new BC_ListBoxItem(_("Unknown"));
00859 list_columns[0].append(enabled);
00860 list_columns[1].append(item1);
00861 list_columns[2].append(item2);
00862 list_columns[3].append(item3);
00863 if(i == thread->current_job)
00864 {
00865 enabled->set_selected(1);
00866 item1->set_selected(1);
00867 item2->set_selected(1);
00868 item3->set_selected(1);
00869 }
00870 if(i == thread->rendering_job)
00871 {
00872 enabled->set_color(RED);
00873 item1->set_color(RED);
00874 item2->set_color(RED);
00875 item3->set_color(RED);
00876 }
00877 }
00878
00879 if(update_widget)
00880 {
00881 batch_list->update(list_columns,
00882 list_titles,
00883 thread->column_width,
00884 BATCHRENDER_COLUMNS,
00885 batch_list->get_xposition(),
00886 batch_list->get_yposition(),
00887 batch_list->get_highlighted_item(),
00888 1,
00889 1);
00890 }
00891 }
00892
00893 void BatchRenderGUI::change_job()
00894 {
00895 BatchRenderJob *job = thread->get_current_job();
00896 format_tools->update(job->asset, &job->strategy);
00897 edl_path_text->update(job->edl_path);
00898 }
00899
00900
00901
00902
00903
00904
00905
00906
00907 BatchFormat::BatchFormat(MWindow *mwindow,
00908 BatchRenderGUI *gui,
00909 Asset *asset)
00910 : FormatTools(mwindow, gui, asset)
00911 {
00912 this->gui = gui;
00913 this->mwindow = mwindow;
00914 }
00915
00916 BatchFormat::~BatchFormat()
00917 {
00918 }
00919
00920
00921 int BatchFormat::handle_event()
00922 {
00923 gui->create_list(1);
00924 return 1;
00925 }
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937 BatchRenderEDLPath::BatchRenderEDLPath(BatchRenderThread *thread,
00938 int x,
00939 int y,
00940 int w,
00941 char *text)
00942 : BC_TextBox(x,
00943 y,
00944 w,
00945 1,
00946 text)
00947 {
00948 this->thread = thread;
00949 }
00950
00951
00952 int BatchRenderEDLPath::handle_event()
00953 {
00954 strcpy(thread->get_current_edl(), get_text());
00955 thread->gui->create_list(1);
00956 return 1;
00957 }
00958
00959
00960
00961
00962
00963
00964 BatchRenderNew::BatchRenderNew(BatchRenderThread *thread,
00965 int x,
00966 int y)
00967 : BC_GenericButton(x, y, _("New"))
00968 {
00969 this->thread = thread;
00970 }
00971
00972 int BatchRenderNew::handle_event()
00973 {
00974 thread->new_job();
00975 return 1;
00976 }
00977
00978 BatchRenderDelete::BatchRenderDelete(BatchRenderThread *thread,
00979 int x,
00980 int y)
00981 : BC_GenericButton(x, y, _("Delete"))
00982 {
00983 this->thread = thread;
00984 }
00985
00986 int BatchRenderDelete::handle_event()
00987 {
00988 thread->delete_job();
00989 return 1;
00990 }
00991
00992
00993
00994
00995
00996
00997 BatchRenderList::BatchRenderList(BatchRenderThread *thread,
00998 int x,
00999 int y,
01000 int w,
01001 int h)
01002 : BC_ListBox(x,
01003 y,
01004 w,
01005 h,
01006 LISTBOX_TEXT,
01007 thread->gui->list_columns,
01008 list_titles,
01009 thread->column_width,
01010 BATCHRENDER_COLUMNS,
01011 0,
01012 0,
01013 LISTBOX_SINGLE,
01014 ICON_LEFT,
01015 1)
01016 {
01017 this->thread = thread;
01018 dragging_item = 0;
01019 set_process_drag(0);
01020 }
01021
01022 int BatchRenderList::handle_event()
01023 {
01024 return 1;
01025 }
01026
01027 int BatchRenderList::selection_changed()
01028 {
01029 thread->current_job = get_selection_number(0, 0);
01030 thread->gui->change_job();
01031 if(get_cursor_x() < thread->column_width[0])
01032 {
01033 BatchRenderJob *job = thread->get_current_job();
01034 job->enabled = !job->enabled;
01035 thread->gui->create_list(1);
01036 }
01037 return 1;
01038 }
01039
01040 int BatchRenderList::column_resize_event()
01041 {
01042 for(int i = 0; i < BATCHRENDER_COLUMNS; i++)
01043 {
01044 thread->column_width[i] = get_column_width(i);
01045 }
01046 return 1;
01047 }
01048
01049 int BatchRenderList::drag_start_event()
01050 {
01051 if(BC_ListBox::drag_start_event())
01052 {
01053 dragging_item = 1;
01054 return 1;
01055 }
01056
01057 return 0;
01058 }
01059
01060 int BatchRenderList::drag_motion_event()
01061 {
01062 if(BC_ListBox::drag_motion_event())
01063 {
01064 return 1;
01065 }
01066 return 0;
01067 }
01068
01069 int BatchRenderList::drag_stop_event()
01070 {
01071 if(dragging_item)
01072 {
01073 int src = get_selection_number(0, 0);
01074 int dst = get_highlighted_item();
01075 if(src != dst)
01076 {
01077 thread->move_batch(src, dst);
01078 }
01079 BC_ListBox::drag_stop_event();
01080 }
01081 }
01082
01083
01084
01085
01086
01087
01088
01089
01090
01091
01092
01093
01094
01095 BatchRenderStart::BatchRenderStart(BatchRenderThread *thread,
01096 int x,
01097 int y)
01098 : BC_GenericButton(x,
01099 y,
01100 _("Start"))
01101 {
01102 this->thread = thread;
01103 }
01104
01105 int BatchRenderStart::handle_event()
01106 {
01107 thread->start_rendering();
01108 return 1;
01109 }
01110
01111 BatchRenderStop::BatchRenderStop(BatchRenderThread *thread,
01112 int x,
01113 int y)
01114 : BC_GenericButton(x,
01115 y,
01116 _("Stop"))
01117 {
01118 this->thread = thread;
01119 }
01120
01121 int BatchRenderStop::handle_event()
01122 {
01123 unlock_window();
01124 thread->stop_rendering();
01125 lock_window("BatchRenderStop::handle_event");
01126 return 1;
01127 }
01128
01129
01130 BatchRenderCancel::BatchRenderCancel(BatchRenderThread *thread,
01131 int x,
01132 int y)
01133 : BC_GenericButton(x,
01134 y,
01135 _("Cancel"))
01136 {
01137 this->thread = thread;
01138 }
01139
01140 int BatchRenderCancel::handle_event()
01141 {
01142 unlock_window();
01143 thread->stop_rendering();
01144 lock_window("BatchRenderCancel::handle_event");
01145 thread->gui->set_done(1);
01146 return 1;
01147 }
01148
01149 int BatchRenderCancel::keypress_event()
01150 {
01151 if(get_keypress() == ESC)
01152 {
01153 unlock_window();
01154 thread->stop_rendering();
01155 lock_window("BatchRenderCancel::keypress_event");
01156 thread->gui->set_done(1);
01157 return 1;
01158 }
01159 return 0;
01160 }
01161
01162
01163