From deb94b9d6149f524bce384852d258c4677213350 Mon Sep 17 00:00:00 2001 From: "Fabian @ Blax Software" Date: Wed, 21 Oct 2026 13:49:29 +0200 Subject: [PATCH] BF input panels are component inputs, cable ends plug in more reliably; A merge panels, hex pass-through, design a component's box - Inside a component, the switch and button rows of its input panels are now input pins (in order with the other inputs, named after the rows); "Rows are component inputs" can be turned off per panel to keep the old fixed switches - Select input panels, Merge: one panel with all rows, spacing and wires kept; circuits that place this one keep their wires - Cable ends plug in more often: bundling orders the wires by the part a side runs to, an end with only some wires on a part still plugs, an end placed by hand next to the pins plugs, and dragging an end near its part shows green rings and plugs it on drop - Hex displays pass their four bits on (outputs on the right), so they can sit in the middle of a bus - Design the box: move lamps, displays, the screen and the name on a component's box, draw lines, boxes, circles and text in six colours, size it, leave things off; every placed copy shows it Co-Authored-By: Claude Opus 5.5 (1M context) --- app/assets/css/main.css | 157 ++++++++++ app/components/editor/App.vue | 1 + app/components/editor/BulkSettings.vue | 7 + app/components/editor/Canvas.vue | 24 +- app/components/editor/CircuitPane.vue | 8 + app/components/editor/FaceDialog.vue | 399 +++++++++++++++++++++++++ app/components/editor/Help.vue | 2 + app/components/editor/NodeSettings.vue | 14 + app/components/editor/NodeView.vue | 39 ++- app/components/editor/PinsPane.vue | 1 + app/composables/useEditor.ts | 32 +- app/composables/useMenu.ts | 8 +- app/lib/logic/bulk.ts | 16 +- app/lib/logic/cables.ts | 23 +- app/lib/logic/compile.ts | 13 +- app/lib/logic/geometry.ts | 74 ++++- app/lib/logic/labels.ts | 6 + app/lib/logic/panels.ts | 41 ++- app/lib/logic/project.ts | 59 +++- app/lib/logic/types.ts | 39 +++ tests/bulk.test.ts | 12 +- tests/face.test.ts | 88 ++++++ tests/panels.test.ts | 75 +++++ tests/plugs.test.ts | 26 +- tests/workflow.test.ts | 25 +- 25 files changed, 1151 insertions(+), 38 deletions(-) create mode 100644 app/components/editor/FaceDialog.vue create mode 100644 tests/face.test.ts create mode 100644 tests/panels.test.ts diff --git a/app/assets/css/main.css b/app/assets/css/main.css index 02f9e37..e2503c4 100644 --- a/app/assets/css/main.css +++ b/app/assets/css/main.css @@ -915,6 +915,38 @@ kbd { border-color: var(--accent); } +/* Drawings on a hand-drawn component box. */ +.node .face-ink { + fill: none; + stroke-width: 1.5; + stroke-linecap: round; +} + +.node .face-text { + font-family: var(--font-sans); + font-weight: 600; + pointer-events: none; +} + +.node .face-ink.ink-muted { stroke: #6b778a; } +.node .face-ink.ink-text { stroke: var(--text); } +.node .face-ink.ink-red { stroke: #ff5c5c; } +.node .face-ink.ink-yellow { stroke: #ffd34d; } +.node .face-ink.ink-green { stroke: #3ddc84; } +.node .face-ink.ink-blue { stroke: #4dabff; } +.node .face-ink.filled.ink-muted { fill: rgb(107 119 138 / 0.25); } +.node .face-ink.filled.ink-text { fill: rgb(219 226 234 / 0.18); } +.node .face-ink.filled.ink-red { fill: rgb(255 92 92 / 0.22); } +.node .face-ink.filled.ink-yellow { fill: rgb(255 211 77 / 0.22); } +.node .face-ink.filled.ink-green { fill: rgb(61 220 132 / 0.22); } +.node .face-ink.filled.ink-blue { fill: rgb(77 171 255 / 0.22); } +.node .face-text.ink-muted { fill: #8592a3; } +.node .face-text.ink-text { fill: var(--text); } +.node .face-text.ink-red { fill: #ff5c5c; } +.node .face-text.ink-yellow { fill: #ffd34d; } +.node .face-text.ink-green { fill: #3ddc84; } +.node .face-text.ink-blue { fill: #4dabff; } + /* + and − under a selected gate. */ .widen-btn { cursor: pointer; @@ -3003,3 +3035,128 @@ kbd { .search-results .muted { color: var(--muted); } + +/* ── Face designer ──────────────────────────────────────────────── */ +.modal.face-modal { + width: min(760px, 100%); +} + +.face-tools { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 10px; + margin: 14px 0 10px; +} + +.face-tools .seg button { + padding: 0 9px; +} + +.face-inks { + display: flex; + gap: 5px; +} + +.face-size { + display: flex; + align-items: center; + gap: 5px; + color: var(--muted); + font-size: 12px; +} + +.face-size input { + width: 56px; + height: 26px; + padding: 0 6px; + border: 1px solid var(--border); + border-radius: 6px; + background: var(--bg); + color: var(--text); +} + +.btn-sm.on { + border-color: var(--accent); + color: var(--accent); +} + +.face-canvas { + display: block; + user-select: none; + -webkit-user-select: none; + max-width: 100%; + border: 1px solid var(--border); + border-radius: 8px; + background: var(--bg); + touch-action: none; +} + +.face-canvas.drawing { + cursor: crosshair; +} + +.face-thing { + fill: transparent; + stroke: rgb(76 194 255 / 0.25); + stroke-dasharray: 3 3; + cursor: move; +} + +.face-thing.shape { + stroke: transparent; +} + +.face-thing:hover, +.face-thing.shape:hover { + stroke: rgb(76 194 255 / 0.6); +} + +.face-thing.sel, +.face-thing.shape.sel { + stroke: var(--accent); + stroke-dasharray: none; + stroke-width: 1.5; +} + +.face-canvas.drawing .face-thing, +.face-canvas.drawing .face-hit { + pointer-events: none; +} + +.face-hit { + stroke: transparent; + stroke-width: 9; + stroke-linecap: round; + cursor: move; +} + +.face-hit:hover { + stroke: rgb(76 194 255 / 0.3); +} + +.face-hit.sel { + stroke: rgb(76 194 255 / 0.45); +} + +.face-grip { + fill: var(--bg); + stroke: var(--accent); + stroke-width: 1.5; + cursor: nwse-resize; +} + +.face-props, +.face-hidden { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 8px; + min-height: 34px; + margin-top: 10px; +} + +.face-props .text-input { + flex: 1; + min-width: 120px; +} diff --git a/app/components/editor/App.vue b/app/components/editor/App.vue index 042fb2b..5c06a4c 100644 --- a/app/components/editor/App.vue +++ b/app/components/editor/App.vue @@ -54,5 +54,6 @@ onMounted(() => { + diff --git a/app/components/editor/BulkSettings.vue b/app/components/editor/BulkSettings.vue index 4ed132c..718c3db 100644 --- a/app/components/editor/BulkSettings.vue +++ b/app/components/editor/BulkSettings.vue @@ -341,6 +341,13 @@ function pack() {

Or drag one wire from a selected part to a pin: the others follow onto the next pins.

+
+

Input panels

+ +
+

Make a component

Wires that cross the selection border become its pins.

diff --git a/app/components/editor/Canvas.vue b/app/components/editor/Canvas.vue index 78effc3..e7addd1 100644 --- a/app/components/editor/Canvas.vue +++ b/app/components/editor/Canvas.vue @@ -8,7 +8,7 @@ import { circuitRoutes, findCrossings } from '~/lib/logic/routing' import { seriesLinks, type Link } from '~/lib/logic/bulk' import { dropLinks, dropPins, fitStart, type DropPin } from '~/lib/logic/fit' import type { CanvasOps, MenuEntry } from '~/composables/useMenu' -import { LANE, ribbon, RIBBON_MAX } from '~/lib/logic/cables' +import { LANE, plugLayout, ribbon, RIBBON_MAX } from '~/lib/logic/cables' import { wirePath } from '~/lib/draw' import { downloadSheet, printSheet, sheetSvg } from '~/lib/sheet' import { inputCount } from '~/lib/logic/wide' @@ -308,6 +308,8 @@ type Drag = from?: DropPin[] /** Pins the moving parts land on: the step that lines them up and the wires dropping makes. */ snap?: { shift: Pt; links: Link[] } | null + /** A cable end brought close to the part its wires run to: dropped, it plugs in. */ + plug?: { part: string; rings: Pt[] } | null } | { kind: 'wire' @@ -555,6 +557,7 @@ function onPointerMove(e: PointerEvent) { const at = d.from.map(p => ({ ...p, x: p.x + dx, y: d.lockY.has(p.node) ? p.y : p.y + dy })) d.snap = e.altKey ? null : dropLinks(at, d.still, d.grabbed === 1 ? 1 : 0) } + d.plug = d.moved && d.grabbed === 1 && !e.altKey ? plugNear(d.node) : null for (const [id, [x, y]] of d.orig) { const n = nodeMap.value.get(id) if (n) { @@ -721,7 +724,10 @@ function onPointerUp(e: PointerEvent) { case 'move': if (d.node.kind === 'button') ed.press(d.node, false) if (d.row && !d.moved) ed.pressRow(d.node, d.row, false) - if (d.moved && d.snap?.links.length) { + if (d.moved && d.plug) { + ed.unplugMoved(new Set(d.orig.keys())) + ed.plugEnd(d.node) + } else if (d.moved && d.snap?.links.length) { const [sx, sy] = d.snap.shift for (const id of d.orig.keys()) { const n = nodeMap.value.get(id) @@ -1166,9 +1172,23 @@ function openMenuForSelection() { menu.value = entries.length ? { x, y, entries, keyboard: true } : null } +/** + * A free cable end dragged to within a square or so of where it would sit + * on its part's pins: the pins it would plug into. + */ +function plugNear(n: CircuitNode): { part: string; rings: Pt[] } | null { + if ((n.kind !== 'bundle' && n.kind !== 'split') || n.plug) return null + const part = ed.plugTarget(n) + const lay = part && plugLayout(def.value, n, part, ed.getDef.value) + if (!part || !lay || Math.hypot(n.x - lay.x, n.y - lay.y) > 1.6) return null + const x = n.kind === 'split' ? lay.x + 1 : lay.x + return { part: part.id, rings: lay.offsets.map(o => [x, lay.y + o] as Pt) } +} + /** Pins a dragged part will connect to when dropped, shown as green rings. */ const dropRings = computed(() => { const d = drag.value + if (d?.kind === 'move' && d.plug) return d.plug.rings.map(([x, y]) => ({ x, y })) if (d?.kind !== 'move' || !d.snap || !d.still) return [] const moving = new Set(d.orig.keys()) return d.snap.links.map(l => { diff --git a/app/components/editor/CircuitPane.vue b/app/components/editor/CircuitPane.vue index 7b1a407..f415d05 100644 --- a/app/components/editor/CircuitPane.vue +++ b/app/components/editor/CircuitPane.vue @@ -147,6 +147,14 @@ watch(() => def.value.id, () => (confirmDelete.value = false))

+
+

Its box

+

How it looks when placed: {{ def.design ? 'drawn by hand' : 'laid out automatically' }}.

+ +
+

Sheet

The circuit as a wiring sheet with a title block: print it, save it as PDF, or keep it as an SVG.

diff --git a/app/components/editor/FaceDialog.vue b/app/components/editor/FaceDialog.vue new file mode 100644 index 0000000..8a0ed3f --- /dev/null +++ b/app/components/editor/FaceDialog.vue @@ -0,0 +1,399 @@ + + + diff --git a/app/components/editor/Help.vue b/app/components/editor/Help.vue index ba5f453..ee99466 100644 --- a/app/components/editor/Help.vue +++ b/app/components/editor/Help.vue @@ -31,6 +31,8 @@ const SHORTCUTS: [string, string][] = [ ['Send signal / Use signal', 'Name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire'], ['Ctrl+F', 'Find a part, signal or component in every circuit, and where a component is used'], ['Ctrl+P', 'Print the circuit as a sheet with a title block, or save it as PDF'], + ['Select input panels, Merge', 'One panel with all their rows; inside a component its rows are input pins'], + ['Design the box (Circuit tab)', 'Move lamps, displays and the name on a component\'s box, draw lines, boxes, circles and text'], ['Select several lamps, pins or switches', 'Green boxes show free pins in a row they fit; point along one, click to wire them all'], ['Shift + click on canvas', 'Keep placing the same part'], ['Ctrl+C, Ctrl+V, Ctrl+D', 'Copy, paste, duplicate; names continue their series (D0 → D1)'], diff --git a/app/components/editor/NodeSettings.vue b/app/components/editor/NodeSettings.vue index 814ea8d..b967c66 100644 --- a/app/components/editor/NodeSettings.vue +++ b/app/components/editor/NodeSettings.vue @@ -219,6 +219,12 @@ const undriven = computed(() => { return cableBits(n.value) - fed.size }) +function setInner(inner: boolean) { + if (inner) n.value.inner = true + else delete n.value.inner + ed.commit() +} + function setRowHz(row: PanelRow, e: Event) { const v = Number((e.target as HTMLInputElement).value) if (v > 0 && v <= 1000) row.hz = v @@ -394,6 +400,11 @@ function setRowHz(row: PanelRow, e: Event) { + +

Kept inside: in a component the switches stay as set here, buttons read 0.

@@ -522,6 +533,9 @@ function setRowHz(row: PanelRow, e: Event) {
+