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