@reekon-tools/boldr-cad 1.4.0 → 1.6.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.
Files changed (311) hide show
  1. package/README.md +13 -3
  2. package/dist/app/edit.d.ts +3 -3
  3. package/dist/app/edit.js +26 -1
  4. package/dist/app/edit.js.map +1 -1
  5. package/dist/app/state.d.ts +6 -8
  6. package/dist/app/state.js +0 -1
  7. package/dist/app/state.js.map +1 -1
  8. package/dist/data/sync.d.ts +1 -1
  9. package/dist/data/sync.js +7 -2
  10. package/dist/data/sync.js.map +1 -1
  11. package/dist/editor/actions.d.ts +8 -0
  12. package/dist/editor/actions.js +255 -181
  13. package/dist/editor/actions.js.map +1 -1
  14. package/dist/editor/elevation.d.ts +4 -1
  15. package/dist/editor/elevation.js +16 -17
  16. package/dist/editor/elevation.js.map +1 -1
  17. package/dist/editor/gestures.d.ts +21 -0
  18. package/dist/editor/gestures.js +92 -14
  19. package/dist/editor/gestures.js.map +1 -1
  20. package/dist/editor/keys.js +4 -3
  21. package/dist/editor/keys.js.map +1 -1
  22. package/dist/editor/laser.d.ts +4 -2
  23. package/dist/editor/laser.js +4 -2
  24. package/dist/editor/laser.js.map +1 -1
  25. package/dist/editor/linkActions.d.ts +49 -12
  26. package/dist/editor/linkActions.js +164 -35
  27. package/dist/editor/linkActions.js.map +1 -1
  28. package/dist/editor/links.d.ts +13 -0
  29. package/dist/editor/links.js +7 -1
  30. package/dist/editor/links.js.map +1 -1
  31. package/dist/editor/mode.d.ts +2 -1
  32. package/dist/editor/mode.js +8 -5
  33. package/dist/editor/mode.js.map +1 -1
  34. package/dist/editor/project.js +1 -2
  35. package/dist/editor/project.js.map +1 -1
  36. package/dist/editor/scaleGate.d.ts +13 -0
  37. package/dist/editor/scaleGate.js +27 -0
  38. package/dist/editor/scaleGate.js.map +1 -0
  39. package/dist/editor/selection.js +13 -9
  40. package/dist/editor/selection.js.map +1 -1
  41. package/dist/editor/tooltips.js +10 -0
  42. package/dist/editor/tooltips.js.map +1 -1
  43. package/dist/editor/view3d.d.ts +4 -1
  44. package/dist/editor/view3d.js +6 -2
  45. package/dist/editor/view3d.js.map +1 -1
  46. package/dist/export/pdf.d.ts +5 -2
  47. package/dist/export/pdf.js +12 -8
  48. package/dist/export/pdf.js.map +1 -1
  49. package/dist/export/plan.d.ts +1 -1
  50. package/dist/export/plan.js +14 -9
  51. package/dist/export/plan.js.map +1 -1
  52. package/dist/index.d.ts +1 -0
  53. package/dist/index.js +1 -0
  54. package/dist/index.js.map +1 -1
  55. package/dist/model/constraints.js +2 -0
  56. package/dist/model/constraints.js.map +1 -1
  57. package/dist/model/demo.d.ts +1 -0
  58. package/dist/model/demo.js +2 -1
  59. package/dist/model/demo.js.map +1 -1
  60. package/dist/model/elevation.d.ts +1 -1
  61. package/dist/model/elevation.js +3 -3
  62. package/dist/model/elevation.js.map +1 -1
  63. package/dist/model/geom.d.ts +2 -0
  64. package/dist/model/geom.js +11 -0
  65. package/dist/model/geom.js.map +1 -1
  66. package/dist/model/history.js +4 -1
  67. package/dist/model/history.js.map +1 -1
  68. package/dist/model/links.d.ts +10 -2
  69. package/dist/model/links.js +15 -3
  70. package/dist/model/links.js.map +1 -1
  71. package/dist/model/measurement.d.ts +2 -2
  72. package/dist/model/measurement.js +3 -3
  73. package/dist/model/measurement.js.map +1 -1
  74. package/dist/model/openings.d.ts +10 -0
  75. package/dist/model/openings.js +18 -0
  76. package/dist/model/openings.js.map +1 -1
  77. package/dist/model/planGeom.d.ts +37 -2
  78. package/dist/model/planGeom.js +72 -9
  79. package/dist/model/planGeom.js.map +1 -1
  80. package/dist/model/project.js +5 -2
  81. package/dist/model/project.js.map +1 -1
  82. package/dist/model/rooms.d.ts +18 -5
  83. package/dist/model/rooms.js +178 -73
  84. package/dist/model/rooms.js.map +1 -1
  85. package/dist/model/scale.d.ts +30 -0
  86. package/dist/model/scale.js +123 -0
  87. package/dist/model/scale.js.map +1 -0
  88. package/dist/model/settings.d.ts +0 -1
  89. package/dist/model/settings.js +1 -1
  90. package/dist/model/settings.js.map +1 -1
  91. package/dist/model/sketch.d.ts +26 -2
  92. package/dist/model/sketch.js +77 -22
  93. package/dist/model/sketch.js.map +1 -1
  94. package/dist/model/stroke.js +2 -2
  95. package/dist/model/trim.d.ts +54 -0
  96. package/dist/model/trim.js +219 -0
  97. package/dist/model/trim.js.map +1 -0
  98. package/dist/model/types.d.ts +62 -9
  99. package/dist/react/BottomBar.d.ts +2 -1
  100. package/dist/react/BottomBar.js +144 -46
  101. package/dist/react/BottomBar.js.map +1 -1
  102. package/dist/react/CadEditor.js +18 -9
  103. package/dist/react/CadEditor.js.map +1 -1
  104. package/dist/react/Drawer.js +6 -4
  105. package/dist/react/Drawer.js.map +1 -1
  106. package/dist/react/Duck.js.map +1 -1
  107. package/dist/react/KeypadSheet.js.map +1 -1
  108. package/dist/react/MarkupPanel.js +1 -1
  109. package/dist/react/PlanCanvas.native.js +54 -7
  110. package/dist/react/PlanCanvas.native.js.map +1 -1
  111. package/dist/react/PlanCanvas.web.js +17 -5
  112. package/dist/react/PlanCanvas.web.js.map +1 -1
  113. package/dist/react/Popovers.js +14 -3
  114. package/dist/react/Popovers.js.map +1 -1
  115. package/dist/react/Rail.js +1 -1
  116. package/dist/react/ShapeMenu.js +3 -2
  117. package/dist/react/ShapeMenu.js.map +1 -1
  118. package/dist/react/Sheet.d.ts +2 -2
  119. package/dist/react/Sheet.js.map +1 -1
  120. package/dist/react/ToolTip.js +3 -2
  121. package/dist/react/ToolTip.js.map +1 -1
  122. package/dist/react/TopBar.js +4 -3
  123. package/dist/react/TopBar.js.map +1 -1
  124. package/dist/react/barScroll.d.ts +23 -0
  125. package/dist/react/barScroll.js +47 -0
  126. package/dist/react/barScroll.js.map +1 -0
  127. package/dist/react/corners.d.ts +6 -2
  128. package/dist/react/corners.js.map +1 -1
  129. package/dist/react/editorBox.d.ts +8 -0
  130. package/dist/react/editorBox.js +10 -0
  131. package/dist/react/editorBox.js.map +1 -0
  132. package/dist/react/host.d.ts +1 -1
  133. package/dist/react/host.js +1 -1
  134. package/dist/react/host.js.map +1 -1
  135. package/dist/react/motion.d.ts +1 -1
  136. package/dist/react/motion.js +1 -1
  137. package/dist/react/motion.js.map +1 -1
  138. package/dist/react/pageLock.native.d.ts +2 -0
  139. package/dist/react/pageLock.native.js +2 -0
  140. package/dist/react/pageLock.native.js.map +1 -1
  141. package/dist/react/pageLock.web.d.ts +6 -0
  142. package/dist/react/pageLock.web.js +12 -3
  143. package/dist/react/pageLock.web.js.map +1 -1
  144. package/dist/react/ports.js +8 -3
  145. package/dist/react/ports.js.map +1 -1
  146. package/dist/react/saving.d.ts +7 -1
  147. package/dist/react/saving.js +10 -2
  148. package/dist/react/saving.js.map +1 -1
  149. package/dist/react/store.d.ts +5 -2
  150. package/dist/react/store.js +4 -1
  151. package/dist/react/store.js.map +1 -1
  152. package/dist/render/draw.d.ts +21 -4
  153. package/dist/render/draw.js +203 -151
  154. package/dist/render/draw.js.map +1 -1
  155. package/dist/render/elevation.js +3 -3
  156. package/dist/render/elevation.js.map +1 -1
  157. package/dist/render/figmaIcons.d.ts +6 -0
  158. package/dist/render/figmaIcons.js +16 -1
  159. package/dist/render/figmaIcons.js.map +1 -1
  160. package/dist/render/hit.d.ts +8 -1
  161. package/dist/render/hit.js +23 -4
  162. package/dist/render/hit.js.map +1 -1
  163. package/dist/render/icons.js +27 -20
  164. package/dist/render/icons.js.map +1 -1
  165. package/dist/render/lens.d.ts +27 -0
  166. package/dist/render/lens.js +41 -0
  167. package/dist/render/lens.js.map +1 -0
  168. package/dist/render/linkTile.d.ts +20 -2
  169. package/dist/render/linkTile.js +476 -246
  170. package/dist/render/linkTile.js.map +1 -1
  171. package/dist/render/snap.d.ts +10 -1
  172. package/dist/render/snap.js +87 -15
  173. package/dist/render/snap.js.map +1 -1
  174. package/dist/render/svgPath.d.ts +29 -0
  175. package/dist/render/svgPath.js +114 -0
  176. package/dist/render/svgPath.js.map +1 -0
  177. package/dist/render/tileIcons.d.ts +18 -0
  178. package/dist/render/tileIcons.js +67 -0
  179. package/dist/render/tileIcons.js.map +1 -0
  180. package/dist/render/view.d.ts +18 -1
  181. package/dist/render/view.js +38 -6
  182. package/dist/render/view.js.map +1 -1
  183. package/dist/skia/SkiaDrawCtx.d.ts +8 -0
  184. package/dist/skia/SkiaDrawCtx.js +27 -5
  185. package/dist/skia/SkiaDrawCtx.js.map +1 -1
  186. package/dist/solver/equations.d.ts +6 -0
  187. package/dist/solver/equations.js +53 -22
  188. package/dist/solver/equations.js.map +1 -1
  189. package/dist/solver/gauss-newton.js +6 -1
  190. package/dist/solver/gauss-newton.js.map +1 -1
  191. package/dist/tools/annotate.d.ts +0 -2
  192. package/dist/tools/annotate.js +1 -22
  193. package/dist/tools/annotate.js.map +1 -1
  194. package/dist/tools/chamfer.js +4 -0
  195. package/dist/tools/chamfer.js.map +1 -1
  196. package/dist/tools/dim.d.ts +3 -3
  197. package/dist/tools/dim.js +26 -65
  198. package/dist/tools/dim.js.map +1 -1
  199. package/dist/tools/fillet.js +4 -0
  200. package/dist/tools/fillet.js.map +1 -1
  201. package/dist/tools/freehand.js +1 -4
  202. package/dist/tools/freehand.js.map +1 -1
  203. package/dist/tools/line.js +15 -11
  204. package/dist/tools/line.js.map +1 -1
  205. package/dist/tools/modify.d.ts +32 -4
  206. package/dist/tools/modify.js +253 -98
  207. package/dist/tools/modify.js.map +1 -1
  208. package/dist/tools/registry.d.ts +7 -0
  209. package/dist/tools/registry.js +14 -1
  210. package/dist/tools/registry.js.map +1 -1
  211. package/dist/tools/select.d.ts +30 -8
  212. package/dist/tools/select.js +165 -34
  213. package/dist/tools/select.js.map +1 -1
  214. package/dist/tools/shapes.d.ts +1 -1
  215. package/dist/tools/shapes.js +12 -5
  216. package/dist/tools/shapes.js.map +1 -1
  217. package/dist/view3d/build.js +9 -8
  218. package/dist/view3d/build.js.map +1 -1
  219. package/package.json +9 -9
  220. package/src/app/edit.ts +25 -1
  221. package/src/app/state.ts +6 -8
  222. package/src/data/sync.ts +7 -2
  223. package/src/editor/actions.ts +213 -122
  224. package/src/editor/elevation.ts +13 -16
  225. package/src/editor/gestures.ts +83 -13
  226. package/src/editor/keys.ts +3 -2
  227. package/src/editor/laser.ts +7 -4
  228. package/src/editor/linkActions.ts +169 -31
  229. package/src/editor/links.ts +17 -1
  230. package/src/editor/mode.ts +8 -5
  231. package/src/editor/project.ts +1 -2
  232. package/src/editor/scaleGate.ts +32 -0
  233. package/src/editor/selection.ts +13 -7
  234. package/src/editor/tooltips.ts +9 -0
  235. package/src/editor/view3d.ts +6 -2
  236. package/src/export/pdf.ts +7 -4
  237. package/src/export/plan.ts +14 -10
  238. package/src/index.ts +1 -0
  239. package/src/model/constraints.ts +1 -0
  240. package/src/model/demo.ts +2 -1
  241. package/src/model/elevation.ts +4 -4
  242. package/src/model/geom.ts +10 -0
  243. package/src/model/history.ts +4 -1
  244. package/src/model/links.ts +14 -3
  245. package/src/model/measurement.ts +3 -3
  246. package/src/model/openings.ts +18 -0
  247. package/src/model/planGeom.ts +70 -10
  248. package/src/model/project.ts +6 -2
  249. package/src/model/rooms.ts +151 -63
  250. package/src/model/scale.ts +107 -0
  251. package/src/model/settings.ts +1 -2
  252. package/src/model/sketch.ts +62 -11
  253. package/src/model/stroke.ts +2 -2
  254. package/src/model/trim.ts +188 -0
  255. package/src/model/types.ts +57 -9
  256. package/src/react/BottomBar.tsx +177 -52
  257. package/src/react/CadEditor.tsx +19 -9
  258. package/src/react/Drawer.tsx +17 -12
  259. package/src/react/Duck.tsx +3 -3
  260. package/src/react/KeypadSheet.tsx +2 -2
  261. package/src/react/MarkupPanel.tsx +1 -1
  262. package/src/react/PlanCanvas.native.tsx +60 -6
  263. package/src/react/PlanCanvas.web.tsx +17 -5
  264. package/src/react/Popovers.tsx +24 -9
  265. package/src/react/Rail.tsx +1 -1
  266. package/src/react/ShapeMenu.tsx +3 -2
  267. package/src/react/Sheet.tsx +3 -3
  268. package/src/react/ToolTip.tsx +3 -2
  269. package/src/react/TopBar.tsx +4 -3
  270. package/src/react/barScroll.ts +57 -0
  271. package/src/react/corners.ts +6 -3
  272. package/src/react/editorBox.ts +20 -0
  273. package/src/react/host.ts +1 -1
  274. package/src/react/motion.tsx +6 -6
  275. package/src/react/pageLock.native.ts +2 -0
  276. package/src/react/pageLock.web.ts +12 -3
  277. package/src/react/ports.ts +7 -2
  278. package/src/react/saving.ts +10 -2
  279. package/src/react/store.ts +5 -2
  280. package/src/render/draw.ts +169 -118
  281. package/src/render/elevation.ts +5 -4
  282. package/src/render/figmaIcons.ts +17 -1
  283. package/src/render/hit.ts +21 -4
  284. package/src/render/icons.ts +27 -20
  285. package/src/render/lens.ts +52 -0
  286. package/src/render/linkTile.ts +436 -190
  287. package/src/render/snap.ts +87 -17
  288. package/src/render/svgPath.ts +95 -0
  289. package/src/render/tileIcons.ts +75 -0
  290. package/src/render/view.ts +43 -7
  291. package/src/skia/SkiaDrawCtx.ts +26 -4
  292. package/src/solver/equations.ts +52 -22
  293. package/src/solver/gauss-newton.ts +4 -1
  294. package/src/styles.css +3 -2
  295. package/src/tools/annotate.ts +1 -18
  296. package/src/tools/chamfer.ts +3 -0
  297. package/src/tools/dim.ts +26 -52
  298. package/src/tools/fillet.ts +3 -0
  299. package/src/tools/freehand.ts +1 -3
  300. package/src/tools/line.ts +12 -11
  301. package/src/tools/modify.ts +210 -70
  302. package/src/tools/registry.ts +18 -1
  303. package/src/tools/select.ts +144 -36
  304. package/src/tools/shapes.ts +9 -4
  305. package/src/ui/ctx.ts +4 -3
  306. package/src/ui/drawer.ts +8 -2
  307. package/src/view3d/build.ts +11 -10
  308. package/dist/react/LaserTray.d.ts +0 -4
  309. package/dist/react/LaserTray.js +0 -26
  310. package/dist/react/LaserTray.js.map +0 -1
  311. package/src/react/LaserTray.tsx +0 -42
