Skip to content

fix(desktop-gpui): drag, nudge and type the manual caption position - #3692

Merged
richiemcilroy merged 8 commits into
mainfrom
fix/gpui-manual-caption-drag
Nov 3, 2026
Merged

richiemcilroy merged 8 commits into
mainfrom
fix/gpui-manual-caption-drag

Conversation

@richiemcilroy

@richiemcilroy richiemcilroy commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Manual caption placement in the Studio editor now does what it says: the captions on the preview can be hovered, selected and dragged, nudged with the arrow keys, or placed by typing an exact X and Y. Reported on Discord: with Position set to Manual the captions stayed bottom-centre and nothing on the stage could select them.

Why Manual did nothing

How it works

flowchart LR
  A[CaptionsLayer::prepare] -->|resting box, before bounce/pop| B[CaptionFrameBox]
  B --> C[FrameLayout.caption<br/>filled after each editor frame]
  C --> D{caption placed Manual?}
  D -- no --> E[no canvas box: clicks go to what is underneath, as before]
  D -- yes --> F[canvas box: hover, select, drag with guides, arrow nudge]
  F -->|centre as a fraction of the output frame| G[captions.settings.manualPosition]
  G --> A
Loading
  • crates/rendering/src/layers/captions.rs: the box placement is one pure function, caption_box_origin, used by preview and export alike. The layer records the resting box (bounce and pop excluded) as a CaptionFrameBox, and crates/editor copies it into FrameLayout.caption after each editor frame.
  • apps/desktop-gpui/src/editor_canvas.rs: a CanvasSelection::Captions element. Its size comes from the renderer; its position comes from the stored centre with the renderer's own clamp, so a drag never waits on a frame. The box only exists while the caption on screen is placed manually, so preset captions never take a click from a text overlay, mask or the screen under them. It sits on top of the other boxes because captions are drawn last.
  • Dragging snaps to the frame centre, the thirds, a 5% safe margin and the other visible elements (Shift turns snapping off). Arrow keys move 1 canvas pixel, 10 with Shift. A drag is one undo step.
  • The stored value is the caption box's centre as a fraction of the output frame, with the box kept fully inside the frame. Font size and margins already scale with the frame, so the same project places captions at the same spot at every export resolution.
  • Captions tab: while Position is Manual, each axis is a slider plus a typed percentage (to a tenth), and Reset Position puts the captions back at bottom centre.
  • Choosing Manual starts from where the preset drew the captions on the current preview frame (falling back to the last drawn caption, then the preset table), so they don't jump.
  • Moving captions no longer switches the style preset to Custom. Placement isn't one of the preset's style keys.

Per-segment position_override

  • A segment's override still wins for that segment, as before. The canvas box shows only while the caption on screen is effectively Manual, whether that comes from the setting or from the segment's override. Dragging writes only manualPosition, never the global Position, so a segment overriding to manual under a preset global stays that way.

Compatibility

  • No new project fields. manualPosition already existed, and old projects (with or without it, including Tauri-era ones) load unchanged.
  • FrameLayout gains caption: Option<CaptionFrameBox>. A preset caption's box is ignored when deciding whether a paused frame rebuilds the editor, so scrubbing across preset captions costs nothing extra.

Evidence

Before and after

Bottom Center preset Choosing Manual: captions stay put, X/Y and Reset appear
preset manual panel
Hover Dragging, snapped to the thirds
hover dragging with guides
Arrow keys (5 right, 3 x Shift+down) Typed X 25, Y 20 Reset Position
nudged typed reset
Dark: selected Dark: dragging
dark selected dark dragging

Screen recording (hover, drag with guides, nudge): https://raw.githubusercontent.com/CapSoftware/Cap/pr-assets/caption-drag/caption-drag.mp4

Preview matches export

Columns: editor preview, 720p export, 4K export, same frame (t = 3.4 s). Rows: centre (0.5, 0.5), top left (0.25, 0.2), bottom right (0.8, 0.9), where the box is pushed back inside the frame.

preview vs export

Caption box as a fraction of the frame (x0, y0, x1, y1), measured from the pixels:

Position Preview 720p export 4K export
0.5, 0.5 0.322, 0.460, 0.678, 0.540 0.322, 0.461, 0.678, 0.539 0.321, 0.459, 0.679, 0.541
0.25, 0.2 0.070, 0.159, 0.429, 0.238 0.072, 0.161, 0.428, 0.239 0.071, 0.159, 0.429, 0.241
0.8, 0.9 0.623, 0.861, 0.979, 0.943 0.622, 0.861, 0.978, 0.939 0.621, 0.860, 0.979, 0.941

Performance

Editor hover bench with the ruler held (every move is a paused scrub step), captions tab open, manual captions, release builds on the Mac mini, alternating order, 5 runs each:

mean per move (median of runs) p95 (median of runs)
main 3391 us 4485 us
this PR 3297 us 4455 us

Playback of the same project for 10 s: 60 fps with 0 dropped frames on both builds.

Tests

  • New unit tests: renderer placement across 16:9, 9:16, 1:1 and 4:3 at three resolutions each, edge clamping, presets unchanged, hit box only for manual captions, hit box covers the drawn caption, snapping to centre / thirds / safe margin, drag and nudge clamping, typed percentages, reset, preset kept, old and new project files.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no new actionable issues were found.

Summary

Manual captions can now be selected, dragged, nudged, and placed with typed percentages.

  • Manual captions can be selected and moved on the preview.
  • Manual caption controls set exact positions without changing the style.

No new actionable issues found. Checks were based on source review; the native UI was not run.

Reviews (4) · Last reviewed commit: "perf(desktop-gpui): read the manual capt..." · Reviewed by Greptile

@vercel

vercel Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
cap-status Ignored Ignored Preview Nov 3, 2026 7:11pm UTC

@richiemcilroy

Copy link
Copy Markdown
Member Author

@greptileai review

Comment thread apps/desktop-gpui/src/editor_tabs.rs Resolved
@richiemcilroy

Copy link
Copy Markdown
Member Author

@greptileai review

@richiemcilroy

Copy link
Copy Markdown
Member Author

@greptileai review

@richiemcilroy
richiemcilroy force-pushed the fix/gpui-manual-caption-drag branch from 7d8e1d5 to 2acf210 Compare November 3, 2026 19:10
@richiemcilroy
richiemcilroy marked this pull request as ready for review November 3, 2026 20:49

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capy found no issues.

View 1 other finding in Capy.

Open in Capy

@richiemcilroy
richiemcilroy merged commit 144fa0c into main Nov 3, 2026
86 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant