Skip to content

Commit

Permalink
Share colors between view and TouchBar
Browse files Browse the repository at this point in the history
  • Loading branch information
xzzz9097 committed Jan 11, 2017
1 parent 892c40c commit ed1bd4b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
8 changes: 0 additions & 8 deletions Muse/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,6 @@ class ViewController: NSViewController {
} else if let image = object as? NSImage {
fullSongArtworkView.image = image
}

// Update the colors with a completion handler
// This avoids blocking the main UI thread
fullSongArtworkView.image?.getColors(scaleDownSize: NSMakeSize(25, 25)) { colors in
// We also set an aggressive scaling size
// to optimize performace and memory usage
self.colorViews(with: colors)
}
}

func colorButtonImages(with color: NSColor) {
Expand Down
13 changes: 10 additions & 3 deletions Muse/WindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -702,10 +702,17 @@ class WindowController: NSWindowController, NSWindowDelegate {
// TODO: Move this elsewhere
songArtworkTitleButton.image = image.resized(to: NSMakeSize(30, 30))

// Set bezel color
// TODO: Share this colors with ViewController
image.getColors(scaleDownSize: NSMakeSize(10, 10)) { colors in
// Fetch image colors
// We also set an aggressive scaling size
// to optimize performace and memory usage
image.getColors(scaleDownSize: NSMakeSize(25, 25)) { colors in
// Set colors on TouchBar button
self.songArtworkTitleButton.bezelColor = colors.primary.blended(withFraction: 0.5, of: .darkGray)

// Set colors on main view
self.onViewController { controller in
controller.colorViews(with: colors)
}
}
}

Expand Down

0 comments on commit ed1bd4b

Please sign in to comment.