r370: Heroine Virutal's official release 1.2.1
[cinelerra_cv/mob.git] / hvirtual / cinelerra / mwindow.h
blobfcd1f2e44d468134550fc3bbd84b76d176df9d5f
1 #ifndef MWINDOW_H
2 #define MWINDOW_H
4 #include "asset.inc"
5 #include "assets.inc"
6 #include "audiodevice.inc"
7 #include "arraylist.h"
8 #include "awindow.inc"
9 #include "batchrender.inc"
10 #include "brender.inc"
11 #include "cache.inc"
12 #include "channel.inc"
13 #include "channeldb.inc"
14 #include "cwindow.inc"
15 #include "defaults.inc"
16 #include "edit.inc"
17 #include "edl.inc"
18 #include "filesystem.inc"
19 #include "filexml.inc"
20 #include "levelwindow.inc"
21 #include "loadmode.inc"
22 #include "mainindexes.inc"
23 #include "mainprogress.inc"
24 #include "mainsession.inc"
25 #include "mainundo.inc"
26 #include "maxchannels.h"
27 #include "mutex.inc"
28 #include "mwindowgui.inc"
29 #include "mwindow.inc"
30 #include "new.inc"
31 #include "patchbay.inc"
32 #include "playbackengine.inc"
33 #include "plugin.inc"
34 #include "pluginserver.inc"
35 #include "pluginset.inc"
36 #include "preferences.inc"
37 #include "preferencesthread.inc"
38 #include "recordlabel.inc"
39 #include "render.inc"
40 #include "sharedlocation.inc"
41 #include "sighandler.inc"
42 #include "splashgui.inc"
43 #include "theme.inc"
44 #include "threadloader.inc"
45 #include "timebar.inc"
46 #include "timebomb.h"
47 #include "track.inc"
48 #include "tracking.inc"
49 #include "tracks.inc"
50 #include "transition.inc"
51 #include "transportque.inc"
52 #include "videowindow.inc"
53 #include "vwindow.inc"
56 #include <stdint.h>
58 // All entry points for commands except for window locking should be here.
59 // This allows scriptability.
61 class MWindow
63 public:
64 MWindow();
65 ~MWindow();
67 // ======================================== initialization commands
68 void create_objects(int want_gui,
69 int want_new,
70 char *config_path);
71 void show_splash();
72 void hide_splash();
73 void start();
75 int run_script(FileXML *script);
76 int new_project();
77 int delete_project(int flash = 1);
79 int load_defaults();
80 int save_defaults();
81 int set_filename(char *filename);
82 // Total vertical pixels in timeline
83 int get_tracks_height();
84 // Total horizontal pixels in timeline
85 int get_tracks_width();
86 // Show windows
87 void show_vwindow();
88 void show_awindow();
89 void show_lwindow();
90 void show_cwindow();
91 void tile_windows();
92 void set_titles(int value);
93 int asset_to_edl(EDL *new_edl, Asset *new_asset, RecordLabels *labels = 0);
95 // Entry point to insert assets and insert edls. Called by TrackCanvas
96 // and AssetPopup when assets are dragged in from AWindow.
97 // Takes the drag vectors from MainSession and
98 // pastes either assets or clips depending on which is full.
99 // Returns 1 if the vectors were full
100 int paste_assets(double position, Track *dest_track);
102 // Insert the assets at a point in the EDL. Called by menueffects,
103 // render, and CWindow drop but recording calls paste_edls directly for
104 // labels.
105 void load_assets(ArrayList<Asset*> *new_assets,
106 double position,
107 int load_mode,
108 Track *first_track /* = 0 */,
109 RecordLabels *labels /* = 0 */,
110 int edit_labels,
111 int edit_plugins);
112 int paste_edls(ArrayList<EDL*> *new_edls,
113 int load_mode,
114 Track *first_track /* = 0 */,
115 double current_position /* = -1 */,
116 int edit_labels,
117 int edit_plugins);
118 // Reset everything for a load
119 void update_project(int load_mode);
120 void fit_selection();
121 // move the window to include the cursor
122 void find_cursor();
123 // Append a plugindb with pointers to the master plugindb
124 void create_plugindb(int do_audio,
125 int do_video,
126 int is_realtime,
127 int is_transition,
128 int is_theme,
129 ArrayList<PluginServer*> &plugindb);
130 // Find the plugin whose title matches title and return it
131 PluginServer* scan_plugindb(char *title,
132 int data_type);
133 void dump_plugins();
138 int load_filenames(ArrayList<char*> *filenames,
139 int load_mode = LOAD_REPLACE,
140 // Cause the project filename on the top of the window to be updated.
141 // Not wanted for loading backups.
142 int update_filename = 1);
144 int interrupt_indexes(); // Stop index building
147 int redraw_time_dependancies(); // after reconfiguring the time format, sample rate, frame rate
149 // =========================================== movement
151 void next_time_format();
152 int reposition_timebar(int new_pixel, int new_height);
153 int expand_sample();
154 int zoom_in_sample();
155 int zoom_sample(int64_t zoom_sample);
156 void zoom_amp(int64_t zoom_amp);
157 void zoom_track(int64_t zoom_track);
158 int fit_sample();
159 int move_left(int64_t distance = 0);
160 int move_right(int64_t distance = 0);
161 void move_up(int64_t distance = 0);
162 void move_down(int64_t distance = 0);
163 int next_label(); // seek to labels
164 int prev_label();
165 void trackmovement(int track_start);
166 int samplemovement(int64_t view_start); // view_start is pixels
167 void select_all();
168 int goto_start();
169 int goto_end();
170 int expand_y();
171 int zoom_in_y();
172 int expand_t();
173 int zoom_in_t();
174 void crop_video();
175 void update_plugins();
176 // Call after every edit operation
177 void save_backup();
178 void show_plugin(Plugin *plugin);
179 void hide_plugin(Plugin *plugin, int lock);
180 void hide_plugins();
181 // Update plugins with configuration changes.
182 // Called by TrackCanvas::cursor_motion_event.
183 void update_plugin_guis();
184 void update_plugin_states();
185 void update_plugin_titles();
186 // Called by Attachmentpoint during playback.
187 // Searches for matching plugin and renders data in it.
188 void render_plugin_gui(void *data, Plugin *plugin);
189 void render_plugin_gui(void *data, int size, Plugin *plugin);
192 // ============================= editing commands ========================
194 void add_audio_track_entry(int above, Track *dst);
195 int add_audio_track(int above, Track *dst);
196 void add_clip_to_edl(EDL *edl);
197 void add_video_track_entry(Track *dst = 0);
198 int add_video_track(int above, Track *dst);
200 void asset_to_size();
201 // Entry point for clear operations.
202 void clear_entry();
203 // Clears active region in EDL.
204 // If clear_handle, edit boundaries are cleared if the range is 0.
205 // Called by paste, record, menueffects, render, and CWindow drop.
206 void clear(int clear_handle);
207 void clear_labels();
208 int clear_labels(double start, double end);
209 void concatenate_tracks();
210 void copy();
211 int copy(double start, double end);
212 static int create_aspect_ratio(float &w, float &h, int width, int height);
213 void cut();
215 void delete_folder(char *folder);
216 void delete_inpoint();
217 void delete_outpoint();
219 void delete_track();
220 void delete_track(Track *track);
221 void delete_tracks();
222 void detach_transition(Transition *transition);
223 int feather_edits(int64_t feather_samples, int audio, int video);
224 int64_t get_feather(int audio, int video);
225 float get_aspect_ratio();
226 void insert(double position,
227 FileXML *file,
228 int edit_labels,
229 int edit_plugins,
230 EDL *parent_edl = 0);
232 // TrackCanvas calls this to insert multiple effects from the drag_pluginservers
233 // into pluginset_highlighted.
234 void insert_effects_canvas(double start,
235 double length);
237 // CWindow calls this to insert multiple effects from
238 // the drag_pluginservers array.
239 void insert_effects_cwindow(Track *dest_track);
241 // This is called multiple times by the above functions.
242 // It can't sync parameters.
243 void insert_effect(char *title,
244 SharedLocation *shared_location,
245 Track *track,
246 PluginSet *plugin_set,
247 double start,
248 double length,
249 int plugin_type);
251 void match_output_size(Track *track);
252 // Move edit to new position
253 void move_edits(ArrayList<Edit*> *edits,
254 Track *track,
255 double position);
256 // Move effect to position
257 void move_effect(Plugin *plugin,
258 PluginSet *plugin_set,
259 Track *track,
260 int64_t position);
261 void move_plugins_up(PluginSet *plugin_set);
262 void move_plugins_down(PluginSet *plugin_set);
263 void move_track_down(Track *track);
264 void move_tracks_down();
265 void move_track_up(Track *track);
266 void move_tracks_up();
267 void mute_selection();
268 void new_folder(char *new_folder);
269 void overwrite(EDL *source);
270 // For clipboard commands
271 void paste();
272 // For splice and overwrite
273 int paste(double start,
274 double end,
275 FileXML *file,
276 int edit_labels,
277 int edit_plugins);
278 int paste_output(int64_t startproject,
279 int64_t endproject,
280 int64_t startsource_sample,
281 int64_t endsource_sample,
282 int64_t startsource_frame,
283 int64_t endsource_frame,
284 Asset *asset,
285 RecordLabels *new_labels);
286 void paste_silence();
288 void paste_transition();
289 void paste_transition_cwindow(Track *dest_track);
290 void paste_audio_transition();
291 void paste_video_transition();
292 void rebuild_indices();
293 void redo_entry(int is_mwindow);
294 // Asset removal
295 void remove_assets_from_project(int push_undo = 0);
296 void remove_assets_from_disk();
297 void resize_track(Track *track, int w, int h);
298 void set_auto_keyframes(int value);
299 // Update the editing mode
300 int set_editing_mode(int new_editing_mode);
301 void set_inpoint(int is_mwindow);
302 void set_outpoint(int is_mwindow);
303 void splice(EDL *source);
304 void toggle_loop_playback();
305 void trim_selection();
306 // Synchronize EDL settings with all playback engines depending on current
307 // operation. Doesn't redraw anything.
308 void sync_parameters(int change_type = CHANGE_PARAMS);
309 void to_clip();
310 int toggle_label(int is_mwindow);
311 void undo_entry(int is_mwindow);
313 int cut_automation();
314 int copy_automation();
315 int paste_automation();
316 void clear_automation();
317 int cut_default_keyframe();
318 int copy_default_keyframe();
319 // Use paste_automation to paste the default keyframe in other position.
320 // Use paste_default_keyframe to replace the default keyframe with whatever is
321 // in the clipboard.
322 int paste_default_keyframe();
323 int clear_default_keyframe();
325 int modify_edithandles();
326 int modify_pluginhandles();
327 void finish_modify_handles();
335 // Send new EDL to caches
336 void update_caches();
337 int optimize_assets(); // delete unused assets from the cache and assets
339 // ================================= cursor selection ======================
341 void select_point(double position);
342 int set_loop_boundaries(); // toggle loop playback and set boundaries for loop playback
344 // ================================ handle selection =======================
348 SplashGUI *splash_window;
349 LevelWindow *level_window;
350 Tracks *tracks;
351 PatchBay *patches;
352 MainUndo *undo;
353 TimeBar *timebar;
354 Defaults *defaults;
355 Assets *assets;
356 // CICaches for drawing timeline only
357 CICache *audio_cache, *video_cache;
358 ThreadLoader *threadloader;
359 VideoWindow *video_window;
360 Preferences *preferences;
361 PreferencesThread *preferences_thread;
362 MainSession *session;
363 Theme *theme;
364 MainIndexes *mainindexes;
365 MainProgress *mainprogress;
366 BRender *brender;
368 // Menu items
369 ArrayList<ColormodelItem*> colormodels;
371 int reset_meters();
373 // Channel DB for playback only. Record channel DB's are in record.C
374 ChannelDB *channeldb_buz;
375 ChannelDB *channeldb_v4l2jpeg;
377 // ====================================== plugins ==============================
379 // Contain file descriptors for all the dlopens
380 ArrayList<PluginServer*> *plugindb;
381 // Currently visible plugins
382 ArrayList<PluginServer*> *plugin_guis;
385 // Adjust sample position to line up with frames.
386 int fix_timing(int64_t &samples_out,
387 int64_t &frames_out,
388 int64_t samples_in);
391 BatchRenderThread *batch_render;
392 Render *render;
393 // Render *renderlist;
394 // Master edl
395 EDL *edl;
396 // Main Window GUI
397 MWindowGUI *gui;
398 // Compositor
399 CWindow *cwindow;
400 // Viewer
401 VWindow *vwindow;
402 // Asset manager
403 AWindow *awindow;
404 // Levels
405 LevelWindow *lwindow;
406 // Lock during creation and destruction of GUI
407 Mutex *plugin_gui_lock;
408 // Lock during creation and destruction of brender so playback doesn't use it.
409 Mutex *brender_lock;
411 // Initialize channel DB's for playback
412 void init_channeldb();
413 void init_render();
414 // These three happen synchronously with each other
415 // Make sure this is called after synchronizing EDL's.
416 void init_brender();
417 // Restart brender after testing its existence
418 void restart_brender();
419 // Stops brender after testing its existence
420 void stop_brender();
421 // This one happens asynchronously of the others. Used by playback to
422 // see what frame is background rendered.
423 int brender_available(int position);
424 void set_brender_start();
426 static void init_defaults(Defaults* &defaults,
427 char *config_path);
428 void init_edl();
429 void init_awindow();
430 // Used by MWindow and RenderFarmClient
431 static void init_plugins(Preferences *preferences,
432 ArrayList<PluginServer*>* &plugindb,
433 SplashGUI *splash_window);
434 static void init_plugin_path(Preferences *preferences,
435 ArrayList<PluginServer*>* &plugindb,
436 FileSystem *fs,
437 SplashGUI *splash_window,
438 int *counter);
439 void init_preferences();
440 void init_signals();
441 void init_theme();
442 void init_compositor();
443 void init_levelwindow();
444 void init_viewer();
445 void init_cache();
446 void init_menus();
447 void init_indexes();
448 void init_gui();
449 void init_playbackcursor();
450 void delete_plugins();
451 void clean_indexes();
452 // TimeBomb timebomb;
453 SigHandler *sighandler;
456 #endif