@@ -1,16 +1,16 @@
1
- import { dimEnds, dimRadius, edgeOf, gridSteps, openingFrame } from '../model/planGeom';
1
+ import { angleCorner, angleSweep, arcAngles, dimEnds, dimRadius, edgeOf, gridSteps, inSweep, openingFrame } from '../model/planGeom';
2
2
  import { imageById } from '../model/images';
3
3
  import { editNoteText } from '../editor/markup';
4
4
  import { afterEdit, resolveOpeningsNow, solveSketch, tryAddConstraint } from '../app/edit';
5
5
  import { ed, isSel, type BoxSel, type Hit, type Snap } from '../app/state';
6
- import { clamp, hyp, norm2, projT, segInter } from '../model/geom';
6
+ import { clamp, hyp, norm2, normAng, projT, segInter } from '../model/geom';
7
7
  import { dropHistory, pushHistory } from '../model/history';
8
8
  import { deep } from '../model/ids';
9
9
  import { settings } from '../model/settings';
10
10
  import { openingSpan, slideGroup, type SlideGroup } from '../model/openings';
11
- import { connectedGeometry, joinPoints, mergePoints, restorePos, snapshotPos } from '../model/sketch';
11
+ import { circleEdge, connectedGeometry, joinPoints, mergePoints, restorePos, snapshotPos } from '../model/sketch';
12
12
  import { planSK, replaceSK, SK } from '../model/store';
