X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Ftrackcanvas.C;h=8ff10d201436032da96830af9e896bf38e342c76;hb=b2eb290b3f6e5c233393017aa152e67c76243130;hp=ab558a5c705a8ed44cf705ad44fa6afc2fec3ca4;hpb=52c715cbb159b61590b95182eedbadac84bbdfe6;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/cinelerra/trackcanvas.C b/cinelerra-5.1/cinelerra/trackcanvas.C index ab558a5c..8ff10d20 100644 --- a/cinelerra-5.1/cinelerra/trackcanvas.C +++ b/cinelerra-5.1/cinelerra/trackcanvas.C @@ -27,6 +27,8 @@ #include "bctimer.h" #include "clip.h" #include "bccolors.h" +#include "cache.h" +#include "canvas.h" #include "cplayback.h" #include "cursors.h" #include "cwindowgui.h" @@ -67,6 +69,7 @@ #include "pluginset.h" #include "plugintoggles.h" #include "preferences.h" +#include "renderengine.h" #include "resourcepixmap.h" #include "resourcethread.h" #include "swindow.h" @@ -80,6 +83,7 @@ #include "transportque.h" #include "vframe.h" #include "vpatchgui.inc" +#include "vrender.h" #include "zoombar.h" #include @@ -1394,16 +1398,15 @@ void TrackCanvas::get_transition_coords(Edit *edit, int transition_w = 30, transition_h = 30; int has_titles = edit->track->show_titles(); int has_assets = edit->track->show_assets(); - int title_bg_h = mwindow->theme->get_image("title_bg_data")->get_h(); - int asset_h2 = resource_h() / 2; - - int iy = has_titles ? - ( has_assets ? title_bg_h + asset_h2 : title_bg_h/2 ) : - ( has_assets ? asset_h2 : 0) ; - int title_h2 = mwindow->theme->title_h / 2; - if( iy < title_h2 ) - iy = title_h2; - y += iy; + 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; x -= transition_w / 2; y -= transition_h / 2; @@ -1844,12 +1847,12 @@ void TrackCanvas::draw_transitions() 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; + int strip_x = x, edit_y = y; get_transition_coords(edit, x, y, w, h); - int strip_h = mwindow->theme->get_image("plugin_bg_data")->get_h(); - int track_y = edit->edits->track->y_pixel; - int strip_y = y - strip_h; - if( strip_y < track_y ) strip_y = track_y; + 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); @@ -2859,6 +2862,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; @@ -2868,15 +2872,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 = resource_h(); - center_pixel = track->y_pixel + + int y = track->y_pixel - mwindow->edl->local_session->track_start[pane->number]; - if( track->show_assets() ) - center_pixel += yscale / 2; - if( track->show_titles() ) - center_pixel += mwindow->theme->get_image("title_bg_data")->get_h(); - zoom_sample = mwindow->edl->local_session->zoom_sample; + 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); } @@ -3589,14 +3601,87 @@ void TrackCanvas::update_drag_handle() { mwindow->session->drag_position = new_position; gui->mainclock->update(new_position); - - timebar_position = new_position; gui->update_timebar(0); -// Que the CWindow. Doesn't do anything if selectionstart and selection end -// aren't changed. -// mwindow->cwindow->update(1, 0, 0); + + EDL *edl = new EDL; + edl->create_objects(); + edl->copy_all(mwindow->edl); + MainSession *session = mwindow->session; + int edit_mode = mwindow->edl->session->edit_handle_mode[session->drag_button]; + edl->modify_edithandles(session->drag_start, + session->drag_position, + session->drag_handle, + edit_mode, + edl->session->labels_follow_edits, + edl->session->plugins_follow_edits, + edl->session->autos_follow_edits); + double position = edit_mode != MOVE_NO_EDITS && + ( session->drag_handle || edit_mode == MOVE_ONE_EDIT ) ? + session->drag_position : session->drag_start; + 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); + edl->remove_user(); + } +} + +int TrackCanvas::render_handle_frame(EDL *edl, int64_t pos, int mode) +{ + int result = 0; + int64_t left = pos-1; + if( left < 0 ) left = 0; + switch( mode ) { + case 0: { + VFrame vlt(edl->get_w(), edl->get_h(), edl->session->color_model); + VFrame vrt(edl->get_w(), edl->get_h(), edl->session->color_model); + TransportCommand command; + command.command = CURRENT_FRAME; + command.get_edl()->copy_all((EDL *)edl); + command.change_type = CHANGE_ALL; + command.realtime = 0; + Preferences *preferences = mwindow->preferences; + RenderEngine *render_engine = new RenderEngine(0, preferences, 0, 0); + 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) && + !vrender->process_buffer(&vrt, pos , 0) ? 0 : 1; + delete render_engine; + 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; + 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->flash(1); + canvas->unlock_canvas(); + mwindow->cwindow->gui->unlock_window(); + break; } + case 1: + case 2: { + 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); + mwindow->cwindow->playback_engine->refresh_frame(CHANGE_EDL, edl, 0); + break; } } + return result; } int TrackCanvas::update_drag_edit() @@ -4368,8 +4453,6 @@ 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->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); @@ -4379,7 +4462,8 @@ int TrackCanvas::do_edit_handles(int cursor_x, int cursor_y, int button_press, if( cursor_x < edit_x + HANDLE_W ) { edit_result = edit; handle_result = 0; - if( cursor_y >= edit_y+edit_h - HANDLE_W ) { + if( cursor_y >= edit_y+edit_h - HANDLE_W && + track->show_assets() ) { new_cursor = DOWNLEFT_RESIZE; if( button_press == LEFT_BUTTON ) result = -1; @@ -4390,7 +4474,8 @@ int TrackCanvas::do_edit_handles(int cursor_x, int cursor_y, int button_press, else if( cursor_x >= edit_x + edit_w - HANDLE_W ) { edit_result = edit; handle_result = 1; - if( cursor_y >= edit_y+edit_h - HANDLE_W ) { + if( cursor_y >= edit_y+edit_h - HANDLE_W && + track->show_assets() ) { new_cursor = DOWNRIGHT_RESIZE; if( button_press == LEFT_BUTTON ) result = -1; @@ -4429,7 +4514,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 ) { mwindow->undo->update_undo_before(); if( !shift_down() ) { if( handle_result == 0 ) @@ -4579,8 +4664,6 @@ 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->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);