From 840f33c42cf5662551d9e0b151412838585ccd99 Mon Sep 17 00:00:00 2001 From: ppizarror Date: Sat, 25 Mar 2023 18:23:56 -0300 Subject: [PATCH 1/3] Fix overflow threshold because of new pygame rounding --- pygame_menu/menu.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pygame_menu/menu.py b/pygame_menu/menu.py index 0663379d..ab4cbcde 100644 --- a/pygame_menu/menu.py +++ b/pygame_menu/menu.py @@ -1617,20 +1617,24 @@ def _build_widget_surface(self) -> None: # Get scrollbars size sx, sy = self._get_scrollbar_thickness() + # Check if there is an overflow + overflow_x = max_x - (self._width - sy) > 1 + overflow_y = max_y - (self._height - sx - menubar_height) > 1 + # Remove the thick of the scrollbar to avoid displaying a horizontal one # If overflow on both axis - if max_x > self._width - sy and max_y > self._height - sx - menubar_height: + if overflow_x and overflow_y: width, height = max_x, max_y if not self._mouse_visible: self._mouse_visible = True # If horizontal overflow - elif max_x > self._width - sy: + elif overflow_x: width, height = max_x, self._height - menubar_height - sx self._mouse_visible = self._mouse_visible_default # If vertical overflow - elif max_y > self._height - sx - menubar_height: + elif overflow_y: width, height = self._width - sy, max_y if not self._mouse_visible: self._mouse_visible = True From 984da9a4f75dcb7cf9541a1158144a4c1bf1d7d4 Mon Sep 17 00:00:00 2001 From: ppizarror Date: Sat, 25 Mar 2023 18:24:07 -0300 Subject: [PATCH 2/3] Improve typing of get_at method --- pygame_menu/baseimage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygame_menu/baseimage.py b/pygame_menu/baseimage.py index 5109e473..93900575 100644 --- a/pygame_menu/baseimage.py +++ b/pygame_menu/baseimage.py @@ -424,7 +424,7 @@ def get_at( self, pos: Tuple2NumberType, ignore_alpha: bool = False - ) -> Union[Tuple3IntType, Tuple4IntType]: + ) -> Union[Tuple3IntType, Tuple4IntType, 'pygame.Color']: """ Get the color from a certain position in image on x-axis and y-axis (x, y). From 49022b21cf2a981cece0172ae063571f61861465 Mon Sep 17 00:00:00 2001 From: ppizarror Date: Sat, 25 Mar 2023 18:24:18 -0300 Subject: [PATCH 3/3] v4.4.0 --- pygame_menu/version.py | 2 +- test/_utils.py | 1 + test/test_widget_none.py | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pygame_menu/version.py b/pygame_menu/version.py index 892082ec..66a10dee 100644 --- a/pygame_menu/version.py +++ b/pygame_menu/version.py @@ -32,6 +32,6 @@ def __str__(self) -> str: patch = property(lambda self: self[2]) -vernum = Version(4, 3, 9) +vernum = Version(4, 4, 0) ver = str(vernum) rev = '' diff --git a/test/_utils.py b/test/_utils.py index 46b88295..9fef35e4 100644 --- a/test/_utils.py +++ b/test/_utils.py @@ -21,6 +21,7 @@ 'reset_widgets_over', 'sleep', 'surface', + 'test_reset_surface', # Class utils 'BaseTest', diff --git a/test/test_widget_none.py b/test/test_widget_none.py index e88d7ae8..69884230 100644 --- a/test/test_widget_none.py +++ b/test/test_widget_none.py @@ -261,7 +261,7 @@ def test_vfill(self) -> None: vf2.hide() vfill_total_after = vf1.get_height() + vf3.get_height() self.assertEqual(vf1.get_height(), vf3.get_height() + 1) - self.assertEqual(vfill_total, vfill_total_after - 1) + self.assertLessEqual(abs(vfill_total - vfill_total_after), 1) vf2.show() self.assertEqual(vfill_total, vf1.get_height() + vf2.get_height() + vf3.get_height()) @@ -269,7 +269,7 @@ def test_vfill(self) -> None: vf1_height_prev = vf1.get_height() b1_height = math.ceil(b1.get_height() / 3) b1.hide() - self.assertEqual(vf1.get_height(), vf1_height_prev + b1_height) + self.assertLessEqual(abs(vf1.get_height() - (vf1_height_prev + b1_height)), 1) b1.show() self.assertEqual(vf1.get_height(), vf1_height_prev)