Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions macos/Sources/ConchApp/SceneView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ extension Theme {
/// background, or nothing, so the scene shows.
static var ground: Color { scene.on ? .clear : window }
/// A pane's background, as far as the scene shows through it.
static var paneFill: Color { window.opacity(scene.paneOpacity) }
static var paneFill: Color { window.opacity(scene.underTerminal) }
/// The same behind a pane's terminal, for AppKit.
static var paneTerminal: NSColor { terminal.withAlphaComponent(scene.paneOpacity) }
static var paneTerminal: NSColor { terminal.withAlphaComponent(scene.underTerminal) }
}

/// A surface of the frame — the sidebar, the tab bar, the status bar —
Expand Down
19 changes: 16 additions & 3 deletions macos/Sources/ConchApp/SettingsWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,18 @@ struct SettingsView: View {
@ObservedObject var model: SettingsModel
/// The theme on screen, a preview included.
@ObservedObject var look: ShownTheme
/// For [app] background: the window's scene behind Settings too.
@ObservedObject var store: Store
@State private var query = ""
@FocusState private var searching: Bool

var schema: [SettingsSection] { model.form?.payload.schema ?? [] }

var body: some View {
let scene = store.appLook.scene
HStack(spacing: 0) {
sidebar.frame(width: 248)
.background { if scene.on { Frost(color: Theme.side) } }
Rectangle().fill(Theme.line).frame(width: 1)
ZStack(alignment: .bottom) {
VStack(spacing: 0) {
Expand All @@ -256,10 +260,19 @@ struct SettingsView: View {
if let t = model.toast { SettingsToast(text: t).padding(18).transition(.move(edge: .top).combined(with: .opacity)) }
}
.animation(.spring(response: 0.3, dampingFraction: 0.8), value: model.toast)
.background(Theme.window)
// Frosted over the scene as the main window's frame is; the
// cards on it keep their own colour, so their text reads.
.background { if scene.on { Frost(color: Theme.window) } else { Theme.window } }
}
.frame(minWidth: 900, minHeight: 600)
.background(Theme.window)
.background {
let shown = scene.showing(project: nil)
if shown.scene != .none {
SceneView(scene: shown).ignoresSafeArea()
} else {
Theme.window
}
}
.preferredColorScheme(look.theme.light ? .light : .dark)
// A new theme repaints every view that reads this, in place: not
// .id, as the main window does, which would make the window anew —
Expand Down Expand Up @@ -984,7 +997,7 @@ final class SettingsWindow {
styleMask: [.titled, .closable, .resizable, .miniaturizable], backing: .buffered, defer: false)
w.title = "conch Settings"
w.isReleasedWhenClosed = false
w.contentView = NSHostingView(rootView: SettingsView(model: model, look: model.store.look))
w.contentView = NSHostingView(rootView: SettingsView(model: model, look: model.store.look, store: model.store))
look = model.store.look.$theme.sink { [weak w] t in
w?.appearance = NSAppearance(named: t.light ? .aqua : .darkAqua)
w?.backgroundColor = Theme.ns(t.chrome)
Expand Down
13 changes: 13 additions & 0 deletions macos/Sources/ConchKit/Backgrounds.swift
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,19 @@ public struct SceneLook: Equatable, Sendable {
/// A pane's opacity: solid with no scene, whatever through says.
public var paneOpacity: Double { on ? 1 - through : 1 }

/// The layers under a terminal — the box it sits in and the pane's
/// card — paint this much of their colour. The terminal paints its own
/// background at paneOpacity, so while the scene shows through they
/// paint nothing: each at paneOpacity too, three layers of 70% made
/// a pane 97% solid and the scene never showed in a terminal.
public var underTerminal: Double { paneOpacity < 1 ? 0 : 1 }

/// How solid a pane ends up, its layers stacked: the terminal's own
/// background over the box and the card.
public var paneCoverage: Double {
1 - (1 - paneOpacity) * (1 - underTerminal) * (1 - underTerminal)
}

/// Whether it moves now: never when asked to be still, when macOS's
/// Reduce Motion is on, or in Low Power Mode.
public func moves(reduceMotion: Bool, lowPower: Bool) -> Bool {
Expand Down
13 changes: 13 additions & 0 deletions macos/Tests/ConchKitTests/BackgroundsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,17 @@ import Testing
#expect(start + Fireworks.burst <= Fireworks.duration)
}
}

// A terminal shows the scene by exactly `through`: only the terminal
// paints its background, not the box and the card under it as well.
@Test func throughIsWhatAPaneLetsIn() {
for t in [0.1, 0.24, 0.3, 0.6] {
let l = SceneLook(scene: .pines, through: t)
#expect(abs((1 - l.paneCoverage) - t) < 1e-9)
#expect(l.underTerminal == 0)
}
// Solid panes, and no scene: everything paints, nothing shows.
#expect(SceneLook(scene: .pines, through: 0).underTerminal == 1 && SceneLook(scene: .pines).paneCoverage == 1)
#expect(SceneLook(scene: .none, through: 0.4).underTerminal == 1 && SceneLook(scene: .none, through: 0.4).paneCoverage == 1)
}
}
Loading