@reekon-tools/boldr-cad 1.5.0 → 1.7.0
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/README.md +12 -1
- package/dist/app/state.d.ts +3 -3
- package/dist/data/provider.d.ts +2 -1
- package/dist/data/sync.js +4 -1
- package/dist/data/sync.js.map +1 -1
- package/dist/editor/actions.js +122 -19
- package/dist/editor/actions.js.map +1 -1
- package/dist/editor/advance.d.ts +2 -0
- package/dist/editor/advance.js +23 -0
- package/dist/editor/advance.js.map +1 -0
- package/dist/editor/dimSize.d.ts +13 -0
- package/dist/editor/dimSize.js +50 -0
- package/dist/editor/dimSize.js.map +1 -0
- package/dist/editor/gestures.js +30 -7
- package/dist/editor/gestures.js.map +1 -1
- package/dist/editor/keypad.d.ts +8 -0
- package/dist/editor/keypad.js +15 -1
- package/dist/editor/keypad.js.map +1 -1
- package/dist/editor/keys.js +2 -1
- package/dist/editor/keys.js.map +1 -1
- package/dist/editor/laser.d.ts +13 -2
- package/dist/editor/laser.js +42 -14
- package/dist/editor/laser.js.map +1 -1
- package/dist/editor/linkActions.d.ts +29 -11
- package/dist/editor/linkActions.js +76 -29
- package/dist/editor/linkActions.js.map +1 -1
- package/dist/editor/links.d.ts +13 -0
- package/dist/editor/links.js +7 -1
- package/dist/editor/links.js.map +1 -1
- package/dist/editor/mode.d.ts +2 -1
- package/dist/editor/mode.js +7 -5
- package/dist/editor/mode.js.map +1 -1
- package/dist/editor/ports.d.ts +9 -0
- package/dist/editor/ports.js +2 -0
- package/dist/editor/ports.js.map +1 -1
- package/dist/editor/selection.js +1 -1
- package/dist/editor/selection.js.map +1 -1
- package/dist/editor/tooltips.js +1 -0
- package/dist/editor/tooltips.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/model/clockwise.d.ts +11 -0
- package/dist/model/clockwise.js +123 -0
- package/dist/model/clockwise.js.map +1 -0
- package/dist/model/constraints.js +2 -0
- package/dist/model/constraints.js.map +1 -1
- package/dist/model/geom.d.ts +2 -0
- package/dist/model/geom.js +11 -0
- package/dist/model/geom.js.map +1 -1
- package/dist/model/links.d.ts +6 -1
- package/dist/model/links.js +6 -1
- package/dist/model/links.js.map +1 -1
- package/dist/model/scale.js +3 -0
- package/dist/model/scale.js.map +1 -1
- package/dist/model/settings.d.ts +2 -0
- package/dist/model/settings.js +1 -1
- package/dist/model/settings.js.map +1 -1
- package/dist/model/sketch.d.ts +5 -1
- package/dist/model/sketch.js +19 -18
- package/dist/model/sketch.js.map +1 -1
- package/dist/model/trim.d.ts +54 -0
- package/dist/model/trim.js +219 -0
- package/dist/model/trim.js.map +1 -0
- package/dist/model/types.d.ts +24 -2
- package/dist/react/BottomBar.js +94 -25
- package/dist/react/BottomBar.js.map +1 -1
- package/dist/react/CadEditor.js +18 -9
- package/dist/react/CadEditor.js.map +1 -1
- package/dist/react/Drawer.js +3 -2
- package/dist/react/Drawer.js.map +1 -1
- package/dist/react/PlanCanvas.native.js +15 -9
- package/dist/react/PlanCanvas.native.js.map +1 -1
- package/dist/react/PlanCanvas.web.js +17 -5
- package/dist/react/PlanCanvas.web.js.map +1 -1
- package/dist/react/ShapeMenu.js +3 -2
- package/dist/react/ShapeMenu.js.map +1 -1
- package/dist/react/ToolTip.js +3 -2
- package/dist/react/ToolTip.js.map +1 -1
- package/dist/react/TopBar.js +4 -3
- package/dist/react/TopBar.js.map +1 -1
- package/dist/react/editorBox.d.ts +8 -0
- package/dist/react/editorBox.js +10 -0
- package/dist/react/editorBox.js.map +1 -0
- package/dist/react/host.d.ts +7 -1
- package/dist/react/host.js +12 -2
- package/dist/react/host.js.map +1 -1
- package/dist/react/pageLock.native.d.ts +2 -0
- package/dist/react/pageLock.native.js +2 -0
- package/dist/react/pageLock.native.js.map +1 -1
- package/dist/react/pageLock.web.d.ts +6 -0
- package/dist/react/pageLock.web.js +12 -3
- package/dist/react/pageLock.web.js.map +1 -1
- package/dist/react/ports.js +10 -4
- package/dist/react/ports.js.map +1 -1
- package/dist/react/saving.d.ts +7 -1
- package/dist/react/saving.js +10 -2
- package/dist/react/saving.js.map +1 -1
- package/dist/react/store.d.ts +5 -2
- package/dist/react/store.js +4 -1
- package/dist/react/store.js.map +1 -1
- package/dist/render/draw.d.ts +7 -0
- package/dist/render/draw.js +41 -15
- package/dist/render/draw.js.map +1 -1
- package/dist/render/linkTile.js +2 -2
- package/dist/render/linkTile.js.map +1 -1
- package/dist/render/navigate.d.ts +11 -6
- package/dist/render/navigate.js +34 -20
- package/dist/render/navigate.js.map +1 -1
- package/dist/render/snap.d.ts +5 -0
- package/dist/render/snap.js +84 -14
- package/dist/render/snap.js.map +1 -1
- package/dist/render/view.js +7 -2
- package/dist/render/view.js.map +1 -1
- package/dist/solver/equations.js +30 -16
- package/dist/solver/equations.js.map +1 -1
- package/dist/tools/dim.d.ts +6 -0
- package/dist/tools/dim.js +28 -4
- package/dist/tools/dim.js.map +1 -1
- package/dist/tools/modify.d.ts +32 -4
- package/dist/tools/modify.js +247 -97
- package/dist/tools/modify.js.map +1 -1
- package/dist/tools/registry.d.ts +2 -0
- package/dist/tools/registry.js +8 -0
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/select.d.ts +11 -8
- package/dist/tools/select.js +51 -19
- package/dist/tools/select.js.map +1 -1
- package/package.json +1 -1
- package/src/app/state.ts +3 -3
- package/src/data/provider.ts +2 -2
- package/src/data/sync.ts +4 -1
- package/src/editor/actions.ts +98 -16
- package/src/editor/advance.ts +23 -0
- package/src/editor/dimSize.ts +53 -0
- package/src/editor/gestures.ts +31 -9
- package/src/editor/keypad.ts +17 -1
- package/src/editor/keys.ts +2 -1
- package/src/editor/laser.ts +45 -14
- package/src/editor/linkActions.ts +87 -26
- package/src/editor/links.ts +17 -1
- package/src/editor/mode.ts +7 -5
- package/src/editor/ports.ts +10 -0
- package/src/editor/selection.ts +1 -1
- package/src/editor/tooltips.ts +1 -0
- package/src/index.ts +2 -2
- package/src/model/clockwise.ts +121 -0
- package/src/model/constraints.ts +1 -0
- package/src/model/geom.ts +10 -0
- package/src/model/links.ts +6 -1
- package/src/model/scale.ts +2 -0
- package/src/model/settings.ts +3 -1
- package/src/model/sketch.ts +14 -7
- package/src/model/trim.ts +188 -0
- package/src/model/types.ts +19 -2
- package/src/react/BottomBar.tsx +109 -25
- package/src/react/CadEditor.tsx +19 -9
- package/src/react/Drawer.tsx +3 -2
- package/src/react/PlanCanvas.native.tsx +25 -12
- package/src/react/PlanCanvas.web.tsx +17 -5
- package/src/react/ShapeMenu.tsx +3 -2
- package/src/react/ToolTip.tsx +3 -2
- package/src/react/TopBar.tsx +4 -3
- package/src/react/editorBox.ts +20 -0
- package/src/react/host.ts +12 -2
- package/src/react/pageLock.native.ts +2 -0
- package/src/react/pageLock.web.ts +12 -3
- package/src/react/ports.ts +10 -4
- package/src/react/saving.ts +10 -2
- package/src/react/store.ts +5 -2
- package/src/render/draw.ts +38 -16
- package/src/render/linkTile.ts +2 -2
- package/src/render/navigate.ts +31 -20
- package/src/render/snap.ts +80 -15
- package/src/render/view.ts +6 -2
- package/src/solver/equations.ts +30 -16
- package/src/tools/dim.ts +28 -4
- package/src/tools/modify.ts +205 -69
- package/src/tools/registry.ts +8 -0
- package/src/tools/select.ts +47 -20
- package/src/ui/domPorts.ts +2 -0
- package/dist/react/LaserTray.d.ts +0 -4
- package/dist/react/LaserTray.js +0 -26
- package/dist/react/LaserTray.js.map +0 -1
- package/src/react/LaserTray.tsx +0 -42
|
@@ -31,7 +31,8 @@ import { TABS_TOP, topLayout } from './topRow';
|
|
|
31
31
|
|
|
32
32
|
As a tool follows the pointer, only the moving parts (preview, snap marker, selection box) are drawn again; the
|
|
33
33
|
drawing is kept until it changes. Touches still reach editor/gestures.ts for the tools, Apple Pencil, and two- and
|
|
34
|
-
three-finger taps (undo, redo); it leaves the view to this canvas (setHostNavigation).
|
|
34
|
+
three-finger taps (undo, redo); it leaves the view to this canvas (setHostNavigation). A Pencil and fingers can be
|
|
35
|
+
down at once (fingers pan and pinch while it draws), so each touch is handed over with what it is (OwnType).
|
|
35
36
|
|
|
36
37
|
While a finger or Pencil places or drags something, the lens (render/lens.ts) shows the drawing around it twice as
|
|
37
38
|
close in a top corner: the same pictures again, through its zoom, clipped to it — nothing more is drawn for it.
|
|
@@ -52,8 +53,15 @@ interface Frame {
|
|
|
52
53
|
/** the latest of the UI thread's views it was drawn at (see UiView) */
|
|
53
54
|
seq: number;
|
|
54
55
|
}
|
|
55
|
-
/** A touch as the UI thread hands it over: id, position on the canvas, position in the window. */
|
|
56
|
-
type Packed = [id: number, x: number, y: number, ax: number, ay: number];
|
|
56
|
+
/** A touch as the UI thread hands it over: id, position on the canvas, position in the window, what it is. */
|
|
57
|
+
type Packed = [id: number, x: number, y: number, ax: number, ay: number, kind: string];
|
|
58
|
+
/**
|
|
59
|
+
* A touch that says what it is. react-native-gesture-handler gives an event one pointer type, whichever touch iOS lists
|
|
60
|
+
* first, so with an Apple Pencil and a finger both down it's a coin toss which the other is taken for; BOLDR patches it
|
|
61
|
+
* to say for each touch too (BOLDR_App patches/react-native-gesture-handler+*.patch). Without that, the event's is used.
|
|
62
|
+
*/
|
|
63
|
+
type OwnType = TouchData & { pointerType?: PointerType };
|
|
64
|
+
interface Typed { id: number; x: number; y: number; ax: number; ay: number; kind: string }
|
|
57
65
|
|
|
58
66
|
/** The latest of the UI thread's views this thread has taken; each frame says which it includes. */
|
|
59
67
|
let hostSeq = 0;
|
|
@@ -65,11 +73,11 @@ let placeLens: (() => void) | null = null;
|
|
|
65
73
|
* Touches from the UI thread: the view first, if the fingers moved it, then each touch to the editor's gestures (as a
|
|
66
74
|
* pointer lands, `down` is every one still down: any other's lift was lost).
|
|
67
75
|
*/
|
|
68
|
-
function touchesOnJS(type: number,
|
|
76
|
+
function touchesOnJS(type: number, ts: Packed[], view: UiView | null, down: number[] | null): void {
|
|
69
77
|
if (view) { hostSeq = view.seq; setViewFromHost(view.s, view.cx, view.cy); }
|
|
70
78
|
if (down) pointersStill(down);
|
|
71
79
|
const fn = type === NAV_DOWN ? pointerDown : type === NAV_MOVE ? pointerMove : type === NAV_UP ? pointerUp : pointerCancel, t = Date.now();
|
|
72
|
-
for (const [id, x, y, ax, ay] of ts) fn({ id, kind, x, y, t, cx: ax, cy: ay });
|
|
80
|
+
for (const [id, x, y, ax, ay, kind] of ts) fn({ id, kind, x, y, t, cx: ax, cy: ay });
|
|
73
81
|
// what a tool shows following the finger (a shape's outline, its marks, the snap), drawn now: left for the next frame
|
|
74
82
|
// it reached the screen a frame behind the finger. Only when nothing but those moving parts changed — the drawing
|
|
75
83
|
// itself, and the view, are drawn on the frame as before.
|
|
@@ -81,17 +89,22 @@ const kindOf = (t: PointerType): string => {
|
|
|
81
89
|
'worklet';
|
|
82
90
|
return t === PointerType.STYLUS ? 'pen' : t === PointerType.MOUSE ? 'mouse' : 'touch';
|
|
83
91
|
};
|
|
84
|
-
|
|
92
|
+
/** Each touch, and what it is: its own pointer type where it says, else the event's (see OwnType). */
|
|
93
|
+
const typed = (ts: TouchData[], type: PointerType): Typed[] => {
|
|
94
|
+
'worklet';
|
|
95
|
+
return ts.map(t => ({ id: t.id, x: t.x, y: t.y, ax: t.absoluteX, ay: t.absoluteY, kind: kindOf((t as OwnType).pointerType ?? type) }));
|
|
96
|
+
};
|
|
97
|
+
const pack = (ts: Typed[]): Packed[] => {
|
|
85
98
|
'worklet';
|
|
86
|
-
return ts.map(t => [t.id, t.x, t.y, t.
|
|
99
|
+
return ts.map(t => [t.id, t.x, t.y, t.ax, t.ay, t.kind] as Packed);
|
|
87
100
|
};
|
|
88
101
|
|
|
89
102
|
export const PlanCanvas = memo(function PlanCanvas() {
|
|
90
103
|
const first = useRef(true);
|
|
91
104
|
const frame = useSharedValue<Frame | null>(null);
|
|
92
105
|
const view = useSharedValue<UiView>({ s: 1, cx: 0, cy: 0, seq: 0 });
|
|
93
|
-
// the UI thread's own: the fingers down, whether they're navigating and where they were last,
|
|
94
|
-
const nav = useSharedValue<NavState>({ fingers: {}, navigating: false, last: null,
|
|
106
|
+
// the UI thread's own: the fingers down, whether they're navigating and where they were last, any Pencil down
|
|
107
|
+
const nav = useSharedValue<NavState>({ fingers: {}, navigating: false, last: null, pens: [] });
|
|
95
108
|
const readOnly = useSharedValue(false);
|
|
96
109
|
// the lens, and whether it's up (mounted only then: nothing drawn twice for it otherwise)
|
|
97
110
|
const lens = useSharedValue<Lens | null>(null);
|
|
@@ -187,11 +200,11 @@ export const PlanCanvas = memo(function PlanCanvas() {
|
|
|
187
200
|
/** A touch event on the UI thread: follow the fingers (render/navigate.ts), then hand the touches to this thread. */
|
|
188
201
|
const touch = (type: number, e: GestureTouchEvent) => {
|
|
189
202
|
'worklet';
|
|
190
|
-
const
|
|
191
|
-
const r = navTouch(nav.value, type,
|
|
203
|
+
const ts = typed(e.changedTouches, e.pointerType), down = type === NAV_DOWN ? e.allTouches.map(t => t.id) : null;
|
|
204
|
+
const r = navTouch(nav.value, type, kindOf(e.pointerType), ts, down, readOnly.value, view.value, frame.value);
|
|
192
205
|
nav.value = r.st;
|
|
193
206
|
if (r.view !== view.value) view.value = r.view;
|
|
194
|
-
runOnJS(touchesOnJS)(type,
|
|
207
|
+
runOnJS(touchesOnJS)(type, pack(ts), r.moved ? r.view : null, down);
|
|
195
208
|
};
|
|
196
209
|
const touches = Gesture.Manual()
|
|
197
210
|
.onTouchesDown((e, manager) => {
|
|
@@ -2,8 +2,8 @@ import { useEffect, useRef } from 'react';
|
|
|
2
2
|
import { pointerCancel, pointerDown, pointerLeave, pointerMove, pointerUp, wheelZoom, type PointerIn } from '../editor/gestures';
|
|
3
3
|
import { keyDown, keyUp, type KeyIn } from '../editor/keys';
|
|
4
4
|
import { page } from '../model/store';
|
|
5
|
-
import { fitView, initCanvas, resize, setFrameRenderer } from '../render/view';
|
|
6
|
-
import { PAGE_LOCK_ROOT } from './pageLock';
|
|
5
|
+
import { cvs, fitView, initCanvas, resize, setFrameRenderer } from '../render/view';
|
|
6
|
+
import { BESIDE, PAGE_LOCK_ROOT } from './pageLock';
|
|
7
7
|
import { setCursorTarget } from './ports';
|
|
8
8
|
|
|
9
9
|
/*
|
|
@@ -14,14 +14,19 @@ import { setCursorTarget } from './ports';
|
|
|
14
14
|
|
|
15
15
|
const keyIn = (e: KeyboardEvent): KeyIn => ({ key: e.key, shift: e.shiftKey, mod: e.metaKey || e.ctrlKey, alt: e.altKey });
|
|
16
16
|
|
|
17
|
+
/** The host's pane beside the editor that the last press on the page was in (BESIDE), if it was in one. */
|
|
18
|
+
let pressedBeside: Element | null = null;
|
|
19
|
+
|
|
17
20
|
/**
|
|
18
21
|
* Whether a key is the editor's: pressed in it, or with nothing focused — not typed into a field, nor pressed in the
|
|
19
22
|
* host's own UI over the drawing (a picker, a measurement's detail), which is outside the editor's root. Delete there
|
|
20
|
-
* would otherwise delete what's selected on the drawing.
|
|
23
|
+
* would otherwise delete what's selected on the drawing. With nothing focused it's the editor's unless the last press
|
|
24
|
+
* was in a pane beside it (a split view) that's still open: a click on its page, where nothing takes focus, leaves the
|
|
25
|
+
* focus on the page itself.
|
|
21
26
|
*/
|
|
22
27
|
function forEditor(e: KeyboardEvent): boolean {
|
|
23
28
|
const t = e.target instanceof HTMLElement ? e.target : null;
|
|
24
|
-
if (!t || t === document.body || t === document.documentElement) return
|
|
29
|
+
if (!t || t === document.body || t === document.documentElement) return !pressedBeside?.isConnected;
|
|
25
30
|
if (t.tagName === 'INPUT' || t.tagName === 'TEXTAREA' || t.tagName === 'SELECT' || t.isContentEditable) return false;
|
|
26
31
|
return !!t.closest('#' + PAGE_LOCK_ROOT);
|
|
27
32
|
}
|
|
@@ -36,7 +41,9 @@ export function PlanCanvas() {
|
|
|
36
41
|
let first = true;
|
|
37
42
|
const ro = new ResizeObserver(() => {
|
|
38
43
|
resize();
|
|
39
|
-
|
|
44
|
+
// fitted once, at its first real size (not while a pane opening round it is still a sliver)
|
|
45
|
+
if (!first || cvs.W < 40 || cvs.H < 40) return;
|
|
46
|
+
if (!page().view || page()._fit !== false) fitView();
|
|
40
47
|
first = false;
|
|
41
48
|
});
|
|
42
49
|
ro.observe(cv);
|
|
@@ -60,6 +67,11 @@ export function PlanCanvas() {
|
|
|
60
67
|
// shift+wheel arrives as deltaX on some systems
|
|
61
68
|
wheelZoom(e.clientX - r.left, e.clientY - r.top, e.deltaY || e.deltaX, e.ctrlKey || e.metaKey, e.deltaMode !== 0);
|
|
62
69
|
}, { passive: false, signal: ac.signal });
|
|
70
|
+
// (whether the last press was in a pane beside the editor, for keys pressed with nothing focused: see forEditor)
|
|
71
|
+
pressedBeside = null;
|
|
72
|
+
document.addEventListener('pointerdown', e => {
|
|
73
|
+
pressedBeside = e.target instanceof Element ? e.target.closest(`[${BESIDE}]`) : null;
|
|
74
|
+
}, { capture: true, signal: ac.signal });
|
|
63
75
|
// capture phase: a key the editor uses (Enter on the keypad, Space to pan, …) must not also press whatever button
|
|
64
76
|
// last took focus
|
|
65
77
|
document.addEventListener('keydown', e => {
|
package/src/react/ShapeMenu.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useRef } from 'react';
|
|
2
|
-
import { Animated, Text,
|
|
2
|
+
import { Animated, Text, View } from 'react-native';
|
|
3
3
|
import { ed } from '../app/state';
|
|
4
4
|
import { railIcon, TOOL_GROUPS, toolLabel } from '../editor/mode';
|
|
5
5
|
import { toolTip } from '../editor/tooltips';
|
|
@@ -9,6 +9,7 @@ import { notify, ui, useEditorKey } from './store';
|
|
|
9
9
|
import { C, FONT, shadow } from './theme';
|
|
10
10
|
import { Tap, usePopup } from './motion';
|
|
11
11
|
import { createSheet } from './corners';
|
|
12
|
+
import { useEditorBox } from './editorBox';
|
|
12
13
|
|
|
13
14
|
const ROW = 44, GAP = 6, PAD = 8;
|
|
14
15
|
/** A menu's height for `n` rows: the rows, the gaps between them, its padding and border. */
|
|
@@ -22,7 +23,7 @@ const heightFor = (n: number) => n * ROW + (n - 1) * GAP + 2 * PAD + 2;
|
|
|
22
23
|
*/
|
|
23
24
|
export function ShapeMenu() {
|
|
24
25
|
useEditorKey(() => (ui.shapeMenu ? [ui.shapeMenu.x, ui.shapeMenu.y, ui.shapeMenu.group, ed.mode, ed.tool].join('|') : ''));
|
|
25
|
-
const { height } =
|
|
26
|
+
const { height } = useEditorBox(), now = ui.shapeMenu, nowGroup = now ? TOOL_GROUPS[now.group] : null;
|
|
26
27
|
const open = !!now && !!nowGroup && ed.mode === nowGroup.mode;
|
|
27
28
|
// (it grows out of the rail's place, sideways; as it goes it keeps what it showed)
|
|
28
29
|
const last = useRef(now), pop = usePopup(open, { x: -8 }, 'left center');
|
package/src/react/ToolTip.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import { Animated,
|
|
2
|
+
import { Animated, View } from 'react-native';
|
|
3
3
|
import { TIP_TOP, topLayout } from './topRow';
|
|
4
4
|
import { RichText } from './RichText';
|
|
5
5
|
import { ui, useEditorKey } from './store';
|
|
@@ -7,6 +7,7 @@ import { C, FONT, shadow } from './theme';
|
|
|
7
7
|
import { TOGGLE_EASE } from './motion';
|
|
8
8
|
import { NATIVE } from './easing';
|
|
9
9
|
import { createSheet } from './corners';
|
|
10
|
+
import { useEditorBox } from './editorBox';
|
|
10
11
|
|
|
11
12
|
/** How long the note stays, and how it comes and goes. */
|
|
12
13
|
const SHOW_MS = 2600, IN_MS = 160, OUT_MS = 240;
|
|
@@ -16,7 +17,7 @@ const SHOW_MS = 2600, IN_MS = 160, OUT_MS = 240;
|
|
|
16
17
|
* moment and goes by itself; picking another tool replaces it at once.
|
|
17
18
|
*/
|
|
18
19
|
export function ToolTip({ phone }: { phone: boolean }) {
|
|
19
|
-
const { width, height } =
|
|
20
|
+
const { width, height } = useEditorBox();
|
|
20
21
|
useEditorKey(() => String(ui.toolTip?.seq ?? '') + '|' + topLayout(width, height, phone).below);
|
|
21
22
|
const tip = ui.toolTip, v = useRef(new Animated.Value(0)).current, [shown, setShown] = useState<{ text: string; seq: number } | null>(null);
|
|
22
23
|
const slide = useRef(v.interpolate({ inputRange: [0, 1], outputRange: [-4, 0] })).current;
|
package/src/react/TopBar.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import { Text,
|
|
2
|
+
import { Text, View } from 'react-native';
|
|
3
3
|
import { closeElevation, elev, elevOpen, elevTitle, flipElevation } from '../editor/elevation';
|
|
4
4
|
import { setMode } from '../editor/mode';
|
|
5
5
|
import { openDrawer } from '../editor/ports';
|
|
@@ -17,6 +17,7 @@ import { C, FONT, shadow } from './theme';
|
|
|
17
17
|
import { Segmented, Tap } from './motion';
|
|
18
18
|
import { createSheet } from './corners';
|
|
19
19
|
import { setTopRoom, TABS_TOP, topKey, topLayout } from './topRow';
|
|
20
|
+
import { useEditorBox } from './editorBox';
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* The top bar: back, the project and page, view controls, the host's own buttons, settings, and Save. In the wall
|
|
@@ -25,7 +26,7 @@ import { setTopRoom, TABS_TOP, topKey, topLayout } from './topRow';
|
|
|
25
26
|
export function TopBar({ onBack, headerRight, phone, readOnly }: {
|
|
26
27
|
onBack?: () => void; headerRight?: ReactNode | ((buttonSize: number) => ReactNode); phone: boolean; readOnly?: boolean;
|
|
27
28
|
}) {
|
|
28
|
-
const { width, height } =
|
|
29
|
+
const { width, height } = useEditorBox(), size = phone ? 42 : 46;
|
|
29
30
|
useEditorKey(() => {
|
|
30
31
|
const w = elevOpen() && !!elev.frame, title = w ? elevTitle() : null;
|
|
31
32
|
return [w, title?.title, title?.sub, store.project.name, page().name, ui.menu, saveState(), manualSave(), is3d(), topKey(topLayout(width, height, phone, size))].join('|');
|
|
@@ -95,7 +96,7 @@ const TABS: [Mode | '3d', string][] = [['annotate', 'Annotate'], ['draft', 'Draf
|
|
|
95
96
|
|
|
96
97
|
/** Annotate / Draft / 3D: centred in the top row, or on a row of their own under it (see topRow.ts). */
|
|
97
98
|
export function ModeTabs({ phone }: { phone: boolean }) {
|
|
98
|
-
const { width, height } =
|
|
99
|
+
const { width, height } = useEditorBox();
|
|
99
100
|
useEditorKey(() => (is3d() ? '3d' : ed.mode) + '|' + topKey(topLayout(width, height, phone)));
|
|
100
101
|
const at = topLayout(width, height, phone);
|
|
101
102
|
// (straight over: no line under the tabs saying how to get about in 3D)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
import { useWindowDimensions } from 'react-native';
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
The editor's own area: what its chrome is laid out in. It's the window when the editor fills it, and less when the
|
|
6
|
+
host puts it in a pane beside something else (a split view, beside the app's sidebar). The phone or tablet layout,
|
|
7
|
+
the top row, the drawer and the menus all go by this, never by the window; the drawing already does, its canvas
|
|
8
|
+
sized by its own layout.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export interface EditorBox { width: number; height: number }
|
|
12
|
+
|
|
13
|
+
/** Set by CadEditor from its root's layout; until that first layout, the window stands in. */
|
|
14
|
+
export const EditorBoxContext = createContext<EditorBox | null>(null);
|
|
15
|
+
|
|
16
|
+
/** The editor's area (the window until it's been laid out). */
|
|
17
|
+
export function useEditorBox(): EditorBox {
|
|
18
|
+
const box = useContext(EditorBoxContext), win = useWindowDimensions();
|
|
19
|
+
return box ?? win;
|
|
20
|
+
}
|
package/src/react/host.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { applyReading, laser } from '../editor/laser';
|
|
1
|
+
import { applyReading, laser, readingOverwrites } from '../editor/laser';
|
|
2
2
|
import { store } from '../model/store';
|
|
3
3
|
import { closeSurveyRun, setSurveyCursor, takeSurveyPoint } from '../tools/survey';
|
|
4
4
|
import { notify } from './store';
|
|
@@ -12,7 +12,7 @@ import { notify } from './store';
|
|
|
12
12
|
/** Whether an editor is on screen (CadEditor sets it): readings that arrive after it closed are left to the host. */
|
|
13
13
|
export const editorHost = { open: false };
|
|
14
14
|
|
|
15
|
-
/** A measure connected or disconnected:
|
|
15
|
+
/** A measure connected or disconnected: enables the keypad's Laser key (no tray of readings shows: see applyReading). */
|
|
16
16
|
export function setLaserConnected(on: boolean): void {
|
|
17
17
|
laser.on = on;
|
|
18
18
|
laser.external = on;
|
|
@@ -33,6 +33,16 @@ export function laserReading(inches: number, capture?: unknown): boolean {
|
|
|
33
33
|
return true;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Whether a reading of `inches`, passed to laserReading now, would replace a length or diameter already measured on
|
|
38
|
+
* the selected line, wall edge or curve (see readingOverwrites), for a host that warns first: hold the reading, ask,
|
|
39
|
+
* and pass it on only once the person agrees. Nothing changes by asking. False when no drawing is open to take it.
|
|
40
|
+
*/
|
|
41
|
+
export function laserReadingOverwrites(inches: number): boolean {
|
|
42
|
+
if (!editorHost.open || !store.project || !Number.isFinite(inches) || inches <= 0) return false;
|
|
43
|
+
return readingOverwrites(inches);
|
|
44
|
+
}
|
|
45
|
+
|
|
36
46
|
/**
|
|
37
47
|
* A point measured by a templating device (BOLDR's T1R), in inches, on the plan's axes: x to the right, y UP. Turning
|
|
38
48
|
* the device's own frame into that is the host's job, and it's where the handedness goes: a device whose angle turns
|
|
@@ -17,6 +17,13 @@ const LOCKED_VIEWPORT = 'width=device-width, initial-scale=1, maximum-scale=1, u
|
|
|
17
17
|
|
|
18
18
|
export const PAGE_LOCK_ROOT = ROOT;
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Put on a host's pane beside the editor (a split view). What starts in it is its own: the lock leaves its pinches and
|
|
22
|
+
* two-finger moves alone, and a key pressed with nothing focused after a press in it isn't the editor's (see
|
|
23
|
+
* PlanCanvas.web.tsx).
|
|
24
|
+
*/
|
|
25
|
+
export const BESIDE = 'data-cad-beside';
|
|
26
|
+
|
|
20
27
|
export function usePageLock(): void {
|
|
21
28
|
useEffect(() => {
|
|
22
29
|
if (typeof document === 'undefined') return;
|
|
@@ -31,9 +38,11 @@ export function usePageLock(): void {
|
|
|
31
38
|
if (!meta) { meta = document.createElement('meta'); meta.name = 'viewport'; document.head.appendChild(meta); }
|
|
32
39
|
const before = meta.content;
|
|
33
40
|
meta.content = LOCKED_VIEWPORT;
|
|
34
|
-
// Safari's pinch zoom (it ignores user-scalable=no): its gesture events, and two-finger touch moves
|
|
35
|
-
|
|
36
|
-
const
|
|
41
|
+
// Safari's pinch zoom (it ignores user-scalable=no): its gesture events, and two-finger touch moves — except in a
|
|
42
|
+
// host's pane beside the editor, which handles its own (BESIDE)
|
|
43
|
+
const own = (e: Event) => e.target instanceof Element && !!e.target.closest(`[${BESIDE}]`);
|
|
44
|
+
const stop = (e: Event) => { if (!own(e)) e.preventDefault(); };
|
|
45
|
+
const pinch = (e: TouchEvent) => { if (e.touches.length > 1 && !own(e)) e.preventDefault(); };
|
|
37
46
|
const opts: AddEventListenerOptions = { passive: false };
|
|
38
47
|
const gestures = ['gesturestart', 'gesturechange', 'gestureend'];
|
|
39
48
|
gestures.forEach(g => document.addEventListener(g, stop, opts));
|
package/src/react/ports.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { manualSave, noteEdits, saveDrawing } from './saving';
|
|
|
12
12
|
import { requestDraw, requestOverlayDraw } from '../render/view';
|
|
13
13
|
import { notify, ui } from './store';
|
|
14
14
|
import { setInteracting } from './Duck';
|
|
15
|
+
import { PAGE_LOCK_ROOT } from './pageLock';
|
|
15
16
|
|
|
16
17
|
/* The editor's ports for the React Native interface: each request updates the interface's state and re-renders. */
|
|
17
18
|
|
|
@@ -58,8 +59,8 @@ function hostRequest(spec: KeypadSpec): HostKeypadRequest {
|
|
|
58
59
|
};
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
/** A slider above the bar (an image's opacity or rotation, the tiles' size): opened, swapped for another, or closed by its button again. */
|
|
62
|
-
function toggleImagePop(kind: 'opacity' | 'rotate' | 'tilesize'): void {
|
|
62
|
+
/** A slider above the bar (an image's opacity or rotation, the tiles' or measurement tiles' size): opened, swapped for another, or closed by its button again. */
|
|
63
|
+
function toggleImagePop(kind: 'opacity' | 'rotate' | 'tilesize' | 'dimsize'): void {
|
|
63
64
|
ui.imgPop = ui.imgPop === kind ? null : kind;
|
|
64
65
|
ui.menu = false;
|
|
65
66
|
// (a toast would sit over the slider: it's done with once the slider opens)
|
|
@@ -110,8 +111,12 @@ export const reactPorts: EditorPorts = {
|
|
|
110
111
|
requestDraw();
|
|
111
112
|
return;
|
|
112
113
|
}
|
|
113
|
-
// the keypad has no text field: let typed keys reach the editor, not the button that opened it (Enter would press it
|
|
114
|
-
|
|
114
|
+
// the keypad has no text field: let typed keys reach the editor, not the button that opened it (Enter would press it
|
|
115
|
+
// again). Only a button of the editor's: focus elsewhere on the page (a pane beside it) stays where it is.
|
|
116
|
+
if (typeof document !== 'undefined') {
|
|
117
|
+
const a = document.activeElement as HTMLElement | null;
|
|
118
|
+
if (a?.closest?.('#' + PAGE_LOCK_ROOT)) a.blur?.();
|
|
119
|
+
}
|
|
115
120
|
keypadStart(spec);
|
|
116
121
|
ui.keypad = true;
|
|
117
122
|
sheetOpened();
|
|
@@ -148,6 +153,7 @@ export const reactPorts: EditorPorts = {
|
|
|
148
153
|
toggleImageOpacity() { toggleImagePop('opacity'); },
|
|
149
154
|
toggleImageRotation() { toggleImagePop('rotate'); },
|
|
150
155
|
toggleTileSize() { toggleImagePop('tilesize'); },
|
|
156
|
+
toggleDimSize() { toggleImagePop('dimsize'); },
|
|
151
157
|
editRoomName(roomId) { ui.drawer = 'rooms'; ui.renameRoom = roomId; notify(); },
|
|
152
158
|
setCursor(cursor, where = 'plan') { cursorTargets[where]?.(cursor); },
|
|
153
159
|
interacting: setInteracting,
|
package/src/react/saving.ts
CHANGED
|
@@ -32,10 +32,18 @@ function setState(s: CadSaveState): void {
|
|
|
32
32
|
notify();
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Start manual saving for the drawing open in `sync`; `listener` hears each change of state, and the first, 'saved',
|
|
37
|
+
* once the editor has mounted (announceSaveState). This runs as the editor first renders, and a host keeps the state in
|
|
38
|
+
* its own: React won't have one component set another's state while it renders.
|
|
39
|
+
*/
|
|
36
40
|
export function startManualSave(sync: CadSync, listener: ((s: CadSaveState) => void) | null): void {
|
|
37
41
|
Object.assign(sv, { manual: true, state: 'saved', cleanSeq: ed.editSeq, sync, listener });
|
|
38
|
-
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Tell the host the state as it is now (the editor, once it has mounted). */
|
|
45
|
+
export function announceSaveState(): void {
|
|
46
|
+
if (sv.manual) sv.listener?.(sv.state);
|
|
39
47
|
}
|
|
40
48
|
|
|
41
49
|
export function stopManualSave(): void {
|
package/src/react/store.ts
CHANGED
|
@@ -55,8 +55,11 @@ export const ui = sessionState(() => ({
|
|
|
55
55
|
palette: false,
|
|
56
56
|
/** what the tool just picked from the rail does (a note under the tabs that goes by itself); seq tells one pick from the next */
|
|
57
57
|
toolTip: null as { text: string; seq: number } | null,
|
|
58
|
-
/**
|
|
59
|
-
|
|
58
|
+
/**
|
|
59
|
+
* what's open above the bar: the selected image's opacity or turn, or the link tiles' size (sliders), or Open's
|
|
60
|
+
* question (here, or side by side)
|
|
61
|
+
*/
|
|
62
|
+
imgPop: null as null | 'opacity' | 'rotate' | 'tilesize' | 'dimsize' | 'open',
|
|
60
63
|
/** the tool each shared place on the rail draws with (the last picked; editor/mode.ts TOOL_GROUPS), and the menu of
|
|
61
64
|
a group's tools, open beside its place at x, y */
|
|
62
65
|
picked: { shapes: 'line', marks: 'arrow' } as Record<string, string>,
|
package/src/render/draw.ts
CHANGED
|
@@ -41,7 +41,8 @@ export function rr(c: C2D, x: number, y: number, w: number, h: number, r: number
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
export interface ChipOpts {
|
|
44
|
-
|
|
44
|
+
/** `r`: its corners' radius (5) */
|
|
45
|
+
bg: string; fg: string; border?: [string, number?] | null; font?: string; pad?: number; h?: number; minW?: number; r?: number;
|
|
45
46
|
kind?: HitChip['kind']; id?: string; rot?: number;
|
|
46
47
|
/**
|
|
47
48
|
* 'link': a measurement of the job sets it. The chip is then Figma's linked measurement (2795:77149): a white badge
|
|
@@ -80,13 +81,22 @@ export function chipSize(c: C2D, text: string, { font = '600 12px', pad = 7, h =
|
|
|
80
81
|
return { w: Math.max(minW, c.measureText(text).width + room), h };
|
|
81
82
|
}
|
|
82
83
|
|
|
84
|
+
/**
|
|
85
|
+
* A measurement tile's size — a dimension's chip: its font, padding, height and corners — times the file's measurement
|
|
86
|
+
* tile size (settings.chipPct, editor/dimSize.ts). At 100%, chip()'s own: 12 px, 7, 22, 5.
|
|
87
|
+
*/
|
|
88
|
+
export function dimChip(): Pick<ChipOpts, 'font' | 'pad' | 'h' | 'r'> {
|
|
89
|
+
const k = settings.chipPct / 100;
|
|
90
|
+
return k === 1 ? {} : { font: '600 ' + 12 * k + 'px', pad: 7 * k, h: 22 * k, r: 5 * k };
|
|
91
|
+
}
|
|
92
|
+
|
|
83
93
|
/** Rounded label on the canvas; registers a hit region when `kind` is given. */
|
|
84
94
|
export function chip(c: C2D, text: string, cx: number, cy: number, opts: ChipOpts): number {
|
|
85
95
|
const { bg, fg, border, kind, id, rot = 0, mark } = opts;
|
|
86
96
|
const { w, h } = chipSize(c, text, opts), x = cx - w / 2, y = cy - h / 2;
|
|
87
97
|
c.save();
|
|
88
98
|
if (rot) { c.translate(cx, cy); c.rotate(rot); c.translate(-cx, -cy); }
|
|
89
|
-
rr(c, x, y, w, h, 5);
|
|
99
|
+
rr(c, x, y, w, h, opts.r ?? 5);
|
|
90
100
|
c.fillStyle = bg; c.fill();
|
|
91
101
|
if (border) { c.lineWidth = border[1] || 1; c.strokeStyle = border[0]; c.stroke(); }
|
|
92
102
|
c.fillStyle = fg; c.textAlign = 'center'; c.textBaseline = 'middle';
|
|
@@ -134,8 +144,13 @@ function drawUnderlay(c: C2D, T: Xform): void {
|
|
|
134
144
|
c.save(); c.globalAlpha = u.opacity ?? 0.6;
|
|
135
145
|
c.translate(x, y);
|
|
136
146
|
if (u.rot) c.rotate((u.rot * Math.PI) / 180);
|
|
137
|
-
if (ready)
|
|
138
|
-
|
|
147
|
+
if (ready) {
|
|
148
|
+
// cropped: the picture whole, past the part that shows, clipped to it
|
|
149
|
+
const k = u.crop;
|
|
150
|
+
if (k) { c.beginPath(); c.rect(-w / 2, -hh / 2, w, hh); c.clip(); }
|
|
151
|
+
const fw = k ? w / (1 - k.l - k.r) : w, fh = k ? hh / (1 - k.t - k.b) : hh;
|
|
152
|
+
c.drawImage(im!, -w / 2 - (k ? k.l * fw : 0), -hh / 2 - (k ? k.t * fh : 0), fw, fh);
|
|
153
|
+
} else {
|
|
139
154
|
c.fillStyle = '#2B2C2E'; c.fillRect(-w / 2, -hh / 2, w, hh);
|
|
140
155
|
if (linkInfoOf(u.link!)?.exists === false) {
|
|
141
156
|
c.font = '500 13px ' + FONT; c.fillStyle = '#9FA0A2'; c.textAlign = 'center'; c.textBaseline = 'middle';
|
|
@@ -149,11 +164,15 @@ function drawUnderlay(c: C2D, T: Xform): void {
|
|
|
149
164
|
/**
|
|
150
165
|
* Each expanded photo's badge: its link icon in a white disc in its top-right corner (imageLinkBadge), over the drawing
|
|
151
166
|
* — always, as Skia's, selected or not, locked or not: it says the photo is the job's, and a tap on it opens it.
|
|
167
|
+
* `selected`: the selected photos' badges, drawn with their outlines and handles (paintOverlay), or the rest, with the
|
|
168
|
+
* drawing. A device keeps the drawing as a picture while a photo is moved, sized, cropped or turned, and draws only
|
|
169
|
+
* the photos and the moving parts again: a badge kept with the drawing stayed where the photo had been.
|
|
152
170
|
*/
|
|
153
|
-
function drawImageLinks(c: C2D, T: Xform): void {
|
|
171
|
+
function drawImageLinks(c: C2D, T: Xform, selected: boolean): void {
|
|
154
172
|
if (!settings.layers.underlay) return;
|
|
155
173
|
const { W, H } = cvs;
|
|
156
174
|
for (const u of page().underlays) {
|
|
175
|
+
if (isSel('underlay', u.id) !== selected) continue;
|
|
157
176
|
const b = imageLinkBadge(T, u);
|
|
158
177
|
if (!b || b.x < -b.r || b.y < -b.r || b.x > W + b.r || b.y > H + b.r) continue;
|
|
159
178
|
const r = b.r, disc = (cc: C2D, X: number, Y: number) => { cc.beginPath(); cc.arc(X + r, Y + r, r, 0, Math.PI * 2); };
|
|
@@ -618,7 +637,7 @@ function drawDims(c: C2D, T: Xform, sk: Sketch): void {
|
|
|
618
637
|
}
|
|
619
638
|
c.restore();
|
|
620
639
|
}
|
|
621
|
-
const text = wrap(fmtAng(val)), opts: ChipOpts = { bg, fg, border, kind: 'dim', id, mark };
|
|
640
|
+
const text = wrap(fmtAng(val)), opts: ChipOpts = { bg, fg, border, kind: 'dim', id, mark, ...dimChip() };
|
|
622
641
|
// (left where it was drawn: 50 px out along the bisector, or as far as its corners stay clear of the corner — a
|
|
623
642
|
// linked chip is wider)
|
|
624
643
|
const sz = chipSize(c, text, opts), out = Math.max(50, Math.hypot(sz.w, sz.h) / 2 + 28);
|
|
@@ -627,7 +646,7 @@ function drawDims(c: C2D, T: Xform, sk: Sketch): void {
|
|
|
627
646
|
continue;
|
|
628
647
|
}
|
|
629
648
|
if (d.type === 'diam' && 'o' in A) {
|
|
630
|
-
drawDiameter(c, T, A.o, A.r, d, d.rad ? 'R ' + wrap(fmtLen(val / 2)) : 'Ø ' + wrap(fmtLen(val)), bad ? TH.red : ref ? TH.chipline : TH.blue, { bg, fg, border, kind: 'dim', id, mark }, ref);
|
|
649
|
+
drawDiameter(c, T, A.o, A.r, d, d.rad ? 'R ' + wrap(fmtLen(val / 2)) : 'Ø ' + wrap(fmtLen(val)), bad ? TH.red : ref ? TH.chipline : TH.blue, { bg, fg, border, kind: 'dim', id, mark, ...dimChip() }, ref);
|
|
631
650
|
continue;
|
|
632
651
|
}
|
|
633
652
|
if (!('a' in A)) continue;
|
|
@@ -641,7 +660,7 @@ function drawDims(c: C2D, T: Xform, sk: Sketch): void {
|
|
|
641
660
|
c.save(); if (ref) c.setLineDash([3, 3]); c.strokeStyle = bad ? TH.red : ref ? TH.chipline : TH.blue; c.lineWidth = 1.2;
|
|
642
661
|
c.beginPath(); c.moveTo(ax, ay); c.lineTo(bx, by); c.stroke(); c.restore();
|
|
643
662
|
}
|
|
644
|
-
chip(c, wrap(fmtLen(val)), mx, my, { bg, fg, border, kind: 'dim', id, mark });
|
|
663
|
+
chip(c, wrap(fmtLen(val)), mx, my, { bg, fg, border, kind: 'dim', id, mark, ...dimChip() });
|
|
645
664
|
}
|
|
646
665
|
}
|
|
647
666
|
|
|
@@ -655,14 +674,15 @@ function drawDims(c: C2D, T: Xform, sk: Sketch): void {
|
|
|
655
674
|
*/
|
|
656
675
|
function drawOpeningDims(c: C2D, T: Xform, sk: Sketch): void {
|
|
657
676
|
if (!settings.layers.dims || ed.mode !== 'draft') return;
|
|
658
|
-
|
|
677
|
+
// (the rows, and how far apart along them, grow with the measurement tiles: editor/dimSize.ts)
|
|
678
|
+
const k = settings.chipPct / 100, ROW = (26 * k) / T.s;
|
|
659
679
|
for (const id in sk.openings) {
|
|
660
680
|
const o = sk.openings[id], g = openingFrame(sk, id);
|
|
661
681
|
if (!g) continue;
|
|
662
682
|
const l = sk.lines[o.line], L = hyp(sk.points[l.b].x - g.A.x, sk.points[l.b].y - g.A.y);
|
|
663
683
|
const side = outsideSide(sk, o.line);
|
|
664
684
|
// automatic rows start 34 px past the wall face (clear of the H/V badges); a dragged dimension keeps its own offset
|
|
665
|
-
const k0 = g.t / 2 + 34 / T.s;
|
|
685
|
+
const k0 = g.t / 2 + (34 + 11 * (k - 1)) / T.s;
|
|
666
686
|
const kRow = (row: number) => side * (k0 + row * ROW);
|
|
667
687
|
/** screen point at `s` along the wall, `k` (signed, world) off its centerline */
|
|
668
688
|
const P = (s: number, k: number) => S(T, g.A.x + g.ux * s + g.nx * k, g.A.y + g.uy * s + g.ny * k);
|
|
@@ -690,14 +710,14 @@ function drawOpeningDims(c: C2D, T: Xform, sk: Sketch): void {
|
|
|
690
710
|
};
|
|
691
711
|
const label = (s0: number, s1: number, part: string, text: string, k: number, bg: string = TH.blue, fg = '#fff', border: [string, number] | null = null) => {
|
|
692
712
|
const [mx, my] = P((s0 + s1) / 2, k);
|
|
693
|
-
chip(c, text, mx, my, { bg, fg, border: odimSel(part) ? [TH.yellow, 2] : border, kind: 'odim', id });
|
|
713
|
+
chip(c, text, mx, my, { bg, fg, border: odimSel(part) ? [TH.yellow, 2] : border, kind: 'odim', id, ...dimChip() });
|
|
694
714
|
if (hits && hits.length) hits[hits.length - 1].part = part;
|
|
695
715
|
};
|
|
696
716
|
// automatic placement packs dimensions into rows so they don't overlap each other or the width chip;
|
|
697
717
|
// spans that only touch end to end share a row (a chained string)
|
|
698
718
|
const rows: [number, number][][] = [o.wOff == null ? [[g.s0, g.s1]] : []];
|
|
699
719
|
const place = (a: number, b: number) => {
|
|
700
|
-
const lo = Math.min(a, b), hi = Math.max(a, b), gap = 64 / T.s;
|
|
720
|
+
const lo = Math.min(a, b), hi = Math.max(a, b), gap = (64 * k) / T.s;
|
|
701
721
|
const clash = ([x, y]: [number, number]) => (lo < y - 1e-6 && hi > x + 1e-6) || Math.abs((lo + hi) / 2 - (x + y) / 2) < gap;
|
|
702
722
|
for (let r = 0; ; r++) {
|
|
703
723
|
rows[r] = rows[r] || [];
|
|
@@ -1108,7 +1128,7 @@ function drawSnap(c: C2D, T: Xform): void {
|
|
|
1108
1128
|
const [x, y] = S(T, s.x, s.y);
|
|
1109
1129
|
if (s.kind !== 'free' && s.kind !== 'grid') {
|
|
1110
1130
|
c.lineWidth = 2; c.beginPath();
|
|
1111
|
-
if (s.kind === 'point') c.arc(x, y, 8, 0, Math.PI * 2);
|
|
1131
|
+
if (s.kind === 'point' || s.kind === 'facecorner') c.arc(x, y, 8, 0, Math.PI * 2);
|
|
1112
1132
|
else if (s.kind === 'mid') { c.moveTo(x, y - 8); c.lineTo(x + 7, y + 5); c.lineTo(x - 7, y + 5); c.closePath(); }
|
|
1113
1133
|
else if (s.kind === 'inter') { c.moveTo(x - 6, y - 6); c.lineTo(x + 6, y + 6); c.moveTo(x + 6, y - 6); c.lineTo(x - 6, y + 6); }
|
|
1114
1134
|
else c.rect(x - 5, y - 5, 10, 10);
|
|
@@ -1209,8 +1229,8 @@ function paintPlanView(ctx: C2D, sk: Sketch, m: number, under = true): void {
|
|
|
1209
1229
|
drawOpeningAnchors(ctx, T, sk);
|
|
1210
1230
|
drawDims(ctx, T, sk);
|
|
1211
1231
|
drawOpeningDims(ctx, T, sk);
|
|
1212
|
-
// (an expanded photo's badge over the drawing, under the markup: as it's tapped)
|
|
1213
|
-
drawImageLinks(ctx, T);
|
|
1232
|
+
// (an expanded photo's badge over the drawing, under the markup: as it's tapped. A selected one's: paintOverlay)
|
|
1233
|
+
drawImageLinks(ctx, T, false);
|
|
1214
1234
|
drawNotes(ctx, T, sk);
|
|
1215
1235
|
drawNoteSelection(ctx, T);
|
|
1216
1236
|
}
|
|
@@ -1258,7 +1278,9 @@ function drawSurveyCursor(ctx: C2D, T: Xform): void {
|
|
|
1258
1278
|
|
|
1259
1279
|
function paintOverlay(ctx: C2D, W: number, H: number, fixed: C2D = ctx): void {
|
|
1260
1280
|
const T = mainT();
|
|
1261
|
-
// a selected image's outline and handles: with the moving parts, as it's turned, moved or sized (over the
|
|
1281
|
+
// a selected image's badge, outline and handles: with the moving parts, as it's turned, moved or sized (over the
|
|
1282
|
+
// drawing; the badge under the handles, as it was under them kept with the drawing). The wall view has no photos.
|
|
1283
|
+
if (!(elevOpen() && elev.frame)) drawImageLinks(ctx, T, true);
|
|
1262
1284
|
drawUnderlaySelection(ctx, T);
|
|
1263
1285
|
if (ed.preview) ed.preview(ctx, T);
|
|
1264
1286
|
// (over the tool's preview — the templator's would-be edge runs into it — whatever tool is in hand)
|
package/src/render/linkTile.ts
CHANGED
|
@@ -101,8 +101,8 @@ function rr(c: DrawCtx, x: number, y: number, w: number, h: number, r: number):
|
|
|
101
101
|
*/
|
|
102
102
|
function clipToBar(c: DrawCtx, u: number, bar: boolean): void {
|
|
103
103
|
// (far past the card every way but the one edge that counts, the bar's top: put where the shape starts, so it's
|
|
104
|
-
// exactly there however the rest rounds. The biggest card,
|
|
105
|
-
// the bar's units across:
|
|
104
|
+
// exactly there however the rest rounds. The biggest card the slider makes, 2400" at the closest zoom (400 px an
|
|
105
|
+
// inch), is 640,000 of the bar's units across: LINK_HARD_MAX_IN × ZOOM_MAX / BAR_SCALE.)
|
|
106
106
|
const far = 1e6, d = bar ? far : -far;
|
|
107
107
|
const draw = (cc: DrawCtx, X: number, Y: number) => {
|
|
108
108
|
cc.beginPath(); cc.moveTo(X - far, Y); cc.lineTo(X + far, Y); cc.lineTo(X + far, Y + d); cc.lineTo(X - far, Y + d); cc.closePath();
|