diff --git a/Packages/ControllerBridgeKit/Sources/ControllerBridgeCore/Coordinator.swift b/Packages/ControllerBridgeKit/Sources/ControllerBridgeCore/Coordinator.swift index cadd6c0..fb74c15 100644 --- a/Packages/ControllerBridgeKit/Sources/ControllerBridgeCore/Coordinator.swift +++ b/Packages/ControllerBridgeKit/Sources/ControllerBridgeCore/Coordinator.swift @@ -34,8 +34,7 @@ public final class Coordinator { /// Logs once per deck when Syndicate's color for it is black, which DeckColors replaces with the default. private func noteBlackSlot(_ numbers: [Int]) -> [Int] { - if numbers.count >= 4, numbers[0] % 2 == 1, (1...7).contains(numbers[0]), DeckColors.isBlack(numbers[1...3]) { - let deck = (numbers[0] + 1) / 2 + if numbers.count >= 4, let deck = DeckColors.deck(forSlot: numbers[0]), DeckColors.isBlack(numbers[1...3]) { if loggedBlackDecks.insert(deck).inserted { log.log("Syndicate's deck \(deck) color is black, which the LC6000's ring can't show; using the default") } diff --git a/Packages/ControllerBridgeKit/Sources/ControllerBridgeCore/DeckColors.swift b/Packages/ControllerBridgeKit/Sources/ControllerBridgeCore/DeckColors.swift index c483e10..bf5bbc6 100644 --- a/Packages/ControllerBridgeKit/Sources/ControllerBridgeCore/DeckColors.swift +++ b/Packages/ControllerBridgeKit/Sources/ControllerBridgeCore/DeckColors.swift @@ -41,11 +41,15 @@ public struct DeckColors: Equatable, Sendable, Codable { 4: [0x62, 0x92, 0x9E], ]) + /// The deck whose color a cue palette slot holds: slots 1, 3, 5 and 7 are decks 1-4 (#123). Nil for any other. + public static func deck(forSlot slot: Int) -> Int? { + slot % 2 == 1 && (1...7).contains(slot) ? (slot + 1) / 2 : nil + } + /// After a ColorPalette message ([slot, r, g, b]): the deck whose slot it is (slot 2N−1 is deck N) takes the color. /// Nil when the message isn't a deck's slot, so nothing needs repainting. public func updated(byPalette numbers: [Int]) -> DeckColors? { - guard numbers.count >= 4, numbers[0] % 2 == 1, (1...7).contains(numbers[0]) else { return nil } - let deck = (numbers[0] + 1) / 2 + guard numbers.count >= 4, let deck = Self.deck(forSlot: numbers[0]) else { return nil } var out = self // Black would turn the ring off: that deck keeps its default color. out.rgb[deck] = Self.isBlack(numbers[1...3]) ? Self.defaults[deck] : Array(numbers[1...3]) diff --git a/Packages/ControllerBridgeKit/Sources/ControllerBridgePresentation/Palette.swift b/Packages/ControllerBridgeKit/Sources/ControllerBridgePresentation/Palette.swift index eb02fa0..bef7dc4 100644 --- a/Packages/ControllerBridgeKit/Sources/ControllerBridgePresentation/Palette.swift +++ b/Packages/ControllerBridgeKit/Sources/ControllerBridgePresentation/Palette.swift @@ -68,20 +68,4 @@ public enum Palette { accent: RGB(hex: 0x00FF48), // --signal onAccent: RGB(hex: 0x111111) // --on-signal ) - - // The dark theme's colors by name, for code that doesn't follow the appearance yet. - public static let background = dark.background - public static let panel = dark.panel - public static let button = dark.button - public static let buttonRaised = dark.buttonRaised - public static let hairline = dark.hairline - public static let buttonEdge = dark.buttonEdge - public static let selectedBar = dark.selectedBar - public static let text = dark.text - public static let caption = dark.caption - public static let live = dark.live - public static let attention = dark.attention - public static let error = dark.error - public static let key = dark.key - public static let accent = dark.accent } diff --git a/Packages/ControllerBridgeKit/Sources/ControllerBridgePresentation/StatusPresentation.swift b/Packages/ControllerBridgeKit/Sources/ControllerBridgePresentation/StatusPresentation.swift index fb82fcb..176ad50 100644 --- a/Packages/ControllerBridgeKit/Sources/ControllerBridgePresentation/StatusPresentation.swift +++ b/Packages/ControllerBridgeKit/Sources/ControllerBridgePresentation/StatusPresentation.swift @@ -366,9 +366,6 @@ public struct StatusPresentation: Equatable, Sendable { } extension StatusLight.Tone { - /// The tone in the dark theme. - public var color: RGB { color(in: Palette.dark) } - /// The tone in a theme (#127): each passes AA on that theme's surfaces. public func color(in palette: ThemePalette) -> RGB { switch self { diff --git a/Packages/ControllerBridgeKit/Tests/ControllerBridgePresentationTests/StatusPresentationTests.swift b/Packages/ControllerBridgeKit/Tests/ControllerBridgePresentationTests/StatusPresentationTests.swift index 0781eca..2ddaef9 100644 --- a/Packages/ControllerBridgeKit/Tests/ControllerBridgePresentationTests/StatusPresentationTests.swift +++ b/Packages/ControllerBridgeKit/Tests/ControllerBridgePresentationTests/StatusPresentationTests.swift @@ -50,7 +50,6 @@ struct StatusPresentationTests { (.error, 0xE06C6C), ] as [(StatusLight.Tone, UInt32)]) func toneColors(tone: StatusLight.Tone, hex: UInt32) { - #expect(tone.color == RGB(hex: hex)) #expect(tone.color(in: Palette.dark) == RGB(hex: hex)) }