T-045 — Resizable editor: host and corner-grip resizing, the size kept in the project, layouts that reflow with the width

Status: done (maintainer looked at the screenshots and resized the editor in Reaper on Linux, 2026-12-04) · Area: rust · Depends on: T-044

Read for that: Spec 003 (Window, Verification), T-044 (Decisions, Outcome), T-019 (D1: v4 sections), T-049 (the Microtuning group on Edit), crates/piano/src/{gui.rs,gui/keyboard.rs,gui/tunings.rs,lib.rs}, crates/params/src/state.rs (EDIT), scripts/gui-smoke-test.sh; the real APIs: clack-extensions-0.2.0/src/gui/{plugin,host}.rs (can_resize, get_resize_hints, adjust_size, set_size; host request_resize), baseview-0.4.2/src/window.rs (Window::resize) and platform/x11/sizing.rs, egui-baseview-0.9.0/src/window.rs (resized).

Why: the editor is fixed at 720 × 400 logical points (T-020 D4). Play is full at that size, so T-049 had to put Microtuning on Edit, and on large screens the controls and keyboard stay small. Spec 003 plans a resizable window with layouts that reflow.

What

  1. CLAP resizing: can_resize → true; get_resize_hints → both axes, no aspect-ratio constraint; adjust_size clamps to the limits (D3) in the host’s units (physical pixels on Windows/X11, logical points on macOS: the same rule as today’s host_size); set_size resizes the baseview window through Window::resize (physical on X11, as window_size does today because of baseview’s X11 scale handling), and egui reflows on egui-baseview’s resized. The window is created with with_resizable(true) so baseview does not pin X11 size hints to one size. A set_size before set_parent only stores the size.
  2. Corner grip (D1): a small drawn grip at the bottom-right of the dock; dragging it calls the host’s request_resize with the clamped size, and the window follows when the host answers with set_size. If the host refuses or lacks the call, the grip does nothing.
  3. Reflow (D2, D4) from one pure function of the window’s logical width: narrow (< 700): one column of control groups, meters below, the middle region scrolling on its own; standard (700–999): today’s two columns, meters below; wide (≥ 1000): two columns of controls, the stereo meters as a vertical pair at the right, and (D5) the Microtuning group on Play. Header and dock keep their height; the keyboard always spans the width (D6).
  4. Size in the project (D3): the last size in the state’s EDIT section, used by get_size when the editor next opens.

Out of scope: Edit’s note list beside or above the inspector (Spec 003; it comes with the inspector in T-047, which reuses the width classes of item 3), octave zoom or scrolling of the keyboard (with T-046, when keys become click targets), a UI zoom setting (D2 b).

Decisions (accepted by the maintainer, 2026-12-04)

QuestionOptionsProposal
D1Who resizes(a) the host’s window frame (set_size) plus a corner grip in the editor (request_resize); (b) the host’s frame only; (c) (a) plus a menu of fixed sizes(a): several hosts give plugin windows no frame handle (and the later VST3/AU wrappers vary), so the grip is the one way that always exists; it is a few lines over the same path. (c) adds UI for what dragging already does
D2What a larger window does(a) reflow: controls keep their ~14 pt size and the layout uses the space (Spec 003’s responsive layouts); (b) zoom: everything scales with the window, layout fixed; (c) both, zoom as a separate setting(a): what the Spec describes; the host’s display scale already handles high-DPI. (b) is easy to add later (egui’s zoom factor), but needs care: egui-baseview resizes the window when the zoom changes
D3Limits, default, where the size is kept(a) default 720 × 400 (unchanged), minimum 480 × 360, maximum 2560 × 1600 logical points, free aspect; kept per project in EDIT version 2 [2, theme, width u16, height u16] (logical points), version 1 still read (default size); not in presets; a resize marks the state dirty; (b) the same, size not kept (always opens at 720 × 400); (c) kept in a user-wide config file(a): a project reopens as it was left, like the theme (T-044 D1); 480 is the narrowest width where one column of controls (label 106 + slider 125 + value 80 + margins) still fits; free aspect because the middle scrolls
D4Layout breakpoints(a) three width classes of the window, < 700 / 700–999 / ≥ 1000 logical points, as in What 3; height only changes how much scrolls; (b) continuous columns (as many as fit)(a): three tested layouts instead of open-ended ones; the classes are a pure function, unit-tested, and T-047 reuses them
D5Microtuning on Play(a) in the wide class, Play also shows the Microtuning group (MTS-ESP switch, status, Scala choosers) as a third block under Tuning; Edit keeps it as now; (b) Microtuning stays on Edit only(a): Status and T-049 put it on Edit only because Play was full; the same widgets in two tabs get distinct egui ids (push_id per tab)
D6Keyboard(a) fit to the window’s width at every size (as now: white-key width = width / 52); zoom and scrolling come with T-046; (b) octave zoom now(a): the keyboard is display-only until T-046, so key size matters for reading, not hitting; at 480 points a white key is ~9 points, still readable for held/sounding marks

