fix awdw solo vicon crash, fix nested clip for binfolders, open edit edl
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / trackcanvas.C
index 70b00a79aefed0491b7eec5d84842477ba0379ed..fc7283c9be31f76ba88e6dafe8a5b4178788ba07 100644 (file)
@@ -779,6 +779,8 @@ 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);
 
 // Search every edit
        for(Track *current = mwindow->edl->tracks->first;
@@ -880,6 +882,14 @@ void TrackCanvas::draw_resources(int mode,
 
                        }
                }
+               int64_t track_x, track_y, track_w, track_h;
+               track_dimensions(current,
+                       track_x, track_y, track_w, track_h);
+               set_color((~get_resources()->get_bg_color()) & 0xffffff);
+               set_opaque();
+               int x1 = track_x, x2 = x1+track_w;
+               int y1 = track_y+track_h-1;
+               draw_line(x1,y1, x2,y1, background_pixmap);
        }
 
 
@@ -1003,8 +1013,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);
@@ -1031,7 +1041,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;
 }
 
@@ -1287,16 +1297,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)
 {
@@ -1307,29 +1313,22 @@ void TrackCanvas::draw_highlight_rectangle(int x, int y, int w, int h)
 
        if (x + w <= 0)
        {
-               draw_triangle_left(0, y + h /6, h * 2/3, h * 2/3, BLACK, GREEN, YELLOW, RED, BLUE);
+               draw_triangle_left(0, y + h /6,
+                       h * 2/3, h * 2/3, BLACK, GREEN, YELLOW, RED, BLUE);
                return;
        } else
        if (x >= get_w())
        {
-               draw_triangle_right(get_w() - h * 2/3, y + h /6, h * 2/3, h * 2/3, BLACK, GREEN, YELLOW, RED, BLUE);
+               draw_triangle_right(get_w() - h * 2/3, y + h /6,
+                       h * 2/3, h * 2/3, BLACK, GREEN, YELLOW, RED, BLUE);
                return;
        }
 
 // Fix bug in heroines & cvs version as of 22.8.2005:
 // If we grab when zoomed in and zoom out while dragging, when edit gets really narrow strange things start happening
        if (w >= 0 && w < 3) {x -= w /2; w = 3;};
-       if(x < -10)
-       {
-               w += x - -10;
-               x = -10;
-       }
-
-       if(y < -10)
-       {
-               h += y - -10;
-               y = -10;
-       }
+       if(x < -10) { w += x - -10;  x = -10; }
+       if(y < -10) { h += y - -10;  y = -10; }
 
        w = MIN(w, get_w() + 20);
        h = MIN(h, get_h() + 20);
@@ -1385,16 +1384,8 @@ void TrackCanvas::draw_highlight_insertion(int x, int y, int w, int h)
 // Fix bug in heroines & cvs version as of 22.8.2005:
 // If we grab when zoomed in and zoom out while dragging, when edit gets really narrow strange things start happening
        if (w >= 0 && w < 3) {x -= w /2; w = 3;};
-       if(x < -10)
-       {
-               w += x - -10;
-               x = -10;
-       }
-       if(y < -10)
-       {
-               h += y - -10;
-               y = -10;
-       }
+       if(x < -10) { w += x - -10;  x = -10; }
+       if(y < -10) { h += y - -10;  y = -10; }
        w = MIN(w, get_w() + 20);
        h = MIN(h, get_h() + 20);
        set_color(mwindow->preferences->highlight_inverse);
@@ -1435,15 +1426,15 @@ void TrackCanvas::get_handle_coords(Edit *edit, int64_t &x, int64_t &y, int64_t
 void TrackCanvas::get_transition_coords(Edit *edit,
                int64_t &x, int64_t &y, int64_t &w, int64_t &h)
 {
-       int transition_w = 30, transition_h = 30;
+       int transition_w = xS(30), transition_h = yS(30);
        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;
@@ -1687,9 +1678,16 @@ void TrackCanvas::draw_selected(int x, int y, int w, int h)
 
 void TrackCanvas::draw_selected_edits(EDL *edl, int dx, int dy, int color0, int color1)
 {
+       int dropping = 0;
        for( Track *track=edl->tracks->first; track; track=track->next ) {
+               if( !track->record && color1 < 0 ) {
+                       if( dropping )
+                               dy -= track->vertical_span(mwindow->theme);
+                       continue;
+               }
                for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
                        if( !edit->is_selected ) continue;
+                       dropping = 1;
                        int64_t x, y, w, h;
                        edit_dimensions(edit, x, y, w, h);
                        x += dx;  y += dy;
@@ -1698,10 +1696,10 @@ void TrackCanvas::draw_selected_edits(EDL *edl, int dx, int dy, int color0, int
                        set_opaque();
                        int inner = color1 < 0 ? color0 : !edit->group_id ? color0 :
                                mwindow->get_group_color(edit->group_id);
-                       set_color(inner);
-                       draw_selected(x, y, w, h);
                        int outer = color1 < 0 ? color0 : !edit->group_id ? color1 : inner;
-                       set_color(outer);
+                       set_color(track->record ? inner : outer);
+                       draw_selected(x, y, w, h);
+                       set_color(track->record ? outer : inner);
                        draw_selected(x-1, y-1, w+2, h+2);
                        draw_selected(x-2, y-2, w+1, h+1);
                }
@@ -1793,7 +1791,7 @@ void TrackCanvas::draw_plugins()
                                                toggle_x = MIN(get_w() - right_margin, toggle_x);
 
 // On toggle
-                                               toggle_x -= PluginOn::calculate_w(mwindow) + 10;
+                                               toggle_x -= PluginOn::calculate_w(mwindow) + xS(10);
                                                if(toggle_x > min_x)
                                                {
                                                        if(current_on >= plugin_on_toggles.total)
@@ -1813,7 +1811,7 @@ void TrackCanvas::draw_plugins()
                                                if(plugin->plugin_type == PLUGIN_STANDALONE)
                                                {
 // Show
-                                                       toggle_x -= PluginShow::calculate_w(mwindow) + 10;
+                                                       toggle_x -= PluginShow::calculate_w(mwindow) + xS(10);
                                                        if(toggle_x > min_x)
                                                        {
                                                                if(current_show >= plugin_show_toggles.total)
@@ -1828,7 +1826,7 @@ void TrackCanvas::draw_plugins()
                                                                }
                                                                current_show++;
                                                        }
-                                                       toggle_x -= PluginPresetEdit::calculate_w(mwindow) + 10;
+                                                       toggle_x -= PluginPresetEdit::calculate_w(mwindow) + xS(10);
                                                        if(toggle_x > min_x)
                                                        {
                                                                if(current_preset >= preset_edit_buttons.total)
@@ -1888,19 +1886,23 @@ void TrackCanvas::refresh_plugintoggles()
 
 void TrackCanvas::draw_hard_edges()
 {
+       if( !mwindow->edl->session->auto_conf->hard_edges )
+               return;
        int64_t x, y, w, h;
 
        for(Track *track = mwindow->edl->tracks->first; track; track = track->next) {
                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);
+                       if( !MWindowGUI::visible(x, x + w, 0, get_w()) ||
+                           !MWindowGUI::visible(y, y + h, 0, get_h()) ) continue;
                        set_color(GREEN);
                        set_opaque();
                        int y1 = y;
                        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 ) {
@@ -1981,19 +1983,19 @@ void TrackCanvas::draw_drag_handle()
                edit_dimensions(edit, x, y, w, h);
                if( y+h < 0 || y >= get_h() ) continue;
                int edge_x = !drag_handle ? x : x + w;
-               int edge_y = y + h/2, k = 10;
+               int edge_y = y + h/2, xs10 = xS(10), ys10 = yS(10);
                if( edge_x >= 0 && edge_x < get_w() ) {
                        if( !can_drag ) {
-                               draw_line(edge_x-k,edge_y-k, edge_x+k,edge_y+k);
-                               draw_line(edge_x-k,edge_y+k, edge_x+k,edge_y-k);
+                               draw_line(edge_x-xs10,edge_y-ys10, edge_x+xs10,edge_y+ys10);
+                               draw_line(edge_x-xs10,edge_y+ys10, edge_x+xs10,edge_y-ys10);
                        }
                        else if( !drag_handle ) {
-                               draw_line(edge_x+k,edge_y-k, edge_x,edge_y);
-                               draw_line(edge_x+k,edge_y+k, edge_x,edge_y);
+                               draw_line(edge_x+xs10,edge_y-ys10, edge_x,edge_y);
+                               draw_line(edge_x+xs10,edge_y+ys10, edge_x,edge_y);
                        }
                        else {
-                               draw_line(edge_x,edge_y, edge_x-k,edge_y-k);
-                               draw_line(edge_x,edge_y, edge_x-k,edge_y+k);
+                               draw_line(edge_x,edge_y, edge_x-xs10,edge_y-ys10);
+                               draw_line(edge_x,edge_y, edge_x-xs10,edge_y+ys10);
                        }
                }
                edge_x += delta;
@@ -2170,6 +2172,7 @@ int TrackCanvas::do_keyframes(int cursor_x,
                pankeyframe_pixmap,
                modekeyframe_pixmap,
                maskkeyframe_pixmap,
+               0,
        };
 
 
@@ -2227,10 +2230,9 @@ int TrackCanvas::do_keyframes(int cursor_x,
 
                                                if( !result && buttonpress && i == AUTOMATION_SPEED )
                                                        mwindow->speed_after(-1);
-                                               int current_grouptype = mwindow->edl->local_session->zoombar_showautotype;
-                                               if( result && buttonpress && grouptype != current_grouptype ) {
-                                                       mwindow->edl->local_session->zoombar_showautotype = grouptype;
-                                                       mwindow->gui->zoombar->update_autozoom();
+                                               if( result && buttonpress ) {
+                                                       int color = GWindowGUI::auto_colors[i];
+                                                       mwindow->gui->zoombar->update_autozoom(grouptype, color);
                                                }
                                                break; }
 
@@ -2337,7 +2339,6 @@ int TrackCanvas::do_keyframes(int cursor_x,
                new_cursor = UPRIGHT_ARROW_CURSOR;
        }
 
-
        return result;
 }
 
@@ -2383,11 +2384,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;
 
@@ -2396,8 +2394,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);
 }
@@ -2450,32 +2448,36 @@ 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);
 
-       if(y2 - 1 > y1)
-       {
-               set_color(BLACK);
-               draw_box(x1 + 1, y1 + 1, x2 - x1, y2 - y1);
-               set_color(color);
-               draw_box(x1, y1, x2 - x1, y2 - y1);
+       if( y2-1 > y1 ) {
+               if( current->curve_mode == FloatAuto::LINEAR ) {
+                       draw_box(x1, y1, x2 - x1, y2 - y1);
+               }
+               else {
+                       ArrayList<int> polygon_x;
+                       ArrayList<int> polygon_y;
+                       polygon_x.append((x1 + x2) / 2 + 1);
+                       polygon_y.append(y1 + 1);
+                       polygon_x.append(x2 + 1);
+                       polygon_y.append((y1 + y2) / 2 + 1);
+                       polygon_x.append((x1 + x2) / 2 + 1);
+                       polygon_y.append(y2 + 1);
+                       polygon_x.append(x1 + 1);
+                       polygon_y.append((y1 + y2) / 2 + 1);
+                       fill_polygon(&polygon_x, &polygon_y);
+               }
        }
 
 // show bezier control points (only) if this
@@ -2485,22 +2487,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);
 
@@ -2542,7 +2544,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;
@@ -2552,8 +2554,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);
 
@@ -2629,7 +2631,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;
@@ -2638,8 +2640,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);
 
@@ -2767,6 +2769,24 @@ int TrackCanvas::test_floatauto(FloatAuto *current, int x, int y, int in_x,
        return result;
 }
 
+static int is_linear(FloatAuto *prev, FloatAuto *next)
+{
+       if( !prev || !next ) return 1;
+       if( prev->curve_mode == FloatAuto::LINEAR ) 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();
+       float cval = prev->get_value(), nval = next->get_value();
+       if( !ival && !oval && EQUIV(cval, nval) ) return 1;
+       float ig = ival / ipos, og = oval / opos;
+       int64_t cpos = prev->position, npos = next->position;
+       float g = (nval - cval) / (npos - cpos);
+       if( EQUIV(ig, g) && EQUIV(og, g) ) return 1;
+       return 0;
+}
 
 // Get the float value & y for position x on the canvas
 #define X_TO_FLOATLINE(x) \
@@ -2799,45 +2819,45 @@ void TrackCanvas::draw_floatline(int center_pixel,
        int x1, int y1, int x2, int y2,
        int color, int autogrouptype)
 {
+       int ytop = center_pixel - yscale / 2;
+       int ybot = center_pixel + yscale / 2 - 1;
+       y1 += center_pixel;  y2 += center_pixel;
+       if( (y1 < ytop && y1 >= ybot) && (y2 < ytop || y2 >= ybot) ) return;
+// check for line draw
+       if( is_linear(previous, next) ) {
+               draw_line(x1, y1, x2, y2);
+               return;
+       }
+
 // Solve bezier equation for either every pixel or a certain large number of
 // points.
 
 // Not using slope intercept
        x1 = MAX(0, x1);
-       int prev_y = y1 + center_pixel;
-
+       draw_pixel(x1, y1);
+       int prev_y = y1;
 
 // Call by reference fails for some reason here
        FloatAuto *previous1 = previous, *next1 = next;
        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;
-
-       for(int x = x1; x < x2; x++)
-       {
+       for( int x=x1; x<x2; ++x ) {
 // Interpolate value between frames
                X_TO_FLOATLINE(x)
 
-               if(/* x > x1 && */
-                       y >= center_pixel - yscale / 2 &&
-                       y < center_pixel + yscale / 2 - 1)
-               {
-// printf("TrackCanvas::draw_floatline y=%d min=%d max=%d\n",
-// y,
-// (int)(center_pixel - yscale / 2),
-// (int)(center_pixel + yscale / 2 - 1));
-
-//printf("draw_line(%d,%d,  %d,%d)\n", x - 1, prev_y  , x, y);
-                       draw_line(x - 1, prev_y  , x, y   );
+               if( /* x > x1 && */ y >= ytop && y < ybot ) {
+                       int x1 = x-1, y1 = prev_y, x2 = x, y2 = y;
+                       if( abs(y2-y1) < 2 )
+                               draw_pixel(x2, y2);
+                       else
+                               draw_bline(x1, y1, x2, y2);
                }
                prev_y = y;
        }
 }
 
 
-
-
-
 int TrackCanvas::test_floatline(int center_pixel,
                FloatAutos *autos,
                double unit_start,
@@ -2918,7 +2938,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);
@@ -2927,6 +2947,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);
                }
        }
@@ -3050,12 +3071,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;
@@ -3556,7 +3577,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;
@@ -3653,19 +3674,23 @@ int TrackCanvas::draw_hairline(Auto *auto_keyframe, int color, int show)
        set_color(color);
        draw_line(ax, 0, ax, get_h());
 
+       char text[BCSTRLEN];
        if( show ) {
-               char text[BCSTRLEN];
                if( auto_keyframe->is_floatauto() ) {
                        FloatAuto *float_auto = (FloatAuto *)auto_keyframe;
                        sprintf(text, "%0.2f", float_auto->get_value());
                }
-               else {
+               else if( auto_keyframe->is_intauto() ) {
                        IntAuto *int_auto = (IntAuto *)auto_keyframe;
                        sprintf(text, "%d", int_auto->value);
                }
+               else
+                       show = 0;
+       }
+       if( show ) {
                int font = MEDIUMFONT;
-               int tw = get_text_width(font, text)  + TOOLTIP_MARGIN * 2;
-               int th = get_text_height(font, text) + TOOLTIP_MARGIN * 2;
+               int tw = get_text_width(font, text)  + xS(TOOLTIP_MARGIN) * 2;
+               int th = get_text_height(font, text) + yS(TOOLTIP_MARGIN) * 2;
                set_color(get_resources()->tooltip_bg_color);
                ax += HANDLE_W/2;
                ay += center_pixel + HANDLE_W/2;
@@ -3673,8 +3698,8 @@ int TrackCanvas::draw_hairline(Auto *auto_keyframe, int color, int show)
                set_color(BLACK);
                draw_rectangle(ax, ay, tw, th);
                set_font(font);
-               ax += TOOLTIP_MARGIN;
-               ay += TOOLTIP_MARGIN + get_text_ascent(font);
+               ax += xS(TOOLTIP_MARGIN);
+               ay += yS(TOOLTIP_MARGIN) + get_text_ascent(font);
                draw_text(ax, ay, text);
        }
        return 0;
@@ -3685,13 +3710,7 @@ void TrackCanvas::draw_overlays()
        int new_cursor, update_cursor, rerender;
 
 // Move background pixmap to foreground pixmap
-       draw_pixmap(background_pixmap,
-               0,
-               0,
-               get_w(),
-               get_h(),
-               0,
-               0);
+       draw_pixmap(background_pixmap, 0, 0, get_w(), get_h(), 0, 0);
 
 // In/Out points
        draw_inout_points();
@@ -3808,21 +3827,37 @@ void TrackCanvas::update_drag_handle()
                edl->create_objects();
                edl->copy_all(mwindow->edl);
                MainSession *session = mwindow->session;
-               int edit_mode = mwindow->edl->session->edit_handle_mode[session->drag_button];
+               int handle_mode = mwindow->edl->session->edit_handle_mode[session->drag_button];
                edl->modify_edithandles(session->drag_start,
-                       session->drag_position,
-                       session->drag_handle,
-                       edit_mode,
+                       session->drag_position, session->drag_handle, handle_mode,
                        edl->session->labels_follow_edits,
                        edl->session->plugins_follow_edits,
                        edl->session->autos_follow_edits,
                        !session->drag_edit ? 0 : session->drag_edit->group_id);
-               double position = edit_mode == MOVE_EDGE || edit_mode == MOVE_EDGE_MEDIA ?
-                               session->drag_position : session->drag_start ;
+
+               double position = -1;
+               int show_edge = !session->drag_handle ? 1 : 2;
+               switch( handle_mode ) {
+               case MOVE_RIPPLE:
+               case MOVE_EDGE:
+                       position = session->drag_handle ?
+                               session->drag_position : session->drag_start;
+                       show_edge = 3 - show_edge;
+                       break;
+               case MOVE_ROLL:
+               case MOVE_SLIDE:
+                       position = session->drag_position;
+                       break;
+               case MOVE_SLIP:
+                       position = session->drag_start;
+                       show_edge = 3 - show_edge;
+                       break;
+               }
+
+               if( position < 0 ) position = 0;
                Track *track = session->drag_handle_track();
                int64_t pos = track->to_units(position, 0);
-               render_handle_frame(edl, pos, shift_down() ? 0 :
-                       session->drag_handle ? 1 : 2);
+               render_handle_frame(edl, pos, shift_down() ? 0 : show_edge);
                edl->remove_user();
        }
 }
@@ -3846,8 +3881,6 @@ int TrackCanvas::render_handle_frame(EDL *edl, int64_t pos, int mode)
                CICache *video_cache = new CICache(preferences);
                render_engine->set_vcache(video_cache);
                render_engine->arm_command(&command);
-               int64_t left = pos-1;
-               if( left < 0 ) left = 0;
                VRender *vrender = render_engine->vrender;
                result = vrender &&
                        !vrender->process_buffer(&vlt, left, 0) &&
@@ -3856,16 +3889,18 @@ int TrackCanvas::render_handle_frame(EDL *edl, int64_t pos, int mode)
                delete video_cache;
                mwindow->cwindow->gui->lock_window("TrackCanvas::render_handle_frame 0");
                Canvas *canvas = mwindow->cwindow->gui->canvas;
-               canvas->lock_canvas("TrackCanvas::render_handle_frame 1");
-               int w = canvas->w, h = canvas->h, w2 = w/2, h2 = h/2;
-               int lx = 0, ly = h2/2, rx = w2, ry = h2/2;
+               float ox1, oy1, ox2, oy2, cx1, cy1, cx2, cy2;
+               canvas->get_transfers(edl, ox1, oy1, ox2, oy2, cx1, cy1, cx2, cy2);
+               float cw = canvas->w/2, ch = canvas->h/2;
+               float cdx = (cx2 - cx1)/2, cdy = (cy2 - cy1)/2;
+               int cx = cx1/2, cy = cy1/2 + ch/2;
+               int ow = ox2 - ox2, oh = oy2 - oy1;
                BC_WindowBase *window = canvas->get_canvas();
                window->set_color(BLACK);
                window->clear_box(0,0, window->get_w(),window->get_h());
-               window->draw_vframe(&vlt, lx,ly, w2,h2, 0,0,vlt.get_w(),vlt.get_h());
-               window->draw_vframe(&vrt, rx,ry, w2,h2, 0,0,vrt.get_w(),vrt.get_h());
+               window->draw_vframe(&vlt, cx,cy, cdx,cdy, ox1,oy1, ow,oh);  cx += cw;
+               window->draw_vframe(&vrt, cx,cy, cdx,cdy, ox1,oy1, ow,oh);
                window->flash(1);
-               canvas->unlock_canvas();
                mwindow->cwindow->gui->unlock_window();
                break; }
        case 1:
