shuttle and transportque reworks, new shdmp, titler font textbox tweak
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / batchrender.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
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.
10  *
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.
15  *
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
19  *
20  */
21
22 #ifndef BATCHRENDER_H
23 #define BATCHRENDER_H
24
25 #include "arraylist.h"
26 #include "asset.inc"
27 #include "batchrender.inc"
28 #include "bcbutton.h"
29 #include "bcdialog.h"
30 #include "browsebutton.inc"
31 #include "filexml.inc"
32 #include "formattools.h"
33 #include "keyframe.inc"
34 #include "mwindow.inc"
35 #include "preferences.inc"
36 #include "render.inc"
37 #include "timeentry.h"
38
39 enum {
40         ENABLED_COL, LABELED_COL, FARMED_COL,
41         OUTPUT_COL, EDL_COL, ELAPSED_COL,
42         BATCHRENDER_COLUMNS
43 };
44
45 class BatchRenderMenuItem : public BC_MenuItem
46 {
47 public:
48         BatchRenderMenuItem(MWindow *mwindow);
49         int handle_event();
50         MWindow *mwindow;
51 };
52
53
54
55 class BatchRenderJob
56 {
57 public:
58         BatchRenderJob(Preferences *preferences, int labeled=0, int farmed=-1);
59         ~BatchRenderJob();
60
61         void copy_from(BatchRenderJob *src);
62         void load(FileXML *file);
63         void save(FileXML *file);
64         int get_strategy();
65
66 // Source EDL to render
67         char edl_path[BCTEXTLEN];
68 // Destination file for output
69         Asset *asset;
70         int labeled, farmed;
71         int enabled;
72 // Amount of time elapsed in last render operation
73         double elapsed;
74         Preferences *preferences;
75 };
76
77
78
79
80
81
82
83
84 class BatchRenderThread : public BC_DialogThread
85 {
86 public:
87         BatchRenderThread(MWindow *mwindow);
88         BatchRenderThread();
89         ~BatchRenderThread();
90         void handle_close_event(int result);
91         BC_Window* new_gui();
92
93         int test_edl_files();
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);
105         void new_job();
106         void delete_job();
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);
115 // For GUI usage
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);
123
124         MWindow *mwindow;
125         char batch_path[BCTEXTLEN];
126         double current_start;
127         double current_end;
128         BatchRenderJob *default_job;
129         ArrayList<BatchRenderJob*> jobs;
130         BC_Hash *boot_defaults;
131         Preferences *preferences;
132         Render *render;
133         BatchRenderGUI *gui;
134
135         static const char *column_titles[BATCHRENDER_COLUMNS];
136         static int column_widths[BATCHRENDER_COLUMNS];
137         int list_width[BATCHRENDER_COLUMNS];
138 // job being edited
139         int current_job;
140 // job being rendered
141         int rendering_job;
142         int is_rendering;
143         int warn;
144 };
145
146
147
148 class BatchRenderEDLPath : public BC_TextBox
149 {
150 public:
151         BatchRenderEDLPath(BatchRenderThread *thread, int x, int y, int w,
152                 char *text);
153         int handle_event();
154         BatchRenderThread *thread;
155 };
156
157
158 class BatchRenderCurrentEDL : public BC_GenericButton
159 {
160 public:
161         BatchRenderCurrentEDL(BatchRenderThread *thread, int x, int y);
162         int handle_event();
163         BatchRenderThread *thread;
164 };
165
166
167 class BatchRenderUpdateEDL : public BC_GenericButton
168 {
169 public:
170         BatchRenderUpdateEDL(BatchRenderThread *thread, int x, int y);
171         int handle_event();
172         BatchRenderThread *thread;
173 };
174
175
176 class BatchRenderNew : public BC_GenericButton
177 {
178 public:
179         BatchRenderNew(BatchRenderThread *thread, int x, int y);
180         int handle_event();
181         BatchRenderThread *thread;
182 };
183
184 class BatchRenderDelete : public BC_GenericButton
185 {
186 public:
187         BatchRenderDelete(BatchRenderThread *thread, int x, int y);
188         int handle_event();
189         BatchRenderThread *thread;
190 };
191
192
193
194 class BatchRenderSaveList : public BC_GenericButton, public Thread
195 {
196 public:
197         BatchRenderSaveList(BatchRenderThread *thread, int x, int y);
198         ~BatchRenderSaveList();
199         int handle_event();
200         BatchRenderThread *thread;
201         BC_FileBox *gui;
202         void run();
203         void stop();
204         virtual int keypress_event();
205         Mutex *startup_lock;
206 };
207
208 class BatchRenderLoadList : public BC_GenericButton, public Thread
209 {
210 public:
211         BatchRenderLoadList(BatchRenderThread *thread, int x, int y);
212         ~BatchRenderLoadList();
213         int handle_event();
214         BatchRenderThread *thread;
215         BC_FileBox *gui;
216         void run();
217         void stop();
218         virtual int keypress_event();
219         Mutex *startup_lock;
220 };
221
222
223
224 class BatchRenderList : public BC_ListBox
225 {
226 public:
227         BatchRenderList(BatchRenderThread *thread, int x, int y, int w, int h);
228         int handle_event();
229         int selection_changed();
230         int column_resize_event();
231         int drag_start_event();
232         int drag_motion_event();
233         int drag_stop_event();
234         int dragging_item;
235         BatchRenderThread *thread;
236 };
237 class BatchRenderStart : public BC_GenericButton
238 {
239 public:
240         BatchRenderStart(BatchRenderThread *thread, int x, int y);
241         int handle_event();
242         BatchRenderThread *thread;
243 };
244
245 class BatchRenderStop : public BC_GenericButton
246 {
247 public:
248         BatchRenderStop(BatchRenderThread *thread, int x, int y);
249         int handle_event();
250         BatchRenderThread *thread;
251 };
252
253 class BatchRenderWarning : public BC_CheckBox
254 {
255 public:
256         BatchRenderWarning(BatchRenderThread *thread, int x, int y);
257         int handle_event();
258         BatchRenderThread *thread;
259 };
260
261 class BatchRenderCancel : public BC_GenericButton
262 {
263 public:
264         BatchRenderCancel(BatchRenderThread *thread, int x, int y);
265         int handle_event();
266         int keypress_event();
267         BatchRenderThread *thread;
268 };
269
270
271 class BatchFormat : public FormatTools
272 {
273 public:
274         BatchFormat(MWindow *mwindow, BatchRenderGUI *gui, Asset *asset);
275         ~BatchFormat();
276
277         int handle_event();
278
279         BatchRenderGUI *gui;
280         MWindow *mwindow;
281 };
282
283 class BatchRenderUseFarm : public BC_CheckBox
284 {
285 public:
286         BatchRenderUseFarm(BatchRenderThread *thread, int x, int y, int *output);
287         int handle_event();
288         void update(int *output);
289
290         BatchRenderThread *thread;
291         int *output;
292 };
293
294
295 class BatchRenderGUI : public BC_Window
296 {
297 public:
298         BatchRenderGUI(MWindow *mwindow,
299                 BatchRenderThread *thread,
300                 int x,
301                 int y,
302                 int w,
303                 int h);
304         ~BatchRenderGUI();
305
306         void create_objects();
307         int resize_event(int w, int h);
308         int translation_event();
309         int close_event();
310         void create_list(int update_widget);
311         void change_job();
312         void button_enable();
313         void button_disable();
314
315         ArrayList<BC_ListBoxItem*> list_items[BATCHRENDER_COLUMNS];
316         const char *list_titles[BATCHRENDER_COLUMNS];
317         int list_width[BATCHRENDER_COLUMNS], list_columns;
318
319         MWindow *mwindow;
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;
343 };
344
345
346 #endif