pluginclient cr=apply in option value textbox, add loop_mode for vwdw
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / trackcanvas.C
index 96726f68222334a5a9af0f6766b404a1469ffdc3..c0f8f995d3453504ef4fc830c5cf9d55c7189e8a 100644 (file)
@@ -210,6 +210,7 @@ int TrackCanvas::drag_cursor_motion(int cursor_x, int cursor_y,
 // Find the edit and track the cursor is over
                for(Track *track = mwindow->edl->tracks->first; track; track = track->next)
                {
+                       if( track->is_hidden() ) continue;
                        int64_t track_x, track_y, track_w, track_h;
                        track_dimensions(track, track_x, track_y, track_w, track_h);
 
@@ -407,7 +408,7 @@ int TrackCanvas::drag_stop(int *redraw)
                                                mwindow->session->edit_highlighted->length);
                                }
                                start = mwindow->edl->align_to_frame(start, 0);
-                               mwindow->insert_effects_canvas(start, length);
+                               mwindow->insert_effects_canvas(track, start, length);
                                *redraw = 1;
                        }
                        if( mwindow->session->track_highlighted )
@@ -779,12 +780,15 @@ void TrackCanvas::draw_resources(int mode,
                gui->resource_pixmaps.remove_all_objects();
 
        if(debug) PRINT_TRACE
+       if(mode != IGNORE_THREAD)
+               gui->resource_thread->reset(pane->number, indexes_only);
 
 // Search every edit
        for(Track *current = mwindow->edl->tracks->first;
                current;
                current = NEXT)
        {
+               if( current->is_hidden() ) continue;
                if(debug) PRINT_TRACE
                for(Edit *edit = current->edits->first; edit; edit = edit->next)
                {
@@ -1011,8 +1015,8 @@ void TrackCanvas::get_pixmap_size(Edit *edit,
 //             }
 //     }
 
-       pixmap_h = mwindow->edl->local_session->zoom_track;
        Track *track = edit->edits->track;
+       pixmap_h = track->data_h;
        if( track->show_titles() )
                pixmap_h += mwindow->theme->get_image("title_bg_data")->get_h();
 //printf("get_pixmap_size %d %d %d %d\n", edit_x, edit_w, pixmap_x, pixmap_w);
@@ -1039,7 +1043,7 @@ void TrackCanvas::edit_dimensions(Edit *edit,
        if( edit->track->show_titles() )
                edit_h += mwindow->theme->get_image("title_bg_data")->get_h();
        if( edit->track->show_assets() )
-               edit_h += resource_h();
+               edit_h += edit->track->data_h;
        h = edit_h;
 }
 
@@ -1147,7 +1151,8 @@ void TrackCanvas::draw_paste_destination()
                for(Track *dest = mwindow->session->track_highlighted;
                        dest;
                        dest = dest->next) {
-                       if(dest->record) {
+                       if( dest->is_hidden() ) continue;
+                       if(dest->is_armed()) {
 // Get source width in pixels
                                w = -1;
 // Use start of highlighted edit
@@ -1295,16 +1300,12 @@ void TrackCanvas::plugin_dimensions(Plugin *plugin, int64_t &x, int64_t &y, int6
        if( plugin->track->show_titles() )
                y += mwindow->theme->get_image("title_bg_data")->get_h();
        if( plugin->track->show_assets() )
-               y += resource_h();
+               y += plugin->track->data_h;
        y += plugin->plugin_set->get_number() *
                        mwindow->theme->get_image("plugin_bg_data")->get_h();
        h = mwindow->theme->get_image("plugin_bg_data")->get_h();
 }
 
-int TrackCanvas::resource_h()
-{
-       return mwindow->edl->local_session->zoom_track;
-}
 
 void TrackCanvas::draw_highlight_rectangle(int x, int y, int w, int h)
 {
@@ -1432,11 +1433,11 @@ void TrackCanvas::get_transition_coords(Edit *edit,
        int has_titles = edit->track->show_titles();
        int has_assets = edit->track->show_assets();
        double title_bg_h = mwindow->theme->get_image("title_bg_data")->get_h();
-       double asset_h = resource_h();
-       double ys = has_assets ? asset_h : has_titles ? title_bg_h : 0;
+       int data_h = edit->track->data_h;
+       double ys = has_assets ? data_h : has_titles ? title_bg_h : 0;
        double dy = has_titles ?
-               ( has_assets ? title_bg_h + asset_h/2 : title_bg_h/2 ) :
-               ( has_assets ? asset_h/2 : 0) ;
+               ( has_assets ? title_bg_h + data_h/2 : title_bg_h/2 ) :
+               ( has_assets ? data_h/2 : 0) ;
        double title_h = mwindow->theme->title_h;
        if( dy < title_h / 2 ) { ys = title_h;  dy = ys / 2; }
        y += dy;
@@ -1682,7 +1683,8 @@ void TrackCanvas::draw_selected_edits(EDL *edl, int dx, int dy, int color0, int
 {
        int dropping = 0;
        for( Track *track=edl->tracks->first; track; track=track->next ) {
-               if( !track->record && color1 < 0 ) {
+               if( track->is_hidden() ) continue;
+               if( !track->is_armed() && color1 < 0 ) {
                        if( dropping )
                                dy -= track->vertical_span(mwindow->theme);
                        continue;
@@ -1699,9 +1701,9 @@ void TrackCanvas::draw_selected_edits(EDL *edl, int dx, int dy, int color0, int
                        int inner = color1 < 0 ? color0 : !edit->group_id ? color0 :
                                mwindow->get_group_color(edit->group_id);
                        int outer = color1 < 0 ? color0 : !edit->group_id ? color1 : inner;
-                       set_color(track->record ? inner : outer);
+                       set_color(track->is_armed() ? inner : outer);
                        draw_selected(x, y, w, h);
-                       set_color(track->record ? outer : inner);
+                       set_color(track->is_armed() ? outer : inner);
                        draw_selected(x-1, y-1, w+2, h+2);
                        draw_selected(x-2, y-2, w+1, h+1);
                }
@@ -1727,6 +1729,7 @@ void TrackCanvas::draw_plugins()
                track;
                track = track->next)
        {
+               if( track->is_hidden() ) continue;
                if(track->expand_view)
                {
                        for(int i = 0; i < track->plugin_set.total; i++)
@@ -1893,6 +1896,7 @@ void TrackCanvas::draw_hard_edges()
        int64_t x, y, w, h;
 
        for(Track *track = mwindow->edl->tracks->first; track; track = track->next) {
+               if( track->is_hidden() ) continue;
                for(Edit *edit = track->edits->first; edit; edit = edit->next) {
                        if( !edit->hard_left && !edit->hard_right ) continue;
                        edit_dimensions(edit, x, y, w, h);
@@ -1904,7 +1908,7 @@ void TrackCanvas::draw_hard_edges()
                        if( track->show_titles() )
                                y1 += mwindow->theme->get_image("title_bg_data")->get_h();
                        if( track->show_assets() )
-                               y1 += resource_h();
+                               y1 += track->data_h;
                        if( y1 == y )
                                y1 += mwindow->theme->title_h;
                        if( edit->hard_left ) {
@@ -1956,6 +1960,7 @@ void TrackCanvas::draw_drag_handle()
        set_line_width(3);
 
        for( Track *track=mwindow->edl->tracks->first; track; track=track->next ) {
+               if( track->is_hidden() ) continue;
                Edit *left = 0, *right = 0;
                double start = DBL_MAX, end = DBL_MIN;
                for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
@@ -2014,6 +2019,7 @@ void TrackCanvas::draw_transitions()
        int64_t x, y, w, h;
 
        for(Track *track = mwindow->edl->tracks->first; track; track = track->next) {
+               if( track->is_hidden() ) continue;
                if( !track->show_transitions() ) continue;
 
                for(Edit *edit = track->edits->first; edit; edit = edit->next) {
@@ -2165,8 +2171,7 @@ int TrackCanvas::do_keyframes(int cursor_x,
 // track context menu to appear
        int result = 0;
        EDLSession *session = mwindow->edl->session;
-
-
+       int gang = session->gang_tracks != GANG_NONE || get_double_click() ? 1 : 0;
 
        static BC_Pixmap *auto_pixmaps[AUTOMATION_TOTAL] =
        {
@@ -2182,6 +2187,7 @@ int TrackCanvas::do_keyframes(int cursor_x,
        for(Track *track = mwindow->edl->tracks->first;
                track && !result;
                track = track->next) {
+               if( track->is_hidden() ) continue;
                Auto *auto_keyframe = 0;
                Automation *automation = track->automation;
 
@@ -2273,7 +2279,7 @@ int TrackCanvas::do_keyframes(int cursor_x,
                                                if (buttonpress != 3)
                                                {
                                                        if(i == AUTOMATION_FADE || i == AUTOMATION_SPEED)
-                                                               fill_ganged_autos(get_double_click(), 0, track,
+                                                               fill_ganged_autos(gang, 0, track,
                                                                        (FloatAuto*)mwindow->session->drag_auto);
                                                        mwindow->session->current_operation = pre_auto_operations[i];
                                                        update_drag_caption();
@@ -2367,6 +2373,7 @@ void TrackCanvas::draw_keyframe_reticle()
            keyframe_hairline == HAIRLINE_DRAGGING && dragging ) ) {
                int show = dragging || keyframe_hairline == HAIRLINE_ALWAYS ? 1 : 0;
                for( Track *track = mwindow->edl->tracks->first; track; track=track->next ) {
+                       if( track->is_hidden() ) continue;
                        Automation *automation = track->automation;
                        for( int i=0; i<AUTOMATION_TOTAL; ++i ) {
                                if( !mwindow->edl->session->auto_conf->autos[i] ) continue;
@@ -2386,11 +2393,8 @@ void TrackCanvas::draw_keyframe_reticle()
        }
 }
 
-void TrackCanvas::draw_auto(Auto *current,
-       int x,
-       int y,
-       int center_pixel,
-       int zoom_track)
+void TrackCanvas::draw_auto(Auto *current, int x, int y,
+               int center_pixel, int data_h)
 {
        int x1, y1, x2, y2;
 
@@ -2399,8 +2403,8 @@ void TrackCanvas::draw_auto(Auto *current,
        y1 = center_pixel + y - HANDLE_W / 2;
        y2 = center_pixel + y + HANDLE_W / 2;
 
-       if(y1 < center_pixel + -zoom_track / 2) y1 = center_pixel + -zoom_track / 2;
-       if(y2 > center_pixel + zoom_track / 2) y2 = center_pixel + zoom_track / 2;
+       if( y1 < center_pixel - data_h/2 ) y1 = center_pixel - data_h/2;
+       if( y2 > center_pixel + data_h/2 ) y2 = center_pixel + data_h/2;
 
        draw_box(x1, y1, x2 - x1, y2 - y1);
 }
@@ -2453,23 +2457,16 @@ void TrackCanvas::draw_cropped_line(int x1,
 }
 
 
-void TrackCanvas::draw_floatauto(FloatAuto *current,
-       int x,
-       int y,
-       int in_x,
-       int in_y,
-       int out_x,
-       int out_y,
-       int center_pixel,
-       int zoom_track,
-       int color)
+void TrackCanvas::draw_floatauto(FloatAuto *current, int x, int y,
+               int in_x, int in_y, int out_x, int out_y,
+               int center_pixel, int data_h, int color)
 {
        int x1 = x - HANDLE_W / 2; // Center
        int x2 = x + HANDLE_W / 2;
        int y1 = center_pixel + y - HANDLE_H / 2;
        int y2 = center_pixel + y + HANDLE_H / 2;
-       int ymin = center_pixel - zoom_track / 2;
-       int ymax = center_pixel + zoom_track / 2;
+       int ymin = center_pixel - data_h / 2;
+       int ymax = center_pixel + data_h / 2;
        CLAMP(y1, ymin, ymax);
        CLAMP(y2, ymin, ymax);
 
@@ -2499,22 +2496,22 @@ void TrackCanvas::draw_floatauto(FloatAuto *current,
                return;
 
        if(in_x != x)
-               draw_floatauto_ctrlpoint(x, y, in_x, in_y, center_pixel, zoom_track, color);
+               draw_floatauto_ctrlpoint(x, y, in_x, in_y, center_pixel, data_h, color);
        if(out_x != x)
-               draw_floatauto_ctrlpoint(x, y, out_x, out_y, center_pixel, zoom_track, color);
+               draw_floatauto_ctrlpoint(x, y, out_x, out_y, center_pixel, data_h, color);
 }
 
 inline int quantize(float f) { return (int)floor(f + 0.5); }
 
 inline void TrackCanvas::draw_floatauto_ctrlpoint(
-       int x, int y, int cp_x, int cp_y, int center_pixel,
-       int zoom_track, int color)
+               int x, int y, int cp_x, int cp_y, int center_pixel,
+               int data_h, int color)
 // draw the tangent and a handle for given bézier ctrl point
 {
-       bool handle_visible = (abs(cp_y) <= zoom_track / 2);
+       bool handle_visible = (abs(cp_y) <= data_h/2);
 
        float slope = (float)(cp_y - y)/(cp_x - x);
-       CLAMP(cp_y, -zoom_track / 2, zoom_track / 2);
+       CLAMP(cp_y, -data_h/2, data_h/2);
        if(slope != 0)
                cp_x = x + quantize((cp_y - y) / slope);
 
@@ -2556,7 +2553,7 @@ inline void TrackCanvas::draw_floatauto_ctrlpoint(
 
 
 int TrackCanvas::test_auto(Auto *current,
-       int x, int y, int center_pixel, int zoom_track,
+       int x, int y, int center_pixel, int data_h,
        int cursor_x, int cursor_y, int buttonpress)
 {
        int x1, y1, x2, y2;
@@ -2566,8 +2563,8 @@ int TrackCanvas::test_auto(Auto *current,
        x2 = x + HANDLE_W / 2;
        y1 = center_pixel + y - HANDLE_H / 2;
        y2 = center_pixel + y + HANDLE_H / 2;
-       int ymin = center_pixel - zoom_track / 2;
-       int ymax = center_pixel + zoom_track / 2;
+       int ymin = center_pixel - data_h/2;
+       int ymax = center_pixel + data_h/2;
        CLAMP(y1, ymin, ymax);
        CLAMP(y2, ymin, ymax);
 
@@ -2643,7 +2640,7 @@ float TrackCanvas::value_to_percentage(float auto_value, int autogrouptype)
 
 
 int TrackCanvas::test_floatauto(FloatAuto *current, int x, int y, int in_x,
-       int in_y, int out_x, int out_y, int center_pixel, int zoom_track,
+       int in_y, int out_x, int out_y, int center_pixel, int data_h,
        int cursor_x, int cursor_y, int buttonpress, int autogrouptype)
 {
        int result = 0;
@@ -2652,8 +2649,8 @@ int TrackCanvas::test_floatauto(FloatAuto *current, int x, int y, int in_x,
        int x2 = x + HANDLE_W / 2;
        int y1 = center_pixel + y - HANDLE_W / 2;
        int y2 = center_pixel + y + HANDLE_W / 2;
-       int ymin = center_pixel - zoom_track / 2;
-       int ymax = center_pixel + zoom_track / 2;
+       int ymin = center_pixel - data_h/2;
+       int ymax = center_pixel + data_h/2;
        CLAMP(y1, ymin, ymax);
        CLAMP(y2, ymin, ymax);
 
@@ -2785,9 +2782,9 @@ static int is_linear(FloatAuto *prev, FloatAuto *next)
 {
        if( !prev || !next ) return 1;
        if( prev->curve_mode == FloatAuto::LINEAR ) return 1;
-       int64_t ipos, opos;
-       if( !(ipos = prev->get_control_in_position()) &&
-           !(opos = prev->get_control_out_position()) ) return 1;
+       int64_t ipos = prev->get_control_in_position();
+       int64_t opos = prev->get_control_out_position();
+       if( !ipos && !opos ) return 1;
        if( !ipos || !opos ) return 0;
        float ival = prev->get_control_in_value();
        float oval = prev->get_control_out_value();
@@ -2854,6 +2851,8 @@ void TrackCanvas::draw_floatline(int center_pixel,
        float automation_min = mwindow->edl->local_session->automation_mins[autogrouptype];
        float automation_max = mwindow->edl->local_session->automation_maxs[autogrouptype];
        float automation_range = automation_max - automation_min;
+       if( autogrouptype == AUTOGROUPTYPE_SPEED && automation_range < SPEED_MIN )
+               automation_range = SPEED_MIN;
        for( int x=x1; x<x2; ++x ) {
 // Interpolate value between frames
                X_TO_FLOATLINE(x)
@@ -2888,6 +2887,8 @@ int TrackCanvas::test_floatline(int center_pixel,
        float automation_min = mwindow->edl->local_session->automation_mins[autogrouptype];
        float automation_max = mwindow->edl->local_session->automation_maxs[autogrouptype];
        float automation_range = automation_max - automation_min;
+       if( autogrouptype == AUTOGROUPTYPE_SPEED && automation_range < SPEED_MIN )
+               automation_range = SPEED_MIN;
        FloatAuto *previous1 = 0, *next1 = 0;
        X_TO_FLOATLINE(cursor_x);
 
@@ -2929,7 +2930,7 @@ int TrackCanvas::test_floatline(int center_pixel,
 
 void TrackCanvas::fill_ganged_autos(int all, float change, Track *skip, FloatAuto *fauto)
 {
-       if( !skip->gang ) return;
+       if( !skip->is_ganged() ) return;
 // Handles the special case of modifying a fadeauto
 // when there are ganged faders on several tracks
        double position = skip->from_units(fauto->position);
@@ -2937,7 +2938,8 @@ void TrackCanvas::fill_ganged_autos(int all, float change, Track *skip, FloatAut
 
        for(Track *current = mwindow->edl->tracks->first; current; current = NEXT) {
                if( (all || current->data_type == skip->data_type) &&
-                   current->gang && current->record && current != skip ) {
+                   current->armed_gang(skip) && current->is_armed() &&
+                   current != skip ) {
                        FloatAutos *fade_autos = (FloatAutos*)current->automation->autos[autoidx];
                        float auto_min = mwindow->edl->local_session->automation_mins[fade_autos->autogrouptype];
                        float auto_max = mwindow->edl->local_session->automation_maxs[fade_autos->autogrouptype];
@@ -2950,7 +2952,7 @@ void TrackCanvas::fill_ganged_autos(int all, float change, Track *skip, FloatAut
                                CLAMP(new_value, auto_min, auto_max);
                                keyframe->adjust_to_new_coordinates(current_position, new_value);
                        }
-                       else {
+                       else if( all >= 0 ) {
 // create keyframe on neighbouring track at the point in time given by fauto
                                FloatAuto *previous = 0, *next = 0;
                                float value = fade_autos->get_value(current_position, PLAY_FORWARD, previous, next);
@@ -2959,6 +2961,7 @@ void TrackCanvas::fill_ganged_autos(int all, float change, Track *skip, FloatAut
                                keyframe = (FloatAuto*)fade_autos->insert_auto(current_position);
                                keyframe->set_value(new_value);
                        }
+                       if( !keyframe ) continue;
                        mwindow->session->drag_auto_gang->append((Auto *)keyframe);
                }
        }
@@ -3082,12 +3085,12 @@ void TrackCanvas::calculate_viewport(Track *track,
        int has_titles = track->show_titles();
        int has_assets = track->show_assets();
        double title_bg_h = mwindow->theme->get_image("title_bg_data")->get_h();
-       double asset_h = resource_h();
        double title_h = mwindow->theme->title_h;
-       double ys = has_assets ? asset_h : has_titles ? title_bg_h : 0;
+       double data_h = track->data_h;
+       double ys = has_assets ? data_h : has_titles ? title_bg_h : 0;
        double dy = has_titles ?
-               ( has_assets ? title_bg_h + asset_h/2 : title_bg_h/2) :
-               ( has_assets ? asset_h/2 : 0) ;
+               ( has_assets ? title_bg_h + data_h/2 : title_bg_h/2) :
+               ( has_assets ? data_h/2 : 0) ;
        if( dy < title_h/2 ) { ys = title_h;  dy = ys / 2; }
        yscale = ys;
        center_pixel = y + dy;
@@ -3135,6 +3138,8 @@ void TrackCanvas::calculate_auto_position(double *x, double *y,
        float automation_min = mwindow->edl->local_session->automation_mins[autogrouptype];
        float automation_max = mwindow->edl->local_session->automation_maxs[autogrouptype];
        float automation_range = automation_max - automation_min;
+       if( autogrouptype == AUTOGROUPTYPE_SPEED && automation_range < SPEED_MIN )
+               automation_range = SPEED_MIN;
        FloatAuto *ptr = (FloatAuto*)current;
        *x = (double)(ptr->position - unit_start) / zoom_units;
        *y = ((ptr->get_value() - automation_min) / automation_range - 0.5) * -yscale;
@@ -3232,7 +3237,7 @@ int TrackCanvas::do_float_autos(Track *track, Autos *autos, int cursor_x, int cu
 
 // Draw or test handle
                if( current && !result && current != autos->default_auto ) {
-                       if( !draw && track->record ) {
+                       if( !draw && track->is_armed() ) {
                                result = test_floatauto((FloatAuto*)current, (int)ax2, (int)ay2,
                                        (int)in_x2, (int)in_y2, (int)out_x2, (int)out_y2,
                                        (int)center_pixel, (int)yscale, cursor_x, cursor_y,
@@ -3249,7 +3254,7 @@ int TrackCanvas::do_float_autos(Track *track, Autos *autos, int cursor_x, int cu
                }
 
 // Draw or test joining line
-               if( !draw && !result && track->record /* && buttonpress != 3 */ ) {
+               if( !draw && !result && track->is_armed() /* && buttonpress != 3 */ ) {
                        result = test_floatline(center_pixel,
                                (FloatAutos*)autos, unit_start, zoom_units, yscale,
 // Exclude auto coverage from the end of the line.  The auto overlaps
@@ -3272,7 +3277,7 @@ int TrackCanvas::do_float_autos(Track *track, Autos *autos, int cursor_x, int cu
 
        if( ax < get_w() && !result ) {
                ax2 = get_w();  ay2 = ay;
-               if(!draw && track->record /* && buttonpress != 3 */ ) {
+               if(!draw && track->is_armed() /* && buttonpress != 3 */ ) {
                        result = test_floatline(center_pixel,
                                (FloatAutos*)autos, unit_start, zoom_units, yscale,
                                (int)ax, (int)ax2, cursor_x, cursor_y,
@@ -3377,7 +3382,7 @@ int TrackCanvas::do_int_autos(Track *track,
                        {
                                if(!draw)
                                {
-                                       if(track->record)
+                                       if(track->is_armed())
                                        {
                                                result = test_auto(current,
                                                        (int)ax2,
@@ -3406,7 +3411,7 @@ int TrackCanvas::do_int_autos(Track *track,
                {
                        if(!result)
                        {
-                               if(track->record /* && buttonpress != 3 */)
+                               if(track->is_armed() /* && buttonpress != 3 */)
                                {
                                        result = test_toggleline(autos,
                                                center_pixel,
@@ -3437,7 +3442,7 @@ int TrackCanvas::do_int_autos(Track *track,
                ay2 = ay;
                if(!draw)
                {
-                       if(track->record /* && buttonpress != 3 */)
+                       if(track->is_armed() /* && buttonpress != 3 */)
                        {
                                result = test_toggleline(autos,
                                        center_pixel,
@@ -3588,7 +3593,7 @@ int TrackCanvas::do_plugin_autos(Track *track, int cursor_x, int cursor_y,
                if( track->show_titles() )
                        center_pixel += mwindow->theme->get_image("title_bg_data")->get_h();
                if( track->show_assets() )
-                       center_pixel += resource_h();
+                       center_pixel += track->data_h;
                center_pixel += (i + 0.5) * mwindow->theme->get_image("plugin_bg_data")->get_h();
 
                for(Plugin *plugin = (Plugin*)plugin_set->first;
@@ -3716,43 +3721,6 @@ int TrackCanvas::draw_hairline(Auto *auto_keyframe, int color, int show)
        return 0;
 }
 
-void TrackCanvas::draw_bline(int x1, int y1, int x2, int y2, BC_Pixmap *pixmap)
-{
-// Short lines are all overhead to hw or sw setup, use bresenhams
-       if( y1 > y2 ) {
-               int tx = x1;  x1 = x2;  x2 = tx;
-               int ty = y1;  y1 = y2;  y2 = ty;
-       }
-
-       int x = x1, y = y1;
-       int dx = x2-x1, dy = y2-y1;
-       int dx2 = 2*dx, dy2 = 2*dy;
-       if( dx < 0 ) dx = -dx;
-       int r = dx > dy ? dx : dy, n = r;
-       int dir = 0;
-       if( dx2 < 0 ) dir += 1;
-       if( dy >= dx ) {
-               if( dx2 >= 0 ) do {     /* +Y, +X */
-                       draw_pixel(x, y++, pixmap);
-                       if( (r -= dx2) < 0 ) { r += dy2;  ++x; }
-               } while( --n >= 0 );
-               else do {               /* +Y, -X */
-                       draw_pixel(x, y++, pixmap);
-                       if( (r += dx2) < 0 ) { r += dy2;  --x; }
-               } while( --n >= 0 );
-       }
-       else {
-               if( dx2 >= 0 ) do {     /* +X, +Y */
-                       draw_pixel(x++, y, pixmap);
-                       if( (r -= dy2) < 0 ) { r += dx2;  ++y; }
-               } while( --n >= 0 );
-               else do {               /* -X, +Y */
-                       draw_pixel(x--, y, pixmap);
-                       if( (r -= dy2) < 0 ) { r -= dx2;  ++y; }
-               } while( --n >= 0 );
-       }
-}
-
 void TrackCanvas::draw_overlays()
 {
        int new_cursor, update_cursor, rerender;
@@ -3934,7 +3902,7 @@ int TrackCanvas::render_handle_frame(EDL *edl, int64_t pos, int mode)
                        !vrender->process_buffer(&vlt, left, 0) &&
                        !vrender->process_buffer(&vrt, pos , 0) ? 0 : 1;
                delete render_engine;
-               delete video_cache;
+               video_cache->remove_user();
                mwindow->cwindow->gui->lock_window("TrackCanvas::render_handle_frame 0");
                Canvas *canvas = mwindow->cwindow->gui->canvas;
                float ox1, oy1, ox2, oy2, cx1, cy1, cx2, cy2;
@@ -3988,7 +3956,7 @@ int TrackCanvas::get_drag_values(float *percentage,
        *percentage = 0;
        *position = 0;
 
-       if(!current->autos->track->record) return 1;
+       if(!current->autos->track->is_armed()) return 1;
        double view_start;
        double unit_start;
        double view_end;
@@ -4024,7 +3992,7 @@ int TrackCanvas::get_drag_values(float *percentage,
 
 #define UPDATE_DRAG_HEAD(do_clamp) \
        int result = 0, center_pixel; \
-       if(!current->autos->track->record) return 0; \
+       if(!current->autos->track->is_armed()) return 0; \
        double view_start, unit_start, view_end, unit_end; \
        double yscale, zoom_sample, zoom_units; \
  \
@@ -4776,6 +4744,7 @@ int TrackCanvas::do_edit_handles(int cursor_x, int cursor_y, int button_press,
        int result = 0;
 
        for( Track *track=mwindow->edl->tracks->first; track && !result; track=track->next) {
+               if( track->is_hidden() ) continue;
                for( Edit *edit=track->edits->first; edit && !result; edit=edit->next ) {
                        int64_t edit_x, edit_y, edit_w, edit_h;
                        edit_dimensions(edit, edit_x, edit_y, edit_w, edit_h);
@@ -4872,6 +4841,7 @@ int TrackCanvas::do_edit_handles(int cursor_x, int cursor_y, int button_press,
                        if( handle_result == 1 ) edit_edge += edit_result->length;
                        double edge_position = edit_result->track->from_units(edit_edge);
                        for( Track *track=mwindow->edl->tracks->first; track!=0; track=track->next ) {
+                               if( track->is_hidden() ) continue;
                                int64_t track_position = track->to_units(edge_position, 1);
                                Edit *left_edit = track->edits->editof(track_position, PLAY_FORWARD, 0);
                                if( left_edit ) {
@@ -4918,6 +4888,7 @@ int TrackCanvas::do_plugin_handles(int cursor_x,
        for(Track *track = mwindow->edl->tracks->first;
                track && !result;
                track = track->next) {
+               if( track->is_hidden() ) continue;
                for(int i = 0; i < track->plugin_set.total && !result; i++) {
                        PluginSet *plugin_set = track->plugin_set.values[i];
                        for(Plugin *plugin = (Plugin*)plugin_set->first;
@@ -5020,6 +4991,7 @@ int TrackCanvas::do_edits(int cursor_x, int cursor_y, int button_press, int drag
        int result = 0;
 
        for(Track *track = mwindow->edl->tracks->first; track && !result; track = track->next) {
+               if( track->is_hidden() ) continue;
                for(Edit *edit = track->edits->first; edit && !result; edit = edit->next) {
                        int64_t edit_x, edit_y, edit_w, edit_h;
                        edit_dimensions(edit, edit_x, edit_y, edit_w, edit_h);
@@ -5031,9 +5003,7 @@ int TrackCanvas::do_edits(int cursor_x, int cursor_y, int button_press, int drag
                                if( button_press && get_buttonpress() == LEFT_BUTTON ) {
                                        if( get_double_click() ) {
                                                mwindow->edl->tracks->clear_selected_edits();
-                                               mwindow->edl->tracks->select_affected_edits(
-                                                       edit->track->from_units(edit->startproject),
-                                                       edit->track, 1);
+                                               edit->select_affected_edits(1, -1);
                                                double start = edit->track->from_units(edit->startproject);
                                                start = mwindow->edl->align_to_frame(start, 0);
                                                mwindow->edl->local_session->set_selectionstart(start);
@@ -5052,7 +5022,7 @@ int TrackCanvas::do_edits(int cursor_x, int cursor_y, int button_press, int drag
                                                update_cursor = -1;
                                        }
                                }
-                               else if( drag_start && track->record ) {
+                               else if( drag_start && track->is_armed() ) {
                                        mwindow->session->drag_edit = edit;
                                        mwindow->session->drag_origin_x = cursor_x;
                                        mwindow->session->drag_origin_y = cursor_y;
@@ -5069,9 +5039,7 @@ int TrackCanvas::do_edits(int cursor_x, int cursor_y, int button_press, int drag
                                                        edit->set_selected(1);
                                                }
                                                else
-                                                       mwindow->edl->tracks->select_affected_edits(
-                                                               edit->track->from_units(edit->startproject),
-                                                               edit->track, 1);
+                                                       edit->select_affected_edits(1, -1);
                                                drag_start = 1;
                                        }
 // Construct list of all affected edits
@@ -5119,7 +5087,7 @@ int TrackCanvas::test_track_group(EDL *group, Track *first_track, double &pos)
        int intersects = 0;
        Track *src = group->tracks->first;
        for( Track *track=first_track; track && src; track=track->next ) {
-               if( !track->record ) return -1;
+               if( !track->is_armed() ) return -1;
                if( src->data_type != track->data_type ) return -1;
                for( Edit *src_edit=src->edits->first; src_edit; src_edit=src_edit->next ) {
                        if( src_edit->silence() ) continue;
@@ -5239,7 +5207,7 @@ int TrackCanvas::do_plugins(int cursor_x, int cursor_y, int drag_start,
                }
                else
 // Move plugin
-               if( drag_start && plugin->track->record && !plugin->silence() ) {
+               if( drag_start && plugin->track->is_armed() && !plugin->silence() ) {
                        if( mwindow->edl->session->editing_mode == EDITING_ARROW ) {
                                if( plugin->track->data_type == TRACK_AUDIO )
                                        mwindow->session->current_operation = DRAG_AEFFECT_COPY;
@@ -5299,6 +5267,7 @@ int TrackCanvas::do_transitions(int cursor_x, int cursor_y,
 
 
        for( Track *track = mwindow->edl->tracks->first; track && !result; track = track->next ) {
+               if( track->is_hidden() ) continue;
                if( !track->show_transitions() ) continue;
 
                for( Edit *edit = track->edits->first; edit; edit = edit->next ) {