13
- import type { Note, SelItem, Sketch, Underlay, WallFace } from '../model/types';
13
+ import type { Note, SelItem, Sketch, Underlay, WallFace, XY } from '../model/types';
14
14
  import { cabOfPoint, cabPoints, faceEdit, openingOfPoint } from '../model/faces';
15
15
  import { pushedOut, syncFace, type Overflow } from '../model/facesolve';
16
16
  import { snapCabinetMove } from '../editor/face';
@@ -20,13 +20,26 @@ import { hitAny } from '../render/hit';
20
20
  import { onGrid, snap45, snapAt } from '../render/snap';
21
21
  import { linkExtent, mainT, NOTE_TEXT_IN, NOTE_TEXT_MAX_IN, NOTE_TEXT_MIN_IN, noteBox, noteTextBox, noteTextIn, paintPending, requestDraw, requestImageDraw, requestOverlayDraw, S, s2w, type HandlePart, underlayAt, underlayH, underlayLocal } from '../render/view';
22
22
  import { solver } from '../solver';
23
- import type { PEv } from './registry';
23
+ import { faceSnapCons, type PEv } from './registry';
24
24
  import { onSessionReset } from '../model/session';
25
25
  import { openDrawer, setCursor, toast, updateCtx, updateHint } from '../editor/ports';
26
26
  import { selectionHint } from '../editor/selection';
27
+ import { openImageLink } from '../editor/linkActions';
28
+
29
+ /**
30
+ * An arc the dragged point is an end of: its other end, which end the point is, how far round it goes (kept as it's
31
+ * dragged), and whether it's closed — dragged all the way round onto its other end (see closeArcs).
32
+ */
33
+ interface ArcEnd { id: string; other: string; end: 'a' | 'b'; sweep: number; closed: boolean }
34
+
35
+ /** Whether point `id` is a wall's (an end, or a curved one's centre): walls join along their centrelines, not onto faces. */
36
+ const wallPoint = (sk: Sketch, id: string): boolean =>
37
+ Object.values(sk.lines).some(l => l.kind === 'wall' && (l.a === id || l.b === id)) ||
38
+ Object.values(sk.arcs).some(a => a.kind === 'wall' && (a.a === id || a.b === id || a.c === id)) ||
39
+ Object.values(sk.circles).some(c => c.kind === 'wall' && c.c === id);
27
40
 
28
41
  type Drag =
29
- | { kind: 'point'; id: string; start: { x: number; y: number }; grab: { x: number; y: number }; snap: Snap | null }
42
+ | { kind: 'point'; id: string; start: { x: number; y: number }; grab: { x: number; y: number }; snap: Snap | null; arcs: ArcEnd[] }
30
43
  /** cab: dragging a cabinet (its box where it started): it snaps to corners, the floor, other cabinets */
31
44
  | { kind: 'multi'; ids: string[]; start: { x: number; y: number }[]; grab: { x: number; y: number }; cab?: { id: string; box: { u0: number; u1: number; z0: number; z1: number } }; via?: string; gst?: number; gx?: number; gy?: number }
32
45
  /** size a circle by its edge; grab: how far out from its centreline it was picked up (a wall's outer face, say) */
@@ -34,6 +47,8 @@ type Drag =
34
47
  | { kind: 'dimoff'; id: string }
35
48
  /** swing a diameter's line around its circle and move the label in/out */
36
49
  | { kind: 'diamlabel'; id: string }
50
+ /** pull an angle's label off its corner: out (its arc's radius) and round between its two lines */
51
+ | { kind: 'anglelabel'; id: string }
37
52
  /** slide a door/window dimension (width or a placed one) toward or away from its wall */
38
53
  | { kind: 'odimoff'; id: string; part: string }
39
54
  /** slide a door/window (or the free chain of openings it's locked into) along its wall; grab: s where it was picked up */
@@ -45,7 +60,7 @@ type Drag =
45
60
  /** several pieces of markup (and photos) selected, one of them dragged: they all move by as much */
46
61
  | { kind: 'group'; notes: { id: string; start: Note }[]; images: { id: string; start: { x: number; y: number } }[]; grab: { x: number; y: number } }
47
62
  | { kind: 'umove'; id: string; start: { x: number; y: number }; grab: { x: number; y: number } }
48
- | { kind: 'uresize'; id: string; part: HandlePart; start: { x: number; y: number; w: number; h: number } }
63
+ | { kind: 'uresize'; id: string; part: HandlePart; start: ImageBox }
49
64
  /** reshape markup: move an arrow end, or resize the box of a cloud / pen stroke */
50
65
  | { kind: 'nresize'; id: string; part: string; start: Note };
51
66
 
