add bump floatautos, add time_references for align timecodes, add menuitem create_key...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / tracks.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 TRACKS_H
23 #define TRACKS_H
24
25 #include <stdio.h>
26 #include <stdint.h>
27
28 #include "autoconf.h"
29 #include "edl.inc"
30 #include "file.inc"
31 #include "filexml.inc"
32 #include "linklist.h"
33 #include "pluginserver.inc"
34 #include "threadindexer.inc"
35 #include "track.h"
36 #include "trackcanvas.inc"
37 #include "transition.inc"
38
39
40
41 class Tracks : public List<Track>
42 {
43 public:
44         Tracks();
45         Tracks(EDL *edl);
46         virtual ~Tracks();
47
48         Tracks& operator=(Tracks &tracks);
49         int load(FileXML *xml,
50                 int &track_offset,
51                 uint32_t load_flags);
52         void move_edits(ArrayList<Edit*> *edits, Track *track, double position,
53                 int edit_labels, int edit_plugins, int edit_autos, int mode);
54         void move_group(EDL *group, Track *first_track, double position, int overwrite);
55         void move_effect(Plugin *plugin, Track *track, int64_t position);
56         void move_effect(Plugin *plugin, PluginSet *plugin_set, int64_t position);
57
58 // Construct a list of all the recordable edits which start on position
59         void clear_selected_edits();
60         int clear_hard_edges(double start, double end);
61         void get_selected_edits(ArrayList<Edit*> *drag_edits);
62         int next_group_id();
63         int new_group(int id);
64         int set_group_selected(int id, int v);
65         int del_group(int id);
66
67         void get_automation_extents(float *min,
68                 float *max,
69                 double start,
70                 double end,
71                 int autogrouptype);
72
73         void equivalent_output(Tracks *tracks, double *result);
74
75         void move_tracks(Track *src, Track *dst, int n);
76         int move_track_up(Track *track);
77         int move_track_down(Track *track);
78         int move_tracks_up();
79         int move_tracks_down();
80         int swap_track_up(Track *track);
81         int swap_track_down(Track *track);
82         int swap_tracks_up();
83         int swap_tracks_down();
84         void paste_audio_transition(PluginServer *server);
85         void paste_video_transition(PluginServer *server, int first_track = 0);
86
87 // Only tests effects
88         Plugin *plugin_exists(int plugin_id);
89         int track_exists(Track *track);
90
91         void paste_transition(PluginServer *server, Edit *dest_edit);
92 // Return the numbers of tracks with the play patch enabled
93         int playable_audio_tracks();
94         int playable_video_tracks();
95 // Return number of tracks with the record patch enabled
96         int recordable_audio_tracks();
97         int recordable_video_tracks();
98         int total_audio_tracks();
99         int total_video_tracks();
100 // return the longest track in all the tracks in seconds
101         double total_length();
102         double total_audio_length();
103         double total_video_length();
104         double total_length_framealigned(double fps);
105 // Update y pixels after a zoom
106         void update_y_pixels(Theme *theme);
107 // Total number of tracks where the following toggles are selected
108         void select_all(int type, int value);
109
110         void translate_fauto_xy(int fauto, float dx, float dy, int all);
111         void translate_projector(float dx, float dy, int all=0);
112         void translate_camera(float dx, float dy, int all=0);
113         void crop_resize(float x, float y, float z);
114         void crop_shrink(float x, float y, float z);
115         double align_timecodes();
116
117         int total_of(int type);
118         Track* get_track_by_id(int id);
119 // add a track
120         Track* add_audio_track(int above, Track *dst_track);
121         Track* add_video_track(int above, Track *dst_track);
122         Track* add_subttl_track(int above, Track *dst_track);
123 //      Track* add_audio_track(int to_end = 1);
124 //      Track* add_video_track(int to_end = 1);
125 // delete any track
126         int delete_track(Track *track, int gang=-1);
127 // detach shared effects referencing module
128         int detach_shared_effects(int module);
129 // detach all corresponding effects in gang
130         int detach_ganged_effects(Plugin *plugin);
131
132         EDL *edl;
133
134
135
136
137
138 // Types for drag toggle behavior
139         enum
140         {
141                 NONE,
142                 PLAY,
143                 RECORD,
144                 GANG,
145                 DRAW,
146                 MUTE,
147                 EXPAND
148         };
149
150
151
152
153
154
155
156
157
158         int change_channels(int oldchannels, int newchannels);
159         int dump(FILE *fp);
160
161
162
163 // Change references to shared modules in all tracks from old to new.
164 // If do_swap is true values of new are replaced with old.
165         void change_modules(int old_location, int new_location, int do_swap);
166 // Append all the tracks to the end of the recordable tracks
167         int concatenate_tracks(int edit_plugins, int edit_autos);
168 // Change references to shared plugins in all tracks
169         void change_plugins(SharedLocation &old_location, SharedLocation &new_location, int do_swap);
170
171         int delete_tracks();     // delete all the recordable tracks
172         int delete_all_tracks();      // delete just the tracks
173
174         void copy_from(Tracks *tracks);
175
176 // ================================== EDL editing
177         int copy(int copy_flags, double start, double end,
178                 FileXML *file, const char *output_path = "");
179
180         int copy_assets(int copy_flags, FileXML *xml, double start, double end);
181         int blade(double position);
182         int clear(double start, double end, int clear_plugins, int edit_autos);
183         void clear_automation(double selectionstart,
184                 double selectionend);
185         void set_automation_mode(double selectionstart,
186                 double selectionend,
187                 int mode);
188         int clear_default_keyframe();
189         int clear_handle(double start,
190                 double end,
191                 double &longest_distance,
192                 int clear_labels,
193                 int clear_plugins,
194                 int edit_autos);
195         int copy_automation(double selectionstart,
196                 double selectionend,
197                 FileXML *file,
198                 int default_only,
199                 int autos_only);
200 //      int copy_default_keyframe(FileXML *file);
201         void paste_automation(double selectionstart,
202                 FileXML *xml,
203                 int default_only,
204                 int active_only,
205                 int typeless);
206 //      int paste_default_keyframe(FileXML *file);
207         int paste(int64_t start, int64_t end);
208 // all units are samples by default
209         int paste_output(int64_t startproject,
210                                 int64_t endproject,
211                                 int64_t startsource_sample,
212                                 int64_t endsource_sample,
213                                 int64_t startsource_frame,
214                                 int64_t endsource_frame,
215                                 Asset *asset);
216         int paste_silence(double start,
217                 double end,
218                 int edit_plugins,
219                 int edit_autos);
220         int purge_asset(Asset *asset);
221         int asset_used(Asset *asset);
222 // Transition popup
223         int popup_transition(int cursor_x, int cursor_y);
224         int select_auto(int cursor_x, int cursor_y);
225         int move_auto(int cursor_x, int cursor_y, int shift_down);
226         int modify_edithandles(double &oldposition, double &newposition,
227                 int currentend, int handle_mode, int edit_labels,
228                 int edit_plugins, int edit_autos, int group_id);
229         int modify_pluginhandles(double &oldposition,
230                 double &newposition,
231                 int currentend,
232                 int handle_mode,
233                 int edit_labels,
234                 int edit_autos,
235                 Edits *trim_edits);
236         int select_handles();
237         int select_region();
238         int select_edit(int64_t cursor_position, int cursor_x, int cursor_y, int64_t &new_start, int64_t &new_end);
239         int feather_edits(int64_t start, int64_t end, int64_t samples, int audio, int video);
240         int64_t get_feather(int64_t selectionstart, int64_t selectionend, int audio, int video);
241 // Move edit boundaries and automation during a framerate change
242         int scale_time(float rate_scale, int ignore_record, int scale_edits, int scale_autos, int64_t start, int64_t end);
243
244         void clear_transitions(double start, double end);
245         void shuffle_edits(double start, double end);
246         void reverse_edits(double start, double end);
247         void align_edits(double start, double end);
248         void set_edit_length(double start, double end, double length);
249         void set_transition_length(double start, double end, double length);
250         void set_transition_length(Transition *transition, double length);
251         void paste_transitions(double start, double end, int track_type, char* title);
252         void update_idxbl_length(int id, double dt);
253         void create_keyframes(double position, int mask, int mode);
254
255 // ================================== accounting
256
257         int handles, titles;     // show handles or titles
258         int show_output;         // what type of video to draw
259         AutoConf auto_conf;      // which autos are visible
260         int overlays_visible;
261         double total_playable_length();     // Longest track.
262 // Used by equivalent_output
263         int total_playable_vtracks();
264         double total_recordable_length();   // Longest track with recording on
265         int totalpixels();       // height of all tracks in pixels
266         int number_of(Track *track);        // track number of pointer
267         Track* number(int number);      // pointer to track number
268         Track *get(int idx, int data_type);
269
270 private:
271 };
272
273 #endif