From 1c91d96ed0da619337a465caea288c7821c2309d Mon Sep 17 00:00:00 2001
From: Manuel Kaufmann <humitos@gmail.com>
Date: Tue, 19 Jun 2012 14:48:00 -0300
Subject: [PATCH Paint v2] 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 <humitos@gmail.com>
---
OficinaActivity.py | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/OficinaActivity.py b/OficinaActivity.py
index 1745d0a..64dace4 100644
a
|
b
|
class OficinaActivity(activity.Activity): |
201 | 201 | canvas_width = self.canvas.allocation.width |
202 | 202 | canvas_height = self.canvas.allocation.height |
203 | 203 | area_width, area_height = self.area.get_size_request() |
204 | | x = (canvas_width - area_width) / 2 |
205 | | y = (canvas_height - area_height) / 2 |
| 204 | |
| 205 | # Avoid 'x' and 'y' to be outside the screen |
| 206 | x = max(0, (canvas_width - area_width) / 2) |
| 207 | y = max(0, (canvas_height - area_height) / 2) |
206 | 208 | return x, y |
207 | 209 | |
208 | 210 | def center_area(self): |
209 | 211 | x, y = self._get_area_displacement() |
210 | | self.fixed.move(self.area, x, 0) |
| 212 | self.fixed.move(self.area, x, y) |
211 | 213 | |
212 | 214 | def move_textview(self, dx, dy): |
213 | 215 | x, y = self._get_area_displacement() |