From: Good Guy Date: Fri, 3 Aug 2018 16:34:59 +0000 (-0600) Subject: proxy toggle fix, rework preview range setup X-Git-Url: https://git.cinelerra-gg.org/git/?a=commitdiff_plain;h=376dbcef804a17c74f0db851064e7947a3d0a5f5;p=goodguy%2Fhistory.git proxy toggle fix, rework preview range setup --- diff --git a/cinelerra-5.1/cinelerra/ctimebar.C b/cinelerra-5.1/cinelerra/ctimebar.C index b22b4db7..6929cc12 100644 --- a/cinelerra-5.1/cinelerra/ctimebar.C +++ b/cinelerra-5.1/cinelerra/ctimebar.C @@ -64,16 +64,18 @@ void CTimeBar::draw_time() double CTimeBar::pixel_to_position(int pixel) { - double start = 0, length = 0; + double start = 0, end = get_edl_length(); EDL *edl = get_edl(); if( edl ) { - start = edl->local_session->preview_start; - if( start >= 0 ) - length = edl->local_session->preview_end - start; + double preview_start = edl->local_session->preview_start; + double preview_end = edl->local_session->preview_end; + if( preview_end >= 0 || preview_start > 0 ) + start = preview_start; + if( preview_end >= 0 && preview_end < end ) + end = preview_end; } - if( length <= 0 ) - length = get_edl_length(); - return start + (double)pixel * length / get_w(); + if( start > end ) start = end; + return start + (double)pixel * (end - start) / get_w(); } diff --git a/cinelerra-5.1/cinelerra/cwindowgui.C b/cinelerra-5.1/cinelerra/cwindowgui.C index b387bfe1..ecb58bee 100644 --- a/cinelerra-5.1/cinelerra/cwindowgui.C +++ b/cinelerra-5.1/cinelerra/cwindowgui.C @@ -787,7 +787,7 @@ CWrapper_cut(next_edit) void CWindowEditing::to_clip() { - mwindow->to_clip(mwindow->edl, _("composer window: "), 0); + mwindow->to_clip(mwindow->edl, _("composer window: "), 0); } @@ -891,20 +891,9 @@ int CWindowSlider::handle_event() void CWindowSlider::set_position() { double new_length = mwindow->edl->tracks->total_length(); -// if(mwindow->edl->local_session->preview_end <= 0 || -// mwindow->edl->local_session->preview_end > new_length) -// mwindow->edl->local_session->preview_end = new_length; -// if(mwindow->edl->local_session->preview_start > -// mwindow->edl->local_session->preview_end) -// mwindow->edl->local_session->preview_start = 0; - - update(mwindow->theme->cslider_w, mwindow->edl->local_session->get_selectionstart(1), - 0, - new_length); -// mwindow->edl->local_session->preview_start, -// mwindow->edl->local_session->preview_end); + 0, new_length); } @@ -2567,7 +2556,7 @@ int CWindowCanvas::test_crop(int button_press, int &redraw) redraw = 1; } } - else + else // Translate all 4 points if(gui->current_operation == CWINDOW_CROP && gui->crop_translate) { diff --git a/cinelerra-5.1/cinelerra/edl.C b/cinelerra-5.1/cinelerra/edl.C index cbde2640..a114f3c9 100644 --- a/cinelerra-5.1/cinelerra/edl.C +++ b/cinelerra-5.1/cinelerra/edl.C @@ -1145,13 +1145,15 @@ void EDL::set_index_file(Indexable *indexable) void EDL::optimize() { //printf("EDL::optimize 1\n"); - if( local_session->preview_start < 0 ) local_session->preview_start = 0; double length = tracks->total_length(); - if( local_session->preview_end > length ) local_session->preview_end = length; - if( local_session->preview_start >= local_session->preview_end ) { - local_session->preview_start = 0; - local_session->preview_end = length; - } + double preview_start = local_session->preview_start; + double preview_end = local_session->preview_end; + if( preview_end < 0 || preview_end > length ) + preview_end = length; + if( preview_start == 0 && preview_end >= length ) + local_session->preview_end = -1; + if( preview_start > preview_end ) + local_session->preview_start = preview_end; for( Track *current=tracks->first; current; current=NEXT ) current->optimize(); } diff --git a/cinelerra-5.1/cinelerra/localsession.C b/cinelerra-5.1/cinelerra/localsession.C index 8e691310..890ff0ad 100644 --- a/cinelerra-5.1/cinelerra/localsession.C +++ b/cinelerra-5.1/cinelerra/localsession.C @@ -69,7 +69,7 @@ LocalSession::LocalSession(EDL *edl) loop_start = loop_end = 0; playback_start = -1; playback_end = 0; - preview_start = preview_end = 0; + preview_start = 0; preview_end = -1; zoom_sample = DEFAULT_ZOOM_TIME; zoom_y = 0; zoom_track = 0; @@ -189,10 +189,9 @@ void LocalSession::save_xml(FileXML *file, double start) file->tag.set_property("ZOOM_TRACK", zoom_track); double preview_start = this->preview_start - start; - if(preview_start < 0) preview_start = 0; + if( preview_start < 0 ) preview_start = 0; double preview_end = this->preview_end - start; - if(preview_end < 0) preview_end = 0; - + if( preview_end < preview_start ) preview_end = -1; file->tag.set_property("PREVIEW_START", preview_start); file->tag.set_property("PREVIEW_END", preview_end); file->tag.set_property("FLOATAUTO_TYPE", floatauto_type); diff --git a/cinelerra-5.1/cinelerra/mwindow.C b/cinelerra-5.1/cinelerra/mwindow.C index b0f829bb..f4a850b9 100644 --- a/cinelerra-5.1/cinelerra/mwindow.C +++ b/cinelerra-5.1/cinelerra/mwindow.C @@ -2175,7 +2175,7 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); edl->session->proxy_auto_scale = 0; edl->session->proxy_beep = 0; edl->local_session->preview_start = 0; - edl->local_session->preview_end = 0; + edl->local_session->preview_end = -1; edl->local_session->loop_playback = 0; edl->local_session->set_selectionstart(0); edl->local_session->set_selectionend(0); diff --git a/cinelerra-5.1/cinelerra/mwindowgui.C b/cinelerra-5.1/cinelerra/mwindowgui.C index baea64a8..66f11871 100644 --- a/cinelerra-5.1/cinelerra/mwindowgui.C +++ b/cinelerra-5.1/cinelerra/mwindowgui.C @@ -666,6 +666,8 @@ void MWindowGUI::update_patchbay() void MWindowGUI::update_proxy_toggle() { + int value = mwindow->edl->session->proxy_scale == 1 ? 1 : 0; + proxy_toggle->set_value(value); if( mwindow->edl->session->proxy_scale == 1 && mwindow->edl->session->proxy_disabled_scale == 1 ) proxy_toggle->hide(); diff --git a/cinelerra-5.1/cinelerra/timebar.C b/cinelerra-5.1/cinelerra/timebar.C index 7d25fb2c..8d8bfc7c 100644 --- a/cinelerra-5.1/cinelerra/timebar.C +++ b/cinelerra-5.1/cinelerra/timebar.C @@ -527,32 +527,19 @@ double TimeBar::get_edl_length() int TimeBar::get_preview_pixels(int &x1, int &x2) { - x1 = 0; - x2 = 0; - + x1 = 0; x2 = get_w(); get_edl_length(); - - if( get_edl() ) { - if( !EQUIV(edl_length, 0) ) { - if( get_edl()->local_session->preview_end <= 0 || - get_edl()->local_session->preview_end > edl_length ) - get_edl()->local_session->preview_end = edl_length; - if( get_edl()->local_session->preview_start > - get_edl()->local_session->preview_end ) - get_edl()->local_session->preview_start = 0; - x1 = (int)(get_edl()->local_session->preview_start / time_per_pixel); - x2 = (int)(get_edl()->local_session->preview_end / time_per_pixel); - } - else { - x1 = 0; - x2 = get_w(); + EDL *edl = get_edl(); + if( edl && !EQUIV(edl_length, 0) ) { + double preview_start = edl->local_session->preview_start; + double preview_end = edl->local_session->preview_end; + if( preview_end < 0 || preview_end > edl_length ) + preview_end = edl_length; + if( preview_end >= preview_start ) { + x1 = (int)(preview_start / time_per_pixel); + x2 = (int)(preview_end / time_per_pixel); } } -// printf("TimeBar::get_preview_pixels %f %f %d %d\n", -// get_edl()->local_session->preview_start, -// get_edl()->local_session->preview_end, -// x1, -// x2); return 0; } @@ -586,6 +573,8 @@ int TimeBar::test_preview(int buttonpress) if( buttonpress ) { current_operation = TIMEBAR_DRAG_RIGHT; start_position = get_edl()->local_session->preview_end; + if( start_position < 0 || start_position > edl_length ) + start_position = edl_length; start_cursor_x = x; } else if( get_cursor() != RIGHT_CURSOR ) @@ -599,6 +588,8 @@ int TimeBar::test_preview(int buttonpress) current_operation = TIMEBAR_DRAG_CENTER; starting_start_position = get_edl()->local_session->preview_start; starting_end_position = get_edl()->local_session->preview_end; + if( starting_end_position < 0 || starting_end_position > edl_length ) + starting_end_position = edl_length; start_cursor_x = x; } if( get_cursor() != HSEPARATE_CURSOR ) @@ -617,26 +608,30 @@ int TimeBar::test_preview(int buttonpress) int TimeBar::move_preview(int &redraw) { int result = 0, x = get_relative_cursor_x(); - - if( current_operation == TIMEBAR_DRAG_LEFT ) { + switch( current_operation ) { + case TIMEBAR_DRAG_LEFT: { get_edl()->local_session->preview_start = start_position + time_per_pixel * (x - start_cursor_x); - CLAMP(get_edl()->local_session->preview_start, - 0, - get_edl()->local_session->preview_end); + double preview_end = get_edl()->local_session->preview_end; + if( preview_end < 0 || preview_end > edl_length ) + preview_end = get_edl()->local_session->preview_end = edl_length; + CLAMP(get_edl()->local_session->preview_start, 0, preview_end); result = 1; - } - else - if( current_operation == TIMEBAR_DRAG_RIGHT ) { - get_edl()->local_session->preview_end = + break; } + case TIMEBAR_DRAG_RIGHT: { + double preview_end = get_edl()->local_session->preview_end = start_position + time_per_pixel * (x - start_cursor_x); - CLAMP(get_edl()->local_session->preview_end, - get_edl()->local_session->preview_start, - edl_length); + double preview_start = get_edl()->local_session->preview_start; + if( preview_end >= edl_length && !preview_start ) { + get_edl()->local_session->preview_end = -1; + if( preview_start > preview_end ) + preview_start = get_edl()->local_session->preview_start = preview_end; + } + else + CLAMP(get_edl()->local_session->preview_end, preview_start, edl_length); result = 1; - } - else - if( current_operation == TIMEBAR_DRAG_CENTER ) { + break; } + case TIMEBAR_DRAG_CENTER: { double dt = time_per_pixel * (x - start_cursor_x); get_edl()->local_session->preview_start = starting_start_position + dt; get_edl()->local_session->preview_end = starting_end_position + dt; @@ -650,6 +645,7 @@ int TimeBar::move_preview(int &redraw) get_edl()->local_session->preview_end = edl_length; } result = 1; + break; } } //printf("TimeBar::move_preview %d %d\n", __LINE__, current_operation); diff --git a/cinelerra-5.1/cinelerra/vtimebar.C b/cinelerra-5.1/cinelerra/vtimebar.C index 4c9ca74e..2855f161 100644 --- a/cinelerra-5.1/cinelerra/vtimebar.C +++ b/cinelerra-5.1/cinelerra/vtimebar.C @@ -103,19 +103,21 @@ void VTimeBar::select_label(double position) double VTimeBar::pixel_to_position(int pixel) { - double start = 0, length = 0; + double start = 0, end = get_edl_length(); EDL *edl = get_edl(); - if(edl) - { - start = edl->local_session->preview_start; - if(start >= 0) - length = edl->local_session->preview_end - start; + if( edl ) { + double preview_start = edl->local_session->preview_start; + double preview_end = edl->local_session->preview_end; + if( preview_end >= 0 || preview_start > 0 ) + start = preview_start; + if( preview_end >= 0 && preview_end < end ) + end = preview_end; } - if(length <= 0) - length = get_edl_length(); - return start + (double)pixel * length / get_w(); + if( start > end ) start = end; + return start + (double)pixel * (end - start) / get_w(); } + void VTimeBar::update_cursor() { int rx = get_relative_cursor_x(); diff --git a/cinelerra-5.1/cinelerra/vwindow.C b/cinelerra-5.1/cinelerra/vwindow.C index 5a63955a..b6dc23c6 100644 --- a/cinelerra-5.1/cinelerra/vwindow.C +++ b/cinelerra-5.1/cinelerra/vwindow.C @@ -256,7 +256,8 @@ void VWindow::change_source(EDL *edl) mwindow->edl->append_vwindow_edl(edl, 1); this->edl = edl; this->edl->Garbage::add_user(); - + edl->local_session->preview_start = 0; + edl->local_session->preview_end = -1; // mwindow->edl->vwindow_edl = edl; // in order not to later delete edl if it is shared // edl->Garbage::add_user();