Files
lanework/Kanban/UI/Board/MarqueeSession.swift
T
rzen f7c8088783 Lanes delete into the trash — rendering, grammar, drag, clipboard, a11y
Phase 2 completes the lanes-in-trash card. TrashEntry merges the
trash's two kinds by rank in exactly ONE place (ItemPath.resolve's
own merge deleted in favor of it — the three-merge-points finding
shrinks instead of growing). TrashLaneRowView renders the opaque
row — tertiary plate, level-default lane glyph never the lane's own
icon, title + card count, no accents, no expansion; the column badge
counts rendered rows. Selection grammar: kind-homogeneous trash
selections — ranges skip the other kind, ⇧-extension stops at the
kind boundary, plain arrows walk the merged order, marquee stays
card-only (now load-bearing: rows register frames for arrows),
Select All card-scoped; successor-on-purge crosses kinds like
navigation as the interim for open Gap 7b5cbc90. Drag: TrashDrop
accepts lane sessions (drop on shown trash deletes), restoreLanes
routes a trash-sourced strip drop as an arrival-ranked within-board
move with an undo step. Clipboard: ⌘X/⌘V lane restore via opaque
lane subjects; fixed boardRoot(ofLaneFolder:) returning .trash as
the root — a same-board restore looked like an import and would
have reminted the lane it was restoring (pinned by test). A11y:
row = one flattened "title, deleted lane, N cards" element with
Delete/Reveal actions; BoardDiff crossings read lanes as
deleted/restored, shown-trash churn digested at row level. Agent
guide stays v7 — the literal already teaches lanes-trash-by-move
and kind stamping; drift-guard pins those lines. README trash
paragraph notes lanes.

Both schemes 1893 tests / 322 suites green.

Claude-Session: https://claude.ai/code/session_01SR4XGjmBE16ZUYWpfFHXwY
2026-07-30 17:04:30 -04:00

117 lines
5.2 KiB
Swift

import CoreGraphics
import Observation
// MARK: - MarqueeSession
/// Window-local state for an in-flight rubber band — `LaneResizeSession`'s sibling, and as small
/// for its reason: it holds only what the *pointer* contributes, because everything the selection
/// needs beyond that is read fresh at gesture time (`MarqueeTargetRegistry`, `MarqueeMath`).
///
/// **The side is frozen at the origin** — "a rubber-band stays on the side of the boundary it
/// started on" (04-interactions.md ▸ The trash). A band begun on the board and dragged across the
/// trash column keeps selecting live cards; a band begun in the trash keeps selecting rows. That is
/// the whole reason the side is stored here rather than re-derived from what the rect touches.
///
/// **Nothing here animates.** 03-board-ui.md § Motion names the marquee twice: "the rubber-band
/// marquee tracks the cursor 1:1 (an eased band visibly lags the mouse)" and, in the
/// animation-free-by-construction list, "the marquee rectangle (1:1 cursor following — animating
/// input echo would be lag)". So the rect is drawn outside every animated transaction on the strip,
/// and the selection churn it drives is deliberately un-keyed too ("never on broad state like the
/// selection set").
@MainActor
@Observable
final class MarqueeSession {
/// Where the band was begun, in `BoardView.stripSpace` coordinates; `nil` when idle — which is
/// what "no marquee" means here rather than a separate flag.
private(set) var origin: CGPoint?
/// The pointer's current position, in the same space. Meaningless while `origin` is `nil`.
private(set) var current: CGPoint = .zero
/// The side of the live/trash boundary this band selects on, frozen at `begin`.
private(set) var container: ItemContainer = .board
/// How far the pointer must travel before a drag on empty space becomes a band. Larger than the
/// lane header's threshold because this gesture arms on *any* empty surface, and a click that
/// clears the selection must not leave a one-pixel band behind it.
static let minimumDistance: CGFloat = 5
var isActive: Bool { origin != nil }
/// The band, normalized so it is a rectangle regardless of which way the drag ran; `nil` when
/// idle, which is also the overlay's "draw nothing".
var rect: CGRect? {
guard let origin else { return nil }
return CGRect(
x: min(origin.x, current.x),
y: min(origin.y, current.y),
width: abs(current.x - origin.x),
height: abs(current.y - origin.y)
)
}
func begin(at point: CGPoint, in container: ItemContainer) {
origin = point
current = point
self.container = container
}
func update(to point: CGPoint) {
guard isActive else { return }
current = point
}
/// Ends the band. **The selection stays exactly as the last sample computed it** — a release is
/// not a commit here, because nothing was written: the band was only ever a way of naming a set.
/// Idempotent, like every other session's `end`.
func end() {
origin = nil
current = .zero
}
}
// MARK: - MarqueeTargetRegistry
/// Where each sweepable item is drawn, keyed by identity — the geometry half of the rubber band.
///
/// **The views register themselves** (`onGeometryChange` in `BoardView.stripSpace`, removal in
/// `onDisappear`) rather than the band re-deriving the masonry's arithmetic: the layout already
/// computed those frames, and a second computation is a second answer that could disagree with what
/// is on screen. It is also what makes the band correct for free across a lane resize, a reorder in
/// flight, and a foreign reload — the frames simply re-register.
///
/// **A live lane is never registered.** The band selects cards, and a lane on the strip has no entry
/// here at all — 04-interactions.md § Selection's "click-drag rubber-bands across lanes" made
/// structural rather than filtered.
///
/// **A trashed lane row is registered** (lanes rejoined the trash 2026-07-29), and not for the band:
/// this registry is also the arrows' geometry (`NavigationMath`, where "plain arrows walk every row,
/// card and lane row alike") and the begin guard's universe below. The band still never selects one
/// — `MarqueeMath` filters by kind, which is where that rule lives for both containers.
///
/// It is also the **begin guard's** universe: a drag that starts inside a registered frame belongs
/// to that item's own gesture (a card drag, a drag out of the trash), never to the band. Deciding
/// that geometrically rather than by gesture priority is what keeps the two from fighting.
@MainActor
@Observable
final class MarqueeTargetRegistry {
private(set) var targets: [ItemID: MarqueeTarget] = [:]
var all: [MarqueeTarget] { Array(targets.values) }
func update(_ target: MarqueeTarget) {
targets[target.id] = target
}
func remove(_ id: ItemID) {
targets.removeValue(forKey: id)
}
/// Whether `point` lands on something already drawn — the band's begin guard.
func contains(_ point: CGPoint) -> Bool {
targets.values.contains { $0.frame.contains(point) }
}
}