Source code for simvx.graphics.platform._base
"""Window backend protocol — duck-typing friendly contract."""
from __future__ import annotations
import logging
from collections.abc import Callable
from typing import Any, Protocol, runtime_checkable
log = logging.getLogger(__name__)
__all__ = ["WindowBackend"]
[docs]
@runtime_checkable
class WindowBackend(Protocol):
"""Protocol that all windowing backends must satisfy."""
[docs]
def create_window(self, width: int, height: int, title: str, *, visible: bool = True) -> None: ...
[docs]
def set_window_size(self, width: int, height: int) -> None: ...
[docs]
def set_title(self, title: str) -> None: ...
[docs]
def create_graphics_surface(self, instance: Any) -> Any: ...
[docs]
def get_required_instance_extensions(self) -> list[str]: ...
[docs]
def poll_events(self) -> None: ...
[docs]
def should_close(self) -> bool: ...
[docs]
def get_framebuffer_size(self) -> tuple[int, int]: ...
[docs]
def get_window_size(self) -> tuple[int, int]: ...
[docs]
def get_content_scale(self) -> tuple[float, float]: ...
[docs]
def set_key_callback(self, callback: Callable[[int, int, int], None] | None) -> None: ...
[docs]
def set_cursor_pos_callback(self, callback: Callable[[float, float], None] | None) -> None: ...
[docs]
def set_char_callback(self, callback: Callable[[int], None] | None) -> None: ...
[docs]
def request_close(self) -> None: ...
[docs]
def get_cursor_pos(self) -> tuple[float, float]: ...
[docs]
def set_cursor_shape(self, shape: int) -> None: ...
[docs]
def destroy(self) -> None: ...