prevent popup deactivation while button_down
[goodguy/history.git] / cinelerra-5.0 / cinelerra / autos.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 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 AUTOS_H
23 #define AUTOS_H
24
25 #include <stdio.h>
26 #include <stdint.h>
27
28 // Base class for automation lists.
29 // Units are the native units for the track data type.
30
31 #include "auto.h"
32 #include "edl.inc"
33 #include "guicast.h"
34 #include "filexml.inc"
35 #include "track.inc"
36
37 #define AUTOS_VIRTUAL_HEIGHT 160
38
39 class Autos : public List<Auto>
40 {
41 public:
42         Autos(EDL *edl, Track *track);
43                 
44         virtual ~Autos();
45
46         void resample(double old_rate, double new_rate);
47
48         virtual void create_objects();
49         void equivalent_output(Autos *autos, int64_t startproject, int64_t *result);
50         void copy_from(Autos *autos);
51         virtual Auto* new_auto();
52 // Get existing auto on or before position.
53 // If use_default is true, return default_auto if none exists 
54 // on or before position.
55 // Return 0 if none exists and use_default is false.
56 // If &current is nonzero it is used as a starting point for searching.
57         Auto* get_prev_auto(int64_t position, int direction, Auto* &current, int use_default = 1);
58         Auto* get_prev_auto(int direction, Auto* &current);
59         Auto* get_next_auto(int64_t position, int direction, Auto* &current, int use_default = 1);
60 // Determine if a keyframe exists before creating it.
61         int auto_exists_for_editing(double position);
62 // Returns auto at exact position, null if non-existent. ignores autokeyframming and align on frames
63         Auto* get_auto_at_position(double position = -1);
64
65 // Get keyframe for editing with automatic creation if enabled
66         Auto* get_auto_for_editing(double position = -1);
67
68 // Insert keyframe at the point if it doesn't exist
69         Auto* insert_auto(int64_t position);
70         void insert_track(Autos *automation, 
71                 int64_t start_unit, 
72                 int64_t length_units,
73                 int replace_default);
74         virtual int load(FileXML *xml);
75         void remove_nonsequential(Auto *keyframe);
76         void optimize();
77
78 // Returns a type enumeration
79         int get_type();
80         int64_t get_length();
81         virtual void get_extents(float *min, 
82                 float *max,
83                 int *coords_undefined,
84                 int64_t unit_start,
85                 int64_t unit_end);
86
87         EDL *edl;
88         Track *track;
89 // Default settings if no autos.
90 // Having a persistent keyframe created problems when files were loaded and
91 // we wanted to keep only 1 auto.
92 // Default auto has position 0 except in effects, where multiple default autos
93 // exist.
94         Auto *default_auto;
95
96         int type;
97         enum
98         {
99                 AUTOMATION_TYPE_FLOAT,
100                 AUTOMATION_TYPE_MASK,
101                 AUTOMATION_TYPE_INT,
102                 AUTOMATION_TYPE_PAN,
103                 AUTOMATION_TYPE_PLUGIN
104         };
105
106
107
108         virtual void dump(FILE *fp);
109
110
111
112
113
114
115         int clear_all();
116         int insert(int64_t start, int64_t end);
117         int paste_silence(int64_t start, int64_t end);
118 // Copy for keyframe clipboard & drag & drop
119 // default_only - only copy the default keyframe
120         int copy(int64_t start, 
121                 int64_t end, 
122                 FileXML *xml, 
123                 int default_only,
124                 int active_only);
125 // Paste for keyframe clipboard & drag & drop
126 // default_only - only paste the default keyframe
127         void paste(int64_t start, 
128                 int64_t length, 
129                 double scale, 
130                 FileXML *file, 
131                 int default_only,
132                 int active_only);
133 // Stores the background rendering position in result
134         void clear(int64_t start, 
135                 int64_t end, 
136                 int shift_autos);
137         virtual void set_automation_mode(int64_t start, int64_t end, int mode);
138         int clear_auto(int64_t position);
139         int save(FileXML *xml);
140         virtual int slope_adjustment(int64_t ax, double slope);
141         int release_auto();
142         virtual int release_auto_derived() { return 0; }
143         Auto* append_auto();
144         int scale_time(float rate_scale, int scale_edits, int scale_autos, int64_t start, int64_t end);
145
146 // rendering utilities
147         int get_neighbors(int64_t start, int64_t end, Auto **before, Auto **after);
148 // 1 if automation doesn't change
149         virtual int automation_is_constant(int64_t start, int64_t end);       
150         virtual double get_automation_constant(int64_t start, int64_t end);
151         int init_automation(int64_t &buffer_position,
152                                 int64_t &input_start, 
153                                 int64_t &input_end, 
154                                 int &automate, 
155                                 double &constant, 
156                                 int64_t input_position,
157                                 int64_t buffer_len,
158                                 Auto **before, 
159                                 Auto **after,
160                                 int reverse);
161
162         int init_slope(Auto **current_auto, 
163                                 double &slope_start, 
164                                 double &slope_value,
165                                 double &slope_position, 
166                                 int64_t &input_start, 
167                                 int64_t &input_end, 
168                                 Auto **before, 
169                                 Auto **after,
170                                 int reverse);
171
172         int get_slope(Auto **current_auto, 
173                                 double &slope_start, 
174                                 double &slope_end, 
175                                 double &slope_value,
176                                 double &slope, 
177                                 int64_t buffer_len, 
178                                 int64_t buffer_position,
179                                 int reverse);
180
181         int advance_slope(Auto **current_auto, 
182                                 double &slope_start, 
183                                 double &slope_value,
184                                 double &slope_position, 
185                                 int reverse);
186
187         Auto* autoof(int64_t position);   // return nearest auto equal to or after position
188                                                                                                   // 0 if after all autos
189         Auto* nearest_before(int64_t position);    // return nearest auto before or 0
190         Auto* nearest_after(int64_t position);     // return nearest auto after or 0
191
192         Auto *selected;
193         int skip_selected;      // if selected was added
194         int64_t selected_position, selected_position_;      // original position for moves
195         double selected_value, selected_value_;      // original position for moves
196         float virtual_h;  // height cursor moves to cover entire range when track height is less than this
197         int virtual_center;
198         int stack_number;
199         int stack_total;
200 };
201
202
203
204
205
206
207 #endif