r858: Merge 2.1:
[cinelerra_cv/ct.git] / cinelerra / mwindow.h
blobb06b1a4675412bec3fbdedcb06c5e56d721b8dc7
1 #ifndef MWINDOW_H
2 #define MWINDOW_H
4 #include "arraylist.h"
5 #include "asset.inc"
6 #include "assets.inc"
7 #include "audiodevice.inc"
8 #include "awindow.inc"
9 #include "batchrender.inc"
10 #include "bcwindowbase.inc"
11 #include "brender.inc"
12 #include "cache.inc"
13 #include "channel.inc"
14 #include "channeldb.inc"
15 #include "cwindow.inc"
16 #include "bchash.inc"
17 #include "edit.inc"
18 #include "edl.inc"
19 #include "filesystem.inc"
20 #include "filexml.inc"
21 #include "gwindow.inc"
22 #include "levelwindow.inc"
23 #include "loadmode.inc"
24 #include "mainerror.inc"
25 #include "mainindexes.inc"
26 #include "mainprogress.inc"
27 #include "mainsession.inc"
28 #include "mainundo.inc"
29 #include "maxchannels.h"
30 #include "mutex.inc"
31 #include "mwindow.inc"
32 #include "mwindowgui.inc"
33 #include "new.inc"
34 #include "patchbay.inc"
35 #include "playback3d.inc"
36 #include "playbackengine.inc"
37 #include "plugin.inc"
38 #include "pluginserver.inc"
39 #include "pluginset.inc"
40 #include "preferences.inc"
41 #include "preferencesthread.inc"
42 #include "recordlabel.inc"
43 #include "render.inc"
44 #include "sharedlocation.inc"
45 #include "sighandler.inc"
46 #include "splashgui.inc"
47 #include "theme.inc"
48 #include "thread.h"
49 #include "threadloader.inc"
50 #include "timebar.inc"
51 #include "timebomb.h"
52 #include "tipwindow.inc"
53 #include "track.inc"
54 #include "tracking.inc"
55 #include "tracks.inc"
56 #include "transition.inc"
57 #include "transportque.inc"
58 #include "videowindow.inc"
59 #include "vwindow.inc"
60 #include "bcwindowbase.inc"
61 #include "exportedl.inc"
63 #include <stdint.h>
65 // All entry points for commands except for window locking should be here.
66 // This allows scriptability.
68 class MWindow : public Thread
70 public:
71 MWindow();
72 ~MWindow();
74 // ======================================== initialization commands
75 void create_objects(int want_gui,
76 int want_new,
77 char *config_path);
78 void show_splash();
79 void hide_splash();
80 void start();
81 void run();
83 int run_script(FileXML *script);
84 int new_project();
85 int delete_project(int flash = 1);
87 int load_defaults();
88 int save_defaults();
89 int set_filename(char *filename);
90 // Total vertical pixels in timeline
91 int get_tracks_height();
92 // Total horizontal pixels in timeline
93 int get_tracks_width();
94 // Show windows
95 void show_vwindow();
96 void show_awindow();
97 void show_lwindow();
98 void show_cwindow();
99 void show_gwindow();
100 void tile_windows();
101 void set_titles(int value);
102 int asset_to_edl(EDL *new_edl, Asset *new_asset, RecordLabels *labels = 0);
104 // Entry point to insert assets and insert edls. Called by TrackCanvas
105 // and AssetPopup when assets are dragged in from AWindow.
106 // Takes the drag vectors from MainSession and
107 // pastes either assets or clips depending on which is full.
108 // Returns 1 if the vectors were full
109 int paste_assets(double position, Track *dest_track);
111 // Insert the assets at a point in the EDL. Called by menueffects,
112 // render, and CWindow drop but recording calls paste_edls directly for
113 // labels.
114 void load_assets(ArrayList<Asset*> *new_assets,
115 double position,
116 int load_mode,
117 Track *first_track /* = 0 */,
118 RecordLabels *labels /* = 0 */,
119 int edit_labels,
120 int edit_plugins);
121 int paste_edls(ArrayList<EDL*> *new_edls,
122 int load_mode,
123 Track *first_track /* = 0 */,
124 double current_position /* = -1 */,
125 int edit_labels,
126 int edit_plugins);
127 // Reset everything for a load
128 void update_project(int load_mode);
129 // Fit selected time to horizontal display range
130 void fit_selection();
131 // Fit selected autos to the vertical display range
132 void fit_autos();
133 void expand_autos();
134 void shrink_autos();
135 // move the window to include the cursor
136 void find_cursor();
137 // Append a plugindb with pointers to the master plugindb
138 void create_plugindb(int do_audio,
139 int do_video,
140 int is_realtime,
141 int is_transition,
142 int is_theme,
143 ArrayList<PluginServer*> &plugindb);
144 // Find the plugin whose title matches title and return it
145 PluginServer* scan_plugindb(char *title,
146 int data_type);
147 void dump_plugins();
152 int load_filenames(ArrayList<char*> *filenames,
153 int load_mode = LOAD_REPLACE,
154 // Cause the project filename on the top of the window to be updated.
155 // Not wanted for loading backups.
156 int update_filename = 1,
157 char *reel_name = "cin0000",
158 int reel_number = 0,
159 int overwrite_reel = 0);
162 // Print out plugins which are referenced in the EDL but not loaded.
163 void test_plugins(EDL *new_edl, char *path);
165 int interrupt_indexes(); // Stop index building
168 int redraw_time_dependancies(); // after reconfiguring the time format, sample rate, frame rate
170 // =========================================== movement
172 void next_time_format();
173 void prev_time_format();
174 void time_format_common();
175 int reposition_timebar(int new_pixel, int new_height);
176 int expand_sample(double fixed_sample = -1); // fixed_sample is the sample that should hold fixed position on the screen after zooming, -1 = selection
177 int zoom_in_sample(double fixed_sample = -1);
178 int zoom_sample(int64_t zoom_sample, int64_t view_start = -1); // what's the supposed view start
179 void zoom_amp(int64_t zoom_amp);
180 void zoom_track(int64_t zoom_track);
181 int fit_sample();
182 int move_left(int64_t distance = 0);
183 int move_right(int64_t distance = 0);
184 void move_up(int64_t distance = 0);
185 void move_down(int64_t distance = 0);
187 // seek to labels
188 // shift_down must be passed by the caller because different windows call
189 // into this
190 int next_label(int shift_down);
191 int prev_label(int shift_down);
192 // seek to edit handles
193 int next_edit_handle(int shift_down);
194 int prev_edit_handle(int shift_down);
195 void trackmovement(int track_start);
196 int samplemovement(int64_t view_start); // view_start is pixels
197 void select_all();
198 int goto_start();
199 int goto_end();
200 int expand_y();
201 int zoom_in_y();
202 int expand_t();
203 int zoom_in_t();
204 void crop_video();
205 void update_plugins();
206 // Call after every edit operation
207 void save_backup();
208 void show_plugin(Plugin *plugin);
209 void hide_plugin(Plugin *plugin, int lock);
210 void hide_plugins();
211 // Update plugins with configuration changes.
212 // Called by TrackCanvas::cursor_motion_event.
213 void update_plugin_guis();
214 void update_plugin_states();
215 void update_plugin_titles();
216 // Called by Attachmentpoint during playback.
217 // Searches for matching plugin and renders data in it.
218 void render_plugin_gui(void *data, Plugin *plugin);
219 void render_plugin_gui(void *data, int size, Plugin *plugin);
221 // Called from PluginVClient::process_buffer
222 // Returns 1 if a GUI for the plugin is open so OpenGL routines can determine if
223 // they can run.
224 int plugin_gui_open(Plugin *plugin);
227 // ============================= editing commands ========================
229 void add_audio_track_entry(int above, Track *dst);
230 int add_audio_track(int above, Track *dst);
231 void add_clip_to_edl(EDL *edl);
232 void add_video_track_entry(Track *dst = 0);
233 int add_video_track(int above, Track *dst);
235 void asset_to_size();
236 void asset_to_rate();
237 // Entry point for clear operations.
238 void clear_entry();
239 // Clears active region in EDL.
240 // If clear_handle, edit boundaries are cleared if the range is 0.
241 // Called by paste, record, menueffects, render, and CWindow drop.
242 void clear(int clear_handle);
243 void clear_labels();
244 int clear_labels(double start, double end);
245 void concatenate_tracks();
246 void copy();
247 int copy(double start, double end);
248 static int create_aspect_ratio(float &w, float &h, int width, int height);
249 void cut();
251 // Calculate defaults path
252 static void create_defaults_path(char *string);
254 void delete_folder(char *folder);
255 void delete_inpoint();
256 void delete_outpoint();
258 void delete_track();
259 void delete_track(Track *track);
260 void delete_tracks();
261 void detach_transition(Transition *transition);
262 int feather_edits(int64_t feather_samples, int audio, int video);
263 int64_t get_feather(int audio, int video);
264 float get_aspect_ratio();
265 void insert(double position,
266 FileXML *file,
267 int edit_labels,
268 int edit_plugins,
269 EDL *parent_edl = 0);
271 // TrackCanvas calls this to insert multiple effects from the drag_pluginservers
272 // into pluginset_highlighted.
273 void insert_effects_canvas(double start,
274 double length);
276 // CWindow calls this to insert multiple effects from
277 // the drag_pluginservers array.
278 void insert_effects_cwindow(Track *dest_track);
280 // This is called multiple times by the above functions.
281 // It can't sync parameters.
282 void insert_effect(char *title,
283 SharedLocation *shared_location,
284 Track *track,
285 PluginSet *plugin_set,
286 double start,
287 double length,
288 int plugin_type);
290 void match_output_size(Track *track);
291 // Move edit to new position
292 void move_edits(ArrayList<Edit*> *edits,
293 Track *track,
294 double position,
295 int behaviour); // behaviour: 0 - old style (cut and insert elswhere), 1- new style - (clear and overwrite elsewere)
296 // Move effect to position
297 void move_effect(Plugin *plugin,
298 PluginSet *plugin_set,
299 Track *track,
300 int64_t position);
301 void move_plugins_up(PluginSet *plugin_set);
302 void move_plugins_down(PluginSet *plugin_set);
303 void move_track_down(Track *track);
304 void move_tracks_down();
305 void move_track_up(Track *track);
306 void move_tracks_up();
307 void mute_selection();
308 void new_folder(char *new_folder);
309 void overwrite(EDL *source);
310 // For clipboard commands
311 void paste();
312 // For splice and overwrite
313 int paste(double start,
314 double end,
315 FileXML *file,
316 int edit_labels,
317 int edit_plugins);
318 int paste_output(int64_t startproject,
319 int64_t endproject,
320 int64_t startsource_sample,
321 int64_t endsource_sample,
322 int64_t startsource_frame,
323 int64_t endsource_frame,
324 Asset *asset,
325 RecordLabels *new_labels);
326 void paste_silence();
328 void paste_transition();
329 void paste_transition_cwindow(Track *dest_track);
330 void paste_audio_transition();
331 void paste_video_transition();
332 void rebuild_indices();
333 // Asset removal from caches
334 void reset_caches();
335 void remove_asset_from_caches(Asset *asset);
336 void remove_assets_from_project(int push_undo = 0);
337 void remove_assets_from_disk();
338 void resize_track(Track *track, int w, int h);
339 void set_auto_keyframes(int value);
340 // Update the editing mode
341 int set_editing_mode(int new_editing_mode);
342 void set_inpoint(int is_mwindow);
343 void set_outpoint(int is_mwindow);
344 void splice(EDL *source);
345 void toggle_loop_playback();
346 void trim_selection();
347 // Synchronize EDL settings with all playback engines depending on current
348 // operation. Doesn't redraw anything.
349 void sync_parameters(int change_type = CHANGE_PARAMS);
350 void to_clip();
351 int toggle_label(int is_mwindow);
352 void undo_entry(BC_WindowBase *calling_window_gui);
353 void redo_entry(BC_WindowBase *calling_window_gui);
356 int cut_automation();
357 int copy_automation();
358 int paste_automation();
359 void clear_automation();
360 void straighten_automation();
361 int cut_default_keyframe();
362 int copy_default_keyframe();
363 // Use paste_automation to paste the default keyframe in other position.
364 // Use paste_default_keyframe to replace the default keyframe with whatever is
365 // in the clipboard.
366 int paste_default_keyframe();
367 int clear_default_keyframe();
369 int modify_edithandles();
370 int modify_pluginhandles();
371 void finish_modify_handles();
379 // Send new EDL to caches
380 void age_caches();
381 int optimize_assets(); // delete unused assets from the cache and assets
384 void select_point(double position);
385 int set_loop_boundaries(); // toggle loop playback and set boundaries for loop playback
388 Playback3D *playback_3d;
390 SplashGUI *splash_window;
391 // Main undo stack
392 MainUndo *undo;
393 BC_Hash *defaults;
394 Assets *assets;
395 // CICaches for drawing timeline only
396 CICache *audio_cache, *video_cache;
397 Preferences *preferences;
398 PreferencesThread *preferences_thread;
399 MainSession *session;
400 Theme *theme;
401 MainIndexes *mainindexes;
402 MainProgress *mainprogress;
403 BRender *brender;
405 // Menu items
406 ArrayList<ColormodelItem*> colormodels;
407 ArrayList<InterlaceautofixoptionItem*> interlace_asset_autofixoptions;
408 ArrayList<InterlacemodeItem*> interlace_project_modes;
409 ArrayList<InterlacemodeItem*> interlace_asset_modes;
410 ArrayList<InterlacefixmethodItem*> interlace_asset_fixmethods;
412 int reset_meters();
414 // Channel DB for playback only. Record channel DB's are in record.C
415 ChannelDB *channeldb_buz;
416 ChannelDB *channeldb_v4l2jpeg;
418 // ====================================== plugins ==============================
420 // Contain file descriptors for all the dlopens
421 ArrayList<PluginServer*> *plugindb;
422 // Currently visible plugins
423 ArrayList<PluginServer*> *plugin_guis;
426 // Adjust sample position to line up with frames.
427 int fix_timing(int64_t &samples_out,
428 int64_t &frames_out,
429 int64_t samples_in);
432 BatchRenderThread *batch_render;
433 Render *render;
435 ExportEDL *exportedl;
438 // Master edl
439 EDL *edl;
440 // Main Window GUI
441 MWindowGUI *gui;
442 // Compositor
443 CWindow *cwindow;
444 // Viewer
445 VWindow *vwindow;
446 // Asset manager
447 AWindow *awindow;
448 // Automation window
449 GWindow *gwindow;
450 // Tip of the day
451 TipWindow *twindow;
452 // Levels
453 LevelWindow *lwindow;
454 // Lock during creation and destruction of GUI
455 Mutex *plugin_gui_lock;
456 // Lock during creation and destruction of brender so playback doesn't use it.
457 Mutex *brender_lock;
460 // Initialize channel DB's for playback
461 void init_channeldb();
462 void init_render();
463 void init_exportedl();
464 // These three happen synchronously with each other
465 // Make sure this is called after synchronizing EDL's.
466 void init_brender();
467 // Restart brender after testing its existence
468 void restart_brender();
469 // Stops brender after testing its existence
470 void stop_brender();
471 // This one happens asynchronously of the others. Used by playback to
472 // see what frame is background rendered.
473 int brender_available(int position);
474 void set_brender_start();
476 void init_error();
477 static void init_defaults(BC_Hash* &defaults,
478 char *config_path);
479 void init_edl();
480 void init_awindow();
481 void init_gwindow();
482 void init_tipwindow();
483 // Used by MWindow and RenderFarmClient
484 static void init_plugins(Preferences *preferences,
485 ArrayList<PluginServer*>* &plugindb,
486 SplashGUI *splash_window);
487 static void init_plugin_path(Preferences *preferences,
488 ArrayList<PluginServer*>* &plugindb,
489 FileSystem *fs,
490 SplashGUI *splash_window,
491 int *counter);
492 void init_preferences();
493 void init_signals();
494 void init_theme();
495 void init_compositor();
496 void init_levelwindow();
497 void init_viewer();
498 void init_cache();
499 void init_menus();
500 void init_indexes();
501 void init_gui();
502 void init_3d();
503 void init_playbackcursor();
504 void delete_plugins();
506 void clean_indexes();
507 // TimeBomb timebomb;
508 SigHandler *sighandler;
511 #endif