18 new shapewipe transitions from rafa, rework savefile/confirm for nested edl edits
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / track.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2010 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 TRACK_H
23 #define TRACK_H
24
25 #include <stdio.h>
26 #include <stdint.h>
27
28 #include "arraylist.h"
29 #include "asset.inc"
30 #include "autoconf.inc"
31 #include "automation.inc"
32 #include "datatype.h"
33 #include "bchash.inc"
34 #include "edit.inc"
35 #include "edits.inc"
36 #include "edl.inc"
37 #include "filexml.inc"
38 #include "floatautos.inc"
39 #include "guicast.h"
40 #include "indexable.inc"
41 #include "keyframe.inc"
42 #include "linklist.h"
43 #include "module.inc"
44 #include "patch.inc"
45 #include "plugin.inc"
46 #include "pluginset.inc"
47 #include "sharedlocation.inc"
48 #include "theme.inc"
49 #include "intautos.inc"
50 #include "trackcanvas.inc"
51 #include "tracks.inc"
52 #include "transition.inc"
53
54 // UNITS ARE SAMPLES FOR ALL
55
56 class Track : public ListItem<Track>
57 {
58 public:
59         Track(EDL *edl, Tracks *tracks);
60         Track();
61         virtual ~Track();
62
63         void create_objects();
64         int get_id();
65         virtual int load_defaults(BC_Hash *defaults);
66         int load(FileXML *file, int track_offset, uint32_t load_flags);
67         virtual int save_header(FileXML *file) { return 0; };
68         virtual int save_derived(FileXML *file) { return 0; };
69         virtual int load_header(FileXML *file, uint32_t load_flags) { return 0; };
70         virtual int load_derived(FileXML *file, uint32_t load_flags) { return 0; };
71         void equivalent_output(Track *track, double *result);
72         int get_mixer_id();
73
74         void get_fauto_xyz(int fauto, float &x, float &y, float &z);
75         void set_fauto_xyz(int fauto, float x, float y, float z);
76         void get_projector(float &x, float &y, float &z);
77         void set_projector(float x, float y, float z);
78         void get_camera(float &x, float &y, float &z);
79         void set_camera(float x, float y, float z);
80
81         virtual void copy_from(Track *track);
82         Track& operator=(Track& track);
83         virtual PluginSet* new_plugins() { return 0; };
84 // Synchronize playback numbers
85         virtual void synchronize_params(Track *track);
86
87 // Get number of pixels to display
88         virtual int vertical_span(Theme *theme);
89         int64_t horizontal_span();
90         void resample(double old_rate, double new_rate);
91
92 // Speed curve in use
93         int has_speed();
94 // Get length of track in seconds
95         double get_length();
96 // Get dimensions of source for convenience functions
97         void get_source_dimensions(double position, int &w, int &h);
98
99 // Editing
100         void insert_asset(Asset *asset, EDL *nested_edl,
101                 double length, double position, int track_number);
102         Plugin* insert_effect(const char *title, SharedLocation *shared_location,
103                 KeyFrame *keyframe, PluginSet *plugin_set,
104                 double start, double length, int plugin_type);
105         void insert_plugin_set(Track *track, int64_t position,
106                 int64_t min_length, int edit_autos);
107         void detach_effect(Plugin *plugin);
108 // Insert a track from another EDL
109         void insert_track(Track *track, double position,
110                 int replace_default, int edit_plugins, int edit_autos,
111 // Pad pasted sections to a minimum of this length.
112                 double edl_length);
113         void shuffle_edits(double start, double end, int first_track);
114         void reverse_edits(double start, double end, int first_track);
115         void align_edits(double start, double end, Track *master_track);
116 // Optimize editing
117         void optimize();
118         int is_muted(int64_t position, int direction);  // Test muting status
119
120         void move_plugins_up(PluginSet *plugin_set);
121         void move_plugins_down(PluginSet *plugin_set);
122         void remove_pluginset(PluginSet *plugin_set);
123         void remove_asset(Indexable *asset);
124
125 // Used for determining a selection for editing so leave as int.
126 // converts the selection to SAMPLES OR FRAMES and stores in value
127         virtual int64_t to_units(double position, int round);
128 // For drawing
129         virtual double to_doubleunits(double position);
130         virtual double from_units(int64_t position);
131
132
133 // Positions are identical for handle modifications
134     virtual int identical(int64_t sample1, int64_t sample2) { return 0; };
135
136 // Get the plugin belonging to the set.
137         Plugin* get_current_plugin(double position,
138                 int plugin_set, int direction, int convert_units, int use_nudge);
139         Plugin* get_current_transition(double position,
140                 int direction, int convert_units, int use_nudge);
141
142 // detach shared effects referencing module
143         void detach_shared_effects(int module);
144
145
146 // Called by playable tracks to test for playable server.
147 // Descends the plugin tree without creating a virtual console.
148 // Used by PlayableTracks::is_playable.
149         int is_synthesis(int64_t position, int direction, int depth=0);
150
151 // Used by PlayableTracks::is_playable
152 // Returns 1 if the track is in the output boundaries.
153         virtual int is_playable(int64_t position, int direction);
154
155 // Test direct copy conditions common to all the rendering routines
156         virtual int direct_copy_possible(int64_t start, int direction, int use_nudge);
157
158 // Used by PlayableTracks::is_playable
159         int plugin_used(int64_t position, int64_t direction);
160 // align to frame boundary
161         int64_t frame_align(int64_t position, int round);
162
163         virtual int copy_settings(Track *track);
164         void shift_keyframes(int64_t position, int64_t length);
165         void shift_effects(int64_t position, int64_t length, int edit_autos, Edits *trim_edits);
166         void change_plugins(SharedLocation &old_location, SharedLocation &new_location, int do_swap);
167         void change_modules(int old_location, int new_location, int do_swap);
168         Plugin *plugin_exists(int plugin_id);
169
170         EDL *edl;
171         Tracks *tracks;
172
173         Edits *edits;
174 // Plugin set uses key frames for automation
175         ArrayList<PluginSet*> plugin_set;
176         Automation *automation;
177
178 // Vertical offset from top of timeline
179         int y_pixel;
180         int expand_view;
181         int draw;
182 // There is some debate on whether to expand gang from faders to
183 // dragging operations.  This would allow every edit in a column to get dragged
184 // simultaneously.
185         int gang;
186         char title[BCTEXTLEN];
187         int play;
188         int record;
189 // mask enable bit flags
190         int masks;
191 // Nudge in track units.  Positive shifts track earlier in time.  This way
192 // the position variables only need to add the nudge.
193         int64_t nudge;
194 // TRACK_AUDIO or TRACK_VIDEO
195         int data_type;
196
197
198         int load_automation(FileXML *file);
199         int load_edits(FileXML *file);
200
201         virtual int change_channels(int oldchannels, int newchannels) { return 0; };
202         virtual int dump(FILE *fp);
203
204 // ===================================== editing
205         int copy(int copy_flags, double start, double end,
206                 FileXML *file, const char *output_path = "");
207         int copy_assets(double start, double end, ArrayList<Asset*> *asset_list);
208         virtual int copy_derived(int64_t start, int64_t end, FileXML *file) { return 0; };
209         virtual int paste_derived(int64_t start, int64_t end,
210                 int64_t total_length, FileXML *file, int &current_channel) { return 0; };
211         int blade(double position);
212         int clear(double start, double end,
213                 int edit_edits, int edit_labels, int clear_plugins,
214                 int edit_autos, Edits *trim_edits);
215         int clear(int64_t start, int64_t end,
216                 int edit_edits, int edit_labels, int clear_plugins,
217                 int edit_autos, Edits *trim_edits);
218 // Returns the point to restart background rendering at.
219 // -1 means nothing changed.
220         void clear_automation(double selectionstart, double selectionend,
221                 int shift_autos   /* = 1 */,
222                 int default_only  /* = 0 */);
223         void set_automation_mode(double selectionstart, double selectionend,
224                 int mode);
225         virtual int clear_automation_derived(AutoConf *auto_conf,
226                 double selectionstart, double selectionend,
227                 int shift_autos = 1) { return 0; };
228         virtual int clear_derived(double start,
229                 double end) { return 0; };
230
231         int copy_automation(double selectionstart, double selectionend,
232                 FileXML *file, int default_only, int active_only);
233         virtual int copy_automation_derived(AutoConf *auto_conf,
234                 double selectionstart, double selectionend,
235                 FileXML *file) { return 0; };
236         int paste_automation(double selectionstart, double total_length,
237                 double frame_rate, int64_t sample_rate, FileXML *file,
238                 int default_only, int active_only);
239         virtual int paste_automation_derived(double selectionstart, double selectionend,
240                 double total_length, FileXML *file, int shift_autos, int &current_pan) { return 0; };
241         int paste_auto_silence(double start, double end);
242         virtual int paste_auto_silence_derived(int64_t start, int64_t end) { return 0; };
243         int scale_time(float rate_scale, int scale_edits, int scale_autos, int64_t start, int64_t end);
244         virtual int scale_time_derived(float rate_scale, int scale_edits, int scale_autos, int64_t start, int64_t end) { return 0; };
245         int purge_asset(Asset *asset);
246         int asset_used(Asset *asset);
247         int clear_handle(double start, double end,
248                 int clear_labels, int clear_plugins, int edit_autos,
249                 double &distance);
250         int paste_silence(double start, double end, int edit_plugins, int edit_autos);
251         int paste_silence(int64_t start, int64_t end, int edit_plugins, int edit_autos);
252         virtual int select_translation(int cursor_x, int cursor_y) { return 0; };  // select video coordinates for frame
253         virtual int update_translation(int cursor_x, int cursor_y, int shift_down) { return 0; };  // move video coordinates
254         int select_auto(AutoConf *auto_conf, int cursor_x, int cursor_y);
255         virtual int select_auto_derived(float zoom_units, float view_start, AutoConf *auto_conf, int cursor_x, int cursor_y) { return 0; };
256         int move_auto(AutoConf *auto_conf, int cursor_x, int cursor_y, int shift_down);
257         virtual int move_auto_derived(float zoom_units, float view_start, AutoConf *auto_conf, int cursor_x, int cursor_y, int shift_down) { return 0; };
258         int release_auto();
259         virtual int release_auto_derived() { return 0; };
260 // Return whether automation would prevent direct frame copies.  Not fully implemented.
261         int automation_is_used(int64_t start, int64_t end);
262         virtual int automation_is_used_derived(int64_t start, int64_t end) { return 0; }
263
264         int popup_transition(int cursor_x, int cursor_y);
265
266 // Return 1 if the left handle was selected 2 if the right handle was selected 3 if the track isn't recordable
267         int modify_edithandles(double oldposition, double newposition,
268                 int currentend, int handle_mode, int edit_labels,
269                 int edit_plugins, int edit_autos, int group_id);
270         int modify_pluginhandles(double oldposition,
271                 double newposition,
272                 int currentend,
273                 int handle_mode,
274                 int edit_labels,
275                 int edit_autos,
276                 Edits *trim_edits);
277         int select_edit(int cursor_x,
278                 int cursor_y,
279                 double &new_start,
280                 double &new_end);
281         virtual int end_translation() { return 0; };
282         virtual int reset_translation(int64_t start, int64_t end) { return 0; };
283         int feather_edits(int64_t start, int64_t end, int64_t units);
284         int64_t get_feather(int64_t selectionstart, int64_t selectionend);
285
286         int show_assets();
287         int show_titles();
288         int show_transitions();
289
290 // Absolute number of this track
291         int number_of();
292
293 // get_dimensions is used for getting drawing regions so use floats for partial frames
294 // get the display dimensions in SAMPLES OR FRAMES
295 //      virtual int get_dimensions(double &view_start,
296 //              double &view_units,
297 //              double &zoom_units) { return 0; };
298 // Longest time from current_position in which nothing changes
299         int64_t edit_change_duration(int64_t input_position,
300                 int64_t input_length,
301                 int reverse,
302                 int test_transitions,
303                 int use_nudge);
304         int64_t plugin_change_duration(int64_t input_position,
305                 int64_t input_length,
306                 int reverse,
307                 int use_nudge);
308 // Utility for edit_change_duration.
309         int need_edit(Edit *current, int test_transitions);
310 // If the edit under position is playable.
311 // Used by PlayableTracks::is_playable.
312         int playable_edit(int64_t position, int direction);
313
314 // ===================================== for handles, titles, etc
315
316         int64_t old_view_start;
317         int pixel;   // pixel position from top of track view
318 // Dimensions of this track if video
319         int track_w, track_h;
320         int mixer_id;
321
322 private:
323 // Identification of the track
324         int id;
325 };
326
327 #endif