simvx.core.ui.core

Core UI types: Control, Theme, Colour, UIInputEvent, FocusMode, AnchorPreset, SizeFlags, DragData.

Module Contents

Classes

Control

Base class for all UI elements.

Data

API

simvx.core.ui.core.log

‘getLogger(…)’

simvx.core.ui.core.__all__

[‘Control’, ‘Theme’, ‘ThemeColour’, ‘ThemeSize’, ‘ThemeStyleBox’, ‘Colour’, ‘UIInputEvent’, ‘FocusMo…

class simvx.core.ui.core.Control(**kwargs)[source]

Bases: simvx.core.nodes_2d.node2d.Node2D

Base class for all UI elements.

Supports anchors, margins, sizing, focus, drag-and-drop, and input handling. Widgets draw themselves using the renderer passed to draw().

Example: control = Control(name=”panel”) control.size = Vec2(200, 100) control.set_anchor_preset(AnchorPreset.FULL_RECT)

Initialization

size_x

‘Property(…)’

size_y

‘Property(…)’

anchor_left

‘Property(…)’

anchor_top

‘Property(…)’

anchor_right

‘Property(…)’

anchor_bottom

‘Property(…)’

margin_left

‘Property(…)’

margin_top

‘Property(…)’

margin_right

‘Property(…)’

margin_bottom

‘Property(…)’

modal

‘Property(…)’

dismiss_on_outside_click

‘Property(…)’

pause_tree_when_modal

‘Property(…)’

top_level

‘Property(…)’

property size: simvx.core.math.types.Vec2[source]

Size backed by size_x/size_y Properties (inspector-synced).

touch_mode: str

‘mouse’

property theme: simvx.core.ui.types.Theme | None[source]
property mouse_over: bool[source]
property focused: bool[source]
property disabled: bool[source]
get_theme() simvx.core.ui.types.Theme[source]

Get effective theme (own -> parent -> default).

queue_redraw()[source]

Mark this control as needing a redraw. Propagates upward to parent.

get_minimum_size() simvx.core.math.types.Vec2[source]

Minimum size needed to display content. Subclasses override.

get_rect() tuple[float, float, float, float][source]

Get (x, y, width, height) in parent space.

get_global_rect() tuple[float, float, float, float][source]

Get (x, y, width, height) in screen space.

Uses axis-aligned position accumulation (no rotation/scale) since UI controls are always axis-aligned rectangles. Result is cached per-frame and auto-expires when the frame counter advances.

is_point_inside(point) bool[source]

Check if point (screen coords) is inside this control.

place_bottom_strip(height: float) None[source]

Anchor this control as a full-width horizontal strip at the bottom.

Equivalent to set_anchor_preset(AnchorPreset.BOTTOM_WIDE) plus margin_top = -height. The negative-margin convention is correct but surprising; this shortcut makes intent obvious.

place_top_strip(height: float) None[source]

Anchor this control as a full-width horizontal strip at the top.

set_anchor_preset(preset: simvx.core.ui.enums.AnchorPreset)[source]

Set anchors from a preset.

Example: panel.set_anchor_preset(AnchorPreset.FULL_RECT) # fills parent label.set_anchor_preset(AnchorPreset.CENTER) # centered

set_focus()[source]

Request focus for this control.

grab_focus()[source]

Claim keyboard focus for this control.

Unfocuses the currently focused control (if any) and sets focus to this one. Respects focus_mode: NONE-mode controls cannot receive focus.

release_focus()[source]

Release focus from this control.

has_focus() bool[source]

Return True if this control currently has keyboard focus.

focus_next_control()[source]

Move focus to next control in tab order.

focus_previous_control()[source]

Move focus to previous control in tab order.

grab_mouse()[source]

Capture mouse – all mouse events route to this control until released.

release_mouse()[source]

Release mouse capture.

set_drag_preview(control: simvx.core.ui.core.Control)[source]

Set a visual preview control for the current drag operation.

show_modal()[source]

Make this control visible and capture all UI input until close_modal().

Sets modal=True, makes the control visible, injects a ModalBackdrop child (transparent click-sink for outside-click dismissal, dimmed when pause_tree_when_modal is True), pushes onto the SceneTree’s modal stack, focuses the first focusable descendant, and (if pause_tree_when_modal) pauses tree processing.

The modal’s input is delivered through the standard _on_gui_input contract: there is no separate popup_input dispatch.

close_modal()[source]

Hide and pop this control from the modal stack.

Removes the auto-injected backdrop, restores prior focus, and (if needed) unpauses the tree. Idempotent.

position

‘_SpatialVecProperty(…)’

rotation

‘Property(…)’

scale

‘_SpatialVecProperty(…)’

z_index

‘Property(…)’

z_as_relative

‘Property(…)’

render_layer

‘Property(…)’

set_render_layer(index: int, enabled: bool = True) None
is_on_render_layer(index: int) bool
property absolute_z_index: int
property rotation_degrees: float
property world_position: simvx.core.math.types.Vec2
property world_rotation: float
property world_scale: simvx.core.math.types.Vec2
property world_transform: tuple[simvx.core.math.types.Vec2, simvx.core.math.types.Vec2, float]
property forward: simvx.core.math.types.Vec2
property right: simvx.core.math.types.Vec2
translate(offset: tuple[float, float] | numpy.ndarray)
rotate(radians: float)
rotate_deg(degrees: float)
look_at(target: tuple[float, float] | numpy.ndarray)
transform_points(points: list[simvx.core.math.types.Vec2]) list[simvx.core.math.types.Vec2]
draw_polygon(renderer, points: list[simvx.core.math.types.Vec2], closed=True, colour=None)
wrap_screen(margin: float = 20)
strict_errors: ClassVar[bool]

True

script_error_raised

‘Signal(…)’

classmethod __init_subclass__(**kwargs)
property name: str
property process_mode: simvx.core.descriptors.ProcessMode
property visible: bool
reset_error() None
add_child(node: simvx.core.node.Node) simvx.core.node.Node
remove_child(node: simvx.core.node.Node)
reparent(new_parent: simvx.core.node.Node)
get_node(path: str) simvx.core.node.Node
find_child(name: str, recursive: bool = False) simvx.core.node.Node | None
find(target: type | str, recursive: bool = True) simvx.core.node.Node | None
find_all(node_type: type, recursive: bool = True) list
walk(*, include_self: bool = True) collections.abc.Iterator[simvx.core.node.Node]
property path: str
add_to_group(group: str)
remove_from_group(group: str)
is_in_group(group: str) bool
on_ready() None
on_enter_tree() None
on_exit_tree() None
on_process(dt: float) None
on_physics_process(dt: float) None
on_draw(renderer) None
on_picked(event: simvx.core.events.InputEvent) None
on_unhandled_input(event: simvx.core.events.TreeInputEvent) None
start_coroutine(gen: simvx.core.descriptors.Coroutine) simvx.core.descriptors.CoroutineHandle
stop_coroutine(gen_or_handle)
clear_children()
destroy()
property app
property tree: simvx.core.scene_tree.SceneTree
__getitem__(key: str)
classmethod get_properties() dict[str, simvx.core.descriptors.Property]
__repr__()