From 05379e0238aeda8b3f162cd718e0aff0d77371d2 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Tue, 19 Jun 2012 17:51:23 +0000 Subject: Center images smaller than the canvas SL #3677 Rotate and center the image. Besides, if a smaller (than the canvas) image is opened it is centered on the screen. Signed-off-by: Manuel Kaufmann Acked-by: Manuel QuiƱones --- (limited to 'OficinaActivity.py') diff --git a/OficinaActivity.py b/OficinaActivity.py index 1745d0a..64dace4 100644 --- a/OficinaActivity.py +++ b/OficinaActivity.py @@ -201,13 +201,15 @@ class OficinaActivity(activity.Activity): canvas_width = self.canvas.allocation.width canvas_height = self.canvas.allocation.height area_width, area_height = self.area.get_size_request() - x = (canvas_width - area_width) / 2 - y = (canvas_height - area_height) / 2 + + # Avoid 'x' and 'y' to be outside the screen + x = max(0, (canvas_width - area_width) / 2) + y = max(0, (canvas_height - area_height) / 2) return x, y def center_area(self): x, y = self._get_area_displacement() - self.fixed.move(self.area, x, 0) + self.fixed.move(self.area, x, y) def move_textview(self, dx, dy): x, y = self._get_area_displacement() -- cgit v0.9.1