Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel QuiƱones <manuq@laptop.org>2013-05-16 18:43:13 (GMT)
committer Agustin Zubiaga <aguz@localhost.localdomain>2013-06-03 19:07:02 (GMT)
commit0554f844bc42a1525ba1792ea8c5a194b08c226f (patch)
tree7f700f37b738028f77ca4b2929f89d0d47f52338
parent8db37d787d4938d0f982c2676bfb4e52224afddd (diff)
Revert changes done for the scrollbars in a5f346a1
-rw-r--r--ImageView.py53
1 files changed, 24 insertions, 29 deletions
diff --git a/ImageView.py b/ImageView.py
index 8b81ca9..be3a616 100644
--- a/ImageView.py
+++ b/ImageView.py
@@ -81,7 +81,7 @@ class ImageViewer(Gtk.DrawingArea):
self.queue_draw()
def _center_target_point(self):
- alloc = self.get_parent().get_allocation()
+ alloc = self.get_allocation()
self._target_point = (alloc.width / 2, alloc.height / 2)
def _center_anchor_point(self):
@@ -92,7 +92,7 @@ class ImageViewer(Gtk.DrawingArea):
# If at the current size the image surface is smaller than the
# available space, center it on the canvas.
- alloc = self.get_parent().get_allocation()
+ alloc = self.get_allocation()
scaled_width = self._surface.get_width() * self._zoom
scaled_height = self._surface.get_height() * self._zoom
@@ -102,18 +102,11 @@ class ImageViewer(Gtk.DrawingArea):
self._center_anchor_point()
self.queue_draw()
- def _do_set_zoom(self, zoom):
- self._zoom = zoom
-
- # Update size and scroll window
- width = int(self._surface.get_width() * self._zoom)
- height = int(self._surface.get_height() * self._zoom)
- self.set_size_request(width, height)
-
def set_zoom(self, zoom):
if zoom < ZOOM_MIN or zoom > ZOOM_MAX:
return
- self._do_set_zoom(zoom)
+ self._zoom = zoom
+ self.queue_draw()
def get_zoom(self):
return self._zoom
@@ -127,39 +120,42 @@ class ImageViewer(Gtk.DrawingArea):
def zoom_in(self):
if not self.can_zoom_in():
return
- self._do_set_zoom(self._zoom + ZOOM_STEP)
+ self._zoom += ZOOM_STEP
+ self.queue_draw()
def zoom_out(self):
if not self.can_zoom_out():
return
- self._do_set_zoom(self._zoom - ZOOM_STEP)
+ self._zoom -= ZOOM_MIN
+
self._center_if_small()
+ self.queue_draw()
def zoom_to_fit(self):
# This tries to figure out a best fit model
# If the image can fit in, we show it in 1:1,
# in any other case we show it in a fit to screen way
- alloc = self.get_parent().get_allocation()
+ alloc = self.get_allocation()
surface_width = self._surface.get_width()
surface_height = self._surface.get_height()
- zoom = None
if alloc.width < surface_width or alloc.height < surface_height:
# Image is larger than allocated size
- zoom = min(alloc.width * 1.0 / surface_width,
- alloc.height * 1.0 / surface_height)
+ self._zoom = min(alloc.width * 1.0 / surface_width,
+ alloc.height * 1.0 / surface_height)
else:
- zoom = 1.0
- self._do_set_zoom(zoom)
+ self._zoom = 1.0
+
self._center_target_point()
self._center_anchor_point()
self.queue_draw()
def zoom_original(self):
- self._do_set_zoom(1)
+ self._zoom = 1
self._center_if_small()
+ self.queue_draw()
def start_dragtouch(self, coords):
self._in_dragtouch = True
@@ -167,7 +163,7 @@ class ImageViewer(Gtk.DrawingArea):
prev_target_point = self._target_point
# Set target point to the relative coordinates of this view.
- alloc = self.get_parent().get_allocation()
+ alloc = self.get_allocation()
self._target_point = (coords[1], coords[2])
# Calculate the new anchor point.
@@ -214,7 +210,7 @@ class ImageViewer(Gtk.DrawingArea):
prev_target_point = self._target_point
# Set target point to the relative coordinates of this view.
- alloc = self.get_parent().get_allocation()
+ alloc = self.get_allocation()
self._target_point = (center[1] - alloc.x, center[2] - alloc.y)
# Calculate the new anchor point.
@@ -247,17 +243,17 @@ class ImageViewer(Gtk.DrawingArea):
self._in_zoomtouch = False
# Apply zoom
- zoom = self._zoom * self._zoomtouch_scale
+ self._zoom = self._zoom * self._zoomtouch_scale
self._zoomtouch_scale = 1
# Restrict zoom values
- if zoom < ZOOM_MIN:
- zoom = ZOOM_MIN
- elif zoom > ZOOM_MAX:
- zoom = ZOOM_MAX
+ if self._zoom < ZOOM_MIN:
+ self._zoom = ZOOM_MIN
+ elif self._zoom > ZOOM_MAX:
+ self._zoom = ZOOM_MAX
- self._do_set_zoom(zoom)
self._center_if_small()
+ self.queue_draw()
def rotate_anticlockwise(self):
self._surface = _rotate_surface(self._surface, -1)
@@ -305,7 +301,6 @@ class ImageViewer(Gtk.DrawingArea):
self._center_anchor_point()
ctx.translate(*self._target_point)
-
zoom_absolute = self._zoom * self._zoomtouch_scale
ctx.scale(zoom_absolute, zoom_absolute)