From f4e2c0865897f29c76b4ecc711a1811ff9d5a23e Mon Sep 17 00:00:00 2001 From: "Fabian @ Blax Software" Date: Wed, 21 Oct 2026 12:33:30 +0200 Subject: [PATCH] A right-click menu for parts, wires and the canvas, "Wire them all to" as cards, plugged latches in plain greys - Right click (or the menu key) shows what can be done with what is under the pointer: one part (open, rename, change to, inputs, colour, speed, panels, unpack, plug and unplug, cable colour), several parts (wire them all to with live preview, connect one by one, switches, change all, arrange, keep only, make a component), wires (bundle, colour, whole signal, straighten, remove cable) or empty canvas (paste here, add a part here, select all, fit, tidy, undo); right drag still moves the view - "Wire them all to": a card per part, each fit a strip of its pins, and which wire goes where for the fit pointed at - Plugged cable ends no longer look selected: grey connector, steel clips - Icons named in menus are bundled for the browser too Co-Authored-By: Claude Opus 5.5 (1M context) --- app/assets/css/main.css | 297 +++++++++++++++++++- app/components/editor/BulkSettings.vue | 95 +++++-- app/components/editor/Canvas.vue | 80 +++++- app/components/editor/ContextMenu.vue | 95 +++++++ app/components/editor/Help.vue | 1 + app/components/editor/MenuList.vue | 85 ++++++ app/composables/useEditor.ts | 13 +- app/composables/useMenu.ts | 372 +++++++++++++++++++++++++ nuxt.config.ts | 3 +- 9 files changed, 1002 insertions(+), 39 deletions(-) create mode 100644 app/components/editor/ContextMenu.vue create mode 100644 app/components/editor/MenuList.vue create mode 100644 app/composables/useMenu.ts diff --git a/app/assets/css/main.css b/app/assets/css/main.css index 9c8b85c..001ae04 100644 --- a/app/assets/css/main.css +++ b/app/assets/css/main.css @@ -824,19 +824,20 @@ kbd { .harness.c-purple { --w-on: #b388ff; --w-off: #463768; } .harness.c-pink { --w-on: #ff7ac6; --w-off: #673657; } +/* A plugged cable end: a plain connector in the part's own greys, held by two steel clips. */ .node .body.cable-end.plugged { - fill: #253447; - stroke: #6fa3cf; + fill: #1f2630; + stroke: #5d6878; } .node .latch rect { - fill: #6fa3cf; - stroke: #1b2633; + fill: #7a8698; + stroke: #10151c; stroke-width: 1; } .node .latch .contact { - stroke: #9fd0f5; + stroke: #3a4554; stroke-width: 2.5; stroke-linecap: round; } @@ -2401,22 +2402,298 @@ kbd { pointer-events: none; } -.fit-list { +/* "Wire them all to": a card per part, each fit a strip of the pins it takes. */ +.fit-cards { + display: grid; + gap: 6px; +} + +.fit-card { + padding: 8px; + border: 1px solid var(--border); + border-radius: 8px; + background: var(--panel-2); + transition: border-color 120ms; +} + +.fit-card.hot { + border-color: rgb(61 220 132 / 0.55); +} + +.fit-card-head { + display: flex; + align-items: center; + gap: 6px; + margin-bottom: 7px; + color: var(--text); + font-size: 12px; + font-weight: 600; +} + +.fit-card-head .fit-icon { + color: var(--muted); +} + +.fit-tag { + color: var(--muted); + font-size: 11px; + font-weight: 500; +} + +.fit-choices { display: flex; flex-wrap: wrap; - gap: 4px; + gap: 5px; } -.fit-list .btn-sm.active { +.fit-choice { + display: inline-flex; + padding: 2px; + border: 1px solid #2f3a48; + border-radius: 6px; + background: #11161d; + gap: 2px; + transition: border-color 100ms, background 100ms; +} + +.fit-choice:hover, +.fit-choice.active { border-color: var(--on); - color: var(--on); + background: rgb(61 220 132 / 0.12); } -.fit-list .muted { +.fit-pill { + min-width: 22px; + padding: 1px 5px; + border-radius: 4px; + background: #1f2732; + color: var(--text); + font-family: var(--font-mono); + font-size: 11px; + line-height: 17px; + text-align: center; +} + +.fit-choice:hover .fit-pill, +.fit-choice.active .fit-pill { + background: rgb(61 220 132 / 0.22); + color: #d9ffe9; +} + +.fit-map { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); + gap: 3px 10px; + margin-top: 8px; + padding: 6px 8px; + border-radius: 6px; + background: var(--bg); color: var(--muted); + font-family: var(--font-mono); + font-size: 11px; +} + +.fit-map.live { + color: var(--text); +} + +.fit-pair { + display: flex; + align-items: center; + gap: 4px; + min-width: 0; +} + +.fit-pair span { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.fit-pair .fit-arrow { + flex: 0 0 auto; + color: var(--on); } .box-select.crossing { fill: rgb(61 220 132 / 0.08); stroke: var(--on); } + +/* ── Context menu ───────────────────────────────────────────────── */ +.ctx { + position: fixed; + z-index: 60; + font-size: 13px; +} + +.ctx-list { + min-width: 220px; + max-width: 320px; + padding: 5px; + border: 1px solid #2d3745; + border-radius: 10px; + background: rgb(22 28 36 / 0.97); + backdrop-filter: blur(8px); + box-shadow: 0 12px 32px rgb(0 0 0 / 0.45), 0 2px 6px rgb(0 0 0 / 0.3); + animation: ctx-in 90ms ease-out; +} + +@keyframes ctx-in { + from { opacity: 0; transform: translateY(-3px) scale(0.98); } +} + +.ctx-head { + padding: 5px 9px 4px; + overflow: hidden; + color: var(--muted); + font-size: 11px; + font-weight: 600; + letter-spacing: 0.04em; + text-overflow: ellipsis; + text-transform: uppercase; + white-space: nowrap; +} + +.ctx-sep { + height: 1px; + margin: 4px 6px; + background: var(--border); +} + +.ctx-li { + position: relative; +} + +.ctx-item { + display: flex; + align-items: center; + gap: 9px; + width: 100%; + min-height: 30px; + padding: 0 9px; + border-radius: 6px; + color: var(--text); + text-align: left; +} + +.ctx-item:hover:not(:disabled), +.ctx-item:focus-visible, +.ctx-li.open > .ctx-item { + background: #232c38; + outline: none; +} + +.ctx-item:disabled { + color: #566273; + cursor: default; +} + +.ctx-item.danger { + color: #ff8787; +} + +.ctx-item.danger:hover { + background: rgb(255 107 107 / 0.12); +} + +.ctx-icon { + flex: 0 0 16px; + width: 16px; + color: var(--muted); +} + +.ctx-icon.checked { + color: var(--on); +} + +.ctx-label { + flex: 1 1 auto; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.ctx-note { + color: var(--muted); + font-size: 12px; + white-space: nowrap; +} + +.ctx-keys { + color: #6b778a; + font-family: var(--font-mono); + font-size: 11px; + white-space: nowrap; +} + +.ctx-chevron { + margin-right: -3px; + color: var(--muted); +} + +.ctx-sub { + position: absolute; + top: -6px; + left: calc(100% + 2px); +} + +.ctx-sub.flip { + right: calc(100% + 2px); + left: auto; +} + +.ctx-sub > .ctx-list { + max-height: 60vh; + overflow-y: auto; +} + +.ctx-swatches { + display: flex; + align-items: center; + gap: 6px; + min-height: 30px; + padding: 0 9px 0 34px; + color: var(--text); +} + +.ctx-dot { + width: 16px; + height: 16px; + border: 2px solid #161c24; + border-radius: 50%; + outline: 1px solid #3a4554; + transition: transform 80ms; +} + +.ctx-dot:hover { + transform: scale(1.18); +} + +.ctx-dot.active { + outline: 2px solid var(--text); +} + +.ctx-input { + display: flex; + align-items: center; + gap: 9px; + padding: 3px 5px 3px 9px; +} + +.ctx-input input { + flex: 1; + min-width: 0; + height: 26px; + padding: 0 8px; + border: 1px solid var(--border); + border-radius: 6px; + background: var(--bg); + color: var(--text); + font-size: 12px; +} + +.ctx-input input:focus { + border-color: var(--accent); + outline: none; +} diff --git a/app/components/editor/BulkSettings.vue b/app/components/editor/BulkSettings.vue index 51fd890..4ed132c 100644 --- a/app/components/editor/BulkSettings.vue +++ b/app/components/editor/BulkSettings.vue @@ -118,23 +118,55 @@ const others = computed(() => { const target = ref('') const chosen = computed(() => others.value.find(o => o.id === target.value) ?? others.value[0]) const targetId = computed({ get: () => chosen.value?.id ?? '', set: v => (target.value = v) }) -/** Where they fit, nearest first: every way to put them on a run of free pins. */ -const fitChoices = computed(() => { - const out: { spot: number; start: number; part: string; pins: string; dist: number }[] = [] +/** Where they fit, one card per part (nearest first), each fit a strip of the pins it takes. */ +const fitCards = computed(() => { + const cards = new Map() ed.fits.value.forEach((f, spot) => { const node = ed.def.value.nodes.find(n => n.id === f.part) - const part = node ? partName(node) : 'part' + const key = `${f.part}:${f.side}` + const card = cards.get(key) ?? { + key, + name: node ? partName(node) : 'Part', + icon: KIND_ICONS[node?.kind ?? ''] ?? 'lucide:cpu', + side: f.side, + dist: f.dist, + choices: [], + } const k = f.mine.length for (let start = 0; start + k <= f.pins.length; start++) { - const a = f.pins[start]! - const b = f.pins[start + k - 1]! - const name = (p: typeof a, i: number) => p.label || String(i + 1) - out.push({ spot, start, part, pins: `${name(a, start)}–${name(b, start + k - 1)}`, dist: Math.hypot(a.x - f.from[0], (a.y + b.y) / 2 - f.from[1]) }) + const pins = f.pins.slice(start, start + k).map((p, i) => p.label || String(start + i + 1)) + card.choices.push({ spot, start, pins: pins.length > 5 ? [pins[0]!, '…', pins[pins.length - 1]!] : pins }) } + card.dist = Math.min(card.dist, f.dist) + cards.set(key, card) }) - return out.sort((a, b) => a.dist - b.dist).slice(0, 8) + return [...cards.values()].sort((a, b) => a.dist - b.dist) }) +const KIND_ICONS: Record = { + chip: 'lucide:cpu', + split: 'lucide:split', + bundle: 'lucide:merge', + panel: 'lucide:sliders-vertical', + nand: 'lucide:square-function', + hex: 'lucide:binary', +} + +/** Which wire goes where for the fit pointed at (or the nearest one), in signal direction. */ +const fitMap = computed(() => { + const h = ed.fitHover.value ?? (fitCards.value[0] ? { spot: fitCards.value[0].choices[0]!.spot, start: fitCards.value[0].choices[0]!.start } : null) + const f = h && ed.fits.value[h.spot] + if (!h || !f) return [] + return f.mine.map((m, i) => { + const node = ed.def.value.nodes.find(n => n.id === m.node) + const mine = node?.label?.trim() || (node ? partName(node) : '?') + const theirs = f.pins[h.start + i]?.label || String(h.start + i + 1) + return f.side === 'out' ? { from: theirs, to: mine } : { from: mine, to: theirs } + }) +}) + +const isHot = (spot: number, start: number) => ed.fitHover.value?.spot === spot && ed.fitHover.value?.start === start + function partName(n: { label?: string; chip?: string; kind: NodeKind; autoLabel?: boolean }) { return (!n.autoLabel && n.label?.trim()) || (n.chip && ed.getDef.value(n.chip)?.name) || KIND_NAMES[n.kind] || n.kind } @@ -258,21 +290,38 @@ function pack() {

Wire them all to

-