Fix zoom_fit() so it really does zoom the canvas to fit the window.
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Sat, 8 Mar 2008 23:42:18 +0000 (23:42 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Sat, 8 Mar 2008 23:42:18 +0000 (23:42 +0000)
git-svn-id: http://svn.voria.com/code@1895 1f10aa63-cdf2-0310-b900-c93c546f37ac

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

index c4f8be6..57d079d 100644 (file)
@@ -2579,20 +2579,18 @@ studio::WorkArea::zoom_out()
 void
 studio::WorkArea::zoom_fit()
 {
-       // This really doesn't zoom to fit. Bug.
-       zoom_norm();
+       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);
+       prev_zoom = zoom;
+       set_zoom(new_zoom);
 }
 
 void
 studio::WorkArea::zoom_norm()
 {
-       if(zoom==1.0)
-               set_zoom(prev_zoom);
-       else
-       {
-               prev_zoom=zoom;
-               set_zoom(1.0f);
-       }
+       if (zoom == 1.0) return set_zoom(prev_zoom);
+       prev_zoom = zoom;
+       set_zoom(1.0f);
 }
 
 gboolean