Skip to content

Commit

Permalink
Instead of tinting the menu bar icon, render it with an outline.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjrusso committed Jan 27, 2022
1 parent 6c68e30 commit a1c2160
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Scoot includes a menu bar icon (an illustration of a Vespa-inspired scooter).

<img align="right" width="256" alt="Scoot Menu Bar Icon" src="./Assets/menu-bar-icon.png" />

* When Scoot is in the foreground, the icon will render with a tint, to make it clearer that Scoot is currently active. (This shouldn't generally be a concern, but it is handy when you're in freestyle mode.)
* When Scoot is in the foreground, the icon will render in an outlined mode, to make it clearer that Scoot is currently active. (This shouldn't generally be a concern, but it is handy when you're in freestyle mode.)
* Additional options are exposed when clicking on the menu bar icon, including a _help_ menu item — which currently opens this README in the user's default browser.

### Keybindings
Expand Down
15 changes: 7 additions & 8 deletions Scoot/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -218,32 +218,31 @@ class AppDelegate: NSObject, NSApplicationDelegate {
let item = NSStatusBar.system.statusItem(
withLength: NSStatusItem.squareLength
)

item.button?.image = menuBarStatusItemDefaultImage
item.button?.image?.size = NSSize(width: 18.0, height: 18.0)

item.menu = menu

self.statusItem = item
}

lazy var menuBarStatusItemDefaultImage: NSImage? = {
let image = NSImage(named: "MenuIcon")
image?.size = NSSize(width: 18.0, height: 18.0)
image?.isTemplate = true
return image
}()

lazy var menuBarStatusItemTintedImage: NSImage? = {
let tintColor = NSColor.systemTeal.withAlphaComponent(0.9)
return menuBarStatusItemDefaultImage?.withTintColor(tintColor)
lazy var menuBarStatusItemOutlinedImage: NSImage? = {
let image = NSImage(named: "MenuIcon-Outlined")
image?.size = NSSize(width: 18.0, height: 18.0)
image?.isTemplate = true
return image
}()

func updateMenuBarStatusItemForInactiveState() {
self.statusItem?.button?.image = menuBarStatusItemDefaultImage
}

func updateMenuBarStatusItemForActiveState() {
self.statusItem?.button?.image = menuBarStatusItemTintedImage
self.statusItem?.button?.image = menuBarStatusItemOutlinedImage
}

// MARK: Activation
Expand Down
12 changes: 12 additions & 0 deletions Scoot/Assets.xcassets/MenuIcon-Outlined.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "Menu Bar Icon - Outlined.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Binary file modified Scoot/Assets.xcassets/MenuIcon.imageset/Menu Bar Icon.pdf
Binary file not shown.

0 comments on commit a1c2160

Please sign in to comment.