[Sugar-devel] [PATCH Paint v2] Center images smaller than the canvas SL #3677

Manuel Quiñones manuq at laptop.org
Tue Jun 19 17:08:37 EDT 2012


2012/6/19 Manuel Kaufmann <humitos at gmail.com>:
> Rotate and center the image.

Pushed.  Thanks!

> Besides, if a smaller (than the
> canvas) image is opened it is centered on the screen.

No need to clarify that, was a regression in your previous patch, but
I'm fine with the patch as is.

> 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
>
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel



-- 
.. manuq ..


More information about the Sugar-devel mailing list