X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Ftrackcanvas.C;h=fa52b9c08e8d1bc0be19a82f333a7d88c6ad857f;hb=9782ed720c4e992ed0427de68c6646720c9b44e4;hp=f89bdab5a744522d46b645d6b4c5f7ff85691a3e;hpb=0df48ad2d876409c5beeae2e21933a728ea76c33;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/cinelerra/trackcanvas.C b/cinelerra-5.1/cinelerra/trackcanvas.C index f89bdab5..fa52b9c0 100644 --- a/cinelerra-5.1/cinelerra/trackcanvas.C +++ b/cinelerra-5.1/cinelerra/trackcanvas.C @@ -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; @@ -1680,9 +1682,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; @@ -1691,10 +1700,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); } @@ -1889,6 +1898,8 @@ void TrackCanvas::draw_hard_edges() 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; @@ -2772,6 +2783,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) \ @@ -2804,45 +2833,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 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, @@ -3873,13 +3902,17 @@ 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; - 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); mwindow->cwindow->gui->unlock_window(); break; } @@ -5045,25 +5078,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; @@ -5076,6 +5113,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; @@ -5093,7 +5131,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;