r602: Fix baver's code... don't insert timecode when show_tc is not set
[cinelerra_cv/mob.git] / cinelerra / trackcanvas.h
blob741d99eb53d6b90c8a38c6feeb4e41272a8b84db
1 #ifndef TRACKCANVAS_H
2 #define TRACKCANVAS_H
4 #include "asset.inc"
5 #include "auto.inc"
6 #include "autos.inc"
7 #include "bezierauto.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_playback_cursor();
42 void draw_highlighting();
43 // User can either call draw or draw_overlays to copy a fresh
44 // canvas and just draw the overlays over it
45 void draw_overlays();
46 void update_handles();
47 // Convert edit coords to transition coords
48 void get_transition_coords(int64_t &x, int64_t &y, int64_t &w, int64_t &h);
49 void get_handle_coords(Edit *edit,
50 int64_t &x,
51 int64_t &y,
52 int64_t &w,
53 int64_t &h,
54 int side);
55 void draw_title(Edit *edit,
56 int64_t edit_x,
57 int64_t edit_y,
58 int64_t edit_w,
59 int64_t edit_h);
60 void draw_automation();
61 void draw_inout_points();
62 void draw_auto(Auto *current,
63 int x,
64 int y,
65 int center_pixel,
66 int zoom_track,
67 int color);
68 void draw_floatauto(Auto *current,
69 int x,
70 int y,
71 int in_x,
72 int in_y,
73 int out_x,
74 int out_y,
75 int center_pixel,
76 int zoom_track,
77 int color);
78 int test_auto(Auto *current,
79 int x,
80 int y,
81 int center_pixel,
82 int zoom_track,
83 int cursor_x,
84 int cursor_y,
85 int buttonpress);
86 int test_floatauto(Auto *current,
87 int x,
88 int y,
89 int in_x,
90 int in_y,
91 int out_x,
92 int out_y,
93 int center_pixel,
94 int zoom_track,
95 int cursor_x,
96 int cursor_y,
97 int buttonpress);
98 void draw_floatline(int center_pixel,
99 FloatAuto *previous,
100 FloatAuto *current,
101 FloatAutos *autos,
102 double unit_start,
103 double zoom_units,
104 double yscale,
105 int ax,
106 int ay,
107 int ax2,
108 int ay2,
109 int color);
110 int test_floatline(int center_pixel,
111 FloatAutos *autos,
112 double unit_start,
113 double zoom_units,
114 double yscale,
115 int x1,
116 int x2,
117 int cursor_x,
118 int cursor_y,
119 int buttonpress);
120 void draw_toggleline(int center_pixel,
121 int ax,
122 int ay,
123 int ax2,
124 int ay2,
125 int color);
126 int test_toggleline(Autos *autos,
127 int center_pixel,
128 int x1,
129 int y1,
130 int x2,
131 int y2,
132 int cursor_x,
133 int cursor_y,
134 int buttonpress);
135 int do_keyframes(int cursor_x,
136 int cursor_y,
137 int draw,
138 int buttonpress,
139 int &new_cursor,
140 int &update_cursor,
141 int &rerender);
143 int do_float_autos(Track *track,
144 Autos *autos,
145 int cursor_x,
146 int cursor_y,
147 int draw,
148 int buttonpress,
149 int color,
150 Auto * &auto_instance);
152 int do_toggle_autos(Track *track,
153 Autos *autos,
154 int cursor_x,
155 int cursor_y,
156 int draw,
157 int buttonpress,
158 int color,
159 Auto * &auto_instance);
160 int do_autos(Track *track,
161 Autos *autos,
162 int cursor_x,
163 int cursor_y,
164 int draw,
165 int buttonpress,
166 BC_Pixmap *pixmap,
167 Auto * &auto_instance);
168 int do_plugin_autos(Track *track,
169 int cursor_x,
170 int cursor_y,
171 int draw,
172 int buttonpress,
173 Plugin* &keyframe_plugin,
174 KeyFrame* &keyframe_instance);
177 void calculate_viewport(Track *track,
178 double &view_start,
179 double &unit_start,
180 double &view_end,
181 double &unit_end,
182 double &yscale,
183 int &center_pixel,
184 double &zoom_sample,
185 double &zoom_units);
187 void synchronize_autos(float change, Track *skip, FloatAuto *fauto, int fill_gangs);
190 void draw_brender_start();
191 void draw_loop_points();
192 void draw_transitions();
193 void draw_drag_handle();
194 void draw_plugins();
195 void update_edit_handles(Edit *edit, int64_t edit_x, int64_t edit_y, int64_t edit_w, int64_t edit_h);
196 void update_transitions();
197 void update_keyframe_handles(Track *track);
198 void get_keyframe_sizes(Track *track, BezierAuto *current, int64_t &x, int64_t &y, int64_t &w, int64_t &h);
199 // Draw everything to synchronize with the view
200 void draw(int force = 0, int hide_cursor = 1);
201 // Draw resources during index building
202 void draw_indexes(Asset *asset);
203 // Get location of edit on screen without boundary checking
204 void edit_dimensions(Edit *edit, int64_t &x, int64_t &y, int64_t &w, int64_t &h);
205 void track_dimensions(Track *track, int64_t &x, int64_t &y, int64_t &w, int64_t &h);
206 void plugin_dimensions(Plugin *plugin, int64_t &x, int64_t &y, int64_t &w, int64_t &h);
207 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);
208 ResourcePixmap* create_pixmap(Edit *edit, int64_t edit_x, int64_t pixmap_x, int64_t pixmap_w, int64_t pixmap_h);
209 int set_index_file(int flash, Asset *asset);
210 void update_cursor();
211 // Get edit and handle the cursor is over
212 int test_edit_handles(int cursor_x,
213 int cursor_y,
214 int button_press,
215 int &redraw,
216 int &rerender);
217 // Get plugin and handle the cursor if over
218 int test_plugin_handles(int cursor_x,
219 int cursor_y,
220 int button_press,
221 int &redraw,
222 int &rerender);
223 // Get edit the cursor is over
224 int test_edits(int cursor_x,
225 int cursor_y,
226 int button_press,
227 int drag_start,
228 int &redraw,
229 int &rerender,
230 int &new_cursor,
231 int &update_cursor);
232 int test_tracks(int cursor_x,
233 int cursor_y,
234 int button_press);
235 int test_resources(int cursor_x, int cursor_y);
236 int test_plugins(int cursor_x,
237 int cursor_y,
238 int drag_start,
239 int button_press,
240 int &redraw,
241 int &rerender);
242 int test_transitions(int cursor_x,
243 int cursor_y,
244 int button_press,
245 int &new_cursor,
246 int &update_cursor);
247 int button_press_event();
248 int button_release_event();
249 int cursor_motion_event();
250 int activate();
251 int deactivate();
252 int repeat_event(int64_t duration);
253 void start_dragscroll();
254 void stop_dragscroll();
255 int start_selection(double position);
256 int drag_motion();
257 int drag_stop();
258 void end_edithandle_selection();
259 void end_pluginhandle_selection();
260 // Number of seconds spanned by the trackcanvas
261 double time_visible();
262 void update_drag_handle();
263 int update_drag_edit();
264 int update_drag_floatauto(int cursor_x, int cursor_y);
265 int update_drag_toggleauto(int cursor_x, int cursor_y);
266 int update_drag_auto(int cursor_x, int cursor_y);
267 int update_drag_pluginauto(int cursor_x, int cursor_y);
269 // Update status bar to reflect drag operation
270 void update_drag_caption();
272 int get_title_h();
273 int resource_h();
275 MWindow *mwindow;
276 MWindowGUI *gui;
277 ArrayList<ResourcePixmap*> resource_pixmaps;
278 // Allows overlays to get redrawn without redrawing the resources
279 BC_Pixmap *background_pixmap;
280 BC_DragWindow *drag_popup;
281 BC_Pixmap *transition_pixmap;
282 EditHandles *edit_handles;
283 // TransitionHandles *transition_handles;
284 BC_Pixmap *keyframe_pixmap;
285 BC_Pixmap *camerakeyframe_pixmap;
286 BC_Pixmap *modekeyframe_pixmap;
287 BC_Pixmap *pankeyframe_pixmap;
288 BC_Pixmap *projectorkeyframe_pixmap;
289 BC_Pixmap *maskkeyframe_pixmap;
290 int active;
291 // Currently in a drag scroll operation
292 int drag_scroll;
295 // Temporary for picon drawing
296 VFrame *temp_picon;
310 // event handlers
311 int button_release();
312 int draw_playback_cursor(int pixel, int flash = 1);
313 int draw_loop_point(int64_t position, int flash);
314 void draw_paste_destination();
316 int draw_floating_handle(int flash);
319 private:
320 int end_translation();
322 // ====================================== cursor selection type
323 int auto_selected; // 1 if automation selected
324 int translate_selected; // 1 if video translation selected
326 int handle_selected; // if a handle is selected
327 // 1 if not floating yet
328 // 2 if floating
329 int which_handle; // 1 left or 2 right handle
330 int64_t handle_oldposition; // original position of handle
331 int64_t handle_position; // current position of handle
332 int handle_pixel; // original pixel position of pointer in window
333 int handle_mode; // Determined by which button was pressed
335 int current_end; // end of selection 1 left 2 right
336 double selection_midpoint1, selection_midpoint2; // division between current ends
337 int region_selected; // 1 if region selected
338 int selection_type; // Whether an edit or a sample is selected
340 int auto_reposition(int &cursor_x, int &cursor_y, int64_t cursor_position);
341 int update_selection(int64_t cursor_position);
342 int update_handle_selection(int64_t cursor_position);
345 #endif