Repository: MyreMylar/pygame_gui
Pull request #545 (2024-03-16 10:28:45)

Add Auto Scrolling Container
Step 8 of splitting mega-PR #494 into smaller easier to review PRs


Patch:
diff --git a/pygame_gui/elements/__init__.py b/pygame_gui/elements/__init__.py
index 4338f3d..b9a3c3a 100644
--- a/pygame_gui/elements/__init__.py
+++ b/pygame_gui/elements/__init__.py
@@ -19,6 +19,7 @@ from pygame_gui.elements.ui_window import UIWindow
 from pygame_gui.elements.ui_scrolling_container import UIScrollingContainer
 from pygame_gui.elements.ui_text_entry_box import UITextEntryBox
 from pygame_gui.elements.ui_auto_resizing_container import UIAutoResizingContainer
+from pygame_gui.elements.ui_auto_scrolling_container import UIAutoScrollingContainer
 
 
 __all__ = ['UIImage',
@@ -42,4 +43,6 @@ __all__ = ['UIImage',
            'UIWindow',
            'UIScrollingContainer',
            'UITextEntryBox',
-           'UIAutoResizingContainer']
+           'UIAutoResizingContainer',
+           'UIAutoScrollingContainer'
+           ]
diff --git a/pygame_gui/elements/ui_auto_resizing_container.py b/pygame_gui/elements/ui_auto_resizing_container.py
index e9f8051..4d1ff06 100644
--- a/pygame_gui/elements/ui_auto_resizing_container.py
+++ b/pygame_gui/elements/ui_auto_resizing_container.py
@@ -56,7 +56,7 @@ class UIAutoResizingContainer(UIContainer):
                          object_id=object_id,
                          anchors=anchors,
                          visible=visible,
-                         element_id=['scrolling_container']
+                         element_id=['auto_resizing_container']
                          )
 
         self.min_edges_rect = min_edges_rect
diff --git a/pygame_gui/elements/ui_auto_scrolling_container.py b/pygame_gui/elements/ui_auto_scrolling_container.py
new file mode 100644
index 0000000..beb47c0
--- /dev/null
+++ b/pygame_gui/elements/ui_auto_scrolling_container.py
@@ -0,0 +1,101 @@
+import pygame
+from pygame_gui.core import UIElement, ObjectID
+from pygame_gui.core.interfaces import IUIManagerInterface, IContainerLikeInterface
+from pygame_gui.elements import UIScrollingContainer, UIAutoResizingContainer
+
+from typing import *
+
+
+class UIAutoScrollingContainer(UIScrollingContainer):
+    """
+    A container like UI element that lets users scroll around a larger container of content with
+    scroll bars. Also allows to prevent adding scroll bars to the horizontal or vertical axis.
+
+    :param relative_rect: The size and relative position of the container. This will also be the
+                          starting size of the scrolling area.
+    :param manager: The UI manager for this element. If not provided or set to None,
+                    it will try to use the first UIManager that was created by your application.
+    :param starting_height: The starting layer height of this container above its container.
+                            Defaults to 1.
+    :param container: The container this container is within. Defaults to None (which is the root
+                      container for the UI)
+    :param parent_element: A parent element for this container. Defaults to None, or the
+                           container if you've set that.
+    :param object_id: An object ID for this element.
+    :param anchors: Layout anchors in a dictionary.
+    :param visible: Whether the element is visible by default. Warning - container visibility
+                    may override this.
+    """
+
+    def __init__(self,
+                 relative_rect: pygame.Rect,
+                 manager: Optional[IUIManagerInterface] = None,
+                 allow_scroll_x: bool = True,
+                 allow_scroll_y: bool = True,
+                 *,
+                 starting_height: int = 1,
+                 container: Optional[IContainerLikeInterface] = None,
+                 parent_element: Optional[UIElement] = None,
+                 object_id: Optional[Union[ObjectID, str]] = None,
+                 anchors: Optional[Dict[str, Union[str, UIElement]]] = None,
+                 visible: int = 1):
+        super().__init__(relative_rect, manager,
+                         allow_scroll_x=allow_scroll_x,
+                         allow_scroll_y=allow_scroll_y,
+                         starting_height=starting_height,
+                         container=container,
+                         parent_element=parent_element,
+                         object_id=object_id,
+                         anchors=anchors,
+                         visible=visible,
+                         element_id=["auto_scrolling_container"])
+
+        resize_left: bool = True
+        resize_right: bool = True
+        resize_top: bool = True
+        resize_bottom: bool = True
+
+        anchors = {"left": "left",
+                   "right": "left",
+                   "top": "top",
+                   "bottom": "top"}
+
+        if not self.allow_scroll_x:
+            resize_left = False
+            resize_right = False
+            anchors["right"] = "right"
+
+        if not self.allow_scroll_y:
+            resize_top = False
+            resize_bottom = False
+            anchors["bottom"] = "bottom"
+
+        self.scrollable_container.kill()
+        scrollable_rect = pygame.Rect(0, 0, relative_rect.width, relative_rect.height)
+        self.scrollable_container = UIAutoResizingContainer(relative_rect=scrollable_rect,
+                                                            manager=manager,
+                                                            resize_left=resize_left,
+                                                            resize_right=resize_right,
+                                                            resize_top=resize_top,
+                                                            resize_bottom=resize_bottom,
+                                                            starting_height=0,
+                                                            container=self._view_container,
+                                                            parent_element=parent_element,
+                                                            object_id=ObjectID(
+                                                                object_id="#scrollable_container",
+                                                                class_id=None),
+                                                            anchors=anchors)
+
+    def update(self, time_delta: float):
+        """
+        Updates the scrolling container's position based upon the scroll bars and updates the
+        scrollbar's visible percentage as well if that has changed.
+
+        :param time_delta: The time passed between frames, measured in seconds.
+
+        """
+        super().update(time_delta)
+
+        if self.scrollable_container.has_recently_updated_dimensions:
+            self._calculate_scrolling_dimensions()
+            self._sort_out_element_container_scroll_bars()
diff --git a/pygame_gui/elements/ui_scrolling_container.py b/pygame_gui/elements/ui_scrolling_container.py
index 7ff254e..80a91c3 100644
--- a/pygame_gui/elements/ui_scrolling_container.py
+++ b/pygame_gui/elements/ui_scrolling_container.py
@@ -1,4 +1,4 @@
-from typing import Union, Dict, Tuple, Optional
+from typing import Union, Dict, Tuple, Optional, List
 
 import pygame
 
