def test_full_rebuild_on_size_change_corner_only_negative_values(
         self, _init_pygame, default_ui_manager: UIManager):
     with pytest.warns(UserWarning, match='Clamping shape_corner_radius'):
         RoundedRectangleShape(containing_rect=pygame.Rect(0, 0, 100, 100),
                               theming_parameters={
                                   'text':
                                   'test',
                                   'font':
                                   default_ui_manager.ui_theme.get_font(
                                       object_ids=[], element_ids=[]),
                                   'shadow_width':
                                   2,
                                   'border_width':
                                   1,
                                   'normal_border':
                                   pygame.Color('#FFFFFF'),
                                   'normal_bg':
                                   pygame.Color('#000000'),
                                   'shape_corner_radius':
                                   -10,
                                   'text_horiz_alignment':
                                   'center',
                                   'text_vert_alignment':
                                   'center'
                               },
                               states=['normal'],
                               manager=default_ui_manager)
 def test_creation_with_filled_bar_no_gradients_at_all(
         self, _init_pygame, default_ui_manager: UIManager):
     RoundedRectangleShape(containing_rect=pygame.Rect(0, 0, 100, 100),
                           theming_parameters={
                               'text':
                               'test',
                               'font':
                               default_ui_manager.get_theme().get_font(
                                   object_ids=[], element_ids=[]),
                               'shadow_width':
                               2,
                               'border_width':
                               1,
                               'normal_border':
                               pygame.Color('#FFFFFF'),
                               'normal_bg':
                               pygame.Color('#FFFFFF'),
                               'filled_bar':
                               pygame.Color('#000000'),
                               'filled_bar_width':
                               50,
                               'shape_corner_radius':
                               2,
                               'text_horiz_alignment':
                               'center',
                               'text_vert_alignment':
                               'center'
                           },
                           states=['normal'],
                           manager=default_ui_manager)
 def test_update(self, _init_pygame, default_ui_manager: UIManager):
     shape = RoundedRectangleShape(
         containing_rect=pygame.Rect(0, 0, 100, 100),
         theming_parameters={
             'text':
             'test',
             'font':
             default_ui_manager.ui_theme.get_font(object_ids=[],
                                                  element_ids=[]),
             'shadow_width':
             2,
             'border_width':
             1,
             'normal_border':
             pygame.Color('#FFFFFF'),
             'normal_bg':
             pygame.Color('#000000'),
             'hovered_border':
             pygame.Color('#000000'),
             'hovered_bg':
             pygame.Color('#FFFFFF'),
             'shape_corner_radius':
             2,
             'text_horiz_alignment':
             'center',
             'text_vert_alignment':
             'center'
         },
         states=['normal', 'hovered'],
         manager=default_ui_manager)
     shape.update()
     shape.update()
 def test_collide_point(self, _init_pygame, default_ui_manager: UIManager):
     theming_params = {
         'text':
         'test',
         'font':
         default_ui_manager.ui_theme.get_font(object_ids=[],
                                              element_ids=[]),
         'shadow_width':
         0,
         'border_width':
         0,
         'shape_corner_radius':
         40,
         'normal_border':
         pygame.Color('#FFFFFF'),
         'normal_bg':
         pygame.Color('#000000'),
         'text_horiz_alignment':
         'center',
         'text_vert_alignment':
         'center'
     }
     shape = RoundedRectangleShape(containing_rect=pygame.Rect(
         0, 0, 100, 100),
                                   theming_parameters=theming_params,
                                   states=['normal'],
                                   manager=default_ui_manager)
     assert shape.collide_point((50, 50)) is True
     assert shape.collide_point((5, 50)) is True
     assert shape.collide_point((25, 25)) is True
     assert shape.collide_point((10, 10)) is False
     assert shape.collide_point((5, 5)) is False
 def test_full_rebuild_on_size_change_large_corners_no_shadow(
         self, _init_pygame, default_ui_manager: UIManager):
     RoundedRectangleShape(containing_rect=pygame.Rect(0, 0, 50, 50),
                           theming_parameters={
                               'text':
                               'test',
                               'font':
                               default_ui_manager.ui_theme.get_font(
                                   object_ids=[], element_ids=[]),
                               'shadow_width':
                               0,
                               'border_width':
                               2,
                               'shape_corner_radius':
                               30,
                               'normal_border':
                               pygame.Color('#FFFFFF'),
                               'normal_bg':
                               pygame.Color('#000000'),
                               'text_horiz_alignment':
                               'center',
                               'text_vert_alignment':
                               'center'
                           },
                           states=['normal'],
                           manager=default_ui_manager)
    def test_clear_and_create_shape_surface(self, _init_pygame,
                                            default_ui_manager: UIManager):
        shape = RoundedRectangleShape(
            containing_rect=pygame.Rect(0, 0, 100, 100),
            theming_parameters={
                'text':
                'test',
                'font':
                default_ui_manager.ui_theme.get_font(object_ids=[],
                                                     element_ids=[]),
                'shadow_width':
                0,
                'border_width':
                0,
                'shape_corner_radius':
                2,
                'normal_border':
                pygame.Color('#FFFFFF'),
                'normal_bg':
                pygame.Color('#000000'),
                'text_horiz_alignment':
                'center',
                'text_vert_alignment':
                'center'
            },
            states=['normal'],
            manager=default_ui_manager)
        shape.clear_and_create_shape_surface(pygame.Surface((100, 100)),
                                             pygame.Rect(0, 0, 90, 90),
                                             overlap=0,
                                             corner_radius=-1,
                                             aa_amount=4)

        shape.clear_and_create_shape_surface(pygame.Surface((100, 100)),
                                             pygame.Rect(0, 0, 90, 90),
                                             overlap=0,
                                             corner_radius=50,
                                             aa_amount=4)

        shape.clear_and_create_shape_surface(pygame.Surface((100, 100)),
                                             pygame.Rect(0, 0, 80, 80),
                                             overlap=0,
                                             corner_radius=40,
                                             aa_amount=4)

        shape.clear_and_create_shape_surface(pygame.Surface((100, 100)),
                                             pygame.Rect(0, 0, 75, 75),
                                             overlap=0,
                                             corner_radius=40,
                                             aa_amount=4)
