class

Egui::Ui

Inherits Reference < Object

Reopen Egui::Ui (NOT Egui::Terminal::Ui) for the one-line entry.

Constants

DEFAULT_WIDGET_SIZE = 10.0

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

new(ctx : Context, id : Id, max_rect : Rect, layout : Layout = Layout.top_down)
Source

Instance methods

add(widget : Widget) : Response

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).

Source
add_sized(size : Vec2, widget : Widget) : Response

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.

Source
allocate_at_least(size : Vec2) : Rect
Source
allocate_space(size : Vec2) : Rect

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).

Source
available_height
Source
available_size

egui Ui::available_size — how much room is left in this region (from the cursor to max_rect's far corner in layout direction).

Source
available_width
Source
big_button(text : String, height : Float64 = 40.0) : Response

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.

Source
button(text : String, id : String | Nil = nil) : Response
Source
canvas(canvas : Canvas, & : Canvas::Interaction -> ) : Response

A pixel Canvas with Paint-style interaction; the block receives this frame's Canvas::Interaction (pointer/drag in pixel coords).

Source
checkbox(checked : Bool, text : String, id : String | Nil = nil, &on_change : Bool -> ) : Response

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.

Source
checkbox(checked : Bool, text : String, id : String | Nil = nil) : Response
Source
checkbox(sig : Signal(Bool), text : String) : Response
Source
child_ui(max_rect : Rect, id : Id | Nil = nil, layout : Layout = Layout.top_down) : Ui

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).

Source
clip

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).

Source
clip=(clip : Rect)

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).

Source
color_edit32(color : Color32, &on_change : Color32 -> ) : Response

egui ui.color_edit32(&mut color): the block fires with the new color when the picker changed it this frame.

Source
columns(n : Int32, &block : Array(Ui) -> ) : Nil

egui ui.columns(n) — split the remaining width into n equal columns; the block receives one Ui per column.

Source
combo_box(id : String, selected : String, options : Array(String), width : Float64 | Nil = nil, variant : Symbol = :button, label : String | Nil = nil, overlay : Bool = false, max_height : Float64 = 220.0, &on_select : String -> ) : Bool

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.

Source
combo_box(id : String, sig : Signal(String), options : Array(String), width : Float64 | Nil = nil, variant : Symbol = :button, label : String | Nil = nil, overlay : Bool = false, max_height : Float64 = 220.0) : Bool
Source
cursor
Source
cursor=(cursor : Pos2)
Source
date_picker(id : String, value : Time, format : String = "%Y-%m-%d", &on_change : Time -> ) : Response

egui_extras DatePickerButton — see DatePicker. The block fires from inside #show on the day click (and Today).

Source
drag_value(value : Float64, speed : Float64 = 1.0, prefix : String = "", suffix : String = "", format : Float64 -> String | Nil = nil, &on_change : Float64 -> ) : Response
Source
drag_value(sig : Signal(Float64), speed : Float64 = 1.0, prefix : String = "", suffix : String = "", format : Float64 -> String | Nil = nil) : Response
Source
enabled(flag : Bool, &block : Ui -> ) : Nil

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.

Source
fonts

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.

Source
frame(fill : Color32 | Nil = nil, stroke : Color32 | Nil = nil, rounding : Float64 = 6.0, margin : Vec2 | Nil = nil, stroke_width : Float64 = 1.0, &block : Ui -> ) : Rect

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).

Source
grid(id : String, &block : Grid -> ) : Rect

egui ui.grid(id) { |grid| … } — aligned columns; see Grid.

Source
heading(text : String) : Response
Source
horizontal

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.

Source
hotkey_edit(action : HotkeyAction, &on_change : Hotkey | Nil -> ) : Response

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.

Source
image(texture_id : UInt64, size : Vec2, tint : Color32 = Color32.new(255, 255, 255, 255)) : Response

egui ui.image(texture, size).

Source
interact(rect : Rect, id : Id, sense : Sense) : Response

egui Ui::interact — delegates to Context/Memory.

Source
label(text : String, wrap : Bool | Nil = nil, userselect : Bool = true) : Response

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.

Source
layer

