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