proxy toggle fix, rework preview range setup
authorGood Guy <[email protected]>
Fri, 3 Aug 2018 16:34:59 +0000 (10:34 -0600)
committerGood Guy <[email protected]>
Fri, 3 Aug 2018 16:34:59 +0000 (10:34 -0600)
cinelerra-5.1/cinelerra/ctimebar.C
cinelerra-5.1/cinelerra/cwindowgui.C
cinelerra-5.1/cinelerra/edl.C
cinelerra-5.1/cinelerra/localsession.C
cinelerra-5.1/cinelerra/mwindow.C
cinelerra-5.1/cinelerra/mwindowgui.C
cinelerra-5.1/cinelerra/timebar.C
cinelerra-5.1/cinelerra/vtimebar.C
cinelerra-5.1/cinelerra/vwindow.C

index b22b4db7ffcf06bfeac8f0cba4eb319c4119e0c5..6929cc12104de8f652c1711c2b4969f7cd1277a3 100644 (file)
@@ -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();
 }
 
 
index b387bfe19a9e0ec146688b60be2e893f622de4f9..ecb58bee58ae8604fdb05d5f9962a582b124b08d 100644 (file)
@@ -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)
        {
index cbde2640730df60673f6099fcd9e79f13050e544..a114f3c995ec3df962b516caf2fe19f216ac7408 100644 (file)
@@ -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();
 }
index 8e691310ba06040a93e35cb5bf9300aa6b514aa4..890ff0adceea4dd996aed3d3fab83deb1335e2ca 100644 (file)
@@ -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);
index b0f829bbd7adaeac2f738600d7bb63c74126930c..f4a850b9838f4ba743cf8f831044eb851e9a0dd5 100644 (file)
@@ -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);
index baea64a815d2e07d1163cb30bf03284ee3440303..66f118714a3636111bcbb06e651c85ab2d7a2bf6 100644 (file)
@@ -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();
index 7d25fb2c3195e37563ad58db99cefa8df4427a2c..8d8bfc7c6a58f7deeac606fba58980831e092370 100644 (file)
@@ -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);
index 4c9ca74e7fa2d96ae3294a63f056284f758189c7..2855f161437a55767a2db45bc6ef228f851db896 100644 (file)
@@ -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();
index 5a63955aed36777230843c54bbadbc19e33d8952..b6dc23c685bae7052b21a4b02e768a072d70f08f 100644 (file)
@@ -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();