@n-uf/placement 26.11.26 → 26.11.27
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 +103 -0
- package/README.md +74 -13
- package/dist/{chunk-CIGRI35P.js → chunk-3GIUOVQH.js} +587 -241
- package/dist/chunk-3GIUOVQH.js.map +1 -0
- package/dist/{model-Dz4R5ydE.d.ts → model-Cxg_ySz6.d.ts} +84 -2
- package/dist/scene-cases.d.ts +38 -12
- package/dist/scene-cases.js +21 -34
- package/dist/scene-cases.js.map +1 -1
- package/dist/scene.d.ts +81 -3
- package/dist/scene.js +11 -1
- package/package.json +3 -2
- package/dist/chunk-CIGRI35P.js.map +0 -1
|
@@ -78,6 +78,12 @@ interface SceneItem {
|
|
|
78
78
|
* form) keeps its height. Without it, a shrink stops at the form's own minimums.
|
|
79
79
|
*/
|
|
80
80
|
readonly floatMin?: Size;
|
|
81
|
+
/**
|
|
82
|
+
* The most a float of it is laid out at, each way (optional, the same shape as `floatMin`, never under it): a larger
|
|
83
|
+
* float rect is drawn at this size, its top-left corner kept (a folded float keeps its bar's height), and `fitResize`
|
|
84
|
+
* stops a resize here (`"max"`).
|
|
85
|
+
*/
|
|
86
|
+
readonly floatMax?: Size;
|
|
81
87
|
}
|
|
82
88
|
interface Edge {
|
|
83
89
|
readonly id: string;
|
|
@@ -138,10 +144,23 @@ interface Edge {
|
|
|
138
144
|
* Default {@link DEFAULT_HIT_BAND}.
|
|
139
145
|
*/
|
|
140
146
|
readonly hitBand?: number | "middle";
|
|
147
|
+
/**
|
|
148
|
+
* `"side"`: a static edge whose fixed item (an anchor: page thumbnails) the user may drag to the other side of the
|
|
149
|
+
* edge's axis. `targets` then offers that item one target, `side:<other side>`, over the place the edge takes there
|
|
150
|
+
* (`setSide`); its own place is home. Left out, a fixed item has no targets.
|
|
151
|
+
*/
|
|
152
|
+
readonly moves?: "side";
|
|
153
|
+
/**
|
|
154
|
+
* `true`: the user may fold this edge's fixed items (an anchor) by hand, like a panel: `fold(scene, id, true)` shows
|
|
155
|
+
* it in its rail form, `fold(scene, id, false)` reopens it, and `storeScene` / `readScene` keep it folded. Left out,
|
|
156
|
+
* `fold` leaves a fixed item as it is.
|
|
157
|
+
*/
|
|
158
|
+
readonly foldable?: boolean;
|
|
141
159
|
/**
|
|
142
160
|
* A dynamic column (left and right only): made by a drop on a column line, deleted when it holds no item, folded whole
|
|
143
161
|
* into its side's rail by give-way (`Scene.contentMin`) or when every member is folded by hand. Its `accepts`,
|
|
144
|
-
* `cross`, `gap`, `pad` and `
|
|
162
|
+
* `cross`, `gap`, `pad`, `menu`, `zoneAccepts` and `hitBand` come from `Scene.columns[side]` when the changes make it;
|
|
163
|
+
* with no `hitBand` of its own it reads the template's.
|
|
145
164
|
*/
|
|
146
165
|
readonly column?: boolean;
|
|
147
166
|
/**
|
|
@@ -177,6 +196,12 @@ interface ColumnTemplate {
|
|
|
177
196
|
};
|
|
178
197
|
/** The kinds each zone takes in the columns made from it (`Edge.zoneAccepts`). */
|
|
179
198
|
readonly zoneAccepts?: ZoneAccepts;
|
|
199
|
+
/**
|
|
200
|
+
* How a gap's hit runs over the open panels of the columns made from it (`Edge.hitBand`): a band that many px about
|
|
201
|
+
* each line, or `"middle"` (a drop on a panel's upper or lower half means the gap before or after it). Default
|
|
202
|
+
* {@link DEFAULT_HIT_BAND}.
|
|
203
|
+
*/
|
|
204
|
+
readonly hitBand?: number | "middle";
|
|
180
205
|
}
|
|
181
206
|
/** Per zone, the kinds it takes. */
|
|
182
207
|
type ZoneAccepts = Readonly<Partial<Record<Zone, readonly Kind[]>>>;
|
|
@@ -423,6 +448,50 @@ declare const DEFAULT_HIT_BAND = 24;
|
|
|
423
448
|
/** A float's size when neither the item nor the call gives one, px. */
|
|
424
449
|
declare const DEFAULT_FLOAT_SIZE: Size;
|
|
425
450
|
|
|
451
|
+
/**
|
|
452
|
+
* `fitResize(scene, id, rect, moving)`: the rect a float takes when the user drags some of its edges, clamped in one
|
|
453
|
+
* pass (no iteration) and with the limits that bound it. Hosts call it on every pointer move for the preview; the
|
|
454
|
+
* scene change `resize(scene, id, rect, moving)` commits the same rect, so the preview is the commit.
|
|
455
|
+
*
|
|
456
|
+
* It is not `fitFloat`: that one moves a float (never resizes it) to a clear place; this one resizes it with the edges
|
|
457
|
+
* not dragged kept put, and stops a dragged edge before anything `fitFloat` would move it off, so `solve` lays the
|
|
458
|
+
* result exactly where it is asked.
|
|
459
|
+
*/
|
|
460
|
+
|
|
461
|
+
/** The edges of a float a resize drags; the others stay put. Left beats right, top beats bottom, when both are set. */
|
|
462
|
+
interface ResizeEdges {
|
|
463
|
+
readonly left?: boolean;
|
|
464
|
+
readonly right?: boolean;
|
|
465
|
+
readonly top?: boolean;
|
|
466
|
+
readonly bottom?: boolean;
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Why a resized float isn't the rect asked for: `"min"` its least size (`floatMin`, else its open form's minimums),
|
|
470
|
+
* `"max"` its `floatMax`, `"region"` the region floats lie in (the stage less the inset at its left and right, its full
|
|
471
|
+
* height), `"docked"` what floats are kept clear of (a bar, a docked item, the chrome).
|
|
472
|
+
*/
|
|
473
|
+
type ResizeLimit = "min" | "max" | "region" | "docked";
|
|
474
|
+
interface FloatResize {
|
|
475
|
+
/** The float's rect: what `resize` stores and `solve` draws. */
|
|
476
|
+
readonly rect: Rect;
|
|
477
|
+
/** The limits that bound it, in this order: min, max, region, docked. Empty when it is the rect asked for. */
|
|
478
|
+
readonly limits: readonly ResizeLimit[];
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* The rect float `id` takes for a resize: `rect` is the rect asked for in stage px (the float as drawn, with the
|
|
482
|
+
* `moving` edges where the pointer put them). In one pass: the edges not moving stay put; the size is at least the
|
|
483
|
+
* item's `floatMin` (else its open form's minimums, which only stop a shrink below the size drawn now, as `solve` lays
|
|
484
|
+
* it) and at most its `floatMax`; the float stays in the region floats lie in; every growing edge (a moving one, or the
|
|
485
|
+
* end of an axis not moving) stops at what floats are kept clear of, as drawn now (across first, over its height now;
|
|
486
|
+
* then along, over its new width), and such a stop beats the minimum. The rect is then laid by the one clamp `solve`
|
|
487
|
+
* lays floats with, so `solve(resize(...))` draws exactly this rect (where that clamp still moves it, a float with no
|
|
488
|
+
* clear place, `"docked"` says so). `limits` says which of these bound it.
|
|
489
|
+
*
|
|
490
|
+
* Null for anything but a float drawn at its first form when that form grows (a panel's card): a toolbar group's size
|
|
491
|
+
* comes from its forms, and so does a folded float's bar. Pure: it solves the scene once, for what is drawn now.
|
|
492
|
+
*/
|
|
493
|
+
declare function fitResize(scene: Scene, id: string, rect: Rect, moving: ResizeEdges): FloatResize | null;
|
|
494
|
+
|
|
426
495
|
/**
|
|
427
496
|
* The scene's pure changes. Each returns a new scene and leaves the one it was given as it was; a change that can't
|
|
428
497
|
* apply (an unknown item or edge, a fixed item, a kind the edge or the float layer doesn't take) returns the scene
|
|
@@ -444,6 +513,7 @@ declare const DEFAULT_FLOAT_SIZE: Size;
|
|
|
444
513
|
* - `raise(scene, id)`: a float to the top of the stack; no use, no reshape.
|
|
445
514
|
* - `orient(scene, id, orient)`: a float's axis.
|
|
446
515
|
* - `resize(scene, edge, size)`: the user's size across; a size that isn't a finite number clears it.
|
|
516
|
+
* `resize(scene, id, rect, moving?)`: a float resized by hand, at `fitResize`'s rect (./float-resize).
|
|
447
517
|
*/
|
|
448
518
|
|
|
449
519
|
/** Where a docked item goes: before the `at`-th item of `zone` (default the item's own zone) in `edge`. */
|
|
@@ -484,7 +554,15 @@ declare function open(scene: Scene, id: string): Scene;
|
|
|
484
554
|
declare function close(scene: Scene, id: string): Scene;
|
|
485
555
|
declare function raise(scene: Scene, id: string): Scene;
|
|
486
556
|
declare function orient(scene: Scene, id: string, to: Orient): Scene;
|
|
557
|
+
/**
|
|
558
|
+
* The user's size across an edge (`size` a number; one that isn't finite clears it). Or, with a rect, a float resized
|
|
559
|
+
* by hand: the rect `fitResize(scene, floatId, rect, moving)` gives (default `moving`: right and bottom), so a host's
|
|
560
|
+
* preview from `fitResize` is what this commits. The float keeps its stacking order and orient, loses its anchor, and
|
|
561
|
+
* the size becomes the item's `floatSize` (stored with the scene). The scene given back where `fitResize` refuses (a
|
|
562
|
+
* toolbar group, a folded float, anything not floating).
|
|
563
|
+
*/
|
|
487
564
|
declare function resize(scene: Scene, edgeId: string, size: number): Scene;
|
|
565
|
+
declare function resize(scene: Scene, floatId: string, rect: Rect, moving?: ResizeEdges): Scene;
|
|
488
566
|
/**
|
|
489
567
|
* The edge moved to the other side of its axis (left ⇄ right, top ⇄ bottom), as its side's outermost edge: ring 0, before
|
|
490
568
|
* that side's other edges (whose rings close up behind it; the side it left closes up too). Its items, size and options
|
|
@@ -590,6 +668,10 @@ type ScenePlace = {
|
|
|
590
668
|
readonly zone: Zone;
|
|
591
669
|
readonly at: number;
|
|
592
670
|
} | ColumnPlace | RailPlace | {
|
|
671
|
+
readonly kind: "side";
|
|
672
|
+
readonly edge: string;
|
|
673
|
+
readonly side: Side;
|
|
674
|
+
} | {
|
|
593
675
|
readonly kind: "float";
|
|
594
676
|
} | {
|
|
595
677
|
readonly kind: "home";
|
|
@@ -640,4 +722,4 @@ interface SceneRefusal {
|
|
|
640
722
|
readonly reason: "no-room" | "own-place" | "not-accepted";
|
|
641
723
|
}
|
|
642
724
|
|
|
643
|
-
export {
|
|
725
|
+
export { raise as $, type SceneRailLayout as A, type SceneRead as B, type ColumnPlace as C, DEFAULT_FLOAT_SIZE as D, type Edge as E, type FloatAnchor as F, type StoredSceneEdge as G, type StoredSceneFloat as H, type StoredSceneItem as I, ZONES as J, type Kind as K, close as L, dockHome as M, fitResize as N, type Orient as O, type Place as P, floatAt as Q, type RailPlace as R, type Scene as S, fold as T, homeFor as U, keep as V, lift as W, moveTo as X, open as Y, type Zone as Z, orient as _, type ScenePlace as a, readScene as a0, resize as a1, setSide as a2, storeScene as a3, use as a4, type SceneLayout as b, type StoredScene as c, type SceneTarget as d, type Side as e, type SceneNoteCode as f, type SceneItem as g, type ZoneAccepts as h, type SolveOptions as i, type SceneTargetOptions as j, type SceneRefusal as k, type ColumnTemplate as l, DEFAULT_HIT_BAND as m, DEFAULT_STRIP as n, type DockPlace as o, type FloatPlace as p, type FloatResize as q, type RailSpec as r, type ResizeEdges as s, type ResizeLimit as t, SIDES as u, type SceneAfter as v, type SceneEdgeLayout as w, type SceneFloat as x, type SceneItemLayout as y, type SceneNote as z };
|
package/dist/scene-cases.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { P as Point, R as Rect } from './geometry-CkZ6Fcfb.js';
|
|
2
2
|
import { S as StackFormKind } from './model-Bd0oELzF.js';
|
|
3
|
-
import { S as Scene, a as ScenePlace, b as SceneLayout, c as StoredScene,
|
|
3
|
+
import { S as Scene, a as ScenePlace, b as SceneLayout, c as StoredScene, d as SceneTarget, Z as Zone, e as Side, f as SceneNoteCode } from './model-Cxg_ySz6.js';
|
|
4
4
|
import './target-CEVCfJd-.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -31,7 +31,7 @@ type GestureType = "press" | "move" | "release" | "key" | "click" | "resize" | "
|
|
|
31
31
|
* press that ends in a float gives one (a host's own default may differ, and no row may depend on it). Nothing lifts yet.
|
|
32
32
|
* - `move`: the pointer moves, to `point` (stage px) or to the target at `place` (a host aims at the target's hit by its
|
|
33
33
|
* place, with `resolvePlace`). With an item pressed, the first move past the lift threshold lifts it (a `place` always
|
|
34
|
-
* lifts), and the pointer is then over whichever target `
|
|
34
|
+
* lifts), and the pointer is then over whichever target the host's pick rule (`PickRule`) finds. Without a press it only moves. With no
|
|
35
35
|
* target under the pointer the page draws the committed layout with the held item's place left empty, and nothing else
|
|
36
36
|
* moves (a release there commits nothing). A host reaches the end gaps `END_REACH` (24) px past an edge's ends: that is
|
|
37
37
|
* required of it, since the rows aim there.
|
|
@@ -223,7 +223,16 @@ interface CaseHost {
|
|
|
223
223
|
stored?(): StoredScene;
|
|
224
224
|
/** The places "Move to ›" offers for an item, in order (the library's `stops` places); absent: the stops check is skipped. */
|
|
225
225
|
stops?(item: string): readonly ScenePlace[];
|
|
226
|
+
/** The pick rule the host aims with (see {@link PickRule}); the runner never calls it. */
|
|
227
|
+
readonly pick?: PickRule;
|
|
226
228
|
}
|
|
229
|
+
/**
|
|
230
|
+
* The pick rule: which of `list` the pointer at `point` is over, or null. There is one, `@n-uf/motion/drag`'s
|
|
231
|
+
* `targetAt` (the lowest priority number, then the smallest zone; a rect holds its edges exactly; `hits` all count), and
|
|
232
|
+
* every host passes it: placement doesn't import motion, so the host takes the rule as an input. A `move` lands the
|
|
233
|
+
* pointer over the target this rule picks, and `resolvePlace` aims with it.
|
|
234
|
+
*/
|
|
235
|
+
type PickRule = (list: readonly SceneTarget[], point: Point) => SceneTarget | null;
|
|
227
236
|
/**
|
|
228
237
|
* A `CaseHost` whose calls may be async (a page a browser runner drives with real pointer events and timers): each of
|
|
229
238
|
* `load`, `perform`, `layout`, `root`, `stored` and `stops` may return a promise. `itemSelector` stays a plain value.
|
|
@@ -237,6 +246,8 @@ interface AsyncCaseHost {
|
|
|
237
246
|
itemSelector?(id: string): string;
|
|
238
247
|
stored?(): StoredScene | Promise<StoredScene>;
|
|
239
248
|
stops?(item: string): readonly ScenePlace[] | Promise<readonly ScenePlace[]>;
|
|
249
|
+
/** The pick rule the host aims with, a plain value (see {@link PickRule}); the runner never calls it. */
|
|
250
|
+
readonly pick?: PickRule;
|
|
240
251
|
}
|
|
241
252
|
interface CaseResult {
|
|
242
253
|
readonly ok: boolean;
|
|
@@ -248,12 +259,13 @@ interface CaseResult {
|
|
|
248
259
|
/**
|
|
249
260
|
* The in-memory reference host: a `CaseHost` with no page, no pointer and no clock, only the scene. It plays gestures
|
|
250
261
|
* the way a page's drag session does: a press on a handle, the first move past the lift threshold lifting the item and
|
|
251
|
-
* asking `targets` for every drop target, a pointer over the most precise of them (`
|
|
252
|
-
*
|
|
253
|
-
* `
|
|
262
|
+
* asking `targets` for every drop target, a pointer over the most precise of them (its `pick`: pass
|
|
263
|
+
* `@n-uf/motion/drag`'s `targetAt`, the one pick rule), the preview drawn from that target's `after.layout`, and a
|
|
264
|
+
* release committing `after.scene`. Every solve carries the layout before it as `previous`. The kits' hosts do the same
|
|
265
|
+
* with their own pointer and DOM; the rows are the contract between them.
|
|
254
266
|
*
|
|
255
|
-
* Also exported: `
|
|
256
|
-
*
|
|
267
|
+
* Also exported: `resolvePlace` (a point that reaches the target at a place, under a pick rule), the pure step a host
|
|
268
|
+
* needs to turn a gesture's `place` into a pointer, and the deprecated `pickTarget` (the default pick).
|
|
257
269
|
*/
|
|
258
270
|
|
|
259
271
|
/** The lift threshold: the pointer moves this far (px) from the press before the item lifts. */
|
|
@@ -263,6 +275,12 @@ declare const END_REACH = 24;
|
|
|
263
275
|
/**
|
|
264
276
|
* The most precise target under `point`: the lowest priority number, then the smallest zone; null when none is. A
|
|
265
277
|
* target with `hits` is under the point in any of them, and its zone's size is theirs together.
|
|
278
|
+
*
|
|
279
|
+
* @deprecated The pick rule is `@n-uf/motion/drag`'s `targetAt`: pass it as `createSceneHost({ pick: targetAt })` and
|
|
280
|
+
* to `resolvePlace`. This is only the reference host's default when none is given (placement doesn't import motion),
|
|
281
|
+
* the same rule with the same tolerances: a rect holds its edges exactly, with no epsilon, and a zone's size is the sum
|
|
282
|
+
* of width × height over its pieces. A test holds it equal to `targetAt`. Removed in the release that drops the legacy
|
|
283
|
+
* entries.
|
|
266
284
|
*/
|
|
267
285
|
declare function pickTarget<T extends {
|
|
268
286
|
readonly priority: number;
|
|
@@ -276,11 +294,12 @@ interface AimArea {
|
|
|
276
294
|
}
|
|
277
295
|
/**
|
|
278
296
|
* A pointer position that reaches the target at `place`: inside its hit and not covered by a more precise target
|
|
279
|
-
* (`
|
|
280
|
-
*
|
|
281
|
-
* reaches it (a gap that a home or
|
|
297
|
+
* (`pick` finds it there: the host's pick rule, `@n-uf/motion/drag`'s `targetAt`; default the same rule, `pickTarget`).
|
|
298
|
+
* It tries the hit's centre, then a grid across the hit; a target over the whole plane (the float) is aimed at the
|
|
299
|
+
* content's centre, then the stage's, then a grid across the stage. Null when no point reaches it (a gap that a home or
|
|
300
|
+
* a blocked spot covers entirely).
|
|
282
301
|
*/
|
|
283
|
-
declare function resolvePlace(list: readonly SceneTarget[], place: ScenePlace, item: string, area_: AimArea): Point | null;
|
|
302
|
+
declare function resolvePlace(list: readonly SceneTarget[], place: ScenePlace, item: string, area_: AimArea, pick?: PickRule): Point | null;
|
|
284
303
|
/** What the in-memory host knows about a drag in progress. */
|
|
285
304
|
interface HostDrag {
|
|
286
305
|
readonly item: string;
|
|
@@ -299,6 +318,8 @@ interface SceneHost extends CaseHost {
|
|
|
299
318
|
stored(): StoredScene;
|
|
300
319
|
/** The drag in progress, or null. */
|
|
301
320
|
drag(): HostDrag | null;
|
|
321
|
+
/** The pick rule it aims with: the one in its options, else the default. */
|
|
322
|
+
readonly pick: PickRule;
|
|
302
323
|
}
|
|
303
324
|
interface SceneHostOptions {
|
|
304
325
|
/** How far past an edge's ends its end gaps reach, px (default {@link END_REACH}). */
|
|
@@ -307,6 +328,11 @@ interface SceneHostOptions {
|
|
|
307
328
|
readonly lift?: number;
|
|
308
329
|
/** Where a press with no `point` holds the item, px from its top-left corner (default 8, 8). A test varies it to prove no row depends on it. */
|
|
309
330
|
readonly grab?: Point;
|
|
331
|
+
/**
|
|
332
|
+
* The pick rule: which target the pointer is over. Pass `@n-uf/motion/drag`'s `targetAt`, the rule a kit's drag intent
|
|
333
|
+
* runs, so the reference host and the kit agree on every boundary pixel. Default: the same rule (`pickTarget`).
|
|
334
|
+
*/
|
|
335
|
+
readonly pick?: PickRule;
|
|
310
336
|
}
|
|
311
337
|
declare function createSceneHost(options?: SceneHostOptions): SceneHost;
|
|
312
338
|
|
|
@@ -442,4 +468,4 @@ declare const CASE_GROUPS: readonly {
|
|
|
442
468
|
/** The row with this id, or undefined. */
|
|
443
469
|
declare const caseById: (id: string) => CaseRow | undefined;
|
|
444
470
|
|
|
445
|
-
export { type AimArea, type AsyncCaseHost, CASES, CASE_GROUPS, type CaseGroup, type CaseHost, type CaseResult, type CaseRow, type CaseSettings, type Checkpoint, type DomCheck, type DomRoot, END_REACH, type EdgeExpect, type Gesture, type GestureType, type ItemExpect, LIFT_THRESHOLD, type LayoutExpect, type SceneHost, type SceneHostOptions, type StoredExpect, WINDOW_A, WINDOW_B, WINDOW_BARE, type WinOptions, type WinSpec, caseById, createSceneHost, defaultItemSelector, g, layoutIssues, pickTarget, resolvePlace, runCase, runCaseAsync, runCases, runCasesAsync, winScene };
|
|
471
|
+
export { type AimArea, type AsyncCaseHost, CASES, CASE_GROUPS, type CaseGroup, type CaseHost, type CaseResult, type CaseRow, type CaseSettings, type Checkpoint, type DomCheck, type DomRoot, END_REACH, type EdgeExpect, type Gesture, type GestureType, type ItemExpect, LIFT_THRESHOLD, type LayoutExpect, type PickRule, type SceneHost, type SceneHostOptions, type StoredExpect, WINDOW_A, WINDOW_B, WINDOW_BARE, type WinOptions, type WinSpec, caseById, createSceneHost, defaultItemSelector, g, layoutIssues, pickTarget, resolvePlace, runCase, runCaseAsync, runCases, runCasesAsync, winScene };
|
package/dist/scene-cases.js
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
fold,
|
|
6
6
|
homeFor,
|
|
7
7
|
open,
|
|
8
|
+
placeTargetId,
|
|
8
9
|
raise,
|
|
9
10
|
readScene,
|
|
10
11
|
resize,
|
|
@@ -13,10 +14,9 @@ import {
|
|
|
13
14
|
storeScene,
|
|
14
15
|
targets,
|
|
15
16
|
use
|
|
16
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-3GIUOVQH.js";
|
|
17
18
|
import "./chunk-IHU6IOZH.js";
|
|
18
19
|
import {
|
|
19
|
-
area,
|
|
20
20
|
centre,
|
|
21
21
|
contains,
|
|
22
22
|
rect
|
|
@@ -1029,8 +1029,8 @@ function withTitle(s) {
|
|
|
1029
1029
|
items: { ...s.items, "window-title": { id: "window-title", kind: "title", used: 0, fixed: true, forms: { row: [form("row", 80, 160, 28, { grows: true })] } } }
|
|
1030
1030
|
};
|
|
1031
1031
|
}
|
|
1032
|
-
var LEFT_OUT = 6;
|
|
1033
1032
|
var RIGHT_EDGE = 1108;
|
|
1033
|
+
var LINE_OUT = 1;
|
|
1034
1034
|
var GESTURE_ROWS = [
|
|
1035
1035
|
{
|
|
1036
1036
|
id: "P1-lift-follows-and-nothing-reflows",
|
|
@@ -1106,16 +1106,16 @@ var GESTURE_ROWS = [
|
|
|
1106
1106
|
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 kits' older "neighbour half that faces it is its own place" no longer holds.`,
|
|
1107
1107
|
group: "gestures",
|
|
1108
1108
|
scene: win(),
|
|
1109
|
-
gestures: [g.press("annotations", { x: 20, y: 10 }), g.at(160,
|
|
1110
|
-
expectLayout: { items: { pages: { rect: rect(12, 0, 300, 800) }, annotations: { floating: true, rect: rect(312,
|
|
1109
|
+
gestures: [g.press("annotations", { x: 20, y: 10 }), g.at(160, 200), g.hold(), g.release()],
|
|
1110
|
+
expectLayout: { items: { pages: { rect: rect(12, 0, 300, 800) }, annotations: { floating: true, rect: rect(312, 190, 280, 360) } }, floats: ["annotations"], columns: { left: [["pages"]], right: [["findings"]] } }
|
|
1111
1111
|
},
|
|
1112
1112
|
{
|
|
1113
1113
|
id: "P6-new-outer-column-from-outside",
|
|
1114
1114
|
title: "A new outer column from outside the right column",
|
|
1115
|
-
expect: "Let go
|
|
1115
|
+
expect: "Let go 1 px outside the right column's outer edge (11 px from the window's edge, past the rail stop's 10), at 5%, 50% or 95% of the stage's height, Annotations makes the outermost column, on the slot's rect.",
|
|
1116
1116
|
group: "gestures",
|
|
1117
1117
|
scene: win(),
|
|
1118
|
-
gestures: [g.press("annotations"), g.at(RIGHT_EDGE +
|
|
1118
|
+
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()],
|
|
1119
1119
|
checkpoints: [
|
|
1120
1120
|
{ at: 2, layout: { items: { pages: { rect: rect(12, 0, 220, 800) }, annotations: { edge: "right-1", rect: rect(888, 0, 220, 800) }, findings: { edge: "right-0", rect: rect(576, 0, 300, 800) } }, columns: { left: [["pages"]], right: [["annotations"], ["findings"]] }, notes: { has: ["column-shrunk"] } }, note: "5%" },
|
|
1121
1121
|
{ at: 4, layout: { items: { pages: { rect: rect(12, 0, 220, 800) }, annotations: { edge: "right-1", rect: rect(888, 0, 220, 800) }, findings: { edge: "right-0", rect: rect(576, 0, 300, 800) } }, columns: { left: [["pages"]], right: [["annotations"], ["findings"]] }, notes: { has: ["column-shrunk"] } }, note: "50%" },
|
|
@@ -1135,10 +1135,10 @@ var GESTURE_ROWS = [
|
|
|
1135
1135
|
{
|
|
1136
1136
|
id: "P6-left-outer-edge",
|
|
1137
1137
|
title: "A new outer column on the left",
|
|
1138
|
-
expect: "Findings let go
|
|
1138
|
+
expect: "Findings let go 1 px outside the left column's outer edge (11 px from the window's edge, past the rail stop's 10) makes the outermost left column; the right side is then empty.",
|
|
1139
1139
|
group: "gestures",
|
|
1140
1140
|
scene: win(),
|
|
1141
|
-
gestures: [g.press("findings"), g.at(12 -
|
|
1141
|
+
gestures: [g.press("findings"), g.at(12 - LINE_OUT, 400), g.hold(), g.release()],
|
|
1142
1142
|
expectLayout: { items: { findings: { edge: "left-1", rect: rect(12, 0, 220, 800) }, pages: { rect: rect(244, 0, 300, 394) }, annotations: { rect: rect(244, 406, 300, 394) } }, columns: { left: [["findings"], ["pages", "annotations"]], right: [] } }
|
|
1143
1143
|
},
|
|
1144
1144
|
{
|
|
@@ -1471,8 +1471,9 @@ var WINDOW_ROWS = [...windowRows(), ...HAND];
|
|
|
1471
1471
|
var LIFT_THRESHOLD = 4;
|
|
1472
1472
|
var END_REACH = 24;
|
|
1473
1473
|
function pickTarget(list, point) {
|
|
1474
|
-
const
|
|
1475
|
-
const
|
|
1474
|
+
const holds = (r) => point.x >= r.x && point.x <= r.x + r.width && point.y >= r.y && point.y <= r.y + r.height;
|
|
1475
|
+
const under = (t) => t.hits ? t.hits.some(holds) : holds(t.hit);
|
|
1476
|
+
const size = (t) => t.hits ? t.hits.reduce((s, r) => s + r.width * r.height, 0) : t.hit.width * t.hit.height;
|
|
1476
1477
|
let best = null;
|
|
1477
1478
|
for (const t of list) {
|
|
1478
1479
|
if (!under(t)) continue;
|
|
@@ -1480,27 +1481,11 @@ function pickTarget(list, point) {
|
|
|
1480
1481
|
}
|
|
1481
1482
|
return best;
|
|
1482
1483
|
}
|
|
1483
|
-
function targetIdOf(place, item) {
|
|
1484
|
-
switch (place.kind) {
|
|
1485
|
-
case "gap":
|
|
1486
|
-
return `gap:${place.edge}:${place.zone}:${place.at}`;
|
|
1487
|
-
case "column":
|
|
1488
|
-
return `column:${place.side}:${place.ring}`;
|
|
1489
|
-
case "rail":
|
|
1490
|
-
return `rail:${place.side}:${place.ring}`;
|
|
1491
|
-
case "float":
|
|
1492
|
-
return `float:${item}`;
|
|
1493
|
-
case "home":
|
|
1494
|
-
return `home:${item}`;
|
|
1495
|
-
default:
|
|
1496
|
-
return null;
|
|
1497
|
-
}
|
|
1498
|
-
}
|
|
1499
1484
|
function targetAt(list, place, item) {
|
|
1500
|
-
const id =
|
|
1485
|
+
const id = placeTargetId(place, item);
|
|
1501
1486
|
return (id ? list.find((t) => t.id === id) : void 0) ?? list.find((t) => t.place.kind === place.kind && (place.kind === "none" || id === null)) ?? null;
|
|
1502
1487
|
}
|
|
1503
|
-
function resolvePlace(list, place, item, area_) {
|
|
1488
|
+
function resolvePlace(list, place, item, area_, pick = pickTarget) {
|
|
1504
1489
|
const t = targetAt(list, place, item);
|
|
1505
1490
|
if (!t) return null;
|
|
1506
1491
|
const big = t.hit.width > 1e6 || t.hit.height > 1e6;
|
|
@@ -1515,13 +1500,14 @@ function resolvePlace(list, place, item, area_) {
|
|
|
1515
1500
|
for (const fy of [0.5, 0.25, 0.75, 0.1, 0.9, 0.4, 0.6, 0, 1]) {
|
|
1516
1501
|
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 });
|
|
1517
1502
|
}
|
|
1518
|
-
return candidates.find((p) => contains(t.hit, p) &&
|
|
1503
|
+
return candidates.find((p) => contains(t.hit, p) && pick(list, p) === t) ?? null;
|
|
1519
1504
|
}
|
|
1520
1505
|
var stageRect = (w, h) => ({ x: 0, y: 0, width: w, height: h });
|
|
1521
1506
|
function createSceneHost(options = {}) {
|
|
1522
1507
|
const endReach = options.endReach ?? END_REACH;
|
|
1523
1508
|
const lifted0 = options.lift ?? LIFT_THRESHOLD;
|
|
1524
1509
|
const defaultGrab = options.grab ?? { x: 8, y: 8 };
|
|
1510
|
+
const pick = options.pick ?? pickTarget;
|
|
1525
1511
|
let start = null;
|
|
1526
1512
|
let scene = null;
|
|
1527
1513
|
let committed = null;
|
|
@@ -1552,23 +1538,23 @@ function createSceneHost(options = {}) {
|
|
|
1552
1538
|
function liftNow(s) {
|
|
1553
1539
|
s.lifted = true;
|
|
1554
1540
|
s.list = targets(now(), s.item, { previous: prev(), endReach });
|
|
1555
|
-
s.target =
|
|
1541
|
+
s.target = pick(s.list, s.point);
|
|
1556
1542
|
}
|
|
1557
1543
|
function move(g2) {
|
|
1558
1544
|
const s = session;
|
|
1559
1545
|
if (!s) return;
|
|
1560
1546
|
if (g2.place) {
|
|
1561
1547
|
if (!s.lifted) liftNow(s);
|
|
1562
|
-
const p = resolvePlace(s.list, g2.place, s.item, aim());
|
|
1548
|
+
const p = resolvePlace(s.list, g2.place, s.item, aim(), pick);
|
|
1563
1549
|
if (!p) throw new Error(`no point reaches the target at ${JSON.stringify(g2.place)} (targets: ${s.list.map((t) => t.id).join(", ") || "none"})`);
|
|
1564
1550
|
s.point = p;
|
|
1565
|
-
s.target =
|
|
1551
|
+
s.target = pick(s.list, p);
|
|
1566
1552
|
return;
|
|
1567
1553
|
}
|
|
1568
1554
|
if (!g2.point) throw new Error("a move needs a point or a place");
|
|
1569
1555
|
s.point = { x: g2.point.x, y: g2.point.y };
|
|
1570
1556
|
if (!s.lifted && Math.hypot(s.point.x - s.down.x, s.point.y - s.down.y) > lifted0) liftNow(s);
|
|
1571
|
-
else if (s.lifted) s.target =
|
|
1557
|
+
else if (s.lifted) s.target = pick(s.list, s.point);
|
|
1572
1558
|
}
|
|
1573
1559
|
function press(g2) {
|
|
1574
1560
|
session = null;
|
|
@@ -1725,6 +1711,7 @@ function createSceneHost(options = {}) {
|
|
|
1725
1711
|
scene: now,
|
|
1726
1712
|
stored: () => storeScene(now()),
|
|
1727
1713
|
stops: (item) => stops(now(), item, { previous: prev(), endReach }).map((t) => t.place),
|
|
1714
|
+
pick,
|
|
1728
1715
|
drag: () => session ? { item: session.item, lifted: session.lifted, target: session.target?.id ?? null, point: session.point, grab: session.grab } : null
|
|
1729
1716
|
};
|
|
1730
1717
|
}
|