Merge CV, ver=5.1; ops/methods from HV, and interface from CV where possible
[goodguy/history.git] / cinelerra-5.1 / cinelerra / edit.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 EDIT_H
23 #define EDIT_H
24
25 #include <stdio.h>
26 #include <stdint.h>
27
28 #include "asset.inc"
29 #include "edl.inc"
30 #include "guicast.h"
31 #include "edits.inc"
32 #include "filexml.inc"
33 #include "indexable.inc"
34 #include "mwindow.inc"
35 #include "plugin.inc"
36 #include "track.inc"
37 #include "transition.inc"
38
39 // UNITS ARE SAMPLES FOR AUDIO / FRAMES FOR VIDEO
40 // zoom_units was mwindow->zoom_sample for AEdit
41
42 // Generic edit of something
43
44 class Edit : public ListItem<Edit>
45 {
46 public:
47         Edit(EDL *edl, Edits *edits);
48         Edit(EDL *edl, Track *track);
49         Edit();
50         virtual ~Edit();
51
52         void reset();
53
54         Indexable* get_source();
55 // Copy from different EDL
56         virtual void copy_from(Edit *edit);
57 // Compare with edit in same EDL
58         virtual int identical(Edit &edit);
59         virtual Edit& operator=(Edit& edit);
60 // Called by Edits and PluginSet.
61 // Compare with edit in different EDL
62         virtual void equivalent_output(Edit *edit, int64_t *result);
63         virtual int operator==(Edit& edit);
64 // When inherited by a plugin need to resample keyframes
65         virtual void synchronize_params(Edit *edit);
66 // Used by Edits::insert_edits to shift plugin keyframes
67         virtual void shift_keyframes(int64_t position) {};
68
69 // Get size of frame to draw on timeline
70         double picon_w();
71         int picon_h();
72         double frame_w();
73         double frames_per_picon();
74         int copy(int64_t start, int64_t end, FileXML *xml, const char *output_path);
75 // When inherited by a plugin need to resample keyframes
76         virtual void resample(double old_rate, double new_rate) {};
77
78 // Shift in time
79         virtual void shift(int64_t difference);
80         int shift_start_in(int edit_mode,
81                 int64_t newposition,
82                 int64_t oldposition,
83                 int edit_edits,
84                 int edit_labels,
85                 int edit_plugins,
86                 int edit_autos,
87                 Edits *trim_edits);
88         int shift_start_out(int edit_mode,
89                 int64_t newposition,
90                 int64_t oldposition,
91                 int edit_edits,
92                 int edit_labels,
93                 int edit_plugins,
94                 int edit_autos,
95                 Edits *trim_edits);
96         int shift_end_in(int edit_mode,
97                 int64_t newposition,
98                 int64_t oldposition,
99                 int edit_edits,
100                 int edit_labels,
101                 int edit_plugins,
102                 int edit_autos,
103                 Edits *trim_edits);
104         int shift_end_out(int edit_mode,
105                 int64_t newposition,
106                 int64_t oldposition,
107                 int edit_edits,
108                 int edit_labels,
109                 int edit_plugins,
110                 int edit_autos,
111                 Edits *trim_edits);
112
113         void insert_transition(char  *title);
114         void detach_transition();
115 // Determine if silence depending on existance of asset or plugin title
116         virtual int silence();
117
118 // Media edit information
119 // Units are native units for the track.
120 // Start of edit in source file normalized to project sample rate.
121 // Normalized because all the editing operations clip startsource relative
122 // to the project sample rate;
123         int64_t startsource;
124 // Start of edit in project file.
125         int64_t startproject;
126 // # of units in edit.
127         int64_t length;
128 // Channel or layer of source
129         int channel;
130 // ID for resource pixmaps
131         int id;
132 // User defined title for timeline
133         char user_title[BCTEXTLEN];
134         int is_plugin;
135
136
137 // Transition if one is present at the beginning of this edit
138 // This stores the length of the transition
139         Transition *transition;
140
141         Edits *edits;
142
143         Track *track;
144
145 // Asset is 0 if silence, otherwise points an object in edl->assets
146         Asset *asset;
147
148 // points to an object in edl->clips if a nested clip
149         EDL *nested_edl;
150
151 // Parent EDL of this edit
152         EDL *edl;
153
154
155
156
157
158
159
160
161
162
163
164 // ============================= initialization
165
166         int load_properties(FileXML *xml, int64_t &startproject);
167         virtual int load_properties_derived(FileXML *xml) { return 0; };
168
169 // ============================= drawing
170
171         virtual int draw(int flash, int center_pixel,
172                 int x, int w, int y, int h, int set_index_file) { return 0; }
173         virtual int set_index_file(int flash, int center_pixel,
174                 int x, int y, int w, int h) { return 0; }
175         int draw_transition(int flash, int center_pixel,
176                 int x, int w, int y, int h, int set_index_file);
177
178         int draw_handles(BC_SubWindow *canvas, float view_start, float view_units,
179                 float zoom_units, int view_pixels, int center_pixel);
180         int draw_titles(BC_SubWindow *canvas, float view_start, float zoom_units,
181                 int view_pixels, int center_pixel);
182
183 // ============================= editing
184
185         virtual int copy_properties_derived(FileXML *xml,
186                 int64_t length_in_selection) { return 0; }
187
188         int popup_transition(float view_start, float zoom_units, int cursor_x, int cursor_y);
189
190 // Return 1 if the left handle was selected 2 if the right handle was selected
191         int select_handle(float view_start, float zoom_units,
192                 int cursor_x, int cursor_y, int64_t &selection);
193         virtual int get_handle_parameters(int64_t &left, int64_t &right,
194                 int64_t &left_sample, int64_t &right_sample, float view_start,
195                 float zoom_units) { return 0; }
196         virtual int64_t get_source_end(int64_t default_);
197         int dump(FILE *fp=stdout);
198         virtual int dump_derived() { return 0; }
199 };
200
201 #endif