Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

trackcanvas.h

Go to the documentation of this file.
00001 #ifndef TRACKCANVAS_H
00002 #define TRACKCANVAS_H
00003 
00004 #include "asset.inc"
00005 #include "auto.inc"
00006 #include "autos.inc"
00007 #include "bctimer.inc"
00008 #include "edit.inc"
00009 #include "edithandles.inc"
00010 #include "floatauto.inc"
00011 #include "floatautos.inc"
00012 #include "guicast.h"
00013 #include "keyframe.inc"
00014 #include "mwindow.inc"
00015 #include "mwindowgui.inc"
00016 #include "plugin.inc"
00017 #include "resourcepixmap.inc"
00018 #include "track.inc"
00019 #include "tracks.inc"
00020 #include "transitionhandles.inc"
00021 #include "keyframe.inc"
00022 #include "floatauto.inc"
00023 
00024 class TrackCanvas : public BC_SubWindow
00025 {
00026 public:
00027         TrackCanvas(MWindow *mwindow, MWindowGUI *gui);
00028         ~TrackCanvas();
00029 
00030         int create_objects();
00031         void resize_event();
00032         int drag_start_event();
00033         int drag_motion_event();
00034         int cursor_leave_event();
00035         int drag_stop_event();
00036         int keypress_event();
00037         void draw_resources(int force = 0,  // Redraw everything
00038                 int indexes_only = 0,     // Redraw only certain audio resources with indexes
00039                 Asset *index_asset = 0);
00040         void draw_highlight_rectangle(int x, int y, int w, int h);
00041         void draw_highlight_insertion(int x, int y, int w, int h);
00042         void draw_playback_cursor();
00043         void draw_highlighting();
00044 // User can either call draw or draw_overlays to copy a fresh 
00045 // canvas and just draw the overlays over it
00046         void draw_overlays();
00047         void update_handles();
00048 // Convert edit coords to transition coords
00049         void get_transition_coords(int64_t &x, int64_t &y, int64_t &w, int64_t &h);
00050         void get_handle_coords(Edit *edit, 
00051                 int64_t &x, 
00052                 int64_t &y, 
00053                 int64_t &w, 
00054                 int64_t &h, 
00055                 int side);
00056         void draw_title(Edit *edit, 
00057                 int64_t edit_x, 
00058                 int64_t edit_y, 
00059                 int64_t edit_w, 
00060                 int64_t edit_h);
00061         void draw_automation();
00062         void draw_inout_points();
00063         void draw_auto(Auto *current, 
00064                 int x, 
00065                 int y, 
00066                 int center_pixel, 
00067                 int zoom_track,
00068                 int color);
00069         void draw_floatauto(Auto *current, 
00070                 int x, 
00071                 int y, 
00072                 int in_x,
00073                 int in_y,
00074                 int out_x,
00075                 int out_y,
00076                 int center_pixel, 
00077                 int zoom_track,
00078                 int color);
00079         int test_auto(Auto *current, 
00080                 int x, 
00081                 int y, 
00082                 int center_pixel, 
00083                 int zoom_track, 
00084                 int cursor_x, 
00085                 int cursor_y, 
00086                 int buttonpress);
00087         int test_floatauto(Auto *current, 
00088                 int x, 
00089                 int y, 
00090                 int in_x,
00091                 int in_y,
00092                 int out_x,
00093                 int out_y,
00094                 int center_pixel, 
00095                 int zoom_track, 
00096                 int cursor_x, 
00097                 int cursor_y, 
00098                 int buttonpress);
00099         void draw_floatline(int center_pixel, 
00100                 FloatAuto *previous,
00101                 FloatAuto *current,
00102                 FloatAutos *autos,
00103                 double unit_start,
00104                 double zoom_units,
00105                 double yscale,
00106                 int ax,
00107                 int ay,
00108                 int ax2,
00109                 int ay2,
00110                 int color);
00111         int test_floatline(int center_pixel, 
00112                 FloatAutos *autos,
00113                 double unit_start,
00114                 double zoom_units,
00115                 double yscale,
00116                 int x1,
00117                 int x2,
00118                 int cursor_x, 
00119                 int cursor_y, 
00120                 int buttonpress);
00121         void draw_toggleline(int center_pixel, 
00122                 int ax,
00123                 int ay,
00124                 int ax2,
00125                 int ay2,
00126                 int color);
00127         int test_toggleline(Autos *autos,
00128                 int center_pixel, 
00129                 int x1,
00130                 int y1,
00131                 int x2,
00132                 int y2,
00133                 int cursor_x, 
00134                 int cursor_y, 
00135                 int buttonpress);
00136         int do_keyframes(int cursor_x, 
00137                 int cursor_y, 
00138                 int draw, 
00139                 int buttonpress, 
00140                 int &new_cursor,
00141                 int &update_cursor,
00142                 int &rerender);
00143 
00144         int do_float_autos(Track *track, 
00145                 Autos *autos, 
00146                 int cursor_x, 
00147                 int cursor_y, 
00148                 int draw, 
00149                 int buttonpress,
00150                 int color,
00151                 Auto * &auto_instance);
00152 
00153         int do_toggle_autos(Track *track, 
00154                 Autos *autos, 
00155                 int cursor_x, 
00156                 int cursor_y, 
00157                 int draw, 
00158                 int buttonpress,
00159                 int color,
00160                 Auto * &auto_instance);
00161         int do_autos(Track *track, 
00162                 Autos *autos, 
00163                 int cursor_x, 
00164                 int cursor_y, 
00165                 int draw, 
00166                 int buttonpress,
00167                 BC_Pixmap *pixmap,
00168                 Auto * &auto_instance);
00169         int do_plugin_autos(Track *track,
00170                 int cursor_x, 
00171                 int cursor_y, 
00172                 int draw, 
00173                 int buttonpress,
00174                 Plugin* &keyframe_plugin,
00175                 KeyFrame* &keyframe_instance);
00176 
00177 
00178         void calculate_viewport(Track *track, 
00179                 double &view_start,
00180                 double &unit_start,
00181                 double &view_end,
00182                 double &unit_end,
00183                 double &yscale,
00184                 int &center_pixel,
00185                 double &zoom_sample,
00186                 double &zoom_units);
00187 
00188 // Convert percentage position inside track to value.
00189 // if is_toggle is 1, the result is either 0 or 1.
00190 // if reference is nonzero and a FloatAuto, 
00191 //     the result is made relative to the value in reference.
00192         float percentage_to_value(float percentage, 
00193                 int is_toggle,
00194                 Auto *reference);
00195 
00196 // Get x and y of a FloatAuto relative to center_pixel
00197         void calculate_auto_position(double *x, 
00198                 double *y,
00199                 double *in_x,
00200                 double *in_y,
00201                 double *out_x,
00202                 double *out_y,
00203                 Auto *current,
00204                 double unit_start,
00205                 double zoom_units,
00206                 double yscale);
00207         void synchronize_autos(float change, Track *skip, FloatAuto *fauto, int fill_gangs);
00208 
00209 
00210         void draw_brender_start();
00211         void draw_loop_points();
00212         void draw_transitions();
00213         void draw_drag_handle();
00214         void draw_plugins();
00215         void update_edit_handles(Edit *edit, int64_t edit_x, int64_t edit_y, int64_t edit_w, int64_t edit_h);
00216         void update_transitions();
00217         void update_keyframe_handles(Track *track);
00218 // Draw everything to synchronize with the view
00219         void draw(int force = 0, int hide_cursor = 1);
00220 // Draw resources during index building
00221         void draw_indexes(Asset *asset);
00222 // Get location of edit on screen without boundary checking
00223         void edit_dimensions(Edit *edit, int64_t &x, int64_t &y, int64_t &w, int64_t &h);
00224         void track_dimensions(Track *track, int64_t &x, int64_t &y, int64_t &w, int64_t &h);
00225         void plugin_dimensions(Plugin *plugin, int64_t &x, int64_t &y, int64_t &w, int64_t &h);
00226         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);
00227         ResourcePixmap* create_pixmap(Edit *edit, int64_t edit_x, int64_t pixmap_x, int64_t pixmap_w, int64_t pixmap_h);
00228         int set_index_file(int flash, Asset *asset);
00229         void update_cursor();
00230 // Get edit and handle the cursor is over
00231         int do_edit_handles(int cursor_x, 
00232                 int cursor_y, 
00233                 int button_press,
00234                 int &redraw,
00235                 int &rerender);
00236 // Get plugin and handle the cursor if over
00237         int do_plugin_handles(int cursor_x, 
00238                 int cursor_y, 
00239                 int button_press,
00240                 int &redraw,
00241                 int &rerender);
00242 // Get edit the cursor is over
00243         int do_edits(int cursor_x, 
00244                 int cursor_y, 
00245                 int button_press,
00246                 int drag_start,
00247                 int &redraw,
00248                 int &rerender,
00249                 int &new_cursor,
00250                 int &update_cursor);
00251         int do_tracks(int cursor_x, 
00252                 int cursor_y,
00253                 int button_press);
00254         int test_resources(int cursor_x, int cursor_y);
00255         int do_plugins(int cursor_x, 
00256                 int cursor_y, 
00257                 int drag_start,
00258                 int button_press,
00259                 int &redraw,
00260                 int &rerender);
00261         int do_transitions(int cursor_x, 
00262                 int cursor_y, 
00263                 int button_press,
00264                 int &new_cursor,
00265                 int &update_cursor);
00266         int button_press_event();
00267         int button_release_event();
00268         int cursor_motion_event();
00269         int activate();
00270         int deactivate();
00271         int repeat_event(int64_t duration);
00272         void start_dragscroll();
00273         void stop_dragscroll();
00274         int start_selection(double position);
00275         int drag_motion();
00276         int drag_stop();
00277         int64_t get_drop_position (int *is_insertion, Edit *moved_edit, int64_t moved_edit_length);
00278         void end_edithandle_selection();
00279         void end_pluginhandle_selection();
00280 // Number of seconds spanned by the trackcanvas
00281         double time_visible();
00282         void update_drag_handle();
00283         int update_drag_edit();
00284         int update_drag_floatauto(int cursor_x, int cursor_y);
00285         int update_drag_toggleauto(int cursor_x, int cursor_y);
00286         int update_drag_auto(int cursor_x, int cursor_y);
00287         int update_drag_pluginauto(int cursor_x, int cursor_y);
00288 
00289 // Update status bar to reflect drag operation
00290         void update_drag_caption();
00291 
00292         int get_title_h();
00293         int resource_h();
00294 
00295 // Display hourglass if timer expired
00296         void test_timer();
00297 
00298 
00299         MWindow *mwindow;
00300         MWindowGUI *gui;
00301         ArrayList<ResourcePixmap*> resource_pixmaps;
00302 // Allows overlays to get redrawn without redrawing the resources
00303         BC_Pixmap *background_pixmap;
00304         BC_DragWindow *drag_popup;
00305         BC_Pixmap *transition_pixmap;
00306         EditHandles *edit_handles;
00307 //      TransitionHandles *transition_handles;
00308         BC_Pixmap *keyframe_pixmap;
00309         BC_Pixmap *camerakeyframe_pixmap;
00310         BC_Pixmap *modekeyframe_pixmap;
00311         BC_Pixmap *pankeyframe_pixmap;
00312         BC_Pixmap *projectorkeyframe_pixmap;
00313         BC_Pixmap *maskkeyframe_pixmap;
00314         int active;
00315 // Currently in a drag scroll operation
00316         int drag_scroll;
00317 // Don't stop hourglass if it was never started before the operation.
00318         int hourglass_enabled;
00319 
00320 // Temporary for picon drawing
00321         VFrame *temp_picon;
00322 // Timer for hourglass
00323         Timer *resource_timer;
00324 
00325 
00326 
00327 
00328 
00329 
00330 
00331 
00332 
00333 
00334 
00335 
00336 
00337 
00338 
00339 
00340 // event handlers
00341         int button_release();
00342         int draw_playback_cursor(int pixel, int flash = 1);
00343         int draw_loop_point(int64_t position, int flash);
00344         void draw_paste_destination();
00345 
00346         int draw_floating_handle(int flash);
00347 
00348 
00349 private:
00350         int end_translation();
00351 
00352 // ====================================== cursor selection type
00353         int auto_selected;               // 1 if automation selected
00354         int translate_selected;          // 1 if video translation selected
00355 
00356         int handle_selected;       // if a handle is selected
00357                                                                 // 1 if not floating yet
00358                                                                 // 2 if floating
00359         int which_handle;           // 1 left or 2 right handle
00360         int64_t handle_oldposition;       // original position of handle
00361         int64_t handle_position;           // current position of handle
00362         int handle_pixel;                // original pixel position of pointer in window
00363         int handle_mode;   // Determined by which button was pressed
00364 
00365         int current_end;       // end of selection 1 left 2 right
00366         double selection_midpoint1, selection_midpoint2;        // division between current ends
00367         int region_selected;         // 1 if region selected
00368         int selection_type;  // Whether an edit or a sample is selected
00369 
00370         int auto_reposition(int &cursor_x, int &cursor_y, int64_t cursor_position);
00371         int update_selection(int64_t cursor_position);
00372         int update_handle_selection(int64_t cursor_position);
00373 };
00374 
00375 #endif

Generated on Sun Jan 8 13:39:01 2006 for Cinelerra-svn by  doxygen 1.4.4