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;
204 virtual int keypress_event();
208 class BatchRenderLoadList : public BC_GenericButton, public Thread
211 BatchRenderLoadList(BatchRenderThread *thread, int x, int y);
212 ~BatchRenderLoadList();
214 BatchRenderThread *thread;
218 virtual int keypress_event();
224 class BatchRenderList : public BC_ListBox
227 BatchRenderList(BatchRenderThread *thread, int x, int y, int w, int h);
229 int selection_changed();
230 int column_resize_event();
231 int drag_start_event();
232 int drag_motion_event();
233 int drag_stop_event();
235 BatchRenderThread *thread;
237 class BatchRenderStart : public BC_GenericButton
240 BatchRenderStart(BatchRenderThread *thread, int x, int y);
242 BatchRenderThread *thread;
245 class BatchRenderStop : public BC_GenericButton
248 BatchRenderStop(BatchRenderThread *thread, int x, int y);
250 BatchRenderThread *thread;
253 class BatchRenderWarning : public BC_CheckBox
256 BatchRenderWarning(BatchRenderThread *thread, int x, int y);
258 BatchRenderThread *thread;
261 class BatchRenderCancel : public BC_GenericButton
264 BatchRenderCancel(BatchRenderThread *thread, int x, int y);
266 int keypress_event();
267 BatchRenderThread *thread;
271 class BatchFormat : public FormatTools
274 BatchFormat(MWindow *mwindow, BatchRenderGUI *gui, Asset *asset);
283 class BatchRenderUseFarm : public BC_CheckBox
286 BatchRenderUseFarm(BatchRenderThread *thread, int x, int y, int *output);
288 void update(int *output);
290 BatchRenderThread *thread;
295 class BatchRenderGUI : public BC_Window
298 BatchRenderGUI(MWindow *mwindow,
299 BatchRenderThread *thread,
306 void create_objects();
307 int resize_event(int w, int h);
308 int translation_event();
310 void create_list(int update_widget);
312 void button_enable();
313 void button_disable();
315 ArrayList<BC_ListBoxItem*> list_items[BATCHRENDER_COLUMNS];
316 const char *list_titles[BATCHRENDER_COLUMNS];
317 int list_width[BATCHRENDER_COLUMNS], list_columns;
320 BatchRenderThread *thread;
321 BC_Title *output_path_title;
322 BatchFormat *format_tools;
323 BrowseButton *edl_path_browse;
324 BatchRenderEDLPath *edl_path_text;
325 BC_Title *edl_path_title;
326 // BC_Title *status_title;
327 // BC_Title *status_text;
328 // BC_ProgressBar *progress_bar;
329 BC_Title *list_title;
330 BC_Title *batch_path;
331 BatchRenderNew *new_batch;
332 BatchRenderDelete *delete_batch;
333 BatchRenderSaveList *savelist_batch;
334 BatchRenderLoadList *loadlist_batch;
335 BatchRenderWarning *warning;
336 BatchRenderList *batch_list;
337 BatchRenderStart *start_button;
338 BatchRenderStop *stop_button;
339 BatchRenderCancel *cancel_button;
340 BatchRenderCurrentEDL *use_current_edl;
341 BatchRenderUpdateEDL *update_selected_edl;
342 BatchRenderUseFarm *use_renderfarm;