Browse code

Shift+click led to division by 0, use it for zoom out now.

To remind, shift+drag is (still) zoom in to area.

Paul Sokolovsky authored on 14/02/2013 00:28:03 • José Fonseca committed on 12/05/2013 12:46:29
Showing 1 changed files

  • xdot.py index 9b1b0fe..6a7ff86 100755
... ...
@@ -1614,10 +1614,14 @@ class DotWidget(gtk.DrawingArea):
1614 1614
         rect = self.get_allocation()
1615 1615
         width = abs(x1 - x2)
1616 1616
         height = abs(y1 - y2)
1617
-        self.zoom_ratio = min(
1618
-            float(rect.width)/float(width),
1619
-            float(rect.height)/float(height)
1620
-        )
1617
+        if width == 0 and height == 0:
1618
+            self.zoom_ratio /= 2
1619
+        else:
1620
+            # TODO: handle case of width or hight == 0
1621
+            self.zoom_ratio = min(
1622
+                float(rect.width)/float(width),
1623
+                float(rect.height)/float(height)
1624
+            )
1621 1625
         self.zoom_to_fit_on_resize = False
1622 1626
         self.x = (x1 + x2) / 2
1623 1627
         self.y = (y1 + y2) / 2