Skip to content

Commit

Permalink
Fix ColorPicker's opacity for macOS 14
Browse files Browse the repository at this point in the history
  • Loading branch information
tattn committed Oct 7, 2023
1 parent df42074 commit 9b30ed3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/xcode/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let package = Package(
defaultLocalization: "en",
platforms: [.macOS(.v13)],
products: [
.library(name: "VCam", targets: ["VCamUI", "VCamMedia", "VCamBridge"]),
.library(name: "VCam", targets: ["VCamUI", "VCamMedia", "VCamBridge", "VCamWorkaround"]),
.library(name: "VCamMedia", targets: ["VCamMedia"]),
.library(name: "VCamCamera", targets: ["VCamCamera"]),

Expand All @@ -32,6 +32,7 @@ let package = Package(
.target(name: "VCamLogger", dependencies: []),
.target(name: "VCamDefaults", dependencies: []),
.target(name: "VCamAppExtension", dependencies: []),
.target(name: "VCamWorkaround", dependencies: []),

.testTarget(name: "VCamEntityTests", dependencies: ["VCamEntity"]),
.testTarget(name: "VCamCameraTests", dependencies: ["VCamCamera"]),
Expand Down
File renamed without changes.
19 changes: 19 additions & 0 deletions app/xcode/Sources/VCamWorkaround/Workaround.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// Workaround.swift
//
//
// Created by Tatsuya Tanaka on 2023/10/07.
//

import AppKit

public enum Workaround {
public static func fixColorPickerOpacity_macOS14() {
if #available(macOS 14, *) {
// The root cause is unknown, but under specific conditions on macOS 14,
// changes to the opacity of SwiftUI's ColorPicker might not be reflected.
// Calling the following can avoid the issue.
NSColorPanel.shared.showsAlpha = true
}
}
}

0 comments on commit 9b30ed3

Please sign in to comment.