@n-uf/docking 0.0.0-stage → 26.11.54
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.
- package/CHANGELOG.md +98 -0
- package/LICENSE +129 -0
- package/README.md +96 -2
- package/dist/chunk-KGNFLHSC.js +4280 -0
- package/dist/chunk-KGNFLHSC.js.map +1 -0
- package/dist/index.d.ts +283 -0
- package/dist/index.js +125 -0
- package/dist/index.js.map +1 -0
- package/dist/lanes-CGg4iMPw.d.ts +1327 -0
- package/dist/testing.d.ts +820 -0
- package/dist/testing.js +3091 -0
- package/dist/testing.js.map +1 -0
- package/package.json +72 -3
package/dist/testing.js
ADDED
|
@@ -0,0 +1,3091 @@
|
|
|
1
|
+
import {
|
|
2
|
+
closeItem,
|
|
3
|
+
dockHome,
|
|
4
|
+
floatAt,
|
|
5
|
+
foldItem,
|
|
6
|
+
homeFor,
|
|
7
|
+
lanes,
|
|
8
|
+
markUsed,
|
|
9
|
+
openItem,
|
|
10
|
+
placeTargetId,
|
|
11
|
+
raiseFloat,
|
|
12
|
+
readDockState,
|
|
13
|
+
refusalTargets,
|
|
14
|
+
refusals,
|
|
15
|
+
resizeEdge,
|
|
16
|
+
solve,
|
|
17
|
+
stops,
|
|
18
|
+
storeDockState,
|
|
19
|
+
targets
|
|
20
|
+
} from "./chunk-KGNFLHSC.js";
|
|
21
|
+
|
|
22
|
+
// src/testing/rows-docking.ts
|
|
23
|
+
import { rect as r } from "@n-uf/placement";
|
|
24
|
+
|
|
25
|
+
// src/testing/gestures.ts
|
|
26
|
+
var gap = (edge, at2, zone = "start") => ({ kind: "gap", edge, zone, at: at2 });
|
|
27
|
+
var g = {
|
|
28
|
+
/** Pointer down on the item's handle; `point` is relative to its top-left corner. */
|
|
29
|
+
press: (item, point) => ({ type: "press", item, ...point ? { point } : {} }),
|
|
30
|
+
/** The pointer moves to the target at `place`. */
|
|
31
|
+
to: (place) => ({ type: "move", place }),
|
|
32
|
+
/** The pointer moves to `point` (stage px). */
|
|
33
|
+
at: (x, y) => ({ type: "move", point: { x, y } }),
|
|
34
|
+
hold: (ms = 120) => ({ type: "hold", ms }),
|
|
35
|
+
release: () => ({ type: "release" }),
|
|
36
|
+
escape: () => ({ type: "key", key: "Escape" }),
|
|
37
|
+
key: (key) => ({ type: "key", key }),
|
|
38
|
+
/** The item's control (`key`), or with none, a click that opens or unfolds it. */
|
|
39
|
+
click: (item, key) => ({ type: "click", item, ...key ? { key } : {} }),
|
|
40
|
+
/** The "Move to ›" row for `place`. */
|
|
41
|
+
moveTo: (item, place) => ({ type: "click", item, place }),
|
|
42
|
+
/** The user's size across an edge. */
|
|
43
|
+
resizeEdge: (edge, size) => ({ type: "resize", edge, size }),
|
|
44
|
+
/** The item's measured length changed by `size` px. */
|
|
45
|
+
resizeItem: (item, size) => ({ type: "resize", item, size }),
|
|
46
|
+
/** The stage is now `width` x `height`. */
|
|
47
|
+
resizeWindow: (width, height) => ({ type: "resize", point: { x: width, y: height } }),
|
|
48
|
+
scroll: (dy) => ({ type: "scroll", size: dy }),
|
|
49
|
+
/** A place: before the `at`-th item of an edge's zone. */
|
|
50
|
+
gap,
|
|
51
|
+
column: (side, ring) => ({ kind: "column", side, ring }),
|
|
52
|
+
rail: (side, ring = 0) => ({ kind: "rail", side, ring }),
|
|
53
|
+
float: { kind: "float" },
|
|
54
|
+
home: { kind: "home" },
|
|
55
|
+
/** Press, aim at `place`, rest, let go. */
|
|
56
|
+
drag: (item, place, grab) => [
|
|
57
|
+
{ type: "press", item, ...grab ? { point: grab } : {} },
|
|
58
|
+
{ type: "move", place },
|
|
59
|
+
{ type: "hold", ms: 120 },
|
|
60
|
+
{ type: "release" }
|
|
61
|
+
]
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// src/testing/world.ts
|
|
65
|
+
var form = (kind, min, natural, cross, extra = {}) => ({
|
|
66
|
+
kind,
|
|
67
|
+
main: { min, natural, ...extra.grows ? { grows: true } : {} },
|
|
68
|
+
cross: { natural: cross, ...extra.crossMin !== void 0 ? { min: extra.crossMin } : {} },
|
|
69
|
+
...extra.rank !== void 0 ? { rank: extra.rank } : {},
|
|
70
|
+
...extra.setsCross !== void 0 ? { setsCross: extra.setsCross } : {}
|
|
71
|
+
});
|
|
72
|
+
var BENCH_PANELS = ["pages", "annotations", "findings"];
|
|
73
|
+
var BENCH_GROUPS = ["views", "tools", "zoom"];
|
|
74
|
+
var PANEL_SIZE = {
|
|
75
|
+
pages: { column: 150, wide: 200 },
|
|
76
|
+
annotations: { column: 130, wide: 240 },
|
|
77
|
+
findings: { column: 170, wide: 220 }
|
|
78
|
+
};
|
|
79
|
+
var WORDS = 3;
|
|
80
|
+
var iconsMain = (axis) => (axis === "column" ? 18 : 16) + 26 * WORDS;
|
|
81
|
+
var FOLD = 40;
|
|
82
|
+
var MENU = 28;
|
|
83
|
+
var BENCH_RAIL = 30;
|
|
84
|
+
var BENCH_BAR_MAX = 40;
|
|
85
|
+
function benchPanel(id, used, more = {}) {
|
|
86
|
+
const s = PANEL_SIZE[id];
|
|
87
|
+
return {
|
|
88
|
+
id,
|
|
89
|
+
kind: "panel",
|
|
90
|
+
used,
|
|
91
|
+
forms: {
|
|
92
|
+
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)],
|
|
93
|
+
row: [form("header", 110, 110, 28), form("rail", 26, 26, 26), form("menu", 0, 0, 0)]
|
|
94
|
+
},
|
|
95
|
+
floatSizes: { column: { width: s.wide, height: s.column + 40 } },
|
|
96
|
+
...more
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function benchGroup(id, used, more = {}) {
|
|
100
|
+
const row2 = 244;
|
|
101
|
+
const ranked = (f2, rank) => ({ ...f2, rank });
|
|
102
|
+
const bar3 = 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)];
|
|
103
|
+
return {
|
|
104
|
+
id,
|
|
105
|
+
kind: "group",
|
|
106
|
+
used,
|
|
107
|
+
forms: {
|
|
108
|
+
column: [form("row", 30, 30, 240), form("stacked", 84, 84, 84), form("icons", iconsMain("column"), iconsMain("column"), 28), form("menu", 0, 0, 0)],
|
|
109
|
+
row: bar3
|
|
110
|
+
},
|
|
111
|
+
// The same float size along either orient: a group of the bench floats at it, as a row or upright.
|
|
112
|
+
floatSizes: { row: { width: row2, height: 34 }, column: { width: row2, height: 34 } },
|
|
113
|
+
...more
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
var BENCH_LAYOUT = {
|
|
117
|
+
column: ["pages", "annotations"],
|
|
118
|
+
bar: ["views", "tools", "zoom"],
|
|
119
|
+
floats: [{ id: "findings", rect: { x: 440, y: 130, width: 220, height: 190 } }]
|
|
120
|
+
};
|
|
121
|
+
var DEFAULT_USED = { pages: 1, annotations: 2, findings: 3, views: 4, tools: 5, zoom: 6 };
|
|
122
|
+
function bench(layout = BENCH_LAYOUT, o = {}) {
|
|
123
|
+
const width = o.width ?? 840;
|
|
124
|
+
const height = o.height ?? 500;
|
|
125
|
+
const used = { ...DEFAULT_USED, ...o.used };
|
|
126
|
+
const items = {};
|
|
127
|
+
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] } : {} });
|
|
128
|
+
for (const id of BENCH_GROUPS) items[id] = benchGroup(id, used[id], o.kept?.includes(id) ? { kept: true } : {});
|
|
129
|
+
const pad = o.pad ?? 12;
|
|
130
|
+
const edges = [
|
|
131
|
+
{ 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 } },
|
|
132
|
+
{ 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 } }
|
|
133
|
+
];
|
|
134
|
+
const floats = layout.floats.map((f2) => ({ id: f2.id, rect: { ...f2.rect }, ...BENCH_GROUPS.includes(f2.id) ? { orient: "row" } : {} }));
|
|
135
|
+
return { stage: { x: 0, y: 0, width, height }, edges, items, floats, floatKinds: ["panel", "group"] };
|
|
136
|
+
}
|
|
137
|
+
var panel = (id, used, more = {}, wide = 260) => ({
|
|
138
|
+
id,
|
|
139
|
+
kind: "panel",
|
|
140
|
+
used,
|
|
141
|
+
forms: {
|
|
142
|
+
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)],
|
|
143
|
+
row: [form("header", 120, 160, 28), form("menu", 0, 0, 0)]
|
|
144
|
+
},
|
|
145
|
+
...more
|
|
146
|
+
});
|
|
147
|
+
var group = (id, used, more = {}) => ({
|
|
148
|
+
id,
|
|
149
|
+
kind: "group",
|
|
150
|
+
used,
|
|
151
|
+
forms: {
|
|
152
|
+
row: [form("row", 180, 200, 28), form("icons", 84, 84, 28), form("menu", 0, 0, 0)],
|
|
153
|
+
column: [form("stacked", 96, 96, 84), form("icons", 84, 84, 28), form("menu", 0, 0, 0)]
|
|
154
|
+
},
|
|
155
|
+
...more
|
|
156
|
+
});
|
|
157
|
+
var title = (id = "title") => ({ id, kind: "title", used: 0, fixed: true, forms: { row: [form("row", 80, 160, 32, { grows: true })] } });
|
|
158
|
+
var controls = (id = "controls") => ({ id, kind: "controls", used: 0, fixed: true, align: "end", forms: { row: [form("row", 84, 84, 32)] } });
|
|
159
|
+
var readout = (id = "readout") => ({ id, kind: "readout", used: 0, fixed: true, align: "center", forms: { row: [form("row", 72, 72, 28)] } });
|
|
160
|
+
var bar = (id, side, ring, items, more = {}) => ({
|
|
161
|
+
id,
|
|
162
|
+
side,
|
|
163
|
+
ring,
|
|
164
|
+
accepts: ["group"],
|
|
165
|
+
items,
|
|
166
|
+
cross: { min: 36, max: 36, rail: 36 },
|
|
167
|
+
gap: 4,
|
|
168
|
+
pad: { start: 8, end: 8 },
|
|
169
|
+
...more
|
|
170
|
+
});
|
|
171
|
+
var column = (id, side, ring, items, more = {}) => ({
|
|
172
|
+
id,
|
|
173
|
+
side,
|
|
174
|
+
ring,
|
|
175
|
+
accepts: ["panel", "group"],
|
|
176
|
+
items,
|
|
177
|
+
cross: { min: 160, max: 480, rail: 30 },
|
|
178
|
+
...more
|
|
179
|
+
});
|
|
180
|
+
var byId = (items) => Object.fromEntries(items.map((it) => [it.id, it]));
|
|
181
|
+
function doc(o = {}) {
|
|
182
|
+
return {
|
|
183
|
+
stage: { x: 0, y: 0, width: o.width ?? 1200, height: o.height ?? 800 },
|
|
184
|
+
edges: [
|
|
185
|
+
{ id: "titlebar", side: "top", ring: 0, accepts: ["group"], items: ["title", "controls"], cross: { min: 32, max: 32, rail: 32 } },
|
|
186
|
+
bar("toolbar", "top", 1, ["views", "tools", "zoom"]),
|
|
187
|
+
bar("status", "bottom", 0, ["readout", "search"], { span: "between", cross: { min: 28, max: 28, rail: 28 } }),
|
|
188
|
+
column("left", "left", 0, ["pages"]),
|
|
189
|
+
column("right", "right", 0, ["findings", "marks"])
|
|
190
|
+
],
|
|
191
|
+
items: byId([
|
|
192
|
+
title(),
|
|
193
|
+
controls(),
|
|
194
|
+
readout(),
|
|
195
|
+
panel("pages", 1),
|
|
196
|
+
panel("findings", 2),
|
|
197
|
+
panel("notes", 3),
|
|
198
|
+
group("views", 4),
|
|
199
|
+
group("tools", 5),
|
|
200
|
+
group("zoom", 6, { align: "end" }),
|
|
201
|
+
group("search", 7, { align: "end" }),
|
|
202
|
+
group("marks", 8)
|
|
203
|
+
]),
|
|
204
|
+
floats: [{ id: "notes", rect: { x: 500, y: 200, width: 280, height: 320 } }],
|
|
205
|
+
floatKinds: ["panel", "group"]
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
function tweakEdge(state, id, patch) {
|
|
209
|
+
return { ...state, edges: state.edges.map((e) => e.id === id ? { ...e, ...patch } : e) };
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// src/testing/rows-docking.ts
|
|
213
|
+
var FINDINGS_FLOAT = { id: "findings", rect: { x: 440, y: 130, width: 220, height: 190 } };
|
|
214
|
+
var ANNOTATIONS_FLOAT = { id: "annotations", rect: { x: 420, y: 120, width: 240, height: 150 } };
|
|
215
|
+
var DOCKING_ROWS = [
|
|
216
|
+
// --- panels in a column ---------------------------------------------------------------------------------------------
|
|
217
|
+
{
|
|
218
|
+
id: "C6",
|
|
219
|
+
title: "A column taller than its content",
|
|
220
|
+
expect: "Groups and folded panels take only their own length; the rest of the column goes to the open panel.",
|
|
221
|
+
group: "panels",
|
|
222
|
+
state: bench({ column: ["views", "pages"], bar: ["tools", "zoom"], floats: [ANNOTATIONS_FLOAT, FINDINGS_FLOAT] }),
|
|
223
|
+
gestures: [],
|
|
224
|
+
expectLayout: {
|
|
225
|
+
items: { views: { formKind: "stacked", edge: "column", rect: r(0, 40, 84, 84) }, pages: { formKind: "open", rect: r(0, 124, 200, 376) } },
|
|
226
|
+
edges: { column: { cross: 200 } }
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
id: "C8",
|
|
231
|
+
title: "Independent panels",
|
|
232
|
+
expect: "Any combination of panels can be open: opening one never closes another.",
|
|
233
|
+
group: "panels",
|
|
234
|
+
state: bench({ column: ["pages", "annotations", "findings"], bar: ["views", "tools", "zoom"], floats: [] }, { from: { annotations: 1 } }),
|
|
235
|
+
gestures: [g.click("annotations")],
|
|
236
|
+
expectLayout: {
|
|
237
|
+
items: {
|
|
238
|
+
pages: { formKind: "open", rect: r(0, 40, 240, 153.33) },
|
|
239
|
+
annotations: { formKind: "open", rect: r(0, 193.33, 240, 132.89) },
|
|
240
|
+
findings: { formKind: "open", rect: r(0, 326.22, 240, 173.78) }
|
|
241
|
+
},
|
|
242
|
+
order: { column: ["pages", "annotations", "findings"] }
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
id: "C9",
|
|
247
|
+
title: "Give-way",
|
|
248
|
+
expect: "When the open panels don't fit their minimum heights, the one used longest ago folds to its header first.",
|
|
249
|
+
group: "panels",
|
|
250
|
+
state: bench({ column: ["pages", "annotations", "findings"], bar: ["views", "tools", "zoom"], floats: [] }, { height: 300, used: { annotations: 1, findings: 2, pages: 3 } }),
|
|
251
|
+
gestures: [],
|
|
252
|
+
expectLayout: {
|
|
253
|
+
items: { pages: { formKind: "open", rect: r(0, 40, 220, 111.43) }, annotations: { formKind: "header", rect: r(0, 151.43, 220, 30) }, findings: { formKind: "open", rect: r(0, 181.43, 220, 118.57) } },
|
|
254
|
+
notes: { has: ["form-down"] }
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
id: "C9b",
|
|
259
|
+
title: "Give-way, then the next oldest",
|
|
260
|
+
expect: "Shorter still, the next oldest (Findings) folds before the newest (Pages); a rail icon only comes after the header.",
|
|
261
|
+
group: "panels",
|
|
262
|
+
state: bench({ column: ["pages", "annotations", "findings"], bar: ["views", "tools", "zoom"], floats: [] }, { height: 300, used: { annotations: 1, findings: 2, pages: 3 } }),
|
|
263
|
+
gestures: [g.resizeWindow(840, 240)],
|
|
264
|
+
expectLayout: {
|
|
265
|
+
items: { pages: { formKind: "open", rect: r(0, 40, 200, 144) }, annotations: { formKind: "rail", rect: r(0, 184, 200, 26) }, findings: { formKind: "header", rect: r(0, 210, 200, 30) } }
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
id: "C18",
|
|
270
|
+
title: "A rail icon opens on click",
|
|
271
|
+
expect: "A click on a panel's rail icon opens that panel; a click is never a drag.",
|
|
272
|
+
group: "panels",
|
|
273
|
+
state: bench({ column: ["pages", "annotations"], bar: ["views", "tools", "zoom"], floats: [FINDINGS_FLOAT] }, { from: { pages: 2 } }),
|
|
274
|
+
gestures: [g.click("pages")],
|
|
275
|
+
expectLayout: {
|
|
276
|
+
items: { pages: { formKind: "open", rect: r(0, 40, 240, 246.43) }, annotations: { formKind: "open", rect: r(0, 286.43, 240, 213.57) } }
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
id: "C23",
|
|
281
|
+
title: "A press is not a reshape",
|
|
282
|
+
expect: "A press on a grip or a header, with no drag and nothing opened, never changes another item's form or rect.",
|
|
283
|
+
group: "panels",
|
|
284
|
+
state: bench({ column: ["pages", "annotations", "findings"], bar: ["views", "tools", "zoom"], floats: [] }, { height: 300 }),
|
|
285
|
+
gestures: [
|
|
286
|
+
g.press("pages"),
|
|
287
|
+
g.release(),
|
|
288
|
+
g.press("annotations"),
|
|
289
|
+
g.release(),
|
|
290
|
+
g.press("findings"),
|
|
291
|
+
g.release(),
|
|
292
|
+
g.press("views"),
|
|
293
|
+
g.release(),
|
|
294
|
+
g.press("tools"),
|
|
295
|
+
g.release(),
|
|
296
|
+
g.press("zoom"),
|
|
297
|
+
g.release()
|
|
298
|
+
],
|
|
299
|
+
expectLayout: {
|
|
300
|
+
items: {
|
|
301
|
+
pages: { formKind: "header", rect: r(0, 40, 240, 30) },
|
|
302
|
+
annotations: { formKind: "open", rect: r(0, 70, 240, 106.67) },
|
|
303
|
+
findings: { formKind: "open", rect: r(0, 176.67, 240, 123.33) },
|
|
304
|
+
views: { formKind: "row", rect: r(12, 0, 244, 40) },
|
|
305
|
+
tools: { formKind: "row", rect: r(264, 0, 244, 40) },
|
|
306
|
+
zoom: { formKind: "row", rect: r(516, 0, 244, 40) }
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
id: "C23b",
|
|
312
|
+
title: "A press is no use, by the stored ages",
|
|
313
|
+
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.",
|
|
314
|
+
group: "panels",
|
|
315
|
+
state: bench({ column: ["pages", "annotations", "findings"], bar: ["views", "tools", "zoom"], floats: [] }, { height: 300 }),
|
|
316
|
+
gestures: [g.press("pages"), g.release(), g.key("Reload")],
|
|
317
|
+
expectLayout: {
|
|
318
|
+
items: {
|
|
319
|
+
pages: { formKind: "header", rect: r(0, 40, 240, 30) },
|
|
320
|
+
annotations: { formKind: "open", rect: r(0, 70, 240, 106.67) },
|
|
321
|
+
findings: { formKind: "open", rect: r(0, 176.67, 240, 123.33) }
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
expectStored: { items: { pages: { used: 1 }, annotations: { used: 2 }, findings: { used: 3 } } }
|
|
325
|
+
},
|
|
326
|
+
// --- groups and toolbars --------------------------------------------------------------------------------------------
|
|
327
|
+
{
|
|
328
|
+
id: "C2",
|
|
329
|
+
title: "A group alone in a column",
|
|
330
|
+
expect: "A group never sets the column's width: alone, the column is a rail of about 30 px with the group as icons.",
|
|
331
|
+
group: "groups",
|
|
332
|
+
state: bench({ column: ["views"], bar: ["tools", "zoom", "pages"], floats: [ANNOTATIONS_FLOAT, FINDINGS_FLOAT] }),
|
|
333
|
+
gestures: [],
|
|
334
|
+
expectLayout: { items: { views: { formKind: "icons", edge: "column", rect: r(0, 40, 28, 96) }, pages: { formKind: "header", edge: "bar" } }, edges: { column: { cross: 30 } } }
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
id: "C10",
|
|
338
|
+
title: "Group forms by space",
|
|
339
|
+
expect: "A group takes the largest form that fits its column: words in a row, stacked words, icons.",
|
|
340
|
+
group: "groups",
|
|
341
|
+
state: bench({ column: ["pages", "views", "tools"], bar: ["zoom"], floats: [ANNOTATIONS_FLOAT, FINDINGS_FLOAT] }, { widthLimit: 140 }),
|
|
342
|
+
gestures: [],
|
|
343
|
+
expectLayout: {
|
|
344
|
+
items: { pages: { formKind: "open", rect: r(0, 40, 140, 292) }, views: { formKind: "stacked", rect: r(0, 332, 84, 84) }, tools: { formKind: "stacked", rect: r(0, 416, 84, 84) } },
|
|
345
|
+
edges: { column: { cross: 140 } }
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
id: "C10b",
|
|
350
|
+
title: "Group forms by space, wide column",
|
|
351
|
+
expect: "In a column wide enough for its words, a group is a row of words, drawn at its own width.",
|
|
352
|
+
group: "groups",
|
|
353
|
+
state: bench({ column: ["pages", "views", "tools"], bar: ["zoom"], floats: [ANNOTATIONS_FLOAT, FINDINGS_FLOAT] }, { widthLimit: 360 }),
|
|
354
|
+
gestures: [g.resizeEdge("column", 300)],
|
|
355
|
+
expectLayout: {
|
|
356
|
+
items: { pages: { formKind: "open", rect: r(0, 40, 300, 400) }, views: { formKind: "row", rect: r(0, 440, 240, 30) }, tools: { formKind: "row", rect: r(0, 470, 240, 30) } },
|
|
357
|
+
edges: { column: { cross: 300 } }
|
|
358
|
+
}
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
id: "C11",
|
|
362
|
+
title: "Draggable groups",
|
|
363
|
+
expect: "Every control group, the zoom group too, can be lifted by its handle and dropped in the column.",
|
|
364
|
+
group: "groups",
|
|
365
|
+
state: bench(),
|
|
366
|
+
gestures: [...g.drag("zoom", g.gap("column", 2)), ...g.drag("views", g.gap("column", 0)), ...g.drag("tools", g.gap("column", 1))],
|
|
367
|
+
expectLayout: {
|
|
368
|
+
order: { column: ["views", "tools", "pages", "annotations", "zoom"], bar: [] },
|
|
369
|
+
items: { views: { formKind: "row", edge: "column", rect: r(0, 0, 240, 30) }, tools: { formKind: "row", rect: r(0, 30, 240, 30) }, zoom: { formKind: "row", rect: r(0, 470, 240, 30) } }
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
id: "C12",
|
|
374
|
+
title: "No grip where nothing moves",
|
|
375
|
+
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.",
|
|
376
|
+
group: "groups",
|
|
377
|
+
state: doc(),
|
|
378
|
+
gestures: [g.press("title"), g.at(300, 200), g.release(), g.press("controls"), g.at(300, 200), g.release()],
|
|
379
|
+
expectLayout: {
|
|
380
|
+
items: { title: { edge: "titlebar", rect: r(0, 0, 1116, 32) }, controls: { edge: "titlebar", rect: r(1116, 0, 84, 32) }, notes: { floating: true, rect: r(500, 200, 280, 320) } },
|
|
381
|
+
content: r(260, 68, 680, 704),
|
|
382
|
+
notes: { none: true }
|
|
383
|
+
}
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
id: "C19",
|
|
387
|
+
title: "A group in icon form keeps its grip",
|
|
388
|
+
expect: "A group drawn as icons still has a handle, and it drags by it.",
|
|
389
|
+
group: "groups",
|
|
390
|
+
state: bench({ column: ["views"], bar: ["tools", "zoom"], floats: [ANNOTATIONS_FLOAT, FINDINGS_FLOAT] }),
|
|
391
|
+
gestures: [g.press("views", { x: 4, y: 4 }), g.at(520, 260), g.release()],
|
|
392
|
+
expectLayout: { items: { views: { floating: true, edge: null, rect: r(516, 256, 244, 34) } }, order: { column: [] }, floats: ["annotations", "findings", "views"] }
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
id: "C21",
|
|
396
|
+
title: "The toolbar never grows tall",
|
|
397
|
+
expect: "The top bar is 40 px tall at most, whatever is in it: a panel there takes its header.",
|
|
398
|
+
group: "groups",
|
|
399
|
+
state: bench({ column: ["pages", "annotations"], bar: ["views", "tools", "findings"], floats: [] }),
|
|
400
|
+
gestures: [g.resizeItem("findings", 35)],
|
|
401
|
+
expectLayout: { items: { findings: { formKind: "header", edge: "bar", rect: r(516, 0, 145, 40) } }, edges: { bar: { cross: 40 } } }
|
|
402
|
+
},
|
|
403
|
+
// --- dragging -------------------------------------------------------------------------------------------------------
|
|
404
|
+
{
|
|
405
|
+
id: "C1",
|
|
406
|
+
title: "The drop preview is the rect it gets",
|
|
407
|
+
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.",
|
|
408
|
+
group: "drag",
|
|
409
|
+
state: bench(),
|
|
410
|
+
gestures: [g.press("annotations"), g.to(g.gap("column", 0)), g.hold(), g.release()],
|
|
411
|
+
checkpoints: [{ at: 2, layout: { items: { annotations: { formKind: "open", rect: r(0, 40, 240, 213.57) }, pages: { rect: r(0, 253.57, 240, 246.43) } }, order: { column: ["annotations", "pages"] } }, note: "the slot" }],
|
|
412
|
+
expectLayout: { items: { annotations: { formKind: "open", rect: r(0, 40, 240, 213.57) }, pages: { rect: r(0, 253.57, 240, 246.43) }, findings: { floating: true, rect: r(440, 130, 220, 190) } }, order: { column: ["annotations", "pages"] } },
|
|
413
|
+
expectDom: [
|
|
414
|
+
{ at: 2, attr: { "data-drag-session": "panel" }, note: "the root says a panel is dragged" },
|
|
415
|
+
{ 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" },
|
|
416
|
+
{ at: 2, select: "[data-drag-marker]", count: 1, note: "its insertion line" },
|
|
417
|
+
{ at: 2, select: "[data-drag-held]", count: 1, note: "the held item" },
|
|
418
|
+
{ at: 3, attr: { "data-drag-session": null }, note: "the session ends with the drop" },
|
|
419
|
+
{ at: 3, select: "[data-drag-slot]", count: 0, note: "no slot after the drop" }
|
|
420
|
+
]
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
id: "C3",
|
|
424
|
+
title: "Drop into any gap",
|
|
425
|
+
expect: "Every gap of a column opens a slot: above, between and below its panels and groups.",
|
|
426
|
+
group: "drag",
|
|
427
|
+
state: bench({ column: ["pages", "annotations", "views"], bar: ["tools", "zoom"], floats: [FINDINGS_FLOAT] }),
|
|
428
|
+
gestures: [
|
|
429
|
+
g.press("findings", { x: 20, y: 10 }),
|
|
430
|
+
g.to(g.gap("column", 0)),
|
|
431
|
+
g.hold(),
|
|
432
|
+
g.to(g.gap("column", 1)),
|
|
433
|
+
g.hold(),
|
|
434
|
+
g.to(g.gap("column", 2)),
|
|
435
|
+
g.hold(),
|
|
436
|
+
g.to(g.gap("column", 3)),
|
|
437
|
+
g.hold(),
|
|
438
|
+
g.escape()
|
|
439
|
+
],
|
|
440
|
+
checkpoints: [
|
|
441
|
+
{ at: 2, layout: { order: { column: ["findings", "pages", "annotations", "views"] }, items: { findings: { edge: "column", rect: r(0, 40, 240, 161.11) } } }, note: "above the first" },
|
|
442
|
+
{ at: 4, layout: { order: { column: ["pages", "findings", "annotations", "views"] }, items: { findings: { rect: r(0, 183.33, 240, 161.11) } } }, note: "between" },
|
|
443
|
+
{ at: 6, layout: { order: { column: ["pages", "annotations", "findings", "views"] }, items: { findings: { rect: r(0, 308.89, 240, 161.11) } } }, note: "between the last two" },
|
|
444
|
+
{ at: 8, layout: { order: { column: ["pages", "annotations", "views", "findings"] }, items: { findings: { rect: r(0, 338.89, 240, 161.11) } } }, note: "below the last" }
|
|
445
|
+
],
|
|
446
|
+
expectLayout: { order: { column: ["pages", "annotations", "views"] }, items: { findings: { floating: true, rect: r(440, 130, 220, 190) }, pages: { rect: r(0, 40, 240, 230.36) } } }
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
id: "C4",
|
|
450
|
+
title: "A group into the panel column",
|
|
451
|
+
expect: "A group dragged into the column opens a slot and takes the largest column form that fits.",
|
|
452
|
+
group: "drag",
|
|
453
|
+
state: bench(),
|
|
454
|
+
gestures: g.drag("views", g.gap("column", 2)),
|
|
455
|
+
expectLayout: { items: { views: { formKind: "row", edge: "column", rect: r(0, 470, 240, 30) } }, order: { column: ["pages", "annotations", "views"], bar: ["tools", "zoom"] } }
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
id: "C20",
|
|
459
|
+
title: "Back over its own place",
|
|
460
|
+
expect: "Dragged away and back over its own place, the item shows that place, and a release puts it back; nothing else moved.",
|
|
461
|
+
group: "drag",
|
|
462
|
+
state: bench(),
|
|
463
|
+
// Pressed 20 px in and 10 down; the float aimed at the content's center lands at the pointer minus that grab.
|
|
464
|
+
gestures: [g.press("pages", { x: 20, y: 10 }), g.to(g.float), g.hold(), g.to(g.home), g.hold(), g.release()],
|
|
465
|
+
checkpoints: [
|
|
466
|
+
{ at: 2, layout: { items: { pages: { floating: true, rect: r(520, 260, 200, 190) }, annotations: { formKind: "open", rect: r(0, 40, 240, 460) } } }, note: "away, over the pages" },
|
|
467
|
+
{ at: 4, layout: { items: { pages: { edge: "column", rect: r(0, 40, 240, 246.43) }, annotations: { rect: r(0, 286.43, 240, 213.57) } } }, note: "back over its own place: the old rect" }
|
|
468
|
+
],
|
|
469
|
+
expectLayout: { items: { pages: { edge: "column", floating: false, rect: r(0, 40, 240, 246.43) }, annotations: { rect: r(0, 286.43, 240, 213.57) }, findings: { floating: true, rect: r(440, 130, 220, 190) } }, order: { column: ["pages", "annotations"] } }
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
id: "C22",
|
|
473
|
+
title: "The whole preview",
|
|
474
|
+
expect: "While a drop is previewed, every other item, floats too, is drawn at its rect after the drop, not only the dropped one.",
|
|
475
|
+
group: "drag",
|
|
476
|
+
// Pages (200 wide) and Findings (220) make a 220 column, with the Views float just beside it. Annotations (240) widens
|
|
477
|
+
// the column to 240, so the float moves clear and Pages and Findings shrink: all of it is drawn before the release.
|
|
478
|
+
state: bench({ column: ["pages", "findings"], bar: ["tools", "zoom"], floats: [ANNOTATIONS_FLOAT, { id: "views", rect: { x: 222, y: 330, width: 244, height: 34 } }] }, { height: 400 }),
|
|
479
|
+
gestures: [g.press("annotations"), g.to(g.gap("column", 2)), g.hold(), g.release()],
|
|
480
|
+
checkpoints: [{ at: 2, layout: { items: { pages: { rect: r(0, 40, 240, 120) }, findings: { rect: r(0, 160, 240, 130) }, annotations: { edge: "column", rect: r(0, 290, 240, 110) }, views: { floating: true, rect: r(240, 330, 244, 34) } } }, note: "during the preview" }],
|
|
481
|
+
expectLayout: { items: { pages: { rect: r(0, 40, 240, 120) }, findings: { rect: r(0, 160, 240, 130) }, annotations: { edge: "column", rect: r(0, 290, 240, 110) }, views: { floating: true, rect: r(240, 330, 244, 34) } } }
|
|
482
|
+
},
|
|
483
|
+
// --- floats, saving, freeze -----------------------------------------------------------------------------------------
|
|
484
|
+
{
|
|
485
|
+
id: "C5",
|
|
486
|
+
title: "Floats stay put while the pages scroll",
|
|
487
|
+
expect: "A float lies above the pages in the window's px: scrolling the pages never moves it.",
|
|
488
|
+
group: "floats",
|
|
489
|
+
state: bench(),
|
|
490
|
+
gestures: [g.scroll(300)],
|
|
491
|
+
expectLayout: { items: { findings: { floating: true, rect: r(440, 130, 220, 190) } } },
|
|
492
|
+
// The layout alone can't tell a float that scrolled: only a page can, by measuring where the float is drawn.
|
|
493
|
+
expectDom: [{ item: "findings", count: 1, rect: r(440, 130, 220, 190), note: "the float is drawn where it was after the scroll" }]
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
id: "C7",
|
|
497
|
+
title: "A float over a docked panel",
|
|
498
|
+
expect: "A float never covers a docked item's content: dropped over one, it lands clear of it, and the preview says so. This assumes the default `hitBand` (an open panel's body is no drop place): a host whose columns use `hitBand: \"middle\"` gets card halves over the panel, and skips or marks this row.",
|
|
499
|
+
group: "floats",
|
|
500
|
+
requires: { hitBand: "default" },
|
|
501
|
+
state: bench(),
|
|
502
|
+
gestures: [g.press("findings", { x: 200, y: 10 }), g.at(260, 230), g.hold(), g.release()],
|
|
503
|
+
checkpoints: [{ at: 2, layout: { items: { findings: { floating: true, rect: r(240, 220, 220, 190) } } }, note: "the preview, clear of the column" }],
|
|
504
|
+
expectLayout: { items: { findings: { floating: true, rect: r(240, 220, 220, 190) }, pages: { rect: r(0, 40, 240, 246.43) } } }
|
|
505
|
+
},
|
|
506
|
+
{
|
|
507
|
+
id: "C13",
|
|
508
|
+
title: "A reload restores the layout",
|
|
509
|
+
expect: "A reload restores every item's place and form from the stored form.",
|
|
510
|
+
group: "floats",
|
|
511
|
+
state: 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"] }),
|
|
512
|
+
// Move a group into the column between the panels, fold the float to its bar, reload: everything comes back.
|
|
513
|
+
gestures: [...g.drag("tools", g.gap("column", 1)), g.click("findings", "fold"), g.key("Reload")],
|
|
514
|
+
checkpoints: [{ at: 4, layout: { items: { annotations: { formKind: "open", rect: r(0, 40, 240, 400) }, tools: { formKind: "row", edge: "column", rect: r(0, 440, 240, 30) }, pages: { formKind: "header", rect: r(0, 470, 240, 30) }, findings: { formKind: "header", floating: true, rect: r(520, 200, 220, 30) } }, order: { column: ["annotations", "tools", "pages"], bar: ["zoom", "views"] } }, note: "before the reload" }],
|
|
515
|
+
expectLayout: { items: { annotations: { formKind: "open", rect: r(0, 40, 240, 400) }, tools: { formKind: "row", edge: "column", rect: r(0, 440, 240, 30) }, pages: { formKind: "header", rect: r(0, 470, 240, 30) }, findings: { formKind: "header", floating: true, rect: r(520, 200, 220, 30) } }, order: { column: ["annotations", "tools", "pages"], bar: ["zoom", "views"] } }
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
id: "C14",
|
|
519
|
+
title: "Frozen",
|
|
520
|
+
expect: "Frozen, nothing lifts; holding Alt lets everything move.",
|
|
521
|
+
group: "floats",
|
|
522
|
+
state: bench(),
|
|
523
|
+
settings: { frozen: true },
|
|
524
|
+
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")],
|
|
525
|
+
checkpoints: [{ at: 2, layout: { items: { pages: { edge: "column", rect: r(0, 40, 240, 246.43) }, annotations: { rect: r(0, 286.43, 240, 213.57) } } }, note: "frozen: nothing moved" }],
|
|
526
|
+
expectLayout: { items: { pages: { floating: true, rect: r(520, 260, 200, 190) }, annotations: { rect: r(0, 40, 240, 460) } } }
|
|
527
|
+
},
|
|
528
|
+
{
|
|
529
|
+
id: "C14b",
|
|
530
|
+
title: "Frozen refuses the menu's moves too",
|
|
531
|
+
expect: "Frozen, the menu's Float, Dock and Move to \u203A change nothing either; with Alt down they work.",
|
|
532
|
+
group: "floats",
|
|
533
|
+
state: bench(),
|
|
534
|
+
settings: { frozen: true },
|
|
535
|
+
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")],
|
|
536
|
+
checkpoints: [{ at: 2, layout: { items: { pages: { edge: "column", floating: false, rect: r(0, 40, 240, 246.43) }, annotations: { rect: r(0, 286.43, 240, 213.57) } } }, note: "frozen: nothing moved" }],
|
|
537
|
+
// The menu's Float anchors it to the content's top-right corner; the float already there wins, so it lies beside it.
|
|
538
|
+
expectLayout: { items: { pages: { floating: true, rect: r(240, 40, 200, 190) }, annotations: { rect: r(0, 40, 240, 460) } } }
|
|
539
|
+
},
|
|
540
|
+
{
|
|
541
|
+
id: "C15",
|
|
542
|
+
title: "No jump",
|
|
543
|
+
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.",
|
|
544
|
+
group: "floats",
|
|
545
|
+
state: bench(),
|
|
546
|
+
gestures: [g.resizeItem("zoom", 35), g.resizeItem("findings", 35)],
|
|
547
|
+
expectLayout: {
|
|
548
|
+
items: {
|
|
549
|
+
views: { rect: r(12, 0, 244, 40) },
|
|
550
|
+
tools: { rect: r(264, 0, 244, 40) },
|
|
551
|
+
zoom: { rect: r(516, 0, 279, 40) },
|
|
552
|
+
pages: { rect: r(0, 40, 240, 246.43) },
|
|
553
|
+
annotations: { rect: r(0, 286.43, 240, 213.57) },
|
|
554
|
+
findings: { floating: true, rect: r(440, 130, 220, 190) }
|
|
555
|
+
},
|
|
556
|
+
content: r(240, 40, 600, 460)
|
|
557
|
+
}
|
|
558
|
+
},
|
|
559
|
+
{
|
|
560
|
+
id: "C16",
|
|
561
|
+
title: "A float has no pin",
|
|
562
|
+
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.",
|
|
563
|
+
group: "floats",
|
|
564
|
+
state: bench(),
|
|
565
|
+
gestures: [g.key("Reload")],
|
|
566
|
+
expectLayout: { items: { findings: { floating: true, rect: r(440, 130, 220, 190) }, pages: { rect: r(0, 40, 240, 246.43) } }, floats: ["findings"] },
|
|
567
|
+
expectStored: { absent: ["pinned"] }
|
|
568
|
+
},
|
|
569
|
+
{
|
|
570
|
+
id: "C17",
|
|
571
|
+
title: "A drop past the stage's edge",
|
|
572
|
+
expect: "A float dropped with the pointer past the stage's edge: the pointer is clamped into the stage first (the host contract; the runner clamps every `move` to a point), and the clamped point, on the window's edge, picks only a target drawn against that edge. Outside the window is no drawn space: the float and every refusal hold only points strictly inside it. Nothing is docked at this stage's right edge, so nothing is picked: the preview leaves the held float's place empty and the drop commits nothing, the float back where it was. A window with a docked edge there picks that edge's last gap instead.",
|
|
573
|
+
group: "floats",
|
|
574
|
+
state: bench(),
|
|
575
|
+
requires: { railDrop: "state" },
|
|
576
|
+
gestures: [g.press("findings", { x: 40, y: 10 }), g.at(920, 240), g.hold(), g.release()],
|
|
577
|
+
checkpoints: [{ at: 2, layout: { items: { findings: null } }, note: "no target past the edge: the held float out of the layout" }],
|
|
578
|
+
expectLayout: { items: { findings: { floating: true, rect: r(440, 130, 220, 190) } } }
|
|
579
|
+
}
|
|
580
|
+
];
|
|
581
|
+
|
|
582
|
+
// src/testing/rows-bars.ts
|
|
583
|
+
import { rect as r2 } from "@n-uf/placement";
|
|
584
|
+
var NO_FLOATS = { column: [], bar: ["views", "tools", "zoom"], floats: [] };
|
|
585
|
+
function tiny(width, items, menu = 28) {
|
|
586
|
+
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 } };
|
|
587
|
+
return { stage: { x: 0, y: 0, width, height: 100 }, edges: [edge], items: Object.fromEntries(items.map((i) => [i.id, i])), floats: [], floatKinds: [] };
|
|
588
|
+
}
|
|
589
|
+
var row = (id, used, forms) => ({ id, kind: "group", used, forms: { row: forms } });
|
|
590
|
+
var f = (kind, main) => form(kind, main, main, 28);
|
|
591
|
+
var BAR_ROWS = [
|
|
592
|
+
{
|
|
593
|
+
id: "T1",
|
|
594
|
+
title: "A \xBB per folded group, in line",
|
|
595
|
+
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.",
|
|
596
|
+
group: "bars",
|
|
597
|
+
state: bench(NO_FLOATS),
|
|
598
|
+
gestures: [g.resizeWindow(640, 500), g.resizeWindow(160, 500), g.resizeWindow(150, 500)],
|
|
599
|
+
checkpoints: [
|
|
600
|
+
{ at: 0, layout: { items: { views: { formKind: "fold", rect: r2(12, 0, 40, 40) }, tools: { formKind: "row", rect: r2(60, 0, 244, 40) }, zoom: { formKind: "row", rect: r2(312, 0, 244, 40) } }, edges: { bar: { menu: null } } }, note: "640: Views folds where it stands, no shared entry" },
|
|
601
|
+
{ at: 1, layout: { items: { views: { formKind: "fold", rect: r2(12, 0, 40, 40) }, tools: { formKind: "fold", rect: r2(60, 0, 40, 40) }, zoom: { formKind: "fold", rect: r2(108, 0, 40, 40) } }, edges: { bar: { menu: null } } }, note: "160: every group folded in line, still no shared entry" }
|
|
602
|
+
],
|
|
603
|
+
expectLayout: { items: { views: { inMenu: true }, tools: { formKind: "fold", rect: r2(12, 0, 40, 40) }, zoom: { formKind: "fold", rect: r2(60, 0, 40, 40) } }, edges: { bar: { menu: ["views"] } } }
|
|
604
|
+
},
|
|
605
|
+
{
|
|
606
|
+
id: "T2-T4",
|
|
607
|
+
title: "A step goes only to a shorter form",
|
|
608
|
+
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.",
|
|
609
|
+
group: "bars",
|
|
610
|
+
state: bench(NO_FLOATS, { used: { zoom: 1 } }),
|
|
611
|
+
gestures: [g.resizeWindow(700, 500), g.resizeWindow(500, 500), g.resizeWindow(360, 500), g.resizeWindow(840, 500)],
|
|
612
|
+
checkpoints: [
|
|
613
|
+
{ at: 0, layout: { items: { views: { formKind: "row" }, tools: { formKind: "row" }, zoom: { formKind: "fold", rect: r2(516, 0, 40, 40) } } }, note: "700: Zoom's row straight to its fold, not stacked" },
|
|
614
|
+
{ at: 1, layout: { items: { views: { formKind: "fold" }, tools: { formKind: "row" }, zoom: { formKind: "fold", rect: r2(312, 0, 40, 40) } } }, note: "500" },
|
|
615
|
+
{ at: 2, layout: { items: { views: { formKind: "fold" }, tools: { formKind: "icons" }, zoom: { formKind: "fold" } } }, note: "360" }
|
|
616
|
+
],
|
|
617
|
+
expectLayout: { items: { views: { formKind: "row", rect: r2(12, 0, 244, 40) }, tools: { formKind: "row", rect: r2(264, 0, 244, 40) }, zoom: { formKind: "row", rect: r2(516, 0, 244, 40) } } }
|
|
618
|
+
},
|
|
619
|
+
{
|
|
620
|
+
id: "T3",
|
|
621
|
+
title: "The ranked primary gives way last",
|
|
622
|
+
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.",
|
|
623
|
+
group: "bars",
|
|
624
|
+
state: bench(NO_FLOATS, { used: { tools: 0 } }),
|
|
625
|
+
gestures: [g.resizeWindow(770, 500), g.resizeWindow(620, 500), g.resizeWindow(410, 500), g.resizeWindow(220, 500), g.resizeWindow(200, 500)],
|
|
626
|
+
checkpoints: [
|
|
627
|
+
{ at: 0, layout: { items: { views: { formKind: "row" }, tools: { formKind: "icons", rect: r2(264, 0, 94, 40) }, zoom: { formKind: "row" } } }, note: "770: Tools goes to its icons first" },
|
|
628
|
+
{ at: 1, layout: { items: { views: { formKind: "fold" }, tools: { formKind: "icons" }, zoom: { formKind: "row" } } }, note: "620: Views folds, Tools keeps its icons" },
|
|
629
|
+
{ at: 2, layout: { items: { views: { formKind: "fold" }, tools: { formKind: "icons" }, zoom: { formKind: "fold" } } }, note: "410: Zoom folds too, Tools still icons" },
|
|
630
|
+
{ at: 3, layout: { items: { views: { formKind: "fold" }, tools: { formKind: "icons" }, zoom: { formKind: "fold" } } }, note: "220: still icons" }
|
|
631
|
+
],
|
|
632
|
+
expectLayout: { items: { views: { formKind: "fold", rect: r2(12, 0, 40, 40) }, tools: { formKind: "fold", rect: r2(60, 0, 40, 40) }, zoom: { formKind: "fold", rect: r2(108, 0, 40, 40) } }, edges: { bar: { menu: null } } }
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
id: "T5",
|
|
636
|
+
title: "Gaps and padding are real",
|
|
637
|
+
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.",
|
|
638
|
+
group: "bars",
|
|
639
|
+
state: bench(NO_FLOATS, { gap: 14, pad: 20 }),
|
|
640
|
+
gestures: [g.press("views"), g.at(846, 20), g.hold(), g.release()],
|
|
641
|
+
checkpoints: [{ at: 2, layout: { items: { views: { edge: "bar", rect: r2(576, 0, 244, 40) } }, order: { bar: ["tools", "zoom", "views"] } }, note: "the end gap, past the bar's end" }],
|
|
642
|
+
expectLayout: { items: { tools: { rect: r2(20, 0, 244, 40) }, zoom: { rect: r2(278, 0, 244, 40) }, views: { rect: r2(576, 0, 244, 40) } }, order: { bar: ["tools", "zoom", "views"] } }
|
|
643
|
+
},
|
|
644
|
+
{
|
|
645
|
+
id: "T6",
|
|
646
|
+
title: "A panel dropped into the bar lands as a header",
|
|
647
|
+
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.",
|
|
648
|
+
group: "bars",
|
|
649
|
+
state: bench({ column: ["pages", "annotations"], bar: ["views", "zoom"], floats: [{ id: "findings", rect: { x: 440, y: 130, width: 220, height: 190 } }] }),
|
|
650
|
+
gestures: [g.press("findings"), g.to(g.gap("bar", 2)), g.hold(), g.release()],
|
|
651
|
+
checkpoints: [{ at: 2, layout: { items: { findings: { formKind: "header", edge: "bar", rect: r2(516, 0, 110, 40) } }, edges: { bar: { cross: 40 } } }, note: "the slot is header-sized" }],
|
|
652
|
+
expectLayout: { items: { findings: { formKind: "header", edge: "bar", floating: false, rect: r2(516, 0, 110, 40) } }, edges: { bar: { cross: 40 } }, order: { bar: ["views", "zoom", "findings"] } }
|
|
653
|
+
},
|
|
654
|
+
// --- what `previous` keeps ------------------------------------------------------------------------------------------
|
|
655
|
+
{
|
|
656
|
+
id: "N1",
|
|
657
|
+
title: "A count gaining a digit reshapes nothing else",
|
|
658
|
+
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.",
|
|
659
|
+
group: "previous",
|
|
660
|
+
state: bench(NO_FLOATS, { width: 760 }),
|
|
661
|
+
gestures: [g.click("tools", "use"), g.click("zoom", "use"), g.click("views", "use"), g.resizeItem("tools", 35)],
|
|
662
|
+
expectLayout: { items: { views: { formKind: "fold", rect: r2(12, 0, 40, 40) }, tools: { formKind: "row", rect: r2(60, 0, 279, 40) }, zoom: { formKind: "row", rect: r2(347, 0, 244, 40) } }, edges: { bar: { menu: null } } }
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
id: "N2",
|
|
666
|
+
title: "A count losing a digit reshapes nothing else",
|
|
667
|
+
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.",
|
|
668
|
+
group: "previous",
|
|
669
|
+
state: bench(NO_FLOATS, { width: 764 }),
|
|
670
|
+
gestures: [g.click("tools", "use"), g.click("zoom", "use"), g.click("views", "use"), g.resizeItem("tools", -7)],
|
|
671
|
+
expectLayout: { items: { views: { formKind: "fold", rect: r2(12, 0, 40, 40) }, tools: { formKind: "row", rect: r2(60, 0, 237, 40) }, zoom: { formKind: "row", rect: r2(305, 0, 244, 40) } }, edges: { bar: { menu: null } } }
|
|
672
|
+
},
|
|
673
|
+
{
|
|
674
|
+
id: "G1",
|
|
675
|
+
title: "Items leave the menu when their form is larger",
|
|
676
|
+
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.",
|
|
677
|
+
group: "previous",
|
|
678
|
+
state: 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)])]),
|
|
679
|
+
gestures: [g.click("c", "use"), g.resizeWindow(139, 100), g.resizeWindow(141, 100), g.resizeWindow(150, 100), g.resizeWindow(175, 100)],
|
|
680
|
+
checkpoints: [
|
|
681
|
+
{ at: 0, layout: { items: { a: { inMenu: true }, b: { inMenu: true }, c: { formKind: "row", rect: r2(0, 0, 100, 28) } }, edges: { tbar: { menu: ["a", "b"] } } }, note: "128, after a use of c: a and b in the menu" },
|
|
682
|
+
{ 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" },
|
|
683
|
+
{ at: 2, layout: { items: { a: { formKind: "icons", rect: r2(0, 0, 20, 28) }, b: { formKind: "icons", rect: r2(20, 0, 20, 28) }, c: { formKind: "row", rect: r2(40, 0, 100, 28) } }, edges: { tbar: { menu: null } } }, note: "141: both come out together" }
|
|
684
|
+
],
|
|
685
|
+
expectLayout: { items: { a: { formKind: "icons", inMenu: false }, b: { formKind: "icons", inMenu: false }, c: { formKind: "row" } }, edges: { tbar: { menu: null } } }
|
|
686
|
+
},
|
|
687
|
+
{
|
|
688
|
+
id: "G2",
|
|
689
|
+
title: "Room comes back in the reverse of give-way order",
|
|
690
|
+
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.",
|
|
691
|
+
group: "previous",
|
|
692
|
+
state: tiny(60, [row("a", 2, [f("row", 100), f("fold", 30)]), row("b", 1, [f("row", 50), f("fold", 30)])]),
|
|
693
|
+
gestures: [g.resizeWindow(90, 100), g.resizeWindow(129, 100), g.resizeWindow(130, 100), g.resizeWindow(149, 100), g.resizeWindow(150, 100)],
|
|
694
|
+
checkpoints: [
|
|
695
|
+
{ at: 0, layout: { items: { a: { formKind: "fold" }, b: { formKind: "fold" } } }, note: "90: both stay folded" },
|
|
696
|
+
{ at: 1, layout: { items: { a: { formKind: "fold" }, b: { formKind: "fold" } } }, note: "129" },
|
|
697
|
+
{ at: 2, layout: { items: { a: { formKind: "row", rect: r2(0, 0, 100, 28) }, b: { formKind: "fold", rect: r2(100, 0, 30, 28) } } }, note: "130: A opens first" },
|
|
698
|
+
{ at: 3, layout: { items: { a: { formKind: "row" }, b: { formKind: "fold" } } }, note: "149: B still folded" }
|
|
699
|
+
],
|
|
700
|
+
expectLayout: { items: { a: { formKind: "row", rect: r2(0, 0, 100, 28) }, b: { formKind: "row", rect: r2(100, 0, 50, 28) } } }
|
|
701
|
+
},
|
|
702
|
+
{
|
|
703
|
+
id: "G2b",
|
|
704
|
+
title: "A group that went into the menu stays there",
|
|
705
|
+
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.",
|
|
706
|
+
group: "previous",
|
|
707
|
+
state: tiny(60, [row("a", 2, [f("row", 100), f("fold", 30)]), row("b", 1, [f("row", 50), f("menu", 0)])], 30),
|
|
708
|
+
gestures: [g.resizeWindow(80, 100), g.resizeWindow(129, 100), g.resizeWindow(130, 100)],
|
|
709
|
+
checkpoints: [
|
|
710
|
+
{ at: 0, layout: { items: { a: { formKind: "fold" }, b: { inMenu: true } }, edges: { tbar: { menu: ["b"] } } }, note: "80" },
|
|
711
|
+
{ at: 1, layout: { items: { a: { formKind: "fold" }, b: { inMenu: true } }, edges: { tbar: { menu: ["b"] } } }, note: "129" }
|
|
712
|
+
],
|
|
713
|
+
expectLayout: { items: { a: { formKind: "row", rect: r2(0, 0, 100, 28) }, b: { inMenu: true } }, edges: { tbar: { menu: ["b"] } } }
|
|
714
|
+
}
|
|
715
|
+
];
|
|
716
|
+
|
|
717
|
+
// src/testing/rows-rules.ts
|
|
718
|
+
import { rect as r3 } from "@n-uf/placement";
|
|
719
|
+
var zoomAwayStops = (endGaps) => [
|
|
720
|
+
g.gap("left", 0),
|
|
721
|
+
g.gap("left", 1),
|
|
722
|
+
g.gap("titlebar", 1),
|
|
723
|
+
g.gap("titlebar", 0, "center"),
|
|
724
|
+
...endGaps.map((at2) => g.gap("titlebar", at2, "end")),
|
|
725
|
+
g.gap("toolbar", 0),
|
|
726
|
+
g.gap("toolbar", 1),
|
|
727
|
+
g.gap("toolbar", 0, "center"),
|
|
728
|
+
g.gap("toolbar", 0, "end"),
|
|
729
|
+
g.gap("status", 0),
|
|
730
|
+
g.gap("right", 0),
|
|
731
|
+
g.gap("right", 1),
|
|
732
|
+
g.gap("right", 2),
|
|
733
|
+
g.float
|
|
734
|
+
];
|
|
735
|
+
var panelsOnly = () => tweakEdge({ ...doc(), floatKinds: ["panel"] }, "left", { accepts: ["panel"] });
|
|
736
|
+
var trayColumn = () => tweakEdge({ ...doc(), floatKinds: ["panel"] }, "left", { zoneAccepts: { start: ["panel"], end: ["group"] } });
|
|
737
|
+
function titleEnd(end, pushable = false) {
|
|
738
|
+
const s = tweakEdge(tweakEdge(doc(), "titlebar", { items: ["title", ...end] }), "toolbar", { items: ["views", "tools"] });
|
|
739
|
+
const readout2 = (id, w) => ({ id, kind: "readout", used: 0, fixed: true, align: "end", ...pushable ? { pushable: true } : {}, forms: { row: [form("row", w, w, 28)] } });
|
|
740
|
+
return { ...s, items: { ...s.items, state: readout2("state", 96), page: readout2("page", 42) } };
|
|
741
|
+
}
|
|
742
|
+
function barZones() {
|
|
743
|
+
const s = tweakEdge(doc(), "toolbar", { items: ["views", "zoom"] });
|
|
744
|
+
return { ...s, floats: [...s.floats, { id: "tools", rect: r3(500, 300, 200, 28) }] };
|
|
745
|
+
}
|
|
746
|
+
var RULE_ROWS = [
|
|
747
|
+
{
|
|
748
|
+
id: "C24",
|
|
749
|
+
title: "Drag isolation",
|
|
750
|
+
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.",
|
|
751
|
+
group: "kinds",
|
|
752
|
+
state: doc(),
|
|
753
|
+
gestures: [g.press("pages"), g.to(g.gap("right", 2)), g.hold(), g.release()],
|
|
754
|
+
checkpoints: [{ at: 2, layout: { items: { findings: { rect: r3(940, 68, 260, 318) }, marks: { rect: r3(940, 386, 84, 96) }, pages: { edge: "right", rect: r3(940, 482, 260, 318) } }, order: { right: ["findings", "marks", "pages"] } }, note: "the slot" }],
|
|
755
|
+
expectLayout: { items: { findings: { rect: r3(940, 68, 260, 318) }, marks: { rect: r3(940, 386, 84, 96) }, pages: { edge: "right", rect: r3(940, 482, 260, 318) } }, order: { right: ["findings", "marks", "pages"] } },
|
|
756
|
+
expectDom: [
|
|
757
|
+
{ at: 2, attr: { "data-drag-session": "panel" }, note: "the root carries the session while held" },
|
|
758
|
+
{ 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" },
|
|
759
|
+
{ at: 3, attr: { "data-drag-session": null }, note: "gone after the drop" },
|
|
760
|
+
{ at: 3, select: "[data-drag-target]", count: 0, note: "no target mark after the drop" }
|
|
761
|
+
]
|
|
762
|
+
},
|
|
763
|
+
{
|
|
764
|
+
id: "C25",
|
|
765
|
+
title: "Targets by kind: a panel in a toolbar",
|
|
766
|
+
expect: `An edge takes only the kinds it lists: a panel held over the toolbar is offered no gap there and no float either: the toolbar refuses it ("Can't go here" at the pointer, nothing drawn on the bar), and a release there puts it back, the toolbar as it was.`,
|
|
767
|
+
group: "kinds",
|
|
768
|
+
state: doc(),
|
|
769
|
+
// (600, 50) is a real gap for a group (the toolbar's center gap): the control row below lets a group go there.
|
|
770
|
+
gestures: [g.press("pages", { x: 20, y: 10 }), g.at(600, 50), g.hold(), g.release()],
|
|
771
|
+
checkpoints: [{ at: 2, layout: { items: { pages: null, views: { rect: r3(8, 32, 200, 36) }, tools: { rect: r3(212, 32, 200, 36) }, zoom: { rect: r3(992, 32, 200, 36) } }, order: { toolbar: ["views", "tools", "zoom"] } }, note: "refused: no target, the held item out of the layout" }],
|
|
772
|
+
expectLayout: { items: { pages: { edge: "left", floating: false }, views: { rect: r3(8, 32, 200, 36) }, tools: { rect: r3(212, 32, 200, 36) }, zoom: { rect: r3(992, 32, 200, 36) } }, order: { toolbar: ["views", "tools", "zoom"], left: ["pages"] } },
|
|
773
|
+
expectDom: [
|
|
774
|
+
{ at: 2, select: "[data-drag-refusal]", count: 1, attr: { "data-drag-refusal": "refuse:toolbar:start" }, note: "the toolbar's one refusal shows where the pointer is" },
|
|
775
|
+
{ at: 2, select: "[data-drag-slot]", count: 0, note: "no slot anywhere" }
|
|
776
|
+
]
|
|
777
|
+
},
|
|
778
|
+
{
|
|
779
|
+
id: "C25-control-bar",
|
|
780
|
+
title: "Targets by kind: the toolbar's gap is real for a group",
|
|
781
|
+
expect: "The same point, with a group held, is the toolbar's center gap: Tools lands in the toolbar's center zone. So the panel's refusal above is the kind's, not an empty spot's.",
|
|
782
|
+
group: "kinds",
|
|
783
|
+
state: doc(),
|
|
784
|
+
gestures: [g.press("tools"), g.at(600, 50), g.hold(), g.release()],
|
|
785
|
+
expectLayout: { items: { tools: { edge: "toolbar", zone: "center" } }, order: { toolbar: ["views", "tools", "zoom"] } }
|
|
786
|
+
},
|
|
787
|
+
{
|
|
788
|
+
id: "C25b",
|
|
789
|
+
title: "Targets by kind: a group in a panel-only column",
|
|
790
|
+
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.",
|
|
791
|
+
group: "kinds",
|
|
792
|
+
state: panelsOnly(),
|
|
793
|
+
gestures: [g.press("tools"), g.at(130, 76), g.hold()],
|
|
794
|
+
expectLayout: { items: { tools: null, pages: { rect: r3(0, 68, 260, 732) }, views: { rect: r3(8, 32, 200, 36) }, zoom: { rect: r3(992, 32, 200, 36) } }, order: { left: ["pages"] } },
|
|
795
|
+
expectDom: [{ select: "[data-drag-slot]", count: 0, note: "no slot where the group can't land" }]
|
|
796
|
+
},
|
|
797
|
+
{
|
|
798
|
+
id: "C25b-control-column",
|
|
799
|
+
title: "Targets by kind: the column's gap is real for a panel",
|
|
800
|
+
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.",
|
|
801
|
+
group: "kinds",
|
|
802
|
+
state: panelsOnly(),
|
|
803
|
+
gestures: [g.press("findings"), g.at(130, 76), g.hold(), g.release()],
|
|
804
|
+
expectLayout: { items: { findings: { edge: "left" } }, order: { left: ["findings", "pages"] } }
|
|
805
|
+
},
|
|
806
|
+
{
|
|
807
|
+
id: "C26a",
|
|
808
|
+
title: "No slot inside a panel's area for a group",
|
|
809
|
+
expect: "A group drag never draws a slot over a panel's body, where it can't land: nothing is offered there.",
|
|
810
|
+
group: "kinds",
|
|
811
|
+
state: panelsOnly(),
|
|
812
|
+
gestures: [g.press("tools"), g.at(130, 400), g.hold()],
|
|
813
|
+
expectLayout: { items: { tools: null, pages: { rect: r3(0, 68, 260, 732) }, findings: { rect: r3(940, 68, 260, 636) } } },
|
|
814
|
+
expectDom: [{ select: "[data-drag-slot]", count: 0, note: "no slot over a panel" }]
|
|
815
|
+
},
|
|
816
|
+
{
|
|
817
|
+
id: "C26b",
|
|
818
|
+
title: "A panel drag sets the same dragging state as a group drag",
|
|
819
|
+
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.",
|
|
820
|
+
group: "kinds",
|
|
821
|
+
state: doc(),
|
|
822
|
+
gestures: [g.press("pages"), g.at(600, 400), g.hold(), g.escape(), g.press("tools"), g.at(600, 400), g.hold(), g.escape()],
|
|
823
|
+
expectLayout: { items: { pages: { rect: r3(0, 68, 260, 732) }, tools: { rect: r3(212, 32, 200, 36) } }, notes: { hasNot: ["content-changed"] } },
|
|
824
|
+
expectDom: [
|
|
825
|
+
{ at: 2, attr: { "data-drag-session": "panel" }, note: "a panel is held" },
|
|
826
|
+
{ at: 3, attr: { "data-drag-session": null }, note: "Escape ends it" },
|
|
827
|
+
{ at: 6, attr: { "data-drag-session": "group" }, note: "a group is held" },
|
|
828
|
+
{ at: 7, attr: { "data-drag-session": null }, note: "Escape ends it" }
|
|
829
|
+
]
|
|
830
|
+
},
|
|
831
|
+
{
|
|
832
|
+
id: "C27",
|
|
833
|
+
title: "Floats never cover the bars",
|
|
834
|
+
expect: "A float let go just under the toolbar, where its grab would put its top over the bar, lands clear of every bar, not on them.",
|
|
835
|
+
group: "kinds",
|
|
836
|
+
state: doc(),
|
|
837
|
+
// (600, 72): the content, 4 px under the toolbar; the grab (10 px down) would put the float's top at 62, over the bar.
|
|
838
|
+
gestures: [g.press("notes", { x: 20, y: 10 }), g.at(600, 72), g.hold(), g.release()],
|
|
839
|
+
checkpoints: [{ at: 2, layout: { items: { notes: { floating: true, rect: r3(580, 68, 280, 320) }, title: { rect: r3(0, 0, 1116, 32) }, controls: { rect: r3(1116, 0, 84, 32) } } }, note: "the preview" }],
|
|
840
|
+
expectLayout: { items: { notes: { floating: true, rect: r3(580, 68, 280, 320) }, title: { rect: r3(0, 0, 1116, 32) }, controls: { rect: r3(1116, 0, 84, 32) } } }
|
|
841
|
+
},
|
|
842
|
+
{
|
|
843
|
+
id: "C27b",
|
|
844
|
+
title: "Floats never cover chrome rects",
|
|
845
|
+
expect: "A float let go over a chrome rect the host draws itself (a status line) lands clear of it.",
|
|
846
|
+
group: "kinds",
|
|
847
|
+
state: { ...doc(), keepClear: [r3(300, 640, 600, 60)] },
|
|
848
|
+
gestures: [g.press("notes", { x: 20, y: 10 }), g.at(600, 660), g.hold(), g.release()],
|
|
849
|
+
checkpoints: [{ at: 2, layout: { items: { notes: { floating: true, rect: r3(580, 320, 280, 320) } } }, note: "the preview" }],
|
|
850
|
+
expectLayout: { items: { notes: { floating: true, rect: r3(580, 320, 280, 320) } } }
|
|
851
|
+
},
|
|
852
|
+
{
|
|
853
|
+
id: "C28",
|
|
854
|
+
title: "A group in a side column takes its own size",
|
|
855
|
+
expect: "A group dropped into a side column takes its own width, from the column's start, never the column's full width.",
|
|
856
|
+
group: "kinds",
|
|
857
|
+
state: doc(),
|
|
858
|
+
gestures: g.drag("tools", g.gap("left", 0)),
|
|
859
|
+
checkpoints: [{ at: 2, layout: { items: { tools: { formKind: "stacked", edge: "left", rect: r3(0, 68, 84, 96) }, pages: { rect: r3(0, 164, 260, 636) } }, edges: { left: { cross: 260 } }, order: { left: ["tools", "pages"] } }, note: "the slot is the group's own size" }],
|
|
860
|
+
expectLayout: { items: { tools: { formKind: "stacked", edge: "left", rect: r3(0, 68, 84, 96) }, pages: { rect: r3(0, 164, 260, 636) } }, edges: { left: { cross: 260 } }, order: { left: ["tools", "pages"] } }
|
|
861
|
+
},
|
|
862
|
+
{
|
|
863
|
+
id: "C29",
|
|
864
|
+
title: "A bar's reserved room",
|
|
865
|
+
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.",
|
|
866
|
+
group: "kinds",
|
|
867
|
+
state: doc(),
|
|
868
|
+
gestures: [g.press("tools"), g.to(g.gap("titlebar", 1)), g.hold(), g.release()],
|
|
869
|
+
checkpoints: [{ at: 2, layout: { items: { title: { rect: r3(0, 0, 160, 32) }, tools: { edge: "titlebar", rect: r3(160, 0, 200, 32) }, controls: { rect: r3(1116, 0, 84, 32) } }, order: { titlebar: ["title", "tools", "controls"] } }, note: "the slot, right after the title" }],
|
|
870
|
+
expectLayout: { items: { title: { rect: r3(0, 0, 160, 32) }, tools: { edge: "titlebar", rect: r3(160, 0, 200, 32) }, controls: { rect: r3(1116, 0, 84, 32) } }, order: { titlebar: ["title", "tools", "controls"] } }
|
|
871
|
+
},
|
|
872
|
+
{
|
|
873
|
+
id: "C29b",
|
|
874
|
+
title: "Over the title, the gap just after it",
|
|
875
|
+
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.",
|
|
876
|
+
group: "kinds",
|
|
877
|
+
state: panelsOnly(),
|
|
878
|
+
gestures: [g.press("tools"), g.at(80, 16), g.hold()],
|
|
879
|
+
expectLayout: { items: { tools: { edge: "titlebar", rect: r3(160, 0, 200, 32) }, title: { rect: r3(0, 0, 160, 32) }, controls: { rect: r3(1116, 0, 84, 32) } }, order: { titlebar: ["title", "tools", "controls"] } },
|
|
880
|
+
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" }]
|
|
881
|
+
},
|
|
882
|
+
// --- gaps as bands, content changes, the float slot ---------------------------------------------------------------------
|
|
883
|
+
{
|
|
884
|
+
id: "R4-band-at-a-boundary",
|
|
885
|
+
title: "The hit area's boundary: 2 px past a gap's hit picks nothing (approached from the content)",
|
|
886
|
+
expect: "The geometry alone: beside a panel's body a gap's hit is a band around the boundary between the Findings panel and the Marks toolbar below it, so 11 px above the boundary is the gap and 13 px above, over the panel's body, reached from the content (where nothing is shown), picks nothing. 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. Leaving the gap from inside is R4b.",
|
|
887
|
+
group: "bands",
|
|
888
|
+
state: panelsOnly(),
|
|
889
|
+
// The boundary is at y 704. In: 693, 715 and 717 (over the toolbar). Out: 691 (over the body), reached from the
|
|
890
|
+
// content (600, 400), where a group has no target: the geometry alone, with no target carried over (a host's intent
|
|
891
|
+
// keeps a shown gap a band's width past its hit; that is the intent's rule, checked in @n-uf/motion/drag).
|
|
892
|
+
gestures: [g.press("tools"), g.at(1070, 693), g.hold(), g.at(1070, 715), g.hold(), g.at(600, 400), g.hold(), g.at(1070, 691), g.hold(), g.at(1070, 717), g.hold()],
|
|
893
|
+
checkpoints: [
|
|
894
|
+
{ at: 2, layout: { items: { findings: { rect: r3(940, 68, 260, 540) }, tools: { edge: "right", rect: r3(940, 608, 84, 96) }, marks: { rect: r3(940, 704, 84, 96) } }, order: { right: ["findings", "tools", "marks"] } }, note: "11 px above the boundary: in the band" },
|
|
895
|
+
{ at: 4, layout: { items: { findings: { rect: r3(940, 68, 260, 540) }, tools: { edge: "right", rect: r3(940, 608, 84, 96) } }, order: { right: ["findings", "tools", "marks"] } }, note: "11 px below: over the toolbar" },
|
|
896
|
+
{ at: 6, layout: { items: { tools: null } }, note: "over the content: no target for a group" },
|
|
897
|
+
{ at: 8, layout: { items: { tools: null, findings: { rect: r3(940, 68, 260, 636) }, marks: { rect: r3(940, 704, 84, 96) } } }, note: "13 px above, over the body: out" }
|
|
898
|
+
],
|
|
899
|
+
expectLayout: { items: { findings: { rect: r3(940, 68, 260, 540) }, tools: { edge: "right", rect: r3(940, 608, 84, 96) }, marks: { rect: r3(940, 704, 84, 96) } }, order: { right: ["findings", "tools", "marks"] } },
|
|
900
|
+
expectDom: [
|
|
901
|
+
{ 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" },
|
|
902
|
+
{ at: 8, select: "[data-drag-slot]", count: 0, note: "no slot 13 px off, over the body" },
|
|
903
|
+
{ at: 10, 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" }
|
|
904
|
+
]
|
|
905
|
+
},
|
|
906
|
+
{
|
|
907
|
+
id: "R4b-leaving-the-band",
|
|
908
|
+
title: "Leaving a gap: the drag intent holds it a band's width past its hit",
|
|
909
|
+
expect: "A host with a drag intent: Tools shown on the gap 11 px below the boundary, then moved 13 px above it (over the panel's body, just past the gap's hit) and rested, still shows that gap (the intent's band holds a shown target); moved on past the band and rested, it shows nothing.",
|
|
910
|
+
group: "bands",
|
|
911
|
+
state: panelsOnly(),
|
|
912
|
+
// The gap's hit reaches 12 px above the boundary (y 692); the intent's band 10 px more (682). 691: past the hit, inside
|
|
913
|
+
// the band. 678: past the band.
|
|
914
|
+
gestures: [g.press("tools"), g.at(1070, 715), g.hold(), g.at(1070, 691), g.hold(), g.at(1070, 678), g.hold()],
|
|
915
|
+
requires: { intent: true },
|
|
916
|
+
checkpoints: [
|
|
917
|
+
{ at: 2, layout: { items: { tools: { edge: "right", rect: r3(940, 608, 84, 96) } }, order: { right: ["findings", "tools", "marks"] } }, note: "on the gap" },
|
|
918
|
+
{ at: 4, layout: { items: { tools: { edge: "right", rect: r3(940, 608, 84, 96) } }, order: { right: ["findings", "tools", "marks"] } }, note: "past the hit, inside the band: the gap holds" }
|
|
919
|
+
],
|
|
920
|
+
expectLayout: { items: { tools: null, findings: { rect: r3(940, 68, 260, 636) }, marks: { rect: r3(940, 704, 84, 96) } } },
|
|
921
|
+
expectDom: [
|
|
922
|
+
{ at: 4, select: "[data-drag-slot][data-drag-target]", count: 1, attr: { "data-drag-target": "gap:right:start:1" }, note: "the band holds the gap's slot" },
|
|
923
|
+
{ at: 6, select: "[data-drag-slot]", count: 0, note: "past the band: no slot" }
|
|
924
|
+
]
|
|
925
|
+
},
|
|
926
|
+
{
|
|
927
|
+
id: "R4-no-gap-over-a-body",
|
|
928
|
+
title: "No gap over a panel's body",
|
|
929
|
+
expect: "Away from its edges, a panel's body is no gap: the pointer falls through to the float target, or to nothing.",
|
|
930
|
+
group: "bands",
|
|
931
|
+
state: panelsOnly(),
|
|
932
|
+
gestures: [g.press("tools"), g.at(1070, 400), g.hold()],
|
|
933
|
+
expectLayout: { items: { tools: null, findings: { rect: r3(940, 68, 260, 636) }, marks: { rect: r3(940, 704, 84, 96) } }, order: { right: ["findings", "marks"] } },
|
|
934
|
+
expectDom: [{ select: "[data-drag-slot]", count: 0, note: "no slot over a body" }]
|
|
935
|
+
},
|
|
936
|
+
{
|
|
937
|
+
id: "R4-bar-gaps-split-at-the-middle",
|
|
938
|
+
title: "A bar's gaps split at its items' middles",
|
|
939
|
+
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.",
|
|
940
|
+
group: "bands",
|
|
941
|
+
state: doc(),
|
|
942
|
+
gestures: [g.press("zoom"), g.at(100, 50), g.hold(), g.at(160, 50), g.hold()],
|
|
943
|
+
checkpoints: [{ at: 2, layout: { items: { views: { rect: r3(212, 32, 200, 36) }, zoom: { rect: r3(8, 32, 200, 36) }, tools: { rect: r3(416, 32, 200, 36) } }, order: { toolbar: ["zoom", "views", "tools"] } }, note: "left of Views' middle: before it" }],
|
|
944
|
+
expectLayout: { items: { views: { rect: r3(8, 32, 200, 36) }, zoom: { rect: r3(212, 32, 200, 36) }, tools: { rect: r3(416, 32, 200, 36) } }, order: { toolbar: ["views", "zoom", "tools"] } }
|
|
945
|
+
},
|
|
946
|
+
{
|
|
947
|
+
id: "R4-content-changed",
|
|
948
|
+
title: "content-changed says when to refit",
|
|
949
|
+
expect: "A window resize that changes the content gives a content-changed note, so the host refits its zoom once, after the change.",
|
|
950
|
+
group: "bands",
|
|
951
|
+
state: doc(),
|
|
952
|
+
gestures: [g.resizeWindow(1e3, 800)],
|
|
953
|
+
expectLayout: { content: r3(260, 68, 480, 704), notes: { has: ["content-changed"] } }
|
|
954
|
+
},
|
|
955
|
+
{
|
|
956
|
+
id: "R4-no-refit-on-a-float-move",
|
|
957
|
+
title: "A float move never refits",
|
|
958
|
+
expect: "Lifting a float and dropping it elsewhere changes no edge, so there is no content-changed note and no refit.",
|
|
959
|
+
group: "bands",
|
|
960
|
+
state: doc(),
|
|
961
|
+
gestures: [g.press("notes", { x: 20, y: 10 }), g.at(620, 260), g.hold(), g.release()],
|
|
962
|
+
expectLayout: { items: { notes: { floating: true, rect: r3(600, 250, 280, 320) } }, content: r3(260, 68, 680, 704), notes: { hasNot: ["content-changed"] } }
|
|
963
|
+
},
|
|
964
|
+
{
|
|
965
|
+
id: "R4-float-slot",
|
|
966
|
+
title: "The float's slot is its after rect",
|
|
967
|
+
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).",
|
|
968
|
+
group: "bands",
|
|
969
|
+
state: doc(),
|
|
970
|
+
gestures: [g.press("notes", { x: 20, y: 10 }), g.at(600, 400), g.hold(), g.release()],
|
|
971
|
+
checkpoints: [{ at: 2, layout: { items: { notes: { floating: true, rect: r3(580, 390, 280, 320) } } }, note: "the slot is where it lands" }],
|
|
972
|
+
expectLayout: { items: { notes: { floating: true, rect: r3(580, 390, 280, 320) } } },
|
|
973
|
+
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" }]
|
|
974
|
+
},
|
|
975
|
+
{
|
|
976
|
+
id: "R4-between-gap-is-its-own-slot",
|
|
977
|
+
title: "Every gap is its own slot",
|
|
978
|
+
expect: "A drop in a column's between gap lands there, not at the top: Pages dropped between Findings and Marks sits between them.",
|
|
979
|
+
group: "bands",
|
|
980
|
+
state: doc(),
|
|
981
|
+
gestures: g.drag("pages", g.gap("right", 1)),
|
|
982
|
+
checkpoints: [{ at: 2, layout: { items: { findings: { rect: r3(940, 68, 260, 318) }, pages: { edge: "right", rect: r3(940, 386, 260, 318) }, marks: { rect: r3(940, 704, 84, 96) } }, order: { right: ["findings", "pages", "marks"] } }, note: "the slot is the between gap's" }],
|
|
983
|
+
expectLayout: { items: { findings: { rect: r3(940, 68, 260, 318) }, pages: { edge: "right", rect: r3(940, 386, 260, 318) }, marks: { rect: r3(940, 704, 84, 96) } }, order: { right: ["findings", "pages", "marks"] } }
|
|
984
|
+
},
|
|
985
|
+
{
|
|
986
|
+
id: "R4-end-reach-stays-in-its-edge-right",
|
|
987
|
+
title: "A gap's end reach never enters another edge",
|
|
988
|
+
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.",
|
|
989
|
+
group: "bands",
|
|
990
|
+
state: doc(),
|
|
991
|
+
gestures: [g.press("views", { x: 20, y: 10 }), g.at(960, 50), g.hold()],
|
|
992
|
+
expectLayout: { items: { views: { edge: "toolbar" } } }
|
|
993
|
+
},
|
|
994
|
+
{
|
|
995
|
+
id: "R4-end-reach-stays-in-its-edge-left",
|
|
996
|
+
title: "A gap's end reach never enters another edge, left side",
|
|
997
|
+
expect: "Views held at (250, 60), inside the toolbar, is offered a toolbar gap, never the left column's top gap.",
|
|
998
|
+
group: "bands",
|
|
999
|
+
state: doc(),
|
|
1000
|
+
gestures: [g.press("views", { x: 20, y: 10 }), g.at(250, 60), g.hold()],
|
|
1001
|
+
expectLayout: { items: { views: { edge: "toolbar" } } }
|
|
1002
|
+
},
|
|
1003
|
+
// --- a column's tray of toolbars (`DockEdge.zoneAccepts`) ------------------------------------------------------------------
|
|
1004
|
+
{
|
|
1005
|
+
id: "R5-group-into-the-tray",
|
|
1006
|
+
title: "A group dropped into a panel column lands in its tray",
|
|
1007
|
+
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.",
|
|
1008
|
+
group: "kinds",
|
|
1009
|
+
state: trayColumn(),
|
|
1010
|
+
gestures: g.drag("tools", g.gap("left", 0, "end")),
|
|
1011
|
+
expectLayout: { items: { tools: { formKind: "icons", edge: "left", zone: "end", rect: r3(0, 716, 28, 84) }, pages: { formKind: "open", rect: r3(0, 68, 260, 648) } }, order: { left: ["pages", "tools"] } }
|
|
1012
|
+
},
|
|
1013
|
+
{
|
|
1014
|
+
id: "R5-group-is-offered-no-gap-above-the-tray",
|
|
1015
|
+
title: "A group is offered no gap in a panel zone",
|
|
1016
|
+
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.",
|
|
1017
|
+
group: "kinds",
|
|
1018
|
+
state: trayColumn(),
|
|
1019
|
+
gestures: [g.press("tools"), g.at(130, 76), g.hold()],
|
|
1020
|
+
expectLayout: { items: { tools: null, pages: { formKind: "open", rect: r3(0, 68, 260, 732) } }, order: { left: ["pages"] } }
|
|
1021
|
+
},
|
|
1022
|
+
{
|
|
1023
|
+
id: "R5-group-never-opens-a-column",
|
|
1024
|
+
title: "A group never opens a column on its own",
|
|
1025
|
+
expect: "An empty column whose start zone takes panels offers its strip (by thirds) to panels only: a group held over it is offered nothing.",
|
|
1026
|
+
group: "kinds",
|
|
1027
|
+
state: tweakEdge(trayColumn(), "left", { items: [] }),
|
|
1028
|
+
gestures: [g.press("tools"), g.at(10, 400), g.hold()],
|
|
1029
|
+
expectLayout: { items: { tools: null, findings: { rect: r3(940, 68, 260, 636) } }, order: { left: [] } },
|
|
1030
|
+
expectDom: [{ select: "[data-drag-slot]", count: 0, note: "no strip for a group" }]
|
|
1031
|
+
},
|
|
1032
|
+
{
|
|
1033
|
+
id: "R5-panel-opens-an-empty-column",
|
|
1034
|
+
title: "A panel opens the empty column",
|
|
1035
|
+
expect: "The column's top third (its start zone, which takes panels) takes a panel: Findings let go over it opens the column.",
|
|
1036
|
+
group: "kinds",
|
|
1037
|
+
state: tweakEdge(trayColumn(), "left", { items: [] }),
|
|
1038
|
+
gestures: [g.press("findings"), g.at(10, 150), g.hold(), g.release()],
|
|
1039
|
+
expectLayout: { items: { findings: { formKind: "open", edge: "left", rect: r3(0, 68, 260, 732) } }, order: { left: ["findings"] } }
|
|
1040
|
+
},
|
|
1041
|
+
...["start", "center", "end"].map(
|
|
1042
|
+
(zone) => ({
|
|
1043
|
+
id: `R6-bar-${zone}-zone`,
|
|
1044
|
+
title: `A toolbar dropped in a bar's ${zone} zone`,
|
|
1045
|
+
expect: {
|
|
1046
|
+
start: "Tools, floating, dropped after Views in the toolbar's start zone lands leading, right after Views.",
|
|
1047
|
+
center: "Tools dropped in the toolbar's center zone lands at the bar's true center, clear of Views at the start and Zoom at the end.",
|
|
1048
|
+
end: "Tools dropped in the toolbar's end zone lands trailing, right before Zoom."
|
|
1049
|
+
}[zone],
|
|
1050
|
+
group: "groups",
|
|
1051
|
+
state: barZones(),
|
|
1052
|
+
gestures: g.drag("tools", g.gap("toolbar", zone === "start" ? 1 : 0, zone)),
|
|
1053
|
+
expectLayout: {
|
|
1054
|
+
items: { tools: { edge: "toolbar", zone, formKind: "row", rect: r3({ start: 212, center: 500, end: 788 }[zone], 32, 200, 36) }, views: { rect: r3(8, 32, 200, 36) }, zoom: { rect: r3(992, 32, 200, 36) } },
|
|
1055
|
+
order: { toolbar: ["views", "tools", "zoom"] }
|
|
1056
|
+
}
|
|
1057
|
+
})
|
|
1058
|
+
),
|
|
1059
|
+
...["leading", "trailing"].map(
|
|
1060
|
+
(half) => ({
|
|
1061
|
+
id: `R7-end-zone-pushes-fixed-behind-a-movable-${half}`,
|
|
1062
|
+
title: `Fixed items behind a movable one are pushed: Zoom's ${half} half`,
|
|
1063
|
+
expect: {
|
|
1064
|
+
leading: "In a title bar whose end zone is State and Page (fixed) then Zoom, Tools let go over Zoom's leading half lands before Zoom (gap end:2): State and Page, placed only by Zoom's size, move left to make room.",
|
|
1065
|
+
trailing: "The same title bar: Tools let go over Zoom's trailing half lands after Zoom (gap end:3), State, Page and Zoom moving left to make room."
|
|
1066
|
+
}[half],
|
|
1067
|
+
group: "groups",
|
|
1068
|
+
state: titleEnd(["state", "page", "zoom"]),
|
|
1069
|
+
gestures: [g.press("tools"), g.at(half === "leading" ? 1050 : 1150, 16), g.hold(), g.release()],
|
|
1070
|
+
expectLayout: {
|
|
1071
|
+
items: half === "leading" ? { tools: { edge: "titlebar", zone: "end", rect: r3(800, 0, 200, 32) }, state: { rect: r3(662, 0, 96, 32) }, page: { rect: r3(758, 0, 42, 32) }, zoom: { rect: r3(1e3, 0, 200, 32) } } : { tools: { edge: "titlebar", zone: "end", rect: r3(1e3, 0, 200, 32) }, state: { rect: r3(662, 0, 96, 32) }, page: { rect: r3(758, 0, 42, 32) }, zoom: { rect: r3(800, 0, 200, 32) } },
|
|
1072
|
+
order: { titlebar: half === "leading" ? ["title", "state", "page", "tools", "zoom"] : ["title", "state", "page", "zoom", "tools"] }
|
|
1073
|
+
}
|
|
1074
|
+
})
|
|
1075
|
+
),
|
|
1076
|
+
{
|
|
1077
|
+
id: "R7-end-zone-anchored-fixed-stay",
|
|
1078
|
+
title: "The anchored fixed run stays put",
|
|
1079
|
+
expect: "With Zoom first in the end zone and State and Page (fixed) after it, at the bar's end, the readouts are the zone's anchored fixed run: no place after them is offered, so Tools let go over Zoom's trailing half lands right after Zoom (gap end:1) and State and Page keep their places.",
|
|
1080
|
+
group: "groups",
|
|
1081
|
+
state: titleEnd(["zoom", "state", "page"]),
|
|
1082
|
+
gestures: [g.press("tools"), g.at(1012, 16), g.hold(), g.release()],
|
|
1083
|
+
expectLayout: {
|
|
1084
|
+
items: { tools: { edge: "titlebar", zone: "end", rect: r3(862, 0, 200, 32) }, zoom: { rect: r3(662, 0, 200, 32) }, state: { rect: r3(1062, 0, 96, 32) }, page: { rect: r3(1158, 0, 42, 32) } },
|
|
1085
|
+
order: { titlebar: ["title", "zoom", "tools", "state", "page"] }
|
|
1086
|
+
}
|
|
1087
|
+
},
|
|
1088
|
+
{
|
|
1089
|
+
id: "R7-end-zone-pushable-put-back",
|
|
1090
|
+
title: "Pushable readouts: the gap after them is a stop, and Put back lands in it",
|
|
1091
|
+
expect: `State and Page (fixed, \`pushable\`) are at the title bar's end with Zoom homed after them: "state page zoom". With Zoom moved to the toolbar they are the end zone's anchored run, and the gap after them (end:2) is still one of Zoom's stops, because a readout that declares it may be pushed inward lets a movable item land after it. "Move to \u203A" that gap puts Zoom back: State and Page move left by Zoom's width and the order is "state page zoom" again. A gap between the two readouts (end:1) is no stop: they keep their order.`,
|
|
1092
|
+
group: "groups",
|
|
1093
|
+
state: titleEnd(["state", "page", "zoom"], true),
|
|
1094
|
+
gestures: [g.moveTo("zoom", g.gap("toolbar", 2)), g.moveTo("zoom", g.gap("titlebar", 2, "end"))],
|
|
1095
|
+
checkpoints: [
|
|
1096
|
+
{ at: 0, layout: { items: { zoom: { edge: "toolbar" }, state: { rect: r3(1062, 0, 96, 32) }, page: { rect: r3(1158, 0, 42, 32) } }, order: { titlebar: ["title", "state", "page"] } }, note: "Zoom away: the readouts sit at the bar's end" }
|
|
1097
|
+
],
|
|
1098
|
+
expectStops: { item: "zoom", at: 0, places: zoomAwayStops([0, 2]) },
|
|
1099
|
+
expectLayout: {
|
|
1100
|
+
items: { state: { rect: r3(862, 0, 96, 32) }, page: { rect: r3(958, 0, 42, 32) }, zoom: { edge: "titlebar", zone: "end", rect: r3(1e3, 0, 200, 32) } },
|
|
1101
|
+
order: { titlebar: ["title", "state", "page", "zoom"] }
|
|
1102
|
+
}
|
|
1103
|
+
},
|
|
1104
|
+
{
|
|
1105
|
+
id: "R7-end-zone-fixed-without-the-flag-no-gap-after",
|
|
1106
|
+
title: "Readouts without `pushable` keep the end: no gap after them",
|
|
1107
|
+
expect: "The same title bar with State and Page not declaring `pushable`, Zoom moved to the toolbar: no place after them is a stop for Zoom (only end:0, before them), so \"state page zoom\" can't be made by a drop. A fixed item pinned to the bar's end (window controls) is protected unless it says otherwise.",
|
|
1108
|
+
group: "groups",
|
|
1109
|
+
state: titleEnd(["state", "page", "zoom"]),
|
|
1110
|
+
gestures: [g.moveTo("zoom", g.gap("toolbar", 2))],
|
|
1111
|
+
expectStops: { item: "zoom", places: zoomAwayStops([0]) },
|
|
1112
|
+
expectLayout: { items: { zoom: { edge: "toolbar" }, state: { rect: r3(1062, 0, 96, 32) }, page: { rect: r3(1158, 0, 42, 32) } }, order: { titlebar: ["title", "state", "page"] } }
|
|
1113
|
+
},
|
|
1114
|
+
{
|
|
1115
|
+
id: "R8-hand-fold-is-the-fold-form",
|
|
1116
|
+
title: "A hand fold folds a toolbar group, it never steps to a variant",
|
|
1117
|
+
expect: "Zoom's forms along the toolbar are row, stacked, icons, its fold (its grip and \xBB) and the menu. Folded by hand (a grip's double-click), it takes its fold form, not stacked, the next variant; unfolded, it takes the form the toolbar's room allows again, its row.",
|
|
1118
|
+
group: "groups",
|
|
1119
|
+
state: zoomFive(),
|
|
1120
|
+
gestures: [g.click("zoom", "fold"), g.click("zoom", "unfold")],
|
|
1121
|
+
checkpoints: [{ at: 0, layout: { items: { zoom: { edge: "toolbar", formKind: "fold", form: 3 } } }, note: "folded by hand: its fold form" }],
|
|
1122
|
+
expectLayout: { items: { zoom: { edge: "toolbar", formKind: "row", form: 0 } } }
|
|
1123
|
+
},
|
|
1124
|
+
{
|
|
1125
|
+
id: "R9-zones-taking-nothing-refuse-nothing",
|
|
1126
|
+
title: "A side rail whose zones take nothing is no drop place and no refusal",
|
|
1127
|
+
expect: "An empty side rail at the window's left edge that lists toolbars but whose zones take none (`zoneAccepts: {}`, a rail the host doesn't draw) is no edge for a toolbar at all: Tools held 6 px from the window's left edge, over the column's panel, shows no refusal there and floats where it is let go (it used to be refused there and went back to its toolbar).",
|
|
1128
|
+
group: "kinds",
|
|
1129
|
+
state: sideRailTakingNothing(),
|
|
1130
|
+
gestures: [g.press("tools"), g.at(6, 400), g.hold(), g.release()],
|
|
1131
|
+
expectLayout: { items: { tools: { edge: null, floating: true } } },
|
|
1132
|
+
expectDom: [{ at: 2, select: "[data-drag-refusal]", count: 0, note: "no refusal along the undrawn rail" }]
|
|
1133
|
+
}
|
|
1134
|
+
];
|
|
1135
|
+
function sideRailTakingNothing() {
|
|
1136
|
+
const s = doc();
|
|
1137
|
+
const rail = { id: "side-rail", side: "left", ring: 0, accepts: ["group"], zoneAccepts: {}, items: [], cross: { min: 32, max: 32, rail: 32 } };
|
|
1138
|
+
return { ...s, edges: [rail, ...s.edges.map((e) => e.side === "left" ? { ...e, ring: e.ring + 1 } : e)] };
|
|
1139
|
+
}
|
|
1140
|
+
function zoomFive() {
|
|
1141
|
+
const s = doc();
|
|
1142
|
+
const row2 = [form("row", 200, 200, 28), form("stacked", 120, 120, 30), form("icons", 84, 84, 28), form("fold", 24, 24, 28), form("menu", 0, 0, 0)];
|
|
1143
|
+
return { ...s, items: { ...s.items, zoom: { ...s.items.zoom, forms: { ...s.items.zoom.forms, row: row2 } } } };
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
// src/testing/rows-gestures.ts
|
|
1147
|
+
import { rect as r4 } from "@n-uf/placement";
|
|
1148
|
+
|
|
1149
|
+
// src/testing/windows.ts
|
|
1150
|
+
var WINDOW_A = { card: { min: 220, max: 640 }, gap: 12, pad: 12, rail: 32, contentMin: { width: 320, height: 240 }, barMain: 30 };
|
|
1151
|
+
var WINDOW_B = { card: { min: 200, max: 560 }, gap: 0, pad: 0, rail: 32, contentMin: { width: 320, height: 240 }, barMain: 30 };
|
|
1152
|
+
var WINDOW_BARE = { ...WINDOW_A, gap: 0, pad: 0, rail: 36 };
|
|
1153
|
+
var DEFAULT_COLUMNS = { left: [["pages", "annotations"]], right: [["findings"]] };
|
|
1154
|
+
var DEFAULT_USED2 = { pages: 1, annotations: 2, findings: 3 };
|
|
1155
|
+
function winState(spec, o = {}) {
|
|
1156
|
+
const card = { kind: "open", main: { min: 120, natural: 300, grows: true }, cross: { natural: spec.card.min, min: spec.card.min } };
|
|
1157
|
+
const bar3 = { kind: "header", main: { min: spec.barMain, natural: spec.barMain }, cross: { natural: spec.card.min, min: 60 } };
|
|
1158
|
+
const rail = { kind: "rail", main: { min: 32, natural: 32 }, cross: { natural: spec.rail } };
|
|
1159
|
+
const template = { accepts: ["panel"], cross: { min: spec.card.min, max: spec.card.max, rail: spec.rail }, gap: spec.gap };
|
|
1160
|
+
const cols = o.columns ?? DEFAULT_COLUMNS;
|
|
1161
|
+
const used = { ...DEFAULT_USED2, ...o.used };
|
|
1162
|
+
const edges = [];
|
|
1163
|
+
const items = {};
|
|
1164
|
+
const add = (id) => {
|
|
1165
|
+
items[id] = { id, kind: "panel", used: used[id] ?? 0, forms: { column: [card, bar3, rail] }, ...o.from?.[id] ? { from: o.from[id] } : {} };
|
|
1166
|
+
};
|
|
1167
|
+
for (const side of ["left", "right"]) {
|
|
1168
|
+
(cols[side] ?? []).forEach((members, ring) => {
|
|
1169
|
+
members.forEach(add);
|
|
1170
|
+
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 } : {} });
|
|
1171
|
+
});
|
|
1172
|
+
}
|
|
1173
|
+
for (const f2 of o.floats ?? []) add(f2.id);
|
|
1174
|
+
return {
|
|
1175
|
+
stage: { x: 0, y: 0, width: o.width ?? 1120, height: o.height ?? 800 },
|
|
1176
|
+
edges,
|
|
1177
|
+
items,
|
|
1178
|
+
floats: (o.floats ?? []).map((f2) => ({ id: f2.id, rect: { ...f2.rect } })),
|
|
1179
|
+
floatKinds: ["panel"],
|
|
1180
|
+
columns: { left: template, right: template },
|
|
1181
|
+
rails: { left: { width: spec.rail, accepts: ["panel"] }, right: { width: spec.rail, accepts: ["panel"] } },
|
|
1182
|
+
contentMin: spec.contentMin,
|
|
1183
|
+
handFold: o.handFold ?? "bar",
|
|
1184
|
+
inset: { left: spec.pad, right: spec.pad },
|
|
1185
|
+
gutter: spec.gap
|
|
1186
|
+
};
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
// src/testing/rows-gestures.ts
|
|
1190
|
+
var win = (o = {}) => winState(WINDOW_A, { size: 300, ...o });
|
|
1191
|
+
var foldsBelow = (w) => 2 * w.pad + w.card.min + 2 * w.gap + w.contentMin.width + w.rail;
|
|
1192
|
+
var BOTH_RAILS_W = Math.min(foldsBelow(WINDOW_A), foldsBelow(WINDOW_B)) - 12;
|
|
1193
|
+
var FLUSH_W = 1440;
|
|
1194
|
+
var flush = () => winState(WINDOW_B, { width: FLUSH_W, height: 900, handFold: "ride" });
|
|
1195
|
+
function withTitle(s) {
|
|
1196
|
+
return {
|
|
1197
|
+
...s,
|
|
1198
|
+
edges: [{ id: "titlebar", side: "top", ring: 0, span: "full", accepts: ["group"], items: ["window-title"], cross: { min: 28, max: 28, rail: 28 } }, ...s.edges],
|
|
1199
|
+
items: { ...s.items, "window-title": { id: "window-title", kind: "title", used: 0, fixed: true, forms: { row: [form("row", 80, 160, 28, { grows: true })] } } }
|
|
1200
|
+
};
|
|
1201
|
+
}
|
|
1202
|
+
function withStatusBar(s) {
|
|
1203
|
+
return {
|
|
1204
|
+
...s,
|
|
1205
|
+
edges: [...s.edges, { id: "statusbar", side: "bottom", ring: 0, span: "full", accepts: ["group"], items: ["status"], cross: { min: 8, max: 8, rail: 8 } }],
|
|
1206
|
+
items: { ...s.items, status: { id: "status", kind: "title", used: 0, fixed: true, forms: { row: [form("row", 80, 160, 8, { grows: true })] } } }
|
|
1207
|
+
};
|
|
1208
|
+
}
|
|
1209
|
+
var RIGHT_EDGE = 1108;
|
|
1210
|
+
var LINE_OUT = 1;
|
|
1211
|
+
var GESTURE_ROWS = [
|
|
1212
|
+
{
|
|
1213
|
+
id: "P1-lift-follows-and-nothing-reflows",
|
|
1214
|
+
title: "Lifting: the slot is the target's rect and nothing else moves",
|
|
1215
|
+
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.",
|
|
1216
|
+
group: "gestures",
|
|
1217
|
+
state: win(),
|
|
1218
|
+
gestures: [g.press("annotations"), g.to(g.gap("right-0", 1)), g.hold()],
|
|
1219
|
+
expectLayout: { items: { pages: { rect: r4(12, 0, 300, 800) }, findings: { rect: r4(808, 0, 300, 394) }, annotations: { edge: "right-0", rect: r4(808, 406, 300, 394) } }, columns: { left: [["pages"]], right: [["findings", "annotations"]] } },
|
|
1220
|
+
expectDom: [
|
|
1221
|
+
{ attr: { "data-drag-session": "panel" }, note: "the root says a panel is dragged" },
|
|
1222
|
+
{ select: "[data-drag-held]", count: 1, note: "the held item" },
|
|
1223
|
+
{ select: "[data-drag-slot][data-drag-target]", count: 1, attr: { "data-drag-target": "gap:right-0:start:1" }, note: "one slot, on the target" }
|
|
1224
|
+
]
|
|
1225
|
+
},
|
|
1226
|
+
{
|
|
1227
|
+
id: "P2-drop-into-another-column-at-a-position",
|
|
1228
|
+
title: "Drop into another column at a position",
|
|
1229
|
+
expect: "Dropped on the end gap of the right column, Annotations lands there, on the rect the slot showed.",
|
|
1230
|
+
group: "gestures",
|
|
1231
|
+
state: win(),
|
|
1232
|
+
gestures: g.drag("annotations", g.gap("right-0", 1)),
|
|
1233
|
+
checkpoints: [{ at: 2, layout: { items: { pages: { rect: r4(12, 0, 300, 800) }, findings: { rect: r4(808, 0, 300, 394) }, annotations: { edge: "right-0", rect: r4(808, 406, 300, 394) } } }, note: "the slot" }],
|
|
1234
|
+
expectLayout: { items: { pages: { rect: r4(12, 0, 300, 800) }, findings: { rect: r4(808, 0, 300, 394) }, annotations: { edge: "right-0", rect: r4(808, 406, 300, 394) } }, columns: { left: [["pages"]], right: [["findings", "annotations"]] } }
|
|
1235
|
+
},
|
|
1236
|
+
{
|
|
1237
|
+
id: "P3-restore-pages-above-annotations",
|
|
1238
|
+
title: "Restore Pages above Annotations",
|
|
1239
|
+
expect: "Pages moved to the right column and dropped back on the left column's top gap is above Annotations again, as it began.",
|
|
1240
|
+
group: "gestures",
|
|
1241
|
+
state: win(),
|
|
1242
|
+
gestures: [...g.drag("pages", g.gap("right-0", 1)), ...g.drag("pages", g.gap("left-0", 0))],
|
|
1243
|
+
checkpoints: [{ at: 3, layout: { columns: { left: [["annotations"]], right: [["findings", "pages"]] }, items: { annotations: { rect: r4(12, 0, 300, 800) }, pages: { rect: r4(808, 406, 300, 394) } } }, note: "after the first drop" }],
|
|
1244
|
+
expectLayout: { items: { pages: { rect: r4(12, 0, 300, 394) }, annotations: { rect: r4(12, 406, 300, 394) }, findings: { rect: r4(808, 0, 300, 800) } }, columns: { left: [["pages", "annotations"]], right: [["findings"]] } }
|
|
1245
|
+
},
|
|
1246
|
+
{
|
|
1247
|
+
id: "P4-escape-cancels",
|
|
1248
|
+
title: "Escape cancels",
|
|
1249
|
+
expect: "Escape during a drag changes nothing: the state is as it was, and no slot or held marker remains.",
|
|
1250
|
+
group: "gestures",
|
|
1251
|
+
state: win(),
|
|
1252
|
+
gestures: [g.press("annotations"), g.to(g.gap("right-0", 0)), g.hold(), g.escape()],
|
|
1253
|
+
expectLayout: { items: { pages: { rect: r4(12, 0, 300, 394) }, annotations: { rect: r4(12, 406, 300, 394) }, findings: { rect: r4(808, 0, 300, 800) } }, columns: { left: [["pages", "annotations"]], right: [["findings"]] } },
|
|
1254
|
+
expectDom: [
|
|
1255
|
+
{ at: 2, select: "[data-drag-slot]", count: 1, note: "the slot while held" },
|
|
1256
|
+
{ select: "[data-drag-slot]", count: 0, note: "no slot after Escape" },
|
|
1257
|
+
{ select: "[data-drag-held]", count: 0, note: "no held marker after Escape" },
|
|
1258
|
+
{ attr: { "data-drag-session": null }, note: "the session is over" }
|
|
1259
|
+
]
|
|
1260
|
+
},
|
|
1261
|
+
{
|
|
1262
|
+
id: "P5-own-place-is-a-no-op",
|
|
1263
|
+
title: "Over its own place is a no-op",
|
|
1264
|
+
expect: "Lifted and let go over its own place, an item changes nothing, shows no slot and is never floated.",
|
|
1265
|
+
group: "gestures",
|
|
1266
|
+
state: win(),
|
|
1267
|
+
gestures: [g.press("annotations"), g.to(g.home), g.hold(), g.release()],
|
|
1268
|
+
expectLayout: { items: { pages: { rect: r4(12, 0, 300, 394) }, annotations: { rect: r4(12, 406, 300, 394) }, findings: { rect: r4(808, 0, 300, 800) } }, columns: { left: [["pages", "annotations"]], right: [["findings"]] } },
|
|
1269
|
+
expectDom: [{ at: 2, select: "[data-drag-slot]", count: 0, note: "no slot over its own place" }]
|
|
1270
|
+
},
|
|
1271
|
+
{
|
|
1272
|
+
id: "P5-gap-beside-it",
|
|
1273
|
+
title: "The gap beside it is its own place",
|
|
1274
|
+
expect: "The gap just below Annotations in its own column is its own place (home's tile, over Annotations itself): a release there changes nothing.",
|
|
1275
|
+
group: "gestures",
|
|
1276
|
+
state: win(),
|
|
1277
|
+
gestures: [g.press("annotations"), g.to(g.home), g.release()],
|
|
1278
|
+
expectLayout: { items: { pages: { rect: r4(12, 0, 300, 394) }, annotations: { rect: r4(12, 406, 300, 394) }, findings: { rect: r4(808, 0, 300, 800) } }, columns: { left: [["pages", "annotations"]], right: [["findings"]] } }
|
|
1279
|
+
},
|
|
1280
|
+
{
|
|
1281
|
+
id: "P5-neighbour-half-facing-it",
|
|
1282
|
+
title: "Over a neighbor's body there is no gap",
|
|
1283
|
+
expect: 'Annotations let go over Pages\' body, away from its edges, finds no gap (over a panel\'s body a gap is a band around a boundary), so it falls through to the float target: it floats, where the pointer let go. The older rule "the neighbor half that faces it is its home" no longer holds. This assumes the default `hitBand` (an open panel\'s body is no drop place): a host whose columns use `hitBand: "middle"` gets card halves there, and skips or marks this row.',
|
|
1284
|
+
group: "gestures",
|
|
1285
|
+
requires: { hitBand: "default" },
|
|
1286
|
+
state: win(),
|
|
1287
|
+
gestures: [g.press("annotations", { x: 20, y: 10 }), g.at(160, 200), g.hold(), g.release()],
|
|
1288
|
+
expectLayout: { items: { pages: { rect: r4(12, 0, 300, 800) }, annotations: { floating: true, rect: r4(312, 190, 280, 360) } }, floats: ["annotations"], columns: { left: [["pages"]], right: [["findings"]] } }
|
|
1289
|
+
},
|
|
1290
|
+
{
|
|
1291
|
+
id: "P6-new-outer-column-from-outside",
|
|
1292
|
+
title: "A new outer column, reached from the content",
|
|
1293
|
+
expect: "Annotations held over the pages (the float) and then moved to the new outermost right column's line (aimed by its place, so it holds with or without a rail strip) makes the outermost column, on the slot's rect.",
|
|
1294
|
+
group: "gestures",
|
|
1295
|
+
state: win(),
|
|
1296
|
+
gestures: [g.press("annotations"), g.at(560, 400), g.hold(), g.to(g.column("right", 0)), g.hold(), g.release()],
|
|
1297
|
+
checkpoints: [{ at: 4, layout: { items: { pages: { rect: r4(12, 0, 220, 800) }, annotations: { edge: "right-1", rect: r4(888, 0, 220, 800) }, findings: { edge: "right-0", rect: r4(576, 0, 300, 800) } }, columns: { left: [["pages"]], right: [["annotations"], ["findings"]] }, notes: { has: ["column-shrunk"] } }, note: "the preview" }],
|
|
1298
|
+
expectLayout: { items: { pages: { rect: r4(12, 0, 220, 800) }, annotations: { edge: "right-1", rect: r4(888, 0, 220, 800) }, findings: { edge: "right-0", rect: r4(576, 0, 300, 800) } }, columns: { left: [["pages"]], right: [["annotations"], ["findings"]] }, notes: { has: ["column-shrunk"] } }
|
|
1299
|
+
},
|
|
1300
|
+
{
|
|
1301
|
+
id: "P6-outer-line-at-11-px",
|
|
1302
|
+
title: "With no rail strip, 11 px from the window's edge is the new-column line",
|
|
1303
|
+
expect: "Precondition: no rail drop strip (the state's `railDrop` as given: none), so the rail's own stop owns the window's outer 10 px. Let go 1 px outside the right column's outer edge (11 px from the window's edge), at 5%, 50% or 95% of the stage's height, Annotations makes the outermost column.",
|
|
1304
|
+
group: "gestures",
|
|
1305
|
+
state: win(),
|
|
1306
|
+
requires: { railDrop: "state" },
|
|
1307
|
+
gestures: [g.press("annotations"), g.at(RIGHT_EDGE + LINE_OUT, 40), g.hold(), g.at(RIGHT_EDGE + LINE_OUT, 400), g.hold(), g.at(RIGHT_EDGE + LINE_OUT, 760), g.hold(), g.release()],
|
|
1308
|
+
checkpoints: [2, 4, 6].map((at2, i) => ({ at: at2, layout: { items: { annotations: { edge: "right-1", rect: r4(888, 0, 220, 800) } }, columns: { right: [["annotations"], ["findings"]] } }, note: ["5%", "50%", "95%"][i] })),
|
|
1309
|
+
expectLayout: { items: { pages: { rect: r4(12, 0, 220, 800) }, annotations: { edge: "right-1", rect: r4(888, 0, 220, 800) }, findings: { edge: "right-0", rect: r4(576, 0, 300, 800) } }, columns: { left: [["pages"]], right: [["annotations"], ["findings"]] }, notes: { has: ["column-shrunk"] } }
|
|
1310
|
+
},
|
|
1311
|
+
{
|
|
1312
|
+
id: "P6-new-outer-column-from-inside",
|
|
1313
|
+
title: "A new outer column from inside the right column",
|
|
1314
|
+
expect: "The new column's line is also reachable from inside the column: Annotations over its outer edge makes the outermost column.",
|
|
1315
|
+
group: "gestures",
|
|
1316
|
+
state: win(),
|
|
1317
|
+
gestures: g.drag("annotations", g.column("right", 0)),
|
|
1318
|
+
expectLayout: { items: { pages: { rect: r4(12, 0, 220, 800) }, annotations: { edge: "right-1", rect: r4(888, 0, 220, 800) }, findings: { edge: "right-0", rect: r4(576, 0, 300, 800) } }, columns: { left: [["pages"]], right: [["annotations"], ["findings"]] }, notes: { has: ["column-shrunk"] } }
|
|
1319
|
+
},
|
|
1320
|
+
{
|
|
1321
|
+
id: "P6-left-outer-edge",
|
|
1322
|
+
title: "A new outer column on the left",
|
|
1323
|
+
expect: "Findings let go on the new outermost left column's line (aimed by its place, so it holds with or without a rail strip) makes the outermost left column; the right side is then empty.",
|
|
1324
|
+
group: "gestures",
|
|
1325
|
+
state: win(),
|
|
1326
|
+
gestures: g.drag("findings", g.column("left", 0)),
|
|
1327
|
+
expectLayout: { items: { findings: { edge: "left-1", rect: r4(12, 0, 220, 800) }, pages: { rect: r4(244, 0, 300, 394) }, annotations: { rect: r4(244, 406, 300, 394) } }, columns: { left: [["findings"], ["pages", "annotations"]], right: [] } }
|
|
1328
|
+
},
|
|
1329
|
+
{
|
|
1330
|
+
id: "P6-between-columns-line",
|
|
1331
|
+
title: "The line between two columns",
|
|
1332
|
+
expect: "Dropped on the new-column line at the inner end of the left side, Annotations makes a second left column.",
|
|
1333
|
+
group: "gestures",
|
|
1334
|
+
state: win(),
|
|
1335
|
+
gestures: g.drag("annotations", g.column("left", 1)),
|
|
1336
|
+
expectLayout: { items: { pages: { rect: r4(12, 0, 220, 800) }, annotations: { edge: "left-1", rect: r4(244, 0, 220, 800) }, findings: { rect: r4(808, 0, 300, 800) } }, columns: { left: [["pages"], ["annotations"]], right: [["findings"]] } }
|
|
1337
|
+
},
|
|
1338
|
+
{
|
|
1339
|
+
id: "P7-end-reach",
|
|
1340
|
+
title: "A drop just past the end of a stack is its end gap",
|
|
1341
|
+
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.",
|
|
1342
|
+
group: "gestures",
|
|
1343
|
+
state: win(),
|
|
1344
|
+
gestures: [g.press("pages"), g.at(958, 814), g.hold(), g.release()],
|
|
1345
|
+
expectLayout: { items: { annotations: { rect: r4(12, 0, 300, 800) }, findings: { rect: r4(808, 0, 300, 394) }, pages: { edge: "right-0", rect: r4(808, 406, 300, 394) } }, columns: { left: [["annotations"]], right: [["findings", "pages"]] } }
|
|
1346
|
+
},
|
|
1347
|
+
{
|
|
1348
|
+
id: "P7-target-meets-a-refusal",
|
|
1349
|
+
title: "Where a target meets a refusal, the target wins",
|
|
1350
|
+
expect: "With an 8 px status line across the bottom (it takes no panels), Pages let go on the line where the right column's outer new-column line ends on the status line goes to a new outer right column: the refusal never takes a point a target holds, however small it is.",
|
|
1351
|
+
group: "gestures",
|
|
1352
|
+
state: withStatusBar(win()),
|
|
1353
|
+
gestures: [g.press("pages"), g.at(1098, 792), g.hold(), g.release()],
|
|
1354
|
+
expectLayout: { columns: { left: [["annotations"]], right: [["pages"], ["findings"]] } }
|
|
1355
|
+
},
|
|
1356
|
+
{
|
|
1357
|
+
id: "P7-past-a-refused-bar",
|
|
1358
|
+
title: "Past the window's edge beyond a refused bar, nothing is picked",
|
|
1359
|
+
expect: "With an 8 px status line across the bottom (it takes no panels), Findings held over the status line is refused there; moved on past the window's bottom edge (clamped onto it) it is over no drawn space: neither the refusal nor the float holds the window's edge, so nothing is picked and the drop commits nothing.",
|
|
1360
|
+
group: "gestures",
|
|
1361
|
+
state: withStatusBar(win()),
|
|
1362
|
+
gestures: [g.press("findings"), g.at(700, 796), g.hold(), g.at(700, 840), g.hold(), g.release()],
|
|
1363
|
+
checkpoints: [
|
|
1364
|
+
{ at: 2, layout: { items: { findings: null } }, note: "over the status line: refused, the held panel out of the layout" },
|
|
1365
|
+
{ at: 4, layout: { items: { findings: null } }, note: "past the window's edge: nothing picked" }
|
|
1366
|
+
],
|
|
1367
|
+
expectLayout: { columns: { left: [["pages", "annotations"]], right: [["findings"]] } }
|
|
1368
|
+
},
|
|
1369
|
+
{
|
|
1370
|
+
id: "P8-folded-bar-drags-like-a-card",
|
|
1371
|
+
title: "A folded bar drags like a card",
|
|
1372
|
+
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.",
|
|
1373
|
+
group: "gestures",
|
|
1374
|
+
state: win({ from: { annotations: 1 } }),
|
|
1375
|
+
gestures: g.drag("annotations", g.gap("right-0", 0)),
|
|
1376
|
+
checkpoints: [{ at: 2, layout: { items: { pages: { rect: r4(12, 0, 300, 800) }, annotations: { formKind: "header", edge: "right-0", rect: r4(808, 0, 300, 30) }, findings: { rect: r4(808, 42, 300, 758) } }, columns: { left: [["pages"]], right: [["annotations", "findings"]] } }, note: "the slot" }],
|
|
1377
|
+
expectLayout: { items: { pages: { rect: r4(12, 0, 300, 800) }, annotations: { formKind: "header", edge: "right-0", rect: r4(808, 0, 300, 30) }, findings: { rect: r4(808, 42, 300, 758) } }, columns: { left: [["pages"]], right: [["annotations", "findings"]] } }
|
|
1378
|
+
},
|
|
1379
|
+
{
|
|
1380
|
+
id: "P9-rail-segment-on-its-own-rail",
|
|
1381
|
+
title: "A rail segment dropped on its own rail changes nothing",
|
|
1382
|
+
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.",
|
|
1383
|
+
group: "gestures",
|
|
1384
|
+
state: win({ width: 700 }),
|
|
1385
|
+
gestures: g.drag("annotations", g.rail("left")),
|
|
1386
|
+
expectLayout: { items: { pages: { rail: "left", rect: r4(12, 0, 32, 32) }, annotations: { rail: "left", rect: r4(12, 32, 32, 32) }, findings: { rect: r4(388, 0, 300, 800) } }, rails: { left: ["pages", "annotations"], right: [] }, columns: { right: [["findings"]] } }
|
|
1387
|
+
},
|
|
1388
|
+
{
|
|
1389
|
+
id: "P9-to-the-other-rail",
|
|
1390
|
+
title: "A rail segment docks folded on the other rail",
|
|
1391
|
+
expect: `At ${BOTH_RAILS_W} px (narrow enough for both windows, A and B) the left column is folded by width into the left rail (Pages and Annotations), and Findings is folded by hand into the right rail, so both rails show. Annotations dropped on the right rail docks folded there, as a segment before Findings; Pages stays in the left rail.`,
|
|
1392
|
+
group: "gestures",
|
|
1393
|
+
requires: { rails: ["left", "right"] },
|
|
1394
|
+
state: win({ width: BOTH_RAILS_W, from: { findings: 1 } }),
|
|
1395
|
+
gestures: g.drag("annotations", g.rail("right")),
|
|
1396
|
+
expectLayout: { items: { pages: { rail: "left", rect: r4(12, 0, 32, 32) }, annotations: { rail: "right", folded: "hand", rect: r4(BOTH_RAILS_W - 44, 0, 32, 32) }, findings: { rail: "right", rect: r4(BOTH_RAILS_W - 44, 32, 32, 32) } }, rails: { left: ["pages"], right: ["annotations", "findings"] } }
|
|
1397
|
+
},
|
|
1398
|
+
{
|
|
1399
|
+
id: "P10-float-keeps-its-place-and-last-size",
|
|
1400
|
+
title: "A float keeps its place and last size",
|
|
1401
|
+
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.",
|
|
1402
|
+
group: "gestures",
|
|
1403
|
+
state: { ...win(), items: { ...win().items, annotations: { ...win().items.annotations, floatSizes: { column: { width: 300, height: 440 } } } } },
|
|
1404
|
+
gestures: [g.click("annotations", "float"), g.scroll(600)],
|
|
1405
|
+
expectLayout: { items: { annotations: { floating: true, edge: null, rect: r4(496, 0, 300, 440) }, pages: { rect: r4(12, 0, 300, 800) } }, floats: ["annotations"], columns: { left: [["pages"]] } },
|
|
1406
|
+
// Only a page can show that the float didn't scroll with the pages: it measures where the float is drawn.
|
|
1407
|
+
expectDom: [{ at: 1, item: "annotations", count: 1, rect: r4(496, 0, 300, 440), note: "the float is drawn where it was after the scroll" }]
|
|
1408
|
+
},
|
|
1409
|
+
{
|
|
1410
|
+
id: "P10-float-moves-by-the-pointer",
|
|
1411
|
+
title: "A float moves by exactly the pointer's distance",
|
|
1412
|
+
expect: "A float lifted and let go 40 px to the right lands exactly 40 px to the right.",
|
|
1413
|
+
group: "gestures",
|
|
1414
|
+
state: win({ floats: [{ id: "annotations", rect: r4(400, 100, 300, 440) }], columns: { left: [["pages"]], right: [["findings"]] } }),
|
|
1415
|
+
// Pressed at (50, 20) in the float; the pointer then moves from (450, 120) to (490, 120): 40 px right, no vertical move.
|
|
1416
|
+
gestures: [g.press("annotations", { x: 50, y: 20 }), g.at(490, 120), g.hold(), g.release()],
|
|
1417
|
+
expectLayout: { items: { annotations: { floating: true, rect: r4(440, 100, 300, 440) } } }
|
|
1418
|
+
},
|
|
1419
|
+
{
|
|
1420
|
+
id: "P10-float-lands-where-held",
|
|
1421
|
+
title: "A float lands where the pointer lets go, as it was held",
|
|
1422
|
+
expect: "A float let go over the middle of the pages area lands at the pointer minus where it was held, inside the stage.",
|
|
1423
|
+
group: "gestures",
|
|
1424
|
+
state: win({ floats: [{ id: "annotations", rect: r4(400, 100, 300, 440) }], columns: { left: [["pages"]], right: [["findings"]] } }),
|
|
1425
|
+
gestures: [g.press("annotations", { x: 50, y: 20 }), g.at(560, 400), g.hold(), g.release()],
|
|
1426
|
+
expectLayout: { items: { annotations: { floating: true, rect: r4(508, 360, 300, 440) } } }
|
|
1427
|
+
},
|
|
1428
|
+
{
|
|
1429
|
+
id: "P11-a-float-never-covers-chrome",
|
|
1430
|
+
title: "A float never covers chrome",
|
|
1431
|
+
expect: "Annotations let go just under the title bar, where its grab would put its top over the bar, lands below it, clear of every bar, and the slot never covers the title.",
|
|
1432
|
+
group: "gestures",
|
|
1433
|
+
state: withTitle(win()),
|
|
1434
|
+
// (600, 32): 4 px under the title bar; the grab (10 px down) would put the float's top at 22, over the bar.
|
|
1435
|
+
gestures: [g.press("annotations", { x: 20, y: 10 }), g.at(600, 32), g.hold(), g.release()],
|
|
1436
|
+
checkpoints: [{ at: 2, layout: { items: { annotations: { floating: true, rect: r4(528, 28, 280, 360) }, "window-title": { rect: r4(12, 0, 1096, 28) }, pages: { rect: r4(12, 28, 300, 772) } } }, note: "the preview, below the title bar" }],
|
|
1437
|
+
expectLayout: { items: { annotations: { floating: true, rect: r4(528, 28, 280, 360) }, "window-title": { rect: r4(12, 0, 1096, 28) }, pages: { rect: r4(12, 28, 300, 772) } } }
|
|
1438
|
+
},
|
|
1439
|
+
{
|
|
1440
|
+
id: "P11-big-stored-float-is-clamped",
|
|
1441
|
+
title: "A big stored float is clamped on read and still draggable",
|
|
1442
|
+
expect: "A stored float larger than the stage is drawn inside it, and lifting it still offers every drop target and shows a slot.",
|
|
1443
|
+
group: "gestures",
|
|
1444
|
+
state: win({ floats: [{ id: "annotations", rect: r4(0, 0, 1300, 1e3) }], columns: { left: [["pages"]], right: [["findings"]] } }),
|
|
1445
|
+
gestures: [g.press("annotations"), g.to(g.gap("left-0", 1)), g.hold()],
|
|
1446
|
+
expectLayout: { items: { pages: { rect: r4(12, 0, 300, 394) }, annotations: { edge: "left-0", rect: r4(12, 406, 300, 394) } } },
|
|
1447
|
+
expectDom: [{ select: "[data-drag-slot][data-drag-target]", count: 1, note: "a slot is shown" }]
|
|
1448
|
+
},
|
|
1449
|
+
{
|
|
1450
|
+
id: "P12-a-press-is-no-use",
|
|
1451
|
+
title: "A press is no use",
|
|
1452
|
+
expect: "A press on a header or grip, with no drag, reshapes nothing: no column swaps width, no fold changes.",
|
|
1453
|
+
group: "gestures",
|
|
1454
|
+
state: win({ width: 870 }),
|
|
1455
|
+
gestures: [g.press("pages"), g.release(), g.press("findings"), g.release()],
|
|
1456
|
+
expectLayout: { items: { pages: { rect: r4(12, 0, 220, 394) }, annotations: { rect: r4(12, 406, 220, 394) }, findings: { rect: r4(576, 0, 282, 800) } }, notes: { hasNot: ["content-changed"] } }
|
|
1457
|
+
},
|
|
1458
|
+
{
|
|
1459
|
+
id: "P12b-a-press-is-no-use-by-the-stored-ages",
|
|
1460
|
+
title: "A press is no use, by the stored ages",
|
|
1461
|
+
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.",
|
|
1462
|
+
group: "gestures",
|
|
1463
|
+
state: win({ width: 700, columns: { left: [["pages"]], right: [["findings"]] } }),
|
|
1464
|
+
gestures: [g.press("pages"), g.release(), g.key("Reload")],
|
|
1465
|
+
expectLayout: { items: { pages: { rail: "left" }, findings: { formKind: "open", edge: "right-0" } }, rails: { left: ["pages"], right: [] } },
|
|
1466
|
+
expectStored: { items: { pages: { used: 1 }, findings: { used: 3 } } }
|
|
1467
|
+
},
|
|
1468
|
+
{
|
|
1469
|
+
id: "P13-kinds",
|
|
1470
|
+
title: "Targets by kind: a panel",
|
|
1471
|
+
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 is refused ("Can't go here" at the pointer, nothing drawn on the bar), and a release there puts it back.`,
|
|
1472
|
+
group: "gestures",
|
|
1473
|
+
state: {
|
|
1474
|
+
...win(),
|
|
1475
|
+
edges: [...win().edges, { id: "tools-bar", side: "bottom", ring: 0, span: "full", accepts: ["group"], items: ["tools"], cross: { min: 28, max: 60 } }],
|
|
1476
|
+
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)] } } }
|
|
1477
|
+
},
|
|
1478
|
+
gestures: [g.press("pages", { x: 20, y: 10 }), g.at(560, 780), g.hold(), g.release()],
|
|
1479
|
+
checkpoints: [{ at: 2, layout: { items: { pages: null, tools: { edge: "tools-bar", rect: r4(12, 770, 120, 30) } }, order: { "tools-bar": ["tools"] } }, note: "refused: no target, the held item out of the layout" }],
|
|
1480
|
+
expectLayout: { items: { pages: { edge: "left-0", floating: false }, tools: { edge: "tools-bar", rect: r4(12, 770, 120, 30) } }, order: { "tools-bar": ["tools"] }, columns: { left: [["pages", "annotations"]] } },
|
|
1481
|
+
expectDom: [
|
|
1482
|
+
{ at: 2, select: "[data-drag-refusal]", count: 1, attr: { "data-drag-refusal": "refuse:tools-bar:start" }, note: "the bar's one refusal shows where the pointer is" },
|
|
1483
|
+
{ at: 2, select: "[data-drag-slot]", count: 0, note: "no slot anywhere" }
|
|
1484
|
+
]
|
|
1485
|
+
},
|
|
1486
|
+
{
|
|
1487
|
+
id: "P13-a-group-never-gets-panel-targets",
|
|
1488
|
+
title: "Targets by kind: a group",
|
|
1489
|
+
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.",
|
|
1490
|
+
group: "gestures",
|
|
1491
|
+
state: {
|
|
1492
|
+
...win(),
|
|
1493
|
+
edges: [...win().edges, { id: "tools-bar", side: "bottom", ring: 0, span: "full", accepts: ["group"], items: ["tools"], cross: { min: 28, max: 60 } }],
|
|
1494
|
+
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)] } } }
|
|
1495
|
+
},
|
|
1496
|
+
gestures: [g.press("tools"), g.at(160, 200), g.hold()],
|
|
1497
|
+
// No target: the committed layout with Tools' place left empty, and nothing else moved (Pages stays 379 tall).
|
|
1498
|
+
expectLayout: { items: { tools: null, pages: { rect: r4(12, 0, 300, 379) }, annotations: { rect: r4(12, 391, 300, 379) }, findings: { rect: r4(808, 0, 300, 770) } }, notes: { hasNot: ["content-changed"] } },
|
|
1499
|
+
expectDom: [{ select: "[data-drag-slot]", count: 0, note: "no slot for a group over a panel column" }]
|
|
1500
|
+
},
|
|
1501
|
+
{
|
|
1502
|
+
id: "P14-open-close-and-dock-at-default",
|
|
1503
|
+
title: "Close, open, and Dock at the default place",
|
|
1504
|
+
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.",
|
|
1505
|
+
group: "gestures",
|
|
1506
|
+
state: win(),
|
|
1507
|
+
gestures: [g.click("annotations", "close"), g.click("annotations", "open"), g.click("pages", "float"), g.click("pages", "dock")],
|
|
1508
|
+
checkpoints: [
|
|
1509
|
+
{ at: 0, layout: { items: { annotations: null, pages: { rect: r4(12, 0, 300, 800) } } }, note: "closed: out of the column" },
|
|
1510
|
+
{ at: 1, layout: { items: { annotations: { rect: r4(12, 406, 300, 394) }, pages: { rect: r4(12, 0, 300, 394) } } }, note: "opened: back below Pages" },
|
|
1511
|
+
{ at: 2, layout: { items: { pages: { floating: true, rect: r4(516, 0, 280, 360) }, annotations: { rect: r4(12, 0, 300, 800) } } }, note: "floated" }
|
|
1512
|
+
],
|
|
1513
|
+
expectLayout: { items: { pages: { rect: r4(12, 0, 300, 394) }, annotations: { rect: r4(12, 406, 300, 394) }, findings: { rect: r4(808, 0, 300, 800) } }, columns: { left: [["pages", "annotations"]], right: [["findings"]] } }
|
|
1514
|
+
},
|
|
1515
|
+
{
|
|
1516
|
+
id: "P14b-dock-after-a-column-id-is-reused",
|
|
1517
|
+
title: "Dock when a new column took a pruned column's id",
|
|
1518
|
+
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.",
|
|
1519
|
+
group: "gestures",
|
|
1520
|
+
state: win(),
|
|
1521
|
+
gestures: [g.moveTo("findings", g.gap("left-0", 2)), g.moveTo("pages", g.column("right", 0)), g.click("findings", "dock")],
|
|
1522
|
+
checkpoints: [{ at: 1, layout: { columns: { left: [["annotations", "findings"]], right: [["pages"]] } }, note: "Pages in a new right column" }],
|
|
1523
|
+
expectLayout: { columns: { left: [["annotations"]], right: [["findings"], ["pages"]] } }
|
|
1524
|
+
},
|
|
1525
|
+
{
|
|
1526
|
+
id: "P15-stops-for-the-keyboard",
|
|
1527
|
+
title: "Move to \u203A stops",
|
|
1528
|
+
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.`,
|
|
1529
|
+
group: "gestures",
|
|
1530
|
+
state: win(),
|
|
1531
|
+
gestures: [
|
|
1532
|
+
g.moveTo("annotations", g.column("left", 0)),
|
|
1533
|
+
g.click("annotations", "dock"),
|
|
1534
|
+
g.moveTo("annotations", g.gap("right-0", 0)),
|
|
1535
|
+
g.click("annotations", "dock"),
|
|
1536
|
+
g.moveTo("annotations", g.float),
|
|
1537
|
+
g.click("annotations", "dock")
|
|
1538
|
+
],
|
|
1539
|
+
checkpoints: [
|
|
1540
|
+
{ at: 0, layout: { items: { annotations: { edge: "left-1", rect: r4(12, 0, 220, 800) }, pages: { rect: r4(244, 0, 220, 800) } } }, note: "a new column at the left side's outer end" },
|
|
1541
|
+
{ at: 2, layout: { items: { annotations: { edge: "right-0", rect: r4(808, 0, 300, 394) }, findings: { rect: r4(808, 406, 300, 394) } } }, note: "before Findings" },
|
|
1542
|
+
{ at: 4, layout: { items: { annotations: { floating: true, rect: r4(516, 0, 280, 360) } } }, note: "the menu's Float: its last size, anchored to the content's top-right" }
|
|
1543
|
+
],
|
|
1544
|
+
expectLayout: { items: { pages: { rect: r4(12, 0, 300, 394) }, annotations: { rect: r4(12, 406, 300, 394) }, findings: { rect: r4(808, 0, 300, 800) } }, columns: { left: [["pages", "annotations"]], right: [["findings"]] } },
|
|
1545
|
+
expectStops: {
|
|
1546
|
+
item: "annotations",
|
|
1547
|
+
places: [
|
|
1548
|
+
{ kind: "rail", side: "left", ring: 0 },
|
|
1549
|
+
{ kind: "column", side: "left", ring: 0 },
|
|
1550
|
+
{ kind: "gap", edge: "left-0", zone: "start", at: 0 },
|
|
1551
|
+
{ kind: "column", side: "left", ring: 1 },
|
|
1552
|
+
{ kind: "rail", side: "right", ring: 0 },
|
|
1553
|
+
{ kind: "column", side: "right", ring: 0 },
|
|
1554
|
+
{ kind: "gap", edge: "right-0", zone: "start", at: 0 },
|
|
1555
|
+
{ kind: "gap", edge: "right-0", zone: "start", at: 1 },
|
|
1556
|
+
{ kind: "column", side: "right", ring: 1 },
|
|
1557
|
+
{ kind: "float" }
|
|
1558
|
+
]
|
|
1559
|
+
}
|
|
1560
|
+
},
|
|
1561
|
+
{
|
|
1562
|
+
id: "P15-rail-stop-then-dock",
|
|
1563
|
+
title: "Dock after a rail stop restores the item",
|
|
1564
|
+
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.`,
|
|
1565
|
+
group: "gestures",
|
|
1566
|
+
state: win(),
|
|
1567
|
+
gestures: [g.moveTo("annotations", g.rail("left", 0)), g.click("annotations", "dock"), g.moveTo("annotations", g.rail("right", 0)), g.click("annotations", "dock")],
|
|
1568
|
+
checkpoints: [{ at: 1, layout: { items: { pages: { rect: r4(12, 0, 300, 394) }, annotations: { formKind: "open", edge: "left-0", rect: r4(12, 406, 300, 394) } } }, note: "docked back, open" }],
|
|
1569
|
+
expectLayout: { items: { pages: { rect: r4(12, 0, 300, 394) }, annotations: { formKind: "open", edge: "left-0", rect: r4(12, 406, 300, 394) }, findings: { rect: r4(808, 0, 300, 800) } }, columns: { left: [["pages", "annotations"]], right: [["findings"]] } },
|
|
1570
|
+
expectStored: { items: { annotations: { from: null } } }
|
|
1571
|
+
},
|
|
1572
|
+
{
|
|
1573
|
+
id: "P16-first-px-left",
|
|
1574
|
+
title: "The window's first px is the new-column line",
|
|
1575
|
+
expect: "In a flush window with a column open on each side, Annotations held over the float mid-window, then moved to the window's first px on the left and rested there, lands in a new outer left column: the float never holds the window's edge.",
|
|
1576
|
+
group: "gestures",
|
|
1577
|
+
state: flush(),
|
|
1578
|
+
requires: { railDrop: "state" },
|
|
1579
|
+
gestures: [g.press("annotations", { x: 20, y: 10 }), g.at(FLUSH_W / 2, 400), g.hold(), g.at(0, 400), g.hold(), g.release()],
|
|
1580
|
+
expectLayout: { items: { annotations: { edge: "left-1", rect: r4(0, 0, 200, 900) }, pages: { rect: r4(200, 0, 200, 900) } }, columns: { left: [["annotations"], ["pages"]], right: [["findings"]] }, floats: [] }
|
|
1581
|
+
},
|
|
1582
|
+
{
|
|
1583
|
+
id: "P16-first-px-right",
|
|
1584
|
+
title: "The window's last px is the new-column line",
|
|
1585
|
+
expect: "The same on the right: Annotations rested over the float, then at the window's last px, lands in a new outer right column.",
|
|
1586
|
+
group: "gestures",
|
|
1587
|
+
state: flush(),
|
|
1588
|
+
requires: { railDrop: "state" },
|
|
1589
|
+
gestures: [g.press("annotations", { x: 20, y: 10 }), g.at(FLUSH_W / 2, 400), g.hold(), g.at(FLUSH_W - 1, 400), g.hold(), g.release()],
|
|
1590
|
+
expectLayout: { items: { annotations: { edge: "right-1", rect: r4(FLUSH_W - 200, 0, 200, 900) }, findings: { rect: r4(FLUSH_W - 400, 0, 200, 900) } }, columns: { left: [["pages"]], right: [["annotations"], ["findings"]] }, floats: [] }
|
|
1591
|
+
},
|
|
1592
|
+
{
|
|
1593
|
+
id: "P16-outer-reach-is-the-column-line",
|
|
1594
|
+
title: "The window's outer 10 px are the new-column line",
|
|
1595
|
+
expect: "With hand folds riding, the left rail can't take the drop while the left column stays open, so it owns none of the window's edge: Annotations let go 9 px in from the left lands in a new outer column, neither floating nor refused.",
|
|
1596
|
+
group: "gestures",
|
|
1597
|
+
state: flush(),
|
|
1598
|
+
requires: { railDrop: "state" },
|
|
1599
|
+
gestures: [g.press("annotations", { x: 20, y: 10 }), g.at(9, 400), g.hold(), g.release()],
|
|
1600
|
+
expectLayout: { items: { annotations: { edge: "left-1", rect: r4(0, 0, 200, 900) } }, columns: { left: [["annotations"], ["pages"]], right: [["findings"]] }, floats: [] }
|
|
1601
|
+
},
|
|
1602
|
+
{
|
|
1603
|
+
id: "P16-own-column-line-is-home",
|
|
1604
|
+
title: "A new column where the item's own column is, is home",
|
|
1605
|
+
expect: "Findings alone in the right column, rested over the float and then over its own column: a new column holding it alone there is the same move as home, so the release changes nothing.",
|
|
1606
|
+
group: "gestures",
|
|
1607
|
+
state: flush(),
|
|
1608
|
+
gestures: [g.press("findings", { x: 20, y: 10 }), g.at(FLUSH_W / 2, 400), g.hold(), g.at(1300, 400), g.hold(), g.release()],
|
|
1609
|
+
checkpoints: [{ at: 4, layout: { items: { findings: { edge: "right-0", rect: r4(FLUSH_W - 200, 0, 200, 900) } } }, note: "over its own column: back in its place" }],
|
|
1610
|
+
expectLayout: { items: { findings: { edge: "right-0", rect: r4(FLUSH_W - 200, 0, 200, 900) }, annotations: { edge: "left-0" } }, columns: { left: [["pages", "annotations"]], right: [["findings"]] }, floats: [] }
|
|
1611
|
+
}
|
|
1612
|
+
];
|
|
1613
|
+
|
|
1614
|
+
// src/testing/rows-windows.ts
|
|
1615
|
+
var shape = (columns, rails, atLeast) => ({
|
|
1616
|
+
columns: { left: columns.left ?? [], right: columns.right ?? [] },
|
|
1617
|
+
rails: { left: rails.left ?? [], right: rails.right ?? [] },
|
|
1618
|
+
...atLeast !== void 0 ? { contentAtLeast: { width: atLeast } } : {}
|
|
1619
|
+
});
|
|
1620
|
+
function at(id, title2, group3, spec, o, width, columns, rails, atLeast, walk) {
|
|
1621
|
+
const gestures = [];
|
|
1622
|
+
if (walk) for (let w = 1400 - walk; w > width; w -= walk) gestures.push(g.resizeWindow(w, 800));
|
|
1623
|
+
if (walk) gestures.push(g.resizeWindow(width, 800));
|
|
1624
|
+
return {
|
|
1625
|
+
id,
|
|
1626
|
+
title: title2,
|
|
1627
|
+
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)" : ""}.`,
|
|
1628
|
+
group: group3,
|
|
1629
|
+
state: winState(spec, { ...o, width: walk ? 1400 : width }),
|
|
1630
|
+
...walk ? {} : { settings: { stage: { w: width, h: 800 } } },
|
|
1631
|
+
gestures,
|
|
1632
|
+
expectLayout: shape(columns, rails, atLeast)
|
|
1633
|
+
};
|
|
1634
|
+
}
|
|
1635
|
+
var ALL_THREE = { left: ["pages", "annotations"], right: ["findings"] };
|
|
1636
|
+
var PAIR = { columns: { left: [["annotations"]], right: [["findings"]] } };
|
|
1637
|
+
function windowRows() {
|
|
1638
|
+
const rows = [];
|
|
1639
|
+
const A = (name, o, w, c, r5, min, walk) => {
|
|
1640
|
+
rows.push(at(`window-a-${name}-${w}${walk ? "-walk" : ""}`, `Window A, ${name}, ${w} px`, "window-a", WINDOW_A, o, w, c, r5, min, walk));
|
|
1641
|
+
};
|
|
1642
|
+
const B = (name, o, w, c, r5, min, walk) => {
|
|
1643
|
+
rows.push(at(`window-b-${name}-${w}${walk ? "-walk" : ""}`, `Window B, ${name}, ${w} px`, "window-b", WINDOW_B, o, w, c, r5, min, walk));
|
|
1644
|
+
};
|
|
1645
|
+
const open3 = { left: [ALL_THREE.left], right: [ALL_THREE.right] };
|
|
1646
|
+
const leftFolded3 = { right: [ALL_THREE.right] };
|
|
1647
|
+
const railsLeft3 = { left: ALL_THREE.left };
|
|
1648
|
+
const railsAll3 = { left: ALL_THREE.left, right: ALL_THREE.right };
|
|
1649
|
+
A("three", {}, 808, open3, {}, 320);
|
|
1650
|
+
A("three", {}, 807, leftFolded3, railsLeft3);
|
|
1651
|
+
A("three", {}, 620, leftFolded3, railsLeft3, 320);
|
|
1652
|
+
A("three", {}, 619, {}, railsAll3);
|
|
1653
|
+
A("three", {}, 576, {}, railsAll3);
|
|
1654
|
+
A("three", {}, 575, {}, railsAll3);
|
|
1655
|
+
A("three", {}, 807, leftFolded3, railsLeft3, void 0, 7);
|
|
1656
|
+
A("three", {}, 619, {}, railsAll3, void 0, 7);
|
|
1657
|
+
A("pair", PAIR, 808, { left: [["annotations"]], right: [["findings"]] }, {});
|
|
1658
|
+
A("pair", PAIR, 807, { right: [["findings"]] }, { left: ["annotations"] });
|
|
1659
|
+
A("pair", PAIR, 620, { right: [["findings"]] }, { left: ["annotations"] });
|
|
1660
|
+
A("pair", PAIR, 619, {}, { left: ["annotations"], right: ["findings"] });
|
|
1661
|
+
const bare = (w, c, r5) => {
|
|
1662
|
+
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, r5));
|
|
1663
|
+
};
|
|
1664
|
+
bare(760, open3, {});
|
|
1665
|
+
bare(759, leftFolded3, railsLeft3);
|
|
1666
|
+
bare(576, leftFolded3, railsLeft3);
|
|
1667
|
+
bare(575, {}, railsAll3);
|
|
1668
|
+
B("three", {}, 720, open3, {}, 320);
|
|
1669
|
+
B("three", {}, 719, leftFolded3, railsLeft3);
|
|
1670
|
+
B("three", {}, 552, leftFolded3, railsLeft3, 320);
|
|
1671
|
+
B("three", {}, 551, {}, railsAll3);
|
|
1672
|
+
B("three", {}, 520, {}, railsAll3);
|
|
1673
|
+
B("three", {}, 519, {}, railsAll3);
|
|
1674
|
+
B("three", {}, 552, leftFolded3, railsLeft3, void 0, 7);
|
|
1675
|
+
B("three", {}, 551, {}, railsAll3, void 0, 7);
|
|
1676
|
+
B("pair", PAIR, 720, { left: [["annotations"]], right: [["findings"]] }, {});
|
|
1677
|
+
B("pair", PAIR, 719, { right: [["findings"]] }, { left: ["annotations"] });
|
|
1678
|
+
B("pair", PAIR, 590, { right: [["findings"]] }, { left: ["annotations"] });
|
|
1679
|
+
B("pair", PAIR, 552, { right: [["findings"]] }, { left: ["annotations"] });
|
|
1680
|
+
B("pair", PAIR, 551, {}, { left: ["annotations"], right: ["findings"] });
|
|
1681
|
+
return rows;
|
|
1682
|
+
}
|
|
1683
|
+
var HAND = [
|
|
1684
|
+
{
|
|
1685
|
+
id: "window-a-hand-bar",
|
|
1686
|
+
title: "A panel folded by hand is a bar in place",
|
|
1687
|
+
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.",
|
|
1688
|
+
group: "window-a",
|
|
1689
|
+
state: winState(WINDOW_A, { from: { annotations: 1 } }),
|
|
1690
|
+
gestures: [],
|
|
1691
|
+
expectLayout: {
|
|
1692
|
+
items: { annotations: { formKind: "header", rect: { height: 30 } }, pages: { formKind: "open", rect: { height: 800 - 30 - 12 } } },
|
|
1693
|
+
columns: { left: [["pages", "annotations"]] }
|
|
1694
|
+
}
|
|
1695
|
+
},
|
|
1696
|
+
{
|
|
1697
|
+
id: "window-a-hand-ride",
|
|
1698
|
+
title: "A one-panel column folded by hand rides",
|
|
1699
|
+
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.",
|
|
1700
|
+
group: "window-a",
|
|
1701
|
+
state: winState(WINDOW_A, { handFold: "ride", from: { annotations: 1 }, columns: { left: [["pages"], ["annotations"]], right: [["findings"]] } }),
|
|
1702
|
+
gestures: [],
|
|
1703
|
+
// The rider is as wide as the column it rides (220), 30 tall, above Pages; the content is exactly what it is without the
|
|
1704
|
+
// rider's column at all (x 244, 632 wide), so it takes no width of its own.
|
|
1705
|
+
expectLayout: {
|
|
1706
|
+
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 } } },
|
|
1707
|
+
content: { x: 244, y: 0, width: 632, height: 800 },
|
|
1708
|
+
edges: { "left-0": { rect: { x: 12, y: 30, width: 220 } } }
|
|
1709
|
+
}
|
|
1710
|
+
},
|
|
1711
|
+
{
|
|
1712
|
+
id: "window-a-hand-all",
|
|
1713
|
+
title: "A column folded all by hand goes to the rail",
|
|
1714
|
+
expect: "A column whose members are all folded by hand goes to its side's rail.",
|
|
1715
|
+
group: "window-a",
|
|
1716
|
+
state: winState(WINDOW_A, { from: { pages: 1, annotations: 1 } }),
|
|
1717
|
+
gestures: [],
|
|
1718
|
+
expectLayout: { columns: { left: [] }, rails: { left: ["pages", "annotations"] } }
|
|
1719
|
+
}
|
|
1720
|
+
];
|
|
1721
|
+
var WINDOW_ROWS = [...windowRows(), ...HAND];
|
|
1722
|
+
|
|
1723
|
+
// src/testing/docks.ts
|
|
1724
|
+
function needsDocks(row2) {
|
|
1725
|
+
if (row2.requires?.docks !== void 0) return row2.requires.docks;
|
|
1726
|
+
const items = row2.state.items;
|
|
1727
|
+
const isPanel = (id) => items[id]?.kind === "panel";
|
|
1728
|
+
const panels = Object.keys(items).filter((id) => isPanel(id) && !items[id].closed);
|
|
1729
|
+
const start = solve(row2.state);
|
|
1730
|
+
const dockedAtStart = new Set(panels.filter((id) => !!start.items[id]?.edge && !start.items[id].floating));
|
|
1731
|
+
const takesPanels = (edge) => !!row2.state.edges.find((e) => e.id === edge)?.accepts.includes("panel");
|
|
1732
|
+
const expects = [row2.expectLayout, ...(row2.checkpoints ?? []).flatMap((c) => c.layout ? [c.layout] : [])];
|
|
1733
|
+
return expects.some(
|
|
1734
|
+
(e) => e.columns !== void 0 || e.rails !== void 0 || Object.values(e.order ?? {}).some((ids) => ids.some(isPanel)) || Object.entries(e.items ?? {}).some(([id, x]) => {
|
|
1735
|
+
if (!x || !isPanel(id)) return false;
|
|
1736
|
+
if (x.edge !== void 0 && x.edge !== null || x.zone !== void 0 || x.rail !== void 0 && x.rail !== null || x.rides || x.inMenu) return true;
|
|
1737
|
+
return dockedAtStart.has(id) && !x.floating && x.edge !== null && (x.rect !== void 0 || x.formKind !== void 0);
|
|
1738
|
+
}) || (e.content !== void 0 || e.contentAtLeast !== void 0) && dockedAtStart.size > 0 || Object.keys(e.edges ?? {}).some(takesPanels) || e.floats !== void 0 && panels.some((id) => !e.floats.includes(id))
|
|
1739
|
+
);
|
|
1740
|
+
}
|
|
1741
|
+
var withDocks = (rows) => rows.map((row2) => row2.requires?.docks === void 0 && needsDocks(row2) ? { ...row2, requires: { ...row2.requires, docks: true } } : row2);
|
|
1742
|
+
|
|
1743
|
+
// src/testing/host.ts
|
|
1744
|
+
import { center, contains as inside } from "@n-uf/placement";
|
|
1745
|
+
import { pickRank } from "@n-uf/placement";
|
|
1746
|
+
var LIFT_THRESHOLD = 4;
|
|
1747
|
+
var END_REACH = 24;
|
|
1748
|
+
function referencePick(list, point) {
|
|
1749
|
+
const holds = (r5) => point.x >= r5.x && point.x <= r5.x + r5.width && point.y >= r5.y && point.y <= r5.y + r5.height;
|
|
1750
|
+
const within = (o) => !o || point.x > o.x && point.x < o.x + o.width && point.y > o.y && point.y < o.y + o.height;
|
|
1751
|
+
const under = (t) => within(t.bounds) && (t.hits ? t.hits.some(holds) : holds(t.hit));
|
|
1752
|
+
const size = (t) => t.hits ? t.hits.reduce((s, r5) => s + r5.width * r5.height, 0) : t.hit.width * t.hit.height;
|
|
1753
|
+
let best = null;
|
|
1754
|
+
for (const t of list) {
|
|
1755
|
+
if (!under(t)) continue;
|
|
1756
|
+
if (!best || pickRank(t) < pickRank(best) || pickRank(t) === pickRank(best) && size(t) < size(best)) best = t;
|
|
1757
|
+
}
|
|
1758
|
+
return best;
|
|
1759
|
+
}
|
|
1760
|
+
function withRefusals(pick, refused) {
|
|
1761
|
+
if (refused.length === 0) return pick;
|
|
1762
|
+
const inert = refusalTargets(refused);
|
|
1763
|
+
return (list, point) => {
|
|
1764
|
+
const t = pick([...list, ...inert], point);
|
|
1765
|
+
return t !== null && isOneOf(list, t) ? t : null;
|
|
1766
|
+
};
|
|
1767
|
+
}
|
|
1768
|
+
var isOneOf = (list, x) => list.includes(x);
|
|
1769
|
+
function targetAt(list, place, item) {
|
|
1770
|
+
const id = placeTargetId(place, item);
|
|
1771
|
+
return (id ? list.find((t) => t.id === id) : void 0) ?? list.find((t) => t.place.kind === place.kind && (place.kind === "none" || id === null)) ?? null;
|
|
1772
|
+
}
|
|
1773
|
+
function resolvePlace(list, place, item, area_, pick = referencePick) {
|
|
1774
|
+
const t = targetAt(list, place, item);
|
|
1775
|
+
if (!t) return null;
|
|
1776
|
+
const big = t.hit.width > 1e6 || t.hit.height > 1e6;
|
|
1777
|
+
const candidates = [];
|
|
1778
|
+
if (big) {
|
|
1779
|
+
if (area_.content) candidates.push(center(area_.content));
|
|
1780
|
+
candidates.push(center(area_.stage));
|
|
1781
|
+
} else {
|
|
1782
|
+
candidates.push(center(t.hit));
|
|
1783
|
+
}
|
|
1784
|
+
const region = big ? area_.stage : t.hit;
|
|
1785
|
+
for (const fy of [0.5, 0.25, 0.75, 0.1, 0.9, 0.4, 0.6, 0, 1]) {
|
|
1786
|
+
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 });
|
|
1787
|
+
}
|
|
1788
|
+
const reach = candidates.filter((p) => inside(t.hit, p) && pick(list, p) === t);
|
|
1789
|
+
const own = area_.own ?? list.find((x) => x.place.kind === "home" && x.id.startsWith("home:"))?.hit;
|
|
1790
|
+
return (own ? reach.find((p) => !inside(own, p)) : void 0) ?? reach[0] ?? null;
|
|
1791
|
+
}
|
|
1792
|
+
function resizeStep(state, start, layout, g2) {
|
|
1793
|
+
if (g2.edge !== void 0) {
|
|
1794
|
+
if (g2.size === void 0) throw new Error("a resize of an edge needs a size");
|
|
1795
|
+
if (!state.edges.some((e) => e.id === g2.edge)) throw new Error(`no edge ${g2.edge}`);
|
|
1796
|
+
return { state: resizeEdge(state, g2.edge, g2.size), start };
|
|
1797
|
+
}
|
|
1798
|
+
if (g2.item !== void 0) {
|
|
1799
|
+
if (g2.size === void 0) throw new Error("a resize of an item needs a size");
|
|
1800
|
+
const id = g2.item;
|
|
1801
|
+
const d = g2.size;
|
|
1802
|
+
if (!Object.hasOwn(state.items, id)) throw new Error(`no item ${id}`);
|
|
1803
|
+
const edge = layout.items[id]?.edge;
|
|
1804
|
+
const side = edge ? layout.edges[edge]?.side : void 0;
|
|
1805
|
+
const axis = side === "top" || side === "bottom" ? "row" : "column";
|
|
1806
|
+
const grown = (s) => {
|
|
1807
|
+
const it = Object.hasOwn(s.items, id) ? s.items[id] : void 0;
|
|
1808
|
+
const forms = it?.forms[axis];
|
|
1809
|
+
if (!it || !forms || forms.length === 0) return s;
|
|
1810
|
+
const f0 = forms[0];
|
|
1811
|
+
const f2 = { ...f0, main: { ...f0.main, min: Math.max(0, f0.main.min + d), natural: Math.max(0, f0.main.natural + d) } };
|
|
1812
|
+
return { ...s, items: { ...s.items, [id]: { ...it, forms: { ...it.forms, [axis]: [f2, ...forms.slice(1)] } } } };
|
|
1813
|
+
};
|
|
1814
|
+
return { state: grown(state), start: grown(start) };
|
|
1815
|
+
}
|
|
1816
|
+
if (g2.point) {
|
|
1817
|
+
const stage = stageRect(g2.point.x, g2.point.y);
|
|
1818
|
+
return { state: { ...state, stage }, start: { ...start, stage } };
|
|
1819
|
+
}
|
|
1820
|
+
throw new Error("a resize needs an edge, an item or a point (the window's size)");
|
|
1821
|
+
}
|
|
1822
|
+
var stageRect = (w, h) => ({ x: 0, y: 0, width: w, height: h });
|
|
1823
|
+
function createReferenceHost(options = {}) {
|
|
1824
|
+
const endReach = options.endReach ?? END_REACH;
|
|
1825
|
+
const lifted0 = options.lift ?? LIFT_THRESHOLD;
|
|
1826
|
+
const defaultGrab = options.grab ?? { x: 8, y: 8 };
|
|
1827
|
+
const pick = options.pick ?? referencePick;
|
|
1828
|
+
let start = null;
|
|
1829
|
+
let state = null;
|
|
1830
|
+
let committed = null;
|
|
1831
|
+
let frozen = false;
|
|
1832
|
+
let alt = false;
|
|
1833
|
+
let session = null;
|
|
1834
|
+
const now = () => {
|
|
1835
|
+
if (!state) throw new Error("nothing is loaded");
|
|
1836
|
+
return state;
|
|
1837
|
+
};
|
|
1838
|
+
const prev = () => {
|
|
1839
|
+
if (!committed) throw new Error("nothing is loaded");
|
|
1840
|
+
return committed;
|
|
1841
|
+
};
|
|
1842
|
+
const settle = (s) => {
|
|
1843
|
+
committed = solve(s, { previous: prev() });
|
|
1844
|
+
state = s;
|
|
1845
|
+
};
|
|
1846
|
+
const preview = () => {
|
|
1847
|
+
if (!session?.lifted) return prev();
|
|
1848
|
+
const t = session.target;
|
|
1849
|
+
if (t) return t.after(session.point, session.grab).layout;
|
|
1850
|
+
const l = prev();
|
|
1851
|
+
const { [session.item]: _held, ...items } = l.items;
|
|
1852
|
+
return { ...l, items, floats: l.floats.filter((f2) => f2 !== session.item) };
|
|
1853
|
+
};
|
|
1854
|
+
const aim = () => ({ stage: now().stage, content: prev().content });
|
|
1855
|
+
function liftNow(s) {
|
|
1856
|
+
s.lifted = true;
|
|
1857
|
+
s.list = targets(now(), s.item, { previous: prev(), endReach });
|
|
1858
|
+
s.pickAt = withRefusals(pick, refusals(now(), s.item, { previous: prev(), endReach }));
|
|
1859
|
+
s.target = s.pickAt(s.list, s.point);
|
|
1860
|
+
}
|
|
1861
|
+
function move(g2) {
|
|
1862
|
+
const s = session;
|
|
1863
|
+
if (!s) return;
|
|
1864
|
+
if (g2.place) {
|
|
1865
|
+
if (!s.lifted) liftNow(s);
|
|
1866
|
+
const p = resolvePlace(s.list, g2.place, s.item, { ...aim(), ...prev().items[s.item] ? { own: prev().items[s.item].rect } : {} }, s.pickAt);
|
|
1867
|
+
if (!p) throw new Error(`no point reaches the target at ${JSON.stringify(g2.place)} (targets: ${s.list.map((t) => t.id).join(", ") || "none"})`);
|
|
1868
|
+
s.point = p;
|
|
1869
|
+
s.target = s.pickAt(s.list, p);
|
|
1870
|
+
return;
|
|
1871
|
+
}
|
|
1872
|
+
if (!g2.point) throw new Error("a move needs a point or a place");
|
|
1873
|
+
s.point = { x: g2.point.x, y: g2.point.y };
|
|
1874
|
+
if (!s.lifted && Math.hypot(s.point.x - s.down.x, s.point.y - s.down.y) > lifted0) liftNow(s);
|
|
1875
|
+
else if (s.lifted) s.target = s.pickAt(s.list, s.point);
|
|
1876
|
+
}
|
|
1877
|
+
function press(g2) {
|
|
1878
|
+
session = null;
|
|
1879
|
+
const id = g2.item;
|
|
1880
|
+
if (!id) throw new Error("a press needs an item");
|
|
1881
|
+
const s = now();
|
|
1882
|
+
const it = Object.hasOwn(s.items, id) ? s.items[id] : void 0;
|
|
1883
|
+
if (!it) throw new Error(`no item ${id}`);
|
|
1884
|
+
const l = prev().items[id];
|
|
1885
|
+
if (it.fixed || it.closed || !l || l.inMenu || frozen && !alt) return;
|
|
1886
|
+
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) };
|
|
1887
|
+
const down = { x: l.rect.x + grab.x, y: l.rect.y + grab.y };
|
|
1888
|
+
if (l.floating) settle(raiseFloat(s, id));
|
|
1889
|
+
session = { item: id, grab, down, point: down, lifted: false, list: [], pickAt: pick, target: null };
|
|
1890
|
+
}
|
|
1891
|
+
function release() {
|
|
1892
|
+
const s = session;
|
|
1893
|
+
session = null;
|
|
1894
|
+
if (!s || !s.lifted) return;
|
|
1895
|
+
const t = s.target;
|
|
1896
|
+
if (!t || t.place.kind === "home" || t.place.kind === "none") return;
|
|
1897
|
+
const after = t.after(s.point, s.grab);
|
|
1898
|
+
state = after.state;
|
|
1899
|
+
committed = after.layout;
|
|
1900
|
+
}
|
|
1901
|
+
function matchStop(g2) {
|
|
1902
|
+
const id = g2.item;
|
|
1903
|
+
const list = stops(now(), id, { previous: prev(), endReach });
|
|
1904
|
+
const t = targetAt(list, g2.place, id);
|
|
1905
|
+
if (!t) throw new Error(`${JSON.stringify(g2.place)} is not one of ${id}'s stops (${list.map((x) => x.id).join(", ") || "none"})`);
|
|
1906
|
+
return t;
|
|
1907
|
+
}
|
|
1908
|
+
function click(g2) {
|
|
1909
|
+
const id = g2.item;
|
|
1910
|
+
if (!id) throw new Error("a click needs an item");
|
|
1911
|
+
const s = now();
|
|
1912
|
+
const it = Object.hasOwn(s.items, id) ? s.items[id] : void 0;
|
|
1913
|
+
if (!it) throw new Error(`no item ${id}`);
|
|
1914
|
+
const moves = g2.place !== void 0 || g2.key === "float" || g2.key === "dock";
|
|
1915
|
+
if (moves && frozen && !alt) return;
|
|
1916
|
+
if (g2.place) {
|
|
1917
|
+
const stop = matchStop(g2);
|
|
1918
|
+
const after = stop.place.kind === "float" ? (() => {
|
|
1919
|
+
const s2 = markUsed(floatAt(s, id), id);
|
|
1920
|
+
return { state: s2, layout: solve(s2, { previous: prev() }) };
|
|
1921
|
+
})() : stop.after(center(s.stage));
|
|
1922
|
+
state = after.state;
|
|
1923
|
+
committed = after.layout;
|
|
1924
|
+
return;
|
|
1925
|
+
}
|
|
1926
|
+
switch (g2.key) {
|
|
1927
|
+
case void 0: {
|
|
1928
|
+
if (it.closed) settle(markUsed(openItem(s, id), id));
|
|
1929
|
+
else if ((it.from ?? 0) > 0) settle(markUsed(foldItem(s, id, false), id));
|
|
1930
|
+
else if (prev().items[id]?.floating) settle(raiseFloat(s, id));
|
|
1931
|
+
return;
|
|
1932
|
+
}
|
|
1933
|
+
case "use":
|
|
1934
|
+
return settle(markUsed(s, id));
|
|
1935
|
+
case "open":
|
|
1936
|
+
return settle(markUsed(openItem(s, id), id));
|
|
1937
|
+
case "close":
|
|
1938
|
+
return settle(closeItem(s, id));
|
|
1939
|
+
case "fold":
|
|
1940
|
+
return settle(markUsed(foldItem(s, id, true), id));
|
|
1941
|
+
case "unfold":
|
|
1942
|
+
return settle(markUsed(foldItem(s, id, false), id));
|
|
1943
|
+
case "float":
|
|
1944
|
+
return settle(markUsed(floatAt(s, id), id));
|
|
1945
|
+
case "dock": {
|
|
1946
|
+
const place = homeFor(s, id, start);
|
|
1947
|
+
if (!place) throw new Error(`the loaded state puts ${id} nowhere`);
|
|
1948
|
+
return settle(markUsed(dockHome(s, id, start), id));
|
|
1949
|
+
}
|
|
1950
|
+
default:
|
|
1951
|
+
throw new Error(`no control ${g2.key}`);
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
function resizeNow(g2) {
|
|
1955
|
+
const next = resizeStep(now(), start, prev(), g2);
|
|
1956
|
+
start = next.start;
|
|
1957
|
+
settle(next.state);
|
|
1958
|
+
}
|
|
1959
|
+
function reload() {
|
|
1960
|
+
session = null;
|
|
1961
|
+
const data = JSON.parse(JSON.stringify(storeDockState(now())));
|
|
1962
|
+
const read = readDockState(data, { ...start, stage: now().stage });
|
|
1963
|
+
state = read.state;
|
|
1964
|
+
committed = solve(read.state);
|
|
1965
|
+
}
|
|
1966
|
+
return {
|
|
1967
|
+
load(s, settings = {}) {
|
|
1968
|
+
const stage = settings.stage ? stageRect(settings.stage.w, settings.stage.h) : s.stage;
|
|
1969
|
+
const loaded = settings.stage ? { ...s, stage } : s;
|
|
1970
|
+
start = loaded;
|
|
1971
|
+
state = loaded;
|
|
1972
|
+
committed = solve(loaded);
|
|
1973
|
+
frozen = settings.frozen === true;
|
|
1974
|
+
alt = false;
|
|
1975
|
+
session = null;
|
|
1976
|
+
},
|
|
1977
|
+
perform(g2) {
|
|
1978
|
+
switch (g2.type) {
|
|
1979
|
+
case "press":
|
|
1980
|
+
return press(g2);
|
|
1981
|
+
case "move":
|
|
1982
|
+
return move(g2);
|
|
1983
|
+
case "release":
|
|
1984
|
+
return release();
|
|
1985
|
+
case "key":
|
|
1986
|
+
if (g2.key === "Escape") session = null;
|
|
1987
|
+
else if (g2.key === "Alt") alt = true;
|
|
1988
|
+
else if (g2.key === "Alt:up") alt = false;
|
|
1989
|
+
else if (g2.key === "Reload") reload();
|
|
1990
|
+
else throw new Error(`no key ${g2.key}`);
|
|
1991
|
+
return;
|
|
1992
|
+
case "click":
|
|
1993
|
+
return click(g2);
|
|
1994
|
+
case "resize":
|
|
1995
|
+
return resizeNow(g2);
|
|
1996
|
+
case "scroll":
|
|
1997
|
+
case "hold":
|
|
1998
|
+
return;
|
|
1999
|
+
default:
|
|
2000
|
+
throw new Error(`no gesture ${String(g2.type)}`);
|
|
2001
|
+
}
|
|
2002
|
+
},
|
|
2003
|
+
layout: preview,
|
|
2004
|
+
state: now,
|
|
2005
|
+
stored: () => storeDockState(now()),
|
|
2006
|
+
stops: (item) => stops(now(), item, { previous: prev(), endReach }).map((t) => t.place),
|
|
2007
|
+
pick,
|
|
2008
|
+
drag: () => session ? { item: session.item, lifted: session.lifted, target: session.target?.id ?? null, point: session.point, grab: session.grab } : null
|
|
2009
|
+
};
|
|
2010
|
+
}
|
|
2011
|
+
|
|
2012
|
+
// src/testing/ids.ts
|
|
2013
|
+
function idRenames(ids) {
|
|
2014
|
+
const entries = Object.entries(ids ?? {});
|
|
2015
|
+
if (entries.length === 0) return { to: (id) => id, from: (id) => id, active: false };
|
|
2016
|
+
const back = /* @__PURE__ */ new Map();
|
|
2017
|
+
const fwd = new Map(entries);
|
|
2018
|
+
for (const [row2, host] of entries) {
|
|
2019
|
+
if (back.has(host)) throw new Error(`the id map names the host id "${host}" for both "${back.get(host)}" and "${row2}"`);
|
|
2020
|
+
back.set(host, row2);
|
|
2021
|
+
}
|
|
2022
|
+
return { to: (id) => fwd.get(id) ?? id, from: (id) => back.get(id) ?? id, active: true };
|
|
2023
|
+
}
|
|
2024
|
+
var rekey = (r5, f2, v = (x) => x) => {
|
|
2025
|
+
const out = {};
|
|
2026
|
+
for (const [k, x] of Object.entries(r5)) out[f2(k)] = v(x, k);
|
|
2027
|
+
return out;
|
|
2028
|
+
};
|
|
2029
|
+
function mapState(s, f2) {
|
|
2030
|
+
return {
|
|
2031
|
+
...s,
|
|
2032
|
+
edges: s.edges.map((e) => ({ ...e, id: f2(e.id), items: e.items.map(f2) })),
|
|
2033
|
+
items: rekey(s.items, f2, (it) => ({ ...it, id: f2(it.id) })),
|
|
2034
|
+
floats: s.floats.map((x) => ({ ...x, id: f2(x.id) }))
|
|
2035
|
+
};
|
|
2036
|
+
}
|
|
2037
|
+
function mapPlace(p, f2) {
|
|
2038
|
+
return p.kind === "gap" || p.kind === "side" ? { ...p, edge: f2(p.edge) } : p;
|
|
2039
|
+
}
|
|
2040
|
+
function mapGesture(g2, f2) {
|
|
2041
|
+
return { ...g2, ...g2.item !== void 0 ? { item: f2(g2.item) } : {}, ...g2.edge !== void 0 ? { edge: f2(g2.edge) } : {}, ...g2.place ? { place: mapPlace(g2.place, f2) } : {} };
|
|
2042
|
+
}
|
|
2043
|
+
var mapNote = (n, f2) => {
|
|
2044
|
+
const out = { ...n };
|
|
2045
|
+
if ("id" in n && typeof n.id === "string") out.id = f2(n.id);
|
|
2046
|
+
if ("edge" in n && typeof n.edge === "string") out.edge = f2(n.edge);
|
|
2047
|
+
return out;
|
|
2048
|
+
};
|
|
2049
|
+
var mapFit = (fit, f2) => ({
|
|
2050
|
+
...fit,
|
|
2051
|
+
items: fit.items.map((it) => ({ ...it, id: f2(it.id) })),
|
|
2052
|
+
menu: fit.menu ? { ...fit.menu, items: fit.menu.items.map(f2) } : null,
|
|
2053
|
+
notes: fit.notes.map((n) => "id" in n ? { ...n, id: f2(n.id) } : n),
|
|
2054
|
+
...fit.steps ? { steps: fit.steps.map((s) => ({ ...s, id: f2(s.id) })) } : {}
|
|
2055
|
+
});
|
|
2056
|
+
function mapLayout(l, f2) {
|
|
2057
|
+
const edge = (e) => ({
|
|
2058
|
+
...e,
|
|
2059
|
+
stack: mapFit(e.stack, f2),
|
|
2060
|
+
free: mapFit(e.free, f2),
|
|
2061
|
+
menu: e.menu ? { ...e.menu, items: e.menu.items.map(f2) } : null,
|
|
2062
|
+
items: (e.items ?? []).map(f2),
|
|
2063
|
+
tabs: e.tabs.map(f2),
|
|
2064
|
+
...e.rides !== void 0 ? { rides: f2(e.rides) } : {}
|
|
2065
|
+
});
|
|
2066
|
+
const rails = {};
|
|
2067
|
+
for (const side of ["left", "right"]) {
|
|
2068
|
+
const r5 = l.rails[side];
|
|
2069
|
+
if (r5) rails[side] = { ...r5, segments: r5.segments.map((s) => ({ ...s, id: f2(s.id), edge: f2(s.edge) })) };
|
|
2070
|
+
}
|
|
2071
|
+
return {
|
|
2072
|
+
...l,
|
|
2073
|
+
items: rekey(l.items, f2, (it) => ({ ...it, ...it.edge !== void 0 ? { edge: f2(it.edge) } : {}, ...it.rides !== void 0 ? { rides: f2(it.rides) } : {} })),
|
|
2074
|
+
edges: rekey(l.edges, f2, edge),
|
|
2075
|
+
floats: l.floats.map(f2),
|
|
2076
|
+
rails,
|
|
2077
|
+
notes: l.notes.map((n) => mapNote(n, f2))
|
|
2078
|
+
};
|
|
2079
|
+
}
|
|
2080
|
+
function mapStored(s, f2) {
|
|
2081
|
+
return {
|
|
2082
|
+
...s,
|
|
2083
|
+
edges: s.edges.map((e) => ({ ...e, id: f2(e.id), items: e.items.map(f2) })),
|
|
2084
|
+
floats: s.floats.map((x) => ({ ...x, id: f2(x.id) })),
|
|
2085
|
+
items: rekey(s.items, f2)
|
|
2086
|
+
};
|
|
2087
|
+
}
|
|
2088
|
+
|
|
2089
|
+
// src/testing/run.ts
|
|
2090
|
+
var DEFAULT_TOLERANCE = 0.5;
|
|
2091
|
+
var defaultItemSelector = (id) => `[data-dock-item="${id.replace(/["\\]/g, "\\$&")}"]`;
|
|
2092
|
+
var KEYS = ["x", "y", "width", "height"];
|
|
2093
|
+
var px = (n) => String(Math.round(n * 100) / 100);
|
|
2094
|
+
var say = (r5) => `${px(r5.x)},${px(r5.y)} ${px(r5.width)}x${px(r5.height)}`;
|
|
2095
|
+
function rectIssues(what, want, got, tol) {
|
|
2096
|
+
const out = [];
|
|
2097
|
+
for (const k of KEYS) {
|
|
2098
|
+
const w = want[k];
|
|
2099
|
+
if (w !== void 0 && !(Math.abs(got[k] - w) <= tol)) out.push(`${what} ${k} is ${px(got[k])}, expected ${px(w)} (${say(got)})`);
|
|
2100
|
+
}
|
|
2101
|
+
return out;
|
|
2102
|
+
}
|
|
2103
|
+
function dockedIn(l, edge) {
|
|
2104
|
+
const e = l.edges[edge];
|
|
2105
|
+
const column2 = e?.side === "left" || e?.side === "right";
|
|
2106
|
+
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);
|
|
2107
|
+
}
|
|
2108
|
+
function columnsOf(l, side) {
|
|
2109
|
+
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);
|
|
2110
|
+
}
|
|
2111
|
+
function itemIssues(id, want, l, tol) {
|
|
2112
|
+
const got = l.items[id];
|
|
2113
|
+
if (want === null) return got ? [`${id} is drawn (${say(got.rect)}), expected it out of the layout`] : [];
|
|
2114
|
+
if (!got) return [`${id} is not in the layout`];
|
|
2115
|
+
const out = [];
|
|
2116
|
+
if (want.rect) out.push(...rectIssues(id, want.rect, got.rect, tol));
|
|
2117
|
+
if (want.formKind !== void 0 && got.formKind !== want.formKind) out.push(`${id} is ${got.formKind}, expected ${want.formKind}`);
|
|
2118
|
+
if (want.form !== void 0 && got.form !== want.form) out.push(`${id} is form ${got.form}, expected ${want.form}`);
|
|
2119
|
+
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"}`);
|
|
2120
|
+
if (want.zone !== void 0 && got.zone !== want.zone) out.push(`${id} is in the ${got.zone ?? "no"} zone, expected ${want.zone}`);
|
|
2121
|
+
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"}`);
|
|
2122
|
+
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"}`);
|
|
2123
|
+
if (want.rail !== void 0 && (got.rail ?? null) !== want.rail) out.push(`${id} is in ${got.rail ?? "no"} rail, expected ${want.rail ?? "no"} rail`);
|
|
2124
|
+
if (want.folded !== void 0 && (got.folded ?? null) !== want.folded) out.push(`${id} is folded ${got.folded ?? "not"}, expected ${want.folded ?? "not"}`);
|
|
2125
|
+
if (want.rides !== void 0 && (got.rides ?? null) !== want.rides) out.push(`${id} rides ${got.rides ?? "nothing"}, expected ${want.rides ?? "nothing"}`);
|
|
2126
|
+
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"}`);
|
|
2127
|
+
return out;
|
|
2128
|
+
}
|
|
2129
|
+
function edgeIssues(id, want, l, tol) {
|
|
2130
|
+
const got = l.edges[id];
|
|
2131
|
+
if (want === null) return got ? [`edge ${id} is in the layout, expected none`] : [];
|
|
2132
|
+
if (!got) return [`edge ${id} is not in the layout`];
|
|
2133
|
+
const out = [];
|
|
2134
|
+
if (want.rect) out.push(...rectIssues(`edge ${id}`, want.rect, got.rect, tol));
|
|
2135
|
+
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)}`);
|
|
2136
|
+
if (want.tabs && got.tabs.join() !== want.tabs.join()) out.push(`edge ${id} tabs are [${got.tabs.join(", ")}], expected [${want.tabs.join(", ")}]`);
|
|
2137
|
+
if (want.menu !== void 0) {
|
|
2138
|
+
const have = got.menu ? got.menu.items : null;
|
|
2139
|
+
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"}`);
|
|
2140
|
+
}
|
|
2141
|
+
return out;
|
|
2142
|
+
}
|
|
2143
|
+
var codes = (notes) => [...new Set(notes.map((n) => n.code))];
|
|
2144
|
+
function layoutIssues(want, layout) {
|
|
2145
|
+
const tol = want.tolerance ?? DEFAULT_TOLERANCE;
|
|
2146
|
+
const out = [];
|
|
2147
|
+
for (const [id, w] of Object.entries(want.items ?? {})) out.push(...itemIssues(id, w, layout, tol));
|
|
2148
|
+
for (const [id, w] of Object.entries(want.edges ?? {})) out.push(...edgeIssues(id, w, layout, tol));
|
|
2149
|
+
if (want.content) out.push(...rectIssues("content", want.content, layout.content, tol));
|
|
2150
|
+
if (want.contentAtLeast) {
|
|
2151
|
+
const { width, height } = want.contentAtLeast;
|
|
2152
|
+
if (width !== void 0 && layout.content.width < width - tol) out.push(`content is ${px(layout.content.width)} wide, expected at least ${px(width)}`);
|
|
2153
|
+
if (height !== void 0 && layout.content.height < height - tol) out.push(`content is ${px(layout.content.height)} tall, expected at least ${px(height)}`);
|
|
2154
|
+
}
|
|
2155
|
+
for (const [edge, ids] of Object.entries(want.order ?? {})) {
|
|
2156
|
+
const have = dockedIn(layout, edge);
|
|
2157
|
+
if (have.join() !== ids.join()) out.push(`${edge} holds [${have.join(", ")}], expected [${ids.join(", ")}]`);
|
|
2158
|
+
}
|
|
2159
|
+
for (const side of ["left", "right"]) {
|
|
2160
|
+
const w = want.columns?.[side];
|
|
2161
|
+
if (w) {
|
|
2162
|
+
const have = columnsOf(layout, side);
|
|
2163
|
+
if (JSON.stringify(have) !== JSON.stringify(w)) out.push(`${side} columns are ${JSON.stringify(have)}, expected ${JSON.stringify(w)}`);
|
|
2164
|
+
}
|
|
2165
|
+
const r5 = want.rails?.[side];
|
|
2166
|
+
if (r5) {
|
|
2167
|
+
const have = (layout.rails[side]?.segments ?? []).map((s) => s.id);
|
|
2168
|
+
if (have.join() !== r5.join()) out.push(`${side} rail holds [${have.join(", ")}], expected [${r5.join(", ")}]`);
|
|
2169
|
+
}
|
|
2170
|
+
}
|
|
2171
|
+
if (want.floats && layout.floats.join() !== want.floats.join()) out.push(`floats are [${layout.floats.join(", ")}], expected [${want.floats.join(", ")}]`);
|
|
2172
|
+
if (want.notes) {
|
|
2173
|
+
const have = codes(layout.notes);
|
|
2174
|
+
for (const c of want.notes.has ?? []) if (!have.includes(c)) out.push(`no ${c} note (notes: ${have.join(", ") || "none"})`);
|
|
2175
|
+
for (const c of want.notes.hasNot ?? []) if (have.includes(c)) out.push(`unexpected ${c} note`);
|
|
2176
|
+
if (want.notes.none && have.length > 0) out.push(`unexpected notes: ${have.join(", ")}`);
|
|
2177
|
+
}
|
|
2178
|
+
return out;
|
|
2179
|
+
}
|
|
2180
|
+
var labelOf = (c) => c.note ?? (c.select ? `${c.select}${c.attr ? ` ${JSON.stringify(c.attr)}` : ""}` : `root ${JSON.stringify(c.attr ?? {})}`);
|
|
2181
|
+
function domIssues(check, root) {
|
|
2182
|
+
const out = [];
|
|
2183
|
+
const els = check.select ? Array.from(root.querySelectorAll(check.select)) : [root];
|
|
2184
|
+
const n = els.length;
|
|
2185
|
+
if (check.select !== void 0 || check.count !== void 0) {
|
|
2186
|
+
const c = check.count;
|
|
2187
|
+
if (typeof c === "number") {
|
|
2188
|
+
if (n !== c) out.push(`${n} elements match ${check.select ?? "the root"}, expected ${c}`);
|
|
2189
|
+
} else if (c) {
|
|
2190
|
+
if (c.min !== void 0 && n < c.min) out.push(`${n} elements match ${check.select ?? "the root"}, expected at least ${c.min}`);
|
|
2191
|
+
if (c.max !== void 0 && n > c.max) out.push(`${n} elements match ${check.select ?? "the root"}, expected at most ${c.max}`);
|
|
2192
|
+
} else if (n === 0) out.push(`nothing matches ${check.select}`);
|
|
2193
|
+
}
|
|
2194
|
+
if (check.rect) {
|
|
2195
|
+
const tol = check.tolerance ?? DEFAULT_TOLERANCE;
|
|
2196
|
+
const origin = root.getBoundingClientRect?.();
|
|
2197
|
+
for (const el of els) {
|
|
2198
|
+
const box = el.getBoundingClientRect?.();
|
|
2199
|
+
if (!box || !origin) {
|
|
2200
|
+
out.push(`${check.select ?? "the root"} has no bounding rect to read`);
|
|
2201
|
+
continue;
|
|
2202
|
+
}
|
|
2203
|
+
const got = { x: box.left - origin.left, y: box.top - origin.top, width: box.width, height: box.height };
|
|
2204
|
+
out.push(...rectIssues(check.select ?? "the root", check.rect, got, tol));
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
for (const [name, want] of Object.entries(check.attr ?? {})) {
|
|
2208
|
+
for (const el of els) {
|
|
2209
|
+
const got = el.getAttribute(name);
|
|
2210
|
+
if (want === null ? got !== null : got !== want) out.push(`${check.select ?? "the root"} has ${name}=${got === null ? "(none)" : `"${got}"`}, expected ${want === null ? "none" : `"${want}"`}`);
|
|
2211
|
+
}
|
|
2212
|
+
}
|
|
2213
|
+
return out;
|
|
2214
|
+
}
|
|
2215
|
+
function storedIssues(want, stored) {
|
|
2216
|
+
const out = [];
|
|
2217
|
+
const data = stored;
|
|
2218
|
+
for (const [id, fields] of Object.entries(want.items ?? {})) {
|
|
2219
|
+
const have = data?.items && Object.hasOwn(data.items, id) ? data.items[id] : void 0;
|
|
2220
|
+
if (!have) {
|
|
2221
|
+
out.push(`the stored form has no item ${id}`);
|
|
2222
|
+
continue;
|
|
2223
|
+
}
|
|
2224
|
+
for (const [k, v] of Object.entries(fields)) {
|
|
2225
|
+
const got = Object.hasOwn(have, k) ? have[k] : null;
|
|
2226
|
+
if (got !== v) out.push(`stored ${id}.${k} is ${JSON.stringify(got)}, expected ${JSON.stringify(v)}`);
|
|
2227
|
+
}
|
|
2228
|
+
}
|
|
2229
|
+
const json = JSON.stringify(stored);
|
|
2230
|
+
for (const s of want.absent ?? []) if (json.includes(s)) out.push(`the stored form contains "${s}"`);
|
|
2231
|
+
return out;
|
|
2232
|
+
}
|
|
2233
|
+
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);
|
|
2234
|
+
var gestureWords = (g2, i) => {
|
|
2235
|
+
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);
|
|
2236
|
+
return `gesture ${i + 1} (${g2.type}${bits.length ? ` ${bits.join(" ")}` : ""})`;
|
|
2237
|
+
};
|
|
2238
|
+
var words = (e) => e instanceof Error ? e.message : String(e);
|
|
2239
|
+
var isWindowResize = (g2) => g2.type === "resize" && g2.edge === void 0 && g2.item === void 0 && g2.point !== void 0;
|
|
2240
|
+
function narrowestStage(row2) {
|
|
2241
|
+
const start = row2.settings?.stage ? row2.settings.stage.w : row2.state.stage.width;
|
|
2242
|
+
return Math.min(start, ...row2.gestures.filter(isWindowResize).map((g2) => g2.point.x));
|
|
2243
|
+
}
|
|
2244
|
+
function* steps(row2, host) {
|
|
2245
|
+
const failures = [];
|
|
2246
|
+
const skipped = [];
|
|
2247
|
+
const n = row2.gestures.length;
|
|
2248
|
+
const last = n - 1;
|
|
2249
|
+
const narrowest = narrowestStage(row2);
|
|
2250
|
+
if (row2.requires?.docks && host.dockMinWidth !== void 0 && narrowest < host.dockMinWidth) {
|
|
2251
|
+
return { ok: true, failures, skipped: [`the row: it needs docked panels at ${px(narrowest)} px, and the host docks from ${px(host.dockMinWidth)} px`] };
|
|
2252
|
+
}
|
|
2253
|
+
const fail = (lines, when) => {
|
|
2254
|
+
for (const l2 of lines) failures.push(`${row2.id}${when}: ${l2}`);
|
|
2255
|
+
};
|
|
2256
|
+
const range = (what, at2) => {
|
|
2257
|
+
if (at2 === void 0) return;
|
|
2258
|
+
if (!Number.isInteger(at2) || at2 < 0 || at2 >= n) fail([`${what} is at gesture ${at2}, but the row has ${n} gestures (0 to ${last})`], "");
|
|
2259
|
+
};
|
|
2260
|
+
const ids = idRenames(host.ids);
|
|
2261
|
+
const itemSelector = (id) => host.itemSelector ? host.itemSelector(ids.to(id)) : defaultItemSelector(ids.to(id));
|
|
2262
|
+
const aimed = (c) => c.item !== void 0 && c.select === void 0 ? { ...c, select: itemSelector(c.item) } : c;
|
|
2263
|
+
for (const cp of row2.checkpoints ?? []) range("a checkpoint", cp.at);
|
|
2264
|
+
for (const c of row2.expectDom ?? []) {
|
|
2265
|
+
range(`the DOM check ${labelOf(aimed(c))}`, c.at);
|
|
2266
|
+
if (c.item !== void 0 && c.select !== void 0) fail([`the DOM check ${labelOf(c)} has both item and select`], "");
|
|
2267
|
+
}
|
|
2268
|
+
range("the stops check", row2.expectStops?.at);
|
|
2269
|
+
if (failures.length > 0) return { ok: false, failures, skipped };
|
|
2270
|
+
function* must(f2) {
|
|
2271
|
+
const r5 = yield f2;
|
|
2272
|
+
if (!r5.ok) throw r5.error;
|
|
2273
|
+
return r5.value;
|
|
2274
|
+
}
|
|
2275
|
+
function* layoutOf(when) {
|
|
2276
|
+
const r5 = yield () => host.layout();
|
|
2277
|
+
if (r5.ok) return ids.active ? mapLayout(r5.value, ids.from) : r5.value;
|
|
2278
|
+
fail([`the host couldn't give its layout: ${words(r5.error)}`], when);
|
|
2279
|
+
return null;
|
|
2280
|
+
}
|
|
2281
|
+
function* dom(index) {
|
|
2282
|
+
for (const c of row2.expectDom ?? []) {
|
|
2283
|
+
if ((c.at ?? last) !== index) continue;
|
|
2284
|
+
const check = aimed(c);
|
|
2285
|
+
const root = host.root ? yield* must(() => host.root()) : null;
|
|
2286
|
+
if (!root) {
|
|
2287
|
+
skipped.push(labelOf(check));
|
|
2288
|
+
continue;
|
|
2289
|
+
}
|
|
2290
|
+
fail(domIssues(check, root), ` after gesture ${index + 1} (${labelOf(check)})`);
|
|
2291
|
+
}
|
|
2292
|
+
}
|
|
2293
|
+
function* stops2(index) {
|
|
2294
|
+
const s = row2.expectStops;
|
|
2295
|
+
if (!s || (s.at ?? last) !== index) return;
|
|
2296
|
+
if (!host.stops) {
|
|
2297
|
+
skipped.push(`the stops of ${s.item}`);
|
|
2298
|
+
return;
|
|
2299
|
+
}
|
|
2300
|
+
const have = (yield* must(() => host.stops(ids.to(s.item)))).map((p) => placeKey(mapPlace(p, ids.from)));
|
|
2301
|
+
const want = s.places.map(placeKey);
|
|
2302
|
+
if (have.join("\n") !== want.join("\n")) fail([`${s.item}'s stops are
|
|
2303
|
+
${have.join("\n ")}
|
|
2304
|
+
expected
|
|
2305
|
+
${want.join("\n ")}`], "");
|
|
2306
|
+
}
|
|
2307
|
+
const loaded = yield () => host.load(ids.active ? mapState(row2.state, ids.to) : row2.state, row2.settings);
|
|
2308
|
+
if (!loaded.ok) {
|
|
2309
|
+
fail([`the host couldn't load the state: ${words(loaded.error)}`], "");
|
|
2310
|
+
return { ok: false, failures, skipped };
|
|
2311
|
+
}
|
|
2312
|
+
let stage = row2.settings?.stage ? { x: 0, y: 0, width: row2.settings.stage.w, height: row2.settings.stage.h } : row2.state.stage;
|
|
2313
|
+
const inStage = (g2) => {
|
|
2314
|
+
if (g2.type !== "move" || !g2.point) return g2;
|
|
2315
|
+
return { ...g2, point: { x: Math.min(stage.x + stage.width, Math.max(stage.x, g2.point.x)), y: Math.min(stage.y + stage.height, Math.max(stage.y, g2.point.y)) } };
|
|
2316
|
+
};
|
|
2317
|
+
for (let i = 0; i < n; i++) {
|
|
2318
|
+
const g2 = row2.gestures[i];
|
|
2319
|
+
const sent = inStage(g2);
|
|
2320
|
+
if (isWindowResize(g2)) stage = { x: 0, y: 0, width: g2.point.x, height: g2.point.y };
|
|
2321
|
+
const done = yield () => host.perform(ids.active ? mapGesture(sent, ids.to) : sent);
|
|
2322
|
+
if (!done.ok) {
|
|
2323
|
+
fail([`${gestureWords(g2, i)} failed: ${words(done.error)}`], "");
|
|
2324
|
+
return { ok: false, failures, skipped };
|
|
2325
|
+
}
|
|
2326
|
+
for (const cp of row2.checkpoints ?? []) {
|
|
2327
|
+
if (cp.at !== i || !cp.layout) continue;
|
|
2328
|
+
const l2 = yield* layoutOf(` after ${gestureWords(g2, i)}`);
|
|
2329
|
+
if (l2) fail(layoutIssues(cp.layout, l2), ` after ${gestureWords(g2, i)}${cp.note ? ` (${cp.note})` : ""}`);
|
|
2330
|
+
}
|
|
2331
|
+
yield* dom(i);
|
|
2332
|
+
yield* stops2(i);
|
|
2333
|
+
}
|
|
2334
|
+
if (last < 0) {
|
|
2335
|
+
yield* dom(-1);
|
|
2336
|
+
yield* stops2(-1);
|
|
2337
|
+
}
|
|
2338
|
+
const l = yield* layoutOf("");
|
|
2339
|
+
if (l) fail(layoutIssues(row2.expectLayout, l), "");
|
|
2340
|
+
if (row2.expectStored) {
|
|
2341
|
+
if (!host.stored) skipped.push("the stored form");
|
|
2342
|
+
else {
|
|
2343
|
+
const r5 = yield () => host.stored();
|
|
2344
|
+
if (r5.ok) fail(storedIssues(row2.expectStored, ids.active ? mapStored(r5.value, ids.from) : r5.value), " (the stored form)");
|
|
2345
|
+
else fail([`the host couldn't give its stored form: ${words(r5.error)}`], "");
|
|
2346
|
+
}
|
|
2347
|
+
}
|
|
2348
|
+
return { ok: failures.length === 0, failures, skipped };
|
|
2349
|
+
}
|
|
2350
|
+
function runCase(row2, host) {
|
|
2351
|
+
const run = steps(row2, host);
|
|
2352
|
+
let r5 = run.next();
|
|
2353
|
+
while (!r5.done) {
|
|
2354
|
+
let out;
|
|
2355
|
+
try {
|
|
2356
|
+
out = { ok: true, value: r5.value() };
|
|
2357
|
+
} catch (error) {
|
|
2358
|
+
out = { ok: false, error };
|
|
2359
|
+
}
|
|
2360
|
+
r5 = run.next(out);
|
|
2361
|
+
}
|
|
2362
|
+
return r5.value;
|
|
2363
|
+
}
|
|
2364
|
+
async function runCaseAsync(row2, host) {
|
|
2365
|
+
const run = steps(row2, host);
|
|
2366
|
+
let r5 = run.next();
|
|
2367
|
+
while (!r5.done) {
|
|
2368
|
+
let out;
|
|
2369
|
+
try {
|
|
2370
|
+
out = { ok: true, value: await r5.value() };
|
|
2371
|
+
} catch (error) {
|
|
2372
|
+
out = { ok: false, error };
|
|
2373
|
+
}
|
|
2374
|
+
r5 = run.next(out);
|
|
2375
|
+
}
|
|
2376
|
+
return r5.value;
|
|
2377
|
+
}
|
|
2378
|
+
function runCases(rows, makeHost) {
|
|
2379
|
+
return rows.map((row2) => ({ id: row2.id, result: runCase(row2, makeHost()) }));
|
|
2380
|
+
}
|
|
2381
|
+
async function runCasesAsync(rows, makeHost, options = {}) {
|
|
2382
|
+
const out = [];
|
|
2383
|
+
for (const row2 of rows) {
|
|
2384
|
+
const result = await runCaseAsync(row2, await makeHost());
|
|
2385
|
+
options.onResult?.(row2.id, result);
|
|
2386
|
+
out.push({ id: row2.id, result });
|
|
2387
|
+
}
|
|
2388
|
+
return out;
|
|
2389
|
+
}
|
|
2390
|
+
|
|
2391
|
+
// src/testing/landing.ts
|
|
2392
|
+
import { rect } from "@n-uf/placement";
|
|
2393
|
+
var HAND_TRAIL = 48;
|
|
2394
|
+
var HAND_TRAIL_BEFORE_HOP = 56;
|
|
2395
|
+
var HAND_MARGIN = 6;
|
|
2396
|
+
function handBound(gap2, beforeHop = false) {
|
|
2397
|
+
return Math.max(beforeHop ? HAND_TRAIL_BEFORE_HOP : HAND_TRAIL, gap2 / 2 + HAND_MARGIN);
|
|
2398
|
+
}
|
|
2399
|
+
var NEAR_REACH = 12;
|
|
2400
|
+
var HAND_FAST = 0.375;
|
|
2401
|
+
var gapTo = (r5, p) => Math.hypot(Math.max(r5.x - p.x, 0, p.x - (r5.x + r5.width)), Math.max(r5.y - p.y, 0, p.y - (r5.y + r5.height)));
|
|
2402
|
+
var touches = (a, b) => a.x <= b.x + b.width && b.x <= a.x + a.width && a.y <= b.y + b.height && b.y <= a.y + a.height;
|
|
2403
|
+
var lo = (r5, axis) => axis === "x" ? r5.x : r5.y;
|
|
2404
|
+
var len = (r5, axis) => axis === "x" ? r5.width : r5.height;
|
|
2405
|
+
var outside = (a, b, p) => Math.max(a - p, 0, p - b);
|
|
2406
|
+
function handRule(row2, before, stretchPositions) {
|
|
2407
|
+
const previous = before ?? solve(row2.state);
|
|
2408
|
+
const own = previous.items[row2.item];
|
|
2409
|
+
const press = row2.path[0];
|
|
2410
|
+
const options = { previous, ...own ? { grab: { x: press.x - own.rect.x, y: press.y - own.rect.y } } : {}, ...stretchPositions ? { stretchPositions } : {} };
|
|
2411
|
+
const bySpot = /* @__PURE__ */ new Map();
|
|
2412
|
+
const regionsOf = (spot) => {
|
|
2413
|
+
let r5 = bySpot.get(spot);
|
|
2414
|
+
if (!r5) bySpot.set(spot, r5 = lanes(row2.state, row2.item, spot ? { ...options, spot } : options));
|
|
2415
|
+
return r5;
|
|
2416
|
+
};
|
|
2417
|
+
return {
|
|
2418
|
+
/**
|
|
2419
|
+
* The grab's share along the lane, as the landing model takes it: of the item's longer side along the lane when it
|
|
2420
|
+
* lies along it, else the middle (a sliding landing starts at the pointer less the share of its own length).
|
|
2421
|
+
*/
|
|
2422
|
+
share(axis) {
|
|
2423
|
+
if (!own) return 0.5;
|
|
2424
|
+
const long = own.rect.width >= own.rect.height ? "x" : "y";
|
|
2425
|
+
const size = len(own.rect, long);
|
|
2426
|
+
const g2 = long === "x" ? press.x - own.rect.x : press.y - own.rect.y;
|
|
2427
|
+
return axis === long && size > 0 && Number.isFinite(g2) ? Math.min(1, Math.max(0, g2 / size)) : 0.5;
|
|
2428
|
+
},
|
|
2429
|
+
/** The lane `lane` as drawn with `spot` held; as seen when the lane has no such spot (another host's ids). */
|
|
2430
|
+
laneOf(lane, spot) {
|
|
2431
|
+
const held = regionsOf(spot).lanes.find((l) => l.id === lane);
|
|
2432
|
+
return held?.spots.some((s) => s.id === spot) ? held : regionsOf("").lanes.find((l) => l.id === lane);
|
|
2433
|
+
},
|
|
2434
|
+
/**
|
|
2435
|
+
* `g`, px: the gap along the lane between the facing edges of the two adjacent landings the pointer `p` lies between
|
|
2436
|
+
* (a sliding spot's landings span its range); 0 where the pointer lies over a landing, or outside all of them.
|
|
2437
|
+
*/
|
|
2438
|
+
gapAt(lane, p) {
|
|
2439
|
+
const spans = lane.spots.map((s) => {
|
|
2440
|
+
const w = len(s.landing, lane.axis);
|
|
2441
|
+
return s.slide ? [Math.min(s.slide.from, s.slide.to), Math.max(s.slide.from, s.slide.to) + w] : [lo(s.landing, lane.axis), lo(s.landing, lane.axis) + w];
|
|
2442
|
+
}).sort((x, y) => x[0] - y[0]);
|
|
2443
|
+
let end = -Infinity;
|
|
2444
|
+
for (const [a, b] of spans) {
|
|
2445
|
+
if (Number.isFinite(end) && end < p && p < a) return a - end;
|
|
2446
|
+
end = Math.max(end, b);
|
|
2447
|
+
}
|
|
2448
|
+
return 0;
|
|
2449
|
+
}
|
|
2450
|
+
};
|
|
2451
|
+
}
|
|
2452
|
+
var worstTrail = (frames) => Math.max(0, ...frames.filter((f2) => f2.moving && f2.region === "lane" && f2.landing).map((f2) => gapTo(f2.landing, f2.point)));
|
|
2453
|
+
function homeIssues(item, before, after) {
|
|
2454
|
+
const a = before.items[item];
|
|
2455
|
+
const b = after.items[item];
|
|
2456
|
+
if (!a) return [`${item} is not in the layout at the press`];
|
|
2457
|
+
if (!b) return [`${item} is not in the layout after the release`];
|
|
2458
|
+
const out = [];
|
|
2459
|
+
const where = (it) => it.floating ? "floating" : it.inMenu ? `in ${it.edge ?? "no"} menu` : it.edge ?? "nowhere";
|
|
2460
|
+
if (where(a) !== where(b)) out.push(`${item} ends ${where(b)}, not where it was (${where(a)})`);
|
|
2461
|
+
else if (a.edge && dockedIn(before, a.edge).join(",") !== dockedIn(after, a.edge).join(","))
|
|
2462
|
+
out.push(`${a.edge} holds ${dockedIn(after, a.edge).join(", ")}, not ${dockedIn(before, a.edge).join(", ")} as at the press`);
|
|
2463
|
+
const r0 = a.rect;
|
|
2464
|
+
const r1 = b.rect;
|
|
2465
|
+
if (Math.max(Math.abs(r0.x - r1.x), Math.abs(r0.y - r1.y), Math.abs(r0.width - r1.width), Math.abs(r0.height - r1.height)) > 0.5)
|
|
2466
|
+
out.push(`${item} is at ${Math.round(r1.x)},${Math.round(r1.y)} ${Math.round(r1.width)}x${Math.round(r1.height)}, not where it was (${Math.round(r0.x)},${Math.round(r0.y)} ${Math.round(r0.width)}x${Math.round(r0.height)})`);
|
|
2467
|
+
return out;
|
|
2468
|
+
}
|
|
2469
|
+
function nearGuideIssues(row2, frames, before, stretchPositions) {
|
|
2470
|
+
const out = [];
|
|
2471
|
+
let seen;
|
|
2472
|
+
const rectOf = (lane) => {
|
|
2473
|
+
if (!seen) {
|
|
2474
|
+
const previous = before ?? solve(row2.state);
|
|
2475
|
+
const own = previous.items[row2.item];
|
|
2476
|
+
const press = row2.path[0];
|
|
2477
|
+
seen = lanes(row2.state, row2.item, { previous, ...own ? { grab: { x: press.x - own.rect.x, y: press.y - own.rect.y } } : {}, ...stretchPositions ? { stretchPositions } : {} });
|
|
2478
|
+
}
|
|
2479
|
+
return seen.lanes.find((l) => l.id === lane)?.rect;
|
|
2480
|
+
};
|
|
2481
|
+
for (const f2 of frames) {
|
|
2482
|
+
if (!f2.guides || f2.guides.length === 0) continue;
|
|
2483
|
+
for (const lane of new Set(f2.guides.map((g2) => g2.lane))) {
|
|
2484
|
+
const holds = f2.lane === lane && (f2.region === "lane" || f2.region === "refused");
|
|
2485
|
+
const r5 = f2.region === "open" && !holds && f2.pending !== lane ? rectOf(lane) : void 0;
|
|
2486
|
+
if (holds || f2.pending === lane || r5 && gapTo(r5, f2.point) <= NEAR_REACH + 0.5) continue;
|
|
2487
|
+
out.push(`at ${Math.round(f2.point.x)},${Math.round(f2.point.y)}: a Near guide of ${lane} over ${f2.region}${f2.lane ? ` in ${f2.lane}` : ""}, where the pointer neither holds ${lane}, nor is pending in it, nor is in open space within ${NEAR_REACH} px of it`);
|
|
2488
|
+
break;
|
|
2489
|
+
}
|
|
2490
|
+
if (out.length >= 4) break;
|
|
2491
|
+
}
|
|
2492
|
+
return out;
|
|
2493
|
+
}
|
|
2494
|
+
function guideSwitches(frames) {
|
|
2495
|
+
let n = 0;
|
|
2496
|
+
let was;
|
|
2497
|
+
for (const f2 of frames) {
|
|
2498
|
+
if (!f2.moving || !f2.guides || f2.guides.length === 0) continue;
|
|
2499
|
+
const now = [...new Set(f2.guides.map((g2) => g2.lane))].sort().join("+");
|
|
2500
|
+
if (was !== void 0 && now !== was) n++;
|
|
2501
|
+
was = now;
|
|
2502
|
+
}
|
|
2503
|
+
return n;
|
|
2504
|
+
}
|
|
2505
|
+
function landingIssues(row2, frames, layout, before, stretchPositions) {
|
|
2506
|
+
const out = [];
|
|
2507
|
+
const m = row2.moving;
|
|
2508
|
+
if (frames.length === 0) return ["no frames"];
|
|
2509
|
+
const hand = m?.hand ? handRule(row2, before, stretchPositions) : void 0;
|
|
2510
|
+
if (m)
|
|
2511
|
+
for (const [i, f2] of frames.entries()) {
|
|
2512
|
+
if (!f2.moving) continue;
|
|
2513
|
+
const at2 = `at ${Math.round(f2.point.x)},${Math.round(f2.point.y)}`;
|
|
2514
|
+
const next = frames[i + 1];
|
|
2515
|
+
const beforeHop = !!next && next.region === "lane" && f2.region === "lane" && next.lane === f2.lane && next.spot !== f2.spot;
|
|
2516
|
+
const bound = beforeHop && m.trailBeforeHop !== void 0 ? m.trailBeforeHop : m.trail;
|
|
2517
|
+
if (m.lane !== void 0 && (f2.region !== "lane" || f2.lane !== m.lane)) out.push(`${at2}: ${f2.region}${f2.lane ? ` in ${f2.lane}` : ""}, not the lane ${m.lane}`);
|
|
2518
|
+
if (m.notLanes && f2.lane && m.notLanes.includes(f2.lane)) out.push(`${at2}: held ${f2.lane}`);
|
|
2519
|
+
if (m.notRegions && m.notRegions.includes(f2.region)) out.push(`${at2}: ${f2.region}`);
|
|
2520
|
+
for (const g2 of m.noGuideIn ? f2.guides ?? [] : []) if (m.noGuideIn.some((r5) => touches(g2.rect, r5))) out.push(`${at2}: the guide ${g2.id} where nothing lands`);
|
|
2521
|
+
if (bound !== void 0 && f2.region === "lane" && f2.landing && gapTo(f2.landing, f2.point) > bound + 0.5) out.push(`${at2}: the landing ${Math.round(gapTo(f2.landing, f2.point))} px from the pointer (at most ${bound}${beforeHop ? ", the frame before a hop" : ""})`);
|
|
2522
|
+
if (hand && f2.region === "lane" && f2.lane && f2.spot && f2.landing) {
|
|
2523
|
+
const lane = hand.laneOf(f2.lane, f2.spot);
|
|
2524
|
+
if (lane) {
|
|
2525
|
+
const p = lane.axis === "x" ? f2.point.x : f2.point.y;
|
|
2526
|
+
const l = f2.landing;
|
|
2527
|
+
const gap2 = hand.gapAt(lane, p);
|
|
2528
|
+
const limit = handBound(gap2, beforeHop);
|
|
2529
|
+
const d = gapTo(l, f2.point);
|
|
2530
|
+
if (d > limit + 0.5) out.push(`${at2}: the landing ${Math.round(d)} px from the pointer (at most ${Number(limit.toFixed(1))}${beforeHop ? ", the frame before a hop" : ""}${gap2 > 0 ? `, between landings ${Math.round(gap2)} px apart` : ""})`);
|
|
2531
|
+
const prev = frames[i - 1];
|
|
2532
|
+
const quick = !!prev && Math.hypot(f2.point.x - prev.point.x, f2.point.y - prev.point.y) / Math.max(f2.t - prev.t, 1e-6) > HAND_FAST;
|
|
2533
|
+
if (!quick) {
|
|
2534
|
+
const a = lo(l, lane.axis);
|
|
2535
|
+
const w0 = len(l, lane.axis);
|
|
2536
|
+
const here = outside(a, a + w0, p);
|
|
2537
|
+
let worst;
|
|
2538
|
+
for (const s of lane.spots) {
|
|
2539
|
+
const w = len(s.landing, lane.axis);
|
|
2540
|
+
const start = s.slide ? Math.min(Math.max(p - hand.share(lane.axis) * w, Math.min(s.slide.from, s.slide.to)), Math.max(s.slide.from, s.slide.to)) : lo(s.landing, lane.axis);
|
|
2541
|
+
if (Math.min(a + w0, start + w) - Math.max(a, start) > -0.5) continue;
|
|
2542
|
+
const there = outside(start, start + w, p);
|
|
2543
|
+
if (here - there > 2 * HAND_MARGIN + 0.5 && (!worst || here - there > worst.by)) worst = { by: here - there, id: s.id, there };
|
|
2544
|
+
}
|
|
2545
|
+
if (worst) out.push(`${at2}: the landing ${Math.round(here)} px from the pointer along ${f2.lane}, not the nearest landing (${worst.id}, ${Math.round(worst.there)} px)`);
|
|
2546
|
+
}
|
|
2547
|
+
} else {
|
|
2548
|
+
const limit = handBound(0, beforeHop);
|
|
2549
|
+
const d = gapTo(f2.landing, f2.point);
|
|
2550
|
+
if (d > limit + 0.5) out.push(`${at2}: the landing ${Math.round(d)} px from the pointer (at most ${limit}${beforeHop ? ", the frame before a hop" : ""}; the lane ${f2.lane} is not one lanes() gives)`);
|
|
2551
|
+
}
|
|
2552
|
+
}
|
|
2553
|
+
if (out.length >= 4) break;
|
|
2554
|
+
}
|
|
2555
|
+
if (m?.nearGuides) out.push(...nearGuideIssues(row2, frames, before, stretchPositions));
|
|
2556
|
+
if (m?.guideSwitches !== void 0) {
|
|
2557
|
+
const n = guideSwitches(frames);
|
|
2558
|
+
if (n > m.guideSwitches) out.push(`the guides switch lane ${n} times along the path (at most ${m.guideSwitches})`);
|
|
2559
|
+
}
|
|
2560
|
+
const last = frames.at(-1);
|
|
2561
|
+
if (row2.end) {
|
|
2562
|
+
if (last.region !== row2.end.region) out.push(`the last frame is ${last.region}, not ${row2.end.region}`);
|
|
2563
|
+
if (row2.end.pending !== void 0 && (last.pending ?? null) !== row2.end.pending) out.push(`the last frame has ${last.pending ?? "no lane"} pending, not ${row2.end.pending ?? "no lane"}`);
|
|
2564
|
+
if (row2.end.landing) {
|
|
2565
|
+
if (!last.landing) out.push("the last frame lands nowhere");
|
|
2566
|
+
else for (const k of ["x", "y", "width", "height"]) if (row2.end.landing[k] !== void 0 && Math.abs(last.landing[k] - row2.end.landing[k]) > 0.5) out.push(`the last frame's landing ${k} is ${Math.round(last.landing[k])}, not ${row2.end.landing[k]}`);
|
|
2567
|
+
}
|
|
2568
|
+
if (row2.end.lane !== void 0 && last.lane !== row2.end.lane) out.push(`the last frame holds ${last.lane ?? "no lane"}, not ${row2.end.lane ?? "no lane"}`);
|
|
2569
|
+
if (row2.end.spot !== void 0 && last.spot !== row2.end.spot) out.push(`the last frame's spot is ${last.spot ?? "none"}, not ${row2.end.spot}`);
|
|
2570
|
+
}
|
|
2571
|
+
if (row2.layout) out.push(...layoutIssues(row2.layout, layout));
|
|
2572
|
+
if (row2.home) out.push(...homeIssues(row2.item, before ?? solve(row2.state), layout));
|
|
2573
|
+
return out;
|
|
2574
|
+
}
|
|
2575
|
+
async function runLandingCases(rows, host) {
|
|
2576
|
+
const out = [];
|
|
2577
|
+
for (const row2 of rows) {
|
|
2578
|
+
try {
|
|
2579
|
+
const played = await host.play(row2);
|
|
2580
|
+
const { frames, layout, before } = played;
|
|
2581
|
+
const issues = landingIssues(row2, frames, layout, before, played.stretchPositions);
|
|
2582
|
+
const over = row2.moving?.trailOverSlow;
|
|
2583
|
+
if (over) {
|
|
2584
|
+
const slow = await host.play({ ...row2, speed: over.slow });
|
|
2585
|
+
const fast = worstTrail(frames);
|
|
2586
|
+
const bound = worstTrail(slow.frames) + over.by;
|
|
2587
|
+
if (fast > bound + 0.5) issues.push(`the landing trails the pointer by ${Math.round(fast)} px, more than a slow hand's ${Math.round(bound - over.by)} px plus ${over.by}`);
|
|
2588
|
+
}
|
|
2589
|
+
const failures = issues.map((l) => `${row2.id}: ${l}`);
|
|
2590
|
+
out.push({ id: row2.id, ok: failures.length === 0, failures, skipped: null });
|
|
2591
|
+
} catch (e) {
|
|
2592
|
+
out.push({ id: row2.id, ok: false, failures: [`${row2.id}: ${e instanceof Error ? e.message : String(e)}`], skipped: null });
|
|
2593
|
+
}
|
|
2594
|
+
}
|
|
2595
|
+
return out;
|
|
2596
|
+
}
|
|
2597
|
+
var SAMPLE = 8;
|
|
2598
|
+
function createLandingHost(o) {
|
|
2599
|
+
return {
|
|
2600
|
+
play(row2) {
|
|
2601
|
+
const s = row2.state;
|
|
2602
|
+
const previous = solve(s);
|
|
2603
|
+
const own = previous.items[row2.item];
|
|
2604
|
+
if (!own) throw new Error(`no item ${row2.item}`);
|
|
2605
|
+
const press = row2.path[0];
|
|
2606
|
+
const grab = { x: press.x - own.rect.x, y: press.y - own.rect.y };
|
|
2607
|
+
const laneOptions = { previous, grab, ...o.stretchPositions ? { stretchPositions: o.stretchPositions } : {} };
|
|
2608
|
+
const regions = lanes(s, row2.item, laneOptions);
|
|
2609
|
+
const regionsFor = (spot2) => lanes(s, row2.item, { ...laneOptions, spot: spot2 });
|
|
2610
|
+
const home = regions.lanes.flatMap((l) => l.spots.filter((x) => x.home).map((x) => ({ lane: l.id, spot: x.id })))[0];
|
|
2611
|
+
const model = o.landing({ regions, regionsFor, grab, floatLanding: (p) => regions.float?.after(p, grab).layout.items[row2.item]?.rect ?? null, ...home ? { home } : {}, placeGuides: "near" });
|
|
2612
|
+
const frames = [];
|
|
2613
|
+
const play = (p, t2, moving) => {
|
|
2614
|
+
const f2 = model.update(p, t2);
|
|
2615
|
+
frames.push({ t: t2, point: p, moving, region: f2.region, lane: f2.lane, spot: f2.spot, landing: f2.landing, room: f2.room, ...f2.guides ? { guides: f2.guides } : {}, ...f2.pending ? { pending: f2.pending } : {} });
|
|
2616
|
+
};
|
|
2617
|
+
let t = 0;
|
|
2618
|
+
let at2 = press;
|
|
2619
|
+
for (let i = 1; i < row2.path.length; i++) {
|
|
2620
|
+
const a = row2.path[i - 1];
|
|
2621
|
+
const b = row2.path[i];
|
|
2622
|
+
const n = Math.max(1, Math.ceil(Math.hypot(b.x - a.x, b.y - a.y) / row2.speed / SAMPLE));
|
|
2623
|
+
for (let k = 1; k <= n; k++) play(at2 = { x: a.x + (b.x - a.x) * k / n, y: a.y + (b.y - a.y) * k / n }, t += SAMPLE, true);
|
|
2624
|
+
}
|
|
2625
|
+
for (let r5 = SAMPLE; r5 <= (row2.rest ?? 0); r5 += SAMPLE) play(at2, t += SAMPLE, false);
|
|
2626
|
+
const out = model.release(at2, t);
|
|
2627
|
+
const spot = out?.kind === "spot" ? [...regions.lanes, ...regionsFor(out.spot).lanes].flatMap((l) => l.spots).find((x) => x.id === out.spot) : void 0;
|
|
2628
|
+
const target = out?.kind === "float" ? regions.float : spot && out?.kind === "spot" && !out.home ? spot.target : null;
|
|
2629
|
+
const next = target ? target.after(at2, grab).state : s;
|
|
2630
|
+
return { frames, layout: solve(next, { previous }), before: previous, ...o.stretchPositions ? { stretchPositions: o.stretchPositions } : {} };
|
|
2631
|
+
}
|
|
2632
|
+
};
|
|
2633
|
+
}
|
|
2634
|
+
var group2 = (id, used) => ({
|
|
2635
|
+
id,
|
|
2636
|
+
kind: "group",
|
|
2637
|
+
used,
|
|
2638
|
+
forms: { row: [form("row", 180, 200, 28), form("icons", 84, 84, 28), form("menu", 0, 0, 0)], column: [form("icons", 84, 84, 28), form("menu", 0, 0, 0)] }
|
|
2639
|
+
});
|
|
2640
|
+
var bar2 = (id, side, ring, items) => ({ id, side, ring, accepts: ["group"], items, cross: { min: 36, max: 36, rail: 36 }, gap: 4, pad: { start: 8, end: 8 } });
|
|
2641
|
+
function landingWindow(top = ["a"], bottom = []) {
|
|
2642
|
+
const ids = ["tools", "zoom", ...top, ...bottom];
|
|
2643
|
+
return {
|
|
2644
|
+
stage: rect(0, 0, 1080, 640),
|
|
2645
|
+
edges: [bar2("top", "top", 0, top), bar2("bottom", "bottom", 0, bottom), { id: "rail-left", side: "left", ring: 0, accepts: ["group"], items: ["tools", "zoom"], cross: { min: 30, max: 30, rail: 30 }, compact: true }],
|
|
2646
|
+
items: Object.fromEntries(ids.map((id, i) => [id, group2(id, i + 1)])),
|
|
2647
|
+
floats: [],
|
|
2648
|
+
floatKinds: ["group"]
|
|
2649
|
+
};
|
|
2650
|
+
}
|
|
2651
|
+
function railBesideColumn(bottom = ["a"]) {
|
|
2652
|
+
const pages = { id: "pages", kind: "panel", used: 9, forms: { column: [form("open", 120, 240, 240, { grows: true, crossMin: 180 }), form("header", 28, 28, 240, { crossMin: 60 }), form("rail", 28, 28, 30), form("menu", 0, 0, 0)], row: [form("header", 120, 160, 28), form("menu", 0, 0, 0)] } };
|
|
2653
|
+
return {
|
|
2654
|
+
stage: rect(0, 0, 1080, 640),
|
|
2655
|
+
edges: [
|
|
2656
|
+
bar2("bottom", "bottom", 0, bottom),
|
|
2657
|
+
{ id: "rail-left", side: "left", ring: 0, accepts: ["group"], items: [], cross: { min: 30, max: 30, rail: 30 }, compact: true, zones: ["start"] },
|
|
2658
|
+
{ id: "left-0", side: "left", ring: 1, column: true, accepts: ["panel"], items: ["pages"], cross: { min: 200, max: 480, rail: 32 }, gap: 12, hitBand: "middle" }
|
|
2659
|
+
],
|
|
2660
|
+
items: { ...Object.fromEntries(bottom.map((id, i) => [id, group2(id, i + 1)])), pages },
|
|
2661
|
+
floats: [],
|
|
2662
|
+
floatKinds: ["group"]
|
|
2663
|
+
};
|
|
2664
|
+
}
|
|
2665
|
+
function emptyCorner(bottom = ["b"]) {
|
|
2666
|
+
return {
|
|
2667
|
+
stage: rect(0, 0, 1080, 640),
|
|
2668
|
+
edges: [bar2("top", "top", 0, []), bar2("bottom", "bottom", 0, bottom), { id: "rail-left", side: "left", ring: 0, accepts: ["group"], items: [], cross: { min: 30, max: 30, rail: 30 }, compact: true, zones: ["start"] }],
|
|
2669
|
+
items: Object.fromEntries(bottom.map((id, i) => [id, group2(id, i + 1)])),
|
|
2670
|
+
floats: [],
|
|
2671
|
+
floatKinds: ["group"]
|
|
2672
|
+
};
|
|
2673
|
+
}
|
|
2674
|
+
var LANDING_CASES = [
|
|
2675
|
+
{
|
|
2676
|
+
id: "landing-rail-repro",
|
|
2677
|
+
title: "An item pulled up its rail stays in the rail",
|
|
2678
|
+
expect: "Zoom's grip pulled straight up its rail, 6 px every 40 ms, to 4 px above the rail's top: every frame holds the rail, and the release docks Zoom above Tools.",
|
|
2679
|
+
state: landingWindow(),
|
|
2680
|
+
item: "zoom",
|
|
2681
|
+
path: [
|
|
2682
|
+
{ x: 15, y: 160 },
|
|
2683
|
+
{ x: 15, y: 32 }
|
|
2684
|
+
],
|
|
2685
|
+
speed: 0.15,
|
|
2686
|
+
rest: 40,
|
|
2687
|
+
moving: { lane: "rail-left" },
|
|
2688
|
+
end: { region: "lane", lane: "rail-left" },
|
|
2689
|
+
layout: { order: { "rail-left": ["zoom", "tools"] } }
|
|
2690
|
+
},
|
|
2691
|
+
{
|
|
2692
|
+
id: "landing-edge-fling",
|
|
2693
|
+
title: "A pointer flung past the window's edge and held there docks against it",
|
|
2694
|
+
expect: "A toolbar flung from the document at 3 px/ms to 10 px past the window's left edge and held there for 40 ms docks in the rail drawn against that edge.",
|
|
2695
|
+
state: landingWindow(),
|
|
2696
|
+
item: "a",
|
|
2697
|
+
path: [
|
|
2698
|
+
{ x: 60, y: 18 },
|
|
2699
|
+
{ x: 500, y: 300 },
|
|
2700
|
+
{ x: -10, y: 400 }
|
|
2701
|
+
],
|
|
2702
|
+
speed: 3,
|
|
2703
|
+
rest: 40,
|
|
2704
|
+
end: { region: "lane", lane: "rail-left" },
|
|
2705
|
+
layout: { items: { a: { edge: "rail-left" } } }
|
|
2706
|
+
},
|
|
2707
|
+
{
|
|
2708
|
+
id: "landing-past-edge",
|
|
2709
|
+
title: "More than 48 px past the window is nowhere",
|
|
2710
|
+
expect: "A toolbar taken 80 px past the window's left edge and held there lands nowhere: the release puts it back.",
|
|
2711
|
+
state: landingWindow(),
|
|
2712
|
+
item: "a",
|
|
2713
|
+
path: [
|
|
2714
|
+
{ x: 60, y: 18 },
|
|
2715
|
+
{ x: 500, y: 300 },
|
|
2716
|
+
{ x: -80, y: 400 }
|
|
2717
|
+
],
|
|
2718
|
+
speed: 1,
|
|
2719
|
+
rest: 80,
|
|
2720
|
+
end: { region: "nowhere", lane: null },
|
|
2721
|
+
layout: { items: { a: { edge: "top" } } }
|
|
2722
|
+
},
|
|
2723
|
+
{
|
|
2724
|
+
id: "landing-lift-over-a-band",
|
|
2725
|
+
title: "A lift over an empty bar's band doesn't enter the bar",
|
|
2726
|
+
expect: "A floating toolbar lying over the empty top bar's band, lifted there and moved away into the document at 1.5 px/ms: the lift itself is no still pointer, so the top bar never holds it.",
|
|
2727
|
+
state: { ...landingWindow([]), items: { ...landingWindow([]).items, a: group2("a", 9) }, floats: [{ id: "a", rect: rect(480, 6, 200, 28) }] },
|
|
2728
|
+
item: "a",
|
|
2729
|
+
path: [
|
|
2730
|
+
{ x: 500, y: 20 },
|
|
2731
|
+
{ x: 504, y: 22 },
|
|
2732
|
+
{ x: 600, y: 320 }
|
|
2733
|
+
],
|
|
2734
|
+
speed: 1.5,
|
|
2735
|
+
moving: { notLanes: ["top"] },
|
|
2736
|
+
end: { region: "open", lane: null }
|
|
2737
|
+
},
|
|
2738
|
+
{
|
|
2739
|
+
id: "landing-blocked",
|
|
2740
|
+
title: "Over a blocked spot a release cancels",
|
|
2741
|
+
expect: "A toolbar taken from its bar to the middle of a blocked spot in the document (`DockState.blocked`) and held there: no float lands there, and the release puts it back in its bar.",
|
|
2742
|
+
state: { ...landingWindow(), blocked: [rect(400, 250, 160, 120)] },
|
|
2743
|
+
item: "a",
|
|
2744
|
+
path: [
|
|
2745
|
+
{ x: 60, y: 18 },
|
|
2746
|
+
{ x: 480, y: 310 }
|
|
2747
|
+
],
|
|
2748
|
+
speed: 0.6,
|
|
2749
|
+
rest: 80,
|
|
2750
|
+
end: { region: "refused", lane: null },
|
|
2751
|
+
layout: { items: { a: { edge: "top" } } }
|
|
2752
|
+
},
|
|
2753
|
+
{
|
|
2754
|
+
id: "landing-guides-where-it-lands",
|
|
2755
|
+
title: "No guide beside chrome nothing lands next to",
|
|
2756
|
+
expect: "Zoom held in a top bar that starts with a fixed lead and ends with fixed controls (nothing lands before the one or after the other): no guide lies in the 8 px before the lead or after the controls.",
|
|
2757
|
+
state: (() => {
|
|
2758
|
+
const s = landingWindow(["lead", "a", "ctl"]);
|
|
2759
|
+
const fixed = (id, end) => ({ id, kind: "chrome", used: 0, fixed: true, ...end ? { align: "end" } : {}, forms: { row: [form("row", 120, 120, 28)] } });
|
|
2760
|
+
return { ...s, items: { ...s.items, lead: fixed("lead", false), ctl: fixed("ctl", true) } };
|
|
2761
|
+
})(),
|
|
2762
|
+
item: "zoom",
|
|
2763
|
+
path: [
|
|
2764
|
+
{ x: 15, y: 160 },
|
|
2765
|
+
{ x: 15, y: 18 },
|
|
2766
|
+
{ x: 600, y: 18 }
|
|
2767
|
+
],
|
|
2768
|
+
speed: 0.3,
|
|
2769
|
+
rest: 80,
|
|
2770
|
+
moving: { noGuideIn: [rect(0, 2, 7, 32), rect(1073, 2, 7, 32)] },
|
|
2771
|
+
end: { region: "lane", lane: "top" }
|
|
2772
|
+
},
|
|
2773
|
+
{
|
|
2774
|
+
id: "landing-fast-pass",
|
|
2775
|
+
title: "A fast pass over a bar opens no room in it",
|
|
2776
|
+
expect: "A toolbar moved from the document down across the empty bottom bar and 40 px past the window at 1.5 px/ms: the bottom bar never holds the pointer while it moves.",
|
|
2777
|
+
state: landingWindow(),
|
|
2778
|
+
item: "a",
|
|
2779
|
+
path: [
|
|
2780
|
+
{ x: 60, y: 18 },
|
|
2781
|
+
{ x: 500, y: 300 },
|
|
2782
|
+
{ x: 520, y: 680 }
|
|
2783
|
+
],
|
|
2784
|
+
speed: 1.5,
|
|
2785
|
+
moving: { notLanes: ["bottom"] }
|
|
2786
|
+
},
|
|
2787
|
+
{
|
|
2788
|
+
id: "landing-lane-to-lane",
|
|
2789
|
+
title: "Rail to bar at the corner never passes through the float",
|
|
2790
|
+
expect: "Zoom moved up its rail into the top bar and along it at 0.6 px/ms, resting there 80 ms: no frame floats it, and it ends in the top bar.",
|
|
2791
|
+
state: landingWindow(),
|
|
2792
|
+
item: "zoom",
|
|
2793
|
+
path: [
|
|
2794
|
+
{ x: 15, y: 160 },
|
|
2795
|
+
{ x: 15, y: 18 },
|
|
2796
|
+
{ x: 400, y: 18 }
|
|
2797
|
+
],
|
|
2798
|
+
speed: 0.6,
|
|
2799
|
+
rest: 80,
|
|
2800
|
+
moving: { notRegions: ["open"] },
|
|
2801
|
+
end: { region: "lane", lane: "top" },
|
|
2802
|
+
layout: { items: { zoom: { edge: "top" } } }
|
|
2803
|
+
},
|
|
2804
|
+
{
|
|
2805
|
+
id: "landing-fast-along-bar",
|
|
2806
|
+
title: "A fast hand along a bar's free stretch keeps the item at the hand",
|
|
2807
|
+
expect: "A toolbar moved along its bar's free stretch at 1.2 px/ms: whenever the bar holds it, the landing lies within 40 px (the spot pitch) of the pointer.",
|
|
2808
|
+
state: landingWindow(),
|
|
2809
|
+
item: "a",
|
|
2810
|
+
path: [
|
|
2811
|
+
{ x: 110, y: 18 },
|
|
2812
|
+
{ x: 970, y: 18 }
|
|
2813
|
+
],
|
|
2814
|
+
speed: 1.2,
|
|
2815
|
+
moving: { lane: "top", trail: 40 }
|
|
2816
|
+
},
|
|
2817
|
+
{
|
|
2818
|
+
id: "landing-back-home-bar",
|
|
2819
|
+
title: "A toolbar taken away by its end and brought back lands home",
|
|
2820
|
+
expect: "A toolbar pressed 12 px from its right end in its bar (the free stretch's spots lie that way), moved into the document and back to the press point at 0.6 px/ms, resting there 80 ms: it ends on its own place, not on a free-stretch spot beside it.",
|
|
2821
|
+
state: landingWindow(),
|
|
2822
|
+
item: "a",
|
|
2823
|
+
path: [
|
|
2824
|
+
{ x: 196, y: 18 },
|
|
2825
|
+
{ x: 500, y: 300 },
|
|
2826
|
+
{ x: 196, y: 18 }
|
|
2827
|
+
],
|
|
2828
|
+
speed: 0.6,
|
|
2829
|
+
rest: 80,
|
|
2830
|
+
end: { region: "lane", lane: "top" },
|
|
2831
|
+
home: true
|
|
2832
|
+
},
|
|
2833
|
+
{
|
|
2834
|
+
id: "landing-back-home-rail",
|
|
2835
|
+
title: "A rail toolbar taken away by its bottom and brought back lands home",
|
|
2836
|
+
expect: "Zoom pressed 6 px above its bottom in its rail (the free stretch's spots lie below it), moved into the document and back to the press point at 0.6 px/ms, resting there 80 ms: it ends where it was, below Tools.",
|
|
2837
|
+
state: landingWindow(),
|
|
2838
|
+
item: "zoom",
|
|
2839
|
+
path: [
|
|
2840
|
+
{ x: 15, y: 198 },
|
|
2841
|
+
{ x: 500, y: 300 },
|
|
2842
|
+
{ x: 15, y: 198 }
|
|
2843
|
+
],
|
|
2844
|
+
speed: 0.6,
|
|
2845
|
+
rest: 80,
|
|
2846
|
+
end: { region: "lane", lane: "rail-left" },
|
|
2847
|
+
home: true
|
|
2848
|
+
},
|
|
2849
|
+
{
|
|
2850
|
+
id: "landing-grip-past-long-neighbor",
|
|
2851
|
+
title: "A toolbar held by its grip and slid past a long neighbor stays at the hand",
|
|
2852
|
+
expect: "A toolbar pressed 6 px into its left end (its grip) in the bottom bar and slid right along it past a 200 px neighbor to the bar's far end at 0.15 px/ms: every frame holds the bar, and the landing stays at the hand (the hand rule: the nearest landing in the bar, within 48 px of the pointer, 56 on the frame before a hop, the landings either side of the neighbor close): the grab never moves a hop past the neighbor.",
|
|
2853
|
+
state: landingWindow(["a"], ["b", "c"]),
|
|
2854
|
+
item: "b",
|
|
2855
|
+
path: [
|
|
2856
|
+
{ x: 14, y: 622 },
|
|
2857
|
+
{ x: 1060, y: 622 }
|
|
2858
|
+
],
|
|
2859
|
+
speed: 0.15,
|
|
2860
|
+
rest: 40,
|
|
2861
|
+
moving: { lane: "bottom", hand: true }
|
|
2862
|
+
},
|
|
2863
|
+
{
|
|
2864
|
+
id: "landing-grip-across-items",
|
|
2865
|
+
title: "A toolbar held by its grip and slid slowly across two neighbors stays at the hand",
|
|
2866
|
+
expect: "In a top bar of three 200 px toolbars, the first pressed 6 px into its left end (its grip) and slid right across the other two to the bar's end at 0.15 px/ms: every frame holds the bar, and the landing stays at the hand (the hand rule: the nearest landing in the bar, within 48 px of the pointer, 56 on the frame before a hop, the landings either side of a neighbor close).",
|
|
2867
|
+
state: landingWindow(["a", "b", "c"]),
|
|
2868
|
+
item: "a",
|
|
2869
|
+
path: [
|
|
2870
|
+
{ x: 14, y: 18 },
|
|
2871
|
+
{ x: 1060, y: 18 }
|
|
2872
|
+
],
|
|
2873
|
+
speed: 0.15,
|
|
2874
|
+
rest: 40,
|
|
2875
|
+
moving: { lane: "top", hand: true }
|
|
2876
|
+
},
|
|
2877
|
+
{
|
|
2878
|
+
id: "landing-grip-up-the-rail",
|
|
2879
|
+
title: "A rail toolbar held by its grip and pulled slowly up past its neighbor stays at the hand",
|
|
2880
|
+
expect: "Zoom pressed 6 px below its top (its grip) in its rail and pulled straight up past Tools (158 px long there) to the rail's head at 0.15 px/ms: every frame holds the rail, and the landing stays at the hand (the hand rule: the nearest landing in the rail, within max(48, g / 2 + 6) px of the pointer, g the gap between the two landings the pointer lies between, the 48 being 56 on the frame before a hop).",
|
|
2881
|
+
state: (() => {
|
|
2882
|
+
const s = landingWindow();
|
|
2883
|
+
const tools = group2("tools", 1);
|
|
2884
|
+
return { ...s, items: { ...s.items, tools: { ...tools, forms: { ...tools.forms, column: [form("icons", 158, 158, 28), form("menu", 0, 0, 0)] } } } };
|
|
2885
|
+
})(),
|
|
2886
|
+
item: "zoom",
|
|
2887
|
+
path: [
|
|
2888
|
+
{ x: 15, y: 200 },
|
|
2889
|
+
{ x: 15, y: 40 }
|
|
2890
|
+
],
|
|
2891
|
+
speed: 0.15,
|
|
2892
|
+
rest: 40,
|
|
2893
|
+
moving: { lane: "rail-left", hand: true }
|
|
2894
|
+
},
|
|
2895
|
+
...[0.15, 0.6].map(
|
|
2896
|
+
(speed) => ({
|
|
2897
|
+
id: `landing-room-up-past-placed-${speed === 0.15 ? "slow" : "fast"}`,
|
|
2898
|
+
title: `A rail toolbar held by its grip and pulled up past a long neighbor that keeps room stays at the hand (${speed} px/ms)`,
|
|
2899
|
+
expect: `Tools (158 px) keeps 100 px of room above it at the rail's head, and Zoom keeps 80 px below Tools. Zoom pressed by its grip and pulled straight up past Tools to the rail's head at ${speed} px/ms: every frame holds the rail, and the landing stays at the hand (the hand rule: the nearest landing in the rail, within max(48, g / 2 + 6) px of the pointer, g the gap between the two landings the pointer lies between, the 48 being 56 on the frame before a hop). Over the free room a drop consumes it; over Tools, Zoom takes Tools' place and Tools gives way, so the landings either side of Tools are never a whole Tools apart.`,
|
|
2900
|
+
state: (() => {
|
|
2901
|
+
const s = landingWindow();
|
|
2902
|
+
const tools = group2("tools", 1);
|
|
2903
|
+
const zoom = group2("zoom", 2);
|
|
2904
|
+
return { ...s, items: { ...s.items, tools: { ...tools, space: 100, forms: { ...tools.forms, column: [form("icons", 158, 158, 28), form("menu", 0, 0, 0)] } }, zoom: { ...zoom, space: 80 } } };
|
|
2905
|
+
})(),
|
|
2906
|
+
item: "zoom",
|
|
2907
|
+
path: [
|
|
2908
|
+
{ x: 15, y: 380 },
|
|
2909
|
+
{ x: 15, y: 40 }
|
|
2910
|
+
],
|
|
2911
|
+
speed,
|
|
2912
|
+
rest: 40,
|
|
2913
|
+
moving: { lane: "rail-left", hand: true }
|
|
2914
|
+
})
|
|
2915
|
+
),
|
|
2916
|
+
{
|
|
2917
|
+
id: "landing-step-down-room",
|
|
2918
|
+
title: "A toolbar slid over room that a neighbor steps down to make stays at the hand",
|
|
2919
|
+
expect: "An 870 px bottom bar: Panels (362 px, 60 in its short form) at its start, Status (382 px) at its end, 109 px between them: 93 px of room for an item less the 8 px gap each side, shorter than Tools (130 px). Tools brought from the document onto the bar and slid right along it at 0.3 px/ms: a drop between them steps Panels down, and the room that makes (266 px past Tools' length) is one sliding stretch, so whenever the bar holds it the landing stays at the hand (the hand rule: the nearest landing in the bar, within max(48, g / 2 + 6) px of the pointer, g the gap between the two landings the pointer lies between, the 48 being 56 on the frame before a hop).",
|
|
2920
|
+
state: (() => {
|
|
2921
|
+
const row2 = (kind, w) => form(kind, w, w, 31);
|
|
2922
|
+
const g2 = (id, used, forms, more = {}) => ({ id, kind: "group", used, forms, ...more });
|
|
2923
|
+
const icons = form("icons", 84, 84, 28);
|
|
2924
|
+
const menu = form("menu", 0, 0, 0);
|
|
2925
|
+
return {
|
|
2926
|
+
stage: rect(0, 0, 870, 660),
|
|
2927
|
+
edges: [{ id: "bottom", side: "bottom", ring: 0, accepts: ["group"], items: ["panels", "status"], cross: { min: 31, max: 31, rail: 31 }, gap: 8, pad: { start: 8, end: 8 }, menu: { main: 24 } }],
|
|
2928
|
+
items: {
|
|
2929
|
+
panels: g2("panels", 1, { row: [row2("row", 362.3), row2("icons", 60), menu], column: [icons, menu] }),
|
|
2930
|
+
status: g2("status", 100, { row: [row2("row", 382.4)], column: [icons] }, { align: "end" }),
|
|
2931
|
+
tools: g2("tools", 2, { row: [row2("row", 130), row2("icons", 60), menu], column: [form("icons", 107, 107, 36), menu] })
|
|
2932
|
+
},
|
|
2933
|
+
floats: [{ id: "tools", rect: rect(529, 53, 36, 107) }],
|
|
2934
|
+
floatKinds: ["group"]
|
|
2935
|
+
};
|
|
2936
|
+
})(),
|
|
2937
|
+
item: "tools",
|
|
2938
|
+
path: [
|
|
2939
|
+
{ x: 547, y: 106 },
|
|
2940
|
+
{ x: 100, y: 645 },
|
|
2941
|
+
{ x: 465, y: 645 }
|
|
2942
|
+
],
|
|
2943
|
+
speed: 0.3,
|
|
2944
|
+
rest: 40,
|
|
2945
|
+
moving: { hand: true },
|
|
2946
|
+
end: { region: "lane", lane: "bottom" }
|
|
2947
|
+
},
|
|
2948
|
+
{
|
|
2949
|
+
id: "landing-across-items",
|
|
2950
|
+
title: "A fast hand across docked items trails no further than it must",
|
|
2951
|
+
expect: "Zoom moved up its rail and along a bar of three toolbars at 1.2 px/ms, both ways: no frame floats it, and its landing is never further from the pointer than when the same path is played at 0.05 px/ms, plus 40 px.",
|
|
2952
|
+
state: landingWindow(["a", "b", "c"]),
|
|
2953
|
+
item: "zoom",
|
|
2954
|
+
path: [
|
|
2955
|
+
{ x: 15, y: 160 },
|
|
2956
|
+
{ x: 15, y: 18 },
|
|
2957
|
+
{ x: 1040, y: 18 },
|
|
2958
|
+
{ x: 40, y: 18 }
|
|
2959
|
+
],
|
|
2960
|
+
speed: 1.2,
|
|
2961
|
+
moving: { notRegions: ["open"], trailOverSlow: { slow: 0.05, by: 40 } }
|
|
2962
|
+
},
|
|
2963
|
+
{
|
|
2964
|
+
id: "landing-near-rail-glide",
|
|
2965
|
+
title: "A toolbar glided to an empty rail beside a panel column shows no guide until it can enter the rail",
|
|
2966
|
+
expect: "A toolbar lifted from the bottom bar and glided at 0.3 px/ms up and left over a panel column (it takes no toolbar) to the empty left rail's strip, resting there 40 ms: the rail's guide shows only once the pointer is in the strip, never over the column on the way (the Near guides' rule: a lane's guide shows where the pointer holds it, is pending in it, or is in open space within 12 px of it), the rail holds the pointer from its first slow step in the strip (the place under it is the column's, which takes nothing, and there is nothing else to mean there), and the toolbar takes the rail's icons form, in the rail's 30 px, as it lands.",
|
|
2967
|
+
state: railBesideColumn(),
|
|
2968
|
+
item: "a",
|
|
2969
|
+
path: [
|
|
2970
|
+
{ x: 60, y: 622 },
|
|
2971
|
+
{ x: 15, y: 320 }
|
|
2972
|
+
],
|
|
2973
|
+
speed: 0.3,
|
|
2974
|
+
rest: 40,
|
|
2975
|
+
moving: { nearGuides: true, hand: true },
|
|
2976
|
+
end: { region: "lane", lane: "rail-left", landing: { x: 0, width: 30 } },
|
|
2977
|
+
layout: { items: { a: { edge: "rail-left", formKind: "icons" } }, order: { "rail-left": ["a"] } }
|
|
2978
|
+
},
|
|
2979
|
+
{
|
|
2980
|
+
id: "landing-near-rail-pending-release",
|
|
2981
|
+
title: "A release while the rail is pending floats nothing and goes home",
|
|
2982
|
+
expect: "The same toolbar glided at 0.6 px/ms (a fast hand: faster than the gate's 0.375 px/ms) into the rail's strip and released on arrival: the rail is pending (the pointer is inside it, its gate not passed), its guide shows (the Near guides' rule), the last frame lands nowhere (the place under it is the column's), and the release puts the toolbar back in the bottom bar.",
|
|
2983
|
+
state: railBesideColumn(),
|
|
2984
|
+
item: "a",
|
|
2985
|
+
path: [
|
|
2986
|
+
{ x: 60, y: 622 },
|
|
2987
|
+
{ x: 15, y: 320 }
|
|
2988
|
+
],
|
|
2989
|
+
speed: 0.6,
|
|
2990
|
+
moving: { nearGuides: true },
|
|
2991
|
+
end: { region: "refused", lane: null, pending: "rail-left" },
|
|
2992
|
+
layout: { items: { a: { edge: "bottom" } } }
|
|
2993
|
+
},
|
|
2994
|
+
{
|
|
2995
|
+
id: "landing-near-corner-steady",
|
|
2996
|
+
title: "At a corner between two lanes the Near guides don't flicker",
|
|
2997
|
+
expect: "A toolbar lifted from the bottom bar, taken into the open space at the corner where the top bar meets the left rail (x 30, y 36) and moved back and forth across it at 0.3 px/ms, 8 px each way, between points where one lane is nearer then the other (both within 12 px): the guides go from the bottom bar's to one lane's once, and stay that lane's, never switching to the other and back (the kept lane gives way only to one 16 px nearer); the release there is in open space, a float.",
|
|
2998
|
+
state: landingWindow(["a"], ["b"]),
|
|
2999
|
+
item: "b",
|
|
3000
|
+
path: [
|
|
3001
|
+
{ x: 60, y: 622 },
|
|
3002
|
+
{ x: 100, y: 60 },
|
|
3003
|
+
// Back and forth three times: the top bar is nearer at the first point, the rail at the second.
|
|
3004
|
+
...[0, 1, 2].flatMap(() => [
|
|
3005
|
+
{ x: 40, y: 38 },
|
|
3006
|
+
{ x: 32, y: 46 }
|
|
3007
|
+
]),
|
|
3008
|
+
{ x: 40, y: 38 }
|
|
3009
|
+
],
|
|
3010
|
+
speed: 0.3,
|
|
3011
|
+
rest: 40,
|
|
3012
|
+
moving: { nearGuides: true, guideSwitches: 1 },
|
|
3013
|
+
end: { region: "open" },
|
|
3014
|
+
layout: { items: { b: { floating: true } } }
|
|
3015
|
+
},
|
|
3016
|
+
{
|
|
3017
|
+
id: "landing-near-pending-corner-steady",
|
|
3018
|
+
title: "Inside two lanes that overlap at a corner, the pending lane doesn't flicker",
|
|
3019
|
+
expect: "A toolbar lifted from the bottom bar and carried at 0.6 px/ms into the corner where the empty top bar's band and the empty left rail's overlap, then moved back and forth inside both, between (26, 21), deeper in the bar, and (20, 27), a pixel deeper in the rail: neither lane is entered (the hand never slows), the bar is pending from the first point inside both and stays pending (the other lane takes over only once it is deeper by the spot margin, 6 px), so the guides go from the bottom bar's to the top bar's once.",
|
|
3020
|
+
state: emptyCorner(),
|
|
3021
|
+
item: "b",
|
|
3022
|
+
path: [
|
|
3023
|
+
{ x: 60, y: 622 },
|
|
3024
|
+
{ x: 100, y: 100 },
|
|
3025
|
+
{ x: 26, y: 21 },
|
|
3026
|
+
...[0, 1, 2, 3].flatMap(() => [
|
|
3027
|
+
{ x: 20, y: 27 },
|
|
3028
|
+
{ x: 26, y: 21 }
|
|
3029
|
+
])
|
|
3030
|
+
],
|
|
3031
|
+
speed: 0.6,
|
|
3032
|
+
moving: { nearGuides: true, guideSwitches: 1, notLanes: ["top", "rail-left"] }
|
|
3033
|
+
}
|
|
3034
|
+
];
|
|
3035
|
+
|
|
3036
|
+
// src/testing/index.ts
|
|
3037
|
+
var CASES = withDocks([...DOCKING_ROWS, ...BAR_ROWS, ...RULE_ROWS, ...GESTURE_ROWS, ...WINDOW_ROWS]);
|
|
3038
|
+
var CASE_GROUPS = [
|
|
3039
|
+
{ id: "panels", title: "Panels in a column" },
|
|
3040
|
+
{ id: "groups", title: "Groups and toolbars" },
|
|
3041
|
+
{ id: "drag", title: "Dragging" },
|
|
3042
|
+
{ id: "floats", title: "Floats, saving, freeze" },
|
|
3043
|
+
{ id: "bars", title: "Bars give way" },
|
|
3044
|
+
{ id: "previous", title: "What previous keeps" },
|
|
3045
|
+
{ id: "kinds", title: "Kinds, chrome and reserved room" },
|
|
3046
|
+
{ id: "bands", title: "Gap hit areas, refits and slots" },
|
|
3047
|
+
{ id: "gestures", title: "Panel gestures" },
|
|
3048
|
+
{ id: "window-a", title: "Window A: width thresholds" },
|
|
3049
|
+
{ id: "window-b", title: "Window B: width thresholds" }
|
|
3050
|
+
];
|
|
3051
|
+
var caseById = (id) => CASES.find((c) => c.id === id);
|
|
3052
|
+
export {
|
|
3053
|
+
CASES,
|
|
3054
|
+
CASE_GROUPS,
|
|
3055
|
+
END_REACH,
|
|
3056
|
+
HAND_FAST,
|
|
3057
|
+
HAND_MARGIN,
|
|
3058
|
+
HAND_TRAIL,
|
|
3059
|
+
HAND_TRAIL_BEFORE_HOP,
|
|
3060
|
+
LANDING_CASES,
|
|
3061
|
+
LIFT_THRESHOLD,
|
|
3062
|
+
NEAR_REACH,
|
|
3063
|
+
WINDOW_A,
|
|
3064
|
+
WINDOW_B,
|
|
3065
|
+
WINDOW_BARE,
|
|
3066
|
+
caseById,
|
|
3067
|
+
createLandingHost,
|
|
3068
|
+
createReferenceHost,
|
|
3069
|
+
defaultItemSelector,
|
|
3070
|
+
g,
|
|
3071
|
+
handBound,
|
|
3072
|
+
idRenames,
|
|
3073
|
+
landingIssues,
|
|
3074
|
+
layoutIssues,
|
|
3075
|
+
mapGesture,
|
|
3076
|
+
mapLayout,
|
|
3077
|
+
mapPlace,
|
|
3078
|
+
mapState,
|
|
3079
|
+
mapStored,
|
|
3080
|
+
nearGuideIssues,
|
|
3081
|
+
resizeStep,
|
|
3082
|
+
resolvePlace,
|
|
3083
|
+
runCase,
|
|
3084
|
+
runCaseAsync,
|
|
3085
|
+
runCases,
|
|
3086
|
+
runCasesAsync,
|
|
3087
|
+
runLandingCases,
|
|
3088
|
+
winState,
|
|
3089
|
+
withRefusals
|
|
3090
|
+
};
|
|
3091
|
+
//# sourceMappingURL=testing.js.map
|