Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use template images in the Preference pane #395

Merged
merged 4 commits into from
Dec 4, 2023
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
23 changes: 12 additions & 11 deletions Source/InputMethodController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -269,27 +269,28 @@ extension McBopomofoInputMethodController {
let previous = state
state = newState

if let newState = newState as? InputState.Deactivated {
switch newState {
case let newState as InputState.Deactivated:
handle(state: newState, previous: previous, client: client)
// Force transition to Empty, so that when activateServer is
// invoked again, the controller is already in the Empty state.
state = .Empty()
} else if let newState = newState as? InputState.Empty {
case let newState as InputState.Empty:
handle(state: newState, previous: previous, client: client)
} else if let newState = newState as? InputState.EmptyIgnoringPreviousState {
case let newState as InputState.EmptyIgnoringPreviousState:
handle(state: newState, previous: previous, client: client)
} else if let newState = newState as? InputState.Committing {
case let newState as InputState.Committing:
handle(state: newState, previous: previous, client: client)
} else if let newState = newState as? InputState.Inputting {
case let newState as InputState.Inputting:
handle(state: newState, previous: previous, client: client)
} else if let newState = newState as? InputState.Marking {
case let newState as InputState.Marking:
handle(state: newState, previous: previous, client: client)
} else if let newState = newState as? InputState.ChoosingCandidate {
case let newState as InputState.ChoosingCandidate:
handle(state: newState, previous: previous, client: client)
} else if let newState = newState as? InputState.AssociatedPhrases {
case let newState as InputState.AssociatedPhrases:
handle(state: newState, previous: previous, client: client)
} else if let newState = newState as? InputState.Big5 {
case let newState as InputState.Big5:
handle(state: newState, previous: previous, client: client)
default:
break
}
}

Expand Down
9 changes: 8 additions & 1 deletion Source/PreferencesWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,14 @@ fileprivate let kWindowTitleHeight: CGFloat = 78
return newImage
}

menuItem.image = resize(image)
let resizedImage = resize(image)
// On newer version of macOS, the icons became black and white
// so we make them template images so it could look better
// on dark mode.
if #available(macOS 10.16, *) {
resizedImage.isTemplate = true
}
menuItem.image = resizedImage
}

if sourceID == "com.apple.keylayout.US" {
Expand Down