simvx.core.ui.core¶
Core UI types: Control, Theme, Colour, UIInputEvent, FocusMode, AnchorPreset, SizeFlags, DragData.
Module Contents¶
Classes¶
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.Node2DBase 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(…)’
- dismiss_on_outside_click¶
‘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]¶
- 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.
Extends :meth:
Drawable2D.queue_redrawadditively: it sets the item-pipeline render-dirty bit (read by the itemRenderItemCache, P2) AND keeps the_draw_dirty/_DrawRecordercache path (read by theDraw2D_draw_recursivewalk the editor play-mode game viewport + web runtime still use).
- get_minimum_size() simvx.core.math.types.Vec2[source]¶
Minimum size needed to display content. Subclasses override.
- 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.
- 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)plusmargin_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
- 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.
- set_drag_preview(control: simvx.core.ui.core.Control)[source]¶
Set a visual preview control for the current drag operation.
- show_overlay(modality: str = 'light', *, dim: bool | None = None, dismiss: bool | None = None, inert: bool | None = None, owner: simvx.core.ui.core.Control | None = None, initial_focus: simvx.core.ui.core.Control | None = None) None[source]¶
Register this control as an on-top overlay until :meth:
close_overlay.modalityis one of"none"/"light"/"blocking"(design §0 preset table).dim/dismiss/inert(None= preset default) override individual flags.owneris the logical chain owner for whole-chain dismissal + input scope (e.g. aMenuBarfor its dropdown + submenu overlays); defaults toself.initial_focusis the descendant to focus when the overlay is capturing (None= the first focusable descendant). Positioning is the widget’s own job: position first, then callshow_overlayto register.
- close_overlay() None[source]¶
Pop this control (and its open chain) from the overlay registry. Idempotent.
Mirrors :meth:
show_overlay, which setsvisible = True: closing hides the control again so a persistent (non-freed) overlay – a reused title/menu screen – stops drawing over the scene once dismissed. A consumer that frees its overlay on close is unaffected (the hide is harmless); one that reuses it getsvisible = Trueback on the nextshow_overlay.
- 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)¶
- hdr¶
‘Property(…)’
- property transform_render_dirty: bool¶
- strict_errors: ClassVar[bool]¶
True
- script_error_raised¶
‘Signal(…)’
- dynamic: bool¶
False
- classmethod __init_subclass__(**kwargs)¶
- property name: str¶
- property update_mode: simvx.core.descriptors.UpdateMode¶
- 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¶
- get_node_or_none(path: str) simvx.core.node.Node | None¶
- find(target, *, direct: bool = False)¶
- find_all(target, *, direct: bool = False)¶
- 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_update(dt: float) None¶
- on_fixed_update(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)¶
- property render_dirty: bool¶
- clear_children()¶
- destroy()¶
- call_deferred(method: collections.abc.Callable[..., Any], *args: Any) None¶
- property app¶
- property tree: simvx.core.scene_tree.SceneTree¶
- property physics¶
- property physics_2d¶
- __getitem__(key: str)¶
- classmethod get_properties() dict[str, simvx.core.descriptors.Property]¶
- __repr__()¶