@@ -3873,11 +3908,11 @@ int TrackCanvas::render_handle_frame(EDL *edl, int64_t pos, int mode)
                Track *track = mwindow->session->drag_handle_track();
                double position = track->from_units(mode == 1 ? left : pos);
                if( position < 0 ) position = 0;
-               edl->local_session->set_selectionstart(position);
-               edl->local_session->set_selectionend(position);
                PlaybackEngine *playback_engine = mwindow->cwindow->playback_engine;
                if( playback_engine->is_playing_back )
                        playback_engine->stop_playback(1);
+               edl->local_session->set_selectionstart(position);
+               edl->local_session->set_selectionend(position);
                mwindow->cwindow->playback_engine->refresh_frame(CHANGE_EDL, edl, 0);
                break; }
        }
@@ -3982,7 +4017,7 @@ int TrackCanvas::update_drag_floatauto(int cursor_x, int cursor_y)
 // Snap to nearby values
                old_value = current->get_value();
                if(shift_down()) {
-                       double value1, value2, distance1, distance2;
+                       double value1, value2, distance1=-1, distance2=-1;
 
                        if(current->previous) {
                                int autogrouptype = current->previous->autos->autogrouptype;
@@ -4021,7 +4056,8 @@ int TrackCanvas::update_drag_floatauto(int cursor_x, int cursor_y)
                        float change = value - old_value;
                        current->adjust_to_new_coordinates(position, value);
                        update_ganged_autos(change, current->autos->track, current);
-                       show_message(current, 1,", %.2f", current->get_value());
+                       int color = GWindowGUI::auto_colors[current->autos->autoidx];
+                       show_message(current, color, ", %.2f", current->get_value());
                }
                break;
 
@@ -4040,7 +4076,8 @@ int TrackCanvas::update_drag_floatauto(int cursor_x, int cursor_y)
                                value * levered_position(position - current->position,
                                                         current->get_control_in_position()));
                        update_ganged_autos(0, current->autos->track, current);
