types.py

lunaengine/backend/types.py

A collection of types used in lunaengine

class EVENTS

Description

No documentation

Attributes
QUIT: Any = pygame.QUIT
KEYDOWN: Any = pygame.KEYDOWN
KEYUP: Any = pygame.KEYUP
MOUSEWHEEL: Any = pygame.MOUSEWHEEL
MOUSEMOTION: Any = pygame.MOUSEMOTION
MOUSEBUTTONDOWN: Any = pygame.MOUSEBUTTONDOWN
MOUSEBUTTONUP: Any = pygame.MOUSEBUTTONUP
JOYAXISMOTION: Any = pygame.JOYAXISMOTION
VIDEORESIZE: Any = pygame.VIDEORESIZE
WINDOWFOCUSGAINED: Any = pygame.WINDOWFOCUSGAINED
WINDOWFOCUSLOST: Any = pygame.WINDOWFOCUSLOST
ACTIVEEVENT: Any = pygame.ACTIVEEVENT
Methods

No methods defined.

class MouseButtonPressed

Description

No documentation

Attributes
left: bool = False
middle: bool = False
right: bool = False
extra_button_1: bool = False
extra_button_2: bool = False
Methods

No methods defined.

class InputState

Description

Tracks input state with proper click detection

Attributes
mouse_pos: tuple = (0, 0)
mouse_buttons_pressed: MouseButtonPressed = None
mouse_just_pressed: bool = False
mouse_just_released: bool = False
mouse_wheel: float = 0
consumed_events: set = None
active_controller: Optional['Controller'] = None
controller_count: int = 0
using_controller: bool = False
Methods
def __post_init__(self: Any) -> Any
No documentation
def consume_global_mouse(self: Any) -> Any
Mark that a mouse event has been handled globally.
def is_global_mouse_consumed(self: Any) -> Any
Check if any element has consumed the current mouse event.
def update(self: Any, mouse_pos: Any, mouse_pressed: Any, mouse_wheel: Any = 0) -> Any
No documentation
def consume_event(self: Any, element_id: Any) -> Any
Mark an event as consumed by a specific element
def is_event_consumed(self: Any, element_id: Any) -> Any
Check if event was already consumed
def clear_consumed(self: Any) -> Any
Clear consumed events for new frame
def get_mouse_state(self: Any) -> Tuple[Tuple[int, int], MouseButtonPressed]
No documentation

class ElementsList

Description

No documentation

Methods
def __init__(self: Any, *args: tuple, **kwargs: dict) -> Any
No documentation
def set_on_change(self: Any, on_change: Callable[[ElementsListEvents, any, Optional[int]], None], parent_element: 'UiElement' = None) -> Any
No documentation
def append(self: Any, item: Any) -> Any
No documentation
def insert(self: Any, index: Any, item: Any) -> Any
No documentation
def extend(self: Any, iterable: Any) -> Any
No documentation
def remove(self: Any, item: Any) -> Any
No documentation
def pop(self: Any, index: Any = -1) -> Any
No documentation

class LayerType

Description

Enumeration of UI render layers.

Attributes
BACKGROUND: Any = 0
NORMAL: Any = 1
ABOVE_NORMAL: Any = 2
POPUP: Any = 3
MODAL: Any = 4
TOP: Any = 5
Methods

No methods defined.

class WindowEventType

Description

Types of window events supported.

Attributes
FOCUS_GAINED: Any = 'window_focus_gained'
FOCUS_LOST: Any = 'window_focus_lost'
RESIZED: Any = 'window_resized'
MOVED: Any = 'window_moved'
ENTER: Any = 'window_enter'
LEAVE: Any = 'window_leave'
CLOSE: Any = 'window_close'
MINIMIZED: Any = 'window_minimized'
RESTORED: Any = 'window_restored'
MAXIMIZED: Any = 'window_maximized'
SHOWN: Any = 'window_shown'
HIDDEN: Any = 'window_hidden'
EXPOSED: Any = 'window_exposed'
Methods

