X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Ftrackcanvas.C;h=4de073e34a281231075b3e7c69a71f5aca5db171;hb=5c1aff2fd123b65be6e51ca7652185e14ddaf168;hp=2edb89bea19dd64f2d3f42e918e36059739b3975;hpb=bd40a11178ed791d8c163877d3c28e5045148c62;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/cinelerra/trackcanvas.C b/cinelerra-5.1/cinelerra/trackcanvas.C index 2edb89be..4de073e3 100644 --- a/cinelerra-5.1/cinelerra/trackcanvas.C +++ b/cinelerra-5.1/cinelerra/trackcanvas.C @@ -708,9 +708,6 @@ void TrackCanvas::draw_resources(int mode, if(debug) PRINT_TRACE - if(!mwindow->edl->session->show_assets) return; - - // can't stop thread here, because this is called for every pane // if(mode != IGNORE_THREAD && !indexes_only) // gui->resource_thread->stop_draw(!indexes_only); @@ -800,24 +797,29 @@ void TrackCanvas::draw_resources(int mode, if(pixmap_w && pixmap_h) { // Create pixmap if it doesn't exist - ResourcePixmap* pixmap = create_pixmap(edit, - edit_x, - pixmap_x, - pixmap_w, - pixmap_h); + ResourcePixmap* pixmap = create_pixmap(edit, edit_x, + pixmap_x, pixmap_w, pixmap_h); // Resize it if it's bigger - if(pixmap_w > pixmap->pixmap_w || - pixmap_h > pixmap->pixmap_h) + if( pixmap_w > pixmap->pixmap_w || + pixmap_h > pixmap->pixmap_h) pixmap->resize(pixmap_w, pixmap_h); - pixmap->draw_data(this, - edit, - edit_x, - edit_w, - pixmap_x, - pixmap_w, - pixmap_h, - mode, - indexes_only); + pixmap->update_settings(edit, edit_x, edit_w, + pixmap_x, pixmap_w, pixmap_h); +// Draw data + if( current->show_assets() ) + pixmap->draw_data(this, + edit, edit_x, edit_w, + pixmap_x, pixmap_w, pixmap_h, + mode, indexes_only); + else { + set_bg_color(BLACK); + clear_box(0,0, pixmap_w,pixmap_h, pixmap); + } +// Draw title + if( current->show_titles() ) + pixmap->draw_title(this, + edit, edit_x, edit_w, + pixmap_x, pixmap_w); // Resize it if it's smaller if(pixmap_w < pixmap->pixmap_w || pixmap_h < pixmap->pixmap_h) @@ -958,27 +960,22 @@ void TrackCanvas::get_pixmap_size(Edit *edit, // } pixmap_h = mwindow->edl->local_session->zoom_track; - if(mwindow->edl->session->show_titles) pixmap_h += mwindow->theme->get_image("title_bg_data")->get_h(); + Track *track = edit->edits->track; + 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); } void TrackCanvas::edit_dimensions(Edit *edit, - int64_t &x, - int64_t &y, - int64_t &w, - int64_t &h) + int64_t &x, int64_t &y, int64_t &w, int64_t &h) { -// w = Units::round(edit->track->from_units(edit->length) * -// mwindow->edl->session->sample_rate / -// mwindow->edl->local_session->zoom_sample); - - h = resource_h(); - x = Units::round(edit->track->from_units(edit->startproject) * mwindow->edl->session->sample_rate / mwindow->edl->local_session->zoom_sample - mwindow->edl->local_session->view_start[pane->number]); + y = edit->edits->track->y_pixel - mwindow->edl->local_session->track_start[pane->number]; + // Method for calculating w so when edits are together we never get off by one error due to rounding int64_t x_next = Units::round(edit->track->from_units(edit->startproject + edit->length) * mwindow->edl->session->sample_rate / @@ -986,10 +983,12 @@ void TrackCanvas::edit_dimensions(Edit *edit, mwindow->edl->local_session->view_start[pane->number]); w = x_next - x; - y = edit->edits->track->y_pixel - mwindow->edl->local_session->track_start[pane->number]; - - if(mwindow->edl->session->show_titles) - h += mwindow->theme->get_image("title_bg_data")->get_h(); + int edit_h = 0; + 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(); + h = edit_h; } void TrackCanvas::track_dimensions(Track *track, int64_t &x, int64_t &y, int64_t &w, int64_t &h) @@ -1239,13 +1238,14 @@ void TrackCanvas::plugin_dimensions(Plugin *plugin, int64_t &x, int64_t &y, int6 w = Units::round(plugin->track->from_units(plugin->length) * mwindow->edl->session->sample_rate / mwindow->edl->local_session->zoom_sample); - y = plugin->track->y_pixel - - mwindow->edl->local_session->track_start[pane->number] + - mwindow->edl->local_session->zoom_track + - plugin->plugin_set->get_number() * - mwindow->theme->get_image("plugin_bg_data")->get_h(); - if(mwindow->edl->session->show_titles) + y = plugin->track->y_pixel + - mwindow->edl->local_session->track_start[pane->number]; + 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->plugin_set->get_number() * + mwindow->theme->get_image("plugin_bg_data")->get_h(); h = mwindow->theme->get_image("plugin_bg_data")->get_h(); } @@ -1378,42 +1378,36 @@ void TrackCanvas::get_handle_coords(Edit *edit, int64_t &x, int64_t &y, int64_t edit_dimensions(edit, x, y, w, h); - if(mwindow->edl->session->show_titles) - { + if( edit->track->show_titles() ) y += mwindow->theme->get_image("title_bg_data")->get_h(); - } - else - { - y = 0; - } if(side == EDIT_OUT) - { x += w - handle_w; - } h = handle_h; w = handle_w; } -void TrackCanvas::get_transition_coords(int64_t &x, int64_t &y, int64_t &w, int64_t &h) +void TrackCanvas::get_transition_coords(Edit *edit, + int64_t &x, int64_t &y, int64_t &w, int64_t &h) { -//printf("TrackCanvas::get_transition_coords 1\n"); -// int transition_w = mwindow->theme->transitionhandle_data[0]->get_w(); -// int transition_h = mwindow->theme->transitionhandle_data[0]->get_h(); - int transition_w = 30; - int transition_h = 30; -//printf("TrackCanvas::get_transition_coords 1\n"); - - if(mwindow->edl->session->show_titles) - y += mwindow->theme->get_image("title_bg_data")->get_h(); -//printf("TrackCanvas::get_transition_coords 2\n"); + int transition_w = 30, transition_h = 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; + double dy = has_titles ? + ( has_assets ? title_bg_h + asset_h/2 : title_bg_h/2 ) : + ( has_assets ? asset_h/2 : 0) ; + double title_h = mwindow->theme->title_h; + if( dy < title_h / 2 ) { ys = title_h; dy = ys / 2; } + y += dy; - y += (h - mwindow->theme->get_image("title_bg_data")->get_h()) / 2 - transition_h / 2; x -= transition_w / 2; - - h = transition_h; + y -= transition_h / 2; w = transition_w; + h = transition_h; } void TrackCanvas::draw_highlighting() @@ -1428,21 +1422,18 @@ void TrackCanvas::draw_highlighting() //printf("TrackCanvas::draw_highlighting 1 %p %p\n", // mwindow->session->track_highlighted, mwindow->session->edit_highlighted); if(mwindow->session->edit_highlighted) { -//printf("TrackCanvas::draw_highlighting 2\n"); if((mwindow->session->current_operation == DRAG_ATRANSITION && mwindow->session->track_highlighted->data_type == TRACK_AUDIO) || (mwindow->session->current_operation == DRAG_VTRANSITION && mwindow->session->track_highlighted->data_type == TRACK_VIDEO)) { -//printf("TrackCanvas::draw_highlighting 2\n"); - edit_dimensions(mwindow->session->edit_highlighted, x, y, w, h); -//printf("TrackCanvas::draw_highlighting 2\n"); - + edit_dimensions(mwindow->session->edit_highlighted, + x, y, w, h); if(MWindowGUI::visible(x, x + w, 0, get_w()) && MWindowGUI::visible(y, y + h, 0, get_h())) { draw_box = 1; - get_transition_coords(x, y, w, h); + get_transition_coords(mwindow->session->edit_highlighted, + x, y, w, h); } -//printf("TrackCanvas::draw_highlighting 3\n"); } } break; @@ -1610,8 +1601,6 @@ void TrackCanvas::draw_plugins() int current_show = 0; int current_preset = 0; -// if(!mwindow->edl->session->show_assets) goto done; - for(int i = 0; i < plugin_on_toggles.total; i++) plugin_on_toggles.values[i]->in_use = 0; for(int i = 0; i < plugin_show_toggles.total; i++) @@ -1787,14 +1776,19 @@ void TrackCanvas::draw_hard_edges() { int64_t x, y, w, h; -// if(!mwindow->edl->session->show_assets) return; - 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); set_color(GREEN); - set_opaque(); int y1 = y+h-1; + 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(); + if( y1 == y ) + y1 += mwindow->theme->title_h; if( edit->hard_left ) { ArrayList xpt, ypt; xpt.append(x); ypt.append(y1); @@ -1843,38 +1837,38 @@ void TrackCanvas::draw_transitions() { int64_t x, y, w, h; -// if(!mwindow->edl->session->show_assets) return; - for(Track *track = mwindow->edl->tracks->first; track; track = track->next) { + if( !track->show_transitions() ) continue; + for(Edit *edit = track->edits->first; edit; edit = edit->next) { if(!edit->transition) continue; edit_dimensions(edit, x, y, w, h); - int strip_x = x, strip_y = y; - if(mwindow->edl->session->show_titles) - strip_y += mwindow->theme->get_image("title_bg_data")->get_h(); - get_transition_coords(x, y, w, h); + int strip_x = x, edit_y = y; + get_transition_coords(edit, x, y, w, h); + int strip_y = y - mwindow->theme->get_image("plugin_bg_data")->get_h(); + if( track->show_assets() && track->show_titles() ) + edit_y += mwindow->theme->get_image("title_bg_data")->get_h(); + if( strip_y < edit_y ) strip_y = edit_y; + int strip_w = Units::round(edit->track->from_units(edit->transition->length) * mwindow->edl->session->sample_rate / mwindow->edl->local_session->zoom_sample); if( MWindowGUI::visible(x, x + w, 0, get_w()) && - MWindowGUI::visible(y, y + h, 0, get_h()) ) - { + MWindowGUI::visible(y, y + h, 0, get_h()) ) { PluginServer *server = mwindow->scan_plugindb(edit->transition->title, track->data_type); if( !server ) continue; VFrame *picon = server->get_picon(); if( !picon ) continue; - draw_vframe(picon, x, y, w, h, 0, 0, picon->get_w(), picon->get_h()); + int picon_w = picon->get_w(), picon_h = picon->get_h(); + int track_h = edit->track->vertical_span(mwindow->theme); + if( picon_h > track_h ) picon_h = track_h; + draw_vframe(picon, x, y, w, h, 0, 0, picon_w, picon_h); } if(MWindowGUI::visible(strip_x, strip_x + strip_w, 0, get_w()) && - MWindowGUI::visible(strip_y, strip_y + h, 0, get_h())) - { + MWindowGUI::visible(strip_y, strip_y + h, 0, get_h())) { int x = strip_x, w = strip_w; - if(x < 0) - { - w -= -x; - x = 0; - } - if(w + x > get_w()) w -= (w + x) - get_w(); + if( x < 0 ) { w -= -x; x = 0; } + if( w + x > get_w() ) w -= (w + x) - get_w(); draw_3segmenth( x, strip_y, w, strip_x, strip_w, mwindow->theme->get_image("plugin_bg_data"), 0); @@ -2127,9 +2121,7 @@ int TrackCanvas::do_keyframes(int cursor_x, } } - if(!result && - session->auto_conf->plugins /* && - mwindow->edl->session->show_assets */) { + if(!result && session->auto_conf->plugins) { Plugin *plugin; KeyFrame *keyframe; result = do_plugin_autos(track, cursor_x, cursor_y, @@ -2866,6 +2858,7 @@ void TrackCanvas::calculate_viewport(Track *track, double &zoom_sample, double &zoom_units) { + view_start = (double)mwindow->edl->local_session->view_start[pane->number] * mwindow->edl->local_session->zoom_sample / mwindow->edl->session->sample_rate; @@ -2875,16 +2868,23 @@ void TrackCanvas::calculate_viewport(Track *track, mwindow->edl->local_session->zoom_sample / mwindow->edl->session->sample_rate; unit_end = track->to_doubleunits(view_end); - yscale = mwindow->edl->local_session->zoom_track; -//printf("TrackCanvas::calculate_viewport yscale=%.0f\n", yscale); - center_pixel = (int)(track->y_pixel - - mwindow->edl->local_session->track_start[pane->number] + - yscale / 2) + - (mwindow->edl->session->show_titles ? - mwindow->theme->get_image("title_bg_data")->get_h() : - 0); - zoom_sample = mwindow->edl->local_session->zoom_sample; + int y = track->y_pixel + - mwindow->edl->local_session->track_start[pane->number]; + 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 dy = has_titles ? + ( has_assets ? title_bg_h + asset_h/2 : title_bg_h/2) : + ( has_assets ? asset_h/2 : 0) ; + if( dy < title_h/2 ) { ys = title_h; dy = ys / 2; } + yscale = ys; + center_pixel = y + dy; + + zoom_sample = mwindow->edl->local_session->zoom_sample; zoom_units = track->to_doubleunits(zoom_sample / mwindow->edl->session->sample_rate); } @@ -3375,11 +3375,13 @@ int TrackCanvas::do_plugin_autos(Track *track, int cursor_x, int cursor_y, for(int i = 0; i < track->plugin_set.total && !result; i++) { PluginSet *plugin_set = track->plugin_set.values[i]; - int center_pixel = (int)(track->y_pixel - - mwindow->edl->local_session->track_start[pane->number] + - mwindow->edl->local_session->zoom_track + - (i + 0.5) * mwindow->theme->get_image("plugin_bg_data")->get_h() + - (mwindow->edl->session->show_titles ? mwindow->theme->get_image("title_bg_data")->get_h() : 0)); + int center_pixel = track->y_pixel - + mwindow->edl->local_session->track_start[pane->number]; + 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 += (i + 0.5) * mwindow->theme->get_image("plugin_bg_data")->get_h(); for(Plugin *plugin = (Plugin*)plugin_set->first; plugin && !result; @@ -3491,7 +3493,7 @@ void TrackCanvas::draw_overlays() draw_inout_points(); // Transitions - if(mwindow->edl->session->auto_conf->transitions) draw_transitions(); + draw_transitions(); // Plugins draw_plugins(); @@ -4373,9 +4375,9 @@ int TrackCanvas::do_edit_handles(int cursor_x, int cursor_y, int button_press, int handle_result = -1; int result = 0; - if( !mwindow->edl->session->show_assets ) return 0; - for( Track *track=mwindow->edl->tracks->first; track && !result; track=track->next) { + if( !track->show_assets() ) 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); @@ -4494,8 +4496,6 @@ int TrackCanvas::do_plugin_handles(int cursor_x, int handle_result = 0; int result = 0; -// if(!mwindow->edl->session->show_assets) return 0; - for(Track *track = mwindow->edl->tracks->first; track && !result; track = track->next) { @@ -4562,8 +4562,6 @@ int TrackCanvas::do_tracks(int cursor_x, int cursor_y, int button_press) { int result = 0; -// if(!mwindow->edl->session->show_assets) return 0; - for(Track *track = mwindow->edl->tracks->first; track && !result; track = track->next) { @@ -4588,9 +4586,8 @@ int TrackCanvas::do_edits(int cursor_x, int cursor_y, int button_press, int drag { int result = 0; - if(!mwindow->edl->session->show_assets) return 0; - for(Track *track = mwindow->edl->tracks->first; track && !result; track = track->next) { + if( !track->show_assets() ) continue; for(Edit *edit = track->edits->first; edit && !result; edit = edit->next) { int64_t edit_x, edit_y, edit_w, edit_h; @@ -4677,10 +4674,6 @@ int TrackCanvas::do_plugins(int cursor_x, int cursor_y, int drag_start, int64_t x, y, w, h; Track *track = 0; - -// if(!mwindow->edl->session->show_assets) return 0; - - for(track = mwindow->edl->tracks->first; track && !done; track = track->next) { if(!track->expand_view) continue; @@ -4789,15 +4782,14 @@ int TrackCanvas::do_transitions(int cursor_x, int cursor_y, int result = 0; int64_t x, y, w, h; - if(/* !mwindow->edl->session->show_assets || */ - !mwindow->edl->session->auto_conf->transitions) return 0; for( Track *track = mwindow->edl->tracks->first; track && !result; track = track->next ) { + if( !track->show_transitions() ) continue; for( Edit *edit = track->edits->first; edit; edit = edit->next ) { if( edit->transition ) { edit_dimensions(edit, x, y, w, h); - get_transition_coords(x, y, w, h); + get_transition_coords(edit, x, y, w, h); if( MWindowGUI::visible(x, x + w, 0, get_w()) && MWindowGUI::visible(y, y + h, 0, get_h()) ) {