@n-uf/placement 26.12.7 → 26.12.8
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 +42 -0
- package/dist/tiling.d.ts +152 -31
- package/dist/tiling.js +250 -49
- package/dist/tiling.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,48 @@ Versions are calendar versions, `YY.M.R` (year, month of the release, counter wi
|
|
|
5
5
|
|
|
6
6
|
Unreleased entries live in `changes/` until a release joins them.
|
|
7
7
|
|
|
8
|
+
## 26.12.8
|
|
9
|
+
|
|
10
|
+
- **Changed:** `tilingDrag`, `tilingConformance` and `tilingHitConformance` take a `fold` key; in 26.12.7 they threw
|
|
11
|
+
on one. `layoutSplit`, `splitNeed`, `canDropOnPane`, `canSplitPane` and `dropFits` still throw when their options
|
|
12
|
+
hold a `fold` key ("use layoutSplitTree").
|
|
13
|
+
- **Added:** the drag over a folding split tree. `tilingDrag(tree, subject, { ...options, fold })` lays the lift, the
|
|
14
|
+
base and every `after` out with `layoutSplitTree` and the fold, each with its own order: the lift with `fold.order`
|
|
15
|
+
(the host's), the base with the panes open at the lift first (a tab torn out of a stack leaves its stack mates in
|
|
16
|
+
its place), a change with the subject first, then those. For
|
|
17
|
+
consumers: pass the `fold` you draw with, draw what the drag gives, and when a release commits `after.tree`, store
|
|
18
|
+
`after.order` with it in the same step, so the next frame draws the layout the preview showed. A pane the base folds
|
|
19
|
+
is refused `folded`; a pane open at the lift that the base folds keeps its target on the lift basis with every place
|
|
20
|
+
refused. Under a fold there is no room rule (`room-along`, `room-across`): an accepted place lands the subject open
|
|
21
|
+
and at least `min`, and the pane it was dropped on may fold. A subject folded at the lift (a pane carried in) has its
|
|
22
|
+
spine segment as its lift rect and no `home`. `dropFits` takes `folded`, the panes a folding layout folds (an `at`
|
|
23
|
+
among them is not judged); `canSplitPane` and `dropFits` read no fold (under a fold the drag has no room rule).
|
|
24
|
+
Without `fold`, the drag gives what it gave.
|
|
25
|
+
- **Added:** `TilingLaidOut.order`, `.spines` and `.folds`, `TilingAfter.opened` and `.closed` (the panes a change
|
|
26
|
+
opens and folds against the lift), `DropFitsOptions.folded`; `TilingDragOptions` takes `fold`
|
|
27
|
+
(`FoldingSplitOptions`). All empty or absent without a fold.
|
|
28
|
+
- **Changed (breaking, types):** `TilingRefusal` has a new code, `folded`, so an exhaustive `switch` over refusal codes
|
|
29
|
+
stops compiling until it handles it, whether or not the host passes a fold. `TilingLaidOut` and `TilingAfter` have
|
|
30
|
+
new required fields (`order`, `spines`, `folds`; `opened`, `closed`), so code that builds one itself (a test double)
|
|
31
|
+
must add them: `order: [], spines: new Map(), folds: []`, `opened: [], closed: []`.
|
|
32
|
+
- **Added:** the hit over a folding split tree. Every point of a rail's box takes no place and holds nothing;
|
|
33
|
+
`TilingHitRead.folded` and `hit.foldedAt(point)` (`TilingFolded`, `{ rail, pane }`) give the rail under the pointer
|
|
34
|
+
and the pane painted there, null in a gap. `tilingConformance` and `tilingHitConformance` take a fold, with new
|
|
35
|
+
properties `folded-refused`, `spine-no-place` and `named-case-refused`. For consumers: pass the same `fold` to the
|
|
36
|
+
conformance runs as to the drag.
|
|
37
|
+
- **Added:** the strip option. `SplitFold.segmentFloor`, a spine segment's least length: the floor used is the smaller
|
|
38
|
+
of it and the rail box's length, and on a rail whose shortest segment would fall under it every segment is that
|
|
39
|
+
long, so the rail's content may run past its box; it moves nothing but segments. `SplitFoldGeometry.railContentLength`,
|
|
40
|
+
the rail's content length. `paintedSpines(layout, railOffset?)` (with `RailOffset` and `FoldedLayout`), each segment
|
|
41
|
+
as painted at the host's offsets, cut to its rail's box. `TilingDragOptions.railOffset`, the host's offset per rail,
|
|
42
|
+
read by the hit at every read. For consumers: `spines` are content positions; where a rail's content runs past its
|
|
43
|
+
box, draw `paintedSpines` and pass the same offsets to the drag.
|
|
44
|
+
- **Changed (breaking, types):** `SplitFoldGeometry` has a new required field, `railContentLength`, `TilingHitRead`
|
|
45
|
+
a new required field, `folded`, and `TilingHit` a new method, `foldedAt(point)`, so code that builds one itself (a
|
|
46
|
+
test double) must add them (`railContentLength`: the rail's length along its edge; `folded: null`;
|
|
47
|
+
`foldedAt: () => null`). `TILING_PROPERTIES` and
|
|
48
|
+
`TILING_HIT_PROPERTIES` have new names, so a host that keys a table by them sees the new rows.
|
|
49
|
+
|
|
8
50
|
## 26.12.7
|
|
9
51
|
|
|
10
52
|
- **Added:** a folding split tree. `layoutSplitTree(tree, area, { ...options, fold })` folds a split that cannot keep
|
package/dist/tiling.d.ts
CHANGED
|
@@ -179,6 +179,14 @@ interface SplitFold<K> {
|
|
|
179
179
|
readonly targetOrder?: readonly K[];
|
|
180
180
|
/** What a pane counts when panes kept open are counted: 1, or 0 for a pane that shows nothing. Default 1. */
|
|
181
181
|
readonly weight?: (pane: K) => 0 | 1;
|
|
182
|
+
/**
|
|
183
|
+
* A spine segment's least length along its rail, px. Absent or 0: a rail's segments share its box, however short.
|
|
184
|
+
* Above 0, the floor used is the smaller of it and the rail box's length; where a rail's shortest segment would fall
|
|
185
|
+
* under it, every segment on that rail is that floor long, 2 px apart, and the rail's content runs past its box
|
|
186
|
+
* (`SplitFoldGeometry.railContentLength`; the host shows a part of it, `paintedSpines`). A fold on the rail whose
|
|
187
|
+
* panes all show nothing takes one floor length and has no segment. The floor moves nothing but segments.
|
|
188
|
+
*/
|
|
189
|
+
readonly segmentFloor?: number;
|
|
182
190
|
}
|
|
183
191
|
/** One folded split of a laid-out tree (`SplitLayout.folds`). */
|
|
184
192
|
interface SplitFoldGeometry<K> {
|
|
@@ -197,10 +205,20 @@ interface SplitFoldGeometry<K> {
|
|
|
197
205
|
* fold's rail gives up nothing, so its open side is the split's whole box.
|
|
198
206
|
*/
|
|
199
207
|
readonly openRect: Rect;
|
|
200
|
-
/**
|
|
208
|
+
/**
|
|
209
|
+
* The spine: its part of the rail's content, the whole rail when the rail holds this fold alone. A content position:
|
|
210
|
+
* placed from the rail box's top or left as if the content were not moved; it is where the spine is painted only
|
|
211
|
+
* where the content fits the box (`railContentLength`) and the host's offset is 0, else see `paintedSpines`.
|
|
212
|
+
*/
|
|
201
213
|
readonly spine: Rect;
|
|
202
|
-
/** The whole rail's box, on `edge`, the spine's thickness across the split's axis. */
|
|
214
|
+
/** The whole rail's box, on `edge`, the spine's thickness across the split's axis: where its content is painted. */
|
|
203
215
|
readonly rail: Rect;
|
|
216
|
+
/**
|
|
217
|
+
* The rail's content length along its edge: the box's length, unless a segment floor (`SplitFold.segmentFloor`)
|
|
218
|
+
* lengthened it. The same on every fold of one rail. A host that moves the content by hand moves it by 0 to this
|
|
219
|
+
* length less the box's.
|
|
220
|
+
*/
|
|
221
|
+
readonly railContentLength: number;
|
|
204
222
|
/**
|
|
205
223
|
* The index in `folds` of the fold heading the rail this spine is drawn in: its own, or that of the enclosing fold on
|
|
206
224
|
* the same edge whose rail it joined (a fold whose box starts where that fold's open side starts on the edge, and
|
|
@@ -353,7 +371,10 @@ interface SplitGeometry {
|
|
|
353
371
|
/**
|
|
354
372
|
* A tree laid out: every open pane's rect, the geometry of each split that has an `id` and is drawn with its two sides,
|
|
355
373
|
* and, under a fold (`layoutSplitTree`'s `fold`), each folded pane's segment of its spine and the folds, outermost
|
|
356
|
-
* first. Without a fold, `spines` and `folds` are empty.
|
|
374
|
+
* first. Without a fold, `spines` and `folds` are empty. A segment in `spines` is a content position, placed from its
|
|
375
|
+
* rail box's top or left: it is where the segment is painted only where the rail's content fits its box
|
|
376
|
+
* (`SplitFoldGeometry.railContentLength`) and the host's offset is 0; `paintedSpines` gives where each is painted at a
|
|
377
|
+
* rail offset.
|
|
357
378
|
*/
|
|
358
379
|
interface SplitLayout<K> {
|
|
359
380
|
readonly panes: Map<K, Rect>;
|
|
@@ -423,28 +444,41 @@ interface SplitRoomOptions {
|
|
|
423
444
|
* The room rule: whether a pane of rect `target` can take another on `side`, both at least `options.min` wide and
|
|
424
445
|
* high. Along the split (width for left and right, height for top and bottom) the pane needs `2 * min` plus the
|
|
425
446
|
* gutter (`gap` plus `handle`), across it `min`. The rect is the pane's as the host measures it, where it will be
|
|
426
|
-
* when the dragged pane is lifted out. `canDropOnPane`'s first rule, for a side.
|
|
447
|
+
* when the dragged pane is lifted out. `canDropOnPane`'s first rule, for a side. Reads no fold: throws when `options`
|
|
448
|
+
* holds a `fold` key (under a fold the drag has no room rule).
|
|
427
449
|
*/
|
|
428
450
|
declare function canSplitPane(target: Rect, side: Side, options: SplitRoomOptions): DropVerdict;
|
|
429
|
-
/**
|
|
430
|
-
|
|
451
|
+
/**
|
|
452
|
+
* What `dropFits` reads: the `min` (as in `DropOptions`), the `side` of `at` the drop is on, for the reason, and under
|
|
453
|
+
* a fold the panes the projected layout folds.
|
|
454
|
+
*/
|
|
455
|
+
interface DropFitsOptions<K = unknown> {
|
|
431
456
|
readonly min: number;
|
|
432
457
|
readonly side: Side;
|
|
458
|
+
/**
|
|
459
|
+
* The panes the projected layout folds (a folding layout's `folds`, their `panes`): a folded `at` is not judged, as
|
|
460
|
+
* the drop may fold it. `dragged` is judged whatever this holds: it must be drawn open. Default: none.
|
|
461
|
+
*/
|
|
462
|
+
readonly folded?: ReadonlySet<K>;
|
|
433
463
|
}
|
|
434
464
|
/**
|
|
435
|
-
* The fit rule: in `projected`, the rect of every pane in the layout the drop makes (the host's own
|
|
436
|
-
* `dropOnPane`'s tree), whether `dragged` and `at` are both there and at least `options.min` wide and
|
|
437
|
-
* `EPS` (a floor of `min` lands at `min` up to float error)
|
|
438
|
-
* nothing to measure). `canDropOnPane`'s last rule.
|
|
465
|
+
* The fit rule: in `projected`, the rect of every pane drawn open in the layout the drop makes (the host's own
|
|
466
|
+
* projection of `dropOnPane`'s tree), whether `dragged` and `at` are both there and at least `options.min` wide and
|
|
467
|
+
* high, to within `EPS` (a floor of `min` lands at `min` up to float error); an `at` in `options.folded` is not judged.
|
|
468
|
+
* Fine when `area` has no width or no height (there is nothing to measure). `canDropOnPane`'s last rule. Reads no fold
|
|
469
|
+
* (a folding host passes the folded panes as `folded`): throws when `options` holds a `fold` key.
|
|
439
470
|
*/
|
|
440
|
-
declare function dropFits<K>(projected: ReadonlyMap<K, Rect>, dragged: K, at: K, area: Rect, options: DropFitsOptions): DropVerdict;
|
|
471
|
+
declare function dropFits<K>(projected: ReadonlyMap<K, Rect>, dragged: K, at: K, area: Rect, options: DropFitsOptions<K>): DropVerdict;
|
|
441
472
|
|
|
442
473
|
/**
|
|
443
474
|
* `layoutSplitTree`: the split tree laid out, folding or not. One function lays the tree out, so what a host draws,
|
|
444
475
|
* what a drag hits and what is judged to fit all come from it. See docs/placement.md, Entry: tiling.
|
|
445
476
|
*/
|
|
446
477
|
|
|
447
|
-
/**
|
|
478
|
+
/**
|
|
479
|
+
* `SplitOptions` plus the fold, which only `layoutSplitTree` (and the drag and its conformance runs) takes:
|
|
480
|
+
* `layoutSplit`, `splitNeed`, `canDropOnPane`, `canSplitPane` and `dropFits` throw on it.
|
|
481
|
+
*/
|
|
448
482
|
interface FoldingSplitOptions<K> extends SplitOptions<K> {
|
|
449
483
|
readonly fold?: SplitFold<K>;
|
|
450
484
|
}
|
|
@@ -459,11 +493,38 @@ interface FoldingSplitOptions<K> extends SplitOptions<K> {
|
|
|
459
493
|
* fold chose. Every split outside a master split then needs an `axis` (throws otherwise); a master split never folds.
|
|
460
494
|
* Where nothing folds and no boundary moves, the panes and splits are those without the fold on the same
|
|
461
495
|
* `options.floor`: with `fold`, a kept split's net is on where there is no `floor` (a ratio of 0.02 lays out at 20 px of
|
|
462
|
-
* 1000 without the fold, 50 px with it). A spine has a segment per folded pane that shows (weight 1)
|
|
463
|
-
*
|
|
496
|
+
* 1000 without the fold, 50 px with it). A spine has a segment per folded pane that shows (weight 1), at a content
|
|
497
|
+
* position (`paintedSpines` gives where it is painted). `tilingDrag` takes the fold too and lays every tree of a drag
|
|
498
|
+
* out here, and so do the conformance runs. See `SplitFold`.
|
|
464
499
|
*/
|
|
465
500
|
declare function layoutSplitTree<K>(tree: Split<K> | null, area: Rect, options?: FoldingSplitOptions<K>): SplitLayout<K>;
|
|
466
501
|
|
|
502
|
+
/**
|
|
503
|
+
* Where a folding layout's spine segments are painted: `paintedSpines(layout, railOffset)`. A rail whose content runs
|
|
504
|
+
* past its box (a segment floor, `SplitFold.segmentFloor`) shows a part of it, moved by the host's offset; the layout's
|
|
505
|
+
* `spines` are content positions, this is what is painted. The drag's hit reads it too, so a point over a rail answers
|
|
506
|
+
* the pane painted there. Pure. See docs/placement.md, Entry: tiling, "A folding split tree".
|
|
507
|
+
*/
|
|
508
|
+
|
|
509
|
+
/** What a painted rail reads of a layout: its segments and its folds (a `SplitLayout`, or a drag's `TilingLaidOut`). */
|
|
510
|
+
interface FoldedLayout<K> {
|
|
511
|
+
readonly spines: ReadonlyMap<K, Rect>;
|
|
512
|
+
readonly folds: readonly SplitFoldGeometry<K>[];
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* How far a rail's content is moved along its edge, px, from the rail box's top or left (on a right-to-left page too:
|
|
516
|
+
* the host converts). Asked with the fold heading the rail (`folds[railOf]`) and its index in `folds`, the host's key
|
|
517
|
+
* for the rail. Not clamped: a segment moved past the box is cut, or not painted. A value that is not a finite number
|
|
518
|
+
* reads 0.
|
|
519
|
+
*/
|
|
520
|
+
type RailOffset<K> = (rail: SplitFoldGeometry<K>, index: number) => number;
|
|
521
|
+
/**
|
|
522
|
+
* Each spine segment of `layout` as it is painted: moved by its rail's offset along the rail (`railOffset`, default 0
|
|
523
|
+
* everywhere) and cut to the rail's box; a segment wholly off the box is absent. Where a rail's content fits its box
|
|
524
|
+
* and the offset is 0, this is `layout.spines`. Pure: every call reads the offsets anew.
|
|
525
|
+
*/
|
|
526
|
+
declare function paintedSpines<K>(layout: FoldedLayout<K>, railOffset?: RailOffset<K>): Map<K, Rect>;
|
|
527
|
+
|
|
467
528
|
/**
|
|
468
529
|
* The shapes a tiling drag's two halves share: the host's tree as an adapter (`TilingTree`) with its stacks, parts and
|
|
469
530
|
* subjects, a held place (`TilingHeld`) and the layout it gives (`TilingAfter`). The layout half (./drag) and the hit
|
|
@@ -548,7 +609,7 @@ interface TilingTree<T, K> {
|
|
|
548
609
|
*/
|
|
549
610
|
parts?(tree: T, pane: K, rect: Rect): readonly TilingPart[];
|
|
550
611
|
}
|
|
551
|
-
/** A held place of a drag: where a release now lands. `at` is
|
|
612
|
+
/** A held place of a drag: where a release now lands. `at` is a pane drawn in the base (or, under a fold, one the base folds: refused `folded`). */
|
|
552
613
|
type TilingHeld<K> = {
|
|
553
614
|
readonly kind: "home";
|
|
554
615
|
} | {
|
|
@@ -568,16 +629,18 @@ type TilingHeld<K> = {
|
|
|
568
629
|
* - `self`: the place is the subject's own (a swap or side of the subject itself, a swap with its own stack, a whole
|
|
569
630
|
* stack joined to itself);
|
|
570
631
|
* - `still`: `at` is a still pane;
|
|
571
|
-
* - `missing`: `at` is not a pane drawn in the base;
|
|
632
|
+
* - `missing`: `at` is not a pane drawn in the base, nor one the base folds;
|
|
633
|
+
* - `folded`: under a fold, `at` is a pane the base folds (a spine's, or one that shows nothing);
|
|
572
634
|
* - `join`: the adapter has no `join`;
|
|
573
635
|
* - `room-along`, `room-across`: `at` is too short for two panes along the split, or too narrow across it, in the base
|
|
574
|
-
* (`canSplitPane`): `need` and `have` px
|
|
636
|
+
* (`canSplitPane`): `need` and `have` px. Never under a fold: there the one verdict on room is `fit`;
|
|
575
637
|
* - `fit`: in the layout the release makes (a side, a swap or a join), `pane` (the subject's drawn key or `at`'s) is
|
|
576
638
|
* below `min` wide or high, the fit rule of `dropFits`. A swap hands each pane the other's rect, so either may fall
|
|
577
|
-
* below it; a join is judged on the stack's rect.
|
|
639
|
+
* below it; a join is judged on the stack's rect. Under a fold the subject must also be drawn open, and `at` may fold
|
|
640
|
+
* there (then it is not judged).
|
|
578
641
|
*/
|
|
579
642
|
type TilingRefusal<K> = {
|
|
580
|
-
readonly code: "self" | "still" | "missing" | "join";
|
|
643
|
+
readonly code: "self" | "still" | "missing" | "folded" | "join";
|
|
581
644
|
} | {
|
|
582
645
|
readonly code: "room-along" | "room-across";
|
|
583
646
|
readonly need: number;
|
|
@@ -586,11 +649,25 @@ type TilingRefusal<K> = {
|
|
|
586
649
|
readonly code: "fit";
|
|
587
650
|
readonly pane: K;
|
|
588
651
|
};
|
|
589
|
-
/**
|
|
652
|
+
/**
|
|
653
|
+
* A tree laid out: every pane drawn open and its rect, and the geometry of each split that has an id; under a fold
|
|
654
|
+
* (`TilingDragOptions.fold`), each folded pane's spine segment, the folds, and the order the layout was made with.
|
|
655
|
+
*/
|
|
590
656
|
interface TilingLaidOut<T, K> {
|
|
591
657
|
readonly tree: T;
|
|
658
|
+
/** Every pane drawn open, and its rect (`SplitLayout.panes`). */
|
|
592
659
|
readonly layout: ReadonlyMap<K, Rect>;
|
|
593
660
|
readonly splits: ReadonlyMap<string, SplitGeometry>;
|
|
661
|
+
/** Each folded pane that shows, and its spine segment (`SplitLayout.spines`); empty without a fold. */
|
|
662
|
+
readonly spines: ReadonlyMap<K, Rect>;
|
|
663
|
+
/** The folded splits, outermost first (`SplitLayout.folds`); empty without a fold. */
|
|
664
|
+
readonly folds: readonly SplitFoldGeometry<K>[];
|
|
665
|
+
/**
|
|
666
|
+
* The order this layout was made with: `layoutSplitTree(split(tree), area, { ...options, fold: { ...fold, order } })`
|
|
667
|
+
* is this layout. The lift's is the host's `fold.order`; the base's the panes open at the lift (in the lift's order),
|
|
668
|
+
* then the rest; a change's the subject, then the panes open at the lift, then the rest. Empty without a fold.
|
|
669
|
+
*/
|
|
670
|
+
readonly order: readonly K[];
|
|
594
671
|
}
|
|
595
672
|
/** A pane a commit moves, from where it was drawn at the lift to where the commit puts it. */
|
|
596
673
|
interface TilingMove<K> {
|
|
@@ -608,8 +685,12 @@ interface TilingAfter<T, K> extends TilingLaidOut<T, K> {
|
|
|
608
685
|
readonly refusal: TilingRefusal<K> | null;
|
|
609
686
|
/** The subject's rect in `layout`: its own when it is drawn, else its stack's. Null when refused. */
|
|
610
687
|
readonly landing: Rect | null;
|
|
611
|
-
/** Every other drawn
|
|
688
|
+
/** Every other pane drawn open here and at the lift whose rect differs from the lift's (the swap partner, the panes that give room), in `layout`'s order. */
|
|
612
689
|
readonly moved: readonly TilingMove<K>[];
|
|
690
|
+
/** Under a fold, the panes folded at the lift and drawn open here (the subject included), in `layout`'s order; else empty. */
|
|
691
|
+
readonly opened: readonly K[];
|
|
692
|
+
/** Under a fold, the panes drawn open at the lift and folded here, in the lift layout's order; else empty. */
|
|
693
|
+
readonly closed: readonly K[];
|
|
613
694
|
}
|
|
614
695
|
|
|
615
696
|
/**
|
|
@@ -716,6 +797,15 @@ type TilingMark<K> = {
|
|
|
716
797
|
readonly rect: Rect;
|
|
717
798
|
readonly slot: Rect | null;
|
|
718
799
|
};
|
|
800
|
+
/**
|
|
801
|
+
* A point over a rail of a folding layout (`SplitLayout.folds`): the rail (the index in the basis's `folds` of the fold
|
|
802
|
+
* heading it) and the pane whose spine segment is painted there (`paintedSpines`), null in a gap or past the last
|
|
803
|
+
* segment. A rail takes no drop: the whole of its box is refused.
|
|
804
|
+
*/
|
|
805
|
+
interface TilingFolded<K> {
|
|
806
|
+
readonly rail: number;
|
|
807
|
+
readonly pane: K | null;
|
|
808
|
+
}
|
|
719
809
|
/** What a frame reads off the hit. */
|
|
720
810
|
interface TilingHitRead<K> {
|
|
721
811
|
/** The held place, home included; null when nothing is held outside home. */
|
|
@@ -724,6 +814,8 @@ interface TilingHitRead<K> {
|
|
|
724
814
|
readonly refused: TilingHeld<K> | null;
|
|
725
815
|
/** The lift basis's mark for the held place; null on the base basis, at home, and with nothing held. */
|
|
726
816
|
readonly mark: TilingMark<K> | null;
|
|
817
|
+
/** Under a fold, the rail under the pointer and the pane painted there (`hit.foldedAt`); null off every rail. Nothing is held over a rail. */
|
|
818
|
+
readonly folded: TilingFolded<K> | null;
|
|
727
819
|
}
|
|
728
820
|
/**
|
|
729
821
|
* The options a `@n-uf/motion/drag` intent takes to read the hit: no home (home is a place of the hit, held by the one
|
|
@@ -768,8 +860,14 @@ interface TilingHit<T, K> {
|
|
|
768
860
|
* over home the intent may pick the part; its `placeOf` then answers null, and home wins.
|
|
769
861
|
*/
|
|
770
862
|
placeOf(target: TilingHitTarget<K>, point: Point, previous?: string | null): string | null;
|
|
771
|
-
/** The intent's frame at `point`, read: the held place, the refused one,
|
|
863
|
+
/** The intent's frame at `point`, read: the held place, the refused one, the lift basis's mark, and the rail under the pointer. */
|
|
772
864
|
read(frame: TilingHitFrame<TilingHitTarget<K>>, point: Point): TilingHitRead<K>;
|
|
865
|
+
/**
|
|
866
|
+
* Under a fold, the rail of the basis's layout whose box holds `point`, and the pane painted there; null off every
|
|
867
|
+
* rail. On the lift basis the rails are painted at the drag's `railOffset`, read anew at every call; on the base
|
|
868
|
+
* basis at none. Pure.
|
|
869
|
+
*/
|
|
870
|
+
foldedAt(point: Point): TilingFolded<K> | null;
|
|
773
871
|
/** What a frame draws: the lift on the lift basis; on the base basis `after(held)`, the lift at home, the base with nothing held. */
|
|
774
872
|
drawn(read: TilingHitRead<K>): TilingLaidOut<T, K>;
|
|
775
873
|
/** What a release commits: `after(held)`, else home's. */
|
|
@@ -827,19 +925,33 @@ declare function giveWay<K>(panes: readonly K[], layout: (kept: readonly K[]) =>
|
|
|
827
925
|
* The host keeps its own tree type and its own changes; it hands them over as a `TilingTree` adapter. The library owns
|
|
828
926
|
* the rules: what is released and when, which tree each change takes, home, the refusals, and the one layout per held
|
|
829
927
|
* place. Geometry has one source: the adapter gives the tree as a `Split` (`split`), and the library lays it out with
|
|
830
|
-
* `layoutSplitTree` under the drag's options (`SplitOptions` plus `min`, as `canDropOnPane` takes them
|
|
928
|
+
* `layoutSplitTree` under the drag's options (`SplitOptions` plus `min`, as `canDropOnPane` takes them, and the host's
|
|
929
|
+
* `fold`). Under a fold every layout of the drag is folded with its own order (`TilingLaidOut.order`), so the drag hits
|
|
930
|
+
* and judges the rects the host draws.
|
|
831
931
|
*
|
|
832
932
|
* The hit half, which place the pointer is over, is `hit(basis)`: built once per drag on one fixed layout (./hit).
|
|
833
933
|
* See docs/placement.md, Entry: tiling.
|
|
834
934
|
*/
|
|
835
935
|
|
|
836
|
-
/**
|
|
837
|
-
|
|
936
|
+
/**
|
|
937
|
+
* What `tilingDrag` reads: the adapter, the stage, and the layout options (`SplitOptions` plus `min`, the least pane
|
|
938
|
+
* width and height a drop keeps, and `fold`, as `layoutSplitTree` takes it). `fold.order` is the lift's order: the
|
|
939
|
+
* drag derives the base's and each change's from it.
|
|
940
|
+
*/
|
|
941
|
+
interface TilingDragOptions<T, K> extends DropOptions<K>, FoldingSplitOptions<K> {
|
|
838
942
|
readonly ops: TilingTree<T, K>;
|
|
839
943
|
/** The stage the tree is laid out in, px. */
|
|
840
944
|
readonly area: Rect;
|
|
841
945
|
/** Panes that take no drop (a swap, a side or a join on one is refused `"still"`). Default: none. */
|
|
842
946
|
readonly still?: (pane: K) => boolean;
|
|
947
|
+
/**
|
|
948
|
+
* Under a fold whose rails' content runs past their boxes (`SplitFold.segmentFloor`), how far the host has moved each
|
|
949
|
+
* rail of the lift layout (`RailOffset`): asked only with the lift's folds, the fold heading the rail and its index
|
|
950
|
+
* (the lift is `layoutSplitTree`'s answer for the same input, so the index is the host's key, not the fold's `id`,
|
|
951
|
+
* which may be undefined). Read at every hit read (`hit.read`, `hit.foldedAt`), never kept: an offset change is a
|
|
952
|
+
* reason to read again. Not clamped; a value that is not a finite number reads 0. Default: 0 everywhere.
|
|
953
|
+
*/
|
|
954
|
+
readonly railOffset?: RailOffset<K>;
|
|
843
955
|
}
|
|
844
956
|
/**
|
|
845
957
|
* A drag of one subject: its base, its home, and the one layout of each held place. Built per drag: its `after` and its
|
|
@@ -853,7 +965,8 @@ interface TilingDrag<T, K> {
|
|
|
853
965
|
readonly base: TilingLaidOut<T, K>;
|
|
854
966
|
/**
|
|
855
967
|
* The gap the release leaves: the subject's lift rect when releasing it takes a drawn pane away (a pane alone, a
|
|
856
|
-
* whole stack), null when it takes none (a member torn out of a stack that stays drawn)
|
|
968
|
+
* whole stack), null when it takes none (a member torn out of a stack that stays drawn) or when the lift folds the
|
|
969
|
+
* subject (its spine segment is no gap: the pointer over it reads the spine).
|
|
857
970
|
*/
|
|
858
971
|
readonly home: Rect | null;
|
|
859
972
|
/** THE layout of `held`. Remembered per held place: the same place gives the same object. */
|
|
@@ -873,9 +986,17 @@ interface TilingDrag<T, K> {
|
|
|
873
986
|
* - **`after(held).tree`** is what a release commits: `normalize(change)`, where the change is `beside` or `join` on
|
|
874
987
|
* the released tree, or `swap` on the lift tree (see `TilingTree` for why). Home's is the lift tree, never normalized.
|
|
875
988
|
* - **`layout`** is that tree laid out, so a frame that draws it draws exactly what the release stores.
|
|
876
|
-
* - **Refusals** are judged on the base (room) and on the change's own layout
|
|
989
|
+
* - **Refusals** are judged on the base (room, and whether `at` is drawn open there) and on the change's own layout
|
|
990
|
+
* (fit), never on another tree.
|
|
991
|
+
* - **Under a fold** (`options.fold`) every layout is folded with its own order: the lift with the host's, the base
|
|
992
|
+
* with the panes open at the lift first (a torn tab's stack mates in its place), each change with the subject first,
|
|
993
|
+
* then the panes open at the lift. A pane
|
|
994
|
+
* the base folds is refused `folded`; there is no room rule (the one verdict on room is `fit` on the change's
|
|
995
|
+
* layout, where the subject must be drawn open and `at` may fold). The subject may be folded at the lift (a pane
|
|
996
|
+
* carried in): its lift rect is then its spine segment and `home` is null.
|
|
877
997
|
*
|
|
878
|
-
* Throws when the subject is not in `tree` (neither drawn nor a member of a drawn stack): a drag
|
|
998
|
+
* Throws when the subject is not in `tree` (neither drawn, open or on a spine, nor a member of a drawn stack): a drag
|
|
999
|
+
* has nothing to lift.
|
|
879
1000
|
*/
|
|
880
1001
|
declare function tilingDrag<T, K>(tree: T, subject: TilingSubject<K>, options: TilingDragOptions<T, K>): TilingDrag<T, K>;
|
|
881
1002
|
|
|
@@ -910,7 +1031,7 @@ interface StackedSplit<K> {
|
|
|
910
1031
|
declare function splitTreeOps<K>(options?: SplitTreeOpsOptions<K>): TilingTree<StackedSplit<K>, K>;
|
|
911
1032
|
|
|
912
1033
|
/** The properties, by name (each is a key of `TilingConformance.counts`). */
|
|
913
|
-
declare const TILING_PROPERTIES: readonly ["home-is-lift", "home-is-the-gap", "home-over-changed", "one-layout", "swap-exchanges", "swap-trades-slots", "swap-keeps-stack-mates", "subject-once", "release-first", "stack-moves-whole", "normalize-idempotent", "nothing-changes"];
|
|
1034
|
+
declare const TILING_PROPERTIES: readonly ["home-is-lift", "home-is-the-gap", "home-over-changed", "one-layout", "folded-refused", "swap-exchanges", "swap-trades-slots", "swap-keeps-stack-mates", "subject-once", "release-first", "stack-moves-whole", "normalize-idempotent", "nothing-changes"];
|
|
914
1035
|
type TilingProperty = (typeof TILING_PROPERTIES)[number];
|
|
915
1036
|
/** A conformance run: whether every property held, the first failures (in words), and per property how many checks ran and failed. */
|
|
916
1037
|
interface TilingConformance {
|
|
@@ -931,7 +1052,7 @@ declare function tilingSubjects<T, K>(tree: T, options: Pick<TilingDragOptions<T
|
|
|
931
1052
|
declare function tilingConformance<T, K>(trees: Iterable<T>, options: TilingDragOptions<T, K>, limit?: number): TilingConformance;
|
|
932
1053
|
|
|
933
1054
|
/** The properties, by name (each is a key of `TilingHitConformance.counts`). */
|
|
934
|
-
declare const TILING_HIT_PROPERTIES: readonly ["fixed-map", "zone-rule", "stillness", "hold-measures", "one-pass", "existence", "lift-equals-home", "shown-under-pointer", "shown-equals-landed", "new-arrangement-sides", "zones-convex", "room-free-map"];
|
|
1055
|
+
declare const TILING_HIT_PROPERTIES: readonly ["fixed-map", "zone-rule", "stillness", "hold-measures", "one-pass", "existence", "lift-equals-home", "shown-under-pointer", "shown-equals-landed", "new-arrangement-sides", "zones-convex", "room-free-map", "spine-no-place", "named-case-refused"];
|
|
935
1056
|
type TilingHitProperty = (typeof TILING_HIT_PROPERTIES)[number];
|
|
936
1057
|
/** A conformance run, as `tilingConformance`'s, and the rows the ruling counts rather than fails. */
|
|
937
1058
|
interface TilingHitConformance {
|
|
@@ -980,4 +1101,4 @@ type Direction = "left" | "right" | "up" | "down";
|
|
|
980
1101
|
*/
|
|
981
1102
|
declare function neighbor<K>(rects: ReadonlyMap<K, Rect>, from: K, direction: Direction): K | null;
|
|
982
1103
|
|
|
983
|
-
export { type Direction, type DropFitsOptions, type DropOptions, type DropVerdict, type FixedLength, type FoldingSplitOptions, type MasterOptions, type MinLength, type OrderLayout, type OrderOptions, type OrderTarget, PANE_REGION_DEFAULTS, PANE_SIDES, type PaneCenter, type PaneRegion, type PaneRegionOptions, type PaneTarget, type PaneTargetsOptions, Rect, type Split, type SplitDecision, type SplitFold, type SplitFoldGeometry, type SplitGeometry, type SplitLayout, type SplitOptions, type SplitRoomOptions, type SplitSide, type SplitStep, type SplitTreeOpsOptions, type StackedSplit, TILING_HIT_DEFAULTS, TILING_HIT_PROPERTIES, TILING_PROPERTIES, type TileOptions, type TilingAfter, type TilingBasis, type TilingConformance, type TilingDrag, type TilingDragOptions, type TilingHeld, type TilingHit, type TilingHitConformance, type TilingHitFrame, type TilingHitIntent, type TilingHitOptions, type TilingHitProperty, type TilingHitRead, type TilingHitRegions, type TilingHitTarget, type TilingHold, type TilingLaidOut, type TilingMark, type TilingMove, type TilingPart, type TilingProperty, type TilingRefusal, type TilingSize, type TilingStack, type TilingSubject, type TilingTree, canDropOnPane, canSplitPane, columns, decideSplit, dropFits, dropOnPane, giveWay, grid, layoutSplit, layoutSplitTree, masterCount, masterRatio, masterStack, neighbor, orderTargets, paneCenter, paneRegion, paneRegionShapes, paneTargets, panesOf, removePane, splitFromOrder, splitNeed, splitPane, splitTreeOps, swapPanes, tilingConformance, tilingDrag, tilingHitConformance, tilingSubjects };
|
|
1104
|
+
export { type Direction, type DropFitsOptions, type DropOptions, type DropVerdict, type FixedLength, type FoldedLayout, type FoldingSplitOptions, type MasterOptions, type MinLength, type OrderLayout, type OrderOptions, type OrderTarget, PANE_REGION_DEFAULTS, PANE_SIDES, type PaneCenter, type PaneRegion, type PaneRegionOptions, type PaneTarget, type PaneTargetsOptions, type RailOffset, Rect, type Split, type SplitDecision, type SplitFold, type SplitFoldGeometry, type SplitGeometry, type SplitLayout, type SplitOptions, type SplitRoomOptions, type SplitSide, type SplitStep, type SplitTreeOpsOptions, type StackedSplit, TILING_HIT_DEFAULTS, TILING_HIT_PROPERTIES, TILING_PROPERTIES, type TileOptions, type TilingAfter, type TilingBasis, type TilingConformance, type TilingDrag, type TilingDragOptions, type TilingFolded, type TilingHeld, type TilingHit, type TilingHitConformance, type TilingHitFrame, type TilingHitIntent, type TilingHitOptions, type TilingHitProperty, type TilingHitRead, type TilingHitRegions, type TilingHitTarget, type TilingHold, type TilingLaidOut, type TilingMark, type TilingMove, type TilingPart, type TilingProperty, type TilingRefusal, type TilingSize, type TilingStack, type TilingSubject, type TilingTree, canDropOnPane, canSplitPane, columns, decideSplit, dropFits, dropOnPane, giveWay, grid, layoutSplit, layoutSplitTree, masterCount, masterRatio, masterStack, neighbor, orderTargets, paintedSpines, paneCenter, paneRegion, paneRegionShapes, paneTargets, panesOf, removePane, splitFromOrder, splitNeed, splitPane, splitTreeOps, swapPanes, tilingConformance, tilingDrag, tilingHitConformance, tilingSubjects };
|