tui: inpainting canvas — interactive keyboard mask editor #132

Closed
opened 2026-04-14 20:11:13 +00:00 by claude-desktop · 0 comments
Collaborator

User story

As a user in inpaint mode, I want a full-screen overlay where I can paint a mask over the init image with the keyboard, so that I can run inpainting jobs without leaving the terminal.

Background

Issue #23 was closed but crates/loom-tui/src/components/inpaint.rs is a 150-line stub — there's no canvas, no brush, no mask export. This ticket implements the full editor.

Acceptance criteria

Overlay

  • New OverlayKind::InpaintCanvas { init_path } opens from the Generate screen when in Inpaint mode
  • Init image rendered via the existing ratatui-image picker (full overlay area, fit aspect)
  • A GrayImage mask buffer sized to the init image is owned by the overlay state
  • Mask is rendered as a translucent red overlay using a half-block layer

Brush controls

  • h/j/k/l and arrow keys move the cursor by one image-pixel × stride (stride = max(1, brush_radius / 2))
  • Space paints a circular stamp at the cursor; held-down auto-repeat respected
  • x erases under the cursor; c clears the whole mask
  • [ / ] decrement/increment brush radius (range 1–128)
  • Cursor + brush radius indicated by a circular outline on the half-block layer

Confirm / cancel

  • Enter writes the mask to a temp PNG (8-bit grayscale, white = inpaint), sets params.mask_path on the Generate screen, closes the overlay
  • Esc discards and closes without changes
  • Status bar at bottom shows radius: N · pixels masked: M

Performance

  • Stamp draws don't allocate per frame
  • Mask layer redraw is throttled to ~30 fps even on continuous paint

Tests

  • Unit: stamp at (x, y) with radius r produces expected non-zero pixel count
  • Unit: confirm export writes a PNG whose pixel count matches the in-memory mask

Out of scope

  • Mouse drawing
  • Multi-layer / smart brushes / lasso tool
  • The actual inpainting backend call (already on Generate)

References

  • crates/loom-tui/src/components/inpaint.rs (stub to replace)
  • crates/loom-gtk/src/pages/edit/mask_canvas.rs (GTK reference, lines 193+)
  • Closed predecessor: #23
## User story As a user in inpaint mode, I want a full-screen overlay where I can paint a mask over the init image with the keyboard, so that I can run inpainting jobs without leaving the terminal. ## Background Issue #23 was closed but `crates/loom-tui/src/components/inpaint.rs` is a 150-line stub — there's no canvas, no brush, no mask export. This ticket implements the full editor. ## Acceptance criteria ### Overlay - [ ] New `OverlayKind::InpaintCanvas { init_path }` opens from the Generate screen when in Inpaint mode - [ ] Init image rendered via the existing ratatui-image picker (full overlay area, fit aspect) - [ ] A `GrayImage` mask buffer sized to the init image is owned by the overlay state - [ ] Mask is rendered as a translucent red overlay using a half-block layer ### Brush controls - [ ] `h`/`j`/`k`/`l` and arrow keys move the cursor by one image-pixel × stride (stride = `max(1, brush_radius / 2)`) - [ ] `Space` paints a circular stamp at the cursor; held-down auto-repeat respected - [ ] `x` erases under the cursor; `c` clears the whole mask - [ ] `[` / `]` decrement/increment brush radius (range 1–128) - [ ] Cursor + brush radius indicated by a circular outline on the half-block layer ### Confirm / cancel - [ ] `Enter` writes the mask to a temp PNG (8-bit grayscale, white = inpaint), sets `params.mask_path` on the Generate screen, closes the overlay - [ ] `Esc` discards and closes without changes - [ ] Status bar at bottom shows `radius: N · pixels masked: M` ### Performance - [ ] Stamp draws don't allocate per frame - [ ] Mask layer redraw is throttled to ~30 fps even on continuous paint ### Tests - [ ] Unit: stamp at `(x, y)` with radius `r` produces expected non-zero pixel count - [ ] Unit: confirm export writes a PNG whose pixel count matches the in-memory mask ## Out of scope - Mouse drawing - Multi-layer / smart brushes / lasso tool - The actual inpainting backend call (already on Generate) ## References - `crates/loom-tui/src/components/inpaint.rs` (stub to replace) - `crates/loom-gtk/src/pages/edit/mask_canvas.rs` (GTK reference, lines 193+) - Closed predecessor: #23
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/loom#132
No description provided.