@@ -39,6 +39,7 @@ class UIScrollingContainer(UIElement, IContainerLikeInterface):
                  container: Optional[IContainerLikeInterface] = None,
                  parent_element: Optional[UIElement] = None,
                  object_id: Optional[Union[ObjectID, str]] = None,
+                 element_id: Union[List[str], None] = None,
                  anchors: Optional[Dict[str, Union[str, UIElement]]] = None,
                  visible: int = 1,
                  allow_scroll_x: bool = True,
@@ -47,6 +48,8 @@ class UIScrollingContainer(UIElement, IContainerLikeInterface):
         # Need to move some declarations early as they are indirectly referenced via the ui element
         # constructor
         self._root_container = None
+        if element_id is None:
+            element_id = ['scrolling_container']
         super().__init__(relative_rect,
                          manager,
                          container,
@@ -56,7 +59,7 @@ class UIScrollingContainer(UIElement, IContainerLikeInterface):
                          visible=visible,
                          parent_element=parent_element,
                          object_id=object_id,
-                         element_id=['scrolling_container'])
+                         element_id=element_id)
 
         self.scroll_bar_width = 0
         self.scroll_bar_height = 0
@@ -302,6 +305,10 @@ class UIScrollingContainer(UIElement, IContainerLikeInterface):
                                                                     'top': 'top',
                                                                     'bottom': 'bottom'})
                 self.join_focus_sets(self.vert_scroll_bar)
+                start_percent = ((self._view_container.rect.top -
+                                  self.scrollable_container.rect.top)
+                                 / self.scrolling_height)
+                self.vert_scroll_bar.set_scroll_from_start_percentage(start_percent)
             else:
                 start_percent = ((self._view_container.rect.top -
                                   self.scrollable_container.rect.top)
@@ -331,6 +338,12 @@ class UIScrollingContainer(UIElement, IContainerLikeInterface):
                                                                        'top': 'bottom',
                                                                        'bottom': 'bottom'})
                 self.join_focus_sets(self.horiz_scroll_bar)
