play_off preview tweak, zoombar auto_color fix, deactivate popupmenu on click while...
[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 "indexable.inc"
34 #include "keyframe.inc"
35 #include "mwindow.inc"
36 #include "preferences.inc"
37 #include "render.inc"
38 #include "timeentry.h"
39
40 enum {
41         ENABLED_COL, LABELED_COL, FARMED_COL,
42         OUTPUT_COL, EDL_COL, ELAPSED_COL,
43         BATCHRENDER_COLUMNS
44 };
45
46 class BatchRenderMenuItem : public BC_MenuItem
47 {
48 public:
49         BatchRenderMenuItem(MWindow *mwindow);
50         int handle_event();
51         MWindow *mwindow;
52 };
53
54
55
56 class BatchRenderJob
57 {
58 public:
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);
70
71         const char *tag;
72 // Source EDL to render
73         char edl_path[BCTEXTLEN];
74 // Destination file for output
75         Asset *asset;
76         int labeled, farmed;
77         int enabled;
78 // Amount of time elapsed in last render operation
79         double elapsed;
80         Preferences *preferences;
81 };
82
83
84
85
86
87
88
89
90 class BatchRenderThread : public BC_DialogThread
91 {
92 public:
93         BatchRenderThread(MWindow *mwindow=0);
94         ~BatchRenderThread();
95         void handle_close_event(int result);
96         BC_Window* new_gui();
97
98         int test_edl_files();
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);
110         void new_job();
111         void delete_job();
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);
120 // For GUI usage
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);
129
130         MWindow *mwindow;
131         char batch_path[BCTEXTLEN];
132         double current_start;
133         double current_end;
134         BatchRenderJob *default_job;
135         ArrayList<BatchRenderJob*> jobs;
136         BC_Hash *boot_defaults;
137         Preferences *preferences;
138         Render *render;
139         BatchRenderGUI *gui;
140
141         static const char *column_titles[BATCHRENDER_COLUMNS];
142         static int column_widths[BATCHRENDER_COLUMNS];
143         int list_width[BATCHRENDER_COLUMNS];
144         int do_farmed;
145         int do_labeled;
146 // job being edited
147         int current_job;
148 // job being rendered
149         int rendering_job;
150         int is_rendering;
151         int warn;
152 };
153
154
155
156 class BatchRenderEDLPath : public BC_TextBox
157 {
158 public:
159         BatchRenderEDLPath(BatchRenderThread *thread, int x, int y, int w,
160                 char *text);
161         int handle_event();
162         BatchRenderThread *thread;
163 };
164
165
166 class BatchRenderCurrentEDL : public BC_GenericButton
167 {
168 public:
169         BatchRenderCurrentEDL(BatchRenderThread *thread, int x, int y);
170         int handle_event();
171         BatchRenderThread *thread;
172 };
173
174
175 class BatchRenderUpdateEDL : public BC_GenericButton
176 {
177 public:
178         BatchRenderUpdateEDL(BatchRenderThread *thread, int x, int y);
179         int handle_event();
180         BatchRenderThread *thread;
181 };
182
183
184 class BatchRenderNew : public BC_GenericButton
185 {
186 public:
187         BatchRenderNew(BatchRenderThread *thread, int x, int y);
188         int handle_event();
189         BatchRenderThread *thread;
190 };
191
192 class BatchRenderDelete : public BC_GenericButton
193 {
194 public:
195         BatchRenderDelete(BatchRenderThread *thread, int x, int y);
196         int handle_event();
197         BatchRenderThread *thread;
198 };
199
200
201
202 class BatchRenderSaveList : public BC_GenericButton, public Thread
203 {
204 public:
205         BatchRenderSaveList(BatchRenderThread *thread, int x, int y);
206         ~BatchRenderSaveList();
207         int handle_event();
208         BatchRenderThread *thread;
209         BC_FileBox *gui;
210         void run();
211         void stop();
212         virtual int keypress_event();
213         Mutex *startup_lock;
214 };
215
216 class BatchRenderLoadList : public BC_GenericButton, public Thread
217 {
218 public:
219         BatchRenderLoadList(BatchRenderThread *thread, int x, int y);
220         ~BatchRenderLoadList();
221         int handle_event();
222         BatchRenderThread *thread;
223         BC_FileBox *gui;
224         void run();
225         void stop();
226         virtual int keypress_event();
227         Mutex *startup_lock;
228 };
229
230
231
232 class BatchRenderList : public BC_ListBox
233 {
234 public:
235         BatchRenderList(BatchRenderThread *thread, int x, int y, int w, int h);
236         int handle_event();
237         int selection_changed();
238         int column_resize_event();
239         int drag_start_event();
240         int drag_motion_event();
241         int drag_stop_event();
242         int dragging_item;
243         BatchRenderThread *thread;
244 };
245 class BatchRenderStart : public BC_GenericButton
246 {
247 public:
248         BatchRenderStart(BatchRenderThread *thread, int x, int y);
249         int handle_event();
250         BatchRenderThread *thread;
251 };
252
253 class BatchRenderStop : public BC_GenericButton
254 {
255 public:
256         BatchRenderStop(BatchRenderThread *thread, int x, int y);
257         int handle_event();
258         BatchRenderThread *thread;
259 };
260
261 class BatchRenderWarning : public BC_CheckBox
262 {
263 public:
264         BatchRenderWarning(BatchRenderThread *thread, int x, int y);
265         int handle_event();
266         BatchRenderThread *thread;
267 };
268
269 class BatchRenderCancel : public BC_GenericButton
270 {
271 public:
272         BatchRenderCancel(BatchRenderThread *thread, int x, int y);
273         int handle_event();
274         int keypress_event();
275         BatchRenderThread *thread;
276 };
277
278
279 class BatchFormat : public FormatTools
280 {
281 public:
282         BatchFormat(MWindow *mwindow, BatchRenderGUI *gui, Asset *asset);
283         ~BatchFormat();
284
285         int handle_event();
286
287         BatchRenderGUI *gui;
288         MWindow *mwindow;
289 };
290
291 class BatchRenderUseFarm : public BC_CheckBox
292 {
293 public:
294         BatchRenderUseFarm(BatchRenderThread *thread, int x, int y, int *output);
295         int handle_event();
296         void update(int *output);
297
298         BatchRenderThread *thread;
299         int *output;
300 };
301
302
303 class BatchRenderGUI : public BC_Window
304 {
305 public:
306         BatchRenderGUI(MWindow *mwindow,
307                 BatchRenderThread *thread,
308                 int x,
309                 int y,
310                 int w,
311                 int h);
312         ~BatchRenderGUI();
313
314         void create_objects();
315         int resize_event(int w, int h);
316         int translation_event();
317         int close_event();
318         void create_list(int update_widget);
319         void change_job();
320         void button_enable();
321         void button_disable();
322
323         ArrayList<BC_ListBoxItem*> list_items[BATCHRENDER_COLUMNS];
324         const char *list_titles[BATCHRENDER_COLUMNS];
325         int list_width[BATCHRENDER_COLUMNS], list_columns;
326
327         MWindow *mwindow;
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;
351 };
352
353
354 #endif