Done when

  • The gates of AGENTS.md pass, including bundle, clap-validator and the GUI smoke test.
  • Tests: adjust_size clamps to the limits at scales 1, 1.5, 2 in host units (and in logical points on macOS); get_size returns the stored size; set_size before set_parent is kept; the width-class function at its boundaries; EDIT v2 round-trip, v1 loads with the default size, a size outside the limits loads clamped, the size is not in presets; the layout still gives every table entry one control in group order in each class (and Microtuning on Play only in wide); a host test (clack-host) sees can_resize and the resize hints; no_alloc passes.
  • The smoke test takes a size (GUI_SMOKE_SIZE=WxH) and resizes while a chord sounds; screenshots in light and dark at 720 × 400, 1100 × 600 and 480 × 360, and one at scale 2, attached to the outcome.
  • The default sound is unchanged (golden test).

Outcome

  • Size logic in crates/piano/src/gui/size.rs (pure, unit-tested): limits MIN 480 × 360, DEFAULT 720 × 400, MAX 2560 × 1600; to_host/from_host (physical pixels on Windows/X11, logical points on macOS); adjust clamps in host units and keeps a host’s exact size inside the limits; WidthClass::of(width) (Narrow < 700, Standard < 1000, Wide); EditorSize, an AtomicU32 (width ≪ 16 | height, 0 = default) shared by the main thread, the editor and the state; grip_size for the grip.
  • CLAP (gui.rs, PluginGuiImpl): can_resize true, resize hints on both axes with AspectRatioStrategy::Disregard, adjust_size, set_size → PianoMainThread::resize_editor (clamps, keeps the logical size, resizes the baseview window if one is open: physical on X11 and Windows, logical on macOS (Windows was logical until T-054), and marks the state dirty if the size changed). get_size reports the host size last accepted (T-054; without one, the kept logical size in host units); the window is created at it with with_resizable(true).
  • Grip (Grip in gui.rs): three diagonal hairlines in the bottom-right corner, in a foreground Area, cursor ResizeNwSe. A drag stores the asked-for logical size in PianoShared::grip_request and requests a main-thread callback; on_main_thread → handle_grip_request calls the host’s request_resize and, when the host accepts, resizes like set_size (CLAP does not promise a set_size after an accepted request). A host that refuses or lacks the call leaves the window as it is.
  • State: EDIT v2 [2, theme, width u16, height u16] (crates/params/src/state.rs, Snapshot::editor_size). While the editor was never resized the section stays v1, so a project saved without a size is byte-identical to before and older builds keep its theme. A malformed v2 section is ignored like an unknown v1 payload; out-of-range sizes load clamped. Presets carry no size, and loading one keeps the size. Loading a project while the editor is open changes the size for the next opening; the open window keeps its size.
  • Layout (EditorApp::play): Narrow: one column of groups, then the meter caption and the meters on their own row; the header drops the model name (Details has it). Standard: unchanged from T-044. Wide: two columns, Microtuning (switch, status, Scala choosers) under Tuning, meters as an L/R pair in a 240-point column at the right. The keyboard spans the width at every size.
  • Tests: gui::size::tests (width classes, adjust at scales 1, 1.5, 2, host units, the kept size, the grip), every_width_class_shows_each_play_control_once_and_microtuning_only_when_wide, the_header_fits_at_every_size_and_drops_the_model_name_when_narrow, dragging_the_corner_grip_requests_the_new_size (egui frames with pointer events), editor_size_round_trips_in_edit_v2_and_v1_has_none (params), and the host test editor_size_is_resizable_kept_in_the_project_and_not_in_presets (clack-host: hints, adjust_size, set_size before set_parent, scale 2, presets, project loads, clamping).
  • Smoke test: GUI_SMOKE_SIZE=WxH resizes the open editor through adjust_size/set_size and checks the child window’s geometry; Xvfb’s screen is now 2560 × 1600. On Xvfb’s software OpenGL in a debug build the first frame at a new size came ~0.4–0.6 s after the resize (at scale 1.5 and 2; the earlier frame is drawn into the old buffer, partly black), so the test waits until the right edge is drawn. Not seen yet on a real GPU or a release build.
  • Gates (2026-12-04): cargo fmt --check, cargo clippy --all-targets -- -D warnings, cargo nextest run (201 passed, 2 skipped), Julia Pkg.test(), cargo xtask bundle piano --release, clap-validator validate (38 passed, 0 failed, 6 skipped), the GUI smoke test at 720 × 400, 1100 × 600, 480 × 360 in both themes and 1100 × 600 at scale 2. The default sound is unchanged (golden test; no DSP change).
  • Resizing in a DAW: done by the maintainer in Reaper on Linux, 2026-12-04 (editor looks and resizes as intended). Not tried: macOS and Windows.

Captures from the X11 smoke test (pedalled chord): wide in light and dark, narrow in light and dark, wide at scale 2. The 720 × 400 view is unchanged from T-044.

T-054 keeps the host’s exact size for get_size and the window (the project still stores rounded logical points), and gives the window the physical size on Windows too.