+
+                start_percent = ((self._view_container.rect.left -
+                                  self.scrollable_container.rect.left)
+                                 / self.scrolling_width)
+                self.horiz_scroll_bar.set_scroll_from_start_percentage(start_percent)
+
             else:
                 start_percent = ((self._view_container.rect.left -
                                   self.scrollable_container.rect.left)


Test patch:
diff --git a/tests/test_elements/test_ui_auto_scrolling_container.py b/tests/test_elements/test_ui_auto_scrolling_container.py
new file mode 100644
index 0000000..b9f55d7
--- /dev/null
+++ b/tests/test_elements/test_ui_auto_scrolling_container.py
@@ -0,0 +1,402 @@
+import pytest
+import pygame
+
+from tests.shared_comparators import compare_surfaces
+
+from pygame_gui.ui_manager import UIManager
+from pygame_gui.elements.ui_auto_scrolling_container import UIAutoScrollingContainer
+from pygame_gui.elements.ui_button import UIButton
+from pygame_gui.core.interfaces import IUIManagerInterface
+
+
+class TestUIAutoScrollingContainer:
+
+    def test_creation(self, _init_pygame, default_ui_manager,
+                      _display_surface_return_none):
+        UIAutoScrollingContainer(relative_rect=pygame.Rect(100, 100, 400, 400),
+                                 manager=default_ui_manager)
+
+    def test_get_container(self, _init_pygame, default_ui_manager: IUIManagerInterface,
+                           _display_surface_return_none):
+        container = UIAutoScrollingContainer(pygame.Rect(100, 100, 200, 200),
+                                             manager=default_ui_manager)
+        assert container.get_container() == container.scrollable_container
+
+    def test_add_element(self, _init_pygame, default_ui_manager: IUIManagerInterface,
+                         _display_surface_return_none):
+        container = UIAutoScrollingContainer(pygame.Rect(100, 100, 200, 200),
+                                             manager=default_ui_manager)
+
+        button = UIButton(relative_rect=pygame.Rect(0, 0, 50, 50), text="",
+                          manager=default_ui_manager)
+        default_ui_manager.get_root_container().remove_element(button)
+        container.get_container().add_element(button)
+        assert len(container.get_container().elements) == 1
+
+        button = UIButton(relative_rect=pygame.Rect(0, 0, 50, 250), text="",
+                          manager=default_ui_manager)
+        default_ui_manager.get_root_container().remove_element(button)
+        container.get_container().add_element(button)
+        container.scrollable_container.update(0.4)
+        container.update(0.4)
+        assert len(container.get_container().elements) == 2
+
+    def test_remove_element(self, _init_pygame, default_ui_manager: IUIManagerInterface,
+                            _display_surface_return_none):
+        container = UIAutoScrollingContainer(pygame.Rect(100, 100, 200, 200),
+                                             manager=default_ui_manager)
+
+        button = UIButton(relative_rect=pygame.Rect(0, 0, 50, 50), text="",
+                          manager=default_ui_manager,
+                          container=container)
+
+        container.get_container().remove_element(button)
+        assert len(container.get_container().elements) == 0
+
+    def test_set_position(self, _init_pygame, default_ui_manager,
+                          _display_surface_return_none):
+        container = UIAutoScrollingContainer(pygame.Rect(100, 100, 200, 200),
+                                             manager=default_ui_manager)
+
+        container.set_position((50, 50))
+
+        assert container.rect.topleft == (50, 50)
+        assert container._root_container.rect.size == (200, 200)
+
+    def test_set_relative_position(self, _init_pygame, default_ui_manager,
+                                   _display_surface_return_none):
+        container = UIAutoScrollingContainer(pygame.Rect(100, 100, 200, 200),
+                                             manager=default_ui_manager)
+        container_2 = UIAutoScrollingContainer(pygame.Rect(50, 50, 50, 50),
+                                               manager=default_ui_manager,
+                                               container=container)
+
+        container_2.set_relative_position((25, 25))
+
+        assert container_2.rect.topleft == (125, 125)
+
+    def test_set_dimensions(self, _init_pygame, default_ui_manager,
+                            _display_surface_return_none):
+        container = UIAutoScrollingContainer(pygame.Rect(100, 100, 200, 200),
+                                             manager=default_ui_manager)
+
+        container.set_dimensions((50, 50))
+
+        assert container.rect.size == (50, 50)
+
+        container.set_scrollable_area_dimensions((500, 600))
+
+        container.set_dimensions((400, 500))
+
+        assert container.rect.size == (400, 500)
+
+        container.set_dimensions((500, 600))
+
+        assert container.rect.size == (500, 600)
+
+    def test_kill(self, _init_pygame, default_ui_manager,
+                  _display_surface_return_none):
+        container = UIAutoScrollingContainer(pygame.Rect(100, 100, 200, 200),
+                                             manager=default_ui_manager)
+        container_2 = UIAutoScrollingContainer(pygame.Rect(50, 50, 50, 50),
+                                               manager=default_ui_manager,
+                                               container=container)
+
+        button = UIButton(relative_rect=pygame.Rect(20, 20, 30, 20), text="X",
+                          manager=default_ui_manager, container=container_2)
+
+        container.kill()
+
+        assert not button.alive()
+        assert not container_2.alive()
+        assert not container.alive()
+
+    def test_set_scrollable_area_dimensions(self, _init_pygame, default_ui_manager,
+                                            _display_surface_return_none):
+        container = UIAutoScrollingContainer(pygame.Rect(100, 100, 200, 200),
+                                             manager=default_ui_manager)
+
+        container.set_scrollable_area_dimensions((500, 600))
+
+        assert container.vert_scroll_bar is not None
+        assert container.horiz_scroll_bar is not None
+        assert container.scrollable_container.rect.size == (500, 600)
+        assert container._view_container.rect.size == (200 - container.vert_scroll_bar.rect.width,
+                                                       200 - container.horiz_scroll_bar.rect.height)
+
+    def test_set_scrollable_area_dimensions_constrained_x_axis(self, _init_pygame, default_ui_manager,
+                                                               _display_surface_return_none):
+        container = UIAutoScrollingContainer(pygame.Rect(100, 100, 200, 200),
+                                             manager=default_ui_manager,
+                                             allow_scroll_x=False)
+
+        assert container.vert_scroll_bar is None
+        assert container.horiz_scroll_bar is None
+        assert container.scrollable_container.rect.size == (200, 200)
+
+        container.set_scrollable_area_dimensions((200, 600))
+
+        assert container.vert_scroll_bar is not None
+        assert container.horiz_scroll_bar is None
+        assert container._view_container.rect.size == (200 - container.vert_scroll_bar.rect.width,
+                                                       200)
+        assert container.scrollable_container.rect.size == (200 - container.vert_scroll_bar.rect.width, 600)
+
+    def test_set_scrollable_area_dimensions_constrained_y_axis(self, _init_pygame, default_ui_manager,
+                                                               _display_surface_return_none):
+        container = UIAutoScrollingContainer(pygame.Rect(100, 100, 200, 200),
+                                             manager=default_ui_manager,
+                                             allow_scroll_y=False)
+
+        assert container.vert_scroll_bar is None
+        assert container.horiz_scroll_bar is None
+        assert container.scrollable_container.rect.size == (200, 200)
+
+        container.set_scrollable_area_dimensions((600, 200))
+
+        assert container.vert_scroll_bar is None
+        assert container.horiz_scroll_bar is not None
+        assert container._view_container.rect.size == (200,
+                                                       200 - container.horiz_scroll_bar.rect.height)
+        assert container.scrollable_container.rect.size == (600,
+                                                            200 - container.horiz_scroll_bar.rect.height)
+
+    def test_update(self, _init_pygame, default_ui_manager,
+                    _display_surface_return_none):
+        container = UIAutoScrollingContainer(pygame.Rect(100, 100, 200, 200),
+                                             manager=default_ui_manager)
+
+        container.set_scrollable_area_dimensions((500, 600))
+
+        container.horiz_scroll_bar.scroll_wheel_right = True
+        container.horiz_scroll_bar.update(0.02)
+
+        container.update(0.02)
+
+        assert container.get_container().get_relative_rect().x == -37
+
+        container.vert_scroll_bar.scroll_wheel_moved = True
+        container.vert_scroll_bar.scroll_wheel_amount = -1.0
+        container.vert_scroll_bar.update(0.02)
+
+        container.update(0.02)
+
+        assert container.get_container().get_relative_rect().y == -67
+
+        container.horiz_scroll_bar.scroll_wheel_right = True
+        container.horiz_scroll_bar.update(0.02)
+        container.horiz_scroll_bar.start_percentage = 0.6
+        container.update(0.02)
+        container.horiz_scroll_bar.scroll_wheel_right = True
+        container.horiz_scroll_bar.update(0.02)
+        container.update(0.02)
+        container.horiz_scroll_bar.scroll_wheel_right = True
+        container.horiz_scroll_bar.update(0.02)
+        container.scrolling_right = container._view_container.rect.right - 1
+        container.update(0.02)
+
+        container.horiz_scroll_bar.scroll_wheel_left = True
+        container.horiz_scroll_bar.update(0.02)
+        container.update(0.02)
+        container.horiz_scroll_bar.scroll_wheel_left = True
+        container.horiz_scroll_bar.update(0.02)
+        container.update(0.02)
+        container.horiz_scroll_bar.scroll_wheel_left = True
+        container.horiz_scroll_bar.update(0.02)
+        container.update(0.02)
+
+        container.scrollable_container.set_dimensions((150, 600))
+        container.horiz_scroll_bar.scroll_wheel_left = True
+        container.horiz_scroll_bar.update(0.02)
+        container.update(0.02)
+
+        container.vert_scroll_bar.scroll_wheel_moved = True
+        container.vert_scroll_bar.scroll_wheel_amount = -5.0
+        container.vert_scroll_bar.update(0.02)
+        container.update(0.02)
+        container.vert_scroll_bar.scroll_wheel_moved = True
+        container.vert_scroll_bar.scroll_wheel_amount = -5.0
+        container.vert_scroll_bar.update(0.02)
+        container.update(0.02)
+        container.vert_scroll_bar.scroll_wheel_moved = True
+        container.vert_scroll_bar.scroll_wheel_amount = -5.0
+        container.vert_scroll_bar.update(0.02)
+        container.update(0.02)
+
+        container.vert_scroll_bar.scroll_wheel_moved = True
+        container.vert_scroll_bar.scroll_wheel_amount = 5.0
+        container.vert_scroll_bar.update(0.02)
+        container.update(0.02)
+        container.vert_scroll_bar.scroll_wheel_moved = True
+        container.vert_scroll_bar.scroll_wheel_amount = 5.0
+        container.vert_scroll_bar.update(0.02)
+        container.update(0.02)
+        container.vert_scroll_bar.scroll_wheel_moved = True
+        container.vert_scroll_bar.scroll_wheel_amount = 5.0
+        container.vert_scroll_bar.update(0.02)
+        container.update(0.02)
+
+        container.scrollable_container.set_dimensions((150, 150))
+
+        container.update(0.02)
+        container.update(0.02)
+        container.update(0.02)
+
+        container = UIAutoScrollingContainer(pygame.Rect(100, 100, 200, 200),
+                                             manager=default_ui_manager)
+
+        container.set_scrollable_area_dimensions((500, 600))
+
+        container.vert_scroll_bar.scroll_wheel_moved = True
+        container.vert_scroll_bar.scroll_wheel_amount = 5.0
+        container.vert_scroll_bar.update(0.02)
+
+        container.scrollable_container.rect.top = -500  # scroll it too high and then update
+        container.update(0.02)
+
+    def test_disable(self, _init_pygame: None, default_ui_manager: UIManager,
+                     _display_surface_return_none: None):
+        container = UIAutoScrollingContainer(pygame.Rect(100, 100, 200, 200),
+                                             manager=default_ui_manager)
+        button_1 = UIButton(relative_rect=pygame.Rect(10, 10, 150, 30),
+                            text="Test Button",
+                            tool_tip_text="This is a test of the button's tool tip functionality.",
+                            manager=default_ui_manager,
+                            container=container)
+
+        button_2 = UIButton(relative_rect=pygame.Rect(10, 50, 150, 30),
+                            text="Test Button 2",
+                            manager=default_ui_manager,
+                            container=container)
+
+        container.disable()
+
+        assert container.is_enabled is False
+        assert button_1.is_enabled is False
+        assert button_2.is_enabled is False
+
+        # process a mouse button down event
+        button_1.process_event(
+            pygame.event.Event(pygame.MOUSEBUTTONDOWN, {'button': 1, 'pos': button_1.rect.center}))
+
+        # process a mouse button up event
+        button_1.process_event(
+            pygame.event.Event(pygame.MOUSEBUTTONUP, {'button': 1, 'pos': button_1.rect.center}))
+
+        button_1.update(0.01)
+
+        assert button_1.check_pressed() is False
+
+    def test_enable(self, _init_pygame: None, default_ui_manager: UIManager,
+                    _display_surface_return_none: None):
+        container = UIAutoScrollingContainer(pygame.Rect(100, 100, 200, 200),
+                                             manager=default_ui_manager)
+        button_1 = UIButton(relative_rect=pygame.Rect(10, 10, 150, 30),
+                            text="Test Button",
+                            tool_tip_text="This is a test of the button's tool tip functionality.",
+                            manager=default_ui_manager,
+                            container=container)
+
+        button_2 = UIButton(relative_rect=pygame.Rect(10, 50, 150, 30),
+                            text="Test Button 2",
+                            manager=default_ui_manager,
+                            container=container)
+
+        container.disable()
+        container.enable()
+
+        assert container.is_enabled is True
+        assert button_1.is_enabled is True
+        assert button_2.is_enabled is True
+
+        # process a mouse button down event
+        button_1.process_event(
+            pygame.event.Event(pygame.MOUSEBUTTONDOWN, {'button': 1, 'pos': button_1.rect.center}))
+
+        # process a mouse button up event
+        button_1.process_event(
+            pygame.event.Event(pygame.MOUSEBUTTONUP, {'button': 1, 'pos': button_1.rect.center}))
+
+        button_1.update(0.01)
+
+        assert button_1.check_pressed() is True
+
+    def test_show(self, _init_pygame, default_ui_manager,
+                  _display_surface_return_none):
+        container = UIAutoScrollingContainer(relative_rect=pygame.Rect(100, 100, 400, 400),
+                                             manager=default_ui_manager, visible=0)
+        container.set_scrollable_area_dimensions((500, 600))
+
+        assert container.visible == 0
+
+        assert container._root_container.visible == 0
+        assert container._view_container.visible == 0
+        assert container.horiz_scroll_bar.visible == 0
+        assert container.vert_scroll_bar.visible == 0
+        assert container.scrollable_container.visible == 0
+
+        container.show()
+
+        assert container.visible == 1
+
+        assert container._root_container.visible == 1
+        assert container._view_container.visible == 1
+        assert container.horiz_scroll_bar.visible == 1
+        assert container.vert_scroll_bar.visible == 1
+        assert container.scrollable_container.visible == 1
+
+    def test_hide(self, _init_pygame, default_ui_manager,
+                  _display_surface_return_none):
+        container = UIAutoScrollingContainer(relative_rect=pygame.Rect(100, 100, 400, 400),
+                                             manager=default_ui_manager)
+        container.set_scrollable_area_dimensions((500, 600))
+
+        assert container.visible == 1
+
+        assert container._root_container.visible == 1
+        assert container._view_container.visible == 1
+        assert container.horiz_scroll_bar.visible == 1
+        assert container.vert_scroll_bar.visible == 1
+        assert container.scrollable_container.visible == 1
+
+        container.hide()
+
+        assert container.visible == 0
+
+        assert container._root_container.visible == 0
+        assert container._view_container.visible == 0
+        assert container.horiz_scroll_bar.visible == 0
+        assert container.vert_scroll_bar.visible == 0
+        assert container.scrollable_container.visible == 0
+
+    def test_show_hide_rendering(self, _init_pygame, default_ui_manager, _display_surface_return_none):
+        resolution = (400, 400)
+        empty_surface = pygame.Surface(resolution)
+        empty_surface.fill(pygame.Color(0, 0, 0))
+
+        surface = empty_surface.copy()
+        manager = UIManager(resolution)
+
+        container = UIAutoScrollingContainer(relative_rect=pygame.Rect(100, 100, 200, 100),
+                                             manager=manager,
+                                             visible=0)
+        container.set_scrollable_area_dimensions((600, 600))
+        manager.update(0.01)
+        manager.draw_ui(surface)
+        assert compare_surfaces(empty_surface, surface)
+
+        surface.fill(pygame.Color(0, 0, 0))
+        container.show()
+        manager.update(0.01)
+        manager.draw_ui(surface)
+        assert not compare_surfaces(empty_surface, surface)
+
+        surface.fill(pygame.Color(0, 0, 0))
+        container.hide()
+        manager.update(0.01)
+        manager.draw_ui(surface)
+        assert compare_surfaces(empty_surface, surface)
+
+
+if __name__ == '__main__':
+    pytest.console_main()