Skip to content

Commit

Permalink
fix: color panel fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
superhighfives committed Dec 21, 2024
1 parent 5752670 commit 1863be7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
2 changes: 2 additions & 0 deletions Pika/Utilities/Eyedroppers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ class Eyedropper: ObservableObject {
panel.titleVisibility = .visible
panel.setTarget(self)
panel.color = color
panel.mode = .RGB
panel.colorSpace = Defaults[.colorSpace]
panel.orderFrontRegardless()
panel.setAction(#selector(colorDidChange))
panel.isContinuous = true
Expand Down
7 changes: 6 additions & 1 deletion Pika/Views/EyedropperItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ struct EyedropperItem: View {
.onReceive(NotificationCenter.default.publisher(
for: Notification.Name("triggerSystemPicker\(eyedropper.type.rawValue.capitalized)")))
{ _ in
eyedropper.picker()
let panel = NSColorPanel.shared
if panel.isVisible, panel.title == "\(eyedropper.type.rawValue.capitalized)" {
panel.close()
} else {
eyedropper.picker()
}
}
.onReceive(NotificationCenter.default.publisher(
for: Notification.Name("triggerFormatHex")))
Expand Down
30 changes: 16 additions & 14 deletions Pika/Views/PreferencesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -213,24 +213,26 @@ struct PreferencesView: View {
Text(PikaText.textFormatDescription).font(.system(size: 13, weight: .medium))
) {
Picker(PikaText.textSpaceTitle, selection:
$colorSpace.onChange(perform: { Defaults[.colorSpace] = $0 }))
{
ForEach(primarySpaces, id: \.self) { value in
if value == systemDefaultSpace {
Text("\(PikaText.textSystemDefault) (\(value.localizedName!))")
.tag(value)
} else {
$colorSpace.onChange(perform: {
NSColorPanel.shared.close()
Defaults[.colorSpace] = $0
})) {
ForEach(primarySpaces, id: \.self) { value in
if value == systemDefaultSpace {
Text("\(PikaText.textSystemDefault) (\(value.localizedName!))")
.tag(value)
} else {
Text(value.localizedName!)
.tag(value)
}
}
Divider()
ForEach(availableSpaces, id: \.self) { value in
Text(value.localizedName!)
.tag(value)
}
}
Divider()
ForEach(availableSpaces, id: \.self) { value in
Text(value.localizedName!)
.tag(value)
}
}
.labelsHidden()
.labelsHidden()
}
}
}
Expand Down

0 comments on commit 1863be7

Please sign in to comment.