simvx.core.ui.types¶
UI utility types — Colour, UIInputEvent, DragData, Theme, and theme descriptors.
Module Contents¶
Classes¶
Colour utility with named presets and hex parsing. |
|
Input event for UI controls. |
|
Data being dragged between controls. |
|
Descriptor that reads a colour from the theme unless explicitly overridden. |
|
Descriptor that reads a layout size from the theme unless overridden. |
|
Descriptor that reads a StyleBox from the theme unless explicitly overridden. |
|
UI theme controlling colours, fonts, and sizing. |
Data¶
API¶
- simvx.core.ui.types.__all__¶
[‘Colour’, ‘UIInputEvent’, ‘DragData’, ‘Theme’, ‘ThemeColour’, ‘ThemeSize’, ‘ThemeStyleBox’]
- class simvx.core.ui.types.Colour[source]¶
Colour 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_colour = Colour.RED label.text_colour = Colour.hex(“#FF6600”) button.bg_colour = Colour.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][source]¶
Parse hex colour string.
Supports ‘#RRGGBB’, ‘#RRGGBBAA’, ‘RRGGBB’, ‘RRGGBBAA’.
- class simvx.core.ui.types.UIInputEvent(position=None, button: int = 0, pressed: bool = True, key: str = '', char: str = '')[source]¶
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.types.DragData(data: Any = None, preview: Any = None)[source]¶
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.types.ThemeColour(key: str)[source]¶
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_colour = ThemeColour("btn_bg") text_colour = ThemeColour("text") btn.bg_colour = Colour.RED # override btn.bg_colour = None # revert to themeInitialization
- __slots__¶
(‘key’, ‘attr’, ‘name’)
- class simvx.core.ui.types.ThemeSize(key: str, default: float = 0.0)[source]¶
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’)
- class simvx.core.ui.types.ThemeStyleBox(key: str)[source]¶
Descriptor that reads a StyleBox from the theme unless explicitly overridden.
Same semantics as :class:
ThemeColourbut for StyleBox values. Setting toNonereverts to the theme default.Initialization
- __slots__¶
(‘key’, ‘attr’, ‘name’)
- class simvx.core.ui.types.Theme[source]¶
UI theme controlling colours, fonts, and sizing.
All colours are float tuples (r, g, b, a) in 0.0-1.0 range.
Example: theme = Theme() theme.colours[‘accent’] = Colour.hex(“#33CCFF”) theme.sizes[‘button_height’] = 40
Initialization