コード例 #1
0
    def test_check_clicked_inside(self, _init_pygame, default_ui_manager,
                                  _display_surface_return_none: None):
        window = UIWindow(pygame.Rect(0, 0, 200, 200),
                          manager=default_ui_manager,
                          element_ids=[])
        clicked_inside = window.check_clicked_inside(
            pygame.event.Event(pygame.MOUSEBUTTONDOWN, {
                'button': 1,
                'pos': (100, 100)
            }))

        assert clicked_inside is True
コード例 #2
0
    def add_new_window(self, window: ui_window.UIWindow):
        """
        Adds a window to the top of the stack.

        :param window: The window to add.
        """
        if len(self.stack) > 0:
            new_layer = self.stack[-1].get_top_layer() + 1
        else:
            new_layer = 0
        window.change_window_layer(new_layer)
        self.stack.append(window)
コード例 #3
0
    def test_process_event(self, _init_pygame, default_ui_manager,
                           _display_surface_return_none: None):
        window = UIWindow(pygame.Rect(0, 0, 200, 200),
                          manager=default_ui_manager,
                          element_ids=[])
        processed_down_event = window.process_event(
            pygame.event.Event(pygame.MOUSEBUTTONDOWN, {
                'button': 1,
                'pos': (100, 100)
            }))

        assert processed_down_event is True
コード例 #4
0
ファイル: ui_manager.py プロジェクト: halfninja/pygame_gui
 def clear_and_reset(self):
     """
     Clear all existing windows, including the root window, which should get rid of all created UI elements.
     We then recreate the UIWindowStack and the root window.
     """
     self.ui_window_stack.clear()
     self.ui_window_stack = UIWindowStack(self.window_resolution)
     UIWindow(pygame.Rect((0, 0), self.window_resolution), self, ['root_window'])
コード例 #5
0
    def test_add_window(self, _init_pygame, default_ui_manager):
        stack = UIWindowStack((800, 600))
        window = UIWindow(pygame.Rect(100, 100, 200, 200),
                          manager=default_ui_manager,
                          element_ids=[])
        stack.add_new_window(window)

        assert len(stack.stack) == 1
コード例 #6
0
    def test_move_window_to_front(self, _init_pygame, default_ui_manager):
        stack = UIWindowStack((800, 600))
        window = UIWindow(pygame.Rect(100, 100, 200, 200),
                          manager=default_ui_manager,
                          element_ids=[])
        window_2 = UIWindow(pygame.Rect(50, 50, 200, 200),
                            manager=default_ui_manager,
                            element_ids=[])
        window_3 = UIWindow(pygame.Rect(0, 0, 200, 200),
                            manager=default_ui_manager,
                            element_ids=[])
        stack.add_new_window(window)
        stack.add_new_window(window_2)
        stack.add_new_window(window_3)
        stack.move_window_to_front(window)
        stack.move_window_to_front(window_3)
        stack.move_window_to_front(window_2)

        assert stack.stack[0] == window
コード例 #7
0
    def test_remove_window(self, _init_pygame, default_ui_manager):
        stack = UIWindowStack((800, 600))
        window = UIWindow(pygame.Rect(100, 100, 200, 200),
                          manager=default_ui_manager,
                          element_ids=[])
        window_2 = UIWindow(pygame.Rect(50, 50, 200, 200),
                            manager=default_ui_manager,
                            element_ids=[])
        window_3 = UIWindow(pygame.Rect(0, 0, 200, 200),
                            manager=default_ui_manager,
                            element_ids=[])
        stack.add_new_window(window)
        stack.add_new_window(window_2)
        stack.add_new_window(window_3)
        stack.remove_window(window)
        stack.remove_window(window_2)
        stack.remove_window(window_3)

        assert len(stack.stack) == 0
コード例 #8
0
    def test_stub_methods(self, _init_pygame, default_ui_manager):
        window = UIWindow(pygame.Rect(100, 100, 200, 200),
                          manager=default_ui_manager,
                          element_ids=[])

        window.select()
        window.unselect()
コード例 #9
0
ファイル: ui_manager.py プロジェクト: halfninja/pygame_gui
    def __init__(self, window_resolution: Tuple[int, int], theme_path: str = None):
        self.window_resolution = window_resolution
        self.ui_theme = UIAppearanceTheme()
        if theme_path is not None:
            self.ui_theme.load_theme(theme_path)
        self.ui_group = pygame.sprite.LayeredUpdates()

        self.select_focused_element = None
        self.last_focused_vertical_scrollbar = None

        self.ui_window_stack = UIWindowStack(self.window_resolution)
        UIWindow(pygame.Rect((0, 0), self.window_resolution), self, ['root_window'])

        self.shadow_generator = ShadowGenerator()
コード例 #10
0
    def __init__(self,
                 window_resolution: Tuple[int, int],
                 theme_path: str = None,
                 enable_live_theme_updates=True):
        self.window_resolution = window_resolution
        self.ui_theme = UIAppearanceTheme()
        if theme_path is not None:
            self.ui_theme.load_theme(theme_path)
        self.ui_group = pygame.sprite.LayeredUpdates()

        self.select_focused_element = None
        self.last_focused_vertical_scrollbar = None

        self.ui_window_stack = UIWindowStack(self.window_resolution)
        UIWindow(pygame.Rect((0, 0), self.window_resolution), self,
                 ['root_window'])

        self.live_theme_updates = enable_live_theme_updates
        self.theme_update_acc = 0.0
        self.theme_update_check_interval = 1.0
コード例 #11
0
 def test_creation(self, _init_pygame, default_ui_manager):
     UIWindow(pygame.Rect(100, 100, 200, 200),
              manager=default_ui_manager,
              element_ids=[])