diff --git a/app/assets/css/main.css b/app/assets/css/main.css
index 396f30a..40d6dc8 100644
--- a/app/assets/css/main.css
+++ b/app/assets/css/main.css
@@ -64,6 +64,9 @@ kbd {
.workspace {
--left: 272px;
--right: 280px;
+ /* The top bar keeps the width it has with both panels open, centred, whatever is open. */
+ --bar-inset: calc(280px + 12px);
+ position: relative;
display: grid;
grid-template-columns: var(--left) 1fr;
min-height: 0;
@@ -112,6 +115,7 @@ kbd {
@media (max-width: 820px) {
.workspace,
.workspace.has-selection {
+ --bar-inset: 12px;
grid-template-columns: 1fr;
grid-template-rows: 1fr 40%;
}
@@ -4489,9 +4493,10 @@ table.board {
.top-dock {
position: absolute;
top: 10px;
- left: 12px;
- right: 12px;
+ left: var(--bar-inset);
+ right: var(--bar-inset);
z-index: 30;
+ container-type: inline-size;
pointer-events: none;
}
diff --git a/app/components/editor/App.vue b/app/components/editor/App.vue
index 4ae84b6..1975610 100644
--- a/app/components/editor/App.vue
+++ b/app/components/editor/App.vue
@@ -41,11 +41,11 @@ watch(
-
+
diff --git a/app/components/editor/BottomBar.vue b/app/components/editor/BottomBar.vue
index 1b90341..1dc7433 100644
--- a/app/components/editor/BottomBar.vue
+++ b/app/components/editor/BottomBar.vue
@@ -31,12 +31,19 @@ const open = ref(null)
const anchor = ref(0)
let timer: ReturnType | undefined
-function show(id: string, e: Event) {
+const dock = ref()
+/** Where the list opens: centred above the pointer, kept inside the canvas. */
+function anchorAt(x: number) {
+ const r = dock.value!.getBoundingClientRect()
+ const half = 130
+ anchor.value = Math.min(Math.max(x - r.left, half), Math.max(half, r.width - half))
+}
+
+function show(id: string, e: PointerEvent) {
clearTimeout(timer)
- const el = e.currentTarget as HTMLElement
const go = () => {
+ if (open.value !== id) anchorAt(e.clientX)
open.value = id
- anchor.value = el.offsetLeft + el.offsetWidth / 2
}
// Moving along the bar switches at once; the first one waits a moment.
if (open.value) go()
@@ -52,13 +59,12 @@ function stay() {
clearTimeout(timer)
}
-function toggle(id: string, e: Event) {
+function toggle(id: string, e: MouseEvent) {
if (open.value === id) open.value = null
else {
clearTimeout(timer)
- const el = e.currentTarget as HTMLElement
+ anchorAt(e.clientX)
open.value = id
- anchor.value = el.offsetLeft + el.offsetWidth / 2
}
}
@@ -95,7 +101,7 @@ onBeforeUnmount(() => window.removeEventListener('keydown', onKey, true))
-
+
diff --git a/app/components/editor/ConnectorDialog.vue b/app/components/editor/ConnectorDialog.vue
index 201253c..37f5b2e 100644
--- a/app/components/editor/ConnectorDialog.vue
+++ b/app/components/editor/ConnectorDialog.vue
@@ -55,6 +55,15 @@ function remove(i: number) {
save()
}
+/** Tab in the last line's name, once it is filled in, adds a line and goes on to it. */
+function lineTab(i: number, e: KeyboardEvent) {
+ const lines = type.value?.lines
+ if (e.shiftKey || !lines || i !== lines.length - 1 || !(e.target as HTMLInputElement).value.trim()) return
+ e.preventDefault()
+ setLine(i, e)
+ addLine()
+}
+
function addLine() {
const lines = type.value?.lines
if (!lines || lines.length >= 64) return
@@ -107,7 +116,7 @@ const forward = computed(() => type.value?.lines.filter(l => !l.back).length ??
{{ i }}
-
+
-
+
diff --git a/app/lib/logic/panels.ts b/app/lib/logic/panels.ts
index 3efde3f..89b8f44 100644
--- a/app/lib/logic/panels.ts
+++ b/app/lib/logic/panels.ts
@@ -4,7 +4,7 @@
// input, an output panel on its right a row per output. A docked panel moves
// with its component and follows it when the component gains or loses pins.
-import { chipPins, panelOffsets, rowPin, shapeOf, type DefLookup } from './geometry'
+import { chipPins, rowPin, shapeOf, type DefLookup } from './geometry'
import { pinName } from './labels'
import { lookup, uid } from './ops'
import type { CircuitNode, ComponentDef, PanelRow, Project } from './types'
@@ -177,7 +177,7 @@ export function detachPanel(panel: CircuitNode) {
/**
* Joins panels into one: the top one keeps its rows, the others' rows follow
- * below in order, keeping their spacing, with their wires. The joined panel
+ * below in order, packed without gaps, with their wires. The joined panel
* is free (no longer docked). Returns it with the pin keys that changed
* (old → new), so circuits that place this one can keep their wires; null
* for fewer than two panels.
@@ -190,16 +190,11 @@ export function mergePanels(def: ComponentDef, ids: string[]): { panel: CircuitN
if (panels.length < 2) return null
const [target, ...rest] = panels as [CircuitNode, ...CircuitNode[]]
const rows = target.rows ?? []
- const at = panelOffsets(rows)
- rows.forEach((r, i) => (r.dy = at[i]!))
- let bottom = at.length ? at[at.length - 1]! : -1
const used = new Set(rows.map(r => r.id))
const renamed = new Map()
for (const p of rest) {
const theirs = p.rows ?? []
- const off = panelOffsets(theirs)
- const shift = bottom + 1 - (off[0] ?? 0)
- theirs.forEach((r, i) => {
+ theirs.forEach(r => {
const id = used.has(r.id) ? uid('r') : r.id
used.add(id)
for (const w of def.wires) {
@@ -207,10 +202,11 @@ export function mergePanels(def: ComponentDef, ids: string[]): { panel: CircuitN
if (w.to.node === p.id && w.to.pin === r.id) w.to = { node: target.id, pin: id }
}
renamed.set(rowPin(p.id, r.id), rowPin(target.id, id))
- rows.push({ ...r, id, dy: off[i]! + shift })
+ rows.push({ ...r, id })
})
- if (theirs.length) bottom = rows[rows.length - 1]!.dy!
}
+ // One row under the other, no space between.
+ for (const r of rows) delete r.dy
target.rows = rows
delete target.attach
delete target.skip
@@ -226,8 +222,7 @@ const SINKS = new Set(['output', 'lamp'])
/**
* Turns separate switches, buttons and clocks into one input panel, or
* output pins and lamps into one output panel: a row each, top to bottom,
- * with their names, settings and wires. Rows keep their distance where the
- * parts were spread out. Returns the panel and the pin keys that changed
+ * with their names, settings and wires, packed without gaps. Returns the panel and the pin keys that changed
* (old → new) for circuits that place this one; null when the parts are
* not all of one side or fewer than two.
*/
@@ -240,11 +235,8 @@ export function combineIntoPanel(def: ComponentDef, ids: string[], get: DefLooku
const pinKind = out ? 'output' : 'input'
if (!sel.some(n => n.kind === pinKind)) panel.inner = true
const renamed = new Map()
- let prev = -1
for (const n of sel) {
- const dy = Math.max(prev + 1, n.y - sel[0]!.y)
- prev = dy
- const row: PanelRow = { id: n.id, type: n.kind === 'button' ? 'button' : n.kind === 'clock' ? 'clock' : 'switch', dy }
+ const row: PanelRow = { id: n.id, type: n.kind === 'button' ? 'button' : n.kind === 'clock' ? 'clock' : 'switch' }
const label = n.label?.trim()
if (label && !n.autoLabel) row.label = label
else if (label) row.name = label
diff --git a/tests/panels.test.ts b/tests/panels.test.ts
index 1025179..d714a59 100644
--- a/tests/panels.test.ts
+++ b/tests/panels.test.ts
@@ -29,8 +29,8 @@ describe('merging input panels', () => {
expect(res.panel.attach).toBeUndefined()
const rows = res.panel.rows!
expect(rows.map(r => r.label)).toEqual(['A0', 'B0', 'B1'])
- // Spacing kept: B1 was two rows under B0.
- expect(panelOffsets(rows)).toEqual([0, 1, 3])
+ // Packed: B1 was two rows under B0, now right below it.
+ expect(panelOffsets(rows)).toEqual([0, 1, 2])
// The wire from B1 now leaves the merged panel; the clashing row id got a new one.
const w2 = def.wires.find(w => w.id === 'w2')!
expect(w2.from.node).toBe('p1')
@@ -159,8 +159,8 @@ describe('combining parts into a panel', () => {
['B', 'switch', false, ''],
['GO', 'button', false, ''],
])
- // Spread-out parts keep their distance; B and GO were one row apart.
- expect(panelOffsets(panel.rows!)).toEqual([0, 3, 4])
+ // Packed without gaps, though A and B were three rows apart.
+ expect(panelOffsets(panel.rows!)).toEqual([0, 1, 2])
expect(def.wires[0]!.from).toEqual({ node: panel.id, pin: 'a' })
expect(res.renamed.get("a")).toBe(`${panel.id}:a`)
expect(def.nodes.some(n => ['a', 'b', 'go'].includes(n.id))).toBe(false)