add zoom slider, fix stop_playback on quit, new msg.txt, rework filelist
[goodguy/history.git] / cinelerra-5.1 / cinelerra / cwindowgui.C
index 73c11dc5cca985735f44b0239af095aba5f2a2d4..4f899c57e7e9ba0c0c8df1e65c107b8d99f83899 100644 (file)
@@ -109,6 +109,7 @@ CWindowGUI::CWindowGUI(MWindow *mwindow, CWindow *cwindow)
        inactive = 0;
        crop_translate = 0;
        eyedrop_visible = 0;
+       highlighted = 0;
 }
 
 CWindowGUI::~CWindowGUI()
@@ -169,10 +170,10 @@ void CWindowGUI::create_objects()
        timebar->create_objects();
 
 #ifdef USE_SLIDER
-       add_subwindow(slider = new CWindowSlider(mwindow, 
-               cwindow, 
+       add_subwindow(slider = new CWindowSlider(mwindow,
+               cwindow,
                mwindow->theme->cslider_x,
-               mwindow->theme->cslider_y, 
+               mwindow->theme->cslider_y,
                mwindow->theme->cslider_w));
 #endif
 
@@ -199,8 +200,9 @@ void CWindowGUI::create_objects()
                mwindow->theme->czoom_y,
                mwindow->theme->czoom_w);
        zoom_panel->create_objects();
-       zoom_panel->zoom_text->add_item(new BC_MenuItem(AUTO_ZOOM));
-       if(!mwindow->edl->session->cwindow_scrollbars) zoom_panel->set_text(AUTO_ZOOM);
+       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);
 
 //     destination = new CWindowDestination(mwindow,
 //             this,
@@ -255,7 +257,7 @@ int CWindowGUI::resize_event(int w, int h)
 
 #ifdef USE_SLIDER
        slider->reposition_window(mwindow->theme->cslider_x,
-               mwindow->theme->cslider_y, 
+               mwindow->theme->cslider_y,
                mwindow->theme->cslider_w);
 // Recalibrate pointer motion range
        slider->set_position();
@@ -357,44 +359,50 @@ void CWindowGUI::draw_status(int flush)
                flush);
 }
 
+float CWindowGUI::get_auto_zoom()
+{
+       float conformed_w, conformed_h;
+       mwindow->edl->calculate_conformed_dimensions(0, conformed_w, conformed_h);
+       float zoom_x = canvas->w / conformed_w;
+       float zoom_y = canvas->h / conformed_h;
+       return zoom_x < zoom_y ? zoom_x : zoom_y;
+}
 
 void CWindowGUI::zoom_canvas(int do_auto, double value, int update_menu)
 {
-       if(do_auto)
-               mwindow->edl->session->cwindow_scrollbars = 0;
-       else
-               mwindow->edl->session->cwindow_scrollbars = 1;
-
+       EDL *edl = mwindow->edl;
+       float x = 0, y = 0;
        float old_zoom = mwindow->edl->session->cwindow_zoom;
        float new_zoom = value;
-       float x = canvas->w / 2.0;
-       float y = canvas->h / 2.0;
-       canvas->canvas_to_output(mwindow->edl,
-                               0,
-                               x,
-                               y);
-       x -= canvas->w_visible / 2 * old_zoom / new_zoom;
-       y -= canvas->h_visible / 2 * old_zoom / new_zoom;
-       if(update_menu)
-       {
-               if(do_auto)
-               {
-                       zoom_panel->update(AUTO_ZOOM);
+       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;
+       }
+
+       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(value);
+               else {
+                       zoom_panel->update(auto_zoom);
+                       composite_panel->cpanel_zoom->update(new_zoom);
                }
        }
+       else 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->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);
+               mwindow->theme->ccanvas_x, mwindow->theme->ccanvas_y,
+               mwindow->theme->ccanvas_w, mwindow->theme->ccanvas_h);
        canvas->draw_refresh();
 }
 
@@ -458,7 +466,7 @@ int CWindowGUI::keypress_event()
                        mwindow->gui->unlock_window();
                        lock_window("CWindowGUI::keypress_event 2");
                        break;
