Egui::Ui
Inherits Reference < Object
Reopen Egui::Ui (NOT Egui::Terminal::Ui) for the one-line entry.
Constants
Global DEFAULT widget size (egui.cr, no upstream counterpart):
the fallback floor a widget falls back to when neither its
content nor an explicit size (min_size:, add_sized) defines
one — a widget may be larger, but its size never collapses to
zero. Window-frame chrome is exempt (it passes its own exact
sizes). Panels have their own default (Context::PANEL_MIN_SIZE).
Constructors
Instance methods
egui Ui::add(widget) — the generic Widget entry point. While
the widget runs, it is the Context's current_widget — the
inspector records kind/class/properties per id from it (nil for
interact calls not coming from an Ui#add).
egui ui.add_sized(size, widget) — lay the widget out in an
exact-size cell instead of its natural size (still bounded by
the region's max_rect, like every allocation).
The cell is a HARD bound: unlike flow regions (#horizontal,
#scope, scroll content) it does NOT inherit v_overflow — a
widget placed in an exact-size cell can never outgrow it, even
inside a scrollable panel. Without this, a fixed-height header
cell (the Inspector's ✕) lets the natural-size button inside
grow past the row and overlap what's below.
egui Ui::allocate_at_least: place a widget of size at the
cursor, grow min_rect, advance the cursor.
Max-size rule (egui.cr guarantee, no upstream counterpart): a
widget rect never extends past max_rect's far corner — the
effective max width/height of every widget is at least bounded
by its parent region. How a widget FITS inside the bound is the
widget's own policy (Label wrap, TextEdit horizontal scroll,
plain clipping otherwise); this is the hard floor that makes
"long content grows past the parent" impossible. Regions with a
semi-infinite max_rect (frames, scroll contents) are
unaffected by the clamp — and so are v_overflow regions (CSS
overflow-y: the content grows past the bottom on purpose,
clipped by clip and scrolled by the owning ScrollArea).
egui Ui::available_size — how much room is left in this region
(from the cursor to max_rect's far corner in layout direction).
A block-level button filling the region's width — the Windows
dialog idiom, where #button is the inline (content-hugging)
one. height overrides the 40pt default.
A pixel Canvas with Paint-style interaction; the block receives this frame's Canvas::Interaction (pointer/drag in pixel coords).
egui ui.checkbox(&mut bool, text) — Crystal keeps the value in
app state; the block fires with the new value on toggle, and
Response#changed? reports the same on the returned Response.
egui Ui::new_child: a child region with its own cursor/layout.
Inherits the parent's layer, clip rect AND vertical-overflow mode
(v_overflow — the CSS overflow-y semantics of a scroll
viewport must reach the whole subtree: without this, rows built
through #horizontal/#scope near the fold would clamp their
children to the viewport's bottom edge and overlap there).
egui Ui::clip_rect: widgets laid out through this Ui are only
interactable inside this rect (panels/windows/scroll viewports
clip their contents; overflowing parts are painted over).
egui Ui::clip_rect: widgets laid out through this Ui are only
interactable inside this rect (panels/windows/scroll viewports
clip their contents; overflowing parts are painted over).
egui ui.color_edit32(&mut color): the block fires with the new
color when the picker changed it this frame.
egui ui.columns(n) — split the remaining width into n equal
columns; the block receives one Ui per column.
variant: picks the closed-combo look (:button separated arrow
strip, :plain rigid single button, :field input field + select
button); label: is a placeholder for the empty selection that
also leads the list as the zero option (picking it reports "");
overlay: opens the list on top of the button, GTK3-style;
max_height: caps the open list — beyond it the list scrolls.
egui_extras DatePickerButton — see DatePicker. The block
fires from inside #show on the day click (and Today).
egui ui.enabled(flag, |ui| …) — gray-out + interaction-block a
region. Contents ALWAYS render through a child Ui so widget ids
stay stable when the flag flips (interaction state must survive
disable/enable cycles). While disabled every Response comes back
dead and a translucent scrim is back-painted over the region.
The font stack this Ui's text measures through: the theme's
font_family resolved via Context#fonts_for (nil family = the
primary stack). Widgets whose effective style carries a family
(class rules / inline / inspector cascade) resolve their own
ctx.fonts_for(style.font_family) instead — this helper is the
"whatever the ambient theme says" default.
egui Frame::show — a padded, painted panel around a block of
contents. Reserve a paint slot, lay the children out inside the
margin, then back-paint the frame under them (the #window trick).
egui ui.grid(id) { |grid| … } — aligned columns; see Grid.
egui ui.horizontal(|ui| …): a child Ui laying out left→right on
the rest of the current line; afterwards the parent cursor jumps
below the row's bounding box (like upstream's single-row shortcut).
Built through #child_ui so the row inherits the parent's layer and
clip rect — a horizontal row inside a window/scroll area must stay
in that layer's z-order and viewport clip.
Hotkey capture button bound to action in ctx.hotkeys; the block
fires with the new binding (nil = cleared) — the map is already
updated, the block is for side effects like persisting settings.
egui ui.image(texture, size).
egui Ui::interact — delegates to Context/Memory.
egui ui.label — selectable text by default (userselect: false
for the inert paint-only label). wrap nil (default) wraps the
label against the available width in a vertical layout; true
wraps always, false never.
Layer widgets created through this Ui belong to (egui WidgetRect's layer_id) — hit-testing and paint order both read it.
Layer widgets created through this Ui belong to (egui WidgetRect's layer_id) — hit-testing and paint order both read it.
Rendered markdown (headings, lists, quotes, code blocks, rules,
images — inline **bold**/*italic*/`code`/links through
RichLabel). base_dir roots relative image paths. See
Egui::Markdown.
egui Region::expand_to_include_rect: containers grow their
bounding box to cover child regions laid out manually.
A stable, route-addressable widget id: this Ui's id + the name.
When the router owes this page a focus fragment (root/page#name
from --page or navigate) and name matches, the id is also
given keyboard focus right away — that is how deep links land on
a widget. Widgets opt in via their focus_id: parameter.
Windows-style integer spin box (NumberInput): digits-only field
with up/down arrow buttons; the block fires with the new Int32 on
every commit (arrow click, Enter, blur, wheel, arrow keys).
egui_plot-style line/scatter plot; see Plot. animated: true
adds live-plot behavior: double-click (or the overlay button)
resets a manually panned/zoomed view back to the default.
draggable: false makes it read-only (no pan/zoom, default view).
reset_button: false hides the reset pill that otherwise appears
on any panned/zoomed plot.
egui ui.radio_value(&mut value, new_value, text).
egui ui.label(RichText).
egui ui.scope — a nested region with its own id space (children
mint ids under the scope's id, not the parent's counter).
egui ScrollArea::vertical().show(ui, …). scrollbar: :classic
switches the flavor: a separate Win95/XP-style strip beside the
content (arrow buttons, paging track) instead of the thin bar
overlaying the edge. Bar placement per axis: vbar: :left moves
the vertical bar to the left edge; hbar: :bottom/:top turns
on horizontal scrolling with the bar on that edge (see ScrollArea).
Seed the row height (see #@row_h): #horizontal and #add_sized open a row whose baseline height is known upfront.
One-of-many segmented selector; the block fires with the newly selected index.
egui egui::ComboBox + search: a SelectBox — a searchable
select for option lists too long to scan linearly (the font
family catalog). See widgets/select_box.cr.
egui ui.selectable_label(selected, text) (upstream 0.36:
Button::selectable). The block form hands the new state back
when the row is clicked, like #checkbox.
ui.sidebar(sections, section, tab) { |s, t| … } — shows a Sidebar
and hands back the new selection when it changed this frame.
on_close (optional) fires with {section, tab} indices when a
tab's nested close button was clicked — the app removes the tab.
egui ui.hyperlink(url) / ui.hyperlink_to(label, url).
egui ui.add_enabled-style block helpers for value widgets:
the block fires with the new value when it changed this frame.
Vector SVG (mini parser → painter primitives); see Egui::Svg.
Header + body table; see Table.
ui.tabs(titles, selected) { |t| … } — shows a Tabs strip and
hands back the new selection when it changed this frame.
layout: picks the overflow behavior: :carousel (default) keeps
one row that scrolls the active tab into view; :multiline wraps
full rows Windows-Properties-style. closable arms the per-tab
close button (an X nested inside the tab — the nested widget
interacts after the tab, so hit-testing hands the click to the X,
not the tab; a close never selects the tab); on_close (optional)
fires with the tab index when its X was clicked — the app removes
the tab.
One-line entry: draw and drive a full terminal.
egui ui.text_edit_singleline(&mut String, hint): the block fires
with the new buffer whenever it changed this frame. password: true masks the display with circles (one per character).
egui ui.text_edit_multiline — here an HTML-textarea-shaped
widget: soft wrap, rows lines tall, its own kinetic scroll.
Switch-style toggle; block form like #checkbox.
CSS overflow-y: when true, vertical allocations are NOT
clamped to max_rect's bottom edge — content may extend below
(clipped by clip, scrollable through a ScrollArea viewport)
instead of collapsing into zero-height rows. available_height
stays bounded by max_rect, so fill-height widgets keep sizing
to the viewport. Set by ScrollArea#show on its inner Ui.
CSS overflow-y: when true, vertical allocations are NOT
clamped to max_rect's bottom edge — content may extend below
(clipped by clip, scrollable through a ScrollArea viewport)
instead of collapsing into zero-height rows. available_height
stays bounded by max_rect, so fill-height widgets keep sizing
to the viewport. Set by ScrollArea#show on its inner Ui.