-                       show_message(current, 1,", %.2f", current->get_control_in_value());
+                       int color = GWindowGUI::auto_colors[current->autos->autoidx];
+                       show_message(current, color, ", %.2f", current->get_control_in_value());
                }
                break; }
 
@@ -4054,7 +4091,8 @@ int TrackCanvas::update_drag_floatauto(int cursor_x, int cursor_y)
                                value * levered_position(position - current->position,
                                                         current->get_control_out_position()));
                        update_ganged_autos(0, current->autos->track, current);
-                       show_message(current, 1,", %.2f", current->get_control_out_value());
+                       int color = GWindowGUI::auto_colors[current->autos->autoidx];
+                       show_message(current, color, ", %.2f", current->get_control_out_value());
                }
                break; }
        }
@@ -4074,7 +4112,7 @@ int TrackCanvas::update_drag_toggleauto(int cursor_x, int cursor_y)
                result = 1;
                current->value = value;
                current->position = position;
-               show_message(current, 0,", %d", current->value);
+               show_message(current, -1, ", %d", current->value);
        }
 
        return result;
@@ -4091,7 +4129,7 @@ int TrackCanvas::update_drag_auto(int cursor_x, int cursor_y)
        {
                result = 1;
                current->position = position;
-               show_message(current, 0,"");
+               show_message(current, -1, "");
 
                double position_f = current->autos->track->from_units(current->position);
                double center_f = (mwindow->edl->local_session->get_selectionstart(1) +
@@ -4155,7 +4193,7 @@ int TrackCanvas::update_drag_pluginauto(int cursor_x, int cursor_y)
                mwindow->session->track_highlighted = track;
                result = 1;
                current->position = position;
-               show_message(current, 0,"");
+               show_message(current, -1, "");
 
                double position_f = current->autos->track->from_units(current->position);
                double center_f = (mwindow->edl->local_session->get_selectionstart(1) +
@@ -4666,6 +4704,9 @@ int TrackCanvas::button_release_event()
                }
        }
 
+       if( mwindow->edl->local_session->zoombar_showautocolor >= 0 )
+               mwindow->gui->zoombar->update_autozoom(-1);
+
        if (result)
                cursor_update(0);
 
@@ -4767,7 +4808,7 @@ int TrackCanvas::do_edit_handles(int cursor_x, int cursor_y, int button_press,
                        update_overlay = 1;
                }
        }
