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