Ejemplo n.º 7
0
 def test_set_dimensions(self, _init_pygame, default_ui_manager: UIManager):
     shape = RoundedRectangleShape(
         containing_rect=pygame.Rect(0, 0, 100, 100),
         theming_parameters={
             'text': 'test',
             'font': default_ui_manager.ui_theme.get_font([]),
             'shadow_width': 0,
             'border_width': 0,
             'shape_corner_radius': 2,
             'normal_border': pygame.Color('#FFFFFF'),
             'normal_bg': pygame.Color('#000000'),
             'text_horiz_alignment': 'center',
             'text_vert_alignment': 'center'
         },
         states=['normal'],
         manager=default_ui_manager)
     shape.set_dimensions((50, 50))
Ejemplo n.º 8
0
 def test_full_rebuild_on_size_change_small_surface(
         self, _init_pygame, default_ui_manager: UIManager):
     with pytest.warns(UserWarning, match='Clamping shape_corner_radius'):
         theming_params = {
             'text': 'test',
             'font': default_ui_manager.ui_theme.get_font([]),
             'shadow_width': 1,
             'border_width': 0,
             'shape_corner_radius': 3,
             'normal_border': pygame.Color('#FFFFFF'),
             'normal_bg': pygame.Color('#000000'),
             'text_horiz_alignment': 'center',
             'text_vert_alignment': 'center'
         }
         RoundedRectangleShape(containing_rect=pygame.Rect(0, 0, 2, 2),
                               theming_parameters=theming_params,
                               states=['normal'],
                               manager=default_ui_manager)