ui(layout): size pedal card width to content, not widthUnits × base
Cards were `220 × widthUnits` wide, so control-sparse multi-unit pedals sat mostly empty (a 3-unit amp was 660px for a 4-knob row needing ~270; the 2-unit Cabinet was 440 for three selectors). Size the enclosure to its widest actual row instead — knob grid (columns capped by widthUnits), inline selectors, or switches — floored at the 3-slot Level·Bypass·Mix footer, and still widened for a vertical-fader bank. New: Cabinet 440→252, Bluesbreaker 660→330, Boutique/Dual 880→330; 1-unit pedals ~252. widthUnits now only sets the knob-column cap (≥2 packs 4 across), not raw width, so all 4-knob amps land at the same tight width regardless of their 3/4 unit value. The looper keeps the flat multiple — its bespoke three-column timeline/knobs/transport layout genuinely needs the wide card. 675 tests pass (view geometry; no logic change). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user