No methods defined.

class WindowEventData

Description

Data container for window events.

Attributes
event_type: WindowEventType = None
timestamp: int = None
window_id: int = None
data: Dict[str, Any] = field(default_factory=dict)
Methods
def size(self: Any) -> Optional[Tuple[int, int]]
Get window size from resize event.
def position(self: Any) -> Optional[Tuple[int, int]]
Get window position from move event.

class Ratio

Description

Represents a width/height ratio (x, y). Supports arithmetic and scaling.

Attributes
x: Any = width
y: Any = height
Methods
def __new__(cls: Any, x: Union[Number, Tuple[Number, Number]], y: Number = None) -> Any
No documentation
def width(self: Any) -> float
No documentation
def height(self: Any) -> float
No documentation
def med(self: Any) -> float
No documentation
def scale(self: Any, factor: float) -> 'Ratio'
Return a new Ratio multiplied by factor.
def clamp(self: Any, min_ratio: 'Ratio' = None, max_ratio: 'Ratio' = None) -> 'Ratio'
Clamp each component between min and max (if provided).
def as_int(self: Any) -> Tuple[int, int]
No documentation
def __add__(self: Any, other: Union[Number, Tuple, 'Ratio']) -> 'Ratio'
No documentation
def __sub__(self: Any, other: Any) -> Any
No documentation
def __mul__(self: Any, other: Any) -> Any
No documentation
def __truediv__(self: Any, other: Any) -> Any
No documentation
def __radd__(self: Any, other: Any) -> Any
No documentation
def __rmul__(self: Any, other: Any) -> Any
No documentation
def __repr__(self: Any) -> Any
No documentation

class Color

Description

No documentation

Attributes
r: int = None
g: int = None
b: int = None
a: float = None
Methods
def __init__(self: Any, r: int, g: int, b: int, a: float = 1.0) -> Any
No documentation
def random(self: Any) -> 'Color'
No documentation
def __repr__(self: Any) -> Any
No documentation
def __str__(self: Any) -> Any
No documentation
def __add__(self: Any, other: 'Color' | Tuple[int, int, int, float]) -> 'Color'
No documentation
def __sub__(self: Any, other: 'Color' | Tuple[int, int, int, float]) -> 'Color'
No documentation
def __mul__(self: Any, other: 'Color' | Tuple[int, int, int, float]) -> 'Color'
No documentation
def __mod__(self: Any, other: 'Color' | Tuple[int, int, int, float]) -> 'Color'
No documentation
def __truediv__(self: Any, other: 'Color' | Tuple[int, int, int, float]) -> 'Color'
No documentation
def from_rgb(cls: Any, r: int, g: int, b: int, a: float = 1.0) -> 'Color'
Create a Color from RGB 0-255 values.
def from_hex(cls: Any, hex_str: str, a: float = 1.0) -> Optional['Color']
Create a Color from a hex string like '#FF0000' or 'FF0000'.
def from_hsv(cls: Any, h: float, s: float, v: float, a: float = 1.0) -> 'Color'
Create a Color from HSV (h:0-360, s:0-1, v:0-1).
def from_hsl(cls: Any, h: float, s: float, l: float, a: float = 1.0) -> 'Color'
Create a Color from HSL (h:0-360, s:0-1, l:0-1).
def to_rgb_tuple(self: Any) -> Tuple[int, int, int]
Return (r, g, b) as integers 0‑255, ignoring alpha.
def to_rgba_tuple(self: Any) -> Tuple[int, int, int, int]
Return (r, g, b, a) with alpha as 0‑255.
def validate(self: Any) -> Any
Ensure that color values are within valid ranges.
def toTuple(self: Any) -> Tuple[int, int, int, int]
Convert to RGBA tuple with alpha as 0-255.
def toHex(self: Any) -> str
Convert to hex string.
def toHSL(self: Any) -> Tuple[float, float, float]
Convert to HSL tuple.
Back to Backend Module