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