tessella.overlay package

Submodules

tessella.overlay.overlay_manager module

class tessella.overlay.overlay_manager.OverlayManager[source]

Bases: object

A static class that allows widgets to be displayed as an overlay.

_overlays

A dict containing all registered overlays.

Type:

dict[Overlay, None]

_in_render_cycle

Tracks if the overlay rendering process is ongoing.

Type:

bool

_processing_event

The event currently being propagated to the overlays, if any. Used to avoid processing the same event more than once.

Type:

pygame.Event | None

_active_renders

Tracks how many non-overlay widgets are rendering now. This is used to render the overlay on after all widgets are done rendering.

Type:

int

_root_constraints

The constraints used by the root of the widget tree.

Type:

WidgetConstraints

classmethod set_root_constraints(root_constraints)[source]

Sets the constraints used by the root of the widget tree. Overlays might use this to correctly position themselves on the screen.

Parameters:

root_constraints (WidgetConstraints) – The root constraints.

Return type:

None

classmethod get_root_constraints()[source]

Returns the constraints used by the root widget, if any.

Returns:

The root constraints.

Return type:

WidgetConstraints | None

classmethod start_render()[source]

Marks when a non-overlay widget has started rendering.

Return type:

None

classmethod end_render(surface, debug_mode=False)[source]

Marks when a non-overlay widget has finished rendering. This method will render the overlays when the last widget finishes rendering.

Parameters:
  • surface (pygame.Surface) – The surface to render the overlays in.

  • debug_mode (bool) – Whether to render a debug version of each overlay widget. Defaults to False.

Return type:

None

classmethod add_widget(widget)[source]

Adds a new widget to the overlay manager, to be rendered after the main widget tree.

Parameters:

widget (Overlay) – The overlay widget to be added.

Return type:

None

classmethod process_event(event, consumed=False)[source]

Propagates a pygame event to every active overlay, in order to let them handle it before the rest of the widget tree.

Parameters:
  • event (pygame.Event) – The event to propagate.

  • consumed (bool) – Whether the event has already been consumed by another widget. Defaults to False.

Returns:

Whether the event was consumed by an overlay.

Return type:

bool

classmethod remove_widget(widget)[source]

Removes a widget from the overlay manager.

Parameters:

widget (Overlay) – The overlay widget to be removed.

Return type:

None

classmethod render(surface, debug_mode=False)[source]

Renders the overlays in the given surface.

Parameters:
  • surface (pygame.Surface) – The surface to render the overlays in.

  • debug_mode (bool) – Whether to render a debug version of each overlay widget. Defaults to False.

Return type:

None