From 74b257ce6edc82490e3b95fb22d6833931cddde5 Mon Sep 17 00:00:00 2001 From: "Fabian @ Blax Software" Date: Wed, 21 Oct 2026 09:29:55 +0200 Subject: [PATCH] A right panel in tabs, Pins list, bulk editing, transistor breakdown, Settings dialog - Right panel tabs: Selection, Circuit, Pins, Test. Display and sound preferences move to a Settings dialog (gear in the top bar). - Pins tab: every input and output in pin order with live values; rename in place (Enter goes to the next), number a whole side from a pattern, flag duplicate names, centre the canvas on a part. - Several selected parts: narrow by type, swap all, rename all from a pattern, set switches to 0/1 or flip, shared colour/frequency/size, align and spread. - Transistors on every part (NAND 4, switches and lamps 0), NAND 4T in the palette, and a per-part breakdown of the circuit. Test: the count equals 4 x the gates the simulator builds, for every example and wide gate. Co-Authored-By: Claude Opus 5.5 (1M context) --- README.md | 9 +- app/assets/css/main.css | 290 +++++++++++++++- app/components/editor/App.vue | 1 + app/components/editor/BulkSettings.vue | 223 ++++++++++++ app/components/editor/Canvas.vue | 16 + app/components/editor/CircuitPane.vue | 156 +++++++++ app/components/editor/Help.vue | 2 + app/components/editor/Inspector.vue | 423 ++++------------------- app/components/editor/NodeSettings.vue | 12 +- app/components/editor/Palette.vue | 1 + app/components/editor/PinsPane.vue | 151 ++++++++ app/components/editor/SettingsDialog.vue | 89 +++++ app/components/editor/TestPane.vue | 113 ++++++ app/components/editor/Toolbar.vue | 18 +- app/components/editor/WireSettings.vue | 58 ++++ app/composables/useEditor.ts | 110 +++++- app/lib/logic/bulk.ts | 134 +++++++ tests/bulk.test.ts | 96 +++++ 18 files changed, 1518 insertions(+), 384 deletions(-) create mode 100644 app/components/editor/BulkSettings.vue create mode 100644 app/components/editor/CircuitPane.vue create mode 100644 app/components/editor/PinsPane.vue create mode 100644 app/components/editor/SettingsDialog.vue create mode 100644 app/components/editor/TestPane.vue create mode 100644 app/components/editor/WireSettings.vue create mode 100644 app/lib/logic/bulk.ts create mode 100644 tests/bulk.test.ts diff --git a/README.md b/README.md index c0b521b..ec54074 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Nuxt 4 (client-only editor, `ssr: false`), Tailwind CSS v4, Lucide icons via `@n - Gates with more inputs: a placed AND, OR, XOR, NAND or NOR (built in, from the examples, or your own) has an "Inputs" setting from 2 to 16. The wide version is a component built as a balanced tree of the two-input gate (NAND and NOR as the plain gate plus a final inverted one), made once per gate and width in "Wide gates" and reused; transistors count honestly and changes to the two-input gate carry through. Which gates qualify is read off their truth table ([app/lib/logic/wide.ts](app/lib/logic/wide.ts)). - Campaign (Projects → New campaign): you start with NAND, inputs, outputs, lamps and notes, and no examples. Each challenge opens once the ones it builds on are solved (NOT → AND, OR, SR Latch → …), and your own solution becomes a part you can place. Other basic parts unlock on the way: constants with NOT, the input panel with AND, hex display and pixel with the decoder, cables with Adder 2, the button with the SR latch, the clock with the D latch. Rules in [app/lib/logic/progress.ts](app/lib/logic/progress.ts). Sandbox projects keep everything open. - Puzzles: "Publish as puzzle" (This circuit) turns a circuit into a link `/puzzle/`. Only its behaviour is published, as a truth table, or for circuits with memory as a run of input changes from power-on; the circuit stays private. Whoever opens the link gets the puzzle in their project, sees the target and the author's transistor count, and after a pass their solution goes to the server, which re-runs the checks and counts the transistors itself (with a fixed work budget) and keeps each player's best. The board shows everyone's transistor counts and your place. The puzzle of the week is generated from the ISO week, the same for everyone: three or four inputs, one or two outputs, each depending on every input. Players are anonymous ids per browser. -- Sound (speaker in the top bar; volume and clock ticks under Display): clicks for placing, wiring, switches and buttons, a tick per clock cycle up to 8 Hz (off by default), and jingles for a solve, a failed check, unlocks and new records. All synthesised with Web Audio, no sound files ([app/lib/audio.ts](app/lib/audio.ts)). +- Sound (speaker in the top bar; volume and clock ticks in Settings, the gear in the top bar): clicks for placing, wiring, switches and buttons, a tick per clock cycle up to 8 Hz (off by default), and jingles for a solve, a failed check, unlocks and new records. All synthesised with Web Audio, no sound files ([app/lib/audio.ts](app/lib/audio.ts)). - Transistors: every component shows how many it takes, counted as a CMOS NAND (4 transistors) per gate at every depth: in the palette, its settings and the circuit stats. Each challenge keeps your record, the fewest transistors of any passing solution, and says so when you beat it. - 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". @@ -19,12 +19,15 @@ Nuxt 4 (client-only editor, `ssr: false`), Tailwind CSS v4, Lucide icons via `@n - 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. +- The right panel has four tabs. **Selection**: settings of what you clicked (switches to it when you select something on an idle panel). **Circuit**: name, symbol, group, statistics, and where the transistors are (each kind of part with its count; click a line to select those parts). **Pins**: every input and output of the circuit in pin order with its live value; rename in place (Enter goes to the next), "Number all" names a whole side from a pattern (D# → D0, D1, …), duplicate names are flagged, the target icon centres the canvas on a part. **Test**: the challenge or puzzle check and the truth table (opens by itself for a challenge). Display and sound preferences are in Settings (gear in the top bar). +- Several selected parts are edited together: chips to narrow the selection by type, swap them all for another part, rename all top to bottom from a pattern, set every switch to 0 or 1 or flip each, one colour, one clock frequency or note size for all, line them up or spread them evenly, plus make component, connect one by one, unlink, duplicate, delete. +- Transistors: every part shows its count (4 for a NAND, 0 for switches, lamps and cables, the whole inside for a component; the NAND in the palette shows 4T). The count is 4 per CMOS NAND gate the simulator builds, at every depth; a test checks this against the flattened circuit for every example and every wide gate. - 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. - Select parts and press "Make component" to turn them into a new component; wires crossing the selection become pins. - Gate symbols in IEC 60617 (DIN, default) or ANSI. A component with one output can be drawn as a gate symbol. -- Wires of different signals never share a line: auto-routed wires pick a free column or a detour, and anything still clashing (hand-placed bends) is drawn on its own lane. Crossings are drawn as a bow, triangle, bridge, gap or plain crossing (Display settings on the right with nothing selected). Clicking a junction dot selects its whole signal. +- Wires of different signals never share a line: auto-routed wires pick a free column or a detour, and anything still clashing (hand-placed bends) is drawn on its own lane. Crossings are drawn as a bow, triangle, bridge, gap or plain crossing (Settings, the gear in the top bar). Clicking a junction dot selects its whole signal. - Connecting: drag from a pin, or click a pin and then the other one. While a wire is drawn, every pin it can go to is ringed (dashed when it already has a wire, which would be replaced); dropping it on a part uses that part's next free pin. "Connect one by one" (W, or the button with several parts selected; on a component "Wire one by one: Inputs / Outputs") numbers the pins of the selection top to bottom and wires them in turn, one click each; clicking the same component again and again fills its pins in order. -- Tidy wiring (Display settings, or "Tidy all wires", which also drops hand-placed bends): every forward wire takes its vertical step in the free gap right in front of the part it feeds. All wires entering parts at the same column are ordered together (each goes where it adds the fewest crossings) and laid out as one compact staircase a grid step apart, slid sideways to where it runs along no other signal; one signal shares one trunk. Only the columns of that gap are looked at, so it stays cheap. On the 4-bit adder without hand routing this cuts crossings from 32 to 18. +- Tidy wiring (Settings, or "Tidy all wires", which also drops hand-placed bends): every forward wire takes its vertical step in the free gap right in front of the part it feeds. All wires entering parts at the same column are ordered together (each goes where it adds the fewest crossings) and laid out as one compact staircase a grid step apart, slid sideways to where it runs along no other signal; one signal shares one trunk. Only the columns of that gap are looked at, so it stays cheap. On the 4-bit adder without hand routing this cuts crossings from 32 to 18. - Wire editing: drag any segment (a stub keeps the pin end straight), drag corner squares, Alt+drag to pull out a new bend, Ctrl+drag to branch a new wire off a signal, double-click to select the whole signal, Shift+click and box selection for several wires, arrow keys to shift them, six colour tags. - Several projects per browser (Projects dialog: open, rename, duplicate, delete). Export a project file, open a file as a new project, or add the components of a file to the open project. - Accounts: email and password. Signed in, every project in the browser is also kept in the account and synced in both directions (on sign-in, on focus, every minute, and two seconds after a change). If two computers changed the same project, both versions are kept. The untouched starter project of a new browser is not uploaded; signing in there opens your latest project instead. diff --git a/app/assets/css/main.css b/app/assets/css/main.css index 0d3e743..ba13de4 100644 --- a/app/assets/css/main.css +++ b/app/assets/css/main.css @@ -1700,7 +1700,8 @@ kbd { flex: 0 0 56px; } -.challenge .score { +.challenge .score, +.inspector .score { display: flex; align-items: center; gap: 6px; @@ -1709,7 +1710,8 @@ kbd { color: var(--muted); } -.challenge .score strong { +.challenge .score strong, +.inspector .score strong { color: var(--on); } @@ -1801,3 +1803,287 @@ kbd { font-style: italic; opacity: 0.75; } + +/* ── Right panel tabs ───────────────────────────────────────────── */ +.itabs { + display: grid; + grid-template-columns: repeat(4, 1fr); + border-bottom: 1px solid var(--border); + flex-shrink: 0; +} + +.itabs button { + position: relative; + display: flex; + flex-direction: column; + align-items: center; + gap: 2px; + padding: 7px 2px 6px; + font-size: 11px; + font-weight: 600; + color: var(--muted); + border-bottom: 2px solid transparent; +} + +.itabs button:hover { + color: var(--text); +} + +.itabs button.active { + color: var(--text); + border-bottom-color: var(--accent); +} + +.itabs button.task:not(.active) { + color: var(--lamp); +} + +.itabs .badge { + position: absolute; + top: 3px; + right: calc(50% - 22px); + min-width: 16px; + padding: 0 4px; + border-radius: 999px; + background: rgb(76 194 255 / 0.18); + color: var(--accent); + font-family: var(--font-mono); + font-size: 9px; + line-height: 14px; +} + +.empty-pane { + display: grid; + justify-items: center; + gap: 6px; + padding: 32px 18px !important; + text-align: center; + color: var(--muted); +} + +.empty-pane .hint { + margin: 0; +} + +/* ── Transistor breakdown ───────────────────────────────────────── */ +.cost { + width: 100%; + margin-top: 8px; + border-collapse: collapse; + font-size: 12px; +} + +.cost td { + padding: 4px 4px; + border-bottom: 1px solid var(--border); +} + +.cost tbody tr { + cursor: pointer; +} + +.cost tbody tr:hover { + background: var(--panel-2); +} + +.cost .num { + text-align: right; + font-family: var(--font-mono); + color: var(--muted); + white-space: nowrap; +} + +.cost .strong { + color: var(--text); + font-weight: 600; +} + +.cost tfoot td { + border-bottom: 0; + font-weight: 600; +} + +/* ── Pins list ──────────────────────────────────────────────────── */ +.count-pill { + margin-left: 4px; + padding: 0 6px; + border-radius: 999px; + background: var(--panel-2); + font-family: var(--font-mono); + font-size: 10px; + letter-spacing: 0; +} + +.io-list { + display: grid; + gap: 2px; +} + +.io-list li { + display: flex; + align-items: center; + gap: 8px; + padding: 3px 4px; + border-radius: 6px; + border: 1px solid transparent; +} + +.io-list li:hover { + background: var(--panel-2); +} + +.io-list li.selected { + border-color: rgb(76 194 255 / 0.5); + background: rgb(76 194 255 / 0.07); +} + +.io-value { + display: grid; + place-items: center; + width: 20px; + height: 20px; + flex-shrink: 0; + border-radius: 5px; + background: var(--panel-2); + color: var(--muted); + font-family: var(--font-mono); + font-size: 11px; + font-weight: 700; +} + +.io-value.on { + background: var(--on-dim); + color: var(--on); +} + +.io-main { + display: grid; + min-width: 0; + flex: 1; +} + +.io-name { + width: 100%; + min-width: 0; + padding: 3px 6px; + border: 1px solid transparent; + border-radius: 5px; + background: transparent; + color: var(--text); + font-family: var(--font-mono); + font-size: 13px; + font-weight: 600; + outline: none; +} + +.io-name:hover { + border-color: var(--border); +} + +.io-name:focus { + border-color: var(--accent); + background: var(--bg); +} + +.io-name::placeholder { + color: var(--muted); + font-weight: 400; + font-style: italic; +} + +.io-kind { + display: flex; + align-items: center; + gap: 4px; + padding-left: 7px; + font-size: 10.5px; + color: var(--muted); +} + +.io-list li.dup .io-kind { + color: var(--lamp); +} + +.numbering { + margin: 4px 0 12px; + padding: 10px; + border: 1px solid var(--border); + border-radius: 8px; + background: var(--panel-2); +} + +/* ── Bulk editing ───────────────────────────────────────────────── */ +.type-chips { + display: flex; + flex-wrap: wrap; + gap: 4px; + margin-bottom: 10px; +} + +.type-chip { + padding: 3px 8px; + border: 1px solid var(--border); + border-radius: 999px; + font-size: 12px; + color: var(--text); +} + +.type-chip span { + font-family: var(--font-mono); + color: var(--muted); +} + +.type-chip:hover { + border-color: var(--accent); +} + +.arrange { + display: grid; + grid-template-columns: repeat(6, 1fr); + gap: 4px; +} + +.arrange .icon-btn { + width: 100%; + border: 1px solid var(--border); +} + +.arrange .icon-btn:disabled { + opacity: 0.4; +} + +.text-input { + width: 100%; + background: var(--panel-2); + border: 1px solid var(--border); + border-radius: 6px; + padding: 6px 8px; + font-size: 13px; + color: var(--text); + outline: none; +} + +.text-input:focus { + border-color: var(--accent); +} + +.tips-box { + margin-top: 12px; + font-size: 12px; + color: var(--muted); +} + +.tips-box summary { + cursor: pointer; + margin-bottom: 6px; +} + +.field small.hint { + display: block; + margin-top: 4px; +} + +.inspector h3 + .score { + margin-top: -4px; + margin-bottom: 12px; +} diff --git a/app/components/editor/App.vue b/app/components/editor/App.vue index 507643c..714ce89 100644 --- a/app/components/editor/App.vue +++ b/app/components/editor/App.vue @@ -46,5 +46,6 @@ onMounted(() => { + diff --git a/app/components/editor/BulkSettings.vue b/app/components/editor/BulkSettings.vue new file mode 100644 index 0000000..5dc40bb --- /dev/null +++ b/app/components/editor/BulkSettings.vue @@ -0,0 +1,223 @@ + + + diff --git a/app/components/editor/Canvas.vue b/app/components/editor/Canvas.vue index f301589..f4d2082 100644 --- a/app/components/editor/Canvas.vue +++ b/app/components/editor/Canvas.vue @@ -167,6 +167,22 @@ watch( }, ) +// Centre on a part picked elsewhere (the Pins list), keeping the zoom. +watch( + () => ed.focusRequest.value, + r => { + const n = r && nodeMap.value.get(r.id) + const s = n && shapes.value.get(n.id) + if (!n || !s) return + const v = view.value + ed.views[def.value.id] = { + ...v, + x: size.w / 2 - (n.x + s.body.x + s.body.w / 2) * G * v.zoom, + y: size.h / 2 - (n.y + s.body.y + s.body.h / 2) * G * v.zoom, + } + }, +) + let resize: ResizeObserver | undefined onMounted(() => { resize = new ResizeObserver(([entry]) => { diff --git a/app/components/editor/CircuitPane.vue b/app/components/editor/CircuitPane.vue new file mode 100644 index 0000000..7be528f --- /dev/null +++ b/app/components/editor/CircuitPane.vue @@ -0,0 +1,156 @@ + + +