class

Egui::Context

Inherits Reference < Object

Constants

PANEL_GRIP = 6.0

Panel resizing (egui Panel::resizable, default there too): a drag grip on the panel's inner edge grows/shrinks it, persisted per panel id in Memory. height:/width: become the INITIAL size.

PANEL_GRIP_SALT = 10375585_u64

also the minimum default panel extent

PANEL_MIN_SIZE = 20.0
PANEL_SIZE_SALT = 85635813_u64
WINDOW_MIN_SIZE = Vec2.new(120.0, 80.0)

A titled, movable, resizable window. egui order preserved: reserve the background slot, interact with the title bar (drag → Areas state moves the window; click/hover → bring to top), build contents, back-fill the frame, title.

Constructors

Instance methods

action_fired?(action : HotkeyAction) : Bool

Was action fired this frame (hotkey or menu click)? Does not claim it — use #consume_action for exactly-once handling.

Source
animate_value_with_time(id : Id, value : Float64, duration : Float64 = 0.15) : Float64

egui Context::animate_value_with_time: smoothly move value towards its new target; state keyed by widget id.

Source
area(id : String, default_pos : Pos2 = Pos2.zero, width : Float64 = 300.0, &block : Ui -> ) : Nil

egui Area (containers/area.rs) — an explicit positioned region in its own Middle layer: the building block window/popup are made of, exposed for custom floating content. Position persists in Areas (bring-to-top on interaction, like a window without chrome).

Source
available_rect

egui Context::available_rect: screen area not yet claimed by panels. Reset each begin_frame; every panel takes a bite; the central panel takes what's left (panels must be added first — the upstream ordering rule).

Source
begin_frame(raw : RawInput) : Nil
Source
bold_fonts

REAL variant faces of the primary stack — what bold/italic text measures and draws through (Sokol.select_fonts(bold:/italic:/ bold_italic:)). Nil = the variant isn't installed: the text serves through the base #fonts' own glyphs, never an emulated one.

Source
bold_fonts=(bold_fonts : Fonts | Nil)

REAL variant faces of the primary stack — what bold/italic text measures and draws through (Sokol.select_fonts(bold:/italic:/ bold_italic:)). Nil = the variant isn't installed: the text serves through the base #fonts' own glyphs, never an emulated one.

Source
bold_italic_fonts
Source
bold_italic_fonts=(bold_italic_fonts : Fonts | Nil)
Source
bottom_panel(id : String = "bottom_panel", height : Float64 | Nil = nil, resizable : Bool = true, layer : LayerId | Nil = nil, fill : Color32 | Nil = nil, &block : Ui -> ) : Rect
Source
central_panel(id : String = "central_panel", fill : Color32 | Nil = nil, &block : Ui -> ) : Rect

egui CentralPanel::show — the remainder. Returns its rect.

