Exemple #1
0
 def test_full_rebuild_on_size_change_large_shadow(
         self, _init_pygame, default_ui_manager: UIManager):
     shape = RectDrawableShape(containing_rect=pygame.Rect(0, 0, 2, 2),
                               theming_parameters={
                                   'text':
                                   'test',
                                   'font':
                                   default_ui_manager.get_theme().get_font(
                                       object_ids=[], element_ids=[]),
                                   'shadow_width':
                                   1,
                                   'border_width':
                                   0,
                                   '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.full_rebuild_on_size_change()
    def test_collide_point(self, _init_pygame, default_ui_manager: UIManager):
        shape = RectDrawableShape(containing_rect=pygame.Rect(0, 0, 100, 100),
                                  theming_parameters={
                                      'text':
                                      'test',
                                      'font':
                                      default_ui_manager.get_theme().get_font(
                                          []),
                                      'normal_text':
                                      pygame.Color('#FFFFFF'),
                                      'normal_text_shadow':
                                      pygame.Color('#000000'),
                                      'shadow_width':
                                      0,
                                      'border_width':
                                      0,
                                      'normal_border':
                                      pygame.Color('#FFFFFF'),
                                      'normal_bg':
                                      pygame.Color('#000000'),
                                      'text_horiz_alignment':
                                      'center',
                                      'text_vert_alignment':
                                      'center'
                                  },
                                  states=['normal'],
                                  manager=default_ui_manager)

        assert shape.collide_point((50, 50)) is True
Exemple #3
0
    def test_set_dimensions(self, _init_pygame, default_ui_manager: UIManager):
        shape = RectDrawableShape(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':
                                      0,
                                      'border_width':
                                      0,
                                      '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))
        assert shape.containing_rect.width == 50
Exemple #4
0
    def rebuild(self):
        theming_parameters = {
            'normal_bg': self.bg_color,
            'normal_border': self.border_color,
            'border_width': self.border_width,
            'shadow_width': self.shadow_width
        }

        if self.shape_type == 'rectangle':
            self.drawable_shape = RectDrawableShape(self.rect,
                                                    theming_parameters,
                                                    ['normal'],
                                                    self.ui_manager)

        self.on_fresh_drawable_shape_ready()