|
TachyonUI 0.1.0
High-performance UI for building tools.
|
All controls follow the same rules for their parameters, their results and their layout. This page explains those rules once, so the pages for each control don't repeat them.
Parameters. Every control takes its parameters in the same order: (id, content or value, ..., callback, style, constraints). Most of them can be left out.
Each control has these overloads:
With ID id first, when you keep the ID yourself.
With StyleRef style, replacing the default CSS class.
Signatures on these pages show the overload with both ID and style.
Content. Buttons, toggles, tabs, list items and menu items take a GUIContent. It holds:
A string or icon converts implicitly:
Results. A control reports the user's input in two ways:
See Return values and callbacks.
LayoutOverride. The last parameter, LayoutOverride&& constraints = {}, overrides size and position for this call, on top of the style. Each builder returns the LayoutOverride again, so builders chain:
| Builder | Effect |
|---|---|
| LayoutOverride::Auto(), FixedSize(w, h), FixedWidth(w), FixedHeight(h) | Factories |
| Size(w, h), Width(w), Height(h) | Fixed size |
| MinWidth, MinHeight, MaxWidth, MaxHeight | Size limits |
| FlexGrow(n), FlexShrink(n), NoGrow(), NoShrink() | Flex factors |
| Position(x, y), Centered(), Relative(...), Absolute(...) | Position |
| Anchored(target, placement, offset) | Position next to another element |
| Overhang(int2) (after Anchored) | How far it may reach past the screen edge, as see-through room around its content |
| StickyX(), StickyY(), Sticky() | Stick while scrolling |
| BreakBefore(), BreakAfter(), KeepWithNext() | Line breaks in wrapping containers |
| GridColumn(start, span), GridRow(start, span), ColumnTrack, RowTrack | Grid placement |
| SetIconSide(side), IconTextGap(gap) | Icon placement |
Units:
They are defined in src/gui_core/layout/gui_constraints.h.
State scopes. Each pair applies to every control emitted between Begin and End:
Scope objects. A scope object is a local variable that calls a Begin function when it's made and the matching End when it goes out of scope. It takes the Begin's arguments. There are scope objects for Window, GhostWindow, CursorGhostWindow, Menu, MenuBar, ContextMenu, Tooltip, Cached, Horizontal, Vertical, HorizontalWrap, VerticalWrap, Area, LabelGroup, ButtonGroup, ToggleGroup, Table, Row, ListView, GridView, TabBar, Toolbar, StatusBar, TitleBar, ReorderableGroup, ReorderableItem, Disabled, Selected, Indeterminate, Invalid and DockingContainer. See Scopes.
Begin / End. BeginWindow, BeginMenu, BeginContextMenu, BeginTooltip and BeginCached return whether to build the content. Call End either way. Other Begin functions always return true. See Begin and End.