rework cpozer zoom slider
authorGood Guy <good1.2guy@gmail.com>
Tue, 30 May 2017 17:43:10 +0000 (11:43 -0600)
committerGood Guy <good1.2guy@gmail.com>
Tue, 30 May 2017 17:43:10 +0000 (11:43 -0600)
cinelerra-5.1/cinelerra/cpanel.C
cinelerra-5.1/cinelerra/cwindow.C
cinelerra-5.1/cinelerra/cwindowgui.C
cinelerra-5.1/cinelerra/cwindowgui.h
cinelerra-5.1/plugin_defs

index 09c54b5ac34b2e90e46d508ddf07c2f7988cbe7b..19cea4904a85c446257a1d85281e652f8b2f78be 100644 (file)
@@ -384,7 +384,7 @@ int CPanelZoom::handle_event()
        double zoom = pow(10.,value);
        switch( mwindow->edl->session->cwindow_operation ) {
        case CWINDOW_ZOOM:
-               gui->subwindow->zoom_canvas(0, zoom, 1);
+               gui->subwindow->zoom_canvas(zoom, 1);
                break;
        case CWINDOW_CAMERA:
                aidx = AUTOMATION_CAMERA_Z;
@@ -411,9 +411,8 @@ int CPanelZoom::handle_event()
 int CPanelZoom::set_shown(int shown)
 {
        if( shown ) {
-               float zoom = gui->subwindow->canvas->get_zoom();
-               gui->subwindow->zoom_canvas(0, zoom, 1);
                show_window();
+               update(gui->subwindow->canvas->get_zoom());
        }
        else
                hide_window();
index f4c91c459f289bf7690c94913a87151a20337aae..063f4e05c9a0f29032143850891afadfe7b0fddb 100644 (file)
@@ -267,10 +267,9 @@ void CWindow::update(int position,
                gui->timebar->update(1);
        }
 
-       if(!mwindow->edl->session->cwindow_scrollbars)
-               gui->zoom_panel->update(_(AUTO_ZOOM));
-       else
-               gui->zoom_panel->update(mwindow->edl->session->cwindow_zoom);
+       double zoom = !mwindow->edl->session->cwindow_scrollbars ?
+               0 :mwindow->edl->session->cwindow_zoom;
+       gui->zoom_panel->update(zoom);
 
        gui->canvas->update_zoom(mwindow->edl->session->cwindow_xscroll,
                        mwindow->edl->session->cwindow_yscroll,
index 4f899c57e7e9ba0c0c8df1e65c107b8d99f83899..bc37551a84bf87b49f070cd8d4583cf660c9ec7c 100644 (file)
@@ -200,9 +200,9 @@ void CWindowGUI::create_objects()
                mwindow->theme->czoom_y,
                mwindow->theme->czoom_w);
        zoom_panel->create_objects();
-       auto_zoom = _(AUTO_ZOOM);
-       zoom_panel->zoom_text->add_item(new BC_MenuItem(auto_zoom));
-       if(!mwindow->edl->session->cwindow_scrollbars) zoom_panel->set_text(auto_zoom);
+       zoom_panel->zoom_text->add_item(new BC_MenuItem(auto_zoom = _(AUTO_ZOOM)));
+       if( !mwindow->edl->session->cwindow_scrollbars )
+               zoom_panel->set_text(auto_zoom);
 
 //     destination = new CWindowDestination(mwindow,
 //             this,
@@ -368,38 +368,30 @@ float CWindowGUI::get_auto_zoom()
        return zoom_x < zoom_y ? zoom_x : zoom_y;
 }
 
-void CWindowGUI::zoom_canvas(int do_auto, double value, int update_menu)
+void CWindowGUI::zoom_canvas(double value, int update_menu)
 {
        EDL *edl = mwindow->edl;
-       float x = 0, y = 0;
+       float x = canvas->get_xscroll(), y = canvas->get_yscroll();
        float old_zoom = mwindow->edl->session->cwindow_zoom;
-       float new_zoom = value;
-       edl->session->cwindow_scrollbars = do_auto ? 0 : 1;
-       if( !do_auto && canvas->scrollbars_exist() ) {
-               float z = 1 - old_zoom / new_zoom;
-               x = canvas->get_xscroll() + 0.5f*canvas->w_visible * z;
-               y = canvas->get_yscroll() + 0.5f*canvas->h_visible * z;
+       float new_zoom = !value ? get_auto_zoom() : value;
+       edl->session->cwindow_scrollbars = !value ? 0 : 1;
+       if( value ) {
+               float z = (1 - old_zoom / new_zoom) / 2;
+               x += canvas->w_visible * z;
+               y += canvas->h_visible * z;
        }
+       else
+               x = y = 0;
 
-       if( update_menu ) {
-               if( !do_auto ) {
-                       int frac = new_zoom >= 1.0f ? 1 :
-                                  new_zoom >= 0.1f ? 2 :
-                                  new_zoom >= .01f ? 3 : 4;
-                       char string[BCSTRLEN];
-                       sprintf(string,"x %.*f", frac, new_zoom);
-                       zoom_panel->update(string);
-               }
-               else {
-                       zoom_panel->update(auto_zoom);
-                       composite_panel->cpanel_zoom->update(new_zoom);
-               }
-       }
-       else if( mwindow->edl->session->cwindow_operation == CWINDOW_ZOOM ) {
+       canvas->update_zoom((int)x, (int)y, new_zoom);
+       if( !value )
+               mwindow->edl->session->cwindow_scrollbars = 0;
+
+       if( update_menu )
+               zoom_panel->update(value);
+       if( mwindow->edl->session->cwindow_operation == CWINDOW_ZOOM )
                composite_panel->cpanel_zoom->update(new_zoom);
-       }
 
-       canvas->update_zoom((int)x, (int)y, new_zoom);
        canvas->reposition_window(mwindow->edl,
                mwindow->theme->ccanvas_x, mwindow->theme->ccanvas_y,
                mwindow->theme->ccanvas_w, mwindow->theme->ccanvas_h);
@@ -780,11 +772,26 @@ CWindowZoom::~CWindowZoom()
 {
 }
 
+void CWindowZoom::update(double value)
+{
+       char string[BCSTRLEN];
+       const char *cp = string;
+       if( value ) {
+               this->value = value;
+               int frac = value >= 1.0f ? 1 :
+                          value >= 0.1f ? 2 :
+                          value >= .01f ? 3 : 4;
+               sprintf(string, "x %.*f", frac, value);
+       }
+       else
+               cp = gui->auto_zoom;
+       ZoomPanel::update(cp);
+}
+
 int CWindowZoom::handle_event()
 {
-       int do_auto = !strcasecmp(gui->auto_zoom, get_text()) ? 1 : 0;
-       float zoom = do_auto ? gui->get_auto_zoom() : get_value();
-       gui->zoom_canvas(do_auto, zoom, 0);
+       double value = !strcasecmp(gui->auto_zoom, get_text()) ? 0 : get_value();
+       gui->zoom_canvas(value, 0);
        return 1;
 }
 
@@ -966,7 +973,7 @@ void CWindowCanvas::update_zoom(int x, int y, float zoom)
 
 void CWindowCanvas::zoom_auto()
 {
-       gui->zoom_canvas(1, gui->get_auto_zoom(), 1);
+       gui->zoom_canvas(0, 1);
 }
 
 int CWindowCanvas::get_xscroll()
@@ -2934,86 +2941,49 @@ int CWindowCanvas::test_bezier(int button_press,
 int CWindowCanvas::test_zoom(int &redraw)
 {
        int result = 0;
-       float zoom = get_zoom();
-       float x;
-       float y;
+       float x, y;
+       float zoom = 0;
 
-       if(!mwindow->edl->session->cwindow_scrollbars)
-       {
+       if( !mwindow->edl->session->cwindow_scrollbars ) {
                mwindow->edl->session->cwindow_scrollbars = 1;
-               zoom = 1.0;
-               x = mwindow->edl->session->output_w / 2;
-               y = mwindow->edl->session->output_h / 2;
-               x = x - w / zoom / 2;
-               y = y - h / zoom / 2;
+               x = (mwindow->edl->session->output_w - w) / 2;
+               y = (mwindow->edl->session->output_h - h) / 2;
+               zoom = 1;
        }
-       else
-       {
-// Cursor position relative to canvas
-               x = get_cursor_x();
-               y = get_cursor_y();
-// cursor position relative to output
-               float output_x = x;
-               float output_y = y;
-               canvas_to_output(mwindow->edl,
-                               0,
-                               output_x,
-                               output_y);
-
-//printf("CWindowCanvas::test_zoom 1 %f %f\n", x, y);
-
+       else {
+               if( *gui->zoom_panel->get_text() != 'x' ) {
 // Find current zoom in table
-               int current_index = 0;
-               for(current_index = 0 ; current_index < total_zooms; current_index++)
-                       if(EQUIV(my_zoom_table[current_index], zoom)) break;
-
-
-// Zoom out
-               if(get_buttonpress() == 5 ||
-                       gui->ctrl_down() ||
-                       gui->shift_down())
-               {
-                       current_index--;
-               }
-               else
-// Zoom in
-               {
-                       current_index++;
+                       int idx = total_zooms;  float old_zoom = get_zoom();
+                       while( --idx >= 0 && !EQUIV(my_zoom_table[idx], old_zoom) );
+                       if( idx >= 0 ) {
+                               idx += get_buttonpress() == 5 ||
+                                        gui->ctrl_down() || gui->shift_down() ?  -1 : +1 ;
+                               CLAMP(idx, 0, total_zooms-1);
+                               zoom = my_zoom_table[idx];
+                       }
                }
-
-               CLAMP(current_index, 0, total_zooms - 1);
-               zoom = my_zoom_table[current_index];
-
-               x = output_x - x / zoom;
-               y = output_y - y / zoom;
-
-
+               x = get_cursor_x();  y = get_cursor_y();
        }
+       if( !zoom ) {
+               mwindow->edl->session->cwindow_scrollbars = 0;
+               gui->zoom_panel->update(0);
+               zoom = gui->get_auto_zoom();
+       }
+       else
+               gui->zoom_panel->ZoomPanel::update(zoom);
 
+       float output_x = x, output_y = y;
+       canvas_to_output(mwindow->edl, 0, output_x, output_y);
+       x = output_x - x / zoom;
+       y = output_y - y / zoom;
+       update_zoom((int)x, (int)y, zoom);
 
+       gui->composite_panel->cpanel_zoom->update(zoom);
 
-       int x_i = (int)x;
-       int y_i = (int)y;
-//     check_boundaries(mwindow->edl, x_i, y_i, zoom);
-
-//printf("CWindowCanvas::test_zoom 2 %d %d\n", x_i, y_i);
-
-       update_zoom(x_i,
-                       y_i,
-                       zoom);
        reposition_window(mwindow->edl,
-                       mwindow->theme->ccanvas_x,
-                       mwindow->theme->ccanvas_y,
-                       mwindow->theme->ccanvas_w,
-                       mwindow->theme->ccanvas_h);
-       redraw = 1;
-       result = 1;
-
-
-       gui->zoom_panel->update(zoom);
-       if( gui->mwindow->edl->session->cwindow_operation == CWINDOW_ZOOM ) {
-               gui->composite_panel->cpanel_zoom->update(zoom);
-       }
+                       mwindow->theme->ccanvas_x, mwindow->theme->ccanvas_y,
+                       mwindow->theme->ccanvas_w, mwindow->theme->ccanvas_h);
+       redraw = 1;  result = 1;
 
        return result;
 }
index a5d18926ca4b2911d71f623581b8710ee2eaa13f..44a0b607be5f5547c2a18d595fb6215975064b70 100644 (file)
@@ -62,7 +62,7 @@ public:
 
        void create_objects();
        int resize_event(int w, int h);
-       void zoom_canvas(int do_auto, double value, int update_menu);
+       void zoom_canvas(double value, int update_menu);
        float get_auto_zoom();
 
 // Events for the fullscreen canvas fall through to here.
@@ -199,6 +199,7 @@ public:
        CWindowZoom(MWindow *mwindow, CWindowGUI *gui, int x, int y, int w);
        virtual ~CWindowZoom();
        int handle_event();
+       void update(double value);
        MWindow *mwindow;
        CWindowGUI *gui;
 };
index 0530ee0885d97d19d1c1f3d089d171f848ee988b..4eba17c5813c7c800dbe96557bd8d9d226158d5c 100644 (file)
@@ -31,7 +31,7 @@ audio_tools := audioscope cdripper compressor dcoffset delayaudio \
        gain graphic interpolateaudio invertaudio leveleffect loopaudio \
        normalize overlayaudio parametric pitch removegaps resample \
        resamplert reverb reverseaudio synthesizer timestretch timestretchrt \
-       vocoder
+       spectrogram vocoder
 
 plugin_dirs += video_tools
 video_tools := blur decimate delayvideo denoisemjpeg denoisevideo downsample \
@@ -39,7 +39,7 @@ video_tools := blur decimate delayvideo denoisemjpeg denoisevideo downsample \
        interpolatevideo invertvideo linearblur loopvideo \
        motion2 motionblur motion motion-cv motion-hv motion51 \
        overlay radialblur reframe reframert reroute \
-       reversevideo seltempavg sharpen spectrogram svg titler timeavg timefront \
+       reversevideo seltempavg sharpen svg titler timeavg timefront \
        unsharp videoscope wave zoomblur
 
 plugin_dirs += blending