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 <noreply@anthropic.com>
This commit is contained in:
parent
5663685505
commit
acb9620b2b
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<HTMLDivElement>()
|
||||
|
|
@ -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<string, string>()
|
||||
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)"
|
||||
/>
|
||||
|
||||
<rect
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ const props = defineProps<{
|
|||
ghost?: boolean
|
||||
/** The pass-through pin of a lamp or output is wired: its label moves out of the wire's way. */
|
||||
through?: boolean
|
||||
/** Name of the pin this part is wired to, shown dimmed while it has no name of its own. */
|
||||
hint?: string
|
||||
}>()
|
||||
|
||||
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(() => {
|
|||
|
||||
<!-- Switch (input pin) -->
|
||||
<template v-else-if="node.kind === 'input'">
|
||||
<text :x="-6" :y="4" text-anchor="end" class="io-label">{{ node.label }}</text>
|
||||
<text :x="-6" :y="4" text-anchor="end" class="io-label" :class="{ ghosted }">{{ ioText }}</text>
|
||||
<rect x="0" :y="-0.6 * G" :width="2 * G" :height="1.2 * G" :rx="0.6 * G" class="switch" :class="{ on: lit }" />
|
||||
<circle :cx="lit ? 1.4 * G : 0.6 * G" cy="0" :r="0.42 * G" class="knob" />
|
||||
<text v-if="node.key" :x="G" :y="1.45 * G" text-anchor="middle" class="key-badge">{{ node.key.toUpperCase() }}</text>
|
||||
|
|
@ -108,7 +115,7 @@ const title = computed(() => {
|
|||
<template v-else-if="node.kind === 'output'">
|
||||
<path :d="`M0 0H${0.4 * G}`" class="stub" />
|
||||
<path :d="`M${0.4 * G} ${-0.6 * G}H${1.5 * G}L${2 * G} 0L${1.5 * G} ${0.6 * G}H${0.4 * G}Z`" class="terminal" :class="{ on: lit }" />
|
||||
<text :x="through ? G : 2 * G + 6" :y="through ? -0.75 * G - 4 : 4" :text-anchor="through ? 'middle' : 'start'" class="io-label">{{ node.label }}</text>
|
||||
<text :x="through ? G : 2 * G + 6" :y="through ? -0.75 * G - 4 : 4" :text-anchor="through ? 'middle' : 'start'" class="io-label" :class="{ ghosted }">{{ ioText }}</text>
|
||||
</template>
|
||||
|
||||
<!-- Lamp: IEC symbol, circle with a cross -->
|
||||
|
|
@ -116,7 +123,7 @@ const title = computed(() => {
|
|||
<path :d="`M0 0H${0.35 * G}`" class="stub" />
|
||||
<circle :cx="G" cy="0" :r="0.65 * G" class="lamp" :class="[node.color ? `l-${node.color}` : '', { on: lit }]" />
|
||||
<path :d="`M${G - 0.46 * G} ${-0.46 * G}L${G + 0.46 * G} ${0.46 * G}M${G + 0.46 * G} ${-0.46 * G}L${G - 0.46 * G} ${0.46 * G}`" class="lamp-cross" :class="{ on: lit }" />
|
||||
<text v-if="node.label" :x="through ? G : 2 * G + 4" :y="through ? -0.75 * G - 4 : 4" :text-anchor="through ? 'middle' : 'start'" class="io-label">{{ node.label }}</text>
|
||||
<text v-if="ioText" :x="through ? G : 2 * G + 4" :y="through ? -0.75 * G - 4 : 4" :text-anchor="through ? 'middle' : 'start'" class="io-label" :class="{ ghosted }">{{ ioText }}</text>
|
||||
</template>
|
||||
|
||||
<!-- Constant 1 -->
|
||||
|
|
@ -137,12 +144,12 @@ const title = computed(() => {
|
|||
<rect x="0" :y="-0.7 * G" :width="2.5 * G" :height="1.4 * G" rx="2" class="body" />
|
||||
<path :d="`M${0.35 * G} ${0.35 * G}H${0.8 * G}V${-0.35 * G}H${1.3 * G}V${0.35 * G}H${1.8 * G}V${-0.35 * G}H${2.15 * G}`" class="wave" :class="{ on: lit }" />
|
||||
<path :d="`M${2.5 * G} 0H${3 * G}`" class="stub" />
|
||||
<text :x="1.25 * G" :y="1.55 * G" text-anchor="middle" class="face-label">{{ node.label || (node.hz ? `${node.hz} Hz` : '') }}</text>
|
||||
<text :x="1.25 * G" :y="1.55 * G" text-anchor="middle" class="face-label" :class="{ ghosted }">{{ ioText || (node.hz ? `${node.hz} Hz` : '') }}</text>
|
||||
</template>
|
||||
|
||||
<!-- Push button -->
|
||||
<template v-else-if="node.kind === 'button'">
|
||||
<text v-if="node.label" :x="-6" :y="4" text-anchor="end" class="io-label">{{ node.label }}</text>
|
||||
<text v-if="ioText" :x="-6" :y="4" text-anchor="end" class="io-label" :class="{ ghosted }">{{ ioText }}</text>
|
||||
<rect x="0" :y="-0.7 * G" :width="1.6 * G" :height="1.4 * G" rx="3" class="body" />
|
||||
<circle :cx="0.8 * G" cy="0" :r="0.45 * G" class="button" :class="{ on: lit }" />
|
||||
<path :d="`M${1.6 * G} 0H${2 * G}`" class="stub" />
|
||||
|
|
|
|||
Loading…
Reference in New Issue