Ticket #3677: 0001-Center-images-smaller-than-the-canvas-SL-3677.2.patch

File 0001-Center-images-smaller-than-the-canvas-SL-3677.2.patch, 1.4 KB (added by humitos, 12 years ago)

Version 2

  • OficinaActivity.py

    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): 
    201201        canvas_width = self.canvas.allocation.width
    202202        canvas_height = self.canvas.allocation.height
    203203        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)
    206208        return x, y
    207209
    208210    def center_area(self):
    209211        x, y = self._get_area_displacement()
    210         self.fixed.move(self.area, x, 0)
     212        self.fixed.move(self.area, x, y)
    211213
    212214    def move_textview(self, dx, dy):
    213215        x, y = self._get_area_displacement()