r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / trackcanvas.h
blobb958f8b842f26f79178f74698ab8d6535961afff
1 #ifndef TRACKCANVAS_H
2 #define TRACKCANVAS_H
4 #include "assets.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 "mwindow.inc"
14 #include "mwindowgui.inc"
15 #include "plugin.inc"
16 #include "resourcepixmap.inc"
17 #include "track.inc"
18 #include "tracks.inc"
19 #include "transitionhandles.inc"
21 class TrackCanvas : public BC_SubWindow
23 public:
24 TrackCanvas(MWindow *mwindow, MWindowGUI *gui);
25 ~TrackCanvas();
27 int create_objects();
28 void resize_event();
29 int drag_start_event();
30 int drag_motion_event();
31 int drag_stop_event();
32 int keypress_event();
33 void draw_resources(int force = 0, // Redraw everything
34 int indexes_only = 0, // Redraw only certain audio resources with indexes
35 Asset *index_asset = 0);
36 void draw_highlight_rectangle(int x, int y, int w, int h);
37 void draw_playback_cursor();
38 void draw_highlighting();
39 // User can either call draw or draw_overlays to copy a fresh
40 // canvas and just draw the overlays over it
41 void draw_overlays();
42 void update_handles();
43 // Convert edit coords to transition coords
44 void get_transition_coords(int64_t &x, int64_t &y, int64_t &w, int64_t &h);
45 void get_handle_coords(Edit *edit,
46 int64_t &x,
47 int64_t &y,
48 int64_t &w,
49 int64_t &h,
50 int side);
51 void draw_title(Edit *edit,
52 int64_t edit_x,
53 int64_t edit_y,
54 int64_t edit_w,
55 int64_t edit_h);
56 void draw_automation();
57 void draw_inout_points();
58 void draw_auto(Auto *current,
59 int x,
60 int y,
61 int center_pixel,
62 int zoom_track,
63 int color);
64 void draw_floatauto(Auto *current,
65 int x,
66 int y,
67 int in_x,
68 int in_y,
69 int out_x,
70 int out_y,
71 int center_pixel,
72 int zoom_track,
73 int color);
74 int test_auto(Auto *current,
75 int x,
76 int y,
77 int center_pixel,
78 int zoom_track,
79 int cursor_x,
80 int cursor_y,
81 int buttonpress);
82 int test_floatauto(Auto *current,
83 int x,
84 int y,
85 int in_x,
86 int in_y,
87 int out_x,
88 int out_y,
89 int center_pixel,
90 int zoom_track,
91 int cursor_x,
92 int cursor_y,
93 int buttonpress);
94 void draw_floatline(int center_pixel,
95 FloatAuto *previous,
96 FloatAuto *current,
97 FloatAutos *autos,
98 int64_t unit_start,
99 double zoom_units,
100 double yscale,
101 int ax,
102 int ay,
103 int ax2,
104 int ay2,
105 int color);
106 int test_floatline(int center_pixel,
107 FloatAutos *autos,
108 int64_t unit_start,
109 double zoom_units,
110 double yscale,
111 int x1,
112 int x2,
113 int cursor_x,
114 int cursor_y,
115 int buttonpress);
116 void draw_toggleline(int center_pixel,
117 int ax,
118 int ay,
119 int ax2,
120 int ay2,
121 int color);
122 int test_toggleline(Autos *autos,
123 int center_pixel,
124 int x1,
125 int y1,
126 int x2,
127 int y2,
128 int cursor_x,
129 int cursor_y,
130 int buttonpress);
131 int do_keyframes(int cursor_x,
132 int cursor_y,
133 int draw,
134 int buttonpress,
135 int &new_cursor,
136 int &update_cursor,
137 int &rerender);
139 int do_float_autos(Track *track,
140 Autos *autos,
141 int cursor_x,
142 int cursor_y,
143 int draw,
144 int buttonpress,
145 int color);
146 int do_toggle_autos(Track *track,
147 Autos *autos,
148 int cursor_x,
149 int cursor_y,
150 int draw,
151 int buttonpress,
152 int color);
153 int do_autos(Track *track,
154 Autos *autos,
155 int cursor_x,
156 int cursor_y,
157 int draw,
158 int buttonpress,
159 BC_Pixmap *pixmap);
160 int do_plugin_autos(Track *track,
161 int cursor_x,
162 int cursor_y,
163 int draw,
164 int buttonpress);
167 void calculate_viewport(Track *track,
168 double &view_start,
169 int64_t &unit_start,
170 double &view_end,
171 int64_t &unit_end,
172 double &yscale,
173 int &center_pixel,
174 double &zoom_sample,
175 double &zoom_units);
177 void draw_brender_start();
178 void draw_loop_points();
179 void draw_transitions();
180 void draw_drag_handle();
181 void draw_plugins();
182 void update_edit_handles(Edit *edit, int64_t edit_x, int64_t edit_y, int64_t edit_w, int64_t edit_h);
183 void update_transitions();
184 void update_keyframe_handles(Track *track);
185 void get_keyframe_sizes(Track *track, BezierAuto *current, int64_t &x, int64_t &y, int64_t &w, int64_t &h);
186 // Draw everything to synchronize with the view
187 void draw(int force = 0, int hide_cursor = 1);
188 // Draw resources during index building
189 void draw_indexes(Asset *asset);
190 // Get location of edit on screen without boundary checking
191 void edit_dimensions(Edit *edit, int64_t &x, int64_t &y, int64_t &w, int64_t &h);
192 void track_dimensions(Track *track, int64_t &x, int64_t &y, int64_t &w, int64_t &h);
193 void plugin_dimensions(Plugin *plugin, int64_t &x, int64_t &y, int64_t &w, int64_t &h);
194 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);
195 ResourcePixmap* create_pixmap(Edit *edit, int64_t edit_x, int64_t pixmap_x, int64_t pixmap_w, int64_t pixmap_h);
196 int set_index_file(int flash, Asset *asset);
197 void update_cursor();
198 // Get edit and handle the cursor is over
199 int test_edit_handles(int cursor_x,
200 int cursor_y,
201 int button_press,
202 int &redraw,
203 int &rerender);
204 // Get plugin and handle the cursor if over
205 int test_plugin_handles(int cursor_x,
206 int cursor_y,
207 int button_press,
208 int &redraw,
209 int &rerender);
210 // Get edit the cursor is over
211 int test_edits(int cursor_x,
212 int cursor_y,
213 int button_press,
214 int drag_start,
215 int &redraw,
216 int &rerender,
217 int &new_cursor,
218 int &update_cursor);
219 int test_tracks(int cursor_x,
220 int cursor_y,
221 int button_press);
222 int test_resources(int cursor_x, int cursor_y);
223 int test_plugins(int cursor_x,
224 int cursor_y,
225 int drag_start,
226 int button_press);
227 int test_transitions(int cursor_x,
228 int cursor_y,
229 int button_press,
230 int &new_cursor,
231 int &update_cursor);
232 int button_press_event();
233 int button_release_event();
234 int cursor_motion_event();
235 int activate();
236 int deactivate();
237 int repeat_event(int64_t duration);
238 void start_dragscroll();
239 void stop_dragscroll();
240 int start_selection(double position);
241 int drag_motion();
242 int drag_stop();
243 void end_edithandle_selection();
244 void end_pluginhandle_selection();
245 // Number of seconds spanned by the trackcanvas
246 double time_visible();
247 void update_drag_handle();
248 int update_drag_edit();
249 int update_drag_floatauto(int cursor_x, int cursor_y);
250 int update_drag_toggleauto(int cursor_x, int cursor_y);
251 int update_drag_auto(int cursor_x, int cursor_y);
253 // Update status bar to reflect drag operation
254 void update_drag_caption();
256 int get_title_h();
257 int resource_h();
259 MWindow *mwindow;
260 MWindowGUI *gui;
261 ArrayList<ResourcePixmap*> resource_pixmaps;
262 // Allows overlays to get redrawn without redrawing the resources
263 BC_Pixmap *background_pixmap;
264 BC_Pixmap *drag_pixmap;
265 BC_DragWindow *drag_popup;
266 BC_Pixmap *transition_pixmap;
267 EditHandles *edit_handles;
268 // TransitionHandles *transition_handles;
269 BC_Pixmap *keyframe_pixmap;
270 BC_Pixmap *camerakeyframe_pixmap;
271 BC_Pixmap *modekeyframe_pixmap;
272 BC_Pixmap *pankeyframe_pixmap;
273 BC_Pixmap *projectorkeyframe_pixmap;
274 BC_Pixmap *maskkeyframe_pixmap;
275 int active;
276 // Currently in a drag scroll operation
277 int drag_scroll;
294 // event handlers
295 int button_release();
296 int draw_playback_cursor(int pixel, int flash = 1);
297 int draw_loop_point(int64_t position, int flash);
298 void draw_paste_destination();
300 int draw_floating_handle(int flash);
303 private:
304 int end_translation();
306 // ====================================== cursor selection type
307 int auto_selected; // 1 if automation selected
308 int translate_selected; // 1 if video translation selected
310 int handle_selected; // if a handle is selected
311 // 1 if not floating yet
312 // 2 if floating
313 int which_handle; // 1 left or 2 right handle
314 int64_t handle_oldposition; // original position of handle
315 int64_t handle_position; // current position of handle
316 int handle_pixel; // original pixel position of pointer in window
317 int handle_mode; // Determined by which button was pressed
319 int current_end; // end of selection 1 left 2 right
320 double selection_midpoint1, selection_midpoint2; // division between current ends
321 int region_selected; // 1 if region selected
322 int selection_type; // Whether an edit or a sample is selected
324 int auto_reposition(int &cursor_x, int &cursor_y, int64_t cursor_position);
325 int update_selection(int64_t cursor_position);
326 int update_handle_selection(int64_t cursor_position);
329 #endif