@n-uf/placement 26.11.15 → 26.11.16
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 +53 -0
- package/README.md +251 -0
- package/dist/chunk-RYFQKQPQ.js +566 -0
- package/dist/chunk-RYFQKQPQ.js.map +1 -0
- package/dist/model-CMH_27_g.d.ts +232 -0
- package/dist/scene.d.ts +572 -0
- package/dist/scene.js +1154 -0
- package/dist/scene.js.map +1 -0
- package/dist/stack.d.ts +23 -202
- package/dist/stack.js +63 -555
- package/dist/stack.js.map +1 -1
- package/package.json +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,59 @@
|
|
|
3
3
|
Versions are calendar versions, `YY.M.R` (year, month of the release, counter within the month), shared with
|
|
4
4
|
`@n-uf/motion`: both packages carry the same version, and a release bumps both.
|
|
5
5
|
|
|
6
|
+
## 26.11.16
|
|
7
|
+
|
|
8
|
+
- `@n-uf/placement/stack`, the cases a host with several kinds of item and a title bar needs. Additive: no rename, no
|
|
9
|
+
removed export, no new required field, and an input that uses none of the new options gives the 26.11.15 fit and
|
|
10
|
+
targets (`test/stack-compat.test.ts` checks it against a verbatim copy of the 26.11.15 solver and targets: 3,000
|
|
11
|
+
fits with a chain of `previous` solves, 1,500 target lists, and the options at their defaults).
|
|
12
|
+
- **`StackInput.accepts(item)`** (C25): `stackTargets` gives no target for a dragged item the stack doesn't accept.
|
|
13
|
+
**`stackTargets(…, { allows(dragged, at) })`** leaves out the gaps it refuses. Item kinds stay the host's.
|
|
14
|
+
- **`StackItem.fixed`** (C29, a bar's reserved room): never gives way (skipped as the victim, keeps its first allowed
|
|
15
|
+
form, also across), counts toward the length, is never dragged (`stackTargets` gives `[]`), takes no part in
|
|
16
|
+
`previous` growth, and has no drop slot inside it: the gaps before and after it stay, and its area is in no gap's
|
|
17
|
+
`hit`.
|
|
18
|
+
- **`stackTargets(…, { onlyFits: true })`**: a gap is offered only where the dragged item fits beside the others: not in
|
|
19
|
+
the menu, no `overflow`, no new `too-wide`, no fixed item squeezed (in another form, shorter than its form's
|
|
20
|
+
`main.min`, or narrower across than before the drop); a fixed item may shrink down to its `main.min` to make room.
|
|
21
|
+
- **`StackInput.ownCross`** (C28, opt-in): an item in a group form (`row`, `stacked`, `icons`, `fold`) is drawn at its
|
|
22
|
+
own `cross.natural`, clamped to the stack's and from its start edge; panel forms (`open`, `header`, `rail`) and the
|
|
23
|
+
» entry still span, so every open panel fills the column, and hits and markers span the stack. The kind decides, not
|
|
24
|
+
`setsCross`: a group's form that sets the cross size (the recommended column form for words, `stacked` with
|
|
25
|
+
`setsCross`, then `icons`, then `menu`, no `row`) widens the column to the widest such group but is drawn at its own
|
|
26
|
+
width.
|
|
27
|
+
- Affected: none unless the options are used. The README has the recommended column forms for a group and a title bar
|
|
28
|
+
example.
|
|
29
|
+
- **New entry `@n-uf/placement/scene`**: one model of a whole window, built on `./stack`. Additive: a new export path
|
|
30
|
+
(`./scene` in `exports`, the tsup entry and the dist check); nothing else changes.
|
|
31
|
+
- `Scene`, `Edge`, `SceneItem`, `SceneFloat`, `SceneLayout`. Edges are cut ring by ring (full bars, columns, between
|
|
32
|
+
bars; overlay edges over the content), each a stack along its length with `forms.column` or `forms.row`; zones
|
|
33
|
+
(`align`: start, center, end); fixed items that shrink and grow but never change form; closed items; a column with
|
|
34
|
+
nothing setting its width is a rail of tabs (`railShowsClosed`); `Edge.size`, clamped to the widest open setter's
|
|
35
|
+
`cross.min`; floats inside the stage, clear of docked items, bars and `chrome`, with `anchor`, `orient` and a bar form
|
|
36
|
+
when folded.
|
|
37
|
+
- `solve(scene, { previous })`: every rect; `previous` goes to each edge's `fitStack`.
|
|
38
|
+
- `targets(scene, id, { previous, endReach, floatSize })`: `gap:<edge>:<zone>:<at>` where the item fits (kinds deny by
|
|
39
|
+
default, no menu, no overflow, fixed items unmoved, hits clear of fixed items and chrome), `strip:<edge>` for an
|
|
40
|
+
empty edge, `float:<id>` over the plane, `none:<i>` over `blocked`, `home:<id>`; each with `after(point, grab)`, the
|
|
41
|
+
scene to commit and `solve` of it, so the preview is the result.
|
|
42
|
+
- Pure changes `moveTo`, `floatAt`, `fold`, `use`, `keep`, `raise`, `open`, `close`, `orient`, `resize`; and
|
|
43
|
+
`storeScene` / `readScene` (`StoredScene` v1, lenient, never throws, lists what it drops, no pinned field).
|
|
44
|
+
- Panels as products have them (planned for the release after the bars): dynamic columns (`Edge.column`, made from
|
|
45
|
+
`Scene.columns[side]`, deleted when empty, rings closed up), one rail per side (`Scene.rails`, `layout.rails`),
|
|
46
|
+
column give-way by `Scene.contentMin` (shrink, then fold whole: unkept first, oldest newest use; held under
|
|
47
|
+
`previous`), `handFold: "ride"`, `inset` and `gutter`; `moveTo` with `column`, `rail` and `float` places, `homeFor`;
|
|
48
|
+
`column:<side>:<ring>` and `rail:<side>:<ring>` targets, own-place drops as homes, `stops`; stored columns
|
|
49
|
+
(`column: true`). Two document windows' width thresholds are pinned in tests.
|
|
50
|
+
- `Edge.hitBand` (`number | "middle"`; default 24 for columns, `"middle"` for bars): a column's gap hits are bands
|
|
51
|
+
around the insertion lines, so a panel's body is no drop area for a group. Gaps on one line are one target.
|
|
52
|
+
- A `content-changed` note (`{ from, to }`) whenever `content` differs from `previous.content`.
|
|
53
|
+
- Under `previous`, a just-opened item counts as the newest (its largest form while it fits); `fresh` ids solve
|
|
54
|
+
without `previous`. Folded columns unfold in the reverse of their fold order, to a fixpoint.
|
|
55
|
+
- Targets: whole-scene C29 (no new `overflow` or `too-wide`, no fixed item changed or squeezed under its min,
|
|
56
|
+
anywhere), hits clear of fixed items' drawn rects, no slot on chrome, no home for a floating item. The store clamps a
|
|
57
|
+
float by its drawn size and never cuts it.
|
|
58
|
+
|
|
6
59
|
## 26.11.15
|
|
7
60
|
|
|
8
61
|
- **Fixed** (`@n-uf/placement/stack`, opt-in `fitStack(input, { previous })` only; a solve without `previous` is
|
package/README.md
CHANGED
|
@@ -46,6 +46,10 @@ without importing each other: a target list from `@n-uf/placement/targets` is ex
|
|
|
46
46
|
sets the width, `gap` and `pad` in the length; a drop target for every gap, each with the exact solve a drop makes; a
|
|
47
47
|
stored form; and floats (an item above the pages, in the stage's own px, kept inside the stage and clear of the docked
|
|
48
48
|
items, with its drop target and stored form). Not tied to `/panels`.
|
|
49
|
+
- **`/scene`**: one model of a whole window on `/stack`: edges cut ring by ring along the stage's sides (full and
|
|
50
|
+
between bars, columns, overlay edges), each a stack with start, center and end zones, fixed items (a title, window
|
|
51
|
+
controls), floats clear of every bar and chrome, one `solve` for every rect, one `targets` for every drop target
|
|
52
|
+
of one item (each carrying the layout a release makes, so the preview is the result), pure changes and a stored form.
|
|
49
53
|
|
|
50
54
|
Rendering stays in the app: it draws the rects, measures its groups, and feeds pointer samples to a drag intent.
|
|
51
55
|
|
|
@@ -546,6 +550,71 @@ console.log(gaps.map((t) => [t.hit.x, t.hit.x + t.hit.width]));
|
|
|
546
550
|
// [ [ -24, 30 ], [ 30, 106 ], [ 106, 214 ], [ 214, 354 ] ] (split at the groups' middles; the ends reach 24 px past the bar)
|
|
547
551
|
```
|
|
548
552
|
|
|
553
|
+
### A title bar, targets by kind, a group's own size
|
|
554
|
+
|
|
555
|
+
Opt-in options for hosts that dock several kinds of item. All are additive: an input that uses none of them gives the
|
|
556
|
+
fit and the targets it always gave. Item kinds are the host's; placement only calls the predicates.
|
|
557
|
+
|
|
558
|
+
- **`StackInput.accepts(item)`**: the stack takes this item or not. `stackTargets` gives no target (`[]`) for a dragged
|
|
559
|
+
item the stack doesn't accept, so a toolbar-only bar takes no panel and a panel-only column no group. `fitStack`
|
|
560
|
+
never calls it: the items already in the stack are laid out as given.
|
|
561
|
+
- **`stackTargets(input, dragged, { allows })`**: `allows(dragged, at)` is asked per gap (`at` is the gap's
|
|
562
|
+
`place.at`) and a gap it refuses has no target. The other targets keep their ids, hits and fits. The stack's
|
|
563
|
+
`accepts` is asked first.
|
|
564
|
+
- **`StackItem.fixed`**: a reserved room, such as the window title, a page readout and the window controls in a title
|
|
565
|
+
bar. A fixed item never gives way: it is skipped when the stack is too long and keeps its first allowed form
|
|
566
|
+
(`forms[from]`) for the length and for the cross size (a `too-wide` note says when it doesn't fit across), so a stack
|
|
567
|
+
too short for it `overflow`s. It counts toward the length and takes no part in `previous`'s growing back. It is never
|
|
568
|
+
dragged (`stackTargets` with a fixed dragged item is `[]`), and it has no drop slot inside it: the gaps before and
|
|
569
|
+
after it stay, the hit of the gap before it ends where it starts and the hit of the gap after it begins where it ends,
|
|
570
|
+
so its own area is in no hit (also when it runs past an overflowing bar). A fixed form that `grows` still takes spare
|
|
571
|
+
length like any form.
|
|
572
|
+
- **`stackTargets(input, dragged, { onlyFits: true })`**: offer a gap only where the dragged item fits beside the
|
|
573
|
+
others. A gap has no target when its fit puts the dragged item into the menu, has an `overflow` note, has a `too-wide`
|
|
574
|
+
note the stack didn't have before the drop, or squeezes a fixed item: it is in another form, shorter along the stack
|
|
575
|
+
than its form's `main.min`, or narrower across than before the drop. A fixed item may shrink down to its `main.min` to
|
|
576
|
+
make room (a title with `grows` gives back the spare length it took, down to its minimum), so the room for the others
|
|
577
|
+
is the length less the fixed items' minimum sizes. In a narrow window, under that, there is no target, so neither the
|
|
578
|
+
slot nor the group covers the title. The gaps left are the unrestricted ones, unchanged. Position is not a size: dropping before a fixed
|
|
579
|
+
item moves it along, as a drop anywhere moves what follows. The solve doesn't depend on where the dragged item is
|
|
580
|
+
inserted (it counts as the newest, and the give-way order is the same at every gap), so what `onlyFits` leaves is all
|
|
581
|
+
the gaps or none; `allows` is what tells gaps apart.
|
|
582
|
+
- **`StackInput.ownCross`** (default off): an item whose current form is a group kind (`row`, `stacked`, `icons`,
|
|
583
|
+
`fold`) is drawn at its own `cross.natural`, clamped to the stack's cross size and from its start edge (the left of a
|
|
584
|
+
column, the top of a bar), not across the whole stack. Panel kinds (`open`, `header`, `rail`) and the » entry still
|
|
585
|
+
span it, so every open panel and header fills the column, as wide as the widest open panel. The kind decides, not
|
|
586
|
+
`setsCross`, which still decides the stack's cross size as before. `cross`, the forms, the notes and the lengths are
|
|
587
|
+
as without it. A target's `slot` is that rect, while its `hit` and `marker` still span the stack.
|
|
588
|
+
- **Recommended column forms for a group.** In a side column give a group `stacked` (one word per line, `setsCross:
|
|
589
|
+
true`, so a column of groups is as wide as its widest), then `icons` (28 across, sets nothing: with every group in
|
|
590
|
+
icons the column is a rail), then `menu`. No `row`: a row of words asks for more than a column has, and the group
|
|
591
|
+
that keeps it widens the column. With `ownCross` each group is drawn at its own width, also beside a wider open panel.
|
|
592
|
+
A bar's group is `row`, `stacked` or `fold`, `icons`, `menu`, as in the toolbar above.
|
|
593
|
+
|
|
594
|
+
```ts
|
|
595
|
+
const title: StackItem = { id: "title", used: 0, fixed: true, forms: [form("row", 160, 160, 26)] };
|
|
596
|
+
const controls: StackItem = { id: "controls", used: 0, fixed: true, forms: [form("row", 72, 72, 26)] };
|
|
597
|
+
const group = (id: string, used: number): StackItem => ({ id, used, forms: [form("row", 100, 100, 26), form("fold", 36, 36, 26), form("menu", 0, 0, 0)] });
|
|
598
|
+
const panels = new Set(["pages"]); // the host's kinds
|
|
599
|
+
const bar = { axis: "row", length: 400, cross: { min: 36, max: 40 }, accepts: (item: StackItem) => !panels.has(item.id), items: [title, group("views", 1), group("tools", 2), controls] } as const;
|
|
600
|
+
|
|
601
|
+
console.log(fitStack(bar).items.map((p) => [p.id, p.kind, p.rect.x, p.rect.width]));
|
|
602
|
+
// [ [ 'title', 'row', 0, 160 ], [ 'views', 'fold', 160, 36 ], [ 'tools', 'row', 196, 100 ], [ 'controls', 'row', 296, 72 ] ]
|
|
603
|
+
// (the three groups need 432: Views, the oldest, folds; the title and the controls stay as they are)
|
|
604
|
+
|
|
605
|
+
const gaps = stackTargets(bar, group("marks", 4));
|
|
606
|
+
console.log(gaps.map((t) => [t.hit.x, t.hit.x + t.hit.width]));
|
|
607
|
+
// [ [ 0, 0 ], [ 160, 178 ], [ 178, 246 ], [ 246, 296 ], [ 368, 400 ] ] (none over the title or the controls)
|
|
608
|
+
console.log(stackTargets(bar, group("pages", 4)).length, stackTargets(bar, title).length); // 0 0: not accepted, fixed
|
|
609
|
+
console.log(stackTargets(bar, group("marks", 4), { allows: (_dragged, at) => at !== 2 }).map((t) => t.id));
|
|
610
|
+
// [ 'gap:0', 'gap:1', 'gap:3', 'gap:4' ]
|
|
611
|
+
|
|
612
|
+
// A column: words groups in their stacked form, each at its own width beside a wider open panel.
|
|
613
|
+
const words = (id: string, used: number, wide: number): StackItem => ({ id, used, forms: [{ ...form("stacked", 78, 78, wide), setsCross: true }, form("icons", 72, 72, 28), form("menu", 0, 0, 0)] });
|
|
614
|
+
const side = fitStack({ axis: "column", length: 400, cross: { min: 120, max: 360 }, ownCross: true, items: [open, words("views", 2, 84), words("tools", 3, 110)] });
|
|
615
|
+
console.log(side.items.map((p) => [p.id, p.rect.x, p.rect.width])); // [ [ 'pages', 0, 240 ], [ 'views', 0, 84 ], [ 'tools', 0, 110 ] ]
|
|
616
|
+
```
|
|
617
|
+
|
|
549
618
|
`storeStack(state)` and `readStack(data, known?)` keep what the user chose, as `{ v: 1, … }`: `order`, `kept`,
|
|
550
619
|
`closed`, `used` (the use order, oldest first, so a reload restores who gives way first) and `forms` (the largest form
|
|
551
620
|
index each item may take, `StackItem.from`; stored only from 1). Reading never throws: anything but an object of
|
|
@@ -626,6 +695,188 @@ A press on a grip while frozen (and Alt not held) never becomes a drag, so no ta
|
|
|
626
695
|
holding Alt shows the grips and everything works, a drag that began finishes. `fitStack` reads sizes, not what an item
|
|
627
696
|
says, so a count or a phase that leaves its forms' sizes alone moves no other item.
|
|
628
697
|
|
|
698
|
+
## Scenes
|
|
699
|
+
|
|
700
|
+
`@n-uf/placement/scene` holds a whole window in one model, so every rule that spans it (kinds, chrome, fixed room,
|
|
701
|
+
preview equals result) has one owner. A `Scene` is the stage (the window's inner rect), its `edges`, the `items`
|
|
702
|
+
(each with a host `kind`, its forms along a column and along a row from `./stack`, its age, and its flags), the
|
|
703
|
+
`floats` and the `chrome` they keep clear of. `solve(scene)` gives every rect the host draws; `targets(scene, id)` gives
|
|
704
|
+
every drop target for one item. Nothing is module-global, so two windows on a page are two scenes.
|
|
705
|
+
|
|
706
|
+
```ts
|
|
707
|
+
import { readScene, solve, storeScene, targets, type Scene, type SceneItem } from "@n-uf/placement/scene";
|
|
708
|
+
import type { StackForm } from "@n-uf/placement/stack";
|
|
709
|
+
|
|
710
|
+
const f = (kind: StackForm["kind"], min: number, natural: number, cross: number, more: Partial<StackForm> = {}): StackForm => ({ kind, main: { min, natural }, cross: { natural: cross }, ...more });
|
|
711
|
+
const panel = (id: string, used: number): SceneItem => ({
|
|
712
|
+
id, kind: "panel", used,
|
|
713
|
+
forms: { column: [f("open", 120, 240, 260, { main: { min: 120, natural: 240, grows: true }, cross: { natural: 260, min: 180 } }), f("header", 28, 28, 260, { cross: { natural: 260, min: 60 } }), f("rail", 28, 28, 30), f("menu", 0, 0, 0)] },
|
|
714
|
+
});
|
|
715
|
+
const group = (id: string, used: number, align?: "end"): SceneItem => ({
|
|
716
|
+
id, kind: "group", used, ...(align ? { align } : {}),
|
|
717
|
+
forms: { row: [f("row", 180, 200, 28), f("icons", 84, 84, 28), f("menu", 0, 0, 0)], column: [f("stacked", 96, 96, 84), f("icons", 84, 84, 28), f("menu", 0, 0, 0)] },
|
|
718
|
+
});
|
|
719
|
+
const fixed = (id: string, kind: string, form: StackForm, align?: "center" | "end"): SceneItem => ({ id, kind, used: 0, fixed: true, forms: { row: [form] }, ...(align ? { align } : {}) });
|
|
720
|
+
const bar = { accepts: ["group"], cross: { min: 36, max: 36, rail: 36 }, gap: 4, pad: { start: 8, end: 8 } };
|
|
721
|
+
const column = { accepts: ["panel", "group"], cross: { min: 160, max: 480, rail: 30 } };
|
|
722
|
+
const items = [
|
|
723
|
+
fixed("title", "title", f("row", 80, 160, 32, { main: { min: 80, natural: 160, grows: true } })),
|
|
724
|
+
fixed("controls", "controls", f("row", 84, 84, 32), "end"),
|
|
725
|
+
fixed("readout", "readout", f("row", 72, 72, 28), "center"),
|
|
726
|
+
panel("pages", 1), panel("findings", 2), panel("notes", 3),
|
|
727
|
+
group("views", 4), group("tools", 5), group("zoom", 6, "end"), group("search", 7, "end"), group("marks", 8),
|
|
728
|
+
];
|
|
729
|
+
const scene: Scene = {
|
|
730
|
+
stage: { x: 0, y: 0, width: 1200, height: 800 },
|
|
731
|
+
edges: [
|
|
732
|
+
{ id: "titlebar", side: "top", ring: 0, accepts: [], items: ["title", "controls"], cross: { min: 32, max: 32, rail: 32 } },
|
|
733
|
+
{ id: "toolbar", side: "top", ring: 1, items: ["views", "tools", "zoom"], ...bar },
|
|
734
|
+
{ id: "status", side: "bottom", ring: 0, span: "between", items: ["readout", "search"], ...bar, cross: { min: 28, max: 28, rail: 28 } },
|
|
735
|
+
{ id: "left", side: "left", ring: 0, items: ["pages"], ...column },
|
|
736
|
+
{ id: "right", side: "right", ring: 0, items: ["findings", "marks"], ...column },
|
|
737
|
+
],
|
|
738
|
+
items: Object.fromEntries(items.map((it) => [it.id, it])),
|
|
739
|
+
floats: [{ id: "notes", rect: { x: 500, y: 200, width: 280, height: 320 } }],
|
|
740
|
+
floatKinds: ["panel", "group"],
|
|
741
|
+
};
|
|
742
|
+
const layout = solve(scene);
|
|
743
|
+
console.log(layout.content); // { x: 260, y: 68, width: 680, height: 704 }
|
|
744
|
+
console.log(layout.items.title!.rect.width, layout.items.controls!.rect.x, layout.items.marks!.rect.width); // 1116 1116 84
|
|
745
|
+
const drops = targets(scene, "views", { previous: layout });
|
|
746
|
+
console.log(drops.filter((t) => t.id.startsWith("gap:status")).map((t) => t.id)); // [ 'gap:status:start:0' ]
|
|
747
|
+
const drop = drops.find((t) => t.id === "gap:right:start:2")!.after({ x: 0, y: 0 });
|
|
748
|
+
console.log(JSON.stringify(solve(drop.scene, { previous: layout })) === JSON.stringify(drop.layout)); // true
|
|
749
|
+
console.log(readScene(JSON.parse(JSON.stringify(storeScene(drop.scene))), scene).dropped); // []
|
|
750
|
+
```
|
|
751
|
+
|
|
752
|
+
**The cut.** Reserved edges cut the stage from the outside in: the full bars first (top then bottom, each by `ring`,
|
|
753
|
+
0 outermost), across the whole width; then the columns (left then right, by ring), down the height the full bars
|
|
754
|
+
leave; then the `span: "between"` bars, across the width the columns leave. What remains is `layout.content`. Edges
|
|
755
|
+
with `mode: "overlay"` are cut the same way from a copy of the content: they lie over it and leave it as it is. An edge
|
|
756
|
+
with nothing drawn in it takes no room.
|
|
757
|
+
|
|
758
|
+
**Each edge is a stack.** Left and right edges are columns (`forms.column`), top and bottom ones bars (`forms.row`),
|
|
759
|
+
each solved by `fitStack` along the length it gets, with `gap`, `pad` and `menu` passed through, its cross limits never
|
|
760
|
+
wider than the room the cut leaves. Group forms in a column take their own width (`ownCross`); open panels and headers
|
|
761
|
+
span it. Spare room goes to the forms that grow, so a column's open panels share its height through `grows` and equal
|
|
762
|
+
naturals. A column where nothing sets the width is a rail: its items that have a `rail` form take it and are listed in
|
|
763
|
+
`edges[id].tabs` (with `railShowsClosed`, closed items too, marked `closed`); the host draws tabs only from the layout.
|
|
764
|
+
`Edge.size` is the user's size across, clamped to the widest open setter's `cross.min` (and the edge's `cross.min`) at
|
|
765
|
+
least and `cross.max` at most; `resize` sets it.
|
|
766
|
+
|
|
767
|
+
**Zones.** An item's `align` (`start`, the default, `center` or `end`) is its zone in its edge. Give-way is as without
|
|
768
|
+
zones (it sums the minimum sizes); when room is spare, start items pack from the start, end items from the end (before
|
|
769
|
+
the » entry) and center items sit on the edge's middle, moved only as far as they must to stay between the other two.
|
|
770
|
+
|
|
771
|
+
**Fixed items** (a title, window controls, a page readout) never change form, are never reordered, never dragged, and
|
|
772
|
+
no hit covers them. Their length shrinks toward `main.min` and grows with spare room when the form `grows`; window
|
|
773
|
+
controls have `min` equal to `natural`. A stage too short for them overflows instead of folding them. A `kept` item with
|
|
774
|
+
no smaller form never folds either: it reports `overflow` or `too-wide`.
|
|
775
|
+
|
|
776
|
+
**Closed items** keep their place in their edge (or their float rect) but take no room and have no targets.
|
|
777
|
+
|
|
778
|
+
**Columns and rails.** A left or right edge with `column: true` is a dynamic column: drops make it (a `column` place, from
|
|
779
|
+
`scene.columns[side]`: `accepts`, `cross`, `gap`, `pad`, `menu`), and it is deleted, its side's rings closed up, when it
|
|
780
|
+
holds no item. On a side with `scene.rails[side]` (`{ width, accepts }`), folded columns show as segments of that side's
|
|
781
|
+
one rail (`layout.rails[side]`, each member at its `rail` form's length, in ring order), lying just outside the side's
|
|
782
|
+
first column. A column folds:
|
|
783
|
+
|
|
784
|
+
- by give-way: while the content is narrower than `scene.contentMin.width` (after `inset`, and a `gutter` after each side
|
|
785
|
+
edge and rail), dynamic columns shrink toward their minimum (the edge's `cross.min` and the widest open setter's
|
|
786
|
+
`cross.min`: a stack costs its widest member's minimum), then fold whole, unkept before kept, the one whose newest use
|
|
787
|
+
is oldest first, the outer first, the left first (`column-shrunk`, `column-folded`, `kept-folded`). Under `previous`,
|
|
788
|
+
what gave way stays so while the content still fits, room that comes back unfolds in the reverse order, and ages alone
|
|
789
|
+
change nothing. Still too narrow: `content-narrow`; under `contentMin.height` (overlay bars counted): `content-short`.
|
|
790
|
+
- by hand: when every member is folded by hand (`from` over 0) it goes to the rail; with `handFold: "ride"` a one-member
|
|
791
|
+
column instead rides as a title bar over the side's first open column, at that column's width, taking no width
|
|
792
|
+
(`rides`), while the side has an open column.
|
|
793
|
+
|
|
794
|
+
A member folded by hand in a column with others is a bar in place (its header form). The open members share the height
|
|
795
|
+
through `grows`. Anchors (a thumbnails column, a fixed drawer) are ring-0 edges with `accepts: []` and fixed items.
|
|
796
|
+
|
|
797
|
+
**Floats** lie above the content in stage px, last on top. Each is moved inside the stage and clear of every docked
|
|
798
|
+
item, every bar and every `chrome` rect (`fitFloat`), with `float-clamped`, `float-moved` or `float-covers` notes. With
|
|
799
|
+
`anchor` (such as `"content-top-right"`) it sits flush with that side or corner of the content and follows it until a
|
|
800
|
+
drop gives it a real rect. `orient` picks the forms it uses (default `"column"`); folded by hand (`from` over 0) it is its
|
|
801
|
+
bar: that form's natural length along its orient, its other size kept.
|
|
802
|
+
|
|
803
|
+
**`previous`.** `solve(scene, { previous })` hands each edge's fits (`edges[id].free` and `.stack`) to `fitStack`, so a
|
|
804
|
+
change of ages alone (a press, `use`) or `raise` changes no rect (C23), a form that was only re-measured keeps its place,
|
|
805
|
+
and one whose kind changed starts over. Whenever `content` isn't the rect `previous.content` was, the layout has a
|
|
806
|
+
`content-changed` note (`{ from, to }`): a host refits its zoom only on that note, so a press or a float move never
|
|
807
|
+
refits it. Columns that gave way stay folded, in the order they folded (the fold notes' order), while the content still
|
|
808
|
+
fits; room that comes back unfolds them in the reverse of that order, never by age, so a press unfolds nothing, and
|
|
809
|
+
solving again from a layout changes nothing. An item docked now that was closed or absent in `previous` has just
|
|
810
|
+
opened: it counts as the newest and takes its largest form that fits its edge as laid out. The columns' fold and shrink
|
|
811
|
+
state still follows `previous` (only a column folded by give-way that holds the opened item is weighed again), so to
|
|
812
|
+
reweigh a column fully, pass `fresh: [columnId]`. `fresh` (edge or item ids, on `solve` and `targets`) solves those
|
|
813
|
+
edges without `previous`.
|
|
814
|
+
|
|
815
|
+
**Targets.** `targets(scene, id, { previous, endReach, floatSize })` gives, in the `@n-uf/motion/drag` shape:
|
|
816
|
+
|
|
817
|
+
- `gap:<edge>:<zone>:<at>` (priority 2) for every edge whose `accepts` lists the item's kind (deny by default), before
|
|
818
|
+
each item of each zone and at each zone's end, so an empty center or end zone can be opened; only where the item
|
|
819
|
+
fits: not in the » menu, no `overflow`, nothing newly `too-wide`, every fixed item of the edge keeping its form and its
|
|
820
|
+
place, and no chrome under its slot. Along the edge the hit follows `Edge.hitBand`: in a column (default 24) a band
|
|
821
|
+
that many px around the gap's insertion line, never into a neighbour's band, so the body of a panel away from its
|
|
822
|
+
edges is no gap and the pointer falls through to the float target (or to none); in a bar (default `"middle"`) the
|
|
823
|
+
edge split halfway between neighbouring lines. Gaps on one line are one target, the first in zone order: when a bar
|
|
824
|
+
has no spare length, `center:0` and `end:0` lie on the start zone's last line and merge into that start gap (its id
|
|
825
|
+
stays `gap:<edge>:start:<n>`). The first and last reach `endReach` px past the edge's ends. Across, the hit is the
|
|
826
|
+
larger of the edge's thickness before and after the drop, and it is cut clear of every fixed item's drawn rect (a
|
|
827
|
+
title grown over its bar's spare room included, so a bar it fills offers no gap; a drop beside it may still shrink it
|
|
828
|
+
toward its `min`) and of chrome. `slot` is the item's rect after the drop and `marker` the insertion line across the
|
|
829
|
+
edge.
|
|
830
|
+
- `strip:<edge>` (2): an empty accepting edge, a strip `Edge.strip` px deep (default 24) along its side.
|
|
831
|
+
- `float:<id>` (3, free) when `floatKinds` lists the kind: the whole plane, landing with the pointer holding the float
|
|
832
|
+
at `grab`, clamped and moved clear. It has no fixed `slot`: the slot to draw is
|
|
833
|
+
`after(point, grab).layout.items[id].rect`, for the pointer at the time.
|
|
834
|
+
- `column:<side>:<ring>` (2): a new column on each column line of a side whose template takes the kind (outside the
|
|
835
|
+
outermost open column, between two, inside the innermost, or at the content's edge), 22 px each way.
|
|
836
|
+
- `rail:<side>:<ring>` (1): docking folded into the side's rail, before each folded column's segments and after the
|
|
837
|
+
last, or a 10 px strip at the side's outer edge while no rail shows.
|
|
838
|
+
- `none:<i>` (1) over each `scene.blocked` rect, and `home:<id>` (1) over a docked item's own rect: a release there
|
|
839
|
+
commits nothing. A floating item has no home, so a move inside its own rect is a float move. A gap, column line or rail
|
|
840
|
+
drop that would put the item back where it is (the gap beside it, its own column's line) keeps its id but is a home
|
|
841
|
+
too: no slot, nothing committed. Every rail target on the side whose rail already holds the item is a home: a segment
|
|
842
|
+
dropped on its own rail, even below the last segment, never splits or reorders it (P9).
|
|
843
|
+
|
|
844
|
+
A gap, column or rail target exists only where the drop keeps the whole scene sound (C29): it adds no `overflow` or
|
|
845
|
+
`too-wide` note to any edge, changes no fixed item's form, squeezes none under its `main.min` anywhere (a between bar
|
|
846
|
+
under a new column included), and lands its slot on no chrome. The rule compares notes: in an edge that already
|
|
847
|
+
overflows (or holds an item already too wide), a drop that adds no new note is accepted, even when it shifts a fixed
|
|
848
|
+
item that was already squeezed.
|
|
849
|
+
|
|
850
|
+
`stops(scene, id)` gives the same targets, home and none left out, in reading order (the left side outer to inner, the
|
|
851
|
+
top bars, the bottom bars, the right side inner to outer, floating last) for "Move to ›" and the arrow keys.
|
|
852
|
+
|
|
853
|
+
Each target's `after(point, grab)` is `{ scene, layout }`: the scene to commit (the item moved and just used) and
|
|
854
|
+
`solve(scene, { previous })`. The host draws every item from `after.layout` during the preview and commits
|
|
855
|
+
`after.scene` on release, so the preview is the result by construction.
|
|
856
|
+
|
|
857
|
+
**Changes** are pure and return the scene given when nothing applies: `moveTo(scene, id, { edge, zone?, at })`,
|
|
858
|
+
`floatAt(scene, id, rect?, orient?)` (with no rect: its last `floatSize`, anchored to the content's top-right), `fold`,
|
|
859
|
+
`use`, `keep`, `raise` (a float on top: no use, no reshape), `open`, `close`, `orient` and `resize`. `moveTo` and
|
|
860
|
+
`floatAt` refuse fixed items and kinds the edge or `floatKinds` doesn't list. `moveTo` also takes `{ kind: "column",
|
|
861
|
+
side, ring }` (`ring: Infinity` is the side's inner end: "Move to › Dock left"), `{ kind: "rail", side, ring }` (docked
|
|
862
|
+
folded) and `{ kind: "float", rect?, anchor? }`. `homeFor(scene, id, start)` is the place a start scene gives the item
|
|
863
|
+
(the same edge before the same neighbour, a new column at its ring when its column is gone, or its float), for Dock,
|
|
864
|
+
Put back and Reset position: `moveTo(scene, id, homeFor(scene, id, start)!)`. `lift(scene, id)` is the scene while an
|
|
865
|
+
item is held: the item out of every edge and float, and a dynamic column it leaves empty gone (its side's rings closed
|
|
866
|
+
up). During a drag a host draws everything else from `solve(lift(scene, id), { previous })`, as if the held item were
|
|
867
|
+
gone.
|
|
868
|
+
|
|
869
|
+
**Stored form.** `storeScene(scene)` gives `{ v: 1, edges: [{ id, side, ring, items, size?, column? }], floats: [{ id, x, y,
|
|
870
|
+
width, height, orient?, anchor? }], items: { [id]: { used, kept?, from?, closed?, align?, floatSize? } } }`; no float has a
|
|
871
|
+
pinned field. `readScene(data, base)` takes kinds, forms, limits and edges from `base` and order, sizes and states from
|
|
872
|
+
the store, never throws, and lists what it drops: unknown edges and items, kinds an edge doesn't accept, fixed items
|
|
873
|
+
stored in another edge than `base`'s, bad fields, an old `pinned`. A stored edge's order is kept exactly, fixed items
|
|
874
|
+
where the store put them, so a drop after a fixed item round-trips; a fixed item the store lacks goes back to its base
|
|
875
|
+
place (trailing ones last). An item the store places nowhere goes where `base` has it, and floats are clamped into the stage by what `solve` draws (a folded float by
|
|
876
|
+
its bar), never cut, so a reload lands where it was drawn. Dynamic columns are the store's: one
|
|
877
|
+
`base` lacks is made from `base.columns[side]` at its stored ring, and empty ones are deleted. Anything but version 1
|
|
878
|
+
gives `base` back with an `error`.
|
|
879
|
+
|
|
629
880
|
## Pane zones
|
|
630
881
|
|
|
631
882
|
`paneZone(rect, point, previous, options?)` says which of a pane's five zones a point is in: the centre rectangle
|