Skip to main content

Module widget

Module widget 

Source
Expand description

Widget types and styling.

Structs§

Action
A typed click target: owner 0 = the screen, k = items control k; slot = the command (or Action::SELECT); index = the item index inside an items control (0 elsewhere).
Image
An image widget’s data — see image.
StateFlags
Interaction state bits of a widget — see Widget::state.
StateStyles
A widget’s state patches: each applies when the widget’s state contains its flags; later rules win.
Style
Visual and layout style for a widget.
StylePatch
Paint-only style overrides — never affect layout.
TextBox
A text box’s content and editing state, as drawn this frame. Built by text_box (text, placeholder, max length, event names); the caret, selection and horizontal scroll are filled in each frame by TextBoxState::apply.
Widget
A single widget in the UI tree.

Enums§

Dock
WinForms-style dock — which edge(s) the widget attaches to inside its parent.
FocusStyle
How a focused widget shows its focus indicator.
Stretch
How an image fills the box it’s given — WPF’s Stretch.
Units
A size value — either a fixed pixel amount, a CSS-style percentage of the parent’s own resolved content size (0.0–100.0), or Auto (size to content/available space, this crate’s original behaviour).
WidgetKind

Constants§

PLACEHOLDER_COLOR
Placeholder text color of a text box.
SELECTION_COLOR
Selection highlight behind selected text.
TEXT_BOX_BORDER
Border of an unfocused text box (vanilla EditBox).
TEXT_BOX_FOCUS_BORDER
Border of a focused text box unless focus_color is set.

Functions§

button
image
An image from a Yog image source — "item:apple", "block:stone", "sprite:button", "mymod:gui/logo" (see yog_gfx::image) — the host resolves it for its Minecraft version. Sized to the image’s natural size (16×16 until the host told it) unless given w/h; scaled into the widget per Widget::stretch (default Uniform), nearest-neighbour.
inv_slot
An inventory-slot decoration (icon + stack-count overlay) for item_id (empty string = empty slot) with count items. Purely decorative — real drag-and-drop still goes through the vanilla Slot this overlays.
item_slot
label
panel
scroll_view
A vertically scrolling column: clips its children, scrolls them by Widget::scroll_y and draws a scrollbar when they overflow — WPF’s ScrollViewer around a StackPanel. Give it a fixed (or flex) height.
spacer
text_box
A single-line text input holding text — black box, grey border (white while focused), like vanilla’s EditBox. Its text, caret and focus live in a TextBoxState that the code-behind keeps and applies to it each frame.