From acb9620b2b0fb3cda68c6dd4e1f9354fddf4fce0 Mon Sep 17 00:00:00 2001 From: "Fabian @ Blax Software" Date: Tue, 20 Oct 2026 20:15:38 +0200 Subject: [PATCH] A dimmed names from the connected pin on switches, lamps and outputs Parts without a hand-typed name show the name of the component pin they are wired to, dimmed and in italics, live as the wiring changes; automatic names are dimmed too. Typed names show as before. Co-Authored-By: Claude Opus 5.5 --- README.md | 2 +- app/assets/css/main.css | 9 +++++++++ app/components/editor/Canvas.vue | 27 +++++++++++++++++++++++++++ app/components/editor/NodeView.vue | 17 ++++++++++++----- 4 files changed, 49 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 422699e..c0b521b 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Nuxt 4 (client-only editor, `ssr: false`), Tailwind CSS v4, Lucide icons via `@n - Cables: a bundle gathers 2 to 32 wires into one thick cable, a split fans it out again in the same order; one bundle can feed several splits. Select some wires and press "Bundle into cable" to have both ends placed for you (the cable takes the wires' colour); "Remove cable" turns it back into single wires. A cable end only joins another cable end, and the cable shows its width. - Pixels and screens: a pixel is a one-grid square that lights at 1, in five colours. Inside a component all pixels show on its box as one screen without gaps (every column and row they sit on becomes one of the screen), so you build your own LCD; see "Screen 4×4" and "Demo: Screen". - Input panel: one part with a column of controls; each row is a switch, button or clock. "Attach input panel" on a placed component docks one to its left with a row per free input, lined up with the pins and named after them. A docked panel moves with its component, gets a row when the component gains an input and loses it when the pin goes; inputs that are wired elsewhere, and rows you remove, are left alone. Inside a component a switch row keeps its position and a button row is 0. -- Automatic names: copies continue a series (D0 copied gives D1, D2; A gives B), and so does placing a new input or output after a numbered one. A switch, button, lamp or output pin without a name of its own (or with an automatic one) takes the name of the component pin it gets wired to, made unique (Cin, Cin2); a name typed by hand is kept. +- Automatic names: copies continue a series (D0 copied gives D1, D2; A gives B), and so does placing a new input or output after a numbered one. A switch, button, lamp or output pin without a name of its own (or with an automatic one) takes the name of the component pin it gets wired to, made unique (Cin, Cin2); a name typed by hand is kept. On the canvas, a switch, button, clock, lamp or output pin without a name typed by hand shows the name of the component pin it is wired to, dimmed and in italics (or its automatic name, also dimmed); the name follows the wiring as it changes. - Every circuit is a component. Its input and output nodes become its pins, ordered top to bottom. Double-click a component to open it. - Lamps and hex displays inside a component show on its box, with their labels, lit by that instance's state. They are laid out in rows the way they sit inside. A checkbox in the inspector turns this off per component. - Clicking anything opens its settings on the right. Parts can be swapped in place (wires stay on the pins in the same position): NAND and components with each other, switch/button/clock/constants with each other, output/lamp/display with each other. Clocks have their own frequency or follow the top bar. Switches and buttons can get a keyboard key. Lamps and displays have colours, notes have sizes, components a name on the canvas. Components can be unpacked into their parts or given their own copy of the definition; any part can have all its wires unlinked. diff --git a/app/assets/css/main.css b/app/assets/css/main.css index 4242eb2..0d3e743 100644 --- a/app/assets/css/main.css +++ b/app/assets/css/main.css @@ -1792,3 +1792,12 @@ kbd { .target-table .truth { max-height: 220px; } + +/* A name borrowed from the pin a part is wired to, while it has none of its own. */ +.io-label.ghosted, +.face-label.ghosted { + fill: var(--muted); + font-weight: 500; + font-style: italic; + opacity: 0.75; +} diff --git a/app/components/editor/Canvas.vue b/app/components/editor/Canvas.vue index c9f2c84..f301589 100644 --- a/app/components/editor/Canvas.vue +++ b/app/components/editor/Canvas.vue @@ -5,6 +5,7 @@ import type { CircuitNode, PanelRow, PinRef, Wire } from '~/lib/logic/types' import { branchCorners, branchTo, moveCorner, moveSegment, segmentDrag, splitDrag } from '~/lib/logic/wires' import { circuitRoutes, findCrossings } from '~/lib/logic/routing' import { wirePath } from '~/lib/draw' +import { pinName } from '~/lib/logic/labels' const ed = useEditor() const root = ref() @@ -473,6 +474,31 @@ const linked = computed(() => { return { in: ins, out: outs } }) +/** + * Names to show, dimmed, on switches, buttons, clocks, lamps and output pins + * that have none of their own: the component pin they are wired to. + */ +const hints = computed(() => { + const out = new Map() + const nodes = nodeMap.value + for (const w of def.value.wires) { + const from = nodes.get(w.from.node) + const to = nodes.get(w.to.node) + if (!from || !to) continue + if (SOURCES.has(from.kind) && (from.autoLabel || !from.label?.trim()) && !out.has(from.id)) { + const name = pinName(to, w.to.pin, ed.getDef.value) + if (name) out.set(from.id, name) + } + if (SINKS.has(to.kind) && (to.autoLabel || !to.label?.trim()) && !out.has(to.id)) { + const name = pinName(from, w.from.pin, ed.getDef.value) + if (name) out.set(to.id, name) + } + } + return out +}) +const SOURCES = new Set(['input', 'button', 'clock']) +const SINKS = new Set(['output', 'lamp']) + /** The part whose body is under the point; the one drawn on top wins. */ function nodeAt(at: Pt): CircuitNode | undefined { const list = def.value.nodes @@ -829,6 +855,7 @@ defineExpose({ fit, zoomAt }) :shape="shapes.get(n.id)!" :selected="selected.has(n.id)" :through="linked.out.has(`${n.id}:q`) && (n.kind === 'lamp' || n.kind === 'output')" + :hint="hints.get(n.id)" /> () const ed = useEditor() @@ -19,6 +21,11 @@ const gate = computed(() => (props.shape.gate ? gateDrawing(props.shape, style.v const chipDef = computed(() => (props.node.chip ? ed.getDef.value(props.node.chip) : undefined)) const b = computed(() => props.shape.body) const rows = computed(() => props.node.rows ?? []) +// A name typed by hand shows as is. Otherwise the name of the pin the part is +// wired to, or its automatic name, shows dimmed. +const own = computed(() => (props.node.autoLabel ? '' : (props.node.label?.trim() ?? ''))) +const ioText = computed(() => own.value || props.hint || props.node.label?.trim() || '') +const ghosted = computed(() => !own.value && !!ioText.value) /** Lines inside a bundle or split from each single wire to the cable pin. */ const cableFan = computed(() => { @@ -98,7 +105,7 @@ const title = computed(() => { @@ -137,12 +144,12 @@ const title = computed(() => { - {{ node.label || (node.hz ? `${node.hz} Hz` : '') }} + {{ ioText || (node.hz ? `${node.hz} Hz` : '') }}