From 1d7e7e5eb9e2198cd534eebf37cff625ba73c3da Mon Sep 17 00:00:00 2001 From: dooglus Date: Fri, 28 Mar 2008 18:54:23 +0000 Subject: [PATCH] Fix "zoom to fit" so that it centers the fitted canvas on the screen, and always zooms back to the previous zoom level and position if clicked a second time. git-svn-id: http://svn.voria.com/code@1933 1f10aa63-cdf2-0310-b900-c93c546f37ac --- synfig-studio/trunk/src/gtkmm/workarea.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/synfig-studio/trunk/src/gtkmm/workarea.cpp b/synfig-studio/trunk/src/gtkmm/workarea.cpp index 57d079d..97c0a6d 100644 --- a/synfig-studio/trunk/src/gtkmm/workarea.cpp +++ b/synfig-studio/trunk/src/gtkmm/workarea.cpp @@ -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 -- 2.7.4