-       else if( result < 0 ) {
+       else if( result < 0 && !edit_result->silence() ) {
                mwindow->undo->update_undo_before();
                if( !shift_down() ) {
                        if( handle_result == 0 )
@@ -5007,11 +5048,8 @@ int TrackCanvas::do_edits(int cursor_x, int cursor_y, int button_press, int drag
                                                        mwindow->session->drag_group->remove_user();
                                                double start_position = 0;
                                                mwindow->session->drag_group =
-                                                       mwindow->selected_edits_to_clip(0, &start_position,
-                                                               &mwindow->session->drag_group_first_track,
-                                                               mwindow->edl->session->labels_follow_edits,
-                                                               mwindow->edl->session->autos_follow_edits,
-                                                               mwindow->edl->session->plugins_follow_edits);
+                                                       mwindow->edl->selected_edits_to_clip(0, &start_position,
+                                                               &mwindow->session->drag_group_first_track);
                                                if( mwindow->session->drag_group ) {
                                                        mwindow->session->current_operation = DRAG_GROUP;
                                                        mwindow->session->drag_group_position = start_position;
@@ -5027,25 +5065,29 @@ int TrackCanvas::do_edits(int cursor_x, int cursor_y, int button_press, int drag
        return result;
 }
 
-
+// returns -1=doesnt fit, 1=fits, 0=fits but overwrites
 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 ) continue;
+               if( !track->record ) 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;
-                       if( edit_intersects(track, src_edit, pos) ) return 0;
+                       if( !intersects && edit_intersects(track, src_edit, pos) )
+                               intersects = 1;
                }
                src = src->next;
        }
-       return !src ? 1 : 0;
+       return src ? -1 : !intersects ? 1 : 0;
 }
 
 int TrackCanvas::edit_intersects(Track *track, Edit *src_edit, double &pos)
 {
        if( pos < 0 ) { pos = 0;  return 1; }
+       int pane_no = pane->number;
+       int cur_pix = track->edl->get_position_cursorx(pos, pane_no);
        int64_t src_start = src_edit->startproject;
        int64_t src_end = src_start + src_edit->length;
        double new_start = src_edit->track->from_units(src_start) + pos;
@@ -5058,6 +5100,7 @@ int TrackCanvas::edit_intersects(Track *track, Edit *src_edit, double &pos)
                if( edit_start >= trk_end ) continue;
                int64_t edit_end = edit_start + edit->length;
                if( trk_start >= edit_end ) continue;
+
                int64_t lt_dist = labs(trk_end - edit_start);
                int64_t rt_dist = labs(edit_end - trk_start);
                int64_t position;
@@ -5075,7 +5118,10 @@ int TrackCanvas::edit_intersects(Track *track, Edit *src_edit, double &pos)
                        if( lt_dist > rt_dist )
                                position -= src_end;
                }
-               pos = edit->track->from_units(position);
+               double new_pos = edit->track->from_units(position);
+               int new_pix = track->edl->get_position_cursorx(new_pos, pane_no);
+               if( abs(new_pix-cur_pix) < HANDLE_W )
+                       pos = new_pos;
                return 1;
        }
        return 0;
