r665: Merged the official release 2.0.
[cinelerra_cv.git] / cinelerra / trackcanvas.h
blobe2f717b8635b9ba7b7c3dab739f7ddb54c8a1c93
1 #ifndef TRACKCANVAS_H
2 #define TRACKCANVAS_H
4 #include "asset.inc"
5 #include "auto.inc"
6 #include "autos.inc"
7 #include "bctimer.inc"
8 #include "edit.inc"
9 #include "edithandles.inc"
10 #include "floatauto.inc"
11 #include "floatautos.inc"
12 #include "guicast.h"
13 #include "keyframe.inc"
14 #include "mwindow.inc"
15 #include "mwindowgui.inc"
16 #include "plugin.inc"
17 #include "resourcepixmap.inc"
18 #include "track.inc"
19 #include "tracks.inc"
20 #include "transitionhandles.inc"
21 #include "keyframe.inc"
22 #include "floatauto.inc"
24 class TrackCanvas : public BC_SubWindow
26 public:
27 TrackCanvas(MWindow *mwindow, MWindowGUI *gui);
28 ~TrackCanvas();
30 int create_objects();
31 void resize_event();
32 int drag_start_event();
33 int drag_motion_event();
34 int cursor_leave_event();
35 int drag_stop_event();
36 int keypress_event();
37 void draw_resources(int force = 0, // Redraw everything
38 int indexes_only = 0, // Redraw only certain audio resources with indexes
39 Asset *index_asset = 0);
40 void draw_highlight_rectangle(int x, int y, int w, int h);
41 void draw_highlight_insertion(int x, int y, int w, int h);
42 void draw_playback_cursor();
43 void draw_highlighting();
44 // User can either call draw or draw_overlays to copy a fresh
45 // canvas and just draw the overlays over it
46 void draw_overlays();
47 void update_handles();
48 // Convert edit coords to transition coords
49 void get_transition_coords(int64_t &x, int64_t &y, int64_t &w, int64_t &h);
50 void get_handle_coords(Edit *edit,
51 int64_t &x,
52 int64_t &y,
53 int64_t &w,
54 int64_t &h,
55 int side);
56 void draw_title(Edit *edit,
57 int64_t edit_x,
58 int64_t edit_y,
59 int64_t edit_w,
60 int64_t edit_h);
61 void draw_automation();
62 void draw_inout_points();
63 void draw_auto(Auto *current,
64 int x,
65 int y,
66 int center_pixel,
67 int zoom_track,
68 int color);
69 void draw_floatauto(Auto *current,
70 int x,
71 int y,
72 int in_x,
73 int in_y,
74 int out_x,
75 int out_y,
76 int center_pixel,
77 int zoom_track,
78 int color);
79 int test_auto(Auto *current,
80 int x,
81 int y,
82 int center_pixel,
83 int zoom_track,
84 int cursor_x,
85 int cursor_y,
86 int buttonpress);
87 int test_floatauto(Auto *current,
88 int x,
89 int y,
90 int in_x,
91 int in_y,
92 int out_x,
93 int out_y,
94 int center_pixel,
95 int zoom_track,
96 int cursor_x,
97 int cursor_y,
98 int buttonpress);
99 void draw_floatline(int center_pixel,
100 FloatAuto *previous,
101 FloatAuto *current,
102 FloatAutos *autos,
103 double unit_start,
104 double zoom_units,
105 double yscale,
106 int ax,
107 int ay,
108 int ax2,
109 int ay2,
110 int color);
111 int test_floatline(int center_pixel,
112 FloatAutos *autos,
113 double unit_start,
114 double zoom_units,
115 double yscale,
116 int x1,
117 int x2,
118 int cursor_x,
119 int cursor_y,
120 int buttonpress);
121 void draw_toggleline(int center_pixel,
122 int ax,
123 int ay,
124 int ax2,
125 int ay2,
126 int color);
127 int test_toggleline(Autos *autos,
128 int center_pixel,
129 int x1,
130 int y1,
131 int x2,
132 int y2,
133 int cursor_x,
134 int cursor_y,
135 int buttonpress);
136 int do_keyframes(int cursor_x,
137 int cursor_y,
138 int draw,
139 int buttonpress,
140 int &new_cursor,
141 int &update_cursor,
142 int &rerender);
144 int do_float_autos(Track *track,
145 Autos *autos,
146 int cursor_x,
147 int cursor_y,
148 int draw,
149 int buttonpress,
150 int color,
151 Auto * &auto_instance);
153 int do_toggle_autos(Track *track,
154 Autos *autos,
155 int cursor_x,
156 int cursor_y,
157 int draw,
158 int buttonpress,
159 int color,
160 Auto * &auto_instance);
161 int do_autos(Track *track,
162 Autos *autos,
163 int cursor_x,
164 int cursor_y,
165 int draw,
166 int buttonpress,
167 BC_Pixmap *pixmap,
168 Auto * &auto_instance);
169 int do_plugin_autos(Track *track,
170 int cursor_x,
171 int cursor_y,
172 int draw,
173 int buttonpress,
174 Plugin* &keyframe_plugin,
175 KeyFrame* &keyframe_instance);
178 void calculate_viewport(Track *track,
179 double &view_start,
180 double &unit_start,
181 double &view_end,
182 double &unit_end,
183 double &yscale,
184 int &center_pixel,
185 double &zoom_sample,
186 double &zoom_units);
188 // Convert percentage position inside track to value.
189 // if is_toggle is 1, the result is either 0 or 1.
190 // if reference is nonzero and a FloatAuto,
191 // the result is made relative to the value in reference.
192 float percentage_to_value(float percentage,
193 int is_toggle,
194 Auto *reference);
196 // Get x and y of a FloatAuto relative to center_pixel
197 void calculate_auto_position(double *x,
198 double *y,
199 double *in_x,
200 double *in_y,
201 double *out_x,
202 double *out_y,
203 Auto *current,
204 double unit_start,
205 double zoom_units,
206 double yscale);
207 void synchronize_autos(float change, Track *skip, FloatAuto *fauto, int fill_gangs);
210 void draw_brender_start();
211 void draw_loop_points();
212 void draw_transitions();
213 void draw_drag_handle();
214 void draw_plugins();
215 void update_edit_handles(Edit *edit, int64_t edit_x, int64_t edit_y, int64_t edit_w, int64_t edit_h);
216 void update_transitions();
217 void update_keyframe_handles(Track *track);
218 // Draw everything to synchronize with the view
219 void draw(int force = 0, int hide_cursor = 1);
220 // Draw resources during index building
221 void draw_indexes(Asset *asset);
222 // Get location of edit on screen without boundary checking
223 void edit_dimensions(Edit *edit, int64_t &x, int64_t &y, int64_t &w, int64_t &h);
224 void track_dimensions(Track *track, int64_t &x, int64_t &y, int64_t &w, int64_t &h);
225 void plugin_dimensions(Plugin *plugin, int64_t &x, int64_t &y, int64_t &w, int64_t &h);
226 void get_pixmap_size(Edit *edit, int64_t edit_x, int64_t edit_w, int64_t &pixmap_x, int64_t &pixmap_w, int64_t &pixmap_h);
227 ResourcePixmap* create_pixmap(Edit *edit, int64_t edit_x, int64_t pixmap_x, int64_t pixmap_w, int64_t pixmap_h);
228 int set_index_file(int flash, Asset *asset);
229 void update_cursor();
230 // Get edit and handle the cursor is over
231 int do_edit_handles(int cursor_x,
232 int cursor_y,
233 int button_press,
234 int &redraw,
235 int &rerender);
236 // Get plugin and handle the cursor if over
237 int do_plugin_handles(int cursor_x,
238 int cursor_y,
239 int button_press,
240 int &redraw,
241 int &rerender);
242 // Get edit the cursor is over
243 int do_edits(int cursor_x,
244 int cursor_y,
245 int button_press,
246 int drag_start,
247 int &redraw,
248 int &rerender,
249 int &new_cursor,
250 int &update_cursor);
251 int do_tracks(int cursor_x,
252 int cursor_y,
253 int button_press);
254 int test_resources(int cursor_x, int cursor_y);
255 int do_plugins(int cursor_x,
256 int cursor_y,
257 int drag_start,
258 int button_press,
259 int &redraw,
260 int &rerender);
261 int do_transitions(int cursor_x,
262 int cursor_y,
263 int button_press,
264 int &new_cursor,
265 int &update_cursor);
266 int button_press_event();
267 int button_release_event();
268 int cursor_motion_event();
269 int activate();
270 int deactivate();
271 int repeat_event(int64_t duration);
272 void start_dragscroll();
273 void stop_dragscroll();
274 int start_selection(double position);
275 int drag_motion();
276 int drag_stop();
277 int64_t get_drop_position (int *is_insertion, Edit *moved_edit, int64_t moved_edit_length);
278 void end_edithandle_selection();
279 void end_pluginhandle_selection();
280 // Number of seconds spanned by the trackcanvas
281 double time_visible();
282 void update_drag_handle();
283 int update_drag_edit();
284 int update_drag_floatauto(int cursor_x, int cursor_y);
285 int update_drag_toggleauto(int cursor_x, int cursor_y);
286 int update_drag_auto(int cursor_x, int cursor_y);
287 int update_drag_pluginauto(int cursor_x, int cursor_y);
289 // Update status bar to reflect drag operation
290 void update_drag_caption();
292 int get_title_h();
293 int resource_h();
295 // Display hourglass if timer expired
296 void test_timer();
299 MWindow *mwindow;
300 MWindowGUI *gui;
301 ArrayList<ResourcePixmap*> resource_pixmaps;
302 // Allows overlays to get redrawn without redrawing the resources
303 BC_Pixmap *background_pixmap;
304 BC_DragWindow *drag_popup;
305 BC_Pixmap *transition_pixmap;
306 EditHandles *edit_handles;
307 // TransitionHandles *transition_handles;
308 BC_Pixmap *keyframe_pixmap;
309 BC_Pixmap *camerakeyframe_pixmap;
310 BC_Pixmap *modekeyframe_pixmap;
311 BC_Pixmap *pankeyframe_pixmap;
312 BC_Pixmap *projectorkeyframe_pixmap;
313 BC_Pixmap *maskkeyframe_pixmap;
314 int active;
315 // Currently in a drag scroll operation
316 int drag_scroll;
317 // Don't stop hourglass if it was never started before the operation.
318 int hourglass_enabled;
320 // Temporary for picon drawing
321 VFrame *temp_picon;
322 // Timer for hourglass
323 Timer *resource_timer;
340 // event handlers
341 int button_release();
342 int draw_playback_cursor(int pixel, int flash = 1);
343 int draw_loop_point(int64_t position, int flash);
344 void draw_paste_destination();
346 int draw_floating_handle(int flash);
349 private:
350 int end_translation();
352 // ====================================== cursor selection type
353 int auto_selected; // 1 if automation selected
354 int translate_selected; // 1 if video translation selected
356 int handle_selected; // if a handle is selected
357 // 1 if not floating yet
358 // 2 if floating
359 int which_handle; // 1 left or 2 right handle
360 int64_t handle_oldposition; // original position of handle
361 int64_t handle_position; // current position of handle
362 int handle_pixel; // original pixel position of pointer in window
363 int handle_mode; // Determined by which button was pressed
365 int current_end; // end of selection 1 left 2 right
366 double selection_midpoint1, selection_midpoint2; // division between current ends
367 int region_selected; // 1 if region selected
368 int selection_type; // Whether an edit or a sample is selected
370 int auto_reposition(int &cursor_x, int &cursor_y, int64_t cursor_position);
371 int update_selection(int64_t cursor_position);
372 int update_handle_selection(int64_t cursor_position);
375 #endif