Expand description
GUI application state and rendering.
State: the loaded Model, a live session::Engine (built over all derived
measures), the current derived-measure snapshot, and the selected measure.
The panels and windows (model browser, pivot grid, formula editor, Info
panel) are all
rendered each frame from this state. The GUI is a pure view/controller
over improv_engine + the model; it adds no modeling semantics (see
.agent/steering/AGENT_GUI_STEERING.md §9.3).
The engine is rebuilt (a structural rebuild) only when the measure structure
changes — a formula edit or a new derived measure. Plain cell-value edits go
through engine.set incrementally.
Structs§
- Formula
Row - One row of the formula pane: a single derived measure’s formula as the
reference’s numbered, checkable list shows it (
✓ 1. Gross Margin = Sum of Revenue - Sum of Cost of Sales). - Gutter
Rects 🔒 - The measured screen geometry of the grid’s margin gutters and the table they frame, as laid out in the last frame.
- Improv
App - The running GUI application.
- Inspector
Data 🔒 - Read-only facts about a measure, assembled for the Info panel.
- Matrix 🔒
- One matrix on the canvas: a measure, that matrix’s OWN pivot / filter /
cursor / cell-editor state, and where it sits (
rect).
Enums§
- Axis
- Which grid axis a category is assigned to.
- Filter
Req 🔒 - A filter change asked for from a category tile’s menu, applied to that tile’s matrix after the gutters are laid out (like a re-pivot move).
- Formula
Editor 🔒 - One of the formula pane’s two editors.
Constants§
- CASCADE 🔒
- How far a newly added matrix is offset from the last one, in points, so a
fresh matrix never lands exactly on top of its predecessor (the classic
cascade). See
ImprovApp::add_matrix. - DISABLED_
MARKER 🔒 - The reserved leading marker in [
Measure::description] that flags a derived measure’s formula as disabled — the reference’s cleared✓(seedocs/reviews/2026-09-22-gui-reconstruction-plan.mdStep 2). - EDGE_
EPS 🔒 - Tolerance, in points, for the gutter-adjacency invariant. The edges are computed from the same panel cursor so they agree exactly; half a point of slack only guards against rounding in egui’s pixel alignment.
- GRID_
MIN_ 🔒H - Height a worksheet window keeps for its gutters and grid: its formula pane grows (or defaults) no taller than what leaves this much above it.
- INITIAL_
WINDOW - Initial window inner size: room for the menu, a default matrix and the Info panel side by side on the workspace.
- MARKER_
SEP 🔒 - Separator between the marker and the user’s own description text.
- MATRIX_
MIN_ 🔒H - MATRIX_
MIN_ 🔒W - Smallest a worksheet window can be resized to. Below roughly this it has no
room for its gutters and a cell, so shrinking further would only hide its
own chrome;
gutters_have_roomis the same judgement about the window. - MENU_
CLEAR 🔒 - Where a fresh canvas’s first matrix starts on the workspace: right of the application menu (at x 4, about 110 wide), as in the NeXT layout.
- MIN_
WINDOW - Minimum window inner size. Smaller windows still never overdraw the side panels (the canvas clips), but the matrix would be mostly scrolled away.
- STATUS_
TTL 🔒 - Seconds a status message stays up before the status bar clears it.
- TILE_H 🔒
- A category tile’s height (the NeXT tiles are 17 px tall).
- UNDO_
DEPTH 🔒 - How many model states the undo (and redo) stack keeps; older entries are evicted.
Functions§
- aggregation_
dsl 🔒 AGG(args…)with itsOVERclause after the first reduced argument (the parser accepts it after any), the window orWHEREthere too.Nonewhen the shape has no spelling (a reduced argument that is not a plain reference, reduced arguments with differentOVERlists,EXCEPT).- anchored_
rect 🔒 - The rect to show NxWindow
winat:homeon the workspace until the user moves or resizes it, then where they left it. The workspace settles over the first frames and follows the native window’s size, so a plaindefault_rectwould keep the first frame’s guess. - assisted_
formula_ 🔒edit - A formula editor with autocomplete (
crate::completion): while a name is typed (at or after bytefrom), a list of what may complete it drops under the edit (Up/Down select, Tab or Enter accept, Esc closes; a click accepts too), the rest of the selected name and its parameters trail the caret in light gray, and a tooltip shows the signature of the function being completed or called, the current argument in bold. With the list closed every key reaches the edit, so Enter still commits. - bound_
dsl 🔒 - A window bound literal as written:
FIRST,LAST,THIS,THIS-2. - build_
engine 🔒 - Build a live engine over all derived measures in
model, plus its initial snapshot. Falls back to no engine (inputs still render) on build failure. - call_
dsl 🔒 - caret_
byte 🔒 - Byte offset of the caret in text edit
idovertext(its end when the edit has none yet). - category_
name 🔒 - cell_
key_ 🔒multi - The sorted
CoordKeyfor a cell when categories are STACKED on each axis:row_cats[i]binds torow_tuple[i],col_cats[j]tocol_tuple[j], plus the pinned page dims. Tuples come fromaxis_tuplesso they align with the category list. The general form ofcell_key. - child_
dsl 🔒 expr_dsl, parenthesized whenebinds more loosely than its context.- completion_
list 🔒 - The completion list under (or, without room, over) the edit
resp,selhighlighted; its rect is kept underridso a press on it can pick a row. Returns whether it went below. - consume_
enter 🔒 - Swallow this frame’s Enter once a text field has acted on it, so the grid (drawn later, and now seeing no focus) doesn’t start a cell edit.
- decode 🔒
- engine_
model 🔒 modelas the ENGINE must see it: every measure whose formula is disabled flattened toMeasureKind::Input, keeping its (still-stored) formula out of the dataflow entirely.- expr_
dsl 🔒 - formula_
disabled 🔒 - Whether
m’s formula is disabled (seeDISABLED_MARKER). Always false for an input measure, which has no formula to disable. - formula_
dsl 🔒 - Render
formulaas symbolic-DSL source text thatparser::parse_exprparses back to the identical AST, orNonewhen the v1 grammar has no exact spelling for the shape (a bare ref carryingover/except, a multi-categoryOVER, an empty measure/category name, an enum/error/negative/exponent literal, an unknown function id). Callers fall back to the controlled-English description for those, whichcommit_formulaalso accepts. - formula_
error_ 🔒lines - A formula error under its row, indented past the checkbox and number: the message, and under it the hint, dimmed.
- formula_
fault 🔒 - An engine-build failure for formula
text, located in it;Nonefor a failed save, which is no fault of the text. - formula_
text_ 🔒edit - A formula editor: a single-line edit of
textwith idid, highlighted, the errorspanunderlined, filling the row.keep_tab: Tab stays in the edit rather than moving the focus. - func_
name 🔒 - The DSL name of a built-in function id, from the function registry.
- grid_
keys_ 🔒enabled - Whether the grid’s single-key bindings (cursor motion, paging, measure cycling, undo/redo) should act this frame.
- gutters_
frame_ 🔒table - Whether the gutters genuinely frame the table: the row gutter’s right edge is the table’s left edge, the column gutter’s bottom edge is the table’s top edge, each gutter spans the table along its other axis, and the corner well sits below the table at the row gutter’s left edge.
- gutters_
have_ 🔒room - Whether the window left the gutters enough room to be laid out at all.
- ident 🔒
- The DSL spelling of
nameas an identifier: the bare form when the tokenizer reads it back as a single non-keyword identifier, else the quoted form ('Unit Price') the grammar gained in plan Step 4a. - is_
aggregation 🔒 - Whether
funcaggregates (SUM(x OVER T)), per the function registry. - is_
bare_ 🔒ident - Whether
namesurvives a round trip through the tokenizer as one bare identifier that the grammar will not mistake for a keyword. - join_
marker 🔒 - Rebuild a description from the two parts
split_markertakes apart — its inverse for every inputsplit_markercan produce. - literal_
dsl 🔒 - matrix_
window_ 🔒id - The
crate::nxwin::NxWindowid of the worksheet window of the matrix whose uid isuid. - natural_
axis_ 🔒order - The measure’s categories in natural (declared) order (empty if none/absent).
- next_
matrix_ 🔒uid - A fresh
Matrixuid. - nth_
tuple 🔒 - The i-th line of the Cartesian product of
lists(outer category first), by mixed-radix decoding ofiacross the list lengths — the inner (last) category is the least-significant digit, matchingaxis_tuples’ ordering (which increments the inner category fastest). Returns the bound(ItemId, name)per category. - parse_
typed 🔒 - Parse cell text as
declared, the measure’s declared type. The declared type WINS over the text’s shape:"42"for a Text measure is text, not a number. Unparsable text is an error (never a coerced value), so a bad edit leaves the prior typed cell untouched. - pick_
default_ 🔒measure - prec 🔒
- Binding tightness, mirroring
parser’s grammar levels (higher binds tighter). Used to emit exactly the parentheses needed to round-trip. - product_
len 🔒 - The number of axis lines the Cartesian product of
listsproduces: the product of each list’s length (emptylists-> 1, the scalar axis; any empty list -> 0, no lines). Mirrorsaxis_tuples(..).len()but is O(k) in the number of categories, never materializing the product. - push_
bounded 🔒 - Push
stateonto a bounded history stack, evicting the oldest entry onceUNDO_DEPTHis reached. - ref_dsl 🔒
- set_
caret 🔒 - Put the caret of text edit
idovertextat byteat. - signature_
tooltip 🔒 - The signature tooltip over (
above) or under the editresp:name’s parameters with argumentargbold and underlined, thend’s description and category. - split_
marker 🔒 - Split a measure description into
(formula disabled, the user's own text). - try_
build_ 🔒engine - Build a live engine over every enabled derived measure in
model, propagating a build failure (cycle, type/dimension error) instead of swallowing it. A measure whose formula is disabled (DISABLED_MARKER) is excluded, viaengine_model. - white_
selection 🔒 - Give
ui’s selected rows a white face. The palette makes egui’s selection fill and hover fill the same gray as the panel, so a selectedselectable_labelwould look merely hovered. Call inside aui.scope(or a child ui) so text-edit selection keeps the theme’s color.
Type Aliases§
- Chart
Axes 🔒 - The resolved pivot for the chart: the ROW category stack, the COLUMN stack,
and the pinned
(category, item)for every PAGE dimension. - Grid
Scroll 🔒 - A grid’s horizontal scroll area, wrapping its table’s vertical one and the rect that vertical scroller was laid out in.