Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion Sources/Bonsplit/Internal/Views/TabBarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ struct TabBarView: View {
.overlay(alignment: .trailing) {
if showSplitButtons {
let shouldShow = presentationMode != "minimal" || isHoveringTabBar
let bg = Color(nsColor: Self.precompositedPaneBackground(for: appearance, focused: isFocused))
let bg = Color(nsColor: Self.buttonBackdropColor(for: appearance, focused: isFocused, style: fadeColorStyle))
ZStack(alignment: .trailing) {
// Backdrop: fade gradient then solid
HStack(spacing: 0) {
Expand Down Expand Up @@ -525,6 +525,39 @@ struct TabBarView: View {
}


private static func buttonBackdropColor(
for appearance: BonsplitConfiguration.Appearance,
focused: Bool,
style: Int
) -> NSColor {
switch style {
case 1: // raw paneBackground forced opaque
return TabBarColors.nsColorPaneBackground(for: appearance).withAlphaComponent(1.0)
case 2: // barBackground (tab bar chrome)
let c = NSColor(TabBarColors.barBackground(for: appearance))
return (c.usingColorSpace(.sRGB) ?? c).withAlphaComponent(1.0)
case 3: // windowBackgroundColor
return NSColor.windowBackgroundColor.withAlphaComponent(1.0)
case 4: // controlBackgroundColor
return NSColor.controlBackgroundColor.withAlphaComponent(1.0)
case 5: // pre-composited barBackground over windowBg
let chrome = NSColor(TabBarColors.barBackground(for: appearance))
let winBg = NSColor.windowBackgroundColor
guard let fg = chrome.usingColorSpace(.sRGB),
let bk = winBg.usingColorSpace(.sRGB) else {
return chrome.withAlphaComponent(1.0)
}
let a: CGFloat = focused ? fg.alphaComponent : fg.alphaComponent * 0.95
let oneMinusA = 1.0 - a
let r = fg.redComponent * a + bk.redComponent * oneMinusA
let g = fg.greenComponent * a + bk.greenComponent * oneMinusA
let b = fg.blueComponent * a + bk.blueComponent * oneMinusA
return NSColor(red: r, green: g, blue: b, alpha: 1.0)
default: // 0: pre-composited paneBackground over windowBg
return precompositedPaneBackground(for: appearance, focused: focused)
}
}
Comment on lines 525 to +559
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 style parameter as raw Int — silent no-op for out-of-range values

Any value outside 0–5 silently falls through to default (style 0). While that's safe today with exactly 6 cases, a raw Int makes it easy to pass an out-of-range value (e.g. an incrementing counter misaligned with case count) without a compile-time error or runtime warning.

If this ever graduates from debug to a real setting, consider a typed enum:

enum BackdropStyle: Int {
    case precompositedPane = 0
    case rawPaneOpaque = 1
    case barBackground = 2
    case windowBackground = 3
    case controlBackground = 4
    case precompositedBar = 5
}

This also makes the switch exhaustive and removes the need for the default fallback.


/// Pre-composite the pane background over the window background to produce
/// a flat opaque color that matches what .background(barFill) looks like
/// after compositing. Avoids double-compositing mismatch on overlays.
Expand Down
Loading