diff --git a/Sources/LyrebirdShoeGazeUI/PedalView.swift b/Sources/LyrebirdShoeGazeUI/PedalView.swift index c783c50..a0b37ee 100644 --- a/Sources/LyrebirdShoeGazeUI/PedalView.swift +++ b/Sources/LyrebirdShoeGazeUI/PedalView.swift @@ -422,9 +422,12 @@ public struct PedalView: View { // MARK: - Layout constants - /// Wide enough for three ~55 pt knobs (dial + label + value) plus padding in a - /// single row, so the effect controls never overlap. + /// Base card width — used by the looper's fixed multi-unit layout. Other pedals size to content + /// via ``enclosureColumnWidth`` (see `enclosureWidth(for:)`). private static let enclosureWidth: CGFloat = 220 + /// Per-column width for the content-sized enclosure — one knob/selector/switch slot (a ~50 pt + /// dial plus its caption). Card width = `2·padding + columns·this + (columns−1)·knobSpacing`. + private static let enclosureColumnWidth: CGFloat = 68 private static let enclosureCornerRadius: CGFloat = 12 private static let enclosurePadding: CGFloat = 14 private static let screwInset: CGFloat = 6 @@ -958,19 +961,36 @@ public struct PedalView: View { } } - /// Enclosure width — the base stompbox width scaled by the pedal's `widthUnits` - /// (a control-dense pedal such as the looper asks for a double-width card), widened - /// further to fit a wide vertical-fader bank (e.g. a multi-band graphic EQ) so its - /// faders are never clipped. + /// Enclosure width, sized to the pedal's **content** rather than a flat `widthUnits × base` + /// multiple (which left control-sparse multi-unit cards — amps, the Cabinet — mostly empty). + /// + /// The card fits its widest row: the knob grid (whose column count is capped by `widthUnits` — + /// a dense pedal packs `wideKnobColumnCount` across instead of `knobColumnCount`), the inline + /// selector row, or the switch row — never narrower than the three-slot `Level · Bypass · Mix` + /// footer. It is widened further to fit a vertical-fader bank (e.g. a multi-band graphic EQ) so + /// its faders are never clipped. + /// + /// The looper is the exception: its bespoke three-column layout (timeline · knobs · transport) + /// genuinely needs the full multi-unit width, so it keeps the flat multiple. private func enclosureWidth(for sliders: [PedalSlider]) -> CGFloat { - let unitWidth: CGFloat = PedalView.enclosureWidth * CGFloat(max(1, pedal.widthUnits)) + if pedal is LooperPedal { + return PedalView.enclosureWidth * CGFloat(max(1, pedal.widthUnits)) + } + let columnCap: Int = pedal.widthUnits >= 2 ? PedalView.wideKnobColumnCount : PedalView.knobColumnCount + let knobColumns: Int = min(pedal.effectKnobs.count, columnCap) + let footerColumns: Int = 3 // Level · Bypass · Mix (or Level · Bypass · footer selector) + let columns: Int = max(knobColumns, inlineSelectors.count, pedal.effectSwitches.count, footerColumns) + let contentWidth: CGFloat = 2 * PedalView.enclosurePadding + + CGFloat(columns) * PedalView.enclosureColumnWidth + + CGFloat(max(0, columns - 1)) * PedalView.knobSpacing + let sliderCount: Int = sliders.count - guard sliderCount > 0 else { return unitWidth } + guard sliderCount > 0 else { return contentWidth } let bankContentWidth: CGFloat = CGFloat(sliderCount) * PedalView.sliderBankItemWidth + CGFloat(max(0, sliderCount - 1)) * PedalView.sliderBankSpacing let needed: CGFloat = bankContentWidth + 2 * PedalView.enclosurePadding - return max(unitWidth, needed) + return max(contentWidth, needed) } /// Bottom control row: the `Level` knob, the bypass switch, and the `Mix` knob,