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