Browse code

Add some margin to zoom to fit.

From: Marius Gedminas <marius@gedmin.as>

Jose.R.Fonseca authored on 13/07/2008 03:22:51
Showing 1 changed files

  • xdot.py index ca21496..9015686 100755
... ...
@@ -969,6 +969,7 @@ class DotWidget(gtk.DrawingArea):
969 969
         self.queue_draw()
970 970
 
971 971
     ZOOM_INCREMENT = 1.25
972
+    ZOOM_TO_FIT_MARGIN = 12
972 973
 
973 974
     def on_zoom_in(self, action):
974 975
         self.zoom_image(self.zoom_ratio * self.ZOOM_INCREMENT)
... ...
@@ -978,6 +979,10 @@ class DotWidget(gtk.DrawingArea):
978 979
 
979 980
     def on_zoom_fit(self, action):
980 981
         rect = self.get_allocation()
982
+        rect.x += self.ZOOM_TO_FIT_MARGIN
983
+        rect.y += self.ZOOM_TO_FIT_MARGIN
984
+        rect.width -= 2 * self.ZOOM_TO_FIT_MARGIN
985
+        rect.height -= 2 * self.ZOOM_TO_FIT_MARGIN
981 986
         zoom_ratio = min(
982 987
             float(rect.width)/float(self.graph.width),
983 988
             float(rect.height)/float(self.graph.height)