simvx.core.ui.core¶
Core UI types — Control, Theme, Color, UIInputEvent, FocusMode, AnchorPreset, SizeFlags, DragData.
Module Contents¶
Classes¶
Determines how a control receives keyboard focus. |
|
Common anchor configurations for quick layout. |
|
Controls how a widget behaves inside a container layout. |
|
Data being dragged between controls. |
|
Color utility with named presets and hex parsing. |
|
Input event for UI controls. |
|
Descriptor that reads a colour from the theme unless explicitly overridden. |
|
Descriptor that reads a layout size from the theme unless overridden. |
|
UI theme controlling colors, fonts, and sizing. |
|
Base class for all UI elements. |
Data¶
API¶
- simvx.core.ui.core.log¶
‘getLogger(…)’
- simvx.core.ui.core.__all__¶
[‘Control’, ‘Theme’, ‘ThemeColour’, ‘ThemeSize’, ‘Color’, ‘UIInputEvent’, ‘FocusMode’, ‘AnchorPreset…
- class simvx.core.ui.core.FocusMode¶
Bases:
enum.IntEnumDetermines how a control receives keyboard focus.
Initialization
Initialize self. See help(type(self)) for accurate signature.
- NONE¶
0
- CLICK¶
1
- ALL¶
2
- __abs__()¶
- __add__()¶
- __and__()¶
- __bool__()¶
- __ceil__()¶
- __delattr__()¶
- __dir__()¶
- __divmod__()¶
- __eq__()¶
- __float__()¶
- __floor__()¶
- __floordiv__()¶
- __format__()¶
- __ge__()¶
- __getattribute__()¶
- __getnewargs__()¶
- __getstate__()¶
- __gt__()¶
- __hash__()¶
- __index__()¶
- __int__()¶
- __invert__()¶
- __le__()¶
- __lshift__()¶
- __lt__()¶
- __mod__()¶
- __mul__()¶
- __ne__()¶
- __neg__()¶
- __new__()¶
- __or__()¶
- __pos__()¶
- __pow__()¶
- __radd__()¶
- __rand__()¶
- __rdivmod__()¶
- __reduce__()¶
- __reduce_ex__()¶
- __repr__()¶
- __rfloordiv__()¶
- __rlshift__()¶
- __rmod__()¶
- __rmul__()¶
- __ror__()¶
- __round__()¶
- __rpow__()¶
- __rrshift__()¶
- __rshift__()¶
- __rsub__()¶
- __rtruediv__()¶
- __rxor__()¶
- __setattr__()¶
- __sizeof__()¶
- __str__()¶
- __sub__()¶
- __subclasshook__()¶
- __truediv__()¶
- __trunc__()¶
- __xor__()¶
- as_integer_ratio()¶
- bit_count()¶
- bit_length()¶
- conjugate()¶
- class denominator¶
- class imag¶
- is_integer()¶
- class numerator¶
- class real¶
- to_bytes()¶
- __deepcopy__(memo)¶
- __copy__()¶
- name()¶
- value()¶
- class simvx.core.ui.core.AnchorPreset¶
Bases:
enum.IntEnumCommon anchor configurations for quick layout.
Initialization
Initialize self. See help(type(self)) for accurate signature.
- TOP_LEFT¶
0
- TOP_RIGHT¶
1
- BOTTOM_LEFT¶
2
- BOTTOM_RIGHT¶
3
- CENTER_LEFT¶
4
- CENTER_RIGHT¶
5
- CENTER_TOP¶
6
- CENTER_BOTTOM¶
7
- CENTER¶
8
- LEFT_WIDE¶
9
- RIGHT_WIDE¶
10
- TOP_WIDE¶
11
- BOTTOM_WIDE¶
12
- FULL_RECT¶
15
- __abs__()¶
- __add__()¶
- __and__()¶
- __bool__()¶
- __ceil__()¶
- __delattr__()¶
- __dir__()¶
- __divmod__()¶
- __eq__()¶
- __float__()¶
- __floor__()¶
- __floordiv__()¶
- __format__()¶
- __ge__()¶
- __getattribute__()¶
- __getnewargs__()¶
- __getstate__()¶
- __gt__()¶
- __hash__()¶
- __index__()¶
- __int__()¶
- __invert__()¶
- __le__()¶
- __lshift__()¶
- __lt__()¶
- __mod__()¶
- __mul__()¶
- __ne__()¶
- __neg__()¶
- __new__()¶
- __or__()¶
- __pos__()¶
- __pow__()¶
- __radd__()¶
- __rand__()¶
- __rdivmod__()¶
- __reduce__()¶
- __reduce_ex__()¶
- __repr__()¶
- __rfloordiv__()¶
- __rlshift__()¶
- __rmod__()¶
- __rmul__()¶
- __ror__()¶
- __round__()¶
- __rpow__()¶
- __rrshift__()¶
- __rshift__()¶
- __rsub__()¶
- __rtruediv__()¶
- __rxor__()¶
- __setattr__()¶
- __sizeof__()¶
- __str__()¶
- __sub__()¶
- __subclasshook__()¶
- __truediv__()¶
- __trunc__()¶
- __xor__()¶
- as_integer_ratio()¶
- bit_count()¶
- bit_length()¶
- conjugate()¶
- class denominator¶
- class imag¶
- is_integer()¶
- class numerator¶
- class real¶
- to_bytes()¶
- __deepcopy__(memo)¶
- __copy__()¶
- name()¶
- value()¶
- class simvx.core.ui.core.SizeFlags¶
Bases:
enum.IntEnumControls how a widget behaves inside a container layout.
Initialization
Initialize self. See help(type(self)) for accurate signature.
- SHRINK_BEGIN¶
0
- FILL¶
1
- EXPAND¶
2
- EXPAND_FILL¶
3
- SHRINK_CENTER¶
4
- SHRINK_END¶
8
- __abs__()¶
- __add__()¶
- __and__()¶
- __bool__()¶
- __ceil__()¶
- __delattr__()¶
- __dir__()¶
- __divmod__()¶
- __eq__()¶
- __float__()¶
- __floor__()¶
- __floordiv__()¶
- __format__()¶
- __ge__()¶
- __getattribute__()¶
- __getnewargs__()¶
- __getstate__()¶
- __gt__()¶
- __hash__()¶
- __index__()¶
- __int__()¶
- __invert__()¶
- __le__()¶
- __lshift__()¶
- __lt__()¶
- __mod__()¶
- __mul__()¶
- __ne__()¶
- __neg__()¶
- __new__()¶
- __or__()¶
- __pos__()¶
- __pow__()¶
- __radd__()¶
- __rand__()¶
- __rdivmod__()¶
- __reduce__()¶
- __reduce_ex__()¶
- __repr__()¶
- __rfloordiv__()¶
- __rlshift__()¶
- __rmod__()¶
- __rmul__()¶
- __ror__()¶
- __round__()¶
- __rpow__()¶
- __rrshift__()¶
- __rshift__()¶
- __rsub__()¶
- __rtruediv__()¶
- __rxor__()¶
- __setattr__()¶
- __sizeof__()¶
- __str__()¶
- __sub__()¶
- __subclasshook__()¶
- __truediv__()¶
- __trunc__()¶
- __xor__()¶
- as_integer_ratio()¶
- bit_count()¶
- bit_length()¶
- conjugate()¶
- class denominator¶
- class imag¶
- is_integer()¶
- class numerator¶
- class real¶
- to_bytes()¶
- __deepcopy__(memo)¶
- __copy__()¶
- name()¶
- value()¶
- class simvx.core.ui.core.DragData(data: Any = None, preview: Any = None)¶
Data being dragged between controls.
Attributes: data: Arbitrary payload. preview: Optional visual preview control shown during drag. source: Control the drag originated from (set by the system).
Initialization
- __slots__¶
(‘data’, ‘preview’, ‘source’)
- class simvx.core.ui.core.Color¶
Color utility with named presets and hex parsing.
All values are float tuples (r, g, b, a) in 0.0-1.0 range.
Example: panel.bg_color = Color.RED label.text_color = Color.hex(“#FF6600”) button.bg_color = Color.rgba(0.2, 0.4, 0.8)
- WHITE¶
(1.0, 1.0, 1.0, 1.0)
- BLACK¶
(0.0, 0.0, 0.0, 1.0)
- RED¶
(1.0, 0.0, 0.0, 1.0)
- GREEN¶
(0.0, 1.0, 0.0, 1.0)
- BLUE¶
(0.0, 0.0, 1.0, 1.0)
- YELLOW¶
(1.0, 1.0, 0.0, 1.0)
- CYAN¶
(0.0, 1.0, 1.0, 1.0)
- MAGENTA¶
(1.0, 0.0, 1.0, 1.0)
- TRANSPARENT¶
(0.0, 0.0, 0.0, 0.0)
- GRAY¶
(0.5, 0.5, 0.5, 1.0)
- DARK_GRAY¶
(0.2, 0.2, 0.2, 1.0)
- LIGHT_GRAY¶
(0.75, 0.75, 0.75, 1.0)
- ORANGE¶
(1.0, 0.6, 0.0, 1.0)
- PURPLE¶
(0.6, 0.2, 0.8, 1.0)
- PINK¶
(1.0, 0.4, 0.7, 1.0)
- static hex(h: str) tuple[float, float, float, float]¶
Parse hex color string.
Supports ‘#RRGGBB’, ‘#RRGGBBAA’, ‘RRGGBB’, ‘RRGGBBAA’.
- static rgba(r: float, g: float, b: float, a: float = 1.0) tuple[float, float, float, float]¶
Create color from float components (0.0-1.0).
- static from_255(r: int, g: int, b: int, a: int = 255) tuple[float, float, float, float]¶
Create color from 0-255 integer components.
- class simvx.core.ui.core.UIInputEvent(position=None, button: int = 0, pressed: bool = True, key: str = '', char: str = '')¶
Input event for UI controls.
Attributes: position: Mouse position in screen coordinates. button: Mouse button (1=left, 2=middle, 3=right) or 0 for keyboard. pressed: True for press, False for release. key: Key name for keyboard events. char: Character typed (for text input).
Initialization
- __slots__¶
(‘position’, ‘button’, ‘pressed’, ‘key’, ‘char’)
- class simvx.core.ui.core.ThemeColour(key: str)¶
Descriptor that reads a colour from the theme unless explicitly overridden.
Overrides are serializable — saved to scene files like Property values. Setting to
Nonereverts to the theme default.Usage::
class Button(Control): bg_color = ThemeColour("btn_bg") text_color = ThemeColour("text") btn.bg_color = Color.RED # override btn.bg_color = None # revert to themeInitialization
- __slots__¶
(‘key’, ‘attr’, ‘name’)
- __set_name__(owner, name)¶
- __get__(obj, objtype=None)¶
- __set__(obj, value)¶
- __repr__()¶
- class simvx.core.ui.core.ThemeSize(key: str, default: float = 0.0)¶
Descriptor that reads a layout size from the theme unless overridden.
Same semantics as :class:
ThemeColourbut for numeric layout values.Initialization
- __slots__¶
(‘key’, ‘attr’, ‘name’, ‘default’)
- __set_name__(owner, name)¶
- __get__(obj, objtype=None)¶
- __set__(obj, value)¶
- __repr__()¶
- class simvx.core.ui.core.Theme¶
UI theme controlling colors, fonts, and sizing.
All colors are float tuples (r, g, b, a) in 0.0-1.0 range.
Example: theme = Theme() theme.colors[‘accent’] = Color.hex(“#33CCFF”) theme.sizes[‘button_height’] = 40
Initialization
- get_color(key: str, default=(1, 1, 1, 1)) tuple[float, float, float, float]¶
Get color by key with fallback.
- get_size(key: str, default: float = 0) float¶
Get size by key with fallback.
- class simvx.core.ui.core.Control(**kwargs)¶
Bases:
simvx.core.engine.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(…)’
- property size: simvx.core.math.types.Vec2¶
Size backed by size_x/size_y Properties (inspector-synced).
- get_theme() simvx.core.ui.core.Theme¶
Get effective theme (own -> parent -> default).
- get_rect() tuple[float, float, float, float]¶
Get (x, y, width, height) in parent space.
- get_global_rect() tuple[float, float, float, float]¶
Get (x, y, width, height) in screen space.
Uses axis-aligned position accumulation (no rotation/scale) since UI controls are always axis-aligned rectangles.
- is_point_inside(point) bool¶
Check if point (screen coords) is inside this control.
- set_anchor_preset(preset: simvx.core.ui.core.AnchorPreset)¶
Set anchors from a preset.
Example: panel.set_anchor_preset(AnchorPreset.FULL_RECT) # fills parent label.set_anchor_preset(AnchorPreset.CENTER) # centered
- set_focus()¶
Request focus for this control.
- grab_focus()¶
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()¶
Release focus from this control.
- has_focus() bool¶
Return True if this control currently has keyboard focus.
- focus_next_control()¶
Move focus to next control in tab order.
- focus_previous_control()¶
Move focus to previous control in tab order.
- grab_mouse()¶
Capture mouse – all mouse events route to this control until released.
- release_mouse()¶
Release mouse capture.
- set_drag_preview(control: simvx.core.ui.core.Control)¶
Set a visual preview control for the current drag operation.
- draw_popup(renderer)¶
Draw popup overlay content. Override in popup-capable widgets.
- is_popup_point_inside(point) bool¶
Check if point is inside the popup area. Override in subclasses.
- popup_input(event)¶
Handle input on the popup overlay. Override in subclasses.
- dismiss_popup()¶
Close the popup. Override in subclasses.
- z_index¶
‘Property(…)’
- z_as_relative¶
‘Property(…)’
- property absolute_z_index: int¶
- property position: simvx.core.math.types.Vec2¶
- property rotation: float¶
- property rotation_degrees: float¶
- property scale: simvx.core.math.types.Vec2¶
- property global_position: simvx.core.math.types.Vec2¶
- property global_rotation: float¶
- property global_scale: simvx.core.math.types.Vec2¶
- 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, color=None)¶
- wrap_screen(margin: float = 20)¶
- script_error_raised¶
‘Signal(…)’
- classmethod __init_subclass__(**kwargs)¶
- property name: str¶
- property process_mode: simvx.core.descriptors.ProcessMode¶
- 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(node_type: type) simvx.core.node.Node | None¶
- property path: str¶
- add_to_group(group: str)¶
- remove_from_group(group: str)¶
- is_in_group(group: str) bool¶
- ready() None¶
- enter_tree() None¶
- exit_tree() None¶
- process(dt: float) None¶
- physics_process(dt: float) None¶
- draw(renderer) None¶
- input_event(event: simvx.core.events.InputEvent) None¶
- input(event: simvx.core.events.TreeInputEvent) None¶
- unhandled_input(event: simvx.core.events.TreeInputEvent) None¶
- start_coroutine(gen: simvx.core.descriptors.Coroutine) simvx.core.descriptors.CoroutineHandle¶
- stop_coroutine(gen_or_handle)¶
- destroy()¶
- queue_free¶
None
- property tree: simvx.core.scene_tree.SceneTree¶
- get_tree() simvx.core.scene_tree.SceneTree¶
- __getitem__(key: str)¶
- classmethod get_properties() dict[str, simvx.core.descriptors.Property]¶
- get_settings¶
None
- __repr__()¶