prevent popup deactivation while button_down
[goodguy/history.git] / cinelerra-5.0 / cinelerra / edl.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  * 
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * 
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  * 
20  */
21
22 #ifndef EDL_H
23 #define EDL_H
24
25 #include <stdio.h>
26 #include <stdint.h>
27
28 #include "asset.inc"
29 #include "assets.inc"
30 #include "autoconf.inc"
31 #include "bchash.inc"
32 #include "edit.inc"
33 #include "edits.inc"
34 #include "edl.inc"
35 #include "edlsession.inc"
36 #include "filexml.inc"
37 #include "indexable.h"
38 #include "indexstate.inc"
39 #include "labels.inc"
40 #include "localsession.inc"
41 #include "maxchannels.h"
42 #include "mutex.inc"
43 #include "nestededls.inc"
44 #include "playabletracks.inc"
45 #include "playbackconfig.h"
46 #include "pluginserver.h"
47 #include "preferences.inc"
48 #include "recordlabel.inc"
49 #include "sharedlocation.inc"
50 #include "theme.inc"
51 #include "tracks.inc"
52 #include "vedit.inc"
53
54 // Loading and saving are built on load and copy except for automation:
55
56 // Storage: 
57 // Load: load new -> paste into master
58 // Save: copy all of master
59 // Undo: selective load into master
60 // Copy: copy from master
61 // Paste: load new -> paste into master
62 // Copy automation: copy just automation from master
63 // Paste automation: paste functions in automation
64
65
66
67
68
69
70
71
72
73
74
75 class EDL : public Indexable
76 {
77 public:
78         EDL(EDL *parent_edl = 0);
79         ~EDL();
80
81         void create_objects();
82         EDL& operator=(EDL &edl);
83
84 // Load configuration and track counts
85         int load_defaults(BC_Hash *defaults);
86         int save_defaults(BC_Hash *defaults);
87 // Clip default settings to boundaries.
88         void boundaries();
89 // Create tracks using existing configuration
90         int create_default_tracks();
91         int load_xml(FileXML *file, 
92                 uint32_t load_flags);
93         int save_xml(FileXML *xml, 
94                 const char *output_path,
95                 int is_clip,
96                 int is_vwindow);
97     int load_audio_config(FileXML *file, int append_mode, uint32_t load_flags);
98     int load_video_config(FileXML *file, int append_mode, uint32_t load_flags);
99
100 // Return 1 if rendering requires a virtual console.
101         int get_use_vconsole(VEdit* *playable_edit,
102                 int64_t position, 
103                 int direction,
104                 PlayableTracks *playable_tracks);
105
106 // Convert position to frames if cursor alignment is enabled
107         double align_to_frame(double position, int round);
108
109
110
111 // Scale all sample values since everything is locked to audio
112         void rechannel();
113         void resample(double old_rate, double new_rate, int data_type);
114         void copy_tracks(EDL *edl);
115 // Copies project path, folders, EDLSession, and LocalSession from edl argument.
116 // session_only - used by preferences and format specify 
117 // whether to only copy EDLSession
118         void copy_session(EDL *edl, int session_only = 0);
119         int copy_all(EDL *edl);
120         void copy_assets(EDL *edl);
121         void copy_clips(EDL *edl);
122 // Copy pan and fade settings from edl
123         void synchronize_params(EDL *edl);
124 // Determine if the positions are equivalent if they're within half a frame
125 // of each other.
126         int equivalent(double position1, double position2);
127 // Determine if the EDL's produce equivalent video output to the old EDL.
128 // The new EDL is this and the old EDL is the argument.
129 // Return the number of seconds from the beginning of this which are 
130 // equivalent to the argument.
131 // If they're completely equivalent, -1 is returned;
132 // This is used by BRender.
133         double equivalent_output(EDL *edl);
134 // Set project path for filename prefixes in the assets
135         void set_path(char *path);
136 // Set points and labels
137         void set_inpoint(double position);
138         void set_outpoint(double position);
139 // Redraw resources during index builds
140         void set_index_file(Indexable *indexable);
141 // Add assets from the src to the destination
142         void update_assets(EDL *src);
143         void optimize();
144 // Debug
145         int dump(FILE *fp=stdout);
146         static int next_id();
147 // Create a new folder if it doesn't exist already
148         void new_folder(const char *folder);
149         void delete_folder(char *folder);
150         void modify_edithandles(double oldposition, 
151                 double newposition, 
152                 int currentend, 
153                 int handle_mode,
154                 int edit_labels,
155                 int edit_plugins,
156                 int edit_autos);
157
158         void modify_pluginhandles(double oldposition, 
159                 double newposition, 
160                 int currentend, 
161                 int handle_mode,
162                 int edit_labels,
163                 int edit_autos,
164                 Edits *trim_edits);
165
166         int trim_selection(double start, 
167                 double end,
168                 int edit_labels,
169                 int edit_plugins,
170                 int edit_autos);
171
172 // Editing functions
173         int copy_assets(double start, 
174                 double end, 
175                 FileXML *file, 
176                 int all, 
177                 const char *output_path);
178         int copy(double start, 
179                 double end, 
180                 int all,   // Ignore recordable status of tracks for saving
181                 int is_clip,
182                 int is_vwindow,
183                 FileXML *file, 
184                 const char *output_path,
185                 int rewind_it);     // Rewind EDL for easy pasting
186         void paste_silence(double start, 
187                 double end, 
188                 int edit_labels /* = 1 */, 
189                 int edit_plugins,
190                 int edit_autos);
191         void remove_from_project(ArrayList<Indexable*> *assets);
192         void remove_from_project(ArrayList<EDL*> *clips);
193         int clear(double start, 
194                 double end, 
195                 int clear_labels,
196                 int clear_plugins,
197                 int edit_autos);
198 // Insert the asset at a point in the EDL
199         void insert_asset(Asset *asset, 
200                 EDL *nested_edl,
201                 double position, 
202                 Track *first_track = 0, 
203                 RecordLabels *labels = 0);
204 // Insert the clip at a point in the EDL
205         int insert_clips(ArrayList<EDL*> *new_edls, int load_mode, Track *first_track = 0);
206 // Add a copy of EDL* to the clip array.  Returns the copy.
207         EDL* add_clip(EDL *edl);
208
209         void get_shared_plugins(Track *source, 
210                 ArrayList<SharedLocation*> *plugin_locations,
211                 int omit_recordable,
212                 int data_type);
213         void get_shared_tracks(Track *track, 
214                 ArrayList<SharedLocation*> *module_locations,
215                 int omit_recordable,
216                 int data_type);
217
218
219     int get_tracks_height(Theme *theme);
220     int64_t get_tracks_width();
221 // Return dimensions for canvas if smaller dimensions has zoom of 1
222         void calculate_conformed_dimensions(int single_channel, float &w, float &h);
223 // Get the total output size scaled to aspect ratio
224         void output_dimensions_scaled(int &w, int &h);
225         float get_aspect_ratio();
226
227
228 // For Indexable
229         int get_audio_channels();
230         int get_sample_rate();
231         int64_t get_audio_samples();
232         int have_audio();
233         int have_video();
234         int get_w();
235         int get_h();
236         double get_frame_rate();
237         int get_video_layers();
238         int64_t get_video_frames();
239
240         EDL* get_vwindow_edl(int number);
241         int total_vwindow_edls();
242         void remove_vwindow_edls();
243         void remove_vwindow_edl(EDL *edl);
244 // Adds to list of EDLs & increase garbage collection counter
245 // Does nothing if EDL already exists
246         void append_vwindow_edl(EDL *edl, int increase_counter);
247
248 // Titles of all subfolders
249         ArrayList<char*> folders;
250 // Clips
251         ArrayList<EDL*> clips;
252 // Nested EDLs
253         NestedEDLs *nested_edls;
254 // EDLs being shown in VWindows
255         ArrayList<EDL*> vwindow_edls;
256 // is the vwindow_edl shared and therefore should not be deleted in destructor
257 //      int vwindow_edl_shared;
258
259 // Media files
260 // Shared between all EDLs
261         Assets *assets;
262
263
264
265         Tracks *tracks;
266         Labels *labels;
267 // Shared between all EDLs in a tree, for projects.
268         EDLSession *session;
269 // Specific to this EDL, for clips.
270         LocalSession *local_session;
271
272
273
274
275
276
277 // Use parent Assets if nonzero
278         EDL *parent_edl;
279
280
281         static Mutex *id_lock;
282
283 };
284
285 #endif