Exemplo n.º 1
0
    def test_set_active_state_with_transitions(self, _init_pygame, default_ui_manager: UIManager):
        shape = DrawableShape(containing_rect=pygame.Rect(0, 0, 100, 100),
                              theming_parameters={'transitions': {('normal', 'hovered'): 0.5,
                                                                  ('hovered', 'normal'): 0.5}},
                              states=['normal', 'hovered'],
                              manager=default_ui_manager)

        shape.set_active_state('hovered')

        shape.update(0.05)

        shape.set_active_state('normal')

        assert shape.active_state.transition is not None
Exemplo n.º 2
0
    def test_update(self, _init_pygame, default_ui_manager: UIManager):
        shape = DrawableShape(containing_rect=pygame.Rect(0, 0, 100, 100),
                              theming_parameters={}, states=['normal', 'hovered'], manager=default_ui_manager)

        assert len(shape.states_to_redraw_queue) == 0

        shape.states_to_redraw_queue.append('normal')
        shape.states_to_redraw_queue.append('hovered')
        shape.update(0.05)
        assert len(shape.states_to_redraw_queue) == 1
        assert shape.need_to_clean_up

        shape.update(0.05)
        assert not shape.need_to_clean_up

        shape.full_rebuild_countdown = 0.5
        shape.should_trigger_full_rebuild = True
        shape.update(0.5)
        assert not shape.should_trigger_full_rebuild