Layer widgets created through this Ui belong to (egui WidgetRect's layer_id) — hit-testing and paint order both read it.

Source
layer=(layer : LayerId)

Layer widgets created through this Ui belong to (egui WidgetRect's layer_id) — hit-testing and paint order both read it.

Source
layout
Source
markdown(source : String, base_dir : String | Nil = nil, id : String | Nil = nil) : Response

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.

Source
max_rect
Source
min_rect
Source
min_rect=(min_rect : Rect)

egui Region::expand_to_include_rect: containers grow their bounding box to cover child regions laid out manually.

Source
named_id(name : String) : Id

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.

Source
next_widget_id

egui ui.next_auto_id(): parent id + incrementing child salt.

Source
number_input(value : Int32, range : Range(Int32, Int32) | Nil = nil, step : Int32 = 1, prefix : String = "", suffix : String = "", &on_change : Int32 -> ) : Response

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).

Source
number_input(sig : Signal(Int32), range : Range(Int32, Int32) | Nil = nil, step : Int32 = 1, prefix : String = "", suffix : String = "") : Response
Source
painter
Source
plot(id : String, height : Float64 = 200.0, animated : Bool = false, draggable : Bool = true, reset_button : Bool = true, &block : Plot -> ) : Response

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.

Source
progress_bar(fraction : Float64, text : String | Nil = nil, animate : Bool = false) : Response
Source
radio(selected : Bool, text : String) : Response

egui ui.radio(selected, text).

Source
radio_value(selected : Bool, value : Bool, text : String, &on_select : Bool -> ) : Response

egui ui.radio_value(&mut value, new_value, text).

Source
rich(text : RichText, wrap : Bool | Nil = nil, userselect : Bool = true) : Response

egui ui.label(RichText).

Source
scope

egui ui.scope — a nested region with its own id space (children mint ids under the scope's id, not the parent's counter).

Source
scroll_area(max_height : Float64 | Nil = nil, scrollbar : Symbol = :overlay, vbar : Symbol = :right, hbar : Symbol | Nil = nil, &block : Ui -> ) : Rect

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).

Source
seed_row_height(h : Float64) : Nil

Seed the row height (see #@row_h): #horizontal and #add_sized open a row whose baseline height is known upfront.

Source
segmented(selected : Int32, labels : Array(String), &on_select : Int32 -> ) : Response

One-of-many segmented selector; the block fires with the newly selected index.

Source
select_box(id : String, selected : String, options : Array(String), width : Float64 | Nil = nil, label : String | Nil = nil, max_height : Float64 = 220.0, &on_select : String -> ) : Bool

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.

Source
selectable(sig : Signal(Bool), text : String) : Response
Source
selectable(selected : Bool, text : String, id : String | Nil = nil, &on_change : Bool -> ) : Response
Source
selectable(selected : Bool, text : String, id : String | Nil = nil) : Response
Source
selectable_label(selected : Bool, text : String, id : String | Nil = nil) : Response

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.

Source
separator
Source
slider(value : Float64, range : Range(Float64, Float64), text : String | Nil = nil, id : String | Nil = nil, &on_change : Float64 -> ) : Response

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.

Source
slider(sig : Signal(Float64), range : Range(Float64, Float64), text : String | Nil = nil) : Response
Source
spinner(size : Float64 | Nil = nil) : Response
Source
style
Source
svg(source : String, size : Vec2 = Vec2.new(128.0, 128.0), current_color : Color32 = Svg::BLACK) : Response

Vector SVG (mini parser → painter primitives); see Egui::Svg.

Source
table(id : String, headers : Array(String), fractions : Array(Float64) | Nil = nil, &block : Grid -> ) : Nil

Header + body table; see Table.

Source
text_edit_singleline(buffer : String, hint : String | Nil = nil, password : Bool = false, focus_id : String | Nil = nil, frame : Bool = true, &on_change : String -> ) : Response

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).

Source
text_field(sig : Signal(String), hint : String | Nil = nil, password : Bool = false) : Response
Source
textarea(sig : Signal(String), hint : String | Nil = nil, rows : Int32 = 8, frame : Bool = true) : Response
Source
textarea(buffer : String, hint : String | Nil = nil, rows : Int32 = 8, frame : Bool = true, &on_change : String -> ) : Response

egui ui.text_edit_multiline — here an HTML-textarea-shaped widget: soft wrap, rows lines tall, its own kinetic scroll.

Source
toggle_button(sig : Signal(Bool), text : String | Nil = nil) : Response
Source
toggle_button(checked : Bool, text : String | Nil = nil, id : String | Nil = nil, &on_change : Bool -> ) : Response

Switch-style toggle; block form like #checkbox.

Source
toggle_button(checked : Bool, text : String | Nil = nil, id : String | Nil = nil) : Response
Source
tree_view(id : String, &block : TreeView -> ) : Nil

Hierarchical list; see TreeView.

Source
v_overflow

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.

Source
v_overflow=(v_overflow : Bool)

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.

Source