fill overrides the panel background (nil → the style's panel_fill) — Color32.transparent makes the central panel paint nothing, so a widget that draws its own (possibly translucent) background shows the desktop through a transparent window.

DEFERRED (egui.cr fix, no upstream counterpart): the block does not run here — #end_frame renders it after every other panel has bitten #available_rect, so the central panel ends up with the true remainder whatever order the app declared panels in (a bottom status bar after the central panel used to paint OVER its content). The return value is the remainder at CALL time — exact when the central panel is declared last (the recommended style), approximate if later panels still bite.

Source
claim_widget_id(id : Id, name : String, kind : String) : Nil

Claim id for a widget created with the explicit name name (kind is the widget class, for the error message). Ids are claimed once per frame; a second claim of the same id raises — explicit ids are the developer's addressing tool and must be unique. Auto ids skip this (their collisions stay on the silent Memory duplicate accounting).

Source
clear_id_style(id : Id, key : String | Nil = nil, state : String | Nil = nil) : Nil

Remove one key (nil = wipe every key of every state) from a per-element override; the slot goes back to inheriting the cascade. Empty bags are dropped entirely.

Source
close_popup(id : String) : Nil
Source
consume_action(action : HotkeyAction) : Bool

egui consume_key semantics for actions: the first caller claims the fired action; later callers this frame see false. Actions live for one frame — an unconsumed firing expires.

Source
current_widget

The widget currently running through Ui#add (set there, read by #interact for inspector meta recording). Internal.

Source
current_widget=(widget : Widget | Nil) : Widget | Nil
Source
cursor_icon

The cursor the frame asked the integration to show (upstream PlatformOutput::cursor_icon): reset to Default each begin_frame, set by widgets via #set_cursor_icon / hover.

Source
cursor_image

Upstream PlatformOutput::cursor_image: when set, the integration should display this RGBA bitmap as the OS cursor instead of #cursor_icon (backends without support fall back to the icon). Reset each begin_frame, set via #set_cursor_image.

Source
cut_stack(path : String) : String

Register (once) the deferred stack for one font FILE and return its family name — the "wght:<path>" cut stacks of the weight axis measure through #fonts_for(name) and draw through the backend's registry.

Source
deferred_font_paths

Font families whose stack is NOT loaded yet: family name → font file paths (the system scan's output). Materialized into #font_families by #fonts_for on FIRST USE through #font_loader — startup pays for names only; the parse happens for the families actually picked. The reserved names are not deferrable (they are the built-in slots).

Source
deferred_font_paths=(deferred_font_paths : Hash(String, Array(String)))

Font families whose stack is NOT loaded yet: family name → font file paths (the system scan's output). Materialized into #font_families by #fonts_for on FIRST USE through #font_loader — startup pays for names only; the parse happens for the families actually picked. The reserved names are not deferrable (they are the built-in slots).

Source
ecss
Source
ecss=(ecss : Ecss::Session | Nil)
Source
embedded_window(id : String, title : String | Nil = nil, width : Float64 = 460.0, close_on_escape : Bool = true, close_on_scrim : Bool = true, &block : Ui -> ) : Bool

An embedded window — a MODAL window with chrome: what #modal is for content dialogs, this is for an app's dialog WINDOWS (Settings, Theme…): it dims the screen and blocks interaction below the Foreground layer (Memory#mark_modal) while floating as a titled, DRAGGABLE window with a ✕ — the caller keeps the open flag and drops it when this returns true.

Centered on the measured size every frame until the user drags the window (the very first frame of a session uses a height estimate, so the card settles once when its content is first measured), auto-fits its content like #window without a resize grip (dialogs are content-sized), stays on screen (#constrain_floating — the top never goes above the screen, so a dialog taller than the screen pins at the top). title: nil drops the title bar down to a slim drag handle.

Returns true the frame the user asked to close it: the ✕, the scrim (when close_on_scrim:, the dimmed area IS the dismiss target) or Escape (close_on_escape:).

Source
end_frame
Source
fire_action(action : HotkeyAction) : Nil

Fire action programmatically this frame (what a menu-item click does): the app's #consume_action handler sees it, wherever the app polls actions from.

Source
fired_actions

Actions fired this frame (hotkey presses + #fire_action), oldest first. Read-only view of the frame's action events.

Source
font_families

Named font families (upstream FontDefinitions::families): a family name → font stack registry, so a GROUP of widgets can swap fonts through the style cascade (font_family key). The backend registers stacks via Sokol.register_font; two names are reserved for the built-in slots — "system" → the primary #fonts (whatever the backend loaded: the system face, a preselected stack…), "monospace" → #mono_font.

Source
font_families=(font_families : Hash(String, Fonts))

Named font families (upstream FontDefinitions::families): a family name → font stack registry, so a GROUP of widgets can swap fonts through the style cascade (font_family key). The backend registers stacks via Sokol.register_font; two names are reserved for the built-in slots — "system" → the primary #fonts (whatever the backend loaded: the system face, a preselected stack…), "monospace" → #mono_font.

Source
font_family_catalog

The catalog of family names a font_family style key can be set to: every registered named stack, every deferred (not yet materialized) family, plus the reserved "system" (the primary — always resolvable, whatever the backend loaded) and "monospace" (resolvable even when no mono stack is installed — it degrades to the primary). Sorted; what a font picker offers. "unset the key" is how a picker returns to the theme slot (Style#font_family, nil by default → the primary).

Source
font_loader

The stack builder for #deferred_font_paths — the backend's from_system chain, installed at on_init. Nil headless: a deferred family degrades to the primary stack there.

Source
font_loader=(font_loader : Proc(Array(String), Fonts | Nil) | Nil)

The stack builder for #deferred_font_paths — the backend's from_system chain, installed at on_init. Nil headless: a deferred family degrades to the primary stack there.

Source
font_register

Draw-side twin of #register_deferred_font, installed by the backend at on_init: a deferred family must be resolvable when a TextCmd NAMES it, and the measure side (#fonts_for) alone doesn't register anything the backend knows. Cut stacks created lazily by #fonts_for_weight go through here too.

Source
font_register=(font_register : Proc(String, Array(String), Nil) | Nil)

Draw-side twin of #register_deferred_font, installed by the backend at on_init: a deferred family must be resolvable when a TextCmd NAMES it, and the measure side (#fonts_for) alone doesn't register anything the backend knows. Cut stacks created lazily by #fonts_for_weight go through here too.

Source
font_weight_axis(family : String | Nil) : Array(Int32)

The weight axis a family REALLY has on this system — the distinct roman cuts of its installed files (Thin 100 … Black 900), empty for unknown families and the mono slot. This is what the inspector's smart weight selector offers.

Source
fonts
Source
fonts=(fonts : Fonts)
Source
fonts_for(family : String | Nil, bold : Bool = false, italic : Bool = false) : Fonts

The stack a family-tagged text measures/draws through: nil or an unknown name → the primary #fonts (a typo degrades to the default, CSS vibes), "system" → the primary, "monospace" → #mono_font. A deferred family materializes HERE — the first resolution parses the files, swaps the placeholder out of #deferred_font_paths and never pays again.

bold/italic shift the PRIMARY resolution to a real variant face when one is installed (#bold_fonts & co — the measure-side twin of the backend's #fonts_for_cmd); a missing variant degrades to the nearest real face (bold+italic → bold → base), headless Contexts included: #fonts serves everything there.

Source
fonts_for_weight(family : String | Nil, weight : Float64 | Nil, bold : Bool) : Tuple(Fonts, String | Nil, Bool)

Resolve (family, weight, bold) to what a widget lays out and draws its base text through — a REAL cut face when the family has one for the target weight, else the family's own stack with a bold flag (the primary's variant faces pick that up; a family without variants degrades to its regular face, no emulation). Returns {fonts, family-for-commands, bold-flag}.

The target: the cascade weight when one is set (the inspector / class-rule value beats a .bold RichText), else the CSS bold slot 700 for bold markup, else 400. A target that lands on the family's own regular file never substitutes — the curated primary stack keeps serving unstyled text.

Source
frame_cache(key : String, &block : -> IdTypeMap::Cell) : IdTypeMap::Cell

egui CacheStorage-lite: memoize an expensive computation for the current frame only (cleared in begin_frame).

Source
hotkey_capture_active!

A HotkeyEdit is capturing the next key press: pause global hotkey dispatch for the next frame so the combo being recorded cannot trigger an action. Called every frame while capturing.

Source
hotkeys

The app-global hotkey → action bindings (see hotkeys.cr). Actions fired this frame (key press or #fire_action) live for exactly one frame and are claimed with #consume_action.

Source
id_style_overrides

Runtime per-element style overrides (the inspector's Element tab). The top layer of the cascade — see Widget#effective_style.

Source
id_style_state_vars(id : Id, state : String | Nil) : StyleVars | Nil

The per-element override bag for state: base keys with the state overlay merged on top (a fresh copy — safe to mutate). Nil when the id has no overrides at all.

Source
in_frame?

True while the frame is being built (begin_frame…end_frame). The reactive layer uses it to skip pointless repaint requests for signal writes made during update.

Source
input
Source
inspector

The inspector state (built on first enable — zero cost while off). The backend drives its frame hooks; see inspector.cr.

Source
inspector?
Source
inspector_enabled=(flag : Bool) : Bool

Enable/disable the inspector at runtime (Sokol.run(…, inspector: :on) flips this on before the first frame).

Source
inspector_enabled?
Source
interact(id : Id, rect : Rect, sense : Sense, layer : LayerId = LayerId.background, clip : Rect = Rect.infinite) : Response
Source
italic_fonts
Source
italic_fonts=(italic_fonts : Fonts | Nil)
Source
load_image(path : String) : UInt64

egui Context::load_texture: decode an image file and cache it per path; 0 means "couldn't load".

Source
memory
Source
mono_font

The font stack mono text measures/draws through: #mono_fonts when the backend installed one, #fonts otherwise.

Source
mono_fonts

The monospace font stack (terminal grids, code) — nil means "same as #fonts". The backend installs a second stack via Sokol.select_fonts(font, mono:); widgets that need mono METRICS read #mono_font, never this nullable property.

Source
mono_fonts=(mono_fonts : Fonts | Nil)

The monospace font stack (terminal grids, code) — nil means "same as #fonts". The backend installs a second stack via Sokol.select_fonts(font, mono:); widgets that need mono METRICS read #mono_font, never this nullable property.

Source
needs_repaint?
Source
open_popup(id : String) : Nil
Source
page(id : String, title : String | Nil = nil, on_back : -> Nil | Nil = nil, fill : Color32 | Nil = nil, &block : Ui -> ) : Rect

A full-window page below the caption (see Egui::Page). The app owns navigation — this only renders the page it is asked for. title: draws the header title; on_back: arms the round back button and fires the callback on click. The page bites the whole remainder, like any other panel — but only AFTER the deferred central panel registered inside it is flushed, so a page containing ctx-level panels behaves like a frame of its own.

Source
painter
Source
pixels_per_point

Framebuffer pixels per UI point (retina: 2.0), set by the backend each frame — 1.0 headless. Raster caches (Svg textures, like the font atlas) bake at this scale so a 2x display gets 2x-texel rasters, not upscaled blur.

Source
pixels_per_point=(pixels_per_point : Float64)

Framebuffer pixels per UI point (retina: 2.0), set by the backend each frame — 1.0 headless. Raster caches (Svg textures, like the font atlas) bake at this scale so a 2x display gets 2x-texel rasters, not upscaled blur.

Source
primary_family_name

The REAL family name of the primary stack (read from its source file's name table) — what the weight axis resolves a nil family against. Nil headless / for synthetic stacks: no cuts then.

Source
register_deferred_font(name : String, paths : Array(String)) : Nil
Source
register_font_family(name : String, fonts : Fonts) : Nil
Source
request_repaint

egui repaint scheduling: an immediate request buys two repaints so frame-delayed responses settle. The backend honors this — on an idle frame (no events, no request, nothing animating) it skips app.update/tessellation and re-emits the last paint commands.

Source
router

The app's route stack (see Egui::Router). Lazy: apps that never call #routes never allocate one.

Source
router?
Source
routes

Declare this frame's pages and render the current route stack when the block ends (see Egui::Router):

ctx.routes do |r| r.page "root/root" { |ui| … } r.modal "root/confirm", title: "Sure?" { |ui| … } end

Source
set_cursor_icon(icon : CursorIcon) : Nil

egui Context::set_cursor_icon: a widget requests the cursor while hovered/dragged; the backend reads #cursor_icon after end_frame.

Source
set_cursor_image(image : CustomCursorImage | Nil) : Nil

egui Context::set_cursor_image: display this RGBA bitmap as the OS cursor for the frame, instead of the standard #cursor_icon — the CSS cursor: url(…) equivalent. Backends without bitmap-cursor support silently fall back to the icon. Pass nil to clear. Reset each begin_frame.

Source
set_id_style(id : Id, key : String, value : StyleValue, state : String | Nil = nil) : Nil

Set one per-element style key (inspector Element tab), optionally scoped to an interaction state ("hover"/"active"; nil = base — applies to every state unless the same layer defines a state value, CSS inline-style semantics). Applies on the next frame — immediate mode needs no apply step.

Source
side_panel(side : Symbol, id : String = "side_panel", width : Float64 = PANEL_MIN_SIZE, resizable : Bool = true, layer : LayerId | Nil = nil, fill : Color32 | Nil = nil, &block : Ui -> ) : Rect
Source
style

The active theme's style — what every un-overridden widget reads.

Source
stylesheet

The active theme's CSS-like class styles (see StyleSheet).

Source
textures
Source
textures=(textures : TextureRegistry)
Source
theme

The active global theme. Widgets read its #style every frame, so assigning a new theme (ctx.theme = Theme.light) restyles the entire UI on the very next frame — an instant swap.

Source
theme=(theme : Theme) : Theme

Instant theme swap (see #theme) — takes effect next frame. Idempotent: assigning the theme already in place (compared by name) is a no-op and does not request a repaint, so an app may re-assign unconditionally every frame.

Source
top_panel(id : String = "top_panel", height : Float64 | Nil = nil, resizable : Bool = true, &block : Ui -> ) : Rect

height pins the strip height (nil → #default_strip_height); the client-side window frame uses it for its caption. resizable (default) adds the drag grip on the inner edge — the size persists across frames and restarts-of-frame-loop; pass false for fixed chrome strips (the window frame does).

Source
window(title : String, default_pos : Pos2 = Pos2.new(24.0, 24.0), width : Float64 = 380.0, &block : Ui -> ) : Nil
Source
with_inspector_widget(widget : Widget, & : -> _)

Run the block with widget as the current_widget — the manual twin of what Ui#add does around widget.ui. Paint-in-place sites (menu rows, title-bar tab cards) wrap their direct #interact calls in this so the inspector records meta for them; with the inspector off it is a plain yield (zero cost).

Source