9 #include "edithandles.inc"
10 #include "floatauto.inc"
11 #include "floatautos.inc"
13 #include "keyframe.inc"
14 #include "mwindow.inc"
15 #include "mwindowgui.inc"
16 #include "resourcethread.inc"
18 #include "plugintoggles.inc"
19 #include "resourcepixmap.inc"
22 #include "transitionhandles.inc"
23 #include "keyframe.inc"
24 #include "floatauto.inc"
26 class TrackCanvas
: public BC_SubWindow
29 TrackCanvas(MWindow
*mwindow
, MWindowGUI
*gui
);
34 int drag_start_event();
35 int drag_motion_event();
36 int cursor_leave_event();
37 int drag_stop_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
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
,
61 void draw_title(Edit
*edit
,
66 void draw_automation();
67 void draw_inout_points();
68 void draw_auto(Auto
*current
,
74 void draw_floatauto(Auto
*current
,
84 int test_auto(Auto
*current
,
92 int test_floatauto(Auto
*current
,
104 void draw_floatline(int center_pixel
,
117 int test_floatline(int center_pixel
,
128 void draw_toggleline(int center_pixel
,
134 int test_toggleline(Autos
*autos
,
143 int do_keyframes(int cursor_x
,
151 int do_float_autos(Track
*track
,
158 Auto
* &auto_instance
,
160 int do_toggle_autos(Track
*track
,
167 Auto
* &auto_instance
);
168 int do_autos(Track
*track
,
175 Auto
* &auto_instance
);
176 int do_plugin_autos(Track
*track
,
181 Plugin
* &keyframe_plugin
,
182 KeyFrame
* &keyframe_instance
);
185 void calculate_viewport(Track
*track
,
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
,
204 // Get x and y of a FloatAuto relative to center_pixel
205 void calculate_auto_position(double *x
,
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();
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
,
250 // Get plugin and handle the cursor if over
251 int do_plugin_handles(int cursor_x
,
258 // Get edit the cursor is over
259 int do_edits(int cursor_x
,
267 int do_tracks(int cursor_x
,
270 int test_resources(int cursor_x
, int cursor_y
);
271 int do_plugins(int cursor_x
,
277 int do_transitions(int cursor_x
,
282 int button_press_event();
283 int button_release_event();
284 int cursor_motion_event();
287 int repeat_event(int64_t duration
);
288 void start_dragscroll();
289 void stop_dragscroll();
290 int start_selection(double position
);
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();
311 // Display hourglass if timer expired
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
;
332 // Currently in a drag scroll operation
334 // Don't stop hourglass if it was never started before the operation.
335 int hourglass_enabled
;
337 // Temporary for picon drawing
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
;
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
);
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
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
);