From: Marius Gedminas <marius@gedmin.as>
... | ... |
@@ -737,6 +737,7 @@ class ZoomToAnimation(MoveToAnimation): |
737 | 737 |
def animate(self, t): |
738 | 738 |
a, b, c = self.source_zoom, self.extra_zoom, self.target_zoom |
739 | 739 |
self.dot_widget.zoom_ratio = c*t + b*t*(1-t) + a*(1-t) |
740 |
+ self.dot_widget.zoom_to_fit_on_resize = False |
|
740 | 741 |
MoveToAnimation.animate(self, t) |
741 | 742 |
|
742 | 743 |
|
... | ... |
@@ -813,6 +814,7 @@ class ZoomAction(DragAction): |
813 | 814 |
|
814 | 815 |
def drag(self, deltax, deltay): |
815 | 816 |
self.dot_widget.zoom_ratio *= 1.005 ** (deltax + deltay) |
817 |
+ self.dot_widget.zoom_to_fit_on_resize = False |
|
816 | 818 |
self.dot_widget.queue_draw() |
817 | 819 |
|
818 | 820 |
def stop(self): |
... | ... |
@@ -871,11 +873,13 @@ class DotWidget(gtk.DrawingArea): |
871 | 873 |
self.add_events(gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.POINTER_MOTION_HINT_MASK | gtk.gdk.BUTTON_RELEASE_MASK) |
872 | 874 |
self.connect("motion-notify-event", self.on_area_motion_notify) |
873 | 875 |
self.connect("scroll-event", self.on_area_scroll_event) |
876 |
+ self.connect("size-allocate", self.on_area_size_allocate) |
|
874 | 877 |
|
875 | 878 |
self.connect('key-press-event', self.on_key_press_event) |
876 | 879 |
|
877 | 880 |
self.x, self.y = 0.0, 0.0 |
878 | 881 |
self.zoom_ratio = 1.0 |
882 |
+ self.zoom_to_fit_on_resize = False |
|
879 | 883 |
self.animation = NoAnimation(self) |
880 | 884 |
self.drag_action = NullAction(self) |
881 | 885 |
self.presstime = None |
... | ... |
@@ -954,6 +958,7 @@ class DotWidget(gtk.DrawingArea): |
954 | 958 |
self.x = self.graph.width/2 |
955 | 959 |
self.y = self.graph.height/2 |
956 | 960 |
self.zoom_ratio = zoom_ratio |
961 |
+ self.zoom_to_fit_on_resize = False |
|
957 | 962 |
self.queue_draw() |
958 | 963 |
|
959 | 964 |
def zoom_to_area(self, x1, y1, x2, y2): |
... | ... |
@@ -964,6 +969,7 @@ class DotWidget(gtk.DrawingArea): |
964 | 969 |
float(rect.width)/float(width), |
965 | 970 |
float(rect.height)/float(height) |
966 | 971 |
) |
972 |
+ self.zoom_to_fit_on_resize = False |
|
967 | 973 |
self.x = (x1 + x2) / 2 |
968 | 974 |
self.y = (y1 + y2) / 2 |
969 | 975 |
self.queue_draw() |
... | ... |
@@ -979,6 +985,7 @@ class DotWidget(gtk.DrawingArea): |
979 | 985 |
float(rect.height)/float(self.graph.height) |
980 | 986 |
) |
981 | 987 |
self.zoom_image(zoom_ratio, center=True) |
988 |
+ self.zoom_to_fit_on_resize = True |
|
982 | 989 |
|
983 | 990 |
ZOOM_INCREMENT = 1.25 |
984 | 991 |
ZOOM_TO_FIT_MARGIN = 12 |
... | ... |
@@ -1093,6 +1100,10 @@ class DotWidget(gtk.DrawingArea): |
1093 | 1100 |
self.drag_action.on_motion_notify(event) |
1094 | 1101 |
return True |
1095 | 1102 |
|
1103 |
+ def on_area_size_allocate(self, area, allocation): |
|
1104 |
+ if self.zoom_to_fit_on_resize: |
|
1105 |
+ self.zoom_to_fit() |
|
1106 |
+ |
|
1096 | 1107 |
def animate_to(self, x, y): |
1097 | 1108 |
self.animation = ZoomToAnimation(self, x, y) |
1098 | 1109 |
self.animation.start() |