# UI System SimVX provides a set of UI controls and layout containers for building game interfaces. ## Controls All controls inherit from `Control`, which provides rect-based layout, mouse interaction, and focus management. ### Label ```python from simvx.core import Label label = Label(text="Score: 0", font_size=24) label.position = Vec2(10, 10) root.add_child(label) ``` ### Button ```python from simvx.core import Button btn = Button(text="Start Game") btn.pressed.connect(start_game) root.add_child(btn) ``` ### TextEdit ```python from simvx.core import TextEdit edit = TextEdit(placeholder="Enter name...") edit.text_changed.connect(lambda text: print(text)) root.add_child(edit) ``` ### Slider ```python from simvx.core import Slider slider = Slider(min_value=0, max_value=100, value=50) slider.value_changed.connect(lambda v: print(f"Volume: {v}")) root.add_child(slider) ``` ### ProgressBar ```python from simvx.core import ProgressBar bar = ProgressBar(min_value=0, max_value=100, value=75) root.add_child(bar) ``` ## Containers Containers automatically arrange their children. ### HBoxContainer / VBoxContainer ```python from simvx.core import HBoxContainer, VBoxContainer, Button menu = VBoxContainer(separation=10) menu.add_child(Button(text="New Game")) menu.add_child(Button(text="Load Game")) menu.add_child(Button(text="Settings")) root.add_child(menu) ``` ### GridContainer ```python from simvx.core import GridContainer grid = GridContainer(columns=3, h_separation=5, v_separation=5) for i in range(9): grid.add_child(Button(text=str(i + 1))) ``` ### MarginContainer ```python from simvx.core import MarginContainer margin = MarginContainer( margin_left=20, margin_right=20, margin_top=10, margin_bottom=10, ) margin.add_child(Label(text="Padded content")) ``` ## Theming Apply consistent styling across controls: ```python from simvx.core import Theme theme = Theme( bg_color=(0.2, 0.2, 0.2, 1.0), fg_color=(1.0, 1.0, 1.0, 1.0), accent_color=(0.3, 0.6, 1.0, 1.0), font_size=16, ) ``` ## Input Handling UI input is routed through the `SceneTree`: ```python tree.ui_input(mouse_pos=(100, 200), button=1, pressed=True) tree.ui_input(key="return", pressed=True) ``` ## API Reference See {py:mod}`simvx.core.ui` for the complete UI API.