X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Ftrackcanvas.C;h=0e42ed89109de1d18108197e4d2877d4f711f46b;hb=a6e4ede4b9a11b56b3aece044ff2a1546630ca38;hp=a4faec2b9de802c3f6e168b833bebe443740bea2;hpb=b5bfe3e40a7255ae60a21d885587ada6e145e3d5;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/cinelerra/trackcanvas.C b/cinelerra-5.1/cinelerra/trackcanvas.C index a4faec2b..0e42ed89 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; @@ -1011,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); @@ -1039,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; } @@ -1295,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) { @@ -1432,11 +1430,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; @@ -1904,7 +1902,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 ) { @@ -2386,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; @@ -2399,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); } @@ -2453,23 +2448,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 +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); @@ -2556,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; @@ -2566,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); @@ -2643,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; @@ -2652,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); @@ -2781,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) \ @@ -2813,45 +2819,47 @@ 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++) - { + if( autogrouptype == AUTOGROUPTYPE_SPEED && automation_range < SPEED_MIN ) + automation_range = SPEED_MIN; + 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, @@ -2870,6 +2878,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); @@ -2932,7 +2942,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); @@ -2941,6 +2951,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); } } @@ -3064,12 +3075,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; @@ -3117,6 +3128,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; @@ -3570,7 +3583,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;