Skip to content

Commit

Permalink
Merge pull request #395 from zonble/master
Browse files Browse the repository at this point in the history
Use template images in the Preference pane
  • Loading branch information
lukhnos authored Dec 4, 2023
2 parents bddbb50 + 23db9f4 commit 627292e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
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

0 comments on commit 627292e

Please sign in to comment.