Skip to main content

Module widget

Module widget 

Source
Expand description

Widget types and styling.

Structs§

Image
An image widget’s data — see image.
Style
Visual and layout style for a widget.
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
mc_image
A raw Minecraft texture ("minecraft:textures/..."), img_w × img_h pixels, stretched over the widget. Version-dependent: prefer image.
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.