Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .agents/skills/verify-screens/features/move-select.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ With the Move tool a person selects frames, drags one or several, snaps them to
- `sel-click`: a click selects, giving a ring and the Focus action; the page takes the pointer. A click on the background clears it.
- `sel-marquee`: a background drag selects every frame it intersects. Escape mid-drag cancels it.
- `drag-commit`: a drag shows pending until the commit, then commits one `moveItems` at the start plus the screen delta divided by zoom.
- `drag-threshold`: a press that wobbles less than 5 screen px selects a frame without moving it, even zoomed out. Moving 5 px or more starts the move.
- `drag-snap`: an edge within 8 screen px of another frame snaps exactly. Holding Cmd or Ctrl turns snapping off.
- `delete`: Backspace removes the selection and the strokes drawn on it.
- `rename`: double-clicking a title or clicking the Screen name edits it; Enter commits. The agent's `retitle_item` and `rename_screen` do the same.
Expand Down Expand Up @@ -51,6 +52,18 @@ expect doc.rev=+1 doc.@A.x=100 doc.@A.y=-50 storage.rev=doc.rev events.revisions
diff
```

```screens id=drag-threshold
add_object title=A files=fixture:plain x=0 y=0 width=800 height=600 as=@A
add_object title=B files=fixture:plain x=2000 y=1500 width=800 height=600 as=@B
fit
mark
drag @A by 4,0
expect view.selection=[@A] doc.@A.x=0 doc.rev=+0
click bg
drag @A by 6,0
expect view.selection=[@A] doc.@A.x>0 doc.rev=+1
```

```screens id=drag-snap
add_object title=L files=fixture:plain x=0 y=0 height=300 as=@L
add_object title=R files=fixture:plain x=600 y=40 height=300 as=@R
Expand Down
8 changes: 5 additions & 3 deletions packages/canvas/src/engine/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import { round2 } from "./stroke.ts";
import { isUnsaved, type BaseDoc, type DisplayItem, type DisplayThread } from "./display.ts";
import { gridColumns, PRESENT_KEYS, SCROLL, fitExact, fitTop, gridRect, policyOf, scrollRect, shownDocOf, slotAmong, type PagesState, type PagesView } from "./pages.ts";

export const DRAG_THRESHOLD_PX = 3, PAN_MOVED_PX = 3, TRANSIENT_INTERVAL_MS = 33, PIN_DRAG_PX = 4;
/** A press on a frame moves it only past DRAG_THRESHOLD_PX on screen, so a click that wobbles still only selects.
* A resize handle is pressed on purpose, so it starts sooner, for small resizes. */
export const DRAG_THRESHOLD_PX = 5, RESIZE_THRESHOLD_PX = 3, PAN_MOVED_PX = 3, TRANSIENT_INTERVAL_MS = 33, PIN_DRAG_PX = 4;
export const STROKE_DRAW_PX = 4, STROKE_SPACING_PX = 0.75, STROKE_MAX_POINTS = 3000;
export const VIEW_COMMAND_TTL_MS = 30_000;

Expand Down Expand Up @@ -50,7 +52,7 @@ export type Gesture =
/** Grid view of a Presentation or Document: the drag reorders. slot is where the pages would go (reorderItems' index). */
readonly reorder: boolean; readonly slot: number | null }
/** starts: each selected item's rect at press; box: their bounds, which the handle resizes, scaling every item with it.
* preview holds every item's full rect once past DRAG_THRESHOLD_PX. */
* preview holds every item's full rect once past RESIZE_THRESHOLD_PX. */
| { readonly kind: "item-resize"; readonly pointerId: number; readonly gestureId: string; readonly origin: Point; readonly starts: ReadonlyMap<ItemId, Rect>;
readonly kinds: readonly string[]; readonly handle: Handle; readonly box: Rect; readonly limits: SizeLimits; readonly targets: readonly Rect[]; readonly preview: ReadonlyMap<ItemId, Placement> | null;
readonly guides: readonly Guide[]; readonly lastBroadcastAt: number; readonly unsent: boolean }
Expand Down Expand Up @@ -561,7 +563,7 @@ function gestureMove(s: ViewState, g: Gesture, i: Extract<CanvasInput, { type: "
return { ...s, interacting: null, gesture: broadcast({ ...g, dragging: true, preview, guides }, env.now(), fx) };
}
case "item-resize": {
if (!g.preview && Math.hypot(c.x - g.origin.x, c.y - g.origin.y) < DRAG_THRESHOLD_PX) return s;
if (!g.preview && Math.hypot(c.x - g.origin.x, c.y - g.origin.y) < RESIZE_THRESHOLD_PX) return s;
const delta = { x: (c.x - g.origin.x) / s.camera.z, y: (c.y - g.origin.y) / s.camera.z };
const r = resizeRect(g.box, g.handle, delta, keepsAspect(g.kinds, g.handle, i.shift), i.mod ? [] : g.targets, SNAP_SCREEN_PX / s.camera.z, g.limits);
const preview = new Map<ItemId, Placement>();
Expand Down