30e96b8ee1
- StereoRouteControlView: 4-way StereoRoute segmented selector + L/R/DRY source LEDs, bound to StereoSplitSection.route (observes collector gains). - StereoSplitSectionView: route control + L/R branch pedal rows. - StereoWidthBadge: MONO/STEREO pill from PedalBoard.width. - Expose StereoSplitSection.collector publicly for UI observation. - Document UI + preset scope in stereo-routing-design.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
76 lines
2.7 KiB
Swift
76 lines
2.7 KiB
Swift
// StereoWidthBadge.swift
|
|
// Lyrebird
|
|
//
|
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
import SwiftUI
|
|
|
|
/// A small pill badge indicating whether a chain point is mono (width 1) or stereo (width 2).
|
|
///
|
|
/// Pass `PedalBoard.width` (or any channel count). Width `2` shows a cyan "STEREO" pill;
|
|
/// anything else shows a dim "MONO" pill. Width is structural (it changes only when pedals
|
|
/// are added or removed), so the badge does not need to observe live parameter state — the
|
|
/// surrounding board view rebuilds when the chain changes.
|
|
///
|
|
/// ## Usage
|
|
///
|
|
/// ```swift
|
|
/// StereoWidthBadge(width: board.width)
|
|
/// ```
|
|
public struct StereoWidthBadge: View {
|
|
|
|
// MARK: - Layout constants
|
|
|
|
private static let fontSize: CGFloat = 9
|
|
private static let paddingH: CGFloat = 7
|
|
private static let paddingV: CGFloat = 3
|
|
private static let cornerRadius: CGFloat = 4
|
|
private static let stereoWidth: Int = 2
|
|
private static let monoFillOpacity: Double = 0.14
|
|
private static let stereoFillOpacity: Double = 0.85
|
|
private static let monoTextOpacity: Double = 0.45
|
|
private static let borderOpacity: Double = 0.30
|
|
private static let borderLineWidth: CGFloat = 0.5
|
|
|
|
// MARK: - Properties
|
|
|
|
private let width: Int
|
|
|
|
// MARK: - Init
|
|
|
|
/// Creates a width badge.
|
|
///
|
|
/// - Parameter width: Channel count at this chain point (`PedalBoard.width`). `2` renders
|
|
/// the stereo badge; any other value renders the mono badge.
|
|
public init(width: Int) {
|
|
self.width = width
|
|
}
|
|
|
|
// MARK: - Body
|
|
|
|
public var body: some View {
|
|
let isStereo: Bool = (width == StereoWidthBadge.stereoWidth)
|
|
Text(isStereo ? "STEREO" : "MONO")
|
|
.font(.system(size: StereoWidthBadge.fontSize, weight: .bold, design: .monospaced))
|
|
.foregroundStyle(isStereo ? Color.black : Color.white.opacity(StereoWidthBadge.monoTextOpacity))
|
|
.padding(.horizontal, StereoWidthBadge.paddingH)
|
|
.padding(.vertical, StereoWidthBadge.paddingV)
|
|
.background(
|
|
RoundedRectangle(cornerRadius: StereoWidthBadge.cornerRadius)
|
|
.fill(
|
|
isStereo
|
|
? Color.cyan.opacity(StereoWidthBadge.stereoFillOpacity)
|
|
: Color.white.opacity(StereoWidthBadge.monoFillOpacity)
|
|
)
|
|
.overlay(
|
|
RoundedRectangle(cornerRadius: StereoWidthBadge.cornerRadius)
|
|
.stroke(
|
|
Color.white.opacity(StereoWidthBadge.borderOpacity),
|
|
lineWidth: StereoWidthBadge.borderLineWidth
|
|
)
|
|
)
|
|
)
|
|
}
|
|
}
|