r901: Automation::fit_autos() now works and automation_{min,max} variable removed
[cinelerra_cv/pmdumuid.git] / cinelerra / mwindow.h
blobc9b7d3eb3e8f2d933c8215a19adb41fe8d777b21
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 *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);
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(ArrayList<Asset*> *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 paste_edls(ArrayList<EDL*> *new_edls,
125 int load_mode,
126 Track *first_track /* = 0 */,
127 double current_position /* = -1 */,
128 int edit_labels,
129 int edit_plugins);
130 // Reset everything for a load
131 void update_project(int load_mode);
132 // Fit selected time to horizontal display range
133 void fit_selection();
134 // Fit selected autos to the vertical display range
135 void fit_autos(int doall);
136 void change_currentautorange(int autogrouptype, int increment, int changemax);
137 void expand_autos(int changeall, int domin, int domax);
138 void shrink_autos(int changeall, int domin, int domax);
139 // move the window to include the cursor
140 void find_cursor();
141 // Append a plugindb with pointers to the master plugindb
142 void create_plugindb(int do_audio,
143 int do_video,
144 int is_realtime,
145 int is_transition,
146 int is_theme,
147 ArrayList<PluginServer*> &plugindb);
148 // Find the plugin whose title matches title and return it
149 PluginServer* scan_plugindb(char *title,
150 int data_type);
151 void dump_plugins();
156 int load_filenames(ArrayList<char*> *filenames,
157 int load_mode = LOAD_REPLACE,
158 // Cause the project filename on the top of the window to be updated.
159 // Not wanted for loading backups.
160 int update_filename = 1,
161 char *reel_name = "cin0000",
162 int reel_number = 0,
163 int overwrite_reel = 0);
166 // Print out plugins which are referenced in the EDL but not loaded.
167 void test_plugins(EDL *new_edl, char *path);
169 int interrupt_indexes(); // Stop index building
172 int redraw_time_dependancies(); // after reconfiguring the time format, sample rate, frame rate
174 // =========================================== movement
176 void next_time_format();
177 void prev_time_format();
178 void time_format_common();
179 int reposition_timebar(int new_pixel, int new_height);
180 int expand_sample(double fixed_sample = -1); // fixed_sample is the sample that should hold fixed position on the screen after zooming, -1 = selection
181 int zoom_in_sample(double fixed_sample = -1);
182 int zoom_sample(int64_t zoom_sample, int64_t view_start = -1); // what's the supposed view start
183 void zoom_amp(int64_t zoom_amp);
184 void zoom_track(int64_t zoom_track);
185 int fit_sample();
186 int move_left(int64_t distance = 0);
187 int move_right(int64_t distance = 0);
188 void move_up(int64_t distance = 0);
189 void move_down(int64_t distance = 0);
191 // seek to labels
192 // shift_down must be passed by the caller because different windows call
193 // into this
194 int next_label(int shift_down);
195 int prev_label(int shift_down);
196 // seek to edit handles
197 int next_edit_handle(int shift_down);
198 int prev_edit_handle(int shift_down);
199 void trackmovement(int track_start);
200 int samplemovement(int64_t view_start); // view_start is pixels
201 void select_all();
202 int goto_start();
203 int goto_end();
204 int expand_y();
205 int zoom_in_y();
206 int expand_t();
207 int zoom_in_t();
208 void crop_video();
209 void update_plugins();
210 // Call after every edit operation
211 void save_backup();
212 void show_plugin(Plugin *plugin);
213 void hide_plugin(Plugin *plugin, int lock);
214 void hide_plugins();
215 // Update plugins with configuration changes.
216 // Called by TrackCanvas::cursor_motion_event.
217 void update_plugin_guis();
218 void update_plugin_states();
219 void update_plugin_titles();
220 // Called by Attachmentpoint during playback.
221 // Searches for matching plugin and renders data in it.
222 void render_plugin_gui(void *data, Plugin *plugin);
223 void render_plugin_gui(void *data, int size, Plugin *plugin);
225 // Called from PluginVClient::process_buffer
226 // Returns 1 if a GUI for the plugin is open so OpenGL routines can determine if
227 // they can run.
228 int plugin_gui_open(Plugin *plugin);
231 // ============================= editing commands ========================
233 // Map each recordable audio track to the desired pattern
234 void map_audio(int pattern);
235 enum
237 AUDIO_5_1_TO_2,
238 AUDIO_1_TO_1
240 void add_audio_track_entry(int above, Track *dst);
241 int add_audio_track(int above, Track *dst);
242 void add_clip_to_edl(EDL *edl);
243 void add_video_track_entry(Track *dst = 0);
244 int add_video_track(int above, Track *dst);
246 void asset_to_size();
247 void asset_to_rate();
248 // Entry point for clear operations.
249 void clear_entry();
250 // Clears active region in EDL.
251 // If clear_handle, edit boundaries are cleared if the range is 0.
252 // Called by paste, record, menueffects, render, and CWindow drop.
253 void clear(int clear_handle);
254 void clear_labels();
255 int clear_labels(double start, double end);
256 void concatenate_tracks();
257 void copy();
258 int copy(double start, double end);
259 void cut();
261 // Calculate aspect ratio from pixel counts
262 static int create_aspect_ratio(float &w, float &h, int width, int height);
263 // Calculate defaults path
264 static void create_defaults_path(char *string);
266 void delete_folder(char *folder);
267 void delete_inpoint();
268 void delete_outpoint();
270 void delete_track();
271 void delete_track(Track *track);
272 void delete_tracks();
273 void detach_transition(Transition *transition);
274 int feather_edits(int64_t feather_samples, int audio, int video);
275 int64_t get_feather(int audio, int video);
276 float get_aspect_ratio();
277 void insert(double position,
278 FileXML *file,
279 int edit_labels,
280 int edit_plugins,
281 EDL *parent_edl = 0);
283 // TrackCanvas calls this to insert multiple effects from the drag_pluginservers
284 // into pluginset_highlighted.
285 void insert_effects_canvas(double start,
286 double length);
288 // CWindow calls this to insert multiple effects from
289 // the drag_pluginservers array.
290 void insert_effects_cwindow(Track *dest_track);
292 // This is called multiple times by the above functions.
293 // It can't sync parameters.
294 void insert_effect(char *title,
295 SharedLocation *shared_location,
296 Track *track,
297 PluginSet *plugin_set,
298 double start,
299 double length,
300 int plugin_type);
302 void match_output_size(Track *track);
303 // Move edit to new position
304 void move_edits(ArrayList<Edit*> *edits,
305 Track *track,
306 double position,
307 int behaviour); // behaviour: 0 - old style (cut and insert elswhere), 1- new style - (clear and overwrite elsewere)
308 // Move effect to position
309 void move_effect(Plugin *plugin,
310 PluginSet *plugin_set,
311 Track *track,
312 int64_t position);
313 void move_plugins_up(PluginSet *plugin_set);
314 void move_plugins_down(PluginSet *plugin_set);
315 void move_track_down(Track *track);
316 void move_tracks_down();
317 void move_track_up(Track *track);
318 void move_tracks_up();
319 void mute_selection();
320 void new_folder(char *new_folder);
321 void overwrite(EDL *source);
322 // For clipboard commands
323 void paste();
324 // For splice and overwrite
325 int paste(double start,
326 double end,
327 FileXML *file,
328 int edit_labels,
329 int edit_plugins);
330 int paste_output(int64_t startproject,
331 int64_t endproject,
332 int64_t startsource_sample,
333 int64_t endsource_sample,
334 int64_t startsource_frame,
335 int64_t endsource_frame,
336 Asset *asset,
337 RecordLabels *new_labels);
338 void paste_silence();
340 void paste_transition();
341 void paste_transition_cwindow(Track *dest_track);
342 void paste_audio_transition();
343 void paste_video_transition();
344 void rebuild_indices();
345 // Asset removal from caches
346 void reset_caches();
347 void remove_asset_from_caches(Asset *asset);
348 void remove_assets_from_project(int push_undo = 0);
349 void remove_assets_from_disk();
350 void resize_track(Track *track, int w, int h);
351 void set_auto_keyframes(int value);
352 // Update the editing mode
353 int set_editing_mode(int new_editing_mode);
354 void set_inpoint(int is_mwindow);
355 void set_outpoint(int is_mwindow);
356 void splice(EDL *source);
357 void toggle_loop_playback();
358 void trim_selection();
359 // Synchronize EDL settings with all playback engines depending on current
360 // operation. Doesn't redraw anything.
361 void sync_parameters(int change_type = CHANGE_PARAMS);
362 void to_clip();
363 int toggle_label(int is_mwindow);
364 void undo_entry(BC_WindowBase *calling_window_gui);
365 void redo_entry(BC_WindowBase *calling_window_gui);
368 int cut_automation();
369 int copy_automation();
370 int paste_automation();
371 void clear_automation();
372 void straighten_automation();
373 int cut_default_keyframe();
374 int copy_default_keyframe();
375 // Use paste_automation to paste the default keyframe in other position.
376 // Use paste_default_keyframe to replace the default keyframe with whatever is
377 // in the clipboard.
378 int paste_default_keyframe();
379 int clear_default_keyframe();
381 int modify_edithandles();
382 int modify_pluginhandles();
383 void finish_modify_handles();
391 // Send new EDL to caches
392 void age_caches();
393 int optimize_assets(); // delete unused assets from the cache and assets
396 void select_point(double position);
397 int set_loop_boundaries(); // toggle loop playback and set boundaries for loop playback
400 Playback3D *playback_3d;
401 RemoveThread *remove_thread;
403 SplashGUI *splash_window;
404 // Main undo stack
405 MainUndo *undo;
406 BC_Hash *defaults;
407 Assets *assets;
408 // CICaches for drawing timeline only
409 CICache *audio_cache, *video_cache;
410 // Frame cache for drawing timeline only.
411 // Cache drawing doesn't wait for file decoding.
412 FrameCache *frame_cache;
413 WaveCache *wave_cache;
414 Preferences *preferences;
415 PreferencesThread *preferences_thread;
416 MainSession *session;
417 Theme *theme;
418 MainIndexes *mainindexes;
419 MainProgress *mainprogress;
420 BRender *brender;
422 // Menu items
423 ArrayList<ColormodelItem*> colormodels;
424 ArrayList<InterlaceautofixoptionItem*> interlace_asset_autofixoptions;
425 ArrayList<InterlacemodeItem*> interlace_project_modes;
426 ArrayList<InterlacemodeItem*> interlace_asset_modes;
427 ArrayList<InterlacefixmethodItem*> interlace_asset_fixmethods;
429 int reset_meters();
431 // Channel DB for playback only. Record channel DB's are in record.C
432 ChannelDB *channeldb_buz;
433 ChannelDB *channeldb_v4l2jpeg;
435 // ====================================== plugins ==============================
437 // Contain file descriptors for all the dlopens
438 ArrayList<PluginServer*> *plugindb;
439 // Currently visible plugins
440 ArrayList<PluginServer*> *plugin_guis;
443 // Adjust sample position to line up with frames.
444 int fix_timing(int64_t &samples_out,
445 int64_t &frames_out,
446 int64_t samples_in);
449 BatchRenderThread *batch_render;
450 Render *render;
452 ExportEDL *exportedl;
455 // Master edl
456 EDL *edl;
457 // Main Window GUI
458 MWindowGUI *gui;
459 // Compositor
460 CWindow *cwindow;
461 // Viewer
462 VWindow *vwindow;
463 // Asset manager
464 AWindow *awindow;
465 // Automation window
466 GWindow *gwindow;
467 // Tip of the day
468 TipWindow *twindow;
469 // Levels
470 LevelWindow *lwindow;
471 // Lock during creation and destruction of GUI
472 Mutex *plugin_gui_lock;
473 // Lock during creation and destruction of brender so playback doesn't use it.
474 Mutex *brender_lock;
476 // Single device drivers which must be shared between audio and video go here.
477 // They are managed by the garbage collector.
478 DeviceDVBInput *dvb_input;
479 // Must be locked before accessing dvb_input or Garbage functions in it.
480 Mutex *dvb_input_lock;
483 // Initialize shared memory
484 void init_shm();
486 // Initialize channel DB's for playback
487 void init_channeldb();
488 void init_render();
489 void init_exportedl();
490 // These three happen synchronously with each other
491 // Make sure this is called after synchronizing EDL's.
492 void init_brender();
493 // Restart brender after testing its existence
494 void restart_brender();
495 // Stops brender after testing its existence
496 void stop_brender();
497 // This one happens asynchronously of the others. Used by playback to
498 // see what frame is background rendered.
499 int brender_available(int position);
500 void set_brender_start();
502 void init_error();
503 static void init_defaults(BC_Hash* &defaults,
504 char *config_path);
505 void init_edl();
506 void init_awindow();
507 void init_gwindow();
508 void init_tipwindow();
509 // Used by MWindow and RenderFarmClient
510 static void init_plugins(Preferences *preferences,
511 ArrayList<PluginServer*>* &plugindb,
512 SplashGUI *splash_window);
513 static void init_plugin_path(Preferences *preferences,
514 ArrayList<PluginServer*>* &plugindb,
515 FileSystem *fs,
516 SplashGUI *splash_window,
517 int *counter);
518 void init_preferences();
519 void init_signals();
520 void init_theme();
521 void init_compositor();
522 void init_levelwindow();
523 void init_viewer();
524 void init_cache();
525 void init_menus();
526 void init_indexes();
527 void init_gui();
528 void init_3d();
529 void init_playbackcursor();
530 void delete_plugins();
532 void clean_indexes();
533 // TimeBomb timebomb;
534 SigHandler *sighandler;
537 #endif