From: dooglus Date: Sat, 8 Mar 2008 23:42:18 +0000 (+0000) Subject: Fix zoom_fit() so it really does zoom the canvas to fit the window. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=933698eb69791193b53ce0142909502de42a6124;p=synfig.git Fix zoom_fit() so it really does zoom the canvas to fit the window. git-svn-id: http://svn.voria.com/code@1895 1f10aa63-cdf2-0310-b900-c93c546f37ac --- diff --git a/synfig-studio/trunk/src/gtkmm/workarea.cpp b/synfig-studio/trunk/src/gtkmm/workarea.cpp index c4f8be6..57d079d 100644 --- a/synfig-studio/trunk/src/gtkmm/workarea.cpp +++ b/synfig-studio/trunk/src/gtkmm/workarea.cpp @@ -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