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;
90 class BatchRenderThread : public BC_DialogThread
93 BatchRenderThread(MWindow *mwindow=0);
95 void handle_close_event(int result);
99 void calculate_dest_paths(ArrayList<char*> *paths,
100 Preferences *preferences);
101 void reset(const char *path=0);
102 // Load batch rendering jobs
103 void load_jobs(char *path, Preferences *preferences);
104 // Not applicable to western civilizations
105 void save_jobs(char *path=0);
106 void load_defaults(BC_Hash *defaults);
107 void save_defaults(BC_Hash *defaults);
108 // Create path for persistent storage functions
109 char* create_path(char *string);
112 void update_selected_edl();
113 void use_current_edl();
114 // Conditionally returns the job or the default job based on current_job
115 BatchRenderJob* get_current_job();
116 Asset* get_current_asset();
117 char* get_current_edl();
118 // For command line usage
119 void start_rendering(char *config_path, char *batch_path);
121 void start_rendering();
122 void stop_rendering();
123 // Highlight the currently rendering job.
124 void update_active(int number);
125 void update_done(int number, int create_list, double elapsed_time);
126 void move_batch(int src, int dst);
127 void start(int do_farmed, int do_labeled);
128 static void trap_hook(FILE *fp, void *vp);
131 char batch_path[BCTEXTLEN];
132 double current_start;
134 BatchRenderJob *default_job;
135 ArrayList<BatchRenderJob*> jobs;
136 BC_Hash *boot_defaults;
137 Preferences *preferences;
141 static const char *column_titles[BATCHRENDER_COLUMNS];
142 static int column_widths[BATCHRENDER_COLUMNS];
143 int list_width[BATCHRENDER_COLUMNS];
148 // job being rendered
156 class BatchRenderEDLPath : public BC_TextBox
159 BatchRenderEDLPath(BatchRenderThread *thread, int x, int y, int w,
162 BatchRenderThread *thread;
166 class BatchRenderCurrentEDL : public BC_GenericButton
169 BatchRenderCurrentEDL(BatchRenderThread *thread, int x, int y);
171 BatchRenderThread *thread;
175 class BatchRenderUpdateEDL : public BC_GenericButton
178 BatchRenderUpdateEDL(BatchRenderThread *thread, int x, int y);
180 BatchRenderThread *thread;
184 class BatchRenderNew : public BC_GenericButton
187 BatchRenderNew(BatchRenderThread *thread, int x, int y);
189 BatchRenderThread *thread;
192 class BatchRenderDelete : public BC_GenericButton
195 BatchRenderDelete(BatchRenderThread *thread, int x, int y);
197 BatchRenderThread *thread;
202 class BatchRenderSaveList : public BC_GenericButton, public Thread
205 BatchRenderSaveList(BatchRenderThread *thread, int x, int y);
206 ~BatchRenderSaveList();
208 BatchRenderThread *thread;
212 virtual int keypress_event();
216 class BatchRenderLoadList : public BC_GenericButton, public Thread
219 BatchRenderLoadList(BatchRenderThread *thread, int x, int y);
220 ~BatchRenderLoadList();
222 BatchRenderThread *thread;
226 virtual int keypress_event();
232 class BatchRenderList : public BC_ListBox
235 BatchRenderList(BatchRenderThread *thread, int x, int y, int w, int h);
237 int selection_changed();
238 int column_resize_event();
239 int drag_start_event();
240 int drag_motion_event();
241 int drag_stop_event();
243 BatchRenderThread *thread;
245 class BatchRenderStart : public BC_GenericButton
248 BatchRenderStart(BatchRenderThread *thread, int x, int y);
250 BatchRenderThread *thread;
253 class BatchRenderStop : public BC_GenericButton
256 BatchRenderStop(BatchRenderThread *thread, int x, int y);
258 BatchRenderThread *thread;
261 class BatchRenderWarning : public BC_CheckBox
264 BatchRenderWarning(BatchRenderThread *thread, int x, int y);
266 BatchRenderThread *thread;
269 class BatchRenderCancel : public BC_GenericButton
272 BatchRenderCancel(BatchRenderThread *thread, int x, int y);
274 int keypress_event();
275 BatchRenderThread *thread;
279 class BatchFormat : public FormatTools
282 BatchFormat(MWindow *mwindow, BatchRenderGUI *gui, Asset *asset);
291 class BatchRenderUseFarm : public BC_CheckBox
294 BatchRenderUseFarm(BatchRenderThread *thread, int x, int y, int *output);
296 void update(int *output);
298 BatchRenderThread *thread;
303 class BatchRenderGUI : public BC_Window
306 BatchRenderGUI(MWindow *mwindow,
307 BatchRenderThread *thread,
314 void create_objects();
315 int resize_event(int w, int h);
316 int translation_event();
318 void create_list(int update_widget);
320 void button_enable();
321 void button_disable();
323 ArrayList<BC_ListBoxItem*> list_items[BATCHRENDER_COLUMNS];
324 const char *list_titles[BATCHRENDER_COLUMNS];
325 int list_width[BATCHRENDER_COLUMNS], list_columns;
328 BatchRenderThread *thread;
329 BC_Title *output_path_title;
330 BatchFormat *format_tools;
331 BrowseButton *edl_path_browse;
332 BatchRenderEDLPath *edl_path_text;
333 BC_Title *edl_path_title;
334 // BC_Title *status_title;
335 // BC_Title *status_text;
336 // BC_ProgressBar *progress_bar;
337 BC_Title *list_title;
338 BC_Title *batch_path;
339 BatchRenderNew *new_batch;
340 BatchRenderDelete *delete_batch;
341 BatchRenderSaveList *savelist_batch;
342 BatchRenderLoadList *loadlist_batch;
343 BatchRenderWarning *warning;
344 BatchRenderList *batch_list;
345 BatchRenderStart *start_button;
346 BatchRenderStop *stop_button;
347 BatchRenderCancel *cancel_button;
348 BatchRenderCurrentEDL *use_current_edl;
349 BatchRenderUpdateEDL *update_selected_edl;
350 BatchRenderUseFarm *use_renderfarm;