-               case BACKSPACE:
+               case DELETE:
                        unlock_window();
                        mwindow->gui->lock_window("CWindowGUI::keypress_event 2");
                        mwindow->clear_entry();
@@ -569,43 +577,26 @@ void CWindowGUI::drag_motion()
 {
        if(get_hidden()) return;
 
-       if(mwindow->session->current_operation == DRAG_ASSET ||
-               mwindow->session->current_operation == DRAG_VTRANSITION ||
-               mwindow->session->current_operation == DRAG_VEFFECT)
-       {
-               int old_status = mwindow->session->ccanvas_highlighted;
-               int cursor_x = get_relative_cursor_x();
-               int cursor_y = get_relative_cursor_y();
-
-               mwindow->session->ccanvas_highlighted = get_cursor_over_window() &&
-                       cursor_x >= canvas->x &&
-                       cursor_x < canvas->x + canvas->w &&
-                       cursor_y >= canvas->y &&
-                       cursor_y < canvas->y + canvas->h;
-
-
-               if(old_status != mwindow->session->ccanvas_highlighted)
-                       canvas->draw_refresh();
-       }
+       if(mwindow->session->current_operation != DRAG_ASSET &&
+               mwindow->session->current_operation != DRAG_VTRANSITION &&
+               mwindow->session->current_operation != DRAG_VEFFECT) return;
+       int need_highlight = cursor_above() && get_cursor_over_window();
+       if( highlighted == need_highlight ) return;
+       highlighted = need_highlight;
+       canvas->draw_refresh();
 }
 
 int CWindowGUI::drag_stop()
 {
        int result = 0;
        if(get_hidden()) return 0;
-
-       if((mwindow->session->current_operation == DRAG_ASSET ||
-               mwindow->session->current_operation == DRAG_VTRANSITION ||
-               mwindow->session->current_operation == DRAG_VEFFECT) &&
-               mwindow->session->ccanvas_highlighted)
-       {
-// Hide highlighting
-               mwindow->session->ccanvas_highlighted = 0;
-               canvas->draw_refresh();
-               result = 1;
-       }
-       else
-               return 0;
+       if( !highlighted ) return 0;
+       if( mwindow->session->current_operation != DRAG_ASSET &&
+           mwindow->session->current_operation != DRAG_VTRANSITION &&
+           mwindow->session->current_operation != DRAG_VEFFECT) return 0;
+       highlighted = 0;
+       canvas->draw_refresh();
+       result = 1;
 
        if(mwindow->session->current_operation == DRAG_ASSET)
        {
@@ -778,15 +769,8 @@ int CWindowMeters::change_status_event(int new_status)
 
 
 CWindowZoom::CWindowZoom(MWindow *mwindow, CWindowGUI *gui, int x, int y, int w)
- : ZoomPanel(mwindow,
-       gui,
-       (double)mwindow->edl->session->cwindow_zoom,
-       x,
-       y,
-       w,
-       my_zoom_table,
-       total_zooms,
-       ZOOM_PERCENTAGE)
+ : ZoomPanel(mwindow, gui, (double)mwindow->edl->session->cwindow_zoom,
+       x, y, w, my_zoom_table, total_zooms, ZOOM_PERCENTAGE)
 {
        this->mwindow = mwindow;
        this->gui = gui;
@@ -798,15 +782,9 @@ CWindowZoom::~CWindowZoom()
 
 int CWindowZoom::handle_event()
 {
-       if(!strcasecmp(AUTO_ZOOM, get_text()))
-       {
-               gui->zoom_canvas(1, get_value(), 0);
-       }
-       else
-       {
-               gui->zoom_canvas(0, get_value(), 0);
-       }
-
+       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);
        return 1;
 }
 
@@ -814,13 +792,13 @@ int CWindowZoom::handle_event()
 
 #ifdef USE_SLIDER
 CWindowSlider::CWindowSlider(MWindow *mwindow, CWindow *cwindow, int x, int y, int pixels)
- : BC_PercentageSlider(x, 
+ : BC_PercentageSlider(x,
                        y,
                        0,
-                       pixels, 
-                       pixels, 
-                       0, 
-                       1, 
+                       pixels,
+                       pixels,
+                       0,
+                       1,
                        0)
 {
        this->mwindow = mwindow;
@@ -844,16 +822,16 @@ void CWindowSlider::set_position()
 //     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 > 
+//     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), 
+       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_start,
 //             mwindow->edl->local_session->preview_end);
 }
 
@@ -876,22 +854,22 @@ int CWindowSlider::decrease_value()
 
 
 // CWindowDestination::CWindowDestination(MWindow *mwindow, CWindowGUI *cwindow, int x, int y)
-//  : BC_PopupTextBox(cwindow, 
-//     &cwindow->destinations, 
+//  : BC_PopupTextBox(cwindow,
+//     &cwindow->destinations,
 //     cwindow->destinations.values[cwindow->cwindow->destination]->get_text(),
-//     x, 
-//     y, 
-//     70, 
+//     x,
+//     y,
+//     70,
 //     200)
 // {
 //     this->mwindow = mwindow;
 //     this->cwindow = cwindow;
 // }
-// 
+//
 // CWindowDestination::~CWindowDestination()
 // {
 // }
-// 
+//
 // int CWindowDestination::handle_event()
 // {
 //     return 1;
@@ -988,7 +966,7 @@ void CWindowCanvas::update_zoom(int x, int y, float zoom)
 
 void CWindowCanvas::zoom_auto()
 {
-       gui->zoom_canvas(1, 1.0, 1);
+       gui->zoom_canvas(1, gui->get_auto_zoom(), 1);
 }
 
 int CWindowCanvas::get_xscroll()
@@ -1530,6 +1508,14 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender,
                                float x2 = point2->x + point2->control_x1;
                                float y2 = point2->y + point2->control_y1;
                                float x3 = point2->x, y3 = point2->y;
+                               float canvas_x0 = (x0 - half_track_w) * projector_z + projector_x;
+                               float canvas_y0 = (y0 - half_track_h) * projector_z + projector_y;
+                               float canvas_x1 = (x1 - half_track_w) * projector_z + projector_x;
+                               float canvas_y1 = (y1 - half_track_h) * projector_z + projector_y;
+                               float canvas_x2 = (x2 - half_track_w) * projector_z + projector_x;
+                               float canvas_y2 = (y2 - half_track_h) * projector_z + projector_y;
+                               float canvas_x3 = (x3 - half_track_w) * projector_z + projector_x;
+                               float canvas_y3 = (y3 - half_track_h) * projector_z + projector_y;
 
                                float t = (float)j / segments;
                                float tpow2 = t * t;
@@ -1546,9 +1532,8 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender,
                                        + 3 * t     * invtpow2 * y1
                                        + 3 * tpow2 * invt     * y2
                                        +     tpow3            * y3);
-
-                               x = (x - half_track_w) * projector_z + projector_x;
-                               y = (y - half_track_h) * projector_z + projector_y;
+                               float canvas_x = (x - half_track_w) * projector_z + projector_x;
+                               float canvas_y = (y - half_track_h) * projector_z + projector_y;
 // Test new point addition
                                if(button_press) {
                                        float line_distance = line_dist(x,y, mask_cursor_x,mask_cursor_y);
@@ -1565,13 +1550,9 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender,
                                        }
 
 // Test existing point selection
-                                       float canvas_x = (x0 - half_track_w) * projector_z + projector_x;
-                                       float canvas_y = (y0 - half_track_h) * projector_z + projector_y;
 // Test first point
                                        if(gui->ctrl_down()) {
-                                               float control_x = (x1 - half_track_w) * projector_z + projector_x;
-                                               float control_y = (y1 - half_track_h) * projector_z + projector_y;
-                                               float distance = line_dist(control_x,control_y, mask_cursor_x,mask_cursor_y);
+                                               float distance = line_dist(x1,y1, mask_cursor_x,mask_cursor_y);
 
                                                if(distance < selected_control_point_distance) {
                                                        selected_point = i;
@@ -1581,7 +1562,8 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender,
                                        }
                                        else {
                                                if(!gui->shift_down()) {
-                                                       if(test_bbox(cursor_x, cursor_y, canvas_x, canvas_y)) {
+                                                       output_to_canvas(mwindow->edl, 0, canvas_x0, canvas_y0);
+                                                       if(test_bbox(cursor_x, cursor_y, canvas_x0, canvas_y0)) {
                                                                selected_point = i;
                                                        }
                                                }
@@ -1590,13 +1572,8 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender,
                                                }
                                        }
 // Test second point
-                                       canvas_x = (x3 - half_track_w) * projector_z + projector_x;
-                                       canvas_y = (y3 - half_track_h) * projector_z + projector_y;
-
                                        if(gui->ctrl_down()) {
-                                               float control_x = (x2 - half_track_w) * projector_z + projector_x;
-                                               float control_y = (y2 - half_track_h) * projector_z + projector_y;
-                                               float distance = line_dist(control_x,control_y, mask_cursor_x,mask_cursor_y);
+                                               float distance = line_dist(x2,y2, mask_cursor_x,mask_cursor_y);
 
 //printf("CWindowCanvas::do_mask %d %f %f\n", i, distance, selected_control_point_distance);
                                                if(distance < selected_control_point_distance) {
@@ -1607,7 +1584,8 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender,
                                        }
                                        else if(i < points.size() - 1) {
                                                if(!gui->shift_down()) {
-                                                       if(test_bbox(cursor_x, cursor_y, canvas_x, canvas_y)) {
+                                                       output_to_canvas(mwindow->edl, 0, canvas_x3, canvas_y3);
+                                                       if(test_bbox(cursor_x, cursor_y, canvas_x3, canvas_y3)) {
                                                                selected_point = (i < points.size() - 1 ? i + 1 : 0);
                                                        }
                                                }
@@ -1617,14 +1595,13 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender,
                                        }
                                }
 
-
-                               output_to_canvas(mwindow->edl, 0, x, y);
+                               output_to_canvas(mwindow->edl, 0, canvas_x, canvas_y);
 
                                if(j > 0) {
 
                                        if(draw) { // Draw joining line
-                                               x_points.append((int)x);
-                                               y_points.append((int)y);
+                                               x_points.append((int)canvas_x);
+                                               y_points.append((int)canvas_y);
                                        }
 
                                        if(j == segments) {
@@ -1632,27 +1609,26 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender,
                                                        if(i < points.size() - 1) {
                                                                if(i == gui->affected_point - 1)
                                                                        get_canvas()->draw_disc(
-                                                                               (int)x - CONTROL_W / 2,
-                                                                               (int)y - CONTROL_W / 2,
+                                                                               (int)canvas_x - CONTROL_W / 2,
+                                                                               (int)canvas_y - CONTROL_W / 2,
                                                                                CONTROL_W, CONTROL_H);
                                                                else
                                                                        get_canvas()->draw_circle(
-                                                                               (int)x - CONTROL_W / 2,
-                                                                               (int)y - CONTROL_W / 2,
+                                                                               (int)canvas_x - CONTROL_W / 2,
+                                                                               (int)canvas_y - CONTROL_W / 2,
                                                                                CONTROL_W, CONTROL_H);
 // char string[BCTEXTLEN];
 // sprintf(string, "%d", (i < points.size() - 1 ? i + 1 : 0));
-// canvas->draw_text((int)x + CONTROL_W, (int)y + CONTROL_W, string);
+// canvas->draw_text((int)canvas_x + CONTROL_W, (int)canvas_y + CONTROL_W, string);
                                                        }
-
-// Draw second control point.  Discard x2 and y2 after this.
-                                                       x2 = (x2 - half_track_w) * projector_z + projector_x;
-                                                       y2 = (y2 - half_track_h) * projector_z + projector_y;
-                                                       output_to_canvas(mwindow->edl, 0, x2, y2);
-                                                       get_canvas()->draw_line((int)x, (int)y, (int)x2, (int)y2);
+// Draw second control point.
+                                                       output_to_canvas(mwindow->edl, 0, canvas_x2, canvas_y2);
+                                                       get_canvas()->draw_line(
+                                                               (int)canvas_x, (int)canvas_y,
+                                                               (int)canvas_x2, (int)canvas_y2);
                                                        get_canvas()->draw_rectangle(
-                                                               (int)x2 - CONTROL_W / 2,
-                                                               (int)y2 - CONTROL_H / 2,
+                                                               (int)canvas_x2 - CONTROL_W / 2,
+                                                               (int)canvas_y2 - CONTROL_H / 2,
                                                                CONTROL_W, CONTROL_H);
                                                }
                                        }
@@ -1664,29 +1640,29 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender,
                                                sprintf(mask_label, "%d",
                                                        mwindow->edl->session->cwindow_mask);
                                                get_canvas()->draw_text(
-                                                       (int)x - FIRST_CONTROL_W,
-                                                       (int)y - FIRST_CONTROL_H,
+                                                       (int)canvas_x - FIRST_CONTROL_W,
+                                                       (int)canvas_y - FIRST_CONTROL_H,
                                                        mask_label);
-                                                       
+
                                                get_canvas()->draw_disc(
-                                                       (int)x - FIRST_CONTROL_W / 2,
-                                                       (int)y - FIRST_CONTROL_H / 2,
+                                                       (int)canvas_x - FIRST_CONTROL_W / 2,
+                                                       (int)canvas_y - FIRST_CONTROL_H / 2,
                                                        FIRST_CONTROL_W, FIRST_CONTROL_H);
                                        }
 
-// Draw first control point.  Discard x1 and y1 after this.
+// Draw first control point.
                                        if(draw) {
-                                               x1 = (x1 - half_track_w) * projector_z + projector_x;
-                                               y1 = (y1 - half_track_h) * projector_z + projector_y;
-                                               output_to_canvas(mwindow->edl, 0, x1, y1);
-                                               get_canvas()->draw_line((int)x, (int)y, (int)x1, (int)y1);
+                                               output_to_canvas(mwindow->edl, 0, canvas_x1, canvas_y1);
+                                               get_canvas()->draw_line(
+                                                       (int)canvas_x, (int)canvas_y,
+                                                       (int)canvas_x1, (int)canvas_y1);
                                                get_canvas()->draw_rectangle(
-                                                       (int)x1 - CONTROL_W / 2,
-                                                       (int)y1 - CONTROL_H / 2,
+                                                       (int)canvas_x1 - CONTROL_W / 2,
+                                                       (int)canvas_y1 - CONTROL_H / 2,
                                                        CONTROL_W, CONTROL_H);
 
-                                               x_points.append((int)x);
-                                               y_points.append((int)y);
+                                               x_points.append((int)canvas_x);
+                                               y_points.append((int)canvas_y);
                                        }
                                }
 //printf("CWindowCanvas::do_mask 1\n");
@@ -2006,26 +1982,26 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender,
                                float y1 = point->y + point->control_y1;
                                float x2 = point->x + point->control_x2;
                                float y2 = point->y + point->control_y2;
-                               float canvas_x = (x0 - half_track_w) * projector_z + projector_x;
-                               float canvas_y = (y0 - half_track_h) * projector_z + projector_y;
+                               float canvas_x0 = (x0 - half_track_w) * projector_z + projector_x;
+                               float canvas_y0 = (y0 - half_track_h) * projector_z + projector_y;
 
-                               output_to_canvas(mwindow->edl, 0, canvas_x, canvas_y);
-                               if(test_bbox(cursor_x, cursor_y, canvas_x, canvas_y)) {
+                               output_to_canvas(mwindow->edl, 0, canvas_x0, canvas_y0);
+                               if(test_bbox(cursor_x, cursor_y, canvas_x0, canvas_y0)) {
                                        over_point = 1;
                                }
 
                                if(!over_point && gui->ctrl_down()) {
-                                       canvas_x = (x1 - half_track_w) * projector_z + projector_x;
-                                       canvas_y = (y1 - half_track_h) * projector_z + projector_y;
-                                       output_to_canvas(mwindow->edl, 0, canvas_x, canvas_y);
-                                       if(test_bbox(cursor_x, cursor_y, canvas_x, canvas_y)) {
+                                       float canvas_x1 = (x1 - half_track_w) * projector_z + projector_x;
+                                       float canvas_y1 = (y1 - half_track_h) * projector_z + projector_y;
+                                       output_to_canvas(mwindow->edl, 0, canvas_x1, canvas_y1);
+                                       if(test_bbox(cursor_x, cursor_y, canvas_x1, canvas_y1)) {
                                                over_point = 1;
                                        }
                                        else {
-                                               canvas_x = (x2 - half_track_w) * projector_z + projector_x;
-                                               canvas_y = (y2 - half_track_h) * projector_z + projector_y;
-                                               output_to_canvas(mwindow->edl, 0, canvas_x, canvas_y);
-                                               if(test_bbox(cursor_x, cursor_y, canvas_x, canvas_y)) {
+                                               float canvas_x2 = (x2 - half_track_w) * projector_z + projector_x;
+                                               float canvas_y2 = (y2 - half_track_h) * projector_z + projector_y;
+                                               output_to_canvas(mwindow->edl, 0, canvas_x2, canvas_y2);
+                                               if(test_bbox(cursor_x, cursor_y, canvas_x2, canvas_y2)) {
                                                        over_point = 1;
                                                }
                                        }
@@ -2288,7 +2264,7 @@ void CWindowCanvas::draw_overlays()
                get_canvas()->set_opaque();
        }
 
-       if(mwindow->session->ccanvas_highlighted)
+       if(gui->highlighted)
        {
                get_canvas()->set_color(WHITE);
                get_canvas()->set_inverse();
@@ -2768,8 +2744,8 @@ void CWindowCanvas::draw_bezier(int do_camera)
 
 }
 
-int CWindowCanvas::test_bezier(int button_press, 
-       int &redraw, 
+int CWindowCanvas::test_bezier(int button_press,
+       int &redraw,
        int &redraw_canvas,
        int &rerender,
        int do_camera)
@@ -2834,11 +2810,11 @@ int CWindowCanvas::test_bezier(int button_press,
                                        FloatAuto *previous = 0;
                                        FloatAuto *next = 0;
                                        float new_z = affected_z_autos->get_value(
-                                               track_position, 
+                                               track_position,
                                                PLAY_FORWARD,
                                                previous,
                                                next);
-                                       gui->affected_z = 
+                                       gui->affected_z =
                                                (FloatAuto*)gui->cwindow->calculate_affected_auto(
                                                        affected_z_autos, 1, &created, 0);
                                        if(created) {
@@ -2851,25 +2827,25 @@ int CWindowCanvas::test_bezier(int button_press,
                                        FloatAuto *previous = 0;
                                        FloatAuto *next = 0;
                                        float new_x = affected_x_autos->get_value(
-                                               track_position, 
+                                               track_position,
                                                PLAY_FORWARD,
                                                previous,
                                                next);
                                        previous = 0;
                                        next = 0;
                                        float new_y = affected_y_autos->get_value(
-                                               track_position, 
+                                               track_position,
                                                PLAY_FORWARD,
                                                previous,
                                                next);
-                                       gui->affected_x = 
+                                       gui->affected_x =
                                                (FloatAuto*)gui->cwindow->calculate_affected_auto(
                                                        affected_x_autos, 1, &created, 0);
                                        if(created) {
                                                gui->affected_x->set_value(new_x);
                                                redraw_canvas = 1;
                                        }
-                                       gui->affected_y = 
+                                       gui->affected_y =
                                                (FloatAuto*)gui->cwindow->calculate_affected_auto(
                                                        affected_y_autos, 1, &created, 0);
                                        if(created) {
@@ -2944,13 +2920,13 @@ int CWindowCanvas::test_bezier(int button_press,
                        else
                                mwindow->undo->update_undo_before(_("projector"), this);
 
-                       gui->current_operation = 
+                       gui->current_operation =
                                mwindow->edl->session->cwindow_operation;
                        gui->tool_panel->raise_window();
                        result = 1;
                }
        }
-       
+
        return result;
 }
 
@@ -2979,9 +2955,9 @@ int CWindowCanvas::test_zoom(int &redraw)
 // cursor position relative to output
                float output_x = x;
                float output_y = y;
-               canvas_to_output(mwindow->edl, 
-                               0, 
-                               output_x, 
+               canvas_to_output(mwindow->edl,
+                               0,
+                               output_x,
                                output_y);
 
 //printf("CWindowCanvas::test_zoom 1 %f %f\n", x, y);
@@ -2994,7 +2970,7 @@ int CWindowCanvas::test_zoom(int &redraw)
 
 // Zoom out
                if(get_buttonpress() == 5 ||
-                       gui->ctrl_down() || 
+                       gui->ctrl_down() ||
                        gui->shift_down())
                {
                        current_index--;
@@ -3004,14 +2980,14 @@ int CWindowCanvas::test_zoom(int &redraw)
                {
                        current_index++;
                }
-               
+
                CLAMP(current_index, 0, total_zooms - 1);
                zoom = my_zoom_table[current_index];
-               
+
                x = output_x - x / zoom;
                y = output_y - y / zoom;
 
-               
+
        }
 
 
@@ -3022,10 +2998,10 @@ int CWindowCanvas::test_zoom(int &redraw)
 
 //printf("CWindowCanvas::test_zoom 2 %d %d\n", x_i, y_i);
 
-       update_zoom(x_i, 
-                       y_i, 
+       update_zoom(x_i,
+                       y_i,
                        zoom);
-       reposition_window(mwindow->edl, 
+       reposition_window(mwindow->edl,
                        mwindow->theme->ccanvas_x,
                        mwindow->theme->ccanvas_y,
                        mwindow->theme->ccanvas_w,
@@ -3033,9 +3009,12 @@ int CWindowCanvas::test_zoom(int &redraw)
        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);
+       }
+
        return result;
 }
 
@@ -3109,8 +3088,8 @@ int CWindowCanvas::cursor_motion_event()
                        int x = (int)(gui->x_origin - cursor_x + gui->x_offset);
                        int y = (int)(gui->y_origin - cursor_y + gui->y_offset);
 
-                       update_zoom(x, 
-                               y, 
+                       update_zoom(x,
+                               y,
                                zoom);
                        update_scrollbars(0);
                        redraw = 1;
@@ -3133,9 +3112,9 @@ int CWindowCanvas::cursor_motion_event()
 
                case CWINDOW_CROP:
                        result = test_crop(0, redraw);
-// printf("CWindowCanvas::cursor_motion_event %d result=%d redraw=%d\n", 
-// __LINE__, 
-// result, 
+// printf("CWindowCanvas::cursor_motion_event %d result=%d redraw=%d\n",
+// __LINE__,
+// result,
 // redraw);
                        break;
 
@@ -3144,9 +3123,9 @@ int CWindowCanvas::cursor_motion_event()
                case CWINDOW_MASK_CONTROL_OUT:
                case CWINDOW_MASK_TRANSLATE:
 
-                       result = do_mask(redraw, 
-                               rerender, 
-                               0, 
+                       result = do_mask(redraw,
+                               rerender,
+                               0,
                                1,
                                0);
                        break;
@@ -3164,8 +3143,8 @@ int CWindowCanvas::cursor_motion_event()
 // cursor font changes
        if(!result)
        {
-// printf("CWindowCanvas::cursor_motion_event %d cwindow_operation=%d\n", 
-// __LINE__, 
+// printf("CWindowCanvas::cursor_motion_event %d cwindow_operation=%d\n",
+// __LINE__,
 // mwindow->edl->session->cwindow_operation);
                switch(mwindow->edl->session->cwindow_operation)
                {
@@ -3176,9 +3155,9 @@ int CWindowCanvas::cursor_motion_event()
                                result = do_ruler(0, 1, 0, 0);
                                break;
                        case CWINDOW_MASK:
-                               result = do_mask(redraw, 
-                                       rerender, 
-                                       0, 
+                               result = do_mask(redraw,
+                                       rerender,
+                                       0,
                                        1,
                                        0);
                                        break;
@@ -3199,12 +3178,12 @@ int CWindowCanvas::cursor_motion_event()
        if(redraw_canvas)
        {
                gui->unlock_window();
-       
-       
+
+
                mwindow->gui->lock_window("CWindowCanvas::cursor_motion_event 1");
                mwindow->gui->draw_overlays(1);
                mwindow->gui->unlock_window();
-               
+
                gui->lock_window("CWindowCanvas::cursor_motion_event 1");
        }
 
@@ -3213,7 +3192,7 @@ int CWindowCanvas::cursor_motion_event()
                gui->unlock_window();
                mwindow->restart_brender();
                mwindow->sync_parameters(CHANGE_PARAMS);
-               gui->cwindow->playback_engine->que->send_command(CURRENT_FRAME, 
+               gui->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
                        CHANGE_NONE,
                        mwindow->edl,
                        1);
@@ -3232,7 +3211,7 @@ int CWindowCanvas::button_press_event()
 
        if(Canvas::button_press_event()) return 1;
 
-       gui->translating_zoom = gui->shift_down(); 
+       gui->translating_zoom = gui->shift_down();
 
        calculate_origin();
 //printf("CWindowCanvas::button_press_event 2 %f %f\n", gui->x_origin, gui->y_origin, gui->x_origin, gui->y_origin);
@@ -3256,7 +3235,7 @@ int CWindowCanvas::button_press_event()
                        case CWINDOW_RULER:
                                result = do_ruler(0, 0, 1, 0);
                                break;
-               
+
                        case CWINDOW_CAMERA:
                                result = test_bezier(1, redraw, redraw_canvas, rerender, 1);
                                break;
@@ -3288,24 +3267,24 @@ int CWindowCanvas::button_press_event()
        {
                draw_refresh();
                gui->unlock_window();
-       
-       
+
+
                mwindow->gui->lock_window("CWindowCanvas::button_press_event 1");
                mwindow->gui->draw_overlays(1);
                mwindow->gui->unlock_window();
                gui->update_tool();
-               
+
                gui->lock_window("CWindowCanvas::button_press_event 1");
        }
 
 // rerendering can also be caused by press event
-       if(rerender) 
+       if(rerender)
        {
                gui->unlock_window();
 
                mwindow->restart_brender();
                mwindow->sync_parameters(CHANGE_PARAMS);
-               gui->cwindow->playback_engine->que->send_command(CURRENT_FRAME, 
+               gui->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
                        CHANGE_NONE,
                        mwindow->edl,
                        1);
@@ -3324,7 +3303,7 @@ int CWindowCanvas::button_release_event()
                case CWINDOW_SCROLL:
                        result = 1;
                        break;
-                       
+
                case CWINDOW_RULER:
                        do_ruler(0, 0, 0, 1);
                        break;
@@ -3345,7 +3324,9 @@ int CWindowCanvas::button_release_event()
                        gui->mask_keyframe = 0;
                        mwindow->undo->update_undo_after(_("mask"), LOAD_AUTOMATION);
                        break;
-
+               case CWINDOW_NONE:
+                       result = Canvas::button_release_event();
+                       break;
        }
 
        gui->current_operation = CWINDOW_NONE;
@@ -3356,12 +3337,12 @@ void CWindowCanvas::zoom_resize_window(float percentage)
 {
        int canvas_w, canvas_h;
        int new_w, new_h;
-       
-       
+
+
 // Get required canvas size
-       calculate_sizes(mwindow->edl->get_aspect_ratio(), 
-               mwindow->edl->session->output_w, 
-               mwindow->edl->session->output_h, 
+       calculate_sizes(mwindow->edl->get_aspect_ratio(),
+               mwindow->edl->session->output_w,
+               mwindow->edl->session->output_h,
                percentage,
                canvas_w,
                canvas_h);
@@ -3374,7 +3355,7 @@ void CWindowCanvas::zoom_resize_window(float percentage)
        mwindow->session->cwindow_w = new_w;
        mwindow->session->cwindow_h = new_h;
 
-       mwindow->theme->get_cwindow_sizes(gui, 
+       mwindow->theme->get_cwindow_sizes(gui,
                mwindow->session->cwindow_controls);
 
 // Estimate again from new borders