Skip to content

Commit 4daa69f

Browse files
committed
feat: adapt panel window corners to appearance
1 parent 4764474 commit 4daa69f

3 files changed

Lines changed: 26 additions & 3 deletions

File tree

‎EdgeMark/Core/Settings/AppSettings.swift‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,10 @@ final class AppSettings {
195195
/// Whether supported systems use Liquid Glass for controls and transient surfaces.
196196
/// Defaults on; disabling it restores EdgeMark's classic material and hover styling.
197197
var liquidGlassEnabled: Bool = true {
198-
didSet { UserDefaults.standard.set(liquidGlassEnabled, forKey: "liquidGlassEnabled") }
198+
didSet {
199+
UserDefaults.standard.set(liquidGlassEnabled, forKey: "liquidGlassEnabled")
200+
NotificationCenter.default.post(name: .liquidGlassSettingChanged, object: nil)
201+
}
199202
}
200203

201204
/// Whether note creation and modification dates remain visible below the title.
@@ -409,6 +412,7 @@ extension AppSettings.SortBy {
409412

410413
extension Notification.Name {
411414
static let editorFontChanged = Notification.Name("editorFontChanged")
415+
static let liquidGlassSettingChanged = Notification.Name("liquidGlassSettingChanged")
412416
static let previewSettingsChanged = Notification.Name("previewSettingsChanged")
413417
}
414418

‎EdgeMark/Core/Window/SidePanelController.swift‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class KeyableWindow: NSWindow {
1818
// MARK: - SidePanelController
1919

2020
final class SidePanelController: NSWindowController {
21-
private let cornerRadius: CGFloat = 10
2221
private(set) var isShown = false
2322
private var isAnimating = false
2423
private var animationGeneration = 0
@@ -80,7 +79,7 @@ final class SidePanelController: NSWindowController {
8079
hostingView.frame = containerView.bounds
8180
hostingView.autoresizingMask = [.width, .height]
8281
hostingView.wantsLayer = true
83-
hostingView.layer?.cornerRadius = 10
82+
hostingView.layer?.cornerRadius = Self.windowCornerRadius(using: appSettings)
8483
hostingView.layer?.maskedCorners = Self.maskedCorners(for: side)
8584
hostingView.layer?.masksToBounds = true
8685
containerView.addSubview(hostingView)
@@ -270,6 +269,13 @@ final class SidePanelController: NSWindowController {
270269
object: nil,
271270
)
272271

272+
NotificationCenter.default.addObserver(
273+
self,
274+
selector: #selector(handleLiquidGlassSettingChanged),
275+
name: .liquidGlassSettingChanged,
276+
object: nil,
277+
)
278+
273279
// Listen for pin state changes to toggle window draggability
274280
NotificationCenter.default.addObserver(
275281
self,
@@ -286,6 +292,10 @@ final class SidePanelController: NSWindowController {
286292

287293
// MARK: - Settings Change
288294

295+
@objc private func handleLiquidGlassSettingChanged() {
296+
contentHostingView?.layer?.cornerRadius = Self.windowCornerRadius(using: appSettings)
297+
}
298+
289299
@objc private func handleSettingsChanged() {
290300
guard let window, let containerView = window.contentView else { return }
291301

@@ -647,6 +657,13 @@ final class SidePanelController: NSWindowController {
647657
return (shown, hidden)
648658
}
649659

660+
/// Match the shell to the active macOS appearance generation.
661+
private static func windowCornerRadius(using settings: AppSettings) -> CGFloat {
662+
settings.usesLiquidGlass
663+
? SurfaceMetrics.liquidGlassWindowCornerRadius
664+
: SurfaceMetrics.classicWindowCornerRadius
665+
}
666+
650667
/// Corner mask for the given edge side.
651668
private static func maskedCorners(for side: EdgeSide) -> CACornerMask {
652669
switch side {

‎EdgeMark/UI/Components/SurfaceMetrics.swift‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import CoreGraphics
55
enum SurfaceMetrics {
66
/// Matches the continuous 12-point corners of native grouped Settings sections.
77
static let panelCornerRadius: CGFloat = 12
8+
static let classicWindowCornerRadius: CGFloat = 10
9+
static let liquidGlassWindowCornerRadius: CGFloat = 16
810
static let panelSectionSpacing: CGFloat = 8
911
static let classicControlCornerRadius: CGFloat = 6
1012
static let compactControlSize: CGFloat = 28

0 commit comments

Comments
 (0)