4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "arraylist.h"
27 #include "batchrender.inc"
30 #include "browsebutton.inc"
31 #include "filexml.inc"
32 #include "formattools.h"
33 #include "indexable.inc"
34 #include "keyframe.inc"
35 #include "mwindow.inc"
36 #include "preferences.inc"
38 #include "timeentry.h"
41 ENABLED_COL, LABELED_COL, FARMED_COL,
42 OUTPUT_COL, EDL_COL, ELAPSED_COL,
46 class BatchRenderMenuItem : public BC_MenuItem
49 BatchRenderMenuItem(MWindow *mwindow);
59 BatchRenderJob(const char *tag,
60 Preferences *preferences, int labeled, int farmed);
61 BatchRenderJob(Preferences *preferences, int labeled, int farmed);
62 BatchRenderJob(const char *tag);
63 virtual ~BatchRenderJob();
64 virtual BatchRenderJob *copy();
65 virtual void load(FileXML *file);
66 virtual void save(FileXML *file);
67 virtual int get_strategy();
68 virtual char *create_script(EDL *edl, ArrayList<Indexable *> *idxbls);
69 void copy_from(BatchRenderJob *src);
72 // Source EDL to render
73 char edl_path[BCTEXTLEN];
74 // Destination file for output
78 // Amount of time elapsed in last render operation
80 Preferences *preferences;
84 class BatchRenderWarnJob
87 BatchRenderWarnJob() { no = 0; path = 0; }
88 ~BatchRenderWarnJob() { delete [] path; }
93 class BatchRenderWarnJobs : public ArrayList<BatchRenderWarnJob>
96 BatchRenderWarnJobs() {}
97 ~BatchRenderWarnJobs() {}
98 void add(int no, const char *path) {
99 BatchRenderWarnJob &job = append();
100 job.no = no; job.path = cstrdup(path);
104 class BatchRenderThread : public BC_DialogThread
107 BatchRenderThread(MWindow *mwindow=0);
108 ~BatchRenderThread();
109 void handle_close_event(int result);
110 BC_Window* new_gui();
112 int test_edl_files();
113 void calculate_dest_paths(ArrayList<char*> *paths,
114 Preferences *preferences);
115 void reset(const char *path=0);
116 // Load batch rendering jobs
117 void load_jobs(char *path, Preferences *preferences);
118 // Not applicable to western civilizations
119 void save_jobs(char *path=0);
120 void load_defaults(BC_Hash *defaults);
121 void save_defaults(BC_Hash *defaults);
122 // Create path for persistent storage functions
123 char* create_path(char *string);
126 void update_selected_edl();
127 void use_current_edl();
128 // Conditionally returns the job or the default job based on current_job
129 BatchRenderJob* get_current_job();
130 Asset* get_current_asset();
131 char* get_current_edl();
132 // For command line usage
133 void start_rendering(char *config_path, char *batch_path);
135 void start_rendering();
136 void stop_rendering();
137 // Highlight the currently rendering job.
138 void update_active(int number);
139 void update_done(int number, int create_list, double elapsed_time);
140 void move_batch(int src, int dst);
141 void start(int do_farmed, int do_labeled);
142 static void trap_hook(FILE *fp, void *vp);
145 char batch_path[BCTEXTLEN];
146 double current_start;
148 BatchRenderJob *default_job;
149 ArrayList<BatchRenderJob*> jobs;
150 BC_Hash *boot_defaults;
151 Preferences *preferences;
155 static const char *column_titles[BATCHRENDER_COLUMNS];
156 static int column_widths[BATCHRENDER_COLUMNS];
157 int list_width[BATCHRENDER_COLUMNS];
162 // job being rendered
170 class BatchRenderEDLPath : public BC_TextBox
173 BatchRenderEDLPath(BatchRenderThread *thread, int x, int y, int w,
176 BatchRenderThread *thread;
180 class BatchRenderCurrentEDL : public BC_GenericButton
183 BatchRenderCurrentEDL(BatchRenderThread *thread, int x, int y);
185 BatchRenderThread *thread;
189 class BatchRenderUpdateEDL : public BC_GenericButton
192 BatchRenderUpdateEDL(BatchRenderThread *thread, int x, int y);
194 BatchRenderThread *thread;
198 class BatchRenderNew : public BC_GenericButton
201 BatchRenderNew(BatchRenderThread *thread, int x, int y);
203 BatchRenderThread *thread;
206 class BatchRenderDelete : public BC_GenericButton
209 BatchRenderDelete(BatchRenderThread *thread, int x, int y);
211 BatchRenderThread *thread;
216 class BatchRenderSaveList : public BC_GenericButton, public Thread
219 BatchRenderSaveList(BatchRenderThread *thread, int x, int y);
220 ~BatchRenderSaveList();
222 BatchRenderThread *thread;
226 virtual int keypress_event();
230 class BatchRenderLoadList : public BC_GenericButton, public Thread
233 BatchRenderLoadList(BatchRenderThread *thread, int x, int y);
234 ~BatchRenderLoadList();
236 BatchRenderThread *thread;
240 virtual int keypress_event();
246 class BatchRenderList : public BC_ListBox
249 BatchRenderList(BatchRenderThread *thread, int x, int y, int w, int h);
251 int selection_changed();
252 int column_resize_event();
253 int drag_start_event();
254 int drag_motion_event();
255 int drag_stop_event();
257 BatchRenderThread *thread;
259 class BatchRenderStart : public BC_GenericButton
262 BatchRenderStart(BatchRenderThread *thread, int x, int y);
264 BatchRenderThread *thread;
267 class BatchRenderStop : public BC_GenericButton
270 BatchRenderStop(BatchRenderThread *thread, int x, int y);
272 BatchRenderThread *thread;
275 class BatchRenderWarning : public BC_CheckBox
278 BatchRenderWarning(BatchRenderThread *thread, int x, int y);
280 BatchRenderThread *thread;
283 class BatchRenderCancel : public BC_GenericButton
286 BatchRenderCancel(BatchRenderThread *thread, int x, int y);
288 int keypress_event();
289 BatchRenderThread *thread;
293 class BatchFormat : public FormatTools
296 BatchFormat(MWindow *mwindow, BatchRenderGUI *gui, Asset *asset);
305 class BatchRenderUseFarm : public BC_CheckBox
308 BatchRenderUseFarm(BatchRenderThread *thread, int x, int y, int *output);
310 void update(int *output);
312 BatchRenderThread *thread;
317 class BatchRenderGUI : public BC_Window
320 BatchRenderGUI(MWindow *mwindow,
321 BatchRenderThread *thread,
328 void create_objects();
329 int resize_event(int w, int h);
330 int translation_event();
332 void create_list(int update_widget);
334 void button_enable();
335 void button_disable();
337 ArrayList<BC_ListBoxItem*> list_items[BATCHRENDER_COLUMNS];
338 const char *list_titles[BATCHRENDER_COLUMNS];
339 int list_width[BATCHRENDER_COLUMNS], list_columns;
342 BatchRenderThread *thread;
343 BC_Title *output_path_title;
344 BatchFormat *format_tools;
345 BrowseButton *edl_path_browse;
346 BatchRenderEDLPath *edl_path_text;
347 BC_Title *edl_path_title;
348 // BC_Title *status_title;
349 // BC_Title *status_text;
350 // BC_ProgressBar *progress_bar;
351 BC_Title *list_title;
352 BC_Title *batch_path;
353 BatchRenderNew *new_batch;
354 BatchRenderDelete *delete_batch;
355 BatchRenderSaveList *savelist_batch;
356 BatchRenderLoadList *loadlist_batch;
357 BatchRenderWarning *warning;
358 BatchRenderList *batch_list;
359 BatchRenderStart *start_button;
360 BatchRenderStop *stop_button;
361 BatchRenderCancel *cancel_button;
362 BatchRenderCurrentEDL *use_current_edl;
363 BatchRenderUpdateEDL *update_selected_edl;
364 BatchRenderUseFarm *use_renderfarm;