@n-uf/placement 26.11.17 → 26.11.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2014 @@
1
+ import {
2
+ close,
3
+ dockHome,
4
+ floatAt,
5
+ fold,
6
+ homeFor,
7
+ open,
8
+ raise,
9
+ readScene,
10
+ resize,
11
+ solve,
12
+ stops,
13
+ storeScene,
14
+ targets,
15
+ use
16
+ } from "./chunk-NCHRKLT3.js";
17
+ import "./chunk-RUITEOZ7.js";
18
+ import {
19
+ rect
20
+ } from "./chunk-QMTNB2C3.js";
21
+
22
+ // src/scene/cases/gestures.ts
23
+ var gap = (edge, at2, zone = "start") => ({ kind: "gap", edge, zone, at: at2 });
24
+ var g = {
25
+ /** Pointer down on the item's handle; `point` is relative to its top-left corner. */
26
+ press: (item, point) => ({ type: "press", item, ...point ? { point } : {} }),
27
+ /** The pointer moves to the target at `place`. */
28
+ to: (place) => ({ type: "move", place }),
29
+ /** The pointer moves to `point` (stage px). */
30
+ at: (x, y) => ({ type: "move", point: { x, y } }),
31
+ hold: (ms = 120) => ({ type: "hold", ms }),
32
+ release: () => ({ type: "release" }),
33
+ escape: () => ({ type: "key", key: "Escape" }),
34
+ key: (key) => ({ type: "key", key }),
35
+ /** The item's control (`key`), or with none, a click that opens or unfolds it. */
36
+ click: (item, key) => ({ type: "click", item, ...key ? { key } : {} }),
37
+ /** The "Move to ›" row for `place`. */
38
+ moveTo: (item, place) => ({ type: "click", item, place }),
39
+ /** The user's size across an edge. */
40
+ resizeEdge: (edge, size) => ({ type: "resize", edge, size }),
41
+ /** The item's measured length changed by `size` px. */
42
+ resizeItem: (item, size) => ({ type: "resize", item, size }),
43
+ /** The stage is now `width` x `height`. */
44
+ resizeWindow: (width, height) => ({ type: "resize", point: { x: width, y: height } }),
45
+ scroll: (dy) => ({ type: "scroll", size: dy }),
46
+ /** A place: before the `at`-th item of an edge's zone. */
47
+ gap,
48
+ column: (side, ring) => ({ kind: "column", side, ring }),
49
+ rail: (side, ring = 0) => ({ kind: "rail", side, ring }),
50
+ float: { kind: "float" },
51
+ home: { kind: "home" },
52
+ /** Press, aim at `place`, rest, let go. */
53
+ drag: (item, place, grab) => [
54
+ { type: "press", item, ...grab ? { point: grab } : {} },
55
+ { type: "move", place },
56
+ { type: "hold", ms: 120 },
57
+ { type: "release" }
58
+ ]
59
+ };
60
+
61
+ // src/scene/cases/world.ts
62
+ var form = (kind, min, natural, cross, extra = {}) => ({
63
+ kind,
64
+ main: { min, natural, ...extra.grows ? { grows: true } : {} },
65
+ cross: { natural: cross, ...extra.crossMin !== void 0 ? { min: extra.crossMin } : {} },
66
+ ...extra.rank !== void 0 ? { rank: extra.rank } : {},
67
+ ...extra.setsCross !== void 0 ? { setsCross: extra.setsCross } : {}
68
+ });
69
+ var BENCH_PANELS = ["pages", "annotations", "findings"];
70
+ var BENCH_GROUPS = ["views", "tools", "zoom"];
71
+ var PANEL_SIZE = {
72
+ pages: { column: 150, wide: 200 },
73
+ annotations: { column: 130, wide: 240 },
74
+ findings: { column: 170, wide: 220 }
75
+ };
76
+ var WORDS = 3;
77
+ var iconsMain = (axis) => (axis === "column" ? 18 : 16) + 26 * WORDS;
78
+ var FOLD = 40;
79
+ var MENU = 28;
80
+ var BENCH_RAIL = 30;
81
+ var BENCH_BAR_MAX = 40;
82
+ function benchPanel(id, used, more = {}) {
83
+ const s = PANEL_SIZE[id];
84
+ return {
85
+ id,
86
+ kind: "panel",
87
+ used,
88
+ forms: {
89
+ column: [form("open", 90, s.column, s.wide, { grows: true, crossMin: 100 }), form("header", 30, 30, s.wide, { crossMin: 56 }), form("rail", 26, 26, BENCH_RAIL), form("menu", 0, 0, 0)],
90
+ row: [form("header", 110, 110, 28), form("rail", 26, 26, 26), form("menu", 0, 0, 0)]
91
+ },
92
+ floatSize: { width: s.wide, height: s.column + 40 },
93
+ ...more
94
+ };
95
+ }
96
+ function benchGroup(id, used, more = {}) {
97
+ const row2 = 244;
98
+ const ranked = (f2, rank) => ({ ...f2, rank });
99
+ const bar2 = id === "tools" ? [ranked(form("row", row2, row2, 28), 0), ranked(form("icons", iconsMain("row"), iconsMain("row"), 28), 0), ranked(form("fold", FOLD, FOLD, 28), 1)] : id === "zoom" ? [form("row", row2, row2, 28), form("stacked", row2, row2, 30), form("fold", FOLD, FOLD, 28), ranked(form("menu", 0, 0, 0), 2)] : [form("row", row2, row2, 28), form("fold", FOLD, FOLD, 28), ranked(form("menu", 0, 0, 0), 2)];
100
+ return {
101
+ id,
102
+ kind: "group",
103
+ used,
104
+ forms: {
105
+ column: [form("row", 30, 30, 240), form("stacked", 84, 84, 84), form("icons", iconsMain("column"), iconsMain("column"), 28), form("menu", 0, 0, 0)],
106
+ row: bar2
107
+ },
108
+ floatSize: { width: row2, height: 34 },
109
+ ...more
110
+ };
111
+ }
112
+ var BENCH_LAYOUT = {
113
+ column: ["pages", "annotations"],
114
+ bar: ["views", "tools", "zoom"],
115
+ floats: [{ id: "findings", rect: { x: 440, y: 130, width: 220, height: 190 } }]
116
+ };
117
+ var DEFAULT_USED = { pages: 1, annotations: 2, findings: 3, views: 4, tools: 5, zoom: 6 };
118
+ function bench(layout = BENCH_LAYOUT, o = {}) {
119
+ const width = o.width ?? 840;
120
+ const height = o.height ?? 500;
121
+ const used = { ...DEFAULT_USED, ...o.used };
122
+ const items = {};
123
+ for (const id of BENCH_PANELS) items[id] = benchPanel(id, used[id], { ...o.kept?.includes(id) ? { kept: true } : {}, ...o.from?.[id] ? { from: o.from[id] } : {} });
124
+ for (const id of BENCH_GROUPS) items[id] = benchGroup(id, used[id], o.kept?.includes(id) ? { kept: true } : {});
125
+ const pad = o.pad ?? 12;
126
+ const edges = [
127
+ { id: "bar", side: "top", ring: 0, accepts: ["group", "panel"], items: [...layout.bar], cross: { min: BENCH_BAR_MAX - 4, max: BENCH_BAR_MAX, rail: BENCH_BAR_MAX }, gap: o.gap ?? 8, pad: { start: pad, end: pad }, menu: { main: MENU } },
128
+ { id: "column", side: "left", ring: 0, accepts: ["panel", "group"], items: [...layout.column], cross: { min: 60, max: o.widthLimit ?? 360, rail: BENCH_RAIL }, menu: { main: MENU } }
129
+ ];
130
+ const floats = layout.floats.map((f2) => ({ id: f2.id, rect: { ...f2.rect }, ...BENCH_GROUPS.includes(f2.id) ? { orient: "row" } : {} }));
131
+ return { stage: { x: 0, y: 0, width, height }, edges, items, floats, floatKinds: ["panel", "group"] };
132
+ }
133
+ var panel = (id, used, more = {}, wide = 260) => ({
134
+ id,
135
+ kind: "panel",
136
+ used,
137
+ forms: {
138
+ column: [form("open", 120, 240, wide, { grows: true, crossMin: 180 }), form("header", 28, 28, wide, { crossMin: 60 }), form("rail", 28, 28, 30), form("menu", 0, 0, 0)],
139
+ row: [form("header", 120, 160, 28), form("menu", 0, 0, 0)]
140
+ },
141
+ ...more
142
+ });
143
+ var group = (id, used, more = {}) => ({
144
+ id,
145
+ kind: "group",
146
+ used,
147
+ forms: {
148
+ row: [form("row", 180, 200, 28), form("icons", 84, 84, 28), form("menu", 0, 0, 0)],
149
+ column: [form("stacked", 96, 96, 84), form("icons", 84, 84, 28), form("menu", 0, 0, 0)]
150
+ },
151
+ ...more
152
+ });
153
+ var title = (id = "title") => ({ id, kind: "title", used: 0, fixed: true, forms: { row: [form("row", 80, 160, 32, { grows: true })] } });
154
+ var controls = (id = "controls") => ({ id, kind: "controls", used: 0, fixed: true, align: "end", forms: { row: [form("row", 84, 84, 32)] } });
155
+ var readout = (id = "readout") => ({ id, kind: "readout", used: 0, fixed: true, align: "center", forms: { row: [form("row", 72, 72, 28)] } });
156
+ var bar = (id, side, ring, items, more = {}) => ({
157
+ id,
158
+ side,
159
+ ring,
160
+ accepts: ["group"],
161
+ items,
162
+ cross: { min: 36, max: 36, rail: 36 },
163
+ gap: 4,
164
+ pad: { start: 8, end: 8 },
165
+ ...more
166
+ });
167
+ var column = (id, side, ring, items, more = {}) => ({
168
+ id,
169
+ side,
170
+ ring,
171
+ accepts: ["panel", "group"],
172
+ items,
173
+ cross: { min: 160, max: 480, rail: 30 },
174
+ ...more
175
+ });
176
+ var byId = (items) => Object.fromEntries(items.map((it) => [it.id, it]));
177
+ function doc(o = {}) {
178
+ return {
179
+ stage: { x: 0, y: 0, width: o.width ?? 1200, height: o.height ?? 800 },
180
+ edges: [
181
+ { id: "titlebar", side: "top", ring: 0, accepts: ["group"], items: ["title", "controls"], cross: { min: 32, max: 32, rail: 32 } },
182
+ bar("toolbar", "top", 1, ["views", "tools", "zoom"]),
183
+ bar("status", "bottom", 0, ["readout", "search"], { span: "between", cross: { min: 28, max: 28, rail: 28 } }),
184
+ column("left", "left", 0, ["pages"]),
185
+ column("right", "right", 0, ["findings", "marks"])
186
+ ],
187
+ items: byId([
188
+ title(),
189
+ controls(),
190
+ readout(),
191
+ panel("pages", 1),
192
+ panel("findings", 2),
193
+ panel("notes", 3),
194
+ group("views", 4),
195
+ group("tools", 5),
196
+ group("zoom", 6, { align: "end" }),
197
+ group("search", 7, { align: "end" }),
198
+ group("marks", 8)
199
+ ]),
200
+ floats: [{ id: "notes", rect: { x: 500, y: 200, width: 280, height: 320 } }],
201
+ floatKinds: ["panel", "group"]
202
+ };
203
+ }
204
+ function tweakEdge(scene, id, patch) {
205
+ return { ...scene, edges: scene.edges.map((e) => e.id === id ? { ...e, ...patch } : e) };
206
+ }
207
+
208
+ // src/scene/cases/rows-docking.ts
209
+ var FINDINGS_FLOAT = { id: "findings", rect: { x: 440, y: 130, width: 220, height: 190 } };
210
+ var ANNOTATIONS_FLOAT = { id: "annotations", rect: { x: 420, y: 120, width: 240, height: 150 } };
211
+ var DOCKING_ROWS = [
212
+ // --- panels in a column ---------------------------------------------------------------------------------------------
213
+ {
214
+ id: "C6",
215
+ title: "A column taller than its content",
216
+ expect: "Groups and folded panels take only their own length; the rest of the column goes to the open panel.",
217
+ group: "panels",
218
+ scene: bench({ column: ["views", "pages"], bar: ["tools", "zoom"], floats: [ANNOTATIONS_FLOAT, FINDINGS_FLOAT] }),
219
+ gestures: [],
220
+ expectLayout: {
221
+ items: { views: { formKind: "stacked", edge: "column", rect: rect(0, 40, 84, 84) }, pages: { formKind: "open", rect: rect(0, 124, 200, 376) } },
222
+ edges: { column: { cross: 200 } }
223
+ }
224
+ },
225
+ {
226
+ id: "C8",
227
+ title: "Independent panels",
228
+ expect: "Any combination of panels can be open: opening one never closes another.",
229
+ group: "panels",
230
+ scene: bench({ column: ["pages", "annotations", "findings"], bar: ["views", "tools", "zoom"], floats: [] }, { from: { annotations: 1 } }),
231
+ gestures: [g.click("annotations")],
232
+ expectLayout: {
233
+ items: {
234
+ pages: { formKind: "open", rect: rect(0, 40, 240, 153.33) },
235
+ annotations: { formKind: "open", rect: rect(0, 193.33, 240, 132.89) },
236
+ findings: { formKind: "open", rect: rect(0, 326.22, 240, 173.78) }
237
+ },
238
+ order: { column: ["pages", "annotations", "findings"] }
239
+ }
240
+ },
241
+ {
242
+ id: "C9",
243
+ title: "Give-way",
244
+ expect: "When the open panels don't fit their minimum heights, the one used longest ago folds to its header first.",
245
+ group: "panels",
246
+ scene: bench({ column: ["pages", "annotations", "findings"], bar: ["views", "tools", "zoom"], floats: [] }, { height: 300, used: { annotations: 1, findings: 2, pages: 3 } }),
247
+ gestures: [],
248
+ expectLayout: {
249
+ items: { pages: { formKind: "open", rect: rect(0, 40, 220, 111.43) }, annotations: { formKind: "header", rect: rect(0, 151.43, 220, 30) }, findings: { formKind: "open", rect: rect(0, 181.43, 220, 118.57) } },
250
+ notes: { has: ["form-down"] }
251
+ }
252
+ },
253
+ {
254
+ id: "C9b",
255
+ title: "Give-way, then the next oldest",
256
+ expect: "Shorter still, the next oldest (Findings) folds before the newest (Pages); a rail icon only comes after the header.",
257
+ group: "panels",
258
+ scene: bench({ column: ["pages", "annotations", "findings"], bar: ["views", "tools", "zoom"], floats: [] }, { height: 300, used: { annotations: 1, findings: 2, pages: 3 } }),
259
+ gestures: [g.resizeWindow(840, 240)],
260
+ expectLayout: {
261
+ items: { pages: { formKind: "open", rect: rect(0, 40, 200, 144) }, annotations: { formKind: "rail", rect: rect(0, 184, 200, 26) }, findings: { formKind: "header", rect: rect(0, 210, 200, 30) } }
262
+ }
263
+ },
264
+ {
265
+ id: "C18",
266
+ title: "A rail icon opens on click",
267
+ expect: "A click on a panel's rail icon opens that panel; a click is never a drag.",
268
+ group: "panels",
269
+ scene: bench({ column: ["pages", "annotations"], bar: ["views", "tools", "zoom"], floats: [FINDINGS_FLOAT] }, { from: { pages: 2 } }),
270
+ gestures: [g.click("pages")],
271
+ expectLayout: {
272
+ items: { pages: { formKind: "open", rect: rect(0, 40, 240, 246.43) }, annotations: { formKind: "open", rect: rect(0, 286.43, 240, 213.57) } }
273
+ }
274
+ },
275
+ {
276
+ id: "C23",
277
+ title: "A press is not a reshape",
278
+ expect: "A press on a grip or a header, with no drag and nothing opened, never changes another item's form or rect.",
279
+ group: "panels",
280
+ scene: bench({ column: ["pages", "annotations", "findings"], bar: ["views", "tools", "zoom"], floats: [] }, { height: 300 }),
281
+ gestures: [
282
+ g.press("pages"),
283
+ g.release(),
284
+ g.press("annotations"),
285
+ g.release(),
286
+ g.press("findings"),
287
+ g.release(),
288
+ g.press("views"),
289
+ g.release(),
290
+ g.press("tools"),
291
+ g.release(),
292
+ g.press("zoom"),
293
+ g.release()
294
+ ],
295
+ expectLayout: {
296
+ items: {
297
+ pages: { formKind: "header", rect: rect(0, 40, 240, 30) },
298
+ annotations: { formKind: "open", rect: rect(0, 70, 240, 106.67) },
299
+ findings: { formKind: "open", rect: rect(0, 176.67, 240, 123.33) },
300
+ views: { formKind: "row", rect: rect(12, 0, 244, 40) },
301
+ tools: { formKind: "row", rect: rect(264, 0, 244, 40) },
302
+ zoom: { formKind: "row", rect: rect(516, 0, 244, 40) }
303
+ }
304
+ }
305
+ },
306
+ {
307
+ id: "C23b",
308
+ title: "A press is no use, by the stored ages",
309
+ expect: "A press on the oldest panel's header, with no drag, changes no age: after a reload (a fresh solve) the oldest still folds first, and the stored form has the ages it began with.",
310
+ group: "panels",
311
+ scene: bench({ column: ["pages", "annotations", "findings"], bar: ["views", "tools", "zoom"], floats: [] }, { height: 300 }),
312
+ gestures: [g.press("pages"), g.release(), g.key("Reload")],
313
+ expectLayout: {
314
+ items: {
315
+ pages: { formKind: "header", rect: rect(0, 40, 240, 30) },
316
+ annotations: { formKind: "open", rect: rect(0, 70, 240, 106.67) },
317
+ findings: { formKind: "open", rect: rect(0, 176.67, 240, 123.33) }
318
+ }
319
+ },
320
+ expectStored: { items: { pages: { used: 1 }, annotations: { used: 2 }, findings: { used: 3 } } }
321
+ },
322
+ // --- groups and toolbars --------------------------------------------------------------------------------------------
323
+ {
324
+ id: "C2",
325
+ title: "A group alone in a column",
326
+ expect: "A group never sets the column's width: alone, the column is a rail of about 30 px with the group as icons.",
327
+ group: "groups",
328
+ scene: bench({ column: ["views"], bar: ["tools", "zoom", "pages"], floats: [ANNOTATIONS_FLOAT, FINDINGS_FLOAT] }),
329
+ gestures: [],
330
+ expectLayout: { items: { views: { formKind: "icons", edge: "column", rect: rect(0, 40, 28, 96) }, pages: { formKind: "header", edge: "bar" } }, edges: { column: { cross: 30 } } }
331
+ },
332
+ {
333
+ id: "C10",
334
+ title: "Group forms by space",
335
+ expect: "A group takes the largest form that fits its column: words in a row, stacked words, icons.",
336
+ group: "groups",
337
+ scene: bench({ column: ["pages", "views", "tools"], bar: ["zoom"], floats: [ANNOTATIONS_FLOAT, FINDINGS_FLOAT] }, { widthLimit: 140 }),
338
+ gestures: [],
339
+ expectLayout: {
340
+ items: { pages: { formKind: "open", rect: rect(0, 40, 140, 292) }, views: { formKind: "stacked", rect: rect(0, 332, 84, 84) }, tools: { formKind: "stacked", rect: rect(0, 416, 84, 84) } },
341
+ edges: { column: { cross: 140 } }
342
+ }
343
+ },
344
+ {
345
+ id: "C10b",
346
+ title: "Group forms by space, wide column",
347
+ expect: "In a column wide enough for its words, a group is a row of words, drawn at its own width.",
348
+ group: "groups",
349
+ scene: bench({ column: ["pages", "views", "tools"], bar: ["zoom"], floats: [ANNOTATIONS_FLOAT, FINDINGS_FLOAT] }, { widthLimit: 360 }),
350
+ gestures: [g.resizeEdge("column", 300)],
351
+ expectLayout: {
352
+ items: { pages: { formKind: "open", rect: rect(0, 40, 300, 400) }, views: { formKind: "row", rect: rect(0, 440, 240, 30) }, tools: { formKind: "row", rect: rect(0, 470, 240, 30) } },
353
+ edges: { column: { cross: 300 } }
354
+ }
355
+ },
356
+ {
357
+ id: "C11",
358
+ title: "Draggable groups",
359
+ expect: "Every control group, the zoom group too, can be lifted by its handle and dropped in the column.",
360
+ group: "groups",
361
+ scene: bench(),
362
+ gestures: [...g.drag("zoom", g.gap("column", 2)), ...g.drag("views", g.gap("column", 0)), ...g.drag("tools", g.gap("column", 1))],
363
+ expectLayout: {
364
+ order: { column: ["views", "tools", "pages", "annotations", "zoom"], bar: [] },
365
+ items: { views: { formKind: "row", edge: "column", rect: rect(0, 0, 240, 30) }, tools: { formKind: "row", rect: rect(0, 30, 240, 30) }, zoom: { formKind: "row", rect: rect(0, 470, 240, 30) } }
366
+ }
367
+ },
368
+ {
369
+ id: "C12",
370
+ title: "No grip where nothing moves",
371
+ expect: "A fixed item (a title, window controls) has no handle: a press on it never lifts anything, and nothing offers a drop onto it.",
372
+ group: "groups",
373
+ scene: doc(),
374
+ gestures: [g.press("title"), g.at(300, 200), g.release(), g.press("controls"), g.at(300, 200), g.release()],
375
+ expectLayout: {
376
+ items: { title: { edge: "titlebar", rect: rect(0, 0, 1116, 32) }, controls: { edge: "titlebar", rect: rect(1116, 0, 84, 32) }, notes: { floating: true, rect: rect(500, 200, 280, 320) } },
377
+ content: rect(260, 68, 680, 704),
378
+ notes: { none: true }
379
+ }
380
+ },
381
+ {
382
+ id: "C19",
383
+ title: "A group in icon form keeps its grip",
384
+ expect: "A group drawn as icons still has a handle, and it drags by it.",
385
+ group: "groups",
386
+ scene: bench({ column: ["views"], bar: ["tools", "zoom"], floats: [ANNOTATIONS_FLOAT, FINDINGS_FLOAT] }),
387
+ gestures: [g.press("views", { x: 4, y: 4 }), g.at(520, 260), g.release()],
388
+ expectLayout: { items: { views: { floating: true, edge: null, rect: rect(516, 256, 244, 34) } }, order: { column: [] }, floats: ["annotations", "findings", "views"] }
389
+ },
390
+ {
391
+ id: "C21",
392
+ title: "The toolbar never grows tall",
393
+ expect: "The top bar is 40 px tall at most, whatever is in it: a panel there takes its header.",
394
+ group: "groups",
395
+ scene: bench({ column: ["pages", "annotations"], bar: ["views", "tools", "findings"], floats: [] }),
396
+ gestures: [g.resizeItem("findings", 35)],
397
+ expectLayout: { items: { findings: { formKind: "header", edge: "bar", rect: rect(516, 0, 145, 40) } }, edges: { bar: { cross: 40 } } }
398
+ },
399
+ // --- dragging -------------------------------------------------------------------------------------------------------
400
+ {
401
+ id: "C1",
402
+ title: "The drop preview is the rect it gets",
403
+ expect: "The slot shown while the item is held is the exact rect it gets after the drop: the same solve with the item inserted.",
404
+ group: "drag",
405
+ scene: bench(),
406
+ gestures: [g.press("annotations"), g.to(g.gap("column", 0)), g.hold(), g.release()],
407
+ checkpoints: [{ at: 2, layout: { items: { annotations: { formKind: "open", rect: rect(0, 40, 240, 213.57) }, pages: { rect: rect(0, 253.57, 240, 246.43) } }, order: { column: ["annotations", "pages"] } }, note: "the slot" }],
408
+ expectLayout: { items: { annotations: { formKind: "open", rect: rect(0, 40, 240, 213.57) }, pages: { rect: rect(0, 253.57, 240, 246.43) }, findings: { floating: true, rect: rect(440, 130, 220, 190) } }, order: { column: ["annotations", "pages"] } },
409
+ expectDom: [
410
+ { at: 2, attr: { "data-drag-session": "panel" }, note: "the root says a panel is dragged" },
411
+ { at: 2, select: "[data-drag-slot][data-drag-target]", count: 1, attr: { "data-drag-target": "gap:column:start:0" }, note: "one slot, on the top gap" },
412
+ { at: 2, select: "[data-drag-marker]", count: 1, note: "its insertion line" },
413
+ { at: 2, select: "[data-drag-held]", count: 1, note: "the held item" },
414
+ { at: 3, attr: { "data-drag-session": null }, note: "the session ends with the drop" },
415
+ { at: 3, select: "[data-drag-slot]", count: 0, note: "no slot after the drop" }
416
+ ]
417
+ },
418
+ {
419
+ id: "C3",
420
+ title: "Drop into any gap",
421
+ expect: "Every gap of a column opens a slot: above, between and below its panels and groups.",
422
+ group: "drag",
423
+ scene: bench({ column: ["pages", "annotations", "views"], bar: ["tools", "zoom"], floats: [FINDINGS_FLOAT] }),
424
+ gestures: [
425
+ g.press("findings", { x: 20, y: 10 }),
426
+ g.to(g.gap("column", 0)),
427
+ g.hold(),
428
+ g.to(g.gap("column", 1)),
429
+ g.hold(),
430
+ g.to(g.gap("column", 2)),
431
+ g.hold(),
432
+ g.to(g.gap("column", 3)),
433
+ g.hold(),
434
+ g.escape()
435
+ ],
436
+ checkpoints: [
437
+ { at: 2, layout: { order: { column: ["findings", "pages", "annotations", "views"] }, items: { findings: { edge: "column", rect: rect(0, 40, 240, 161.11) } } }, note: "above the first" },
438
+ { at: 4, layout: { order: { column: ["pages", "findings", "annotations", "views"] }, items: { findings: { rect: rect(0, 183.33, 240, 161.11) } } }, note: "between" },
439
+ { at: 6, layout: { order: { column: ["pages", "annotations", "findings", "views"] }, items: { findings: { rect: rect(0, 308.89, 240, 161.11) } } }, note: "between the last two" },
440
+ { at: 8, layout: { order: { column: ["pages", "annotations", "views", "findings"] }, items: { findings: { rect: rect(0, 338.89, 240, 161.11) } } }, note: "below the last" }
441
+ ],
442
+ expectLayout: { order: { column: ["pages", "annotations", "views"] }, items: { findings: { floating: true, rect: rect(440, 130, 220, 190) }, pages: { rect: rect(0, 40, 240, 230.36) } } }
443
+ },
444
+ {
445
+ id: "C4",
446
+ title: "A group into the panel column",
447
+ expect: "A group dragged into the column opens a slot and takes the largest column form that fits.",
448
+ group: "drag",
449
+ scene: bench(),
450
+ gestures: g.drag("views", g.gap("column", 2)),
451
+ expectLayout: { items: { views: { formKind: "row", edge: "column", rect: rect(0, 470, 240, 30) } }, order: { column: ["pages", "annotations", "views"], bar: ["tools", "zoom"] } }
452
+ },
453
+ {
454
+ id: "C20",
455
+ title: "Back over its own place",
456
+ expect: "Dragged away and back over its own place, the item shows that place, and a release puts it back; nothing else moved.",
457
+ group: "drag",
458
+ scene: bench(),
459
+ // Pressed 20 px in and 10 down; the float aimed at the content's centre lands at the pointer minus that grab.
460
+ gestures: [g.press("pages", { x: 20, y: 10 }), g.to(g.float), g.hold(), g.to(g.home), g.hold(), g.release()],
461
+ checkpoints: [
462
+ { at: 2, layout: { items: { pages: { floating: true, rect: rect(520, 260, 200, 190) }, annotations: { formKind: "open", rect: rect(0, 40, 240, 460) } } }, note: "away, over the pages" },
463
+ { at: 4, layout: { items: { pages: { edge: "column", rect: rect(0, 40, 240, 246.43) }, annotations: { rect: rect(0, 286.43, 240, 213.57) } } }, note: "back over its own place: the old rect" }
464
+ ],
465
+ expectLayout: { items: { pages: { edge: "column", floating: false, rect: rect(0, 40, 240, 246.43) }, annotations: { rect: rect(0, 286.43, 240, 213.57) }, findings: { floating: true, rect: rect(440, 130, 220, 190) } }, order: { column: ["pages", "annotations"] } }
466
+ },
467
+ {
468
+ id: "C22",
469
+ title: "The whole preview",
470
+ expect: "While a drop is previewed, every other item, floats too, is drawn at its rect after the drop, not only the dropped one.",
471
+ group: "drag",
472
+ // Pages (200 wide) and Findings (220) make a 220 column, with the Views float just beside it. Annotations (240) widens
473
+ // the column to 240, so the float moves clear and Pages and Findings shrink: all of it is drawn before the release.
474
+ scene: bench({ column: ["pages", "findings"], bar: ["tools", "zoom"], floats: [ANNOTATIONS_FLOAT, { id: "views", rect: { x: 222, y: 330, width: 244, height: 34 } }] }, { height: 400 }),
475
+ gestures: [g.press("annotations"), g.to(g.gap("column", 2)), g.hold(), g.release()],
476
+ checkpoints: [{ at: 2, layout: { items: { pages: { rect: rect(0, 40, 240, 120) }, findings: { rect: rect(0, 160, 240, 130) }, annotations: { edge: "column", rect: rect(0, 290, 240, 110) }, views: { floating: true, rect: rect(240, 330, 244, 34) } } }, note: "during the preview" }],
477
+ expectLayout: { items: { pages: { rect: rect(0, 40, 240, 120) }, findings: { rect: rect(0, 160, 240, 130) }, annotations: { edge: "column", rect: rect(0, 290, 240, 110) }, views: { floating: true, rect: rect(240, 330, 244, 34) } } }
478
+ },
479
+ // --- floats, saving, freeze -----------------------------------------------------------------------------------------
480
+ {
481
+ id: "C5",
482
+ title: "Floats stay put while the pages scroll",
483
+ expect: "A float lies above the pages in the window's px: scrolling the pages never moves it.",
484
+ group: "floats",
485
+ scene: bench(),
486
+ gestures: [g.scroll(300)],
487
+ expectLayout: { items: { findings: { floating: true, rect: rect(440, 130, 220, 190) } } },
488
+ // The layout alone can't tell a float that scrolled: only a page can, by measuring where the float is drawn.
489
+ expectDom: [{ item: "findings", count: 1, rect: rect(440, 130, 220, 190), note: "the float is drawn where it was after the scroll" }]
490
+ },
491
+ {
492
+ id: "C7",
493
+ title: "A float over a docked panel",
494
+ expect: "A float never covers a docked item's content: dropped over one, it lands clear of it, and the preview says so.",
495
+ group: "floats",
496
+ scene: bench(),
497
+ gestures: [g.press("findings", { x: 200, y: 10 }), g.at(260, 230), g.hold(), g.release()],
498
+ checkpoints: [{ at: 2, layout: { items: { findings: { floating: true, rect: rect(240, 220, 220, 190) } } }, note: "the preview, clear of the column" }],
499
+ expectLayout: { items: { findings: { floating: true, rect: rect(240, 220, 220, 190) }, pages: { rect: rect(0, 40, 240, 246.43) } } }
500
+ },
501
+ {
502
+ id: "C13",
503
+ title: "A reload restores the layout",
504
+ expect: "A reload restores every item's place and form from the stored form.",
505
+ group: "floats",
506
+ scene: bench({ column: ["annotations", "pages"], bar: ["zoom", "views", "tools"], floats: [{ id: "findings", rect: { x: 520, y: 200, width: 220, height: 190 } }] }, { from: { pages: 1 }, kept: ["annotations"] }),
507
+ // Move a group into the column between the panels, fold the float to its bar, reload: everything comes back.
508
+ gestures: [...g.drag("tools", g.gap("column", 1)), g.click("findings", "fold"), g.key("Reload")],
509
+ checkpoints: [{ at: 4, layout: { items: { annotations: { formKind: "open", rect: rect(0, 40, 240, 400) }, tools: { formKind: "row", edge: "column", rect: rect(0, 440, 240, 30) }, pages: { formKind: "header", rect: rect(0, 470, 240, 30) }, findings: { formKind: "header", floating: true, rect: rect(520, 200, 220, 30) } }, order: { column: ["annotations", "tools", "pages"], bar: ["zoom", "views"] } }, note: "before the reload" }],
510
+ expectLayout: { items: { annotations: { formKind: "open", rect: rect(0, 40, 240, 400) }, tools: { formKind: "row", edge: "column", rect: rect(0, 440, 240, 30) }, pages: { formKind: "header", rect: rect(0, 470, 240, 30) }, findings: { formKind: "header", floating: true, rect: rect(520, 200, 220, 30) } }, order: { column: ["annotations", "tools", "pages"], bar: ["zoom", "views"] } }
511
+ },
512
+ {
513
+ id: "C14",
514
+ title: "Frozen",
515
+ expect: "Frozen, nothing lifts; holding Alt lets everything move.",
516
+ group: "floats",
517
+ scene: bench(),
518
+ settings: { frozen: true },
519
+ gestures: [g.press("pages", { x: 20, y: 10 }), g.at(300, 240), g.release(), g.key("Alt"), g.press("pages", { x: 20, y: 10 }), g.to(g.float), g.hold(), g.release(), g.key("Alt:up")],
520
+ checkpoints: [{ at: 2, layout: { items: { pages: { edge: "column", rect: rect(0, 40, 240, 246.43) }, annotations: { rect: rect(0, 286.43, 240, 213.57) } } }, note: "frozen: nothing moved" }],
521
+ expectLayout: { items: { pages: { floating: true, rect: rect(520, 260, 200, 190) }, annotations: { rect: rect(0, 40, 240, 460) } } }
522
+ },
523
+ {
524
+ id: "C14b",
525
+ title: "Frozen refuses the menu's moves too",
526
+ expect: "Frozen, the menu's Float, Dock and Move to \u203A change nothing either; with Alt down they work.",
527
+ group: "floats",
528
+ scene: bench(),
529
+ settings: { frozen: true },
530
+ gestures: [g.click("pages", "float"), g.moveTo("pages", g.float), g.click("pages", "dock"), g.key("Alt"), g.click("pages", "float"), g.key("Alt:up")],
531
+ checkpoints: [{ at: 2, layout: { items: { pages: { edge: "column", floating: false, rect: rect(0, 40, 240, 246.43) }, annotations: { rect: rect(0, 286.43, 240, 213.57) } } }, note: "frozen: nothing moved" }],
532
+ expectLayout: { items: { pages: { floating: true, rect: rect(640, 40, 200, 190) }, annotations: { rect: rect(0, 40, 240, 460) } } }
533
+ },
534
+ {
535
+ id: "C15",
536
+ title: "No jump",
537
+ expect: "When an item's own size grows (its count gains digits), no other item moves more than 0.5 px: the last group in the bar grows by 35 px and a float's content grows, and nothing else changes.",
538
+ group: "floats",
539
+ scene: bench(),
540
+ gestures: [g.resizeItem("zoom", 35), g.resizeItem("findings", 35)],
541
+ expectLayout: {
542
+ items: {
543
+ views: { rect: rect(12, 0, 244, 40) },
544
+ tools: { rect: rect(264, 0, 244, 40) },
545
+ zoom: { rect: rect(516, 0, 279, 40) },
546
+ pages: { rect: rect(0, 40, 240, 246.43) },
547
+ annotations: { rect: rect(0, 286.43, 240, 213.57) },
548
+ findings: { floating: true, rect: rect(440, 130, 220, 190) }
549
+ },
550
+ content: rect(240, 40, 600, 460)
551
+ }
552
+ },
553
+ {
554
+ id: "C16",
555
+ title: "A float has no pin",
556
+ expect: "There is one kind of float, in the window's px: the stored form carries no pinned flag, and a float survives a reload as a plain float.",
557
+ group: "floats",
558
+ scene: bench(),
559
+ gestures: [g.key("Reload")],
560
+ expectLayout: { items: { findings: { floating: true, rect: rect(440, 130, 220, 190) }, pages: { rect: rect(0, 40, 240, 246.43) } }, floats: ["findings"] },
561
+ expectStored: { absent: ["pinned"] }
562
+ },
563
+ {
564
+ id: "C17",
565
+ title: "A drop past the stage's edge",
566
+ expect: "A float dropped with the pointer past the stage's edge is clamped into the stage, and the preview shows it clamped; it never cancels.",
567
+ group: "floats",
568
+ scene: bench(),
569
+ gestures: [g.press("findings", { x: 40, y: 10 }), g.at(920, 240), g.hold(), g.release()],
570
+ checkpoints: [{ at: 2, layout: { items: { findings: { floating: true, rect: rect(620, 230, 220, 190) } } }, note: "the preview, clamped into the stage" }],
571
+ expectLayout: { items: { findings: { floating: true, rect: rect(620, 230, 220, 190) } } }
572
+ }
573
+ ];
574
+
575
+ // src/scene/cases/rows-bars.ts
576
+ var NO_FLOATS = { column: [], bar: ["views", "tools", "zoom"], floats: [] };
577
+ function tiny(width, items, menu = 28) {
578
+ const edge = { id: "tbar", side: "top", ring: 0, accepts: ["group"], items: items.map((i) => i.id), cross: { min: 28, max: 40, rail: 28 }, gap: 0, pad: { start: 0, end: 0 }, menu: { main: menu } };
579
+ return { stage: { x: 0, y: 0, width, height: 100 }, edges: [edge], items: Object.fromEntries(items.map((i) => [i.id, i])), floats: [], floatKinds: [] };
580
+ }
581
+ var row = (id, used, forms) => ({ id, kind: "group", used, forms: { row: forms } });
582
+ var f = (kind, main) => form(kind, main, main, 28);
583
+ var BAR_ROWS = [
584
+ {
585
+ id: "T1",
586
+ title: "A \xBB per folded group, in line",
587
+ expect: "Short of room, a group folds to its own handle and \xBB, in its place in the bar; the shared \xBB entry comes only after the folds.",
588
+ group: "bars",
589
+ scene: bench(NO_FLOATS),
590
+ gestures: [g.resizeWindow(640, 500), g.resizeWindow(160, 500), g.resizeWindow(150, 500)],
591
+ checkpoints: [
592
+ { at: 0, layout: { items: { views: { formKind: "fold", rect: rect(12, 0, 40, 40) }, tools: { formKind: "row", rect: rect(60, 0, 244, 40) }, zoom: { formKind: "row", rect: rect(312, 0, 244, 40) } }, edges: { bar: { menu: null } } }, note: "640: Views folds where it stands, no shared entry" },
593
+ { at: 1, layout: { items: { views: { formKind: "fold", rect: rect(12, 0, 40, 40) }, tools: { formKind: "fold", rect: rect(60, 0, 40, 40) }, zoom: { formKind: "fold", rect: rect(108, 0, 40, 40) } }, edges: { bar: { menu: null } } }, note: "160: every group folded in line, still no shared entry" }
594
+ ],
595
+ expectLayout: { items: { views: { inMenu: true }, tools: { formKind: "fold", rect: rect(12, 0, 40, 40) }, zoom: { formKind: "fold", rect: rect(60, 0, 40, 40) } }, edges: { bar: { menu: ["views"] } } }
596
+ },
597
+ {
598
+ id: "T2-T4",
599
+ title: "A step goes only to a shorter form",
600
+ expect: "Zoom's stacked words are as long as its row, so a give-way step never takes them: Zoom goes from its row straight to its fold, and back to its row.",
601
+ group: "bars",
602
+ scene: bench(NO_FLOATS, { used: { zoom: 1 } }),
603
+ gestures: [g.resizeWindow(700, 500), g.resizeWindow(500, 500), g.resizeWindow(360, 500), g.resizeWindow(840, 500)],
604
+ checkpoints: [
605
+ { at: 0, layout: { items: { views: { formKind: "row" }, tools: { formKind: "row" }, zoom: { formKind: "fold", rect: rect(516, 0, 40, 40) } } }, note: "700: Zoom's row straight to its fold, not stacked" },
606
+ { at: 1, layout: { items: { views: { formKind: "fold" }, tools: { formKind: "row" }, zoom: { formKind: "fold", rect: rect(312, 0, 40, 40) } } }, note: "500" },
607
+ { at: 2, layout: { items: { views: { formKind: "fold" }, tools: { formKind: "icons" }, zoom: { formKind: "fold" } } }, note: "360" }
608
+ ],
609
+ expectLayout: { items: { views: { formKind: "row", rect: rect(12, 0, 244, 40) }, tools: { formKind: "row", rect: rect(264, 0, 244, 40) }, zoom: { formKind: "row", rect: rect(516, 0, 244, 40) } } }
610
+ },
611
+ {
612
+ id: "T3",
613
+ title: "The ranked primary gives way last",
614
+ expect: "Tools, the primary, goes to its icons first and folds only after every other group has folded, even when it was used longest ago.",
615
+ group: "bars",
616
+ scene: bench(NO_FLOATS, { used: { tools: 0 } }),
617
+ gestures: [g.resizeWindow(770, 500), g.resizeWindow(620, 500), g.resizeWindow(410, 500), g.resizeWindow(220, 500), g.resizeWindow(200, 500)],
618
+ checkpoints: [
619
+ { at: 0, layout: { items: { views: { formKind: "row" }, tools: { formKind: "icons", rect: rect(264, 0, 94, 40) }, zoom: { formKind: "row" } } }, note: "770: Tools goes to its icons first" },
620
+ { at: 1, layout: { items: { views: { formKind: "fold" }, tools: { formKind: "icons" }, zoom: { formKind: "row" } } }, note: "620: Views folds, Tools keeps its icons" },
621
+ { at: 2, layout: { items: { views: { formKind: "fold" }, tools: { formKind: "icons" }, zoom: { formKind: "fold" } } }, note: "410: Zoom folds too, Tools still icons" },
622
+ { at: 3, layout: { items: { views: { formKind: "fold" }, tools: { formKind: "icons" }, zoom: { formKind: "fold" } } }, note: "220: still icons" }
623
+ ],
624
+ expectLayout: { items: { views: { formKind: "fold", rect: rect(12, 0, 40, 40) }, tools: { formKind: "fold", rect: rect(60, 0, 40, 40) }, zoom: { formKind: "fold", rect: rect(108, 0, 40, 40) } }, edges: { bar: { menu: null } } }
625
+ },
626
+ {
627
+ id: "T5",
628
+ title: "Gaps and padding are real",
629
+ expect: "The bar's gap and padding count in its length and in every rect, and an end gap reaches past the bar's end: a group let go there lands last.",
630
+ group: "bars",
631
+ scene: bench(NO_FLOATS, { gap: 14, pad: 20 }),
632
+ gestures: [g.press("views"), g.at(846, 20), g.hold(), g.release()],
633
+ checkpoints: [{ at: 2, layout: { items: { views: { edge: "bar", rect: rect(576, 0, 244, 40) } }, order: { bar: ["tools", "zoom", "views"] } }, note: "the end gap, past the bar's end" }],
634
+ expectLayout: { items: { tools: { rect: rect(20, 0, 244, 40) }, zoom: { rect: rect(278, 0, 244, 40) }, views: { rect: rect(576, 0, 244, 40) } }, order: { bar: ["tools", "zoom", "views"] } }
635
+ },
636
+ {
637
+ id: "T6",
638
+ title: "A panel dropped into the bar lands as a header",
639
+ expect: "An open panel is too thick for a 40 px bar, so dropped there it lands as its header and the bar stays 40 px.",
640
+ group: "bars",
641
+ scene: bench({ column: ["pages", "annotations"], bar: ["views", "zoom"], floats: [{ id: "findings", rect: { x: 440, y: 130, width: 220, height: 190 } }] }),
642
+ gestures: [g.press("findings"), g.to(g.gap("bar", 2)), g.hold(), g.release()],
643
+ checkpoints: [{ at: 2, layout: { items: { findings: { formKind: "header", edge: "bar", rect: rect(516, 0, 110, 40) } }, edges: { bar: { cross: 40 } } }, note: "the slot is header-sized" }],
644
+ expectLayout: { items: { findings: { formKind: "header", edge: "bar", floating: false, rect: rect(516, 0, 110, 40) } }, edges: { bar: { cross: 40 } }, order: { bar: ["views", "zoom", "findings"] } }
645
+ },
646
+ // --- what `previous` keeps ------------------------------------------------------------------------------------------
647
+ {
648
+ id: "N1",
649
+ title: "A count gaining a digit reshapes nothing else",
650
+ expect: "After uses (the ages all change), a group whose badge gains digits grows by its own width (35 px) and no other form changes, though a fresh solve would give way differently.",
651
+ group: "previous",
652
+ scene: bench(NO_FLOATS, { width: 760 }),
653
+ gestures: [g.click("tools", "use"), g.click("zoom", "use"), g.click("views", "use"), g.resizeItem("tools", 35)],
654
+ expectLayout: { items: { views: { formKind: "fold", rect: rect(12, 0, 40, 40) }, tools: { formKind: "row", rect: rect(60, 0, 279, 40) }, zoom: { formKind: "row", rect: rect(347, 0, 244, 40) } }, edges: { bar: { menu: null } } }
655
+ },
656
+ {
657
+ id: "N2",
658
+ title: "A count losing a digit reshapes nothing else",
659
+ expect: "After uses (the ages all change), a group whose badge loses a digit is 7 px shorter and no other form changes, though a fresh solve would give way differently.",
660
+ group: "previous",
661
+ scene: bench(NO_FLOATS, { width: 764 }),
662
+ gestures: [g.click("tools", "use"), g.click("zoom", "use"), g.click("views", "use"), g.resizeItem("tools", -7)],
663
+ expectLayout: { items: { views: { formKind: "fold", rect: rect(12, 0, 40, 40) }, tools: { formKind: "row", rect: rect(60, 0, 237, 40) }, zoom: { formKind: "row", rect: rect(305, 0, 244, 40) } }, edges: { bar: { menu: null } } }
664
+ },
665
+ {
666
+ id: "G1",
667
+ title: "Items leave the menu when their form is larger",
668
+ expect: "An item in the \xBB menu comes out when its form is larger, even if the bar gets shorter (the last one takes the \xBB entry along); under 140 nothing comes out.",
669
+ group: "previous",
670
+ scene: tiny(128, [row("a", 1, [f("row", 100), f("icons", 20), f("menu", 0)]), row("b", 2, [f("row", 100), f("icons", 20), f("menu", 0)]), row("c", 9, [f("row", 100), f("fold", 60), f("icons", 40), f("menu", 0)])]),
671
+ gestures: [g.click("c", "use"), g.resizeWindow(139, 100), g.resizeWindow(141, 100), g.resizeWindow(150, 100), g.resizeWindow(175, 100)],
672
+ checkpoints: [
673
+ { at: 0, layout: { items: { a: { inMenu: true }, b: { inMenu: true }, c: { formKind: "row", rect: rect(0, 0, 100, 28) } }, edges: { tbar: { menu: ["a", "b"] } } }, note: "128, after a use of c: a and b in the menu" },
674
+ { at: 1, layout: { items: { a: { inMenu: true }, b: { inMenu: true }, c: { formKind: "row" } } }, note: "139: both icons plus the row need 140, so nothing comes out" },
675
+ { at: 2, layout: { items: { a: { formKind: "icons", rect: rect(0, 0, 20, 28) }, b: { formKind: "icons", rect: rect(20, 0, 20, 28) }, c: { formKind: "row", rect: rect(40, 0, 100, 28) } }, edges: { tbar: { menu: null } } }, note: "141: both come out together" }
676
+ ],
677
+ expectLayout: { items: { a: { formKind: "icons", inMenu: false }, b: { formKind: "icons", inMenu: false }, c: { formKind: "row" } }, edges: { tbar: { menu: null } } }
678
+ },
679
+ {
680
+ id: "G2",
681
+ title: "Room comes back in the reverse of give-way order",
682
+ expect: "B gave way first, then A; at 90 A can't open (it needs 130), so B doesn't open ahead of it; at 130 A opens first, and B only at 150.",
683
+ group: "previous",
684
+ scene: tiny(60, [row("a", 2, [f("row", 100), f("fold", 30)]), row("b", 1, [f("row", 50), f("fold", 30)])]),
685
+ gestures: [g.resizeWindow(90, 100), g.resizeWindow(129, 100), g.resizeWindow(130, 100), g.resizeWindow(149, 100), g.resizeWindow(150, 100)],
686
+ checkpoints: [
687
+ { at: 0, layout: { items: { a: { formKind: "fold" }, b: { formKind: "fold" } } }, note: "90: both stay folded" },
688
+ { at: 1, layout: { items: { a: { formKind: "fold" }, b: { formKind: "fold" } } }, note: "129" },
689
+ { at: 2, layout: { items: { a: { formKind: "row", rect: rect(0, 0, 100, 28) }, b: { formKind: "fold", rect: rect(100, 0, 30, 28) } } }, note: "130: A opens first" },
690
+ { at: 3, layout: { items: { a: { formKind: "row" }, b: { formKind: "fold" } } }, note: "149: B still folded" }
691
+ ],
692
+ expectLayout: { items: { a: { formKind: "row", rect: rect(0, 0, 100, 28) }, b: { formKind: "row", rect: rect(100, 0, 50, 28) } } }
693
+ },
694
+ {
695
+ id: "G2b",
696
+ title: "A group that went into the menu stays there",
697
+ expect: "A group that went into the menu straight from its row stays there while the one ahead of it can't open, from 80 to 129.",
698
+ group: "previous",
699
+ scene: tiny(60, [row("a", 2, [f("row", 100), f("fold", 30)]), row("b", 1, [f("row", 50), f("menu", 0)])], 30),
700
+ gestures: [g.resizeWindow(80, 100), g.resizeWindow(129, 100), g.resizeWindow(130, 100)],
701
+ checkpoints: [
702
+ { at: 0, layout: { items: { a: { formKind: "fold" }, b: { inMenu: true } }, edges: { tbar: { menu: ["b"] } } }, note: "80" },
703
+ { at: 1, layout: { items: { a: { formKind: "fold" }, b: { inMenu: true } }, edges: { tbar: { menu: ["b"] } } }, note: "129" }
704
+ ],
705
+ expectLayout: { items: { a: { formKind: "row", rect: rect(0, 0, 100, 28) }, b: { inMenu: true } }, edges: { tbar: { menu: ["b"] } } }
706
+ }
707
+ ];
708
+
709
+ // src/scene/cases/rows-rules.ts
710
+ var panelsOnly = () => tweakEdge({ ...doc(), floatKinds: ["panel"] }, "left", { accepts: ["panel"] });
711
+ var trayColumn = () => tweakEdge({ ...doc(), floatKinds: ["panel"] }, "left", { zoneAccepts: { start: ["panel"], end: ["group"] } });
712
+ var RULE_ROWS = [
713
+ {
714
+ id: "C24",
715
+ title: "Drag isolation",
716
+ expect: "While an item is held the root says so (data-drag-session) and only its valid targets show: one slot, on the target; the session ends with the drop.",
717
+ group: "kinds",
718
+ scene: doc(),
719
+ gestures: [g.press("pages"), g.to(g.gap("right", 2)), g.hold(), g.release()],
720
+ checkpoints: [{ at: 2, layout: { items: { findings: { rect: rect(940, 68, 260, 318) }, marks: { rect: rect(940, 386, 84, 96) }, pages: { edge: "right", rect: rect(940, 482, 260, 318) } }, order: { right: ["findings", "marks", "pages"] } }, note: "the slot" }],
721
+ expectLayout: { items: { findings: { rect: rect(940, 68, 260, 318) }, marks: { rect: rect(940, 386, 84, 96) }, pages: { edge: "right", rect: rect(940, 482, 260, 318) } }, order: { right: ["findings", "marks", "pages"] } },
722
+ expectDom: [
723
+ { at: 2, attr: { "data-drag-session": "panel" }, note: "the root carries the session while held" },
724
+ { at: 2, select: "[data-drag-target]", count: 1, attr: { "data-drag-target": "gap:right:start:2" }, note: "only the shown target carries a target mark" },
725
+ { at: 3, attr: { "data-drag-session": null }, note: "gone after the drop" },
726
+ { at: 3, select: "[data-drag-target]", count: 0, note: "no target mark after the drop" }
727
+ ]
728
+ },
729
+ {
730
+ id: "C25",
731
+ title: "Targets by kind: a panel in a toolbar",
732
+ expect: "An edge takes only the kinds it lists: a panel held over the toolbar is offered no gap there, it falls through to the float, and the toolbar is as it was.",
733
+ group: "kinds",
734
+ scene: doc(),
735
+ // (600, 50) is a real gap for a group (the toolbar's centre gap): the control row below lets a group go there.
736
+ gestures: [g.press("pages", { x: 20, y: 10 }), g.at(600, 50), g.hold()],
737
+ expectLayout: { items: { pages: { floating: true, rect: rect(580, 68, 280, 360) }, views: { rect: rect(8, 32, 200, 36) }, tools: { rect: rect(212, 32, 200, 36) }, zoom: { rect: rect(992, 32, 200, 36) } }, order: { toolbar: ["views", "tools", "zoom"] } }
738
+ },
739
+ {
740
+ id: "C25-control-bar",
741
+ title: "Targets by kind: the toolbar's gap is real for a group",
742
+ expect: "The same point, with a group held, is the toolbar's centre gap: Tools lands in the toolbar's centre zone. So the panel's refusal above is the kind's, not an empty spot's.",
743
+ group: "kinds",
744
+ scene: doc(),
745
+ gestures: [g.press("tools"), g.at(600, 50), g.hold(), g.release()],
746
+ expectLayout: { items: { tools: { edge: "toolbar", zone: "center" } }, order: { toolbar: ["views", "tools", "zoom"] } }
747
+ },
748
+ {
749
+ id: "C25b",
750
+ title: "Targets by kind: a group in a panel-only column",
751
+ expect: "A group held over a column that takes panels only is offered nothing: no slot, and the held group is out of the preview.",
752
+ group: "kinds",
753
+ scene: panelsOnly(),
754
+ gestures: [g.press("tools"), g.at(130, 76), g.hold()],
755
+ expectLayout: { items: { tools: null, pages: { rect: rect(0, 68, 260, 732) }, views: { rect: rect(8, 32, 200, 36) }, zoom: { rect: rect(992, 32, 200, 36) } }, order: { left: ["pages"] } },
756
+ expectDom: [{ select: "[data-drag-slot]", count: 0, note: "no slot where the group can't land" }]
757
+ },
758
+ {
759
+ id: "C25b-control-column",
760
+ title: "Targets by kind: the column's gap is real for a panel",
761
+ expect: "The same point, with a panel held, is the left column's top gap: Findings lands first in the column. So the group's refusal above is the kind's, not an empty spot's.",
762
+ group: "kinds",
763
+ scene: panelsOnly(),
764
+ gestures: [g.press("findings"), g.at(130, 76), g.hold(), g.release()],
765
+ expectLayout: { items: { findings: { edge: "left" } }, order: { left: ["findings", "pages"] } }
766
+ },
767
+ {
768
+ id: "C26a",
769
+ title: "No slot inside a panel's area for a group",
770
+ expect: "A group drag never draws a slot over a panel's body, where it can't land: nothing is offered there.",
771
+ group: "kinds",
772
+ scene: panelsOnly(),
773
+ gestures: [g.press("tools"), g.at(130, 400), g.hold()],
774
+ expectLayout: { items: { tools: null, pages: { rect: rect(0, 68, 260, 732) }, findings: { rect: rect(940, 68, 260, 636) } } },
775
+ expectDom: [{ select: "[data-drag-slot]", count: 0, note: "no slot over a panel" }]
776
+ },
777
+ {
778
+ id: "C26b",
779
+ title: "A panel drag sets the same dragging state as a group drag",
780
+ expect: "The root carries data-drag-session with the dragged item's kind, for a panel as for a group, and it is gone after Escape.",
781
+ group: "kinds",
782
+ scene: doc(),
783
+ gestures: [g.press("pages"), g.at(600, 400), g.hold(), g.escape(), g.press("tools"), g.at(600, 400), g.hold(), g.escape()],
784
+ expectLayout: { items: { pages: { rect: rect(0, 68, 260, 732) }, tools: { rect: rect(212, 32, 200, 36) } }, notes: { hasNot: ["content-changed"] } },
785
+ expectDom: [
786
+ { at: 2, attr: { "data-drag-session": "panel" }, note: "a panel is held" },
787
+ { at: 3, attr: { "data-drag-session": null }, note: "Escape ends it" },
788
+ { at: 6, attr: { "data-drag-session": "group" }, note: "a group is held" },
789
+ { at: 7, attr: { "data-drag-session": null }, note: "Escape ends it" }
790
+ ]
791
+ },
792
+ {
793
+ id: "C27",
794
+ title: "Floats never cover the bars",
795
+ expect: "A float let go over the title bar lands clear of every bar, not on them.",
796
+ group: "kinds",
797
+ scene: doc(),
798
+ gestures: [g.press("notes", { x: 20, y: 10 }), g.at(600, 12), g.hold(), g.release()],
799
+ checkpoints: [{ at: 2, layout: { items: { notes: { floating: true, rect: rect(580, 68, 280, 320) }, title: { rect: rect(0, 0, 1116, 32) }, controls: { rect: rect(1116, 0, 84, 32) } } }, note: "the preview" }],
800
+ expectLayout: { items: { notes: { floating: true, rect: rect(580, 68, 280, 320) }, title: { rect: rect(0, 0, 1116, 32) }, controls: { rect: rect(1116, 0, 84, 32) } } }
801
+ },
802
+ {
803
+ id: "C27b",
804
+ title: "Floats never cover chrome rects",
805
+ expect: "A float let go over a chrome rect the host draws itself (a status line) lands clear of it.",
806
+ group: "kinds",
807
+ scene: { ...doc(), chrome: [rect(300, 640, 600, 60)] },
808
+ gestures: [g.press("notes", { x: 20, y: 10 }), g.at(600, 660), g.hold(), g.release()],
809
+ checkpoints: [{ at: 2, layout: { items: { notes: { floating: true, rect: rect(580, 320, 280, 320) } } }, note: "the preview" }],
810
+ expectLayout: { items: { notes: { floating: true, rect: rect(580, 320, 280, 320) } } }
811
+ },
812
+ {
813
+ id: "C28",
814
+ title: "A group in a side column takes its own size",
815
+ expect: "A group dropped into a side column takes its own width, from the column's start, never the column's full width.",
816
+ group: "kinds",
817
+ scene: doc(),
818
+ gestures: g.drag("tools", g.gap("left", 0)),
819
+ checkpoints: [{ at: 2, layout: { items: { tools: { formKind: "stacked", edge: "left", rect: rect(0, 68, 84, 96) }, pages: { rect: rect(0, 164, 260, 636) } }, edges: { left: { cross: 260 } }, order: { left: ["tools", "pages"] } }, note: "the slot is the group's own size" }],
820
+ expectLayout: { items: { tools: { formKind: "stacked", edge: "left", rect: rect(0, 68, 84, 96) }, pages: { rect: rect(0, 164, 260, 636) } }, edges: { left: { cross: 260 } }, order: { left: ["tools", "pages"] } }
821
+ },
822
+ {
823
+ id: "C29",
824
+ title: "A bar's reserved room",
825
+ expect: "A slot in the title bar opens beside the title and controls, never over them: the controls keep their place and size, and the title keeps its start and its natural width. A leading toolbar sits right after the title's natural rect.",
826
+ group: "kinds",
827
+ scene: doc(),
828
+ gestures: [g.press("tools"), g.to(g.gap("titlebar", 1)), g.hold(), g.release()],
829
+ checkpoints: [{ at: 2, layout: { items: { title: { rect: rect(0, 0, 160, 32) }, tools: { edge: "titlebar", rect: rect(160, 0, 200, 32) }, controls: { rect: rect(1116, 0, 84, 32) } }, order: { titlebar: ["title", "tools", "controls"] } }, note: "the slot, right after the title" }],
830
+ expectLayout: { items: { title: { rect: rect(0, 0, 160, 32) }, tools: { edge: "titlebar", rect: rect(160, 0, 200, 32) }, controls: { rect: rect(1116, 0, 84, 32) } }, order: { titlebar: ["title", "tools", "controls"] } }
831
+ },
832
+ {
833
+ id: "C29b",
834
+ title: "Over the title, the gap just after it",
835
+ expect: "Held over the title's text (the bar's leading third), a group is offered the leading zone's gap, just after the title; the slot never covers the title's natural rect: the title keeps its natural width, the controls keep theirs.",
836
+ group: "kinds",
837
+ scene: panelsOnly(),
838
+ gestures: [g.press("tools"), g.at(80, 16), g.hold()],
839
+ expectLayout: { items: { tools: { edge: "titlebar", rect: rect(160, 0, 200, 32) }, title: { rect: rect(0, 0, 160, 32) }, controls: { rect: rect(1116, 0, 84, 32) } }, order: { titlebar: ["title", "tools", "controls"] } },
840
+ expectDom: [{ select: "[data-drag-slot][data-drag-target]", count: 1, attr: { "data-drag-target": "gap:titlebar:start:1" }, note: "the slot just after the title" }]
841
+ },
842
+ // --- revision 4 -------------------------------------------------------------------------------------------------------
843
+ {
844
+ id: "R4-band-at-a-boundary",
845
+ title: "A gap is a band around a boundary",
846
+ expect: "Beside a panel's body the gap is a band: within 12 px of the boundary between the Findings panel and the Marks toolbar below it there is a gap, 11 px above; 13 px above, over the panel's body, there is none. Below the boundary the toolbar is a short item, not a body: its whole length belongs to the nearest gap, so 11 and 13 px below are both that gap.",
847
+ group: "bands",
848
+ scene: panelsOnly(),
849
+ // The boundary is at y 704. In: 693, 715 and 717 (over the toolbar). Out: 691 (over the body).
850
+ gestures: [g.press("tools"), g.at(1070, 693), g.hold(), g.at(1070, 715), g.hold(), g.at(1070, 691), g.hold(), g.at(1070, 717), g.hold()],
851
+ checkpoints: [
852
+ { at: 2, layout: { items: { findings: { rect: rect(940, 68, 260, 540) }, tools: { edge: "right", rect: rect(940, 608, 84, 96) }, marks: { rect: rect(940, 704, 84, 96) } }, order: { right: ["findings", "tools", "marks"] } }, note: "11 px above the boundary: in the band" },
853
+ { at: 4, layout: { items: { findings: { rect: rect(940, 68, 260, 540) }, tools: { edge: "right", rect: rect(940, 608, 84, 96) } }, order: { right: ["findings", "tools", "marks"] } }, note: "11 px below: over the toolbar" },
854
+ { at: 6, layout: { items: { tools: null, findings: { rect: rect(940, 68, 260, 636) }, marks: { rect: rect(940, 704, 84, 96) } } }, note: "13 px above, over the body: out" }
855
+ ],
856
+ expectLayout: { items: { findings: { rect: rect(940, 68, 260, 540) }, tools: { edge: "right", rect: rect(940, 608, 84, 96) }, marks: { rect: rect(940, 704, 84, 96) } }, order: { right: ["findings", "tools", "marks"] } },
857
+ expectDom: [
858
+ { at: 2, select: "[data-drag-slot][data-drag-target]", count: 1, attr: { "data-drag-target": "gap:right:start:1" }, note: "the slot on the boundary's gap" },
859
+ { at: 6, select: "[data-drag-slot]", count: 0, note: "no slot 13 px off, over the body" },
860
+ { at: 8, select: "[data-drag-slot][data-drag-target]", count: 1, attr: { "data-drag-target": "gap:right:start:1" }, note: "13 px below, over the toolbar: the same gap" }
861
+ ]
862
+ },
863
+ {
864
+ id: "R4-no-gap-over-a-body",
865
+ title: "No gap over a panel's body",
866
+ expect: "Away from its edges, a panel's body is no gap: the pointer falls through to the float target, or to nothing.",
867
+ group: "bands",
868
+ scene: panelsOnly(),
869
+ gestures: [g.press("tools"), g.at(1070, 400), g.hold()],
870
+ expectLayout: { items: { tools: null, findings: { rect: rect(940, 68, 260, 636) }, marks: { rect: rect(940, 704, 84, 96) } }, order: { right: ["findings", "marks"] } },
871
+ expectDom: [{ select: "[data-drag-slot]", count: 0, note: "no slot over a body" }]
872
+ },
873
+ {
874
+ id: "R4-bar-gaps-split-at-the-middle",
875
+ title: "A bar's gaps split at its items' middles",
876
+ expect: "In a bar the band is the whole stretch up to the items' middles: left of Views' middle is the gap before it, right of it the gap after.",
877
+ group: "bands",
878
+ scene: doc(),
879
+ gestures: [g.press("zoom"), g.at(100, 50), g.hold(), g.at(160, 50), g.hold()],
880
+ checkpoints: [{ at: 2, layout: { items: { views: { rect: rect(212, 32, 200, 36) }, zoom: { rect: rect(8, 32, 200, 36) }, tools: { rect: rect(416, 32, 200, 36) } }, order: { toolbar: ["zoom", "views", "tools"] } }, note: "left of Views' middle: before it" }],
881
+ expectLayout: { items: { views: { rect: rect(8, 32, 200, 36) }, zoom: { rect: rect(212, 32, 200, 36) }, tools: { rect: rect(416, 32, 200, 36) } }, order: { toolbar: ["views", "zoom", "tools"] } }
882
+ },
883
+ {
884
+ id: "R4-content-changed",
885
+ title: "content-changed says when to refit",
886
+ expect: "A window resize that changes the content gives a content-changed note, so the host refits its zoom once, after the change.",
887
+ group: "bands",
888
+ scene: doc(),
889
+ gestures: [g.resizeWindow(1e3, 800)],
890
+ expectLayout: { content: rect(260, 68, 480, 704), notes: { has: ["content-changed"] } }
891
+ },
892
+ {
893
+ id: "R4-no-refit-on-a-float-move",
894
+ title: "A float move never refits",
895
+ expect: "Lifting a float and dropping it elsewhere changes no edge, so there is no content-changed note and no refit.",
896
+ group: "bands",
897
+ scene: doc(),
898
+ gestures: [g.press("notes", { x: 20, y: 10 }), g.at(620, 260), g.hold(), g.release()],
899
+ expectLayout: { items: { notes: { floating: true, rect: rect(600, 250, 280, 320) } }, content: rect(260, 68, 680, 704), notes: { hasNot: ["content-changed"] } }
900
+ },
901
+ {
902
+ id: "R4-float-slot",
903
+ title: "The float's slot is its after rect",
904
+ expect: "Held over the pages, a float shows a slot: the rect it gets after the drop (the pointer minus where it was held, clear of everything).",
905
+ group: "bands",
906
+ scene: doc(),
907
+ gestures: [g.press("notes", { x: 20, y: 10 }), g.at(600, 400), g.hold(), g.release()],
908
+ checkpoints: [{ at: 2, layout: { items: { notes: { floating: true, rect: rect(580, 390, 280, 320) } } }, note: "the slot is where it lands" }],
909
+ expectLayout: { items: { notes: { floating: true, rect: rect(580, 390, 280, 320) } } },
910
+ expectDom: [{ at: 2, select: "[data-drag-slot][data-drag-target]", count: 1, attr: { "data-drag-target": "float:notes" }, note: "a slot for the float too" }]
911
+ },
912
+ {
913
+ id: "R4-between-gap-is-its-own-slot",
914
+ title: "Every gap is its own slot",
915
+ expect: "A drop in a column's between gap lands there, not at the top: Pages dropped between Findings and Marks sits between them.",
916
+ group: "bands",
917
+ scene: doc(),
918
+ gestures: g.drag("pages", g.gap("right", 1)),
919
+ checkpoints: [{ at: 2, layout: { items: { findings: { rect: rect(940, 68, 260, 318) }, pages: { edge: "right", rect: rect(940, 386, 260, 318) }, marks: { rect: rect(940, 704, 84, 96) } }, order: { right: ["findings", "pages", "marks"] } }, note: "the slot is the between gap's" }],
920
+ expectLayout: { items: { findings: { rect: rect(940, 68, 260, 318) }, pages: { edge: "right", rect: rect(940, 386, 260, 318) }, marks: { rect: rect(940, 704, 84, 96) } }, order: { right: ["findings", "pages", "marks"] } }
921
+ },
922
+ {
923
+ id: "R4-end-reach-stays-in-its-edge-right",
924
+ title: "A gap's end reach never enters another edge",
925
+ expect: "Views held at (960, 50), inside the toolbar, is offered a toolbar gap, never the right column's top gap, whose end reach would otherwise run up into the toolbar.",
926
+ group: "bands",
927
+ scene: doc(),
928
+ gestures: [g.press("views", { x: 20, y: 10 }), g.at(960, 50), g.hold()],
929
+ expectLayout: { items: { views: { edge: "toolbar" } } }
930
+ },
931
+ {
932
+ id: "R4-end-reach-stays-in-its-edge-left",
933
+ title: "A gap's end reach never enters another edge, left side",
934
+ expect: "Views held at (250, 60), inside the toolbar, is offered a toolbar gap, never the left column's top gap.",
935
+ group: "bands",
936
+ scene: doc(),
937
+ gestures: [g.press("views", { x: 20, y: 10 }), g.at(250, 60), g.hold()],
938
+ expectLayout: { items: { views: { edge: "toolbar" } } }
939
+ },
940
+ // --- a column's tray of toolbars (`Edge.zoneAccepts`) ------------------------------------------------------------------
941
+ {
942
+ id: "R5-group-into-the-tray",
943
+ title: "A group dropped into a panel column lands in its tray",
944
+ expect: "With zoneAccepts (panels at the top, toolbars at the foot), a group dropped into the left column lands in the end-zone tray at the foot, as its icons, and the panels give way first.",
945
+ group: "kinds",
946
+ scene: trayColumn(),
947
+ gestures: g.drag("tools", g.gap("left", 0, "end")),
948
+ expectLayout: { items: { tools: { formKind: "icons", edge: "left", zone: "end", rect: rect(0, 716, 28, 84) }, pages: { formKind: "open", rect: rect(0, 68, 260, 648) } }, order: { left: ["pages", "tools"] } }
949
+ },
950
+ {
951
+ id: "R5-group-is-offered-no-gap-above-the-tray",
952
+ title: "A group is offered no gap in a panel zone",
953
+ expect: "The column's start zone takes panels only: a group held over its top gap is offered nothing, and the panel stays as it was.",
954
+ group: "kinds",
955
+ scene: trayColumn(),
956
+ gestures: [g.press("tools"), g.at(130, 76), g.hold()],
957
+ expectLayout: { items: { tools: null, pages: { formKind: "open", rect: rect(0, 68, 260, 732) } }, order: { left: ["pages"] } }
958
+ },
959
+ {
960
+ id: "R5-group-never-opens-a-column",
961
+ title: "A group never opens a column on its own",
962
+ expect: "An empty column whose start zone takes panels offers its strip to panels only: a group held over the strip is offered nothing.",
963
+ group: "kinds",
964
+ scene: tweakEdge(trayColumn(), "left", { items: [] }),
965
+ gestures: [g.press("tools"), g.at(10, 400), g.hold()],
966
+ expectLayout: { items: { tools: null, findings: { rect: rect(940, 68, 260, 636) } }, order: { left: [] } },
967
+ expectDom: [{ select: "[data-drag-slot]", count: 0, note: "no strip for a group" }]
968
+ },
969
+ {
970
+ id: "R5-panel-opens-an-empty-column",
971
+ title: "A panel opens the empty column",
972
+ expect: "The same strip takes a panel: Findings let go over it opens the column.",
973
+ group: "kinds",
974
+ scene: tweakEdge(trayColumn(), "left", { items: [] }),
975
+ gestures: [g.press("findings"), g.at(10, 400), g.hold(), g.release()],
976
+ expectLayout: { items: { findings: { formKind: "open", edge: "left", rect: rect(0, 68, 260, 732) } }, order: { left: ["findings"] } }
977
+ }
978
+ ];
979
+
980
+ // src/scene/cases/windows.ts
981
+ var WINDOW_A = { card: { min: 220, max: 640 }, gap: 12, pad: 12, rail: 32, contentMin: { width: 320, height: 240 }, barMain: 30 };
982
+ var WINDOW_B = { card: { min: 200, max: 560 }, gap: 0, pad: 0, rail: 32, contentMin: { width: 320, height: 240 }, barMain: 30 };
983
+ var WINDOW_BARE = { ...WINDOW_A, gap: 0, pad: 0, rail: 36 };
984
+ var DEFAULT_COLUMNS = { left: [["pages", "annotations"]], right: [["findings"]] };
985
+ var DEFAULT_USED2 = { pages: 1, annotations: 2, findings: 3 };
986
+ function winScene(spec, o = {}) {
987
+ const card = { kind: "open", main: { min: 120, natural: 300, grows: true }, cross: { natural: spec.card.min, min: spec.card.min } };
988
+ const bar2 = { kind: "header", main: { min: spec.barMain, natural: spec.barMain }, cross: { natural: spec.card.min, min: 60 } };
989
+ const rail = { kind: "rail", main: { min: 32, natural: 32 }, cross: { natural: spec.rail } };
990
+ const template = { accepts: ["panel"], cross: { min: spec.card.min, max: spec.card.max, rail: spec.rail }, gap: spec.gap };
991
+ const cols = o.columns ?? DEFAULT_COLUMNS;
992
+ const used = { ...DEFAULT_USED2, ...o.used };
993
+ const edges = [];
994
+ const items = {};
995
+ const add = (id) => {
996
+ items[id] = { id, kind: "panel", used: used[id] ?? 0, forms: { column: [card, bar2, rail] }, ...o.from?.[id] ? { from: o.from[id] } : {} };
997
+ };
998
+ for (const side of ["left", "right"]) {
999
+ (cols[side] ?? []).forEach((members, ring) => {
1000
+ members.forEach(add);
1001
+ edges.push({ id: `${side}-${ring}`, side, ring, column: true, items: [...members], accepts: template.accepts, cross: template.cross, gap: template.gap, ...o.size !== void 0 ? { size: o.size } : {} });
1002
+ });
1003
+ }
1004
+ for (const f2 of o.floats ?? []) add(f2.id);
1005
+ return {
1006
+ stage: { x: 0, y: 0, width: o.width ?? 1120, height: o.height ?? 800 },
1007
+ edges,
1008
+ items,
1009
+ floats: (o.floats ?? []).map((f2) => ({ id: f2.id, rect: { ...f2.rect } })),
1010
+ floatKinds: ["panel"],
1011
+ columns: { left: template, right: template },
1012
+ rails: { left: { width: spec.rail, accepts: ["panel"] }, right: { width: spec.rail, accepts: ["panel"] } },
1013
+ contentMin: spec.contentMin,
1014
+ handFold: o.handFold ?? "bar",
1015
+ inset: { left: spec.pad, right: spec.pad },
1016
+ gutter: spec.gap
1017
+ };
1018
+ }
1019
+
1020
+ // src/scene/cases/rows-gestures.ts
1021
+ var win = (o = {}) => winScene(WINDOW_A, { size: 300, ...o });
1022
+ function withTitle(s) {
1023
+ return {
1024
+ ...s,
1025
+ edges: [{ id: "titlebar", side: "top", ring: 0, span: "full", accepts: ["group"], items: ["window-title"], cross: { min: 28, max: 28, rail: 28 } }, ...s.edges],
1026
+ items: { ...s.items, "window-title": { id: "window-title", kind: "title", used: 0, fixed: true, forms: { row: [form("row", 80, 160, 28, { grows: true })] } } }
1027
+ };
1028
+ }
1029
+ var LEFT_OUT = 6;
1030
+ var RIGHT_EDGE = 1108;
1031
+ var GESTURE_ROWS = [
1032
+ {
1033
+ id: "P1-lift-follows-and-nothing-reflows",
1034
+ title: "Lifting: the slot is the target's rect and nothing else moves",
1035
+ expect: "While Annotations is held over a gap, one slot shows and it is the rect Annotations gets after the drop; everything else is drawn where the drop leaves it.",
1036
+ group: "gestures",
1037
+ scene: win(),
1038
+ gestures: [g.press("annotations"), g.to(g.gap("right-0", 1)), g.hold()],
1039
+ expectLayout: { items: { pages: { rect: rect(12, 0, 300, 800) }, findings: { rect: rect(808, 0, 300, 394) }, annotations: { edge: "right-0", rect: rect(808, 406, 300, 394) } }, columns: { left: [["pages"]], right: [["findings", "annotations"]] } },
1040
+ expectDom: [
1041
+ { attr: { "data-drag-session": "panel" }, note: "the root says a panel is dragged" },
1042
+ { select: "[data-drag-held]", count: 1, note: "the held item" },
1043
+ { select: "[data-drag-slot][data-drag-target]", count: 1, attr: { "data-drag-target": "gap:right-0:start:1" }, note: "one slot, on the target" }
1044
+ ]
1045
+ },
1046
+ {
1047
+ id: "P2-drop-into-another-column-at-a-position",
1048
+ title: "Drop into another column at a position",
1049
+ expect: "Dropped on the end gap of the right column, Annotations lands there, on the rect the slot showed.",
1050
+ group: "gestures",
1051
+ scene: win(),
1052
+ gestures: g.drag("annotations", g.gap("right-0", 1)),
1053
+ checkpoints: [{ at: 2, layout: { items: { pages: { rect: rect(12, 0, 300, 800) }, findings: { rect: rect(808, 0, 300, 394) }, annotations: { edge: "right-0", rect: rect(808, 406, 300, 394) } } }, note: "the slot" }],
1054
+ expectLayout: { items: { pages: { rect: rect(12, 0, 300, 800) }, findings: { rect: rect(808, 0, 300, 394) }, annotations: { edge: "right-0", rect: rect(808, 406, 300, 394) } }, columns: { left: [["pages"]], right: [["findings", "annotations"]] } }
1055
+ },
1056
+ {
1057
+ id: "P3-restore-pages-above-annotations",
1058
+ title: "Restore Pages above Annotations",
1059
+ expect: "Pages moved to the right column and dropped back on the left column's top gap is above Annotations again, as it began.",
1060
+ group: "gestures",
1061
+ scene: win(),
1062
+ gestures: [...g.drag("pages", g.gap("right-0", 1)), ...g.drag("pages", g.gap("left-0", 0))],
1063
+ checkpoints: [{ at: 3, layout: { columns: { left: [["annotations"]], right: [["findings", "pages"]] }, items: { annotations: { rect: rect(12, 0, 300, 800) }, pages: { rect: rect(808, 406, 300, 394) } } }, note: "after the first drop" }],
1064
+ expectLayout: { items: { pages: { rect: rect(12, 0, 300, 394) }, annotations: { rect: rect(12, 406, 300, 394) }, findings: { rect: rect(808, 0, 300, 800) } }, columns: { left: [["pages", "annotations"]], right: [["findings"]] } }
1065
+ },
1066
+ {
1067
+ id: "P4-escape-cancels",
1068
+ title: "Escape cancels",
1069
+ expect: "Escape during a drag changes nothing: the scene is as it was, and no slot or held marker remains.",
1070
+ group: "gestures",
1071
+ scene: win(),
1072
+ gestures: [g.press("annotations"), g.to(g.gap("right-0", 0)), g.hold(), g.escape()],
1073
+ expectLayout: { items: { pages: { rect: rect(12, 0, 300, 394) }, annotations: { rect: rect(12, 406, 300, 394) }, findings: { rect: rect(808, 0, 300, 800) } }, columns: { left: [["pages", "annotations"]], right: [["findings"]] } },
1074
+ expectDom: [
1075
+ { at: 2, select: "[data-drag-slot]", count: 1, note: "the slot while held" },
1076
+ { select: "[data-drag-slot]", count: 0, note: "no slot after Escape" },
1077
+ { select: "[data-drag-held]", count: 0, note: "no held marker after Escape" },
1078
+ { attr: { "data-drag-session": null }, note: "the session is over" }
1079
+ ]
1080
+ },
1081
+ {
1082
+ id: "P5-own-place-is-a-no-op",
1083
+ title: "Over its own place is a no-op",
1084
+ expect: "Lifted and let go over its own place, an item changes nothing, shows no slot and is never floated.",
1085
+ group: "gestures",
1086
+ scene: win(),
1087
+ gestures: [g.press("annotations"), g.to(g.home), g.hold(), g.release()],
1088
+ expectLayout: { items: { pages: { rect: rect(12, 0, 300, 394) }, annotations: { rect: rect(12, 406, 300, 394) }, findings: { rect: rect(808, 0, 300, 800) } }, columns: { left: [["pages", "annotations"]], right: [["findings"]] } },
1089
+ expectDom: [{ at: 2, select: "[data-drag-slot]", count: 0, note: "no slot over its own place" }]
1090
+ },
1091
+ {
1092
+ id: "P5-gap-beside-it",
1093
+ title: "The gap beside it is its own place",
1094
+ expect: "The gap just below Annotations in its own column is its own place: a release there changes nothing.",
1095
+ group: "gestures",
1096
+ scene: win(),
1097
+ gestures: [g.press("annotations"), g.to(g.gap("left-0", 1)), g.release()],
1098
+ expectLayout: { items: { pages: { rect: rect(12, 0, 300, 394) }, annotations: { rect: rect(12, 406, 300, 394) }, findings: { rect: rect(808, 0, 300, 800) } }, columns: { left: [["pages", "annotations"]], right: [["findings"]] } }
1099
+ },
1100
+ {
1101
+ id: "P5-neighbour-half-facing-it",
1102
+ title: "Over a neighbour's body there is no gap",
1103
+ expect: `Annotations let go over Pages' body, away from its edges, finds no gap (revision 4: a gap is a band around a boundary), so it falls through to the float target: it floats, where the pointer let go. The kits' older "neighbour half that faces it is its own place" no longer holds.`,
1104
+ group: "gestures",
1105
+ scene: win(),
1106
+ gestures: [g.press("annotations", { x: 20, y: 10 }), g.at(160, 392), g.hold(), g.release()],
1107
+ expectLayout: { items: { pages: { rect: rect(12, 0, 300, 800) }, annotations: { floating: true, rect: rect(312, 382, 280, 360) } }, floats: ["annotations"], columns: { left: [["pages"]], right: [["findings"]] } }
1108
+ },
1109
+ {
1110
+ id: "P6-new-outer-column-from-outside",
1111
+ title: "A new outer column from outside the right column",
1112
+ expect: "Let go 6 px outside the right column's outer edge, at 5%, 50% or 95% of the stage's height, Annotations makes the outermost column, on the slot's rect.",
1113
+ group: "gestures",
1114
+ scene: win(),
1115
+ gestures: [g.press("annotations"), g.at(RIGHT_EDGE + LEFT_OUT, 40), g.hold(), g.at(RIGHT_EDGE + LEFT_OUT, 400), g.hold(), g.at(RIGHT_EDGE + LEFT_OUT, 760), g.hold(), g.release()],
1116
+ checkpoints: [
1117
+ { at: 2, layout: { items: { pages: { rect: rect(12, 0, 220, 800) }, annotations: { edge: "right-1", rect: rect(888, 0, 220, 800) }, findings: { edge: "right-0", rect: rect(576, 0, 300, 800) } }, columns: { left: [["pages"]], right: [["annotations"], ["findings"]] }, notes: { has: ["column-shrunk"] } }, note: "5%" },
1118
+ { at: 4, layout: { items: { pages: { rect: rect(12, 0, 220, 800) }, annotations: { edge: "right-1", rect: rect(888, 0, 220, 800) }, findings: { edge: "right-0", rect: rect(576, 0, 300, 800) } }, columns: { left: [["pages"]], right: [["annotations"], ["findings"]] }, notes: { has: ["column-shrunk"] } }, note: "50%" },
1119
+ { at: 6, layout: { items: { pages: { rect: rect(12, 0, 220, 800) }, annotations: { edge: "right-1", rect: rect(888, 0, 220, 800) }, findings: { edge: "right-0", rect: rect(576, 0, 300, 800) } }, columns: { left: [["pages"]], right: [["annotations"], ["findings"]] }, notes: { has: ["column-shrunk"] } }, note: "95%" }
1120
+ ],
1121
+ expectLayout: { items: { pages: { rect: rect(12, 0, 220, 800) }, annotations: { edge: "right-1", rect: rect(888, 0, 220, 800) }, findings: { edge: "right-0", rect: rect(576, 0, 300, 800) } }, columns: { left: [["pages"]], right: [["annotations"], ["findings"]] }, notes: { has: ["column-shrunk"] } }
1122
+ },
1123
+ {
1124
+ id: "P6-new-outer-column-from-inside",
1125
+ title: "A new outer column from inside the right column",
1126
+ expect: "The new column's line is also reachable from inside the column: Annotations over its outer edge makes the outermost column.",
1127
+ group: "gestures",
1128
+ scene: win(),
1129
+ gestures: g.drag("annotations", g.column("right", 0)),
1130
+ expectLayout: { items: { pages: { rect: rect(12, 0, 220, 800) }, annotations: { edge: "right-1", rect: rect(888, 0, 220, 800) }, findings: { edge: "right-0", rect: rect(576, 0, 300, 800) } }, columns: { left: [["pages"]], right: [["annotations"], ["findings"]] }, notes: { has: ["column-shrunk"] } }
1131
+ },
1132
+ {
1133
+ id: "P6-left-outer-edge",
1134
+ title: "A new outer column on the left",
1135
+ expect: "Findings let go 6 px outside the left column's outer edge makes the outermost left column; the right side is then empty.",
1136
+ group: "gestures",
1137
+ scene: win(),
1138
+ gestures: [g.press("findings"), g.at(12 - LEFT_OUT, 400), g.hold(), g.release()],
1139
+ expectLayout: { items: { findings: { edge: "left-1", rect: rect(12, 0, 220, 800) }, pages: { rect: rect(244, 0, 300, 394) }, annotations: { rect: rect(244, 406, 300, 394) } }, columns: { left: [["findings"], ["pages", "annotations"]], right: [] } }
1140
+ },
1141
+ {
1142
+ id: "P6-between-columns-line",
1143
+ title: "The line between two columns",
1144
+ expect: "Dropped on the new-column line at the inner end of the left side, Annotations makes a second left column.",
1145
+ group: "gestures",
1146
+ scene: win(),
1147
+ gestures: g.drag("annotations", g.column("left", 1)),
1148
+ expectLayout: { items: { pages: { rect: rect(12, 0, 220, 800) }, annotations: { edge: "left-1", rect: rect(244, 0, 220, 800) }, findings: { rect: rect(808, 0, 300, 800) } }, columns: { left: [["pages"], ["annotations"]], right: [["findings"]] } }
1149
+ },
1150
+ {
1151
+ id: "P7-end-reach",
1152
+ title: "A drop just past the end of a stack is its end gap",
1153
+ expect: "A drop up to 24 px past the end of a stack is its end gap: Pages let go 14 px below the right column's last member goes last in it.",
1154
+ group: "gestures",
1155
+ scene: win(),
1156
+ gestures: [g.press("pages"), g.at(958, 814), g.hold(), g.release()],
1157
+ expectLayout: { items: { annotations: { rect: rect(12, 0, 300, 800) }, findings: { rect: rect(808, 0, 300, 394) }, pages: { edge: "right-0", rect: rect(808, 406, 300, 394) } }, columns: { left: [["annotations"]], right: [["findings", "pages"]] } }
1158
+ },
1159
+ {
1160
+ id: "P8-folded-bar-drags-like-a-card",
1161
+ title: "A folded bar drags like a card",
1162
+ expect: "Annotations folded by hand to a bar lifts and drops like a card: on the right column's top gap it lands first, still a bar, on the slot's rect.",
1163
+ group: "gestures",
1164
+ scene: win({ from: { annotations: 1 } }),
1165
+ gestures: g.drag("annotations", g.gap("right-0", 0)),
1166
+ checkpoints: [{ at: 2, layout: { items: { pages: { rect: rect(12, 0, 300, 800) }, annotations: { formKind: "header", edge: "right-0", rect: rect(808, 0, 300, 30) }, findings: { rect: rect(808, 42, 300, 758) } }, columns: { left: [["pages"]], right: [["annotations", "findings"]] } }, note: "the slot" }],
1167
+ expectLayout: { items: { pages: { rect: rect(12, 0, 300, 800) }, annotations: { formKind: "header", edge: "right-0", rect: rect(808, 0, 300, 30) }, findings: { rect: rect(808, 42, 300, 758) } }, columns: { left: [["pages"]], right: [["annotations", "findings"]] } }
1168
+ },
1169
+ {
1170
+ id: "P9-rail-segment-on-its-own-rail",
1171
+ title: "A rail segment dropped on its own rail changes nothing",
1172
+ expect: "In a narrow window, a rail segment dropped on its own side's rail (even below the last segment) never splits or reorders it.",
1173
+ group: "gestures",
1174
+ scene: win({ width: 700 }),
1175
+ gestures: g.drag("annotations", g.rail("left")),
1176
+ expectLayout: { items: { pages: { rail: "left", rect: rect(12, 0, 32, 32) }, annotations: { rail: "left", rect: rect(12, 32, 32, 32) }, findings: { rect: rect(388, 0, 300, 800) } }, rails: { left: ["pages", "annotations"], right: [] }, columns: { right: [["findings"]] } }
1177
+ },
1178
+ {
1179
+ id: "P9-to-the-other-rail",
1180
+ title: "A rail segment docks folded on the other rail",
1181
+ expect: "Annotations dropped on the right side's rail docks folded there, as a segment.",
1182
+ group: "gestures",
1183
+ scene: win({ width: 700 }),
1184
+ gestures: g.drag("annotations", g.rail("right")),
1185
+ expectLayout: { items: { pages: { rail: "left", rect: rect(12, 0, 32, 32) }, findings: { rect: rect(388, 0, 256, 800) }, annotations: { rail: "right", folded: "hand", rect: rect(656, 0, 32, 32) } }, rails: { left: ["pages"], right: ["annotations"] } }
1186
+ },
1187
+ {
1188
+ id: "P10-float-keeps-its-place-and-last-size",
1189
+ title: "A float keeps its place and last size",
1190
+ expect: "Floated from the menu, Annotations leaves its column and floats at the content's top-right corner at its last float size; scrolling never moves it.",
1191
+ group: "gestures",
1192
+ scene: { ...win(), items: { ...win().items, annotations: { ...win().items.annotations, floatSize: { width: 300, height: 440 } } } },
1193
+ gestures: [g.click("annotations", "float"), g.scroll(600)],
1194
+ expectLayout: { items: { annotations: { floating: true, edge: null, rect: rect(496, 0, 300, 440) }, pages: { rect: rect(12, 0, 300, 800) } }, floats: ["annotations"], columns: { left: [["pages"]] } },
1195
+ // Only a page can show that the float didn't scroll with the pages: it measures where the float is drawn.
1196
+ expectDom: [{ at: 1, item: "annotations", count: 1, rect: rect(496, 0, 300, 440), note: "the float is drawn where it was after the scroll" }]
1197
+ },
1198
+ {
1199
+ id: "P10-float-moves-by-the-pointer",
1200
+ title: "A float moves by exactly the pointer's distance",
1201
+ expect: "A float lifted and let go 40 px to the right lands exactly 40 px to the right.",
1202
+ group: "gestures",
1203
+ scene: win({ floats: [{ id: "annotations", rect: rect(400, 100, 300, 440) }], columns: { left: [["pages"]], right: [["findings"]] } }),
1204
+ // Pressed at (50, 20) in the float; the pointer then moves from (450, 120) to (490, 120): 40 px right, no vertical move.
1205
+ gestures: [g.press("annotations", { x: 50, y: 20 }), g.at(490, 120), g.hold(), g.release()],
1206
+ expectLayout: { items: { annotations: { floating: true, rect: rect(440, 100, 300, 440) } } }
1207
+ },
1208
+ {
1209
+ id: "P10-float-lands-where-held",
1210
+ title: "A float lands where the pointer lets go, as it was held",
1211
+ expect: "A float let go over the middle of the pages area lands at the pointer minus where it was held, inside the stage.",
1212
+ group: "gestures",
1213
+ scene: win({ floats: [{ id: "annotations", rect: rect(400, 100, 300, 440) }], columns: { left: [["pages"]], right: [["findings"]] } }),
1214
+ gestures: [g.press("annotations", { x: 50, y: 20 }), g.at(560, 400), g.hold(), g.release()],
1215
+ expectLayout: { items: { annotations: { floating: true, rect: rect(508, 360, 300, 440) } } }
1216
+ },
1217
+ {
1218
+ id: "P11-a-float-never-covers-chrome",
1219
+ title: "A float never covers chrome",
1220
+ expect: "Annotations let go over the title bar lands below it, clear of every bar, and the slot never covers the title.",
1221
+ group: "gestures",
1222
+ scene: withTitle(win()),
1223
+ gestures: [g.press("annotations", { x: 20, y: 10 }), g.at(600, 12), g.hold(), g.release()],
1224
+ checkpoints: [{ at: 2, layout: { items: { annotations: { floating: true, rect: rect(528, 28, 280, 360) }, "window-title": { rect: rect(12, 0, 1096, 28) }, pages: { rect: rect(12, 28, 300, 772) } } }, note: "the preview, below the title bar" }],
1225
+ expectLayout: { items: { annotations: { floating: true, rect: rect(528, 28, 280, 360) }, "window-title": { rect: rect(12, 0, 1096, 28) }, pages: { rect: rect(12, 28, 300, 772) } } }
1226
+ },
1227
+ {
1228
+ id: "P11-big-stored-float-is-clamped",
1229
+ title: "A big stored float is clamped on read and still draggable",
1230
+ expect: "A stored float larger than the stage is drawn inside it, and lifting it still offers every drop target and shows a slot.",
1231
+ group: "gestures",
1232
+ scene: win({ floats: [{ id: "annotations", rect: rect(0, 0, 1300, 1e3) }], columns: { left: [["pages"]], right: [["findings"]] } }),
1233
+ gestures: [g.press("annotations"), g.to(g.gap("left-0", 1)), g.hold()],
1234
+ expectLayout: { items: { pages: { rect: rect(12, 0, 300, 394) }, annotations: { edge: "left-0", rect: rect(12, 406, 300, 394) } } },
1235
+ expectDom: [{ select: "[data-drag-slot][data-drag-target]", count: 1, note: "a slot is shown" }]
1236
+ },
1237
+ {
1238
+ id: "P12-a-press-is-no-use",
1239
+ title: "A press is no use",
1240
+ expect: "A press on a header or grip, with no drag, reshapes nothing: no column swaps width, no fold changes.",
1241
+ group: "gestures",
1242
+ scene: win({ width: 870 }),
1243
+ gestures: [g.press("pages"), g.release(), g.press("findings"), g.release()],
1244
+ expectLayout: { items: { pages: { rect: rect(12, 0, 220, 394) }, annotations: { rect: rect(12, 406, 220, 394) }, findings: { rect: rect(576, 0, 282, 800) } }, notes: { hasNot: ["content-changed"] } }
1245
+ },
1246
+ {
1247
+ id: "P12b-a-press-is-no-use-by-the-stored-ages",
1248
+ title: "A press is no use, by the stored ages",
1249
+ expect: "A press on Pages' header, with no drag, changes no age: after a reload Pages is still the oldest, so in a narrow window it is the column that folds first, and the stored ages are as they began.",
1250
+ group: "gestures",
1251
+ scene: win({ width: 700, columns: { left: [["pages"]], right: [["findings"]] } }),
1252
+ gestures: [g.press("pages"), g.release(), g.key("Reload")],
1253
+ expectLayout: { items: { pages: { rail: "left" }, findings: { formKind: "open", edge: "right-0" } }, rails: { left: ["pages"], right: [] } },
1254
+ expectStored: { items: { pages: { used: 1 }, findings: { used: 3 } } }
1255
+ },
1256
+ {
1257
+ id: "P13-kinds",
1258
+ title: "Targets by kind: a panel",
1259
+ expect: "Lifting a panel offers panel columns, rails, new-column lines and the float target, never a toolbar's gaps: over the tools bar it floats.",
1260
+ group: "gestures",
1261
+ scene: {
1262
+ ...win(),
1263
+ edges: [...win().edges, { id: "tools-bar", side: "bottom", ring: 0, span: "full", accepts: ["group"], items: ["tools"], cross: { min: 28, max: 60 } }],
1264
+ items: { ...win().items, tools: { id: "tools", kind: "group", used: 0, forms: { row: [form("stacked", 60, 120, 28), form("icons", 40, 40, 28), form("menu", 0, 0, 0)] } } }
1265
+ },
1266
+ gestures: [g.press("pages", { x: 20, y: 10 }), g.at(560, 780), g.hold()],
1267
+ expectLayout: { items: { pages: { floating: true, rect: rect(528, 410, 280, 360) }, tools: { edge: "tools-bar", rect: rect(12, 770, 120, 30) }, annotations: { rect: rect(12, 0, 300, 770) } }, order: { "tools-bar": ["tools"] } },
1268
+ expectDom: [{ select: "[data-drag-slot]", count: 1, note: "only the float's slot" }]
1269
+ },
1270
+ {
1271
+ id: "P13-a-group-never-gets-panel-targets",
1272
+ title: "Targets by kind: a group",
1273
+ expect: "Lifting a group offers none of the panel columns, rails or the float (groups don't float here): held over a column, nothing is offered and no slot shows.",
1274
+ group: "gestures",
1275
+ scene: {
1276
+ ...win(),
1277
+ edges: [...win().edges, { id: "tools-bar", side: "bottom", ring: 0, span: "full", accepts: ["group"], items: ["tools"], cross: { min: 28, max: 60 } }],
1278
+ items: { ...win().items, tools: { id: "tools", kind: "group", used: 0, forms: { row: [form("stacked", 60, 120, 28), form("icons", 40, 40, 28), form("menu", 0, 0, 0)] } } }
1279
+ },
1280
+ gestures: [g.press("tools"), g.at(160, 200), g.hold()],
1281
+ // No target: the committed layout with Tools' place left empty, and nothing else moved (Pages stays 379 tall).
1282
+ expectLayout: { items: { tools: null, pages: { rect: rect(12, 0, 300, 379) }, annotations: { rect: rect(12, 391, 300, 379) }, findings: { rect: rect(808, 0, 300, 770) } }, notes: { hasNot: ["content-changed"] } },
1283
+ expectDom: [{ select: "[data-drag-slot]", count: 0, note: "no slot for a group over a panel column" }]
1284
+ },
1285
+ {
1286
+ id: "P14-open-close-and-dock-at-default",
1287
+ title: "Close, open, and Dock at the default place",
1288
+ expect: "A closed item keeps its place; opening it puts it back where it was and never closes another; Float then Dock puts Pages above Annotations again.",
1289
+ group: "gestures",
1290
+ scene: win(),
1291
+ gestures: [g.click("annotations", "close"), g.click("annotations", "open"), g.click("pages", "float"), g.click("pages", "dock")],
1292
+ checkpoints: [
1293
+ { at: 0, layout: { items: { annotations: null, pages: { rect: rect(12, 0, 300, 800) } } }, note: "closed: out of the column" },
1294
+ { at: 1, layout: { items: { annotations: { rect: rect(12, 406, 300, 394) }, pages: { rect: rect(12, 0, 300, 394) } } }, note: "opened: back below Pages" },
1295
+ { at: 2, layout: { items: { pages: { floating: true, rect: rect(516, 0, 280, 360) }, annotations: { rect: rect(12, 0, 300, 800) } } }, note: "floated" }
1296
+ ],
1297
+ expectLayout: { items: { pages: { rect: rect(12, 0, 300, 394) }, annotations: { rect: rect(12, 406, 300, 394) }, findings: { rect: rect(808, 0, 300, 800) } }, columns: { left: [["pages", "annotations"]], right: [["findings"]] } }
1298
+ },
1299
+ {
1300
+ id: "P14b-dock-after-a-column-id-is-reused",
1301
+ title: "Dock when a new column took a pruned column's id",
1302
+ expect: "Findings moved into the left column empties its right column, which goes; Pages opened in a new right column gets that column's id again. Dock then gives Findings its own column at the right side's outer end, as at the start, with Pages inside it: never a place beside Pages.",
1303
+ group: "gestures",
1304
+ scene: win(),
1305
+ gestures: [g.moveTo("findings", g.gap("left-0", 2)), g.moveTo("pages", g.column("right", 0)), g.click("findings", "dock")],
1306
+ checkpoints: [{ at: 1, layout: { columns: { left: [["annotations", "findings"]], right: [["pages"]] } }, note: "Pages in a new right column" }],
1307
+ expectLayout: { columns: { left: [["annotations"]], right: [["findings"], ["pages"]] } }
1308
+ },
1309
+ {
1310
+ id: "P15-stops-for-the-keyboard",
1311
+ title: "Move to \u203A stops",
1312
+ expect: `The places "Move to \u203A" offers for Annotations are, in this order: the left rail, a new column at the left side's outer end, the gap before Pages, a new column at its inner end, the right rail, a new column at the right side's inner end, the gaps before and after Findings, a new column at its outer end, and a float; each one moves Annotations there, and Dock puts it back.`,
1313
+ group: "gestures",
1314
+ scene: win(),
1315
+ gestures: [
1316
+ g.moveTo("annotations", g.column("left", 0)),
1317
+ g.click("annotations", "dock"),
1318
+ g.moveTo("annotations", g.gap("right-0", 0)),
1319
+ g.click("annotations", "dock"),
1320
+ g.moveTo("annotations", g.float),
1321
+ g.click("annotations", "dock")
1322
+ ],
1323
+ checkpoints: [
1324
+ { at: 0, layout: { items: { annotations: { edge: "left-1", rect: rect(12, 0, 220, 800) }, pages: { rect: rect(244, 0, 220, 800) } } }, note: "a new column at the left side's outer end" },
1325
+ { at: 2, layout: { items: { annotations: { edge: "right-0", rect: rect(808, 0, 300, 394) }, findings: { rect: rect(808, 406, 300, 394) } } }, note: "before Findings" },
1326
+ { at: 4, layout: { items: { annotations: { floating: true, rect: rect(516, 0, 280, 360) } } }, note: "the menu's Float: its last size, anchored to the content's top-right" }
1327
+ ],
1328
+ expectLayout: { items: { pages: { rect: rect(12, 0, 300, 394) }, annotations: { rect: rect(12, 406, 300, 394) }, findings: { rect: rect(808, 0, 300, 800) } }, columns: { left: [["pages", "annotations"]], right: [["findings"]] } },
1329
+ expectStops: {
1330
+ item: "annotations",
1331
+ places: [
1332
+ { kind: "rail", side: "left", ring: 0 },
1333
+ { kind: "column", side: "left", ring: 0 },
1334
+ { kind: "gap", edge: "left-0", zone: "start", at: 0 },
1335
+ { kind: "column", side: "left", ring: 1 },
1336
+ { kind: "rail", side: "right", ring: 0 },
1337
+ { kind: "column", side: "right", ring: 0 },
1338
+ { kind: "gap", edge: "right-0", zone: "start", at: 0 },
1339
+ { kind: "gap", edge: "right-0", zone: "start", at: 1 },
1340
+ { kind: "column", side: "right", ring: 1 },
1341
+ { kind: "float" }
1342
+ ]
1343
+ }
1344
+ },
1345
+ {
1346
+ id: "P15-rail-stop-then-dock",
1347
+ title: "Dock after a rail stop restores the item",
1348
+ expect: `After "Move to \u203A rail" (docked folded), Dock puts Annotations back where the start layout had it, open: Dock restores the item's start fold, not only its place.`,
1349
+ group: "gestures",
1350
+ scene: win(),
1351
+ gestures: [g.moveTo("annotations", g.rail("left", 0)), g.click("annotations", "dock"), g.moveTo("annotations", g.rail("right", 0)), g.click("annotations", "dock")],
1352
+ checkpoints: [{ at: 1, layout: { items: { pages: { rect: rect(12, 0, 300, 394) }, annotations: { formKind: "open", edge: "left-0", rect: rect(12, 406, 300, 394) } } }, note: "docked back, open" }],
1353
+ expectLayout: { items: { pages: { rect: rect(12, 0, 300, 394) }, annotations: { formKind: "open", edge: "left-0", rect: rect(12, 406, 300, 394) }, findings: { rect: rect(808, 0, 300, 800) } }, columns: { left: [["pages", "annotations"]], right: [["findings"]] } },
1354
+ expectStored: { items: { annotations: { from: null } } }
1355
+ }
1356
+ ];
1357
+
1358
+ // src/scene/cases/rows-windows.ts
1359
+ var shape = (columns, rails, atLeast) => ({
1360
+ columns: { left: columns.left ?? [], right: columns.right ?? [] },
1361
+ rails: { left: rails.left ?? [], right: rails.right ?? [] },
1362
+ ...atLeast !== void 0 ? { contentAtLeast: { width: atLeast } } : {}
1363
+ });
1364
+ function at(id, title2, group2, spec, o, width, columns, rails, atLeast, walk) {
1365
+ const gestures = [];
1366
+ if (walk) for (let w = 1400 - walk; w > width; w -= walk) gestures.push(g.resizeWindow(w, 800));
1367
+ if (walk) gestures.push(g.resizeWindow(width, 800));
1368
+ return {
1369
+ id,
1370
+ title: title2,
1371
+ expect: `At a stage ${width} px wide: ${[...(columns.left ?? []).map((c) => `left column ${c.join("+")}`), ...(columns.right ?? []).map((c) => `right column ${c.join("+")}`), ...rails.left?.length ? [`left rail ${rails.left.join("+")}`] : [], ...rails.right?.length ? [`right rail ${rails.right.join("+")}`] : []].join(", ") || "nothing open"}${walk ? " (reached by shrinking a step at a time)" : ""}.`,
1372
+ group: group2,
1373
+ scene: winScene(spec, { ...o, width: walk ? 1400 : width }),
1374
+ ...walk ? {} : { settings: { stage: { w: width, h: 800 } } },
1375
+ gestures,
1376
+ expectLayout: shape(columns, rails, atLeast)
1377
+ };
1378
+ }
1379
+ var ALL_THREE = { left: ["pages", "annotations"], right: ["findings"] };
1380
+ var PAIR = { columns: { left: [["annotations"]], right: [["findings"]] } };
1381
+ function windowRows() {
1382
+ const rows = [];
1383
+ const A = (name, o, w, c, r, min, walk) => {
1384
+ rows.push(at(`window-a-${name}-${w}${walk ? "-walk" : ""}`, `Window A, ${name}, ${w} px`, "window-a", WINDOW_A, o, w, c, r, min, walk));
1385
+ };
1386
+ const B = (name, o, w, c, r, min, walk) => {
1387
+ rows.push(at(`window-b-${name}-${w}${walk ? "-walk" : ""}`, `Window B, ${name}, ${w} px`, "window-b", WINDOW_B, o, w, c, r, min, walk));
1388
+ };
1389
+ const open3 = { left: [ALL_THREE.left], right: [ALL_THREE.right] };
1390
+ const leftFolded3 = { right: [ALL_THREE.right] };
1391
+ const railsLeft3 = { left: ALL_THREE.left };
1392
+ const railsAll3 = { left: ALL_THREE.left, right: ALL_THREE.right };
1393
+ A("three", {}, 808, open3, {}, 320);
1394
+ A("three", {}, 807, leftFolded3, railsLeft3);
1395
+ A("three", {}, 620, leftFolded3, railsLeft3, 320);
1396
+ A("three", {}, 619, {}, railsAll3);
1397
+ A("three", {}, 576, {}, railsAll3);
1398
+ A("three", {}, 575, {}, railsAll3);
1399
+ A("three", {}, 807, leftFolded3, railsLeft3, void 0, 7);
1400
+ A("three", {}, 619, {}, railsAll3, void 0, 7);
1401
+ A("pair", PAIR, 808, { left: [["annotations"]], right: [["findings"]] }, {});
1402
+ A("pair", PAIR, 807, { right: [["findings"]] }, { left: ["annotations"] });
1403
+ A("pair", PAIR, 620, { right: [["findings"]] }, { left: ["annotations"] });
1404
+ A("pair", PAIR, 619, {}, { left: ["annotations"], right: ["findings"] });
1405
+ const bare = (w, c, r) => {
1406
+ rows.push(at(`window-a-bare-${w}`, `Window A without gap, padding or a 36 px rail, ${w} px`, "window-a", WINDOW_BARE, {}, w, c, r));
1407
+ };
1408
+ bare(760, open3, {});
1409
+ bare(759, leftFolded3, railsLeft3);
1410
+ bare(576, leftFolded3, railsLeft3);
1411
+ bare(575, {}, railsAll3);
1412
+ B("three", {}, 720, open3, {}, 320);
1413
+ B("three", {}, 719, leftFolded3, railsLeft3);
1414
+ B("three", {}, 552, leftFolded3, railsLeft3, 320);
1415
+ B("three", {}, 551, {}, railsAll3);
1416
+ B("three", {}, 520, {}, railsAll3);
1417
+ B("three", {}, 519, {}, railsAll3);
1418
+ B("three", {}, 552, leftFolded3, railsLeft3, void 0, 7);
1419
+ B("three", {}, 551, {}, railsAll3, void 0, 7);
1420
+ B("pair", PAIR, 720, { left: [["annotations"]], right: [["findings"]] }, {});
1421
+ B("pair", PAIR, 719, { right: [["findings"]] }, { left: ["annotations"] });
1422
+ B("pair", PAIR, 590, { right: [["findings"]] }, { left: ["annotations"] });
1423
+ B("pair", PAIR, 552, { right: [["findings"]] }, { left: ["annotations"] });
1424
+ B("pair", PAIR, 551, {}, { left: ["annotations"], right: ["findings"] });
1425
+ return rows;
1426
+ }
1427
+ var HAND = [
1428
+ {
1429
+ id: "window-a-hand-bar",
1430
+ title: "A panel folded by hand is a bar in place",
1431
+ expect: "Annotations folded by hand inside the stack is a 30 px bar as wide as the column; Pages takes the height the bar leaves.",
1432
+ group: "window-a",
1433
+ scene: winScene(WINDOW_A, { from: { annotations: 1 } }),
1434
+ gestures: [],
1435
+ expectLayout: {
1436
+ items: { annotations: { formKind: "header", rect: { height: 30 } }, pages: { formKind: "open", rect: { height: 800 - 30 - 12 } } },
1437
+ columns: { left: [["pages", "annotations"]] }
1438
+ }
1439
+ },
1440
+ {
1441
+ id: "window-a-hand-ride",
1442
+ title: "A one-panel column folded by hand rides",
1443
+ expect: "With handFold ride, a one-panel column folded by hand is a title bar over the first open column of its side, at that column's width, taking no width of its own.",
1444
+ group: "window-a",
1445
+ scene: winScene(WINDOW_A, { handFold: "ride", from: { annotations: 1 }, columns: { left: [["pages"], ["annotations"]], right: [["findings"]] } }),
1446
+ gestures: [],
1447
+ // The rider is as wide as the column it rides (220), 30 tall, above Pages; the content is exactly what it is without the
1448
+ // rider's column at all (x 244, 632 wide), so it takes no width of its own.
1449
+ expectLayout: {
1450
+ items: { annotations: { rides: "left-0", folded: "hand", formKind: "header", rect: { x: 12, y: 0, width: 220, height: 30 } }, pages: { edge: "left-0", rect: { x: 12, y: 30, width: 220, height: 770 } } },
1451
+ content: { x: 244, y: 0, width: 632, height: 800 },
1452
+ edges: { "left-0": { rect: { x: 12, y: 30, width: 220 } } }
1453
+ }
1454
+ },
1455
+ {
1456
+ id: "window-a-hand-all",
1457
+ title: "A column folded all by hand goes to the rail",
1458
+ expect: "A column whose members are all folded by hand goes to its side's rail.",
1459
+ group: "window-a",
1460
+ scene: winScene(WINDOW_A, { from: { pages: 1, annotations: 1 } }),
1461
+ gestures: [],
1462
+ expectLayout: { columns: { left: [] }, rails: { left: ["pages", "annotations"] } }
1463
+ }
1464
+ ];
1465
+ var WINDOW_ROWS = [...windowRows(), ...HAND];
1466
+
1467
+ // src/scene/cases/host.ts
1468
+ var LIFT_THRESHOLD = 4;
1469
+ var END_REACH = 24;
1470
+ var EPS = 1e-6;
1471
+ var inside = (r, p) => p.x >= r.x - EPS && p.x <= r.x + r.width + EPS && p.y >= r.y - EPS && p.y <= r.y + r.height + EPS;
1472
+ var area = (r) => Math.max(0, r.width) * Math.max(0, r.height);
1473
+ var centre = (r) => ({ x: r.x + r.width / 2, y: r.y + r.height / 2 });
1474
+ function pickTarget(list, point) {
1475
+ let best = null;
1476
+ for (const t of list) {
1477
+ if (!inside(t.hit, point)) continue;
1478
+ if (!best || t.priority < best.priority || t.priority === best.priority && area(t.hit) < area(best.hit)) best = t;
1479
+ }
1480
+ return best;
1481
+ }
1482
+ function targetIdOf(place, item) {
1483
+ switch (place.kind) {
1484
+ case "gap":
1485
+ return `gap:${place.edge}:${place.zone}:${place.at}`;
1486
+ case "column":
1487
+ return `column:${place.side}:${place.ring}`;
1488
+ case "rail":
1489
+ return `rail:${place.side}:${place.ring}`;
1490
+ case "float":
1491
+ return `float:${item}`;
1492
+ case "home":
1493
+ return `home:${item}`;
1494
+ default:
1495
+ return null;
1496
+ }
1497
+ }
1498
+ function targetAt(list, place, item) {
1499
+ const id = targetIdOf(place, item);
1500
+ return (id ? list.find((t) => t.id === id) : void 0) ?? list.find((t) => t.place.kind === place.kind && (place.kind === "none" || id === null)) ?? null;
1501
+ }
1502
+ function resolvePlace(list, place, item, area_) {
1503
+ const t = targetAt(list, place, item);
1504
+ if (!t) return null;
1505
+ const big = t.hit.width > 1e6 || t.hit.height > 1e6;
1506
+ const candidates = [];
1507
+ if (big) {
1508
+ if (area_.content) candidates.push(centre(area_.content));
1509
+ candidates.push(centre(area_.stage));
1510
+ } else {
1511
+ candidates.push(centre(t.hit));
1512
+ }
1513
+ const region = big ? area_.stage : t.hit;
1514
+ for (const fy of [0.5, 0.25, 0.75, 0.1, 0.9, 0.4, 0.6, 0, 1]) {
1515
+ for (const fx of [0.5, 0.25, 0.75, 0.1, 0.9, 0.4, 0.6, 0, 1]) candidates.push({ x: region.x + region.width * fx, y: region.y + region.height * fy });
1516
+ }
1517
+ return candidates.find((p) => inside(t.hit, p) && pickTarget(list, p) === t) ?? null;
1518
+ }
1519
+ var stageRect = (w, h) => ({ x: 0, y: 0, width: w, height: h });
1520
+ function createSceneHost(options = {}) {
1521
+ const endReach = options.endReach ?? END_REACH;
1522
+ const lifted0 = options.lift ?? LIFT_THRESHOLD;
1523
+ const defaultGrab = options.grab ?? { x: 8, y: 8 };
1524
+ let start = null;
1525
+ let scene = null;
1526
+ let committed = null;
1527
+ let frozen = false;
1528
+ let alt = false;
1529
+ let session = null;
1530
+ const now = () => {
1531
+ if (!scene) throw new Error("nothing is loaded");
1532
+ return scene;
1533
+ };
1534
+ const prev = () => {
1535
+ if (!committed) throw new Error("nothing is loaded");
1536
+ return committed;
1537
+ };
1538
+ const settle = (s) => {
1539
+ committed = solve(s, { previous: prev() });
1540
+ scene = s;
1541
+ };
1542
+ const preview = () => {
1543
+ if (!session?.lifted) return prev();
1544
+ const t = session.target;
1545
+ if (t) return t.after(session.point, session.grab).layout;
1546
+ const l = prev();
1547
+ const { [session.item]: _held, ...items } = l.items;
1548
+ return { ...l, items, floats: l.floats.filter((f2) => f2 !== session.item) };
1549
+ };
1550
+ const aim = () => ({ stage: now().stage, content: prev().content });
1551
+ function liftNow(s) {
1552
+ s.lifted = true;
1553
+ s.list = targets(now(), s.item, { previous: prev(), endReach });
1554
+ s.target = pickTarget(s.list, s.point);
1555
+ }
1556
+ function move(g2) {
1557
+ const s = session;
1558
+ if (!s) return;
1559
+ if (g2.place) {
1560
+ if (!s.lifted) liftNow(s);
1561
+ const p = resolvePlace(s.list, g2.place, s.item, aim());
1562
+ if (!p) throw new Error(`no point reaches the target at ${JSON.stringify(g2.place)} (targets: ${s.list.map((t) => t.id).join(", ") || "none"})`);
1563
+ s.point = p;
1564
+ s.target = pickTarget(s.list, p);
1565
+ return;
1566
+ }
1567
+ if (!g2.point) throw new Error("a move needs a point or a place");
1568
+ s.point = { x: g2.point.x, y: g2.point.y };
1569
+ if (!s.lifted && Math.hypot(s.point.x - s.down.x, s.point.y - s.down.y) > lifted0) liftNow(s);
1570
+ else if (s.lifted) s.target = pickTarget(s.list, s.point);
1571
+ }
1572
+ function press(g2) {
1573
+ session = null;
1574
+ const id = g2.item;
1575
+ if (!id) throw new Error("a press needs an item");
1576
+ const s = now();
1577
+ const it = Object.hasOwn(s.items, id) ? s.items[id] : void 0;
1578
+ if (!it) throw new Error(`no item ${id}`);
1579
+ const l = prev().items[id];
1580
+ if (it.fixed || it.closed || !l || l.inMenu || frozen && !alt) return;
1581
+ const grab = g2.point ? { x: g2.point.x, y: g2.point.y } : { x: Math.min(defaultGrab.x, l.rect.width / 2), y: Math.min(defaultGrab.y, l.rect.height / 2) };
1582
+ const down = { x: l.rect.x + grab.x, y: l.rect.y + grab.y };
1583
+ if (l.floating) settle(raise(s, id));
1584
+ session = { item: id, grab, down, point: down, lifted: false, list: [], target: null };
1585
+ }
1586
+ function release() {
1587
+ const s = session;
1588
+ session = null;
1589
+ if (!s || !s.lifted) return;
1590
+ const t = s.target;
1591
+ if (!t || t.place.kind === "home" || t.place.kind === "none") return;
1592
+ const after = t.after(s.point, s.grab);
1593
+ scene = after.scene;
1594
+ committed = after.layout;
1595
+ }
1596
+ function matchStop(g2) {
1597
+ const id = g2.item;
1598
+ const list = stops(now(), id, { previous: prev(), endReach });
1599
+ const t = targetAt(list, g2.place, id);
1600
+ if (!t) throw new Error(`${JSON.stringify(g2.place)} is not one of ${id}'s stops (${list.map((x) => x.id).join(", ") || "none"})`);
1601
+ return t;
1602
+ }
1603
+ function click(g2) {
1604
+ const id = g2.item;
1605
+ if (!id) throw new Error("a click needs an item");
1606
+ const s = now();
1607
+ const it = Object.hasOwn(s.items, id) ? s.items[id] : void 0;
1608
+ if (!it) throw new Error(`no item ${id}`);
1609
+ const moves = g2.place !== void 0 || g2.key === "float" || g2.key === "dock";
1610
+ if (moves && frozen && !alt) return;
1611
+ if (g2.place) {
1612
+ const stop = matchStop(g2);
1613
+ const after = stop.place.kind === "float" ? (() => {
1614
+ const s2 = use(floatAt(s, id), id);
1615
+ return { scene: s2, layout: solve(s2, { previous: prev() }) };
1616
+ })() : stop.after(centre(s.stage));
1617
+ scene = after.scene;
1618
+ committed = after.layout;
1619
+ return;
1620
+ }
1621
+ switch (g2.key) {
1622
+ case void 0: {
1623
+ if (it.closed) settle(use(open(s, id), id));
1624
+ else if ((it.from ?? 0) > 0) settle(use(fold(s, id, false), id));
1625
+ else if (prev().items[id]?.floating) settle(raise(s, id));
1626
+ return;
1627
+ }
1628
+ case "use":
1629
+ return settle(use(s, id));
1630
+ case "open":
1631
+ return settle(use(open(s, id), id));
1632
+ case "close":
1633
+ return settle(close(s, id));
1634
+ case "fold":
1635
+ return settle(use(fold(s, id, true), id));
1636
+ case "unfold":
1637
+ return settle(use(fold(s, id, false), id));
1638
+ case "float":
1639
+ return settle(use(floatAt(s, id), id));
1640
+ case "dock": {
1641
+ const place = homeFor(s, id, start);
1642
+ if (!place) throw new Error(`the loaded scene puts ${id} nowhere`);
1643
+ return settle(use(dockHome(s, id, start), id));
1644
+ }
1645
+ default:
1646
+ throw new Error(`no control ${g2.key}`);
1647
+ }
1648
+ }
1649
+ function measure(id, d) {
1650
+ const edge = prev().items[id]?.edge;
1651
+ const side = edge ? prev().edges[edge]?.side : void 0;
1652
+ const axis = side === "top" || side === "bottom" ? "row" : "column";
1653
+ const grown = (s) => {
1654
+ const it = Object.hasOwn(s.items, id) ? s.items[id] : void 0;
1655
+ const forms = it?.forms[axis];
1656
+ if (!it || !forms || forms.length === 0) return s;
1657
+ const f0 = forms[0];
1658
+ const f2 = { ...f0, main: { ...f0.main, min: Math.max(0, f0.main.min + d), natural: Math.max(0, f0.main.natural + d) } };
1659
+ return { ...s, items: { ...s.items, [id]: { ...it, forms: { ...it.forms, [axis]: [f2, ...forms.slice(1)] } } } };
1660
+ };
1661
+ if (!Object.hasOwn(now().items, id)) throw new Error(`no item ${id}`);
1662
+ start = grown(start);
1663
+ settle(grown(now()));
1664
+ }
1665
+ function resizeNow(g2) {
1666
+ if (g2.edge !== void 0) {
1667
+ if (g2.size === void 0) throw new Error("a resize of an edge needs a size");
1668
+ if (!now().edges.some((e) => e.id === g2.edge)) throw new Error(`no edge ${g2.edge}`);
1669
+ settle(resize(now(), g2.edge, g2.size));
1670
+ } else if (g2.item !== void 0) {
1671
+ if (g2.size === void 0) throw new Error("a resize of an item needs a size");
1672
+ measure(g2.item, g2.size);
1673
+ } else if (g2.point) {
1674
+ const stage = stageRect(g2.point.x, g2.point.y);
1675
+ start = { ...start, stage };
1676
+ settle({ ...now(), stage });
1677
+ } else throw new Error("a resize needs an edge, an item or a point (the window's size)");
1678
+ }
1679
+ function reload() {
1680
+ session = null;
1681
+ const data = JSON.parse(JSON.stringify(storeScene(now())));
1682
+ const read = readScene(data, { ...start, stage: now().stage });
1683
+ scene = read.scene;
1684
+ committed = solve(read.scene);
1685
+ }
1686
+ return {
1687
+ load(s, settings = {}) {
1688
+ const stage = settings.stage ? stageRect(settings.stage.w, settings.stage.h) : s.stage;
1689
+ const loaded = settings.stage ? { ...s, stage } : s;
1690
+ start = loaded;
1691
+ scene = loaded;
1692
+ committed = solve(loaded);
1693
+ frozen = settings.frozen === true;
1694
+ alt = false;
1695
+ session = null;
1696
+ },
1697
+ perform(g2) {
1698
+ switch (g2.type) {
1699
+ case "press":
1700
+ return press(g2);
1701
+ case "move":
1702
+ return move(g2);
1703
+ case "release":
1704
+ return release();
1705
+ case "key":
1706
+ if (g2.key === "Escape") session = null;
1707
+ else if (g2.key === "Alt") alt = true;
1708
+ else if (g2.key === "Alt:up") alt = false;
1709
+ else if (g2.key === "Reload") reload();
1710
+ else throw new Error(`no key ${g2.key}`);
1711
+ return;
1712
+ case "click":
1713
+ return click(g2);
1714
+ case "resize":
1715
+ return resizeNow(g2);
1716
+ case "scroll":
1717
+ case "hold":
1718
+ return;
1719
+ default:
1720
+ throw new Error(`no gesture ${String(g2.type)}`);
1721
+ }
1722
+ },
1723
+ layout: preview,
1724
+ scene: now,
1725
+ stored: () => storeScene(now()),
1726
+ stops: (item) => stops(now(), item, { previous: prev(), endReach }).map((t) => t.place),
1727
+ drag: () => session ? { item: session.item, lifted: session.lifted, target: session.target?.id ?? null, point: session.point, grab: session.grab } : null
1728
+ };
1729
+ }
1730
+
1731
+ // src/scene/cases/run.ts
1732
+ var DEFAULT_TOLERANCE = 0.5;
1733
+ var defaultItemSelector = (id) => `[data-dock-item="${id.replace(/["\\]/g, "\\$&")}"]`;
1734
+ var KEYS = ["x", "y", "width", "height"];
1735
+ var px = (n) => String(Math.round(n * 100) / 100);
1736
+ var say = (r) => `${px(r.x)},${px(r.y)} ${px(r.width)}x${px(r.height)}`;
1737
+ function rectIssues(what, want, got, tol) {
1738
+ const out = [];
1739
+ for (const k of KEYS) {
1740
+ const w = want[k];
1741
+ if (w !== void 0 && !(Math.abs(got[k] - w) <= tol)) out.push(`${what} ${k} is ${px(got[k])}, expected ${px(w)} (${say(got)})`);
1742
+ }
1743
+ return out;
1744
+ }
1745
+ function dockedIn(l, edge) {
1746
+ const e = l.edges[edge];
1747
+ const column2 = e?.side === "left" || e?.side === "right";
1748
+ return Object.entries(l.items).filter(([, it]) => it.edge === edge && !it.inMenu && !it.rides && it.rail === void 0).sort((a, b) => column2 ? a[1].rect.y - b[1].rect.y : a[1].rect.x - b[1].rect.x).map(([id]) => id);
1749
+ }
1750
+ function columnsOf(l, side) {
1751
+ return Object.entries(l.edges).filter(([, e]) => e.side === side && !e.folded && !e.rides && e.cross > 0).sort((a, b) => a[1].ring - b[1].ring).map(([id]) => dockedIn(l, id)).filter((ids) => ids.length > 0);
1752
+ }
1753
+ function itemIssues(id, want, l, tol) {
1754
+ const got = l.items[id];
1755
+ if (want === null) return got ? [`${id} is drawn (${say(got.rect)}), expected it out of the layout`] : [];
1756
+ if (!got) return [`${id} is not in the layout`];
1757
+ const out = [];
1758
+ if (want.rect) out.push(...rectIssues(id, want.rect, got.rect, tol));
1759
+ if (want.formKind !== void 0 && got.formKind !== want.formKind) out.push(`${id} is ${got.formKind}, expected ${want.formKind}`);
1760
+ if (want.form !== void 0 && got.form !== want.form) out.push(`${id} is form ${got.form}, expected ${want.form}`);
1761
+ if (want.edge !== void 0 && (got.edge ?? null) !== want.edge) out.push(`${id} is docked in ${got.edge ?? "no edge"}, expected ${want.edge ?? "no edge"}`);
1762
+ if (want.zone !== void 0 && got.zone !== want.zone) out.push(`${id} is in the ${got.zone ?? "no"} zone, expected ${want.zone}`);
1763
+ if (want.floating !== void 0 && got.floating === true !== want.floating) out.push(`${id} is ${got.floating ? "floating" : "not floating"}, expected ${want.floating ? "floating" : "not floating"}`);
1764
+ if (want.inMenu !== void 0 && got.inMenu === true !== want.inMenu) out.push(`${id} is ${got.inMenu ? "in the menu" : "not in the menu"}, expected ${want.inMenu ? "in the menu" : "not in the menu"}`);
1765
+ if (want.rail !== void 0 && (got.rail ?? null) !== want.rail) out.push(`${id} is in ${got.rail ?? "no"} rail, expected ${want.rail ?? "no"} rail`);
1766
+ if (want.folded !== void 0 && (got.folded ?? null) !== want.folded) out.push(`${id} is folded ${got.folded ?? "not"}, expected ${want.folded ?? "not"}`);
1767
+ if (want.rides !== void 0 && (got.rides ?? null) !== want.rides) out.push(`${id} rides ${got.rides ?? "nothing"}, expected ${want.rides ?? "nothing"}`);
1768
+ if (want.tab !== void 0 && got.tab === true !== want.tab) out.push(`${id} is ${got.tab ? "a tab" : "not a tab"}, expected ${want.tab ? "a tab" : "not a tab"}`);
1769
+ return out;
1770
+ }
1771
+ function edgeIssues(id, want, l, tol) {
1772
+ const got = l.edges[id];
1773
+ if (want === null) return got ? [`edge ${id} is in the layout, expected none`] : [];
1774
+ if (!got) return [`edge ${id} is not in the layout`];
1775
+ const out = [];
1776
+ if (want.rect) out.push(...rectIssues(`edge ${id}`, want.rect, got.rect, tol));
1777
+ if (want.cross !== void 0 && !(Math.abs(got.cross - want.cross) <= tol)) out.push(`edge ${id} is ${px(got.cross)} across, expected ${px(want.cross)}`);
1778
+ if (want.tabs && got.tabs.join() !== want.tabs.join()) out.push(`edge ${id} tabs are [${got.tabs.join(", ")}], expected [${want.tabs.join(", ")}]`);
1779
+ if (want.menu !== void 0) {
1780
+ const have = got.menu ? got.menu.items : null;
1781
+ if ((have ? have.join() : null) !== (want.menu ? want.menu.join() : null)) out.push(`edge ${id} menu is ${have ? `[${have.join(", ")}]` : "none"}, expected ${want.menu ? `[${want.menu.join(", ")}]` : "none"}`);
1782
+ }
1783
+ return out;
1784
+ }
1785
+ var codes = (notes) => [...new Set(notes.map((n) => n.code))];
1786
+ function layoutIssues(want, layout) {
1787
+ const tol = want.tolerance ?? DEFAULT_TOLERANCE;
1788
+ const out = [];
1789
+ for (const [id, w] of Object.entries(want.items ?? {})) out.push(...itemIssues(id, w, layout, tol));
1790
+ for (const [id, w] of Object.entries(want.edges ?? {})) out.push(...edgeIssues(id, w, layout, tol));
1791
+ if (want.content) out.push(...rectIssues("content", want.content, layout.content, tol));
1792
+ if (want.contentAtLeast) {
1793
+ const { width, height } = want.contentAtLeast;
1794
+ if (width !== void 0 && layout.content.width < width - tol) out.push(`content is ${px(layout.content.width)} wide, expected at least ${px(width)}`);
1795
+ if (height !== void 0 && layout.content.height < height - tol) out.push(`content is ${px(layout.content.height)} tall, expected at least ${px(height)}`);
1796
+ }
1797
+ for (const [edge, ids] of Object.entries(want.order ?? {})) {
1798
+ const have = dockedIn(layout, edge);
1799
+ if (have.join() !== ids.join()) out.push(`${edge} holds [${have.join(", ")}], expected [${ids.join(", ")}]`);
1800
+ }
1801
+ for (const side of ["left", "right"]) {
1802
+ const w = want.columns?.[side];
1803
+ if (w) {
1804
+ const have = columnsOf(layout, side);
1805
+ if (JSON.stringify(have) !== JSON.stringify(w)) out.push(`${side} columns are ${JSON.stringify(have)}, expected ${JSON.stringify(w)}`);
1806
+ }
1807
+ const r = want.rails?.[side];
1808
+ if (r) {
1809
+ const have = (layout.rails[side]?.segments ?? []).map((s) => s.id);
1810
+ if (have.join() !== r.join()) out.push(`${side} rail holds [${have.join(", ")}], expected [${r.join(", ")}]`);
1811
+ }
1812
+ }
1813
+ if (want.floats && layout.floats.join() !== want.floats.join()) out.push(`floats are [${layout.floats.join(", ")}], expected [${want.floats.join(", ")}]`);
1814
+ if (want.notes) {
1815
+ const have = codes(layout.notes);
1816
+ for (const c of want.notes.has ?? []) if (!have.includes(c)) out.push(`no ${c} note (notes: ${have.join(", ") || "none"})`);
1817
+ for (const c of want.notes.hasNot ?? []) if (have.includes(c)) out.push(`unexpected ${c} note`);
1818
+ if (want.notes.none && have.length > 0) out.push(`unexpected notes: ${have.join(", ")}`);
1819
+ }
1820
+ return out;
1821
+ }
1822
+ var labelOf = (c) => c.note ?? (c.select ? `${c.select}${c.attr ? ` ${JSON.stringify(c.attr)}` : ""}` : `root ${JSON.stringify(c.attr ?? {})}`);
1823
+ function domIssues(check, root) {
1824
+ const out = [];
1825
+ const els = check.select ? Array.from(root.querySelectorAll(check.select)) : [root];
1826
+ const n = els.length;
1827
+ if (check.select !== void 0 || check.count !== void 0) {
1828
+ const c = check.count;
1829
+ if (typeof c === "number") {
1830
+ if (n !== c) out.push(`${n} elements match ${check.select ?? "the root"}, expected ${c}`);
1831
+ } else if (c) {
1832
+ if (c.min !== void 0 && n < c.min) out.push(`${n} elements match ${check.select ?? "the root"}, expected at least ${c.min}`);
1833
+ if (c.max !== void 0 && n > c.max) out.push(`${n} elements match ${check.select ?? "the root"}, expected at most ${c.max}`);
1834
+ } else if (n === 0) out.push(`nothing matches ${check.select}`);
1835
+ }
1836
+ if (check.rect) {
1837
+ const tol = check.tolerance ?? DEFAULT_TOLERANCE;
1838
+ const origin = root.getBoundingClientRect?.();
1839
+ for (const el of els) {
1840
+ const box = el.getBoundingClientRect?.();
1841
+ if (!box || !origin) {
1842
+ out.push(`${check.select ?? "the root"} has no bounding rect to read`);
1843
+ continue;
1844
+ }
1845
+ const got = { x: box.left - origin.left, y: box.top - origin.top, width: box.width, height: box.height };
1846
+ out.push(...rectIssues(check.select ?? "the root", check.rect, got, tol));
1847
+ }
1848
+ }
1849
+ for (const [name, want] of Object.entries(check.attr ?? {})) {
1850
+ for (const el of els) {
1851
+ const got = el.getAttribute(name);
1852
+ if (want === null ? got !== null : got !== want) out.push(`${check.select ?? "the root"} has ${name}=${got === null ? "(none)" : `"${got}"`}, expected ${want === null ? "none" : `"${want}"`}`);
1853
+ }
1854
+ }
1855
+ return out;
1856
+ }
1857
+ function storedIssues(want, stored) {
1858
+ const out = [];
1859
+ const data = stored;
1860
+ for (const [id, fields] of Object.entries(want.items ?? {})) {
1861
+ const have = data?.items && Object.hasOwn(data.items, id) ? data.items[id] : void 0;
1862
+ if (!have) {
1863
+ out.push(`the stored form has no item ${id}`);
1864
+ continue;
1865
+ }
1866
+ for (const [k, v] of Object.entries(fields)) {
1867
+ const got = Object.hasOwn(have, k) ? have[k] : null;
1868
+ if (got !== v) out.push(`stored ${id}.${k} is ${JSON.stringify(got)}, expected ${JSON.stringify(v)}`);
1869
+ }
1870
+ }
1871
+ const json = JSON.stringify(stored);
1872
+ for (const s of want.absent ?? []) if (json.includes(s)) out.push(`the stored form contains "${s}"`);
1873
+ return out;
1874
+ }
1875
+ var placeKey = (p) => JSON.stringify(p, (_k, v) => typeof v === "number" && !Number.isFinite(v) ? "Infinity" : v && typeof v === "object" && !Array.isArray(v) ? Object.fromEntries(Object.entries(v).sort(([a], [b]) => a < b ? -1 : 1)) : v);
1876
+ var gestureWords = (g2, i) => {
1877
+ const bits = [g2.item, g2.place ? JSON.stringify(g2.place) : void 0, g2.point ? `${px(g2.point.x)},${px(g2.point.y)}` : void 0, g2.key, g2.edge, g2.size !== void 0 ? String(g2.size) : void 0].filter((x) => x !== void 0);
1878
+ return `gesture ${i + 1} (${g2.type}${bits.length ? ` ${bits.join(" ")}` : ""})`;
1879
+ };
1880
+ function runCase(row2, host) {
1881
+ const failures = [];
1882
+ const skipped = [];
1883
+ const n = row2.gestures.length;
1884
+ const last = n - 1;
1885
+ const fail = (lines, when) => {
1886
+ for (const l2 of lines) failures.push(`${row2.id}${when}: ${l2}`);
1887
+ };
1888
+ const range = (what, at2) => {
1889
+ if (at2 === void 0) return;
1890
+ if (!Number.isInteger(at2) || at2 < 0 || at2 >= n) fail([`${what} is at gesture ${at2}, but the row has ${n} gestures (0 to ${last})`], "");
1891
+ };
1892
+ const itemSelector = (id) => host.itemSelector ? host.itemSelector(id) : defaultItemSelector(id);
1893
+ const aimed = (c) => c.item !== void 0 && c.select === void 0 ? { ...c, select: itemSelector(c.item) } : c;
1894
+ for (const cp of row2.checkpoints ?? []) range("a checkpoint", cp.at);
1895
+ for (const c of row2.expectDom ?? []) {
1896
+ range(`the DOM check ${labelOf(aimed(c))}`, c.at);
1897
+ if (c.item !== void 0 && c.select !== void 0) fail([`the DOM check ${labelOf(c)} has both item and select`], "");
1898
+ }
1899
+ range("the stops check", row2.expectStops?.at);
1900
+ if (failures.length > 0) return { ok: false, failures, skipped };
1901
+ const layoutOf = (when) => {
1902
+ try {
1903
+ return host.layout();
1904
+ } catch (e) {
1905
+ fail([`the host couldn't give its layout: ${e instanceof Error ? e.message : String(e)}`], when);
1906
+ return null;
1907
+ }
1908
+ };
1909
+ const dom = (index) => {
1910
+ for (const c of row2.expectDom ?? []) {
1911
+ if ((c.at ?? last) !== index) continue;
1912
+ const check = aimed(c);
1913
+ const root = host.root ? host.root() : null;
1914
+ if (!root) {
1915
+ skipped.push(labelOf(check));
1916
+ continue;
1917
+ }
1918
+ fail(domIssues(check, root), ` after gesture ${index + 1} (${labelOf(check)})`);
1919
+ }
1920
+ };
1921
+ const stops2 = (index) => {
1922
+ const s = row2.expectStops;
1923
+ if (!s || (s.at ?? last) !== index) return;
1924
+ if (!host.stops) {
1925
+ skipped.push(`the stops of ${s.item}`);
1926
+ return;
1927
+ }
1928
+ const have = host.stops(s.item).map(placeKey);
1929
+ const want = s.places.map(placeKey);
1930
+ if (have.join("\n") !== want.join("\n")) fail([`${s.item}'s stops are
1931
+ ${have.join("\n ")}
1932
+ expected
1933
+ ${want.join("\n ")}`], "");
1934
+ };
1935
+ try {
1936
+ host.load(row2.scene, row2.settings);
1937
+ } catch (e) {
1938
+ fail([`the host couldn't load the scene: ${e instanceof Error ? e.message : String(e)}`], "");
1939
+ return { ok: false, failures, skipped };
1940
+ }
1941
+ for (let i = 0; i < n; i++) {
1942
+ const g2 = row2.gestures[i];
1943
+ try {
1944
+ host.perform(g2);
1945
+ } catch (e) {
1946
+ fail([`${gestureWords(g2, i)} failed: ${e instanceof Error ? e.message : String(e)}`], "");
1947
+ return { ok: false, failures, skipped };
1948
+ }
1949
+ for (const cp of row2.checkpoints ?? []) {
1950
+ if (cp.at !== i || !cp.layout) continue;
1951
+ const l2 = layoutOf(` after ${gestureWords(g2, i)}`);
1952
+ if (l2) fail(layoutIssues(cp.layout, l2), ` after ${gestureWords(g2, i)}${cp.note ? ` (${cp.note})` : ""}`);
1953
+ }
1954
+ dom(i);
1955
+ stops2(i);
1956
+ }
1957
+ if (last < 0) {
1958
+ dom(-1);
1959
+ stops2(-1);
1960
+ }
1961
+ const l = layoutOf("");
1962
+ if (l) fail(layoutIssues(row2.expectLayout, l), "");
1963
+ if (row2.expectStored) {
1964
+ if (!host.stored) skipped.push("the stored form");
1965
+ else {
1966
+ try {
1967
+ fail(storedIssues(row2.expectStored, host.stored()), " (the stored form)");
1968
+ } catch (e) {
1969
+ fail([`the host couldn't give its stored form: ${e instanceof Error ? e.message : String(e)}`], "");
1970
+ }
1971
+ }
1972
+ }
1973
+ return { ok: failures.length === 0, failures, skipped };
1974
+ }
1975
+ function runCases(rows, makeHost) {
1976
+ return rows.map((row2) => ({ id: row2.id, result: runCase(row2, makeHost()) }));
1977
+ }
1978
+
1979
+ // src/scene/cases/index.ts
1980
+ var CASES = [...DOCKING_ROWS, ...BAR_ROWS, ...RULE_ROWS, ...GESTURE_ROWS, ...WINDOW_ROWS];
1981
+ var CASE_GROUPS = [
1982
+ { id: "panels", title: "Panels in a column" },
1983
+ { id: "groups", title: "Groups and toolbars" },
1984
+ { id: "drag", title: "Dragging" },
1985
+ { id: "floats", title: "Floats, saving, freeze" },
1986
+ { id: "bars", title: "Bars give way" },
1987
+ { id: "previous", title: "What previous keeps" },
1988
+ { id: "kinds", title: "Kinds, chrome and reserved room" },
1989
+ { id: "bands", title: "Gap bands, refits and slots" },
1990
+ { id: "gestures", title: "The kits' panel gestures" },
1991
+ { id: "window-a", title: "Window A: width thresholds" },
1992
+ { id: "window-b", title: "Window B: width thresholds" }
1993
+ ];
1994
+ var caseById = (id) => CASES.find((c) => c.id === id);
1995
+ export {
1996
+ CASES,
1997
+ CASE_GROUPS,
1998
+ END_REACH,
1999
+ LIFT_THRESHOLD,
2000
+ WINDOW_A,
2001
+ WINDOW_B,
2002
+ WINDOW_BARE,
2003
+ caseById,
2004
+ createSceneHost,
2005
+ defaultItemSelector,
2006
+ g,
2007
+ layoutIssues,
2008
+ pickTarget,
2009
+ resolvePlace,
2010
+ runCase,
2011
+ runCases,
2012
+ winScene
2013
+ };
2014
+ //# sourceMappingURL=scene-cases.js.map