Fix "zoom to fit" so that it centers the fitted canvas on the screen, and always...
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Fri, 28 Mar 2008 18:54:23 +0000 (18:54 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Fri, 28 Mar 2008 18:54:23 +0000 (18:54 +0000)
git-svn-id: http://svn.voria.com/code@1933 1f10aa63-cdf2-0310-b900-c93c546f37ac

synfig-studio/trunk/src/gtkmm/workarea.cpp

index 57d079d..97c0a6d 100644 (file)
@@ -2133,8 +2133,6 @@ WorkArea::refresh(GdkEventExpose*event)
                drawing_frame->unset_bg(Gtk::STATE_NORMAL);
 #endif
 
-       previous_focus=get_focus_point();
-
        return true;
 }
 
@@ -2580,9 +2578,15 @@ void
 studio::WorkArea::zoom_fit()
 {
        float new_zoom(min(drawing_area->get_width() * zoom / w, drawing_area->get_height() * zoom / h));
-       if (zoom == new_zoom) return set_zoom(prev_zoom);
+       if (zoom / new_zoom > 0.995 && new_zoom / zoom > 0.995)
+       {
+               set_zoom(prev_zoom);
+               return set_focus_point(previous_focus);
+       }
+       previous_focus = get_focus_point();
        prev_zoom = zoom;
        set_zoom(new_zoom);
+       set_focus_point(Point(0,0));
 }
 
 void