From 43e9b26891c76448f4a37aa2fec272321c560cf0 Mon Sep 17 00:00:00 2001 From: akshayaurora Date: Sun, 17 Jul 2011 15:44:55 +0530 Subject: [PATCH 1/2] keep_ratio BooleanProperty for uix.Image --- kivy/uix/image.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/kivy/uix/image.py b/kivy/uix/image.py index 12bcac68a..ac9a38982 100644 --- a/kivy/uix/image.py +++ b/kivy/uix/image.py @@ -127,6 +127,19 @@ class Image(Widget): default to False ''' + keep_ratio = BooleanProperty(True) + '''If False along with allow_stretch being True, the normalized image + size will be maximized to fit in the image box disregarding the image + ratio. + Otherwise, if the box is too high, the image will be not strech more + than 1:1 pixels + + .. versionadded:: 1.0.7 + + :data:`keep_ratio` is a :class:`~kivy.properties.BooleanProperty`, + default to True + ''' + def get_norm_image_size(self): if not self.texture: return self.size @@ -136,6 +149,8 @@ class Image(Widget): # ensure that the width is always maximized to the containter width if self.allow_stretch: + if not self.keep_ratio: + return w, h iw = w else: iw = min(w, tw) From aa5cbe702c872c122695b784f0041dfc06209339 Mon Sep 17 00:00:00 2001 From: akshayaurora Date: Tue, 19 Jul 2011 21:00:03 +0530 Subject: [PATCH 2/2] change add version to 1.0.8 --- kivy/uix/image.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kivy/uix/image.py b/kivy/uix/image.py index ac9a38982..aceb5a1c5 100644 --- a/kivy/uix/image.py +++ b/kivy/uix/image.py @@ -134,7 +134,7 @@ class Image(Widget): Otherwise, if the box is too high, the image will be not strech more than 1:1 pixels - .. versionadded:: 1.0.7 + .. versionadded:: 1.0.8 :data:`keep_ratio` is a :class:`~kivy.properties.BooleanProperty`, default to True