# HG changeset patch # User Alain Leufroy # Date 1639918629 -3600 # Sun Dec 19 13:57:09 2021 +0100 # Node ID 8e69a26afabbcd73a1088cf735f9b52b4bd90630 # Parent 1bd04c04b076a1b2f6468bdc84daf21d571a22c9 main packer widget: preserve a little bit more the preferred user orientation for example, on a small screen size, if the user specify HORIZONTAL, when the screen is reduced, we preserve the horizontal orientation. diff --git a/lairucrem/widgets/mainwidget.py b/lairucrem/widgets/mainwidget.py --- a/lairucrem/widgets/mainwidget.py +++ b/lairucrem/widgets/mainwidget.py @@ -224,8 +224,13 @@ self._pile_widget.contents.toggle_maximize(value) def _guess_orientation(self, size): + old_cols = self._previous_size[0] if self._previous_size else ANY cols = size[0] - self._orientation = config.HORIZONTAL if cols > 160 else config.VERTICAL + # Note: `not (x <= y)` because of Any which always answers True + if cols > 160 and cols > old_cols: + self._orientation = config.HORIZONTAL + if cols <= 160 and cols < old_cols: + self._orientation = config.VERTICAL def keypress(self, size, key): """Process pressed key""" diff --git a/lairucrem/widgets/utils.py b/lairucrem/widgets/utils.py --- a/lairucrem/widgets/utils.py +++ b/lairucrem/widgets/utils.py @@ -97,4 +97,16 @@ def __eq__(self, _dummy): return True + __le__ = __eq__ + __lt__ = __eq__ + __gt__ = __eq__ + __ge__ = __eq__ + + def __getitem__(self, _dummy): + return self + + def __getattr__(self, _dummy): + return self + + ANY = Any()