prevent popup deactivation while button_down
[goodguy/history.git] / cinelerra-5.0 / 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 "cursor.inc"
30 #include "edl.inc"
31 #include "file.inc"
32 #include "filexml.inc"
33 #include "linklist.h"
34 #include "pluginserver.inc"
35 #include "threadindexer.inc"
36 #include "track.h"
37 #include "trackcanvas.inc"
38 #include "transition.inc"
39
40
41
42 class Tracks : public List<Track>
43 {
44 public:
45         Tracks();
46         Tracks(EDL *edl);
47         virtual ~Tracks();
48
49         Tracks& operator=(Tracks &tracks);
50         int load(FileXML *xml, 
51                 int &track_offset, 
52                 uint32_t load_flags);
53         void move_edits(ArrayList<Edit*> *edits, 
54                 Track *track,
55                 double position,
56                 int edit_labels,
57                 int edit_plugins,
58                 int edit_autos);
59         void move_effect(Plugin *plugin,
60                 PluginSet *plugin_set,
61                 Track *track, 
62                 int64_t position);
63
64 // Construct a list of all the recordable edits which start on position
65         void get_affected_edits(ArrayList<Edit*> *drag_edits, 
66                 double position, 
67                 Track *start_track);
68
69         void get_automation_extents(float *min, 
70                 float *max,
71                 double start,
72                 double end);
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_video_length();
99 // Update y pixels after a zoom
100         void update_y_pixels(Theme *theme);
101 // Total number of tracks where the following toggles are selected
102         void select_all(int type,
103                 int value);
104         void translate_camera(float offset_x, float offset_y);
105         void translate_projector(float offset_x, float offset_y);
106                 int total_of(int type);
107 // add a track
108         Track* add_audio_track(int above, Track *dst_track);
109         Track* add_video_track(int above, Track *dst_track);
110         Track* add_subttl_track(int above, Track *dst_track);
111 //      Track* add_audio_track(int to_end = 1);
112 //      Track* add_video_track(int to_end = 1);
113 // delete any track
114         int delete_track(Track* track);       
115 // detach shared effects referencing module
116         int detach_shared_effects(int module);  
117
118         EDL *edl;
119         
120         
121         
122         
123
124 // Types for drag toggle behavior
125         enum
126         {
127                 NONE,
128                 PLAY,
129                 RECORD,
130                 GANG,
131                 DRAW,
132                 MUTE,
133                 EXPAND
134         };
135
136
137
138         
139         
140         
141         
142         
143         
144         int change_channels(int oldchannels, int newchannels);
145         int dump(FILE *fp);
146
147
148
149 // Change references to shared modules in all tracks from old to new.
150 // If do_swap is true values of new are replaced with old.
151         void change_modules(int old_location, int new_location, int do_swap);
152 // Append all the tracks to the end of the recordable tracks
153         int concatenate_tracks(int edit_plugins, int edit_autos);
154 // Change references to shared plugins in all tracks
155         void change_plugins(SharedLocation &old_location, SharedLocation &new_location, int do_swap);
156
157         int delete_tracks();     // delete all the recordable tracks
158         int delete_all_tracks();      // delete just the tracks
159
160         void copy_from(Tracks *tracks);
161
162 // ================================== EDL editing
163         int copy(double start, 
164                 double end, 
165                 int all, 
166                 FileXML *file, 
167                 const char *output_path = "");
168
169
170
171         int copy_assets(FileXML *xml, 
172                 double start, 
173                 double end, 
174                 int all);
175         int clear(double start, double end, int clear_plugins, int edit_autos);
176         void clear_automation(double selectionstart, 
177                 double selectionend);
178         void set_automation_mode(double selectionstart, 
179                 double selectionend,
180                 int mode);
181         int clear_default_keyframe();
182         int clear_handle(double start, 
183                 double end,
184                 double &longest_distance,
185                 int clear_labels,
186                 int clear_plugins,
187                 int edit_autos);
188         int copy_automation(double selectionstart, 
189                 double selectionend, 
190                 FileXML *file,
191                 int default_only,
192                 int autos_only);
193 //      int copy_default_keyframe(FileXML *file);
194         void paste_automation(double selectionstart, 
195                 FileXML *xml,
196                 int default_only,
197                 int active_only,
198                 int typeless);
199 //      int paste_default_keyframe(FileXML *file);
200         int paste(int64_t start, int64_t end);
201 // all units are samples by default
202         int paste_output(int64_t startproject, 
203                                 int64_t endproject, 
204                                 int64_t startsource_sample, 
205                                 int64_t endsource_sample, 
206                                 int64_t startsource_frame, 
207                                 int64_t endsource_frame, 
208                                 Asset *asset);
209         int paste_silence(double start, 
210                 double end, 
211                 int edit_plugins,
212                 int edit_autos);
213         int purge_asset(Asset *asset);
214         int asset_used(Asset *asset);
215 // Transition popup
216         int popup_transition(int cursor_x, int cursor_y);
217         int select_auto(int cursor_x, int cursor_y);
218         int move_auto(int cursor_x, int cursor_y, int shift_down);
219         int modify_edithandles(double &oldposition, 
220                 double &newposition, 
221                 int currentend, 
222                 int handle_mode,
223                 int edit_labels,
224                 int edit_plugins,
225                 int edit_autos);
226         int modify_pluginhandles(double &oldposition, 
227                 double &newposition, 
228                 int currentend, 
229                 int handle_mode,
230                 int edit_labels,
231                 int edit_autos,
232                 Edits *trim_edits);
233         int select_handles();
234         int select_region();
235         int select_edit(int64_t cursor_position, int cursor_x, int cursor_y, int64_t &new_start, int64_t &new_end);
236         int feather_edits(int64_t start, int64_t end, int64_t samples, int audio, int video);
237         int64_t get_feather(int64_t selectionstart, int64_t selectionend, int audio, int video);
238 // Move edit boundaries and automation during a framerate change
239         int scale_time(float rate_scale, int ignore_record, int scale_edits, int scale_autos, int64_t start, int64_t end);
240
241         void clear_transitions(double start, double end);
242         void shuffle_edits(double start, double end);
243         void reverse_edits(double start, double end);
244         void align_edits(double start, double end);
245         void set_edit_length(double start, double end, double length);
246         void set_transition_length(double start, double end, double length);
247         void set_transition_length(Transition *transition, double length);
248         void paste_transitions(double start, double end, int track_type, char* title);
249
250 // ================================== accounting
251
252         int handles, titles;     // show handles or titles
253         int show_output;         // what type of video to draw
254         AutoConf auto_conf;      // which autos are visible
255         int overlays_visible;
256         double total_playable_length();     // Longest track.
257 // Used by equivalent_output
258         int total_playable_vtracks();
259         double total_recordable_length();   // Longest track with recording on
260         int totalpixels();       // height of all tracks in pixels
261         int number_of(Track *track);        // track number of pointer
262         Track* number(int number);      // pointer to track number
263         Track *get(int idx, int data_type);
264
265
266 private:
267 };
268
269 #endif