@@ -5261,7 +5307,7 @@ int TrackCanvas::button_press_event()
                        gui->stop_transport("TrackCanvas::button_press_event");
                }
 
-               int update_overlay = 0, update_cursor = 0, rerender = 0;
+               int update_overlay = 0, update_cursor = 0, rerender = 0, update_message = 0;
 
                if(get_buttonpress() == WHEEL_UP) {
                        if(shift_down())
@@ -5304,6 +5350,7 @@ int TrackCanvas::button_press_event()
                                if( do_keyframes(cursor_x, cursor_y,
                                        0, get_buttonpress(), new_cursor,
                                        update_cursor, rerender) ) break;
+                               update_message = 1;
 // Test edit boundaries
                                if( do_edit_handles(cursor_x, cursor_y,
                                        1, rerender, update_overlay, new_cursor,
@@ -5339,6 +5386,7 @@ int TrackCanvas::button_press_event()
                                        update_overlay = 1;
                                        break;
                                }
+                               update_message = 1;
 // Test edit boundaries
                                if( do_edit_handles(cursor_x, cursor_y,
                                        1, rerender, update_overlay, new_cursor, update_cursor) ) break;
@@ -5369,9 +5417,12 @@ int TrackCanvas::button_press_event()
                        gui->update_patchbay();
                }
 
-               if( update_overlay ) {
+               if( update_message )
+                       gui->default_message();
+
+               if( update_overlay )
                        gui->draw_overlays(1);
-               }
+
                if( update_cursor < 0 ) {
 // double_click edit
                        gui->swindow->update_selection();
@@ -5448,11 +5499,11 @@ double TrackCanvas::time_visible()
 }
 
 
-void TrackCanvas::show_message(Auto *current, int show_curve_type, const char *fmt, ...)
+void TrackCanvas::show_message(Auto *current, int box_color, const char *fmt, ...)
 {
        char string[BCTEXTLEN];
        char *cp = string, *ep = cp + sizeof(string)-1;
-       if( show_curve_type ) {
+       if( box_color >= 0 ) {
                cp += snprintf(string, ep-cp, "%-8s ",
                        FloatAuto::curve_name(((FloatAuto*)current)->curve_mode));
        }
@@ -5468,7 +5519,7 @@ void TrackCanvas::show_message(Auto *current, int show_curve_type, const char *f
        va_start(ap, fmt);
        vsnprintf(cp, ep-cp, fmt, ap);
        va_end(ap);
-       gui->show_message(string);
+       gui->show_message(string, -1, box_color);
 }
 
 // Patchbay* TrackCanvas::get_patchbay()