[Sugar-devel] [PATCH Paint v2] Center images smaller than the canvas SL #3677
Manuel Kaufmann
humitos at gmail.com
Tue Jun 19 13:51:23 EDT 2012
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 at 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/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()
--
1.7.10.2
More information about the Sugar-devel
mailing list