@@ -179,6 +194,8 @@ export const selectTool = {
179
194
  else if (st.dragging && ed.boxSel) { boxSelect(ed.boxSel, ev.shift); ed.boxSel = null; }
180
195
  else if (st.hit) {
181
196
  const h = st.hit, now = performance.now();
197
+ // an expanded photo's badge, tapped: open what it's for
198
+ if (h.type === 'underlay' && h.part === 'link') { this.st = {}; openImageLink(h.id); updateCtx(); requestDraw(); return; }
182
199
  // a cabinet's footprint in the plan: open its wall, the cabinet selected
183
200
  if (h.type === 'cabfoot') { const [key, cab] = h.id.split('#'); this.st = {}; openCabinet(key, cab); return; }
184
201
  // with a finger or pencil, tapping the selected line again selects everything joined to it (as a double tap does)
@@ -186,8 +203,10 @@ export const selectTool = {
186
203
  : st.down.touch && st.again ? h
187
204
  : doubleTapOf(st.down, h, now);
188
205
  const sk = SK();
189
- // a corner point stands for the lines meeting there
190
- const from = first?.type === 'point' ? Object.keys(sk.lines).filter(id => !sk.lines[id].anchor && (sk.lines[id].a === first.id || sk.lines[id].b === first.id)) : [];
206
+ // a corner point stands for the lines meeting there: its walls and lines, if it has any (a guide drawn off a
207
+ // shape's corner leaves the shape's), else its guides
208
+ const at = first?.type === 'point' ? Object.keys(sk.lines).filter(id => !sk.lines[id].anchor && (sk.lines[id].a === first.id || sk.lines[id].b === first.id)) : [];
209
+ const from = at.some(id => !sk.lines[id].constr) ? at.filter(id => !sk.lines[id].constr) : at;
191
210
  if (first && ((first.type === 'line' && !sk.lines[first.id]?.anchor) || first.type === 'arc' || from.length)) {
192
211
  // double tap a line or arc (or a point on one): select everything connected to it
193
212
  const g = connectedGeometry(sk, first.type === 'line' ? [first.id] : from, first.type === 'arc' ? [first.id] : []);
@@ -220,6 +239,8 @@ export const selectTool = {
220
239
  this.st = {};
221
240
  updateCtx(); updateHint(); requestDraw();
222
241
  },
242
+ /** (something being dragged: not a box drawn round things, nor a press that hasn't moved anything) */
243
+ magnify() { return !!this.st.drag; },
223
244
  hint() {
224
245
  if (ed.sel.length) return selectionHint();
225
246
  return ed.lastPointerTouch
@@ -355,7 +376,11 @@ function beginDrag(h: Hit, down: PEv): Drag | null {
355
376
  if (it.type === 'point') s.add(it.id);
356
377
  if (it.type === 'arc') addArc(it.id);
357
378
  if (it.type === 'circle') { const ci = sk.circles[it.id]; if (ci) s.add(ci.c); }
358
- if (it.type === 'room') { const r = sk.rooms[it.id]; if (r) r.loop.forEach(p => s.add(p)); }
379
+ if (it.type === 'room') {
380
+ const r = sk.rooms[it.id];
381
+ // (its corners — and the centre of a circle it runs round, which has none of its own)
382
+ if (r) { r.loop.forEach(p => s.add(p)); for (const e of r.edges ?? []) { const ce = circleEdge(e), ci = ce && sk.circles[ce.cid]; if (ci) s.add(ci.c); } }
383
+ }
359
384
  }
360
385
  } else {
361
386
  if (h.type === 'line') addL(h.id);
@@ -373,7 +398,7 @@ function beginDrag(h: Hit, down: PEv): Drag | null {
373
398
  if (p.fixed) { toast(p.origin ? 'The origin stays put. Lock or unlock other points from the bar below.' : p.anchor ? 'This corner is set by the plan — move the wall, door or window there.' : 'This point is locked. Unlock it to move it.', { warn: true }); return null; }
374
399
  // (one of several selected: the selection moves, as by one of its lines)
375
400
  if (several) return multi(ptsOf());
376
- return { kind: 'point', id: h.id, start: { x: p.x, y: p.y }, grab: { x: wx, y: wy }, snap: null };
401
+ return { kind: 'point', id: h.id, start: { x: p.x, y: p.y }, grab: { x: wx, y: wy }, snap: null, arcs: arcEnds(sk, h.id) };
377
402
  }
378
403
  if (h.type === 'cab') {
379
404
  // a cabinet moves as a whole (and the rest of the selection with it, when it's part of it)
@@ -403,7 +428,10 @@ function beginDrag(h: Hit, down: PEv): Drag | null {
403
428
  if (h.type === 'dim') {
404
429
  const c = sk.cons[h.id];
405
430
  if (c.type === 'diam') return { kind: 'diamlabel', id: h.id };
406
- if (c.type !== 'dist') return null;
431
+ if (c.type === 'angle') return { kind: 'anglelabel', id: h.id };
432
+ // (a distance between two parallel lines or walls slides along them: the user's call, 2026-10-24, when one made
433
+ // by selecting two walls across from each other wouldn't leave where it was first drawn)
434
+ if (c.type !== 'dist' && c.type !== 'pldist') return null;
407
435
  return { kind: 'dimoff', id: h.id };
408
436
  }
409
437
  if (h.type === 'opening') {
@@ -429,7 +457,7 @@ function beginDrag(h: Hit, down: PEv): Drag | null {
429
457
  if (!u) return null;
430
458
  if (u.locked) { toast('This image is locked. Tap Unlock in the bar below to move or resize it.', { warn: true }); return null; }
431
459
  if (h.type === 'underlay') return { kind: 'umove', id: u.id, start: { x: u.x, y: u.y }, grab: { x: wx, y: wy } };
432
- return { kind: 'uresize', id: u.id, part: h.part as HandlePart, start: { x: u.x, y: u.y, w: u.w, h: underlayH(u) } };
460
+ return { kind: 'uresize', id: u.id, part: h.part as HandlePart, start: { x: u.x, y: u.y, w: u.w, h: underlayH(u), crop: u.crop } };
433
461
  }
434
462
  return null;
435
463
  }
@@ -449,6 +477,41 @@ function groupDrag(sk: Sketch, h: Hit, wx: number, wy: number): Drag | null {
449
477
  /** How far things ran past their walls when each drag began: it may not go further. */
450
478
  const dragBase = new WeakMap<Drag, Overflow>();
451
479
 
480
+ /** The arcs a point is an end of (not their centre), each with how far round it goes now. */
481
+ function arcEnds(sk: Sketch, pid: string): ArcEnd[] {
482
+ const out: ArcEnd[] = [];
483
+ for (const id in sk.arcs) {
484
+ const a = sk.arcs[id];
485
+ if (a.a === a.b || a.c === pid || (a.a !== pid && a.b !== pid)) continue;
486
+ const g = arcAngles(sk, a);
487
+ out.push({ id, other: a.a === pid ? a.b : a.a, end: a.a === pid ? 'a' : 'b', sweep: g.full ? 2 * Math.PI : normAng(g.t1 - g.t0), closed: false });
488
+ }
489
+ return out;
490
+ }
491
+
492
+ /**
493
+ * An arc's end dragged all the way round onto its other end — or on past it — closes it (the user's call, 2026-10-29:
494
+ * "if u fully rotate it to reach around - it should create a circle"): it's held on the other end, drawn all the way
495
+ * round (arcAngles' `full`), and joined into a circle when it's let go (endDrag). Back the way it came, it opens again.
496
+ * Only from more than half way round: dragged back onto its start the short way, an arc shrinks — it isn't snapped onto
497
+ * its own other end, which would close it. `s` is where the end would go otherwise, `raw` the pointer; returns where it goes.
498
+ */
499
+ function closeArcs(sk: Sketch, arcs: ArcEnd[], s: Snap, raw: XY, tol: number): Snap {
500
+ for (const t of arcs) {
501
+ const a = sk.arcs[t.id], o = a && sk.points[a.c], q = a && sk.points[t.other];
502
+ if (!a || !o || !q) continue;
503
+ // how far round it would go with the end at the pointer (from its other end, the way it runs: counter-clockwise a → b)
504
+ const th = Math.atan2(raw.y - o.y, raw.x - o.x), tq = Math.atan2(q.y - o.y, q.x - o.x);
505
+ const sweep = t.end === 'b' ? normAng(th - tq) : normAng(tq - th), near = hyp(raw.x - q.x, raw.y - q.y) <= tol;
506
+ if (t.closed) { if (sweep > 1.5 * Math.PI && !near) t.closed = false; }
507
+ else if ((near && t.sweep > Math.PI) || (t.sweep > 1.5 * Math.PI && sweep < 0.5 * Math.PI)) t.closed = true;
508
+ if (t.closed) return { x: q.x, y: q.y, kind: 'point', ref: t.other, label: 'Endpoint', guides: [] };
509
+ t.sweep = sweep;
510
+ if (s.kind === 'point' && s.ref === t.other) return { x: raw.x, y: raw.y, kind: 'free', ref: null, guides: [] };
511
+ }
512
+ return s;
513
+ }
514
+
452
515
  function dragTo(d: Drag, ev: PEv): void {
453
516
  const sk = SK();
454
517
  const [wx, wy] = s2w(ev.sx, ev.sy);
@@ -482,16 +545,22 @@ function dragTo(d: Drag, ev: PEv): void {
482
545
  // (not a line already held level or plumb: its direction can't change)
483
546
  const squared = (l: { a: string; b: string }) => Object.values(sk.cons).some(c => (c.type === 'h' || c.type === 'v') && ((c.a === l.a && c.b === l.b) || (c.a === l.b && c.b === l.a)));
484
547
  const ends = ev.shift ? Object.values(sk.lines).filter(l => !l.anchor && (l.a === d.id || l.b === d.id) && !squared(l)).map(l => sk.points[l.a === d.id ? l.b : l.a]) : [];
548
+ let locked = false;
485
549
  if (ends.length) {
486
550
  const q = ends.map(o => snap45(o, { x: wx, y: wy })).reduce((m, c) => (hyp(c.x - wx, c.y - wy) < hyp(m.x - wx, m.y - wy) ? c : m));
487
551
  // where the drawing can't take it there (other constraints), it's an ordinary drag — never stuck
488
- if (go([d.id], [{ x: q.x, y: q.y }])) { d.snap = null; ed.snapState = null; return; }
489
- restoreFit(sk, held!);
552
+ locked = go([d.id], [{ x: q.x, y: q.y }]);
553
+ if (locked) { d.snap = null; ed.snapState = null; } else restoreFit(sk, held!);
554
+ }
555
+ // (either way on to what every step of a drag does below — its doors and windows, and drawing it again: returning
556
+ // here left a Shift-drag frozen on the screen until the pointer lifted)
557
+ if (!locked) {
558
+ // (an arc's end, round onto its other end: closed — see closeArcs)
559
+ const s = closeArcs(sk, d.arcs, snapAt(ev.sx, ev.sy, { exclude: new Set([d.id]), touch: ev.touch, faces: !wallPoint(sk, d.id) }), { x: wx, y: wy }, (ev.touch ? 16 : 10) / mainT().s);
560
+ d.snap = s.kind === 'point' || s.kind === 'mid' || s.kind === 'online' || s.kind === 'oncircle' || s.kind === 'onface' || s.kind === 'facecorner' ? s : null;
561
+ ed.snapState = d.snap ? s : null;
562
+ go([d.id], [{ x: s.x, y: s.y }]);
490
563
  }
491
- const s = snapAt(ev.sx, ev.sy, { exclude: new Set([d.id]), touch: ev.touch });
492
- d.snap = s.kind === 'point' || s.kind === 'mid' || s.kind === 'online' || s.kind === 'oncircle' ? s : null;
493
- ed.snapState = d.snap ? s : null;
494
- go([d.id], [{ x: s.x, y: s.y }]);
495
564
  } else if (d.kind === 'multi') {
496
565
  let mx = wx - d.grab.x, my = wy - d.grab.y;
497
566
  // Shift: moved level, plumb or 45° only
@@ -529,10 +598,20 @@ function dragTo(d: Drag, ev: PEv): void {
529
598
  c.ang = Math.atan2(wy - g.o.y, wx - g.o.x);
530
599
  c.off = Math.max(0, hyp(wx - g.o.x, wy - g.o.y) - g.r - 40 / mainT().s);
531
600
  }
601
+ } else if (d.kind === 'anglelabel') {
602
+ // (where the label's dragged: as far out from its corner, and round it as far as its two lines; never into it)
603
+ const c = sk.cons[d.id], g = angleCorner(sk, c);
604
+ if (g) {
605
+ const a = Math.atan2(wy - g.vtx.y, wx - g.vtx.x);
606
+ c.off = Math.max(24 / mainT().s, hyp(wx - g.vtx.x, wy - g.vtx.y));
607
+ c.ang = g.u1 && g.u2 ? (({ t1, sweep }) => inSweep(a, t1, sweep))(angleSweep(g.u1, g.u2)) : a;
608
+ }
532
609
  } else if (d.kind === 'dimoff') {
533
- // (off the line it's drawn from: a wall's face, for a length measured on one)
534
- const c = sk.cons[d.id], e = dimEnds(sk, c), a = e ? e.a : sk.points[c.a!], b = e ? e.b : sk.points[c.b!];
535
- const n = norm2(-(b.y - a.y), b.x - a.x);
610
+ // (off the span it measures: a line, a wall's face for a length measured on one — or, for a distance between
611
+ // parallel lines or walls, along them)
612
+ const c = sk.cons[d.id], e = dimEnds(sk, c) ?? (c.a && c.b ? { a: sk.points[c.a], b: sk.points[c.b] } : null);
613
+ if (!e) return;
614
+ const { a, b } = e, n = norm2(-(b.y - a.y), b.x - a.x);
536
615
  c.off = (wx - (a.x + b.x) / 2) * n[0] + (wy - (a.y + b.y) / 2) * n[1];
537
616
  } else if (d.kind === 'wopening') {
538
617
  // a locked door won't move: say so once, then nothing
@@ -578,7 +657,7 @@ function dragTo(d: Drag, ev: PEv): void {
578
657
  if (n) n.leader = [s.x, s.y];
579
658
  } else reshapeNote(d.id, d.part, d.start, wx, wy);
580
659
  } else if (d.kind === 'uresize') {
581
- resizeUnderlay(d.id, d.part, d.start, wx, wy, ev.shift);
660
+ resizeUnderlay(d.id, d.part, d.start, wx, wy);
582
661
  }
583
662
  resolveOpeningsNow();
584
663
  // on a wall face, a door or window tied to what's dragged (a dimension to a cabinet) moves on the face as it's
@@ -594,7 +673,17 @@ function endDrag(d: Drag): void {
594
673
  const sk = SK();
595
674
  ed.snapState = null;
596
675
  if (d.kind === 'wopening' && !d.drag.started) dropHistory(); // it didn't move
597
- if (d.kind === 'point' && d.snap && settings.autoCons) {
676
+ // an arc dragged all the way round onto its start: its ends joined, it's a circle (gc: closeArc). It's what the drag
677
+ // was, so whether or not auto-constrain is on
678
+ const closed = d.kind === 'point' ? d.arcs.find(t => t.closed) : undefined;
679
+ if (closed && d.kind === 'point') {
680
+ const was = JSON.stringify(sk);
681
+ if (mergePoints(sk, closed.other, d.id)) {
682
+ const r = solveSketch();
683
+ if (!r.ok) { replaceSK(JSON.parse(was) as Sketch); toast('Can’t close that arc — it conflicts with other constraints.', { warn: true }); }
684
+ else { ed.sel = sk.circles[closed.id] ? [{ type: 'circle', id: closed.id }] : []; toast('Closed into a circle'); }
685
+ }
686
+ } else if (d.kind === 'point' && d.snap && settings.autoCons) {
598
687
  const s = d.snap;
599
688
  if (s.kind === 'point') {
600
689
  const snap = JSON.stringify(sk);
@@ -606,6 +695,7 @@ function endDrag(d: Drag): void {
606
695
  } else if (s.kind === 'mid') tryAddConstraint({ type: sk.lines[s.ref!]?.anchor ? 'online' : 'mid', p: d.id, l: s.ref! }, { silent: !!sk.lines[s.ref!]?.anchor }); // (on a wall face's own edge: on it, free to slide)
607
696
  else if (s.kind === 'online') tryAddConstraint({ type: 'online', p: d.id, l: s.ref! }, { silent: true });
608
697
  else if (s.kind === 'oncircle') tryAddConstraint({ type: 'oncircle', p: d.id, c: s.ref! }, { silent: true });
698
+ else for (const c of faceSnapCons(s, d.id)) tryAddConstraint(c, { silent: true });
609
699
  }
610
700
  if (d.kind === 'point') {
611
701
  const p = SK().points[d.id];
@@ -638,11 +728,22 @@ function joinDropped(via: string): void {
638
728
  afterEdit();
639
729
  }
640
730
 
731
+ /** An image's box as a drag on it began (h as it's drawn, its own or from its picture), and its crop then. */
732
+ interface ImageBox { x: number; y: number; w: number; h: number; crop?: Underlay['crop'] }
733
+
734
+ /** A crop as it's kept: a side trimmed by next to nothing isn't, and nothing trimmed is no crop at all. */
735
+ function tidyCrop(k: NonNullable<Underlay['crop']>): Underlay['crop'] {
736
+ const v = (n: number) => (n < 1e-6 ? 0 : n), out = { l: v(k.l), t: v(k.t), r: v(k.r), b: v(k.b) };
737
+ return out.l || out.t || out.r || out.b ? out : undefined;
738
+ }
739
+
641
740
  /**
642
- * Resize the image underlay from a handle. Corners scale proportionally about the opposite corner
643
- * (hold Shift for a free corner); side handles stretch one direction about the opposite side.
741
+ * Resize an image from a handle. A corner scales it, its shape kept, about the opposite corner; a side crops it — the
742
+ * side follows the pointer, in to a sliver short of the other side, out as far as the picture's own edge. Never
743
+ * stretched (the user's call, 2026-11-03: "get rid of stretch - make the side bars crop"): a plan stretched would have
744
+ * one scale across and another down.
644
745
  */
645
- function resizeUnderlay(id: string, part: HandlePart, s0: { x: number; y: number; w: number; h: number }, ptx: number, pty: number, free: boolean): void {
746
+ function resizeUnderlay(id: string, part: HandlePart, s0: ImageBox, ptx: number, pty: number): void {
646
747
  const u = imageById(id), min = 8 / mainT().s;
647
748
  if (!u) return;
648
749
  // worked in the image's own frame (from its middle as the drag began, unturned), so a turned image resizes along its
@@ -650,25 +751,32 @@ function resizeUnderlay(id: string, part: HandlePart, s0: { x: number; y: number
650
751
  const was: Underlay = { ...u, x: s0.x, y: s0.y, w: s0.w, h: s0.h }, { x: wx, y: wy } = underlayLocal(was, ptx, pty);
651
752
  const left = -s0.w / 2, right = s0.w / 2, top = s0.h / 2, bottom = -s0.h / 2;
652
753
  const W = part.includes('w'), E = part.includes('e'), N = part.includes('n'), Sth = part.includes('s');
653
- let w = s0.w, h = s0.h;
654
- if (part.length === 2 && !free) {
655
- // proportional: project the pointer onto the diagonal from the fixed corner
754
+ let L = left, R = right, Tp = top, B = bottom, crop = s0.crop;
755
+ if (part.length === 2) {
756
+ // a corner: project the pointer onto the diagonal from the fixed corner
656
757
  const ax = W ? right : left, ay = N ? bottom : top;
657
758
  const cx = W ? left : right, cy = N ? top : bottom;
658
759
  const dx = cx - ax, dy = cy - ay;
659
760
  const f = Math.max(min / Math.min(s0.w, s0.h), ((wx - ax) * dx + (wy - ay) * dy) / (dx * dx + dy * dy));
660
- w = s0.w * f; h = s0.h * f;
761
+ const w = s0.w * f, h = s0.h * f;
762
+ if (W) L = right - w; else R = left + w;
763
+ if (N) Tp = bottom + h; else B = top - h;
661
764
  } else {
662
- if (E) w = Math.max(min, wx - left);
663
- if (W) w = Math.max(min, right - wx);
664
- if (N) h = Math.max(min, wy - bottom);
665
- if (Sth) h = Math.max(min, top - wy);
765
+ // a side: where the picture's own edges are, in this frame (past the crop), as far out as it can go
766
+ const k = s0.crop ?? { l: 0, t: 0, r: 0, b: 0 }, fw = s0.w / (1 - k.l - k.r), fh = s0.h / (1 - k.t - k.b);
767
+ const fl = left - k.l * fw, fr = right + k.r * fw, ft = top + k.t * fh, fb = bottom - k.b * fh;
768
+ if (E) R = clamp(wx, left + min, fr);
769
+ if (W) L = clamp(wx, fl, right - min);
770
+ if (N) Tp = clamp(wy, bottom + min, ft);
771
+ if (Sth) B = clamp(wy, fb, top - min);
772
+ crop = tidyCrop({ l: (L - fl) / fw, r: (fr - R) / fw, t: (ft - Tp) / fh, b: (B - fb) / fh });
666
773
  }
667
- const mid = underlayAt(was, (W ? right - w : left) + w / 2, (N ? bottom + h : top) - h / 2);
774
+ const w = R - L, h = Tp - B, mid = underlayAt(was, (L + R) / 2, (Tp + B) / 2);
668
775
  u.w = w;
669
776
  u.h = h;
670
777
  u.x = mid.x - w / 2;
671
778
  u.y = mid.y + h / 2;
779
+ if (crop) u.crop = crop; else delete u.crop;
672
780
  }
673
781
 
674
782
  /**
@@ -15,6 +15,7 @@ import { mainT, requestDraw, requestOverlayDraw, S } from '../render/view';
15
15
  import { fmtLen } from '../units';
16
16
  import { anchorMark, applyPending, commitPoint, lengthPreview, PT, rememberHover, wallBand, type PEv } from './registry';
17
17
  import { toast, updateHint } from '../editor/ports';
18
+ import { noScaleYet } from '../editor/scaleGate';
18
19
  import { wallBounds } from '../editor/elevation';
19
20
  import { drawsWalls } from '../editor/mode';
20
21
  import { splitWallsAtEnds } from './modify';
@@ -93,13 +94,15 @@ export const rectTool = {
93
94
  // (a wall corner placed partway along another wall splits that one there)
94
95
  if (wall) for (const id of sides) splitWallsAtEnds(sk, id);
95
96
  applyPending(a.cons); applyPending(c.cons);
96
- for (const k of [{ type: 'h' as const, a: a.id, b }, { type: 'v' as const, a: b, b: c.id }, { type: 'h' as const, a: d, b: c.id }, { type: 'v' as const, a: a.id, b: d }]) tryAddConstraint(k, { silent: true });
97
+ // its sides held level and plumb only with auto-constrain on, as any drawing's are (the user's call, 2026-10-26:
98
+ // "if auto constraint is disabled - it should not work on squares either"); off, it's four lines like any others
99
+ if (settings.autoCons) for (const k of [{ type: 'h' as const, a: a.id, b }, { type: 'v' as const, a: b, b: c.id }, { type: 'h' as const, a: d, b: c.id }, { type: 'v' as const, a: a.id, b: d }]) tryAddConstraint(k, { silent: true });
97
100
  this.reset();
98
101
  // (drawn, not selected: nothing new is highlighted — tap it to select it)
99
102
  ed.sel = [];
100
103
  afterEdit();
101
104
  },
102
- hint() { return this.st.p1 ? 'Tap the opposite corner.' : 'Tap or drag two opposite corners. Edges stay square.'; },
105
+ hint() { return this.st.p1 ? 'Tap the opposite corner.' : 'Tap or drag two opposite corners.' + (settings.autoCons ? ' Edges stay square.' : ''); },
103
106
  };
104
107
 
105
108
  export const circleTool = {
@@ -128,7 +131,8 @@ export const circleTool = {
128
131
  c.restore();
129
132
  // centre marker: crosshair + dot, always visible
130
133
  anchorMark(c, x, y);
131
- chip(c, 'Ø ' + fmtLen(2 * r), x, y - r * T.s - 16, { bg: '#fff', fg: '#0066FF', border: ['#0066FF', 1.5] });
134
+ // (its diameter once the drawing has its scale: before, only a placeholder)
135
+ if (!noScaleYet()) chip(c, 'Ø ' + fmtLen(2 * r), x, y - r * T.s - 16, { bg: '#fff', fg: '#0066FF', border: ['#0066FF', 1.5] });
132
136
  };
133
137
  } else ed.preview = null;
134
138
  requestOverlayDraw();
@@ -151,7 +155,8 @@ export const circleTool = {
151
155
  applyPending(cp.cons);
152
156
  const id = uid('ci');
153
157
  SK().circles[id] = { c: cp.id, r, ...asDrawn() };
154
- if (s.kind === 'point') tryAddConstraint({ type: 'oncircle', p: s.ref!, c: id }, { silent: true });
158
+ // (its edge on a point: held there with auto-constrain on, as a snap is when drawing)
159
+ if (s.kind === 'point' && settings.autoCons) tryAddConstraint({ type: 'oncircle', p: s.ref!, c: id }, { silent: true });
155
160
  this.reset();
156
161
  ed.sel = [];
157
162
  afterEdit();
package/src/ui/ctx.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ed } from '../app/state';
2
2
  import { markupTarget } from '../editor/markup';
3
- import { applyCtxAction, barItems, deleteSelection, plusAction, plusLabel, plusVisible } from '../editor/actions';
3
+ import { applyCtxAction, barItems, deleteSelection, iconAlone, plusAction, plusLabel, plusVisible } from '../editor/actions';
4
4
  import { selInfo, selectionHint } from '../editor/selection';
5
5
  import { $ } from './dom';
6
6
  import { icon } from './icons';
@@ -16,10 +16,11 @@ export function updateCtx(): void {
16
16
  if (it === 'sep') { const d = document.createElement('div'); d.className = 'sep'; box.appendChild(d); continue; }
17
17
  if ('lbl' in it) { const d = document.createElement('div'); d.className = 'lbl'; d.textContent = it.lbl; box.appendChild(d); continue; }
18
18
  const b = document.createElement('button');
19
- b.className = 'cb' + (it.on ? ' on' : '') + (it.locked ? ' locked' : '');
19
+ b.className = 'cb' + (it.on ? ' on' : '') + (it.locked ? ' locked' : '') + (iconAlone(it) ? ' lead' : '');
20
+ // (the bar's lead — Lock, or Open — and Lock wherever it is: its icon alone, its name its label for a screen reader)
20
21
  b.innerHTML = (it.ic === 'color'
21
22
  ? `<svg width="24" height="24" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="8" fill="${markupTarget().color}" stroke="#fff" stroke-width="2"/></svg>`
22
- : icon(it.ic)) + '<span>' + it.label + '</span>';
23
+ : icon(it.ic)) + (iconAlone(it) ? '' : '<span>' + it.label + '</span>');
23
24
  b.setAttribute('aria-label', it.label);
24
25
  if (it.on != null) b.setAttribute('aria-pressed', String(!!it.on));
25
26
  if (it.locked != null) b.setAttribute('aria-pressed', String(it.locked));
package/src/ui/drawer.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { addPage, deletePage, deletePending, duplicatePage, focusSpace, renamePage, renameProject, renameSpace, spaceSchedule, switchPage as switchPageIn } from '../editor/project';
2
2
  import { allPages, page, store } from '../model/store';
3
+ import { noScaleYet } from '../editor/scaleGate';
3
4
  import { drawThumb } from '../render/draw';
4
5
  import { fmtArea, fmtLen } from '../units';
5
6
  import { $, esc } from './dom';
@@ -57,11 +58,16 @@ export function renderDrawer(): void {
57
58
  } else {
58
59
  const sched = spaceSchedule(), total = sched.total;
59
60
  if (!sched.rows.length) { body.innerHTML = '<p class="empty">No spaces on this page yet. Close a loop of walls or lines, or pick the Space tool and tap inside a closed shape.</p>'; return; }
61
+ // (a sketch's sizes are placeholders until its first length: no areas until then)
62
+ const sketchOnly = noScaleYet();
60
63
  let h = '';
61
64
  for (const r of sched.rows) {
62
- h += `<div class="roomrow"><input class="field" data-room="${r.id}" value="${esc(r.name)}" aria-label="Space name"><div class="nums"><span><b>${fmtArea(r.area)}</b> floor</span><span><b>${fmtLen(r.per)}</b> perimeter</span></div></div>`;
65
+ const nums = sketchOnly ? '' : `<div class="nums"><span><b>${fmtArea(r.area)}</b> floor</span><span><b>${fmtLen(r.per)}</b> perimeter</span></div>`;
66
+ h += `<div class="roomrow"><input class="field" data-room="${r.id}" value="${esc(r.name)}" aria-label="Space name">${nums}</div>`;
63
67
  }
64
- h += `<div class="row"><div><b>Total</b><small>Measured to inside wall faces</small></div><b>${fmtArea(total)}</b></div>`;
68
+ h += sketchOnly
69
+ ? '<p class="empty">Areas show once the drawing has a length. Select a line and tap + to enter one.</p>'
70
+ : `<div class="row"><div><b>Total</b><small>Measured to inside wall faces</small></div><b>${fmtArea(total)}</b></div>`;
65
71
  body.innerHTML = h;
66
72
  body.querySelectorAll<HTMLInputElement>('[data-room]').forEach(i => {
67
73
  i.onchange = () => renameSpace(i.dataset.room!, i.value);
@@ -2,12 +2,12 @@ import { openingHeights, toU, wallHeight } from '../model/elevation';
2
2
  import { faceKeyParts } from '../model/faces';
3
3
  import { faceFrame, UPPER_Z } from '../model/facesolve';
4
4
  import { hyp, normAng } from '../model/geom';
5
- import { edgeS, openingSpan } from '../model/openings';
5
+ import { edgeS, hingeEdge, openingSpan } from '../model/openings';
6
6
  import { curveFrame, wallThick } from '../model/planGeom';
7
7
  import { roomGeom } from '../model/rooms';
8
8
  import { settings } from '../model/settings';
9
9
  import { roomValid, withLineIndex } from '../model/sketch';
10
- import type { Opening, Sketch, XY } from '../model/types';
10
+ import type { Opening, OpeningEdge, Sketch, XY } from '../model/types';
11
11
  import { wallPieces } from '../model/wallshape';
12
12
  import { boxLines, cellLines, mergeIv, raiseIn, type Cell3 } from './lines';
13
13
  import { PartBuilder, type Mat3, type Part3, type V3 } from './mesh';
@@ -59,7 +59,7 @@ export function inFront(cut: Cut3, m: XY, n: XY): boolean {
59
59
 
60
60
  interface Wall3 { id: string; A: XY; B: XY; u: XY; L: number; t: number; h: number; full: number }
61
61
 
62
- interface Opening3 { id: string; type: Opening['type']; s0: number; s1: number; sill: number; head: number; flip: boolean }
62
+ interface Opening3 { id: string; type: Opening['type']; s0: number; s1: number; sill: number; head: number; flip: boolean; hinge: OpeningEdge }
63
63
 
64
64
  /** The plan's straight walls, each at its height (cut down when it's in front of a cutaway). */
65
65
  function straightWalls(sk: Sketch, cut: Cut3 | null, lowered: string[]): Map<string, Wall3> {
@@ -150,7 +150,7 @@ function openingsIn(sk: Sketch, w: Wall3, mine: [string, Opening][]): Opening3[]
150
150
  const s0 = Math.max(0, Math.min(a, b)), s1 = Math.min(w.L, Math.max(a, b));
151
151
  if (s1 - s0 < 0.01) continue;
152
152
  const { sill, head } = openingHeights(o);
153
- out.push({ id, type: o.type, s0, s1, sill: Math.min(sill, w.h), head: Math.min(head, w.h), flip: !!o.flip });
153
+ out.push({ id, type: o.type, s0, s1, sill: Math.min(sill, w.h), head: Math.min(head, w.h), flip: !!o.flip, hinge: hingeEdge(o) });
154
154
  }
155
155
  return out.sort((p, q) => p.s0 - q.s0);
156
156
  }
@@ -243,8 +243,8 @@ const FRAME = 0.75, CASING = 2.5, CASING_OUT = 0.625, LEAF = 1.375, OPEN = (30 *
243
243
 
244
244
  /**
245
245
  * A door, so it reads as one: the floor run on through the doorway, a frame lining its sides and head, casings round
246
- * it on both faces (as high as the wall goes), and its leaf — hinged at its first side on the face it swings to, as the
247
- * plan draws it, and open a little. Its outlines go on `lines`.
246
+ * it on both faces (as high as the wall goes), and its leaf — hung on its hinge's jamb (Opening.hinge) on the face it
247
+ * swings to, as the plan draws it, and open a little. Its outlines go on `lines`.
248
248
  */
249
249
  function doorPart(w: Wall3, o: Opening3, lines: number[]): PartBuilder {
250
250
  const b = new PartBuilder('opening', o.id), half = w.t / 2, head = Math.min(o.head, w.h), nx = -w.u.y, ny = w.u.x;
@@ -267,12 +267,13 @@ function doorPart(w: Wall3, o: Opening3, lines: number[]): PartBuilder {
267
267
  box(rect(o.s1, o.s1 + CASING, k0, k1), 0, top, 'frame');
268
268
  box(rect(o.s0, o.s1, k0, k1), head, top, 'frame');
269
269
  }
270
- const f = o.flip ? -1 : 1, W = o.s1 - o.s0 - 2 * FRAME, H = head - FRAME - 0.5;
270
+ const f = o.flip ? -1 : 1, m = o.hinge === 's1' ? -1 : 1, W = o.s1 - o.s0 - 2 * FRAME, H = head - FRAME - 0.5;
271
271
  if (W > 2 && H > 2) {
272
- // (turned about its hinge, at the frame on the face it swings to, toward that face)
273
- const hs = o.s0 + FRAME, hk = f * half, c = Math.cos(f * OPEN), sn = Math.sin(f * OPEN);
272
+ // (turned about its hinge, at the frame on the face it swings to, toward that face; it runs from its hinge's jamb
273
+ // to the other: along the wall, or back along it, `m`)
274
+ const hs = m > 0 ? o.s0 + FRAME : o.s1 - FRAME, hk = f * half, c = Math.cos(m * f * OPEN), sn = Math.sin(m * f * OPEN);
274
275
  const R = (s: number, k: number): XY => P(hs + (s - hs) * c - (k - hk) * sn, hk + (s - hs) * sn + (k - hk) * c);
275
- box([R(hs, hk), R(hs + W, hk), R(hs + W, hk - f * LEAF), R(hs, hk - f * LEAF)], 0.5, 0.5 + H, 'door');
276
+ box([R(hs, hk), R(hs + m * W, hk), R(hs + m * W, hk - f * LEAF), R(hs, hk - f * LEAF)], 0.5, 0.5 + H, 'door');
276
277
  }
277
278
  return b;
278
279
  }
@@ -1,4 +0,0 @@
1
- /** Readings that arrived with nothing to go to: tap one to put it on the selected line. */
2
- export declare function LaserTray({ phone }: {
3
- phone: boolean;
4
- }): import("react").JSX.Element | null;
@@ -1,26 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Text, View } from 'react-native';
3
- import { laser, useTrayReading } from '../editor/laser';
4
- import { fmtLen } from '../units';
5
- import { notify, useEditorKey } from './store';
6
- import { C, FONT, shadow } from './theme';
7
- import { Tap } from './motion';
8
- import { createSheet } from './corners';
9
- /** Readings that arrived with nothing to go to: tap one to put it on the selected line. */
10
- export function LaserTray({ phone }) {
11
- useEditorKey(() => (laser.on ? [laser.external, ...laser.readings.map(r => r.id + ':' + fmtLen(r.v))].join('|') : ''));
12
- if (!laser.on)
13
- return null;
14
- return (_jsxs(View, { style: [s.tray, phone ? { left: 12, bottom: 160 } : { left: 90, bottom: 92 }], testID: "tray", children: [_jsxs(View, { style: s.head, children: [_jsx(Text, { style: s.title, children: "Laser readings" }), !laser.external && _jsx(Tap, { accessibilityRole: "button", onPress: () => { laser.on = false; laser.readings = []; notify(); }, children: _jsx(Text, { style: s.link, children: "Disconnect" }) })] }), laser.readings.length ? (_jsx(View, { style: s.chips, children: laser.readings.map(r => (_jsx(Tap, { accessibilityRole: "button", accessibilityLabel: 'Reading ' + fmtLen(r.v) + '. Tap to put it on the selected line.', onPress: () => useTrayReading(r.id), style: s.chip, children: _jsx(Text, { style: s.chipText, children: fmtLen(r.v) }) }, r.id))) })) : _jsx(Text, { style: s.help, children: "Select a wall and take a reading, or tap a reading here to put it on the selected line." })] }));
15
- }
16
- const s = createSheet({
17
- tray: { position: 'absolute', zIndex: 23, backgroundColor: C.g1, borderRadius: 15, padding: 10, width: 250, ...shadow },
18
- head: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', marginBottom: 8 },
19
- title: { fontFamily: FONT, fontSize: 13, fontWeight: '600', color: C.lg2 },
20
- link: { fontFamily: FONT, fontSize: 12, fontWeight: '600', color: C.lblue, padding: 4 },
21
- chips: { flexDirection: 'row', flexWrap: 'wrap', gap: 6 },
22
- chip: { height: 38, paddingHorizontal: 12, borderRadius: 8, backgroundColor: C.blue, justifyContent: 'center' },
23
- chipText: { fontFamily: FONT, fontSize: 15, fontWeight: '600', color: '#fff' },
24
- help: { fontFamily: FONT, fontSize: 12, color: C.g4, lineHeight: 16 },
25
- });
26
- //# sourceMappingURL=LaserTray.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LaserTray.js","sourceRoot":"","sources":["../../src/react/LaserTray.tsx"],"names":[],"mappings":"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"}
@@ -1,42 +0,0 @@
1
- import { Text, View } from 'react-native';
2
- import { laser, useTrayReading } from '../editor/laser';
3
- import { fmtLen } from '../units';
4
- import { notify, useEditorKey } from './store';
5
- import { C, FONT, shadow } from './theme';
6
- import { Tap } from './motion';
7
- import { createSheet } from './corners';
8
-
9
- /** Readings that arrived with nothing to go to: tap one to put it on the selected line. */
10
- export function LaserTray({ phone }: { phone: boolean }) {
11
- useEditorKey(() => (laser.on ? [laser.external, ...laser.readings.map(r => r.id + ':' + fmtLen(r.v))].join('|') : ''));
12
- if (!laser.on) return null;
13
- return (
14
- // (beside the rail on a tablet or computer, where the rail runs to the bottom of the screen)
15
- <View style={[s.tray, phone ? { left: 12, bottom: 160 } : { left: 90, bottom: 92 }]} testID="tray">
16
- <View style={s.head}>
17
- <Text style={s.title}>Laser readings</Text>
18
- {!laser.external && <Tap accessibilityRole="button" onPress={() => { laser.on = false; laser.readings = []; notify(); }}><Text style={s.link}>Disconnect</Text></Tap>}
19
- </View>
20
- {laser.readings.length ? (
21
- <View style={s.chips}>
22
- {laser.readings.map(r => (
23
- <Tap key={r.id} accessibilityRole="button" accessibilityLabel={'Reading ' + fmtLen(r.v) + '. Tap to put it on the selected line.'} onPress={() => useTrayReading(r.id)} style={s.chip}>
24
- <Text style={s.chipText}>{fmtLen(r.v)}</Text>
25
- </Tap>
26
- ))}
27
- </View>
28
- ) : <Text style={s.help}>Select a wall and take a reading, or tap a reading here to put it on the selected line.</Text>}
29
- </View>
30
- );
31
- }
32
-
33
- const s = createSheet({
34
- tray: { position: 'absolute', zIndex: 23, backgroundColor: C.g1, borderRadius: 15, padding: 10, width: 250, ...shadow },
35
- head: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', marginBottom: 8 },
36
- title: { fontFamily: FONT, fontSize: 13, fontWeight: '600', color: C.lg2 },
37
- link: { fontFamily: FONT, fontSize: 12, fontWeight: '600', color: C.lblue, padding: 4 },
38
- chips: { flexDirection: 'row', flexWrap: 'wrap', gap: 6 },
39
- chip: { height: 38, paddingHorizontal: 12, borderRadius: 8, backgroundColor: C.blue, justifyContent: 'center' },
40
- chipText: { fontFamily: FONT, fontSize: 15, fontWeight: '600', color: '#fff' },
41
- help: { fontFamily: FONT, fontSize: 12, color: C.g4, lineHeight: 16 },
42
- });