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 "keyframe.inc"
34 #include "mwindow.inc"
35 #include "preferences.inc"
37 #include "timeentry.h"
40 ENABLED_COL, LABELED_COL, FARMED_COL,
41 OUTPUT_COL, EDL_COL, ELAPSED_COL,
45 class BatchRenderMenuItem : public BC_MenuItem
48 BatchRenderMenuItem(MWindow *mwindow);
58 BatchRenderJob(Preferences *preferences, int labeled=0, int farmed=-1);
61 void copy_from(BatchRenderJob *src);
62 void load(FileXML *file);
63 void save(FileXML *file);
66 // Source EDL to render
67 char edl_path[BCTEXTLEN];
68 // Destination file for output
72 // Amount of time elapsed in last render operation
74 Preferences *preferences;
84 class BatchRenderThread : public BC_DialogThread
87 BatchRenderThread(MWindow *mwindow);
90 void handle_close_event(int result);
94 void calculate_dest_paths(ArrayList<char*> *paths,
95 Preferences *preferences);
96 void reset(const char *path=0);
97 // Load batch rendering jobs
98 void load_jobs(char *path, Preferences *preferences);
99 // Not applicable to western civilizations
100 void save_jobs(char *path=0);
101 void load_defaults(BC_Hash *defaults);
102 void save_defaults(BC_Hash *defaults);
103 // Create path for persistent storage functions
104 char* create_path(char *string);
107 void update_selected_edl();
108 void use_current_edl();
109 // Conditionally returns the job or the default job based on current_job
110 BatchRenderJob* get_current_job();
111 Asset* get_current_asset();
112 char* get_current_edl();
113 // For command line usage
114 void start_rendering(char *config_path, char *batch_path);
116 void start_rendering();
117 void stop_rendering();
118 // Highlight the currently rendering job.
119 void update_active(int number);
120 void update_done(int number, int create_list, double elapsed_time);
121 void move_batch(int src, int dst);
122 static void trap_hook(FILE *fp, void *vp);
125 char batch_path[BCTEXTLEN];
126 double current_start;
128 BatchRenderJob *default_job;
129 ArrayList<BatchRenderJob*> jobs;
130 BC_Hash *boot_defaults;
131 Preferences *preferences;
135 static const char *column_titles[BATCHRENDER_COLUMNS];
136 static int column_widths[BATCHRENDER_COLUMNS];
137 int list_width[BATCHRENDER_COLUMNS];
140 // job being rendered
148 class BatchRenderEDLPath : public BC_TextBox
151 BatchRenderEDLPath(BatchRenderThread *thread, int x, int y, int w,
154 BatchRenderThread *thread;
158 class BatchRenderCurrentEDL : public BC_GenericButton
161 BatchRenderCurrentEDL(BatchRenderThread *thread, int x, int y);
163 BatchRenderThread *thread;
167 class BatchRenderUpdateEDL : public BC_GenericButton
170 BatchRenderUpdateEDL(BatchRenderThread *thread, int x, int y);
172 BatchRenderThread *thread;
176 class BatchRenderNew : public BC_GenericButton
179 BatchRenderNew(BatchRenderThread *thread, int x, int y);
181 BatchRenderThread *thread;
184 class BatchRenderDelete : public BC_GenericButton
187 BatchRenderDelete(BatchRenderThread *thread, int x, int y);
189 BatchRenderThread *thread;
194 class BatchRenderSaveList : public BC_GenericButton, public Thread
197 BatchRenderSaveList(BatchRenderThread *thread, int x, int y);
198 ~BatchRenderSaveList();
200 BatchRenderThread *thread;
203 virtual int keypress_event();
207 class BatchRenderLoadList : public BC_GenericButton, public Thread
210 BatchRenderLoadList(BatchRenderThread *thread, int x, int y);
211 ~BatchRenderLoadList();
213 BatchRenderThread *thread;
216 virtual int keypress_event();
222 class BatchRenderList : public BC_ListBox
225 BatchRenderList(BatchRenderThread *thread, int x, int y, int w, int h);
227 int selection_changed();
228 int column_resize_event();
229 int drag_start_event();
230 int drag_motion_event();
231 int drag_stop_event();
233 BatchRenderThread *thread;
235 class BatchRenderStart : public BC_GenericButton
238 BatchRenderStart(BatchRenderThread *thread, int x, int y);
240 BatchRenderThread *thread;
243 class BatchRenderStop : public BC_GenericButton
246 BatchRenderStop(BatchRenderThread *thread, int x, int y);
248 BatchRenderThread *thread;
251 class BatchRenderWarning : public BC_CheckBox
254 BatchRenderWarning(BatchRenderThread *thread, int x, int y);
256 BatchRenderThread *thread;
259 class BatchRenderCancel : public BC_GenericButton
262 BatchRenderCancel(BatchRenderThread *thread, int x, int y);
264 int keypress_event();
265 BatchRenderThread *thread;
269 class BatchFormat : public FormatTools
272 BatchFormat(MWindow *mwindow, BatchRenderGUI *gui, Asset *asset);
281 class BatchRenderUseFarm : public BC_CheckBox
284 BatchRenderUseFarm(BatchRenderThread *thread, int x, int y, int *output);
286 void update(int *output);
288 BatchRenderThread *thread;
293 class BatchRenderGUI : public BC_Window
296 BatchRenderGUI(MWindow *mwindow,
297 BatchRenderThread *thread,
304 void create_objects();
305 int resize_event(int w, int h);
306 int translation_event();
308 void create_list(int update_widget);
310 void button_enable();
311 void button_disable();
313 ArrayList<BC_ListBoxItem*> list_items[BATCHRENDER_COLUMNS];
314 const char *list_titles[BATCHRENDER_COLUMNS];
315 int list_width[BATCHRENDER_COLUMNS], list_columns;
318 BatchRenderThread *thread;
319 BC_Title *output_path_title;
320 BatchFormat *format_tools;
321 BrowseButton *edl_path_browse;
322 BatchRenderEDLPath *edl_path_text;
323 BC_Title *edl_path_title;
324 // BC_Title *status_title;
325 // BC_Title *status_text;
326 // BC_ProgressBar *progress_bar;
327 BC_Title *list_title;
328 BC_Title *batch_path;
329 BatchRenderNew *new_batch;
330 BatchRenderDelete *delete_batch;
331 BatchRenderSaveList *savelist_batch;
332 BatchRenderLoadList *loadlist_batch;
333 BatchRenderWarning *warning;
334 BatchRenderList *batch_list;
335 BatchRenderStart *start_button;
336 BatchRenderStop *stop_button;
337 BatchRenderCancel *cancel_button;
338 BatchRenderCurrentEDL *use_current_edl;
339 BatchRenderUpdateEDL *update_selected_edl;
340 BatchRenderUseFarm *use_renderfarm;