Merge branch 'ct' of git.pipapo.org:cinelerra-ct into ct
[cinelerra_cv/ct.git] / cinelerra / track.h
blob0f055099f87f7c1b285689e57d4388a97c7420a6
1 #ifndef TRACK_H
2 #define TRACK_H
4 #include "arraylist.h"
5 #include "asset.inc"
6 #include "assets.inc"
7 #include "autoconf.inc"
8 #include "automation.inc"
9 #include "datatype.h"
10 #include "bchash.inc"
11 #include "edit.inc"
12 #include "edits.inc"
13 #include "edl.inc"
14 #include "filexml.inc"
15 #include "floatautos.inc"
16 #include "guicast.h"
17 #include "keyframe.inc"
18 #include "linklist.h"
19 #include "module.inc"
20 #include "patch.inc"
21 #include "plugin.inc"
22 #include "pluginset.inc"
23 #include "renderengine.inc"
24 #include "sharedlocation.inc"
25 #include "theme.inc"
26 #include "intautos.inc"
27 #include "trackcanvas.inc"
28 #include "tracks.inc"
29 #include "transition.inc"
31 #include <stdint.h>
33 // UNITS ARE SAMPLES FOR ALL
35 class Track : public ListItem<Track>
37 public:
38 Track(EDL *edl, Tracks *tracks);
39 Track();
40 virtual ~Track();
42 int create_objects();
43 int get_id();
44 virtual int load_defaults(BC_Hash *defaults);
45 int load(FileXML *file, int track_offset, uint32_t load_flags);
46 virtual int save_header(FileXML *file) { return 0; };
47 virtual int save_derived(FileXML *file) { return 0; };
48 virtual int load_header(FileXML *file, uint32_t load_flags) { return 0; };
49 virtual int load_derived(FileXML *file, uint32_t load_flags) { return 0; };
50 void equivalent_output(Track *track, double *result);
52 virtual void copy_from(Track *track);
53 Track& operator=(Track& track);
54 virtual PluginSet* new_plugins() { return 0; };
55 // Synchronize playback numbers
56 virtual void synchronize_params(Track *track);
58 // Get number of pixels to display
59 virtual int vertical_span(Theme *theme);
60 int64_t horizontal_span();
61 void resample(double old_rate, double new_rate);
63 // Get length of track in seconds
64 double get_length();
65 // Get dimensions of source for convenience functions
66 void get_source_dimensions(double position, int &w, int &h);
68 // Editing
69 void insert_asset(Asset_GC asset,
70 double length,
71 double position,
72 int track_number);
73 Plugin* insert_effect(char *title,
74 SharedLocation *shared_location,
75 KeyFrame *keyframe,
76 PluginSet *plugin_set,
77 double start,
78 double length,
79 int plugin_type);
80 void insert_plugin_set(Track *track, double position);
81 void detach_effect(Plugin *plugin);
82 // Insert a track from another EDL
83 void insert_track(Track *track,
84 double position,
85 int replace_default,
86 int edit_plugins);
87 // Optimize editing
88 void optimize();
89 int is_muted(int64_t position, int direction); // Test muting status
91 void move_plugins_up(PluginSet *plugin_set);
92 void move_plugins_down(PluginSet *plugin_set);
93 void remove_pluginset(PluginSet *plugin_set);
94 void remove_asset(Asset_GC asset);
96 // Used for determining a selection for editing so leave as int.
97 // converts the selection to SAMPLES OR FRAMES and stores in value
98 virtual int64_t to_units(double position, int round);
99 // For drawing
100 virtual double to_doubleunits(double position);
101 virtual double from_units(int64_t position);
105 // Positions are identical for handle modifications
106 virtual int identical(int64_t sample1, int64_t sample2) { return 0; };
108 // Get the plugin belonging to the set.
109 Plugin* get_current_plugin(double position,
110 int plugin_set,
111 int direction,
112 int convert_units,
113 int use_nudge);
114 Plugin* get_current_transition(double position,
115 int direction,
116 int convert_units,
117 int use_nudge);
119 // detach shared effects referencing module
120 void detach_shared_effects(int module);
123 // Called by playable tracks to test for playable server.
124 // Descends the plugin tree without creating a virtual console.
125 // Used by PlayableTracks::is_playable.
126 int is_synthesis(RenderEngine *renderengine,
127 int64_t position,
128 int direction);
130 // Used by PlayableTracks::is_playable
131 // Returns 1 if the track is in the output boundaries.
132 virtual int is_playable(int64_t position,
133 int direction);
135 // Test direct copy conditions common to all the rendering routines
136 virtual int direct_copy_possible(int64_t start, int direction, int use_nudge);
138 // Used by PlayableTracks::is_playable
139 int plugin_used(int64_t position, int64_t direction);
145 virtual int copy_settings(Track *track);
146 void shift_keyframes(double position, double length, int convert_units);
147 void shift_effects(double position, double length, int convert_units);
148 void change_plugins(SharedLocation &old_location,
149 SharedLocation &new_location,
150 int do_swap);
151 void change_modules(int old_location,
152 int new_location,
153 int do_swap);
155 EDL *edl;
156 Tracks *tracks;
158 Edits *edits;
159 // Plugin set uses key frames for automation
160 ArrayList<PluginSet*> plugin_set;
161 Automation *automation;
163 // Vertical offset from top of timeline
164 int y_pixel;
165 int expand_view;
166 int draw;
167 // There is some debate on whether to expand gang from faders to
168 // dragging operations. This would allow every edit in a column to get dragged
169 // simultaneously.
170 int gang;
171 char title[BCTEXTLEN];
172 int play;
173 int record;
174 // Nudge in track units. Positive shifts track earlier in time. This way
175 // the position variables only need to add the nudge.
176 int64_t nudge;
177 // TRACK_AUDIO or TRACK_VIDEO
178 int data_type;
198 int load_automation(FileXML *file);
199 int load_edits(FileXML *file);
201 virtual int change_channels(int oldchannels, int newchannels) { return 0; };
202 virtual int dump();
206 // ===================================== editing
207 int copy(double start,
208 double end,
209 FileXML *file,
210 char *output_path = "");
211 int copy_assets(double start,
212 double end,
213 Assets_vector &asset_list);
214 virtual int copy_derived(int64_t start, int64_t end, FileXML *file) { return 0; };
215 virtual int paste_derived(int64_t start, int64_t end, int64_t total_length, FileXML *file, int &current_channel) { return 0; };
216 int clear(double start,
217 double end,
218 int edit_edits,
219 int edit_labels,
220 int clear_plugins,
221 int convert_units,
222 Edits *trim_edits);
223 // Returns the point to restart background rendering at.
224 // -1 means nothing changed.
225 void clear_automation(double selectionstart,
226 double selectionend,
227 int shift_autos /* = 1 */,
228 int default_only /* = 0 */);
229 void straighten_automation(double selectionstart,
230 double selectionend);
231 virtual int clear_automation_derived(AutoConf *auto_conf,
232 double selectionstart,
233 double selectionend,
234 int shift_autos = 1) { return 0; };
235 virtual int clear_derived(double start,
236 double end) { return 0; };
238 int copy_automation(double selectionstart,
239 double selectionend,
240 FileXML *file,
241 int default_only,
242 int autos_only);
243 virtual int copy_automation_derived(AutoConf *auto_conf,
244 double selectionstart,
245 double selectionend,
246 FileXML *file) { return 0; };
247 int paste_automation(double selectionstart,
248 double total_length,
249 double frame_rate,
250 int64_t sample_rate,
251 FileXML *file,
252 int default_only);
253 virtual int paste_automation_derived(double selectionstart,
254 double selectionend,
255 double total_length,
256 FileXML *file,
257 int shift_autos,
258 int &current_pan) { return 0; };
259 int paste_auto_silence(double start, double end);
260 virtual int paste_auto_silence_derived(int64_t start, int64_t end) { return 0; };
261 int scale_time(float rate_scale, int scale_edits, int scale_autos, int64_t start, int64_t end);
262 virtual int scale_time_derived(float rate_scale, int scale_edits, int scale_autos, int64_t start, int64_t end) { return 0; };
263 int purge_asset(Asset_GC asset);
264 int asset_used(Asset_GC asset);
265 int clear_handle(double start,
266 double end,
267 int clear_labels,
268 int clear_plugins,
269 double &distance);
270 int paste_silence(double start, double end, int edit_plugins);
271 virtual int select_translation(int cursor_x, int cursor_y) { return 0; }; // select video coordinates for frame
272 virtual int update_translation(int cursor_x, int cursor_y, int shift_down) { return 0; }; // move video coordinates
273 int select_auto(AutoConf *auto_conf, int cursor_x, int cursor_y);
274 virtual int select_auto_derived(float zoom_units, float view_start, AutoConf *auto_conf, int cursor_x, int cursor_y) { return 0; };
275 int move_auto(AutoConf *auto_conf, int cursor_x, int cursor_y, int shift_down);
276 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; };
277 int release_auto();
278 virtual int release_auto_derived() { return 0; };
279 // Return whether automation would prevent direct frame copies. Not fully implemented.
280 int automation_is_used(int64_t start, int64_t end);
281 virtual int automation_is_used_derived(int64_t start, int64_t end) { return 0; }
283 int popup_transition(int cursor_x, int cursor_y);
285 // Return 1 if the left handle was selected 2 if the right handle was selected 3 if the track isn't recordable
286 int modify_edithandles(double oldposition,
287 double newposition,
288 int currentend,
289 int handle_mode,
290 int edit_labels,
291 int edit_plugins);
292 int modify_pluginhandles(double oldposition,
293 double newposition,
294 int currentend,
295 int handle_mode,
296 int edit_labels,
297 Edits *trim_edits);
298 int select_edit(int cursor_x,
299 int cursor_y,
300 double &new_start,
301 double &new_end);
302 virtual int end_translation() { return 0; };
303 virtual int reset_translation(int64_t start, int64_t end) { return 0; };
304 int feather_edits(int64_t start, int64_t end, int64_t units);
305 int64_t get_feather(int64_t selectionstart, int64_t selectionend);
308 // Absolute number of this track
309 int number_of();
311 // get_dimensions is used for getting drawing regions so use floats for partial frames
312 // get the display dimensions in SAMPLES OR FRAMES
313 virtual int get_dimensions(double &view_start,
314 double &view_units,
315 double &zoom_units) { return 0; };
316 // Longest time from current_position in which nothing changes
317 int64_t edit_change_duration(int64_t input_position,
318 int64_t input_length,
319 int reverse,
320 int test_transitions,
321 int use_nudge);
322 int64_t plugin_change_duration(int64_t input_position,
323 int64_t input_length,
324 int reverse,
325 int use_nudge);
326 // Utility for edit_change_duration.
327 int need_edit(Edit *current, int test_transitions);
328 // If the edit under position is playable.
329 // Used by PlayableTracks::is_playable.
330 int playable_edit(int64_t position, int direction);
332 // ===================================== for handles, titles, etc
334 int64_t old_view_start;
335 int pixel; // pixel position from top of track view
336 // Dimensions of this track if video
337 int track_w, track_h;
342 private:
343 // Identification of the track
344 int id;
347 #endif
349 // Local Variables:
350 // mode: C++
351 // c-file-style: "linux"
352 // End: