From 794acad14095d35e88a9f3c798e4c94fac8fc148 Mon Sep 17 00:00:00 2001 From: "Fabian @ Blax Software" Date: Thu, 22 Oct 2026 06:48:42 +0200 Subject: [PATCH] A finer component boxes, a regrouped parts list with keyboard search, a real green for wires and cables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Box designer: drag pins up or down to open gaps between groups; size (+/−) and turn (R) lamps, displays, screens and drawings; pixels belong to named screens, each placed on its own; displays of the components inside can be shown on the box (off unless ticked); a list of everything the box can show, each optional; the box grows to hold what it shows - Lamps and displays deep inside placed components light up on the box - Parts list: one search box for parts and components (letters in order match too), recently placed parts first, grouped Logic / Inputs / Outputs / Wiring / Notes, then components by group; groups fold away - Keys: / searches the parts list (Enter starts placing), Shift+A or Ctrl+K adds a part at the mouse - Wires and cables get a green; the default swatch shows grey, as the default really is Co-Authored-By: Claude Opus 5.5 (1M context) --- app/assets/css/main.css | 158 +++++++++- app/components/editor/BulkSettings.vue | 13 + app/components/editor/Canvas.vue | 34 +++ app/components/editor/FaceDialog.vue | 391 +++++++++++++++++-------- app/components/editor/Help.vue | 2 + app/components/editor/NodeSettings.vue | 18 +- app/components/editor/NodeView.vue | 10 +- app/components/editor/Palette.vue | 239 ++++++++++----- app/components/editor/QuickAdd.vue | 67 +++++ app/components/editor/WireSettings.vue | 2 +- app/composables/useEditor.ts | 18 ++ app/composables/useMenu.ts | 8 +- app/composables/useParts.ts | 141 +++++++++ app/lib/logic/compile.ts | 3 +- app/lib/logic/geometry.ts | 212 ++++++++++++-- app/lib/logic/project.ts | 14 +- app/lib/logic/types.ts | 22 +- app/lib/match.ts | 17 ++ app/lib/recent.ts | 26 ++ tests/face.test.ts | 75 ++++- 20 files changed, 1221 insertions(+), 249 deletions(-) create mode 100644 app/components/editor/QuickAdd.vue create mode 100644 app/composables/useParts.ts create mode 100644 app/lib/match.ts create mode 100644 app/lib/recent.ts diff --git a/app/assets/css/main.css b/app/assets/css/main.css index 7587f8a..9feea6c 100644 --- a/app/assets/css/main.css +++ b/app/assets/css/main.css @@ -450,6 +450,80 @@ kbd { width: 100%; } +.search.part-search { + margin: 10px 10px 4px; +} + +.search.part-search:focus-within { + border-color: var(--accent); +} + +.search kbd { + padding: 0 5px; + border: 1px solid var(--border); + border-radius: 4px; + color: var(--muted); + font-family: var(--font-mono); + font-size: 10px; +} + +/* Parts list groups: a heading that folds the group away. */ +.group-head { + display: flex; + align-items: center; + gap: 5px; + width: 100%; + padding: 12px 10px 5px; + color: var(--muted); + font-size: 11px; + font-weight: 700; + letter-spacing: 0.06em; + text-align: left; + text-transform: uppercase; +} + +.group-head:hover { + color: var(--text); +} + +.group-count { + margin-left: auto; + font-family: var(--font-mono); + font-size: 10px; + font-weight: 500; + letter-spacing: 0; +} + +.group-tag { + color: var(--muted); + font-size: 11px; +} + +.recent-parts { + display: flex; + flex-wrap: wrap; + gap: 4px; + padding: 0 10px; +} + +.recent-chip { + display: inline-flex; + max-width: 100%; + align-items: center; + gap: 5px; + padding: 3px 8px; + border: 1px solid var(--border); + border-radius: 6px; + background: var(--panel-2); + color: var(--text); + font-size: 12px; + cursor: grab; +} + +.recent-chip:hover { + border-color: var(--accent); +} + .intro { padding: 12px; font-size: 13px; @@ -739,6 +813,7 @@ kbd { .wire.c-red { --w-on: #ff5c5c; --w-off: #6b3337; } .wire.c-orange { --w-on: #ff9f43; --w-off: #6b4a2b; } .wire.c-yellow { --w-on: #ffd93d; --w-off: #625a2e; } +.wire.c-green { --w-on: #3ddc84; --w-off: #2a5a3f; } .wire.c-blue { --w-on: #4dabff; --w-off: #2b4a6b; } .wire.c-purple { --w-on: #b388ff; --w-off: #463768; } .wire.c-pink { --w-on: #ff7ac6; --w-off: #673657; } @@ -851,6 +926,7 @@ kbd { .harness.c-red { --w-on: #ff5c5c; --w-off: #6b3337; } .harness.c-orange { --w-on: #ff9f43; --w-off: #6b4a2b; } .harness.c-yellow { --w-on: #ffd93d; --w-off: #625a2e; } +.harness.c-green { --w-on: #3ddc84; --w-off: #2a5a3f; } .harness.c-blue { --w-on: #4dabff; --w-off: #2b4a6b; } .harness.c-purple { --w-on: #b388ff; --w-off: #463768; } .harness.c-pink { --w-on: #ff7ac6; --w-off: #673657; } @@ -1717,13 +1793,15 @@ kbd { outline: 1px solid var(--border); } +/* The default colour: grey like an unlit wire or a cable's sleeve, struck through. */ .swatch.none { - background: var(--on); + background: linear-gradient(135deg, transparent 45%, #8592a3 45% 55%, transparent 55%), #3b4554; } .swatch.c-red { --w-on: #ff5c5c; } .swatch.c-orange { --w-on: #ff9f43; } .swatch.c-yellow { --w-on: #ffd93d; } +.swatch.c-green { --w-on: #3ddc84; } .swatch.c-blue { --w-on: #4dabff; } .swatch.c-purple { --w-on: #b388ff; } .swatch.c-pink { --w-on: #ff7ac6; } @@ -2643,6 +2721,7 @@ kbd { .lane.c-red { --w-on: #ff5c5c; --w-off: #6b3337; } .lane.c-orange { --w-on: #ff9f43; --w-off: #6b4a2b; } .lane.c-yellow { --w-on: #ffd93d; --w-off: #625a2e; } +.lane.c-green { --w-on: #3ddc84; --w-off: #2a5a3f; } .lane.c-blue { --w-on: #4dabff; --w-off: #2b4a6b; } .lane.c-purple { --w-on: #b388ff; --w-off: #463768; } .lane.c-pink { --w-on: #ff7ac6; --w-off: #673657; } @@ -3077,7 +3156,65 @@ kbd { /* ── Face designer ──────────────────────────────────────────────── */ .modal.face-modal { - width: min(760px, 100%); + width: min(900px, 100%); +} + +.face-body { + display: flex; + gap: 12px; + align-items: flex-start; +} + +.face-side { + flex: 1 1 200px; + min-width: 0; + max-height: 440px; + overflow-y: auto; +} + +.face-side h3 { + margin: 0 0 6px; +} + +.face-side h3 + * { + margin-bottom: 4px; +} + +.face-side .hint { + margin: 0 0 6px; +} + +.face-list { + display: grid; + gap: 1px; + margin-bottom: 12px; +} + +.face-list li { + padding: 2px 4px; + border-radius: 5px; + font-size: 12px; +} + +.face-list li.sel { + background: rgb(76 194 255 / 0.12); +} + +.face-list .check { + display: flex; + align-items: center; + gap: 6px; + min-width: 0; +} + +.face-thing.face-pinbox { + stroke: transparent; + cursor: ns-resize; +} + +.face-thing.face-pinbox:hover, +.face-thing.face-pinbox.sel { + stroke: rgb(76 194 255 / 0.7); } .face-tools { @@ -3223,3 +3360,20 @@ kbd { border-color: var(--accent); color: var(--accent); } + +/* ── Quick add (Shift+A, Ctrl+K) ────────────────────────────────── */ +.quick-add { + position: fixed; + z-index: 60; + width: 300px; + padding-bottom: 6px; + border: 1px solid #2d3745; + border-radius: 10px; + background: rgb(22 28 36 / 0.97); + box-shadow: 0 12px 32px rgb(0 0 0 / 0.45); + animation: ctx-in 90ms ease-out; +} + +.quick-add .item { + cursor: pointer; +} diff --git a/app/components/editor/BulkSettings.vue b/app/components/editor/BulkSettings.vue index 02c26df..a7cb8d2 100644 --- a/app/components/editor/BulkSettings.vue +++ b/app/components/editor/BulkSettings.vue @@ -69,6 +69,10 @@ function rename() { const switches = computed(() => nodes.value.filter(n => n.kind === 'input')) const switchesOn = computed(() => switches.value.filter(n => n.on).length) const colorable = computed(() => only('lamp', 'hex', 'pixel')) +const sameScreen = computed(() => { + const set = new Set(nodes.value.map(n => n.screen ?? '')) + return set.size === 1 ? [...set][0] : '' +}) const color = computed(() => { const set = new Set(nodes.value.map(n => n.color ?? '')) return set.size === 1 ? [...set][0] : null @@ -239,6 +243,15 @@ function pack() { +
Colour
diff --git a/app/components/editor/Canvas.vue b/app/components/editor/Canvas.vue index 5dcfe06..b07b4dc 100644 --- a/app/components/editor/Canvas.vue +++ b/app/components/editor/Canvas.vue @@ -604,6 +604,7 @@ function onWireDown(e: PointerEvent, el: Element, w: Pt) { } function onPointerMove(e: PointerEvent) { + lastClient = { x: e.clientX, y: e.clientY } const w = toWorld(e) cursor.value = w altDown.value = e.altKey @@ -925,6 +926,17 @@ function onKey(e: KeyboardEvent) { e.preventDefault() return openMenuForSelection() } + // Finding parts from the keyboard: / searches the parts list, Shift+A or Ctrl+K adds one at the mouse. + if (e.key === '/' && !mod) { + e.preventDefault() + ed.toggleSidebar('left', true) + ed.partSearch.value++ + return + } + if ((e.shiftKey && key === 'a' && !mod) || (mod && key === 'k')) { + e.preventDefault() + return openQuickAdd() + } // Keys bound to switches, buttons and panel rows win over the shortcuts below. if (!mod && !e.altKey && e.key.length === 1) { const bound = def.value.nodes.filter(n => n.key === key && (n.kind === 'input' || n.kind === 'button')) @@ -1188,6 +1200,27 @@ watch( }, ) +// ── Quick add ─────────────────────────────────────────────────────── +/** The quick-add box: where it opened on screen and on the canvas. */ +const quick = ref<{ x: number; y: number; at: Pt } | null>(null) +let lastClient = { x: 0, y: 0 } + +function openQuickAdd() { + const r = root.value!.getBoundingClientRect() + const inside = lastClient.x >= r.left && lastClient.x <= r.right && lastClient.y >= r.top && lastClient.y <= r.bottom + const x = inside ? lastClient.x : r.left + r.width / 2 + const y = inside ? lastClient.y : r.top + r.height / 3 + quick.value = { x, y, at: toWorld({ clientX: x, clientY: y }) } +} + +function onQuickPick(p: { kind: CircuitNode['kind']; chip?: string }) { + const q = quick.value + quick.value = null + if (!q) return + const { node, links } = landing(p, q.at, false) + ed.addNode(p, node.x, node.y, links) +} + // ── Context menu ──────────────────────────────────────────────────── const menu = ref<{ x: number; y: number; entries: MenuEntry[]; keyboard?: boolean } | null>(null) const { build } = useMenu() @@ -1500,6 +1533,7 @@ defineExpose({ fit, zoomAt }) +
diff --git a/app/components/editor/FaceDialog.vue b/app/components/editor/FaceDialog.vue index 8a0ed3f..4187d00 100644 --- a/app/components/editor/FaceDialog.vue +++ b/app/components/editor/FaceDialog.vue @@ -1,8 +1,9 @@