Archived
1

Optimized image resources.

This commit is contained in:
Kim Wittenburg
2015-09-04 02:06:52 +02:00
parent 2c2252f6af
commit b851b70ddb
17 changed files with 87 additions and 68 deletions

View File

@@ -13,6 +13,20 @@ import AppKitPlus
/// only be initialized from a nib or storyboard.
public class TrackTableCellView: AdvancedTableCellView {
// MARK: Types
private struct Images {
/// Caches the tick image for track cells so that it does not need to be
/// reloaded every time a cell is configured.
static let tickImage = NSImage(named: "Tick")?.imageByMaskingWithColor(NSColor.clearColor())
/// Caches the gray tick image for track cells so that it does not need to be
/// reloaded every time a cell is configured.
static let grayTickImage = NSImage(named: "Tick")?.imageByMaskingWithColor(NSColor.lightGrayColor())
}
// MARK: Properties
/// An outlet do display the track number. This acts as a secondary label.
@@ -97,9 +111,9 @@ public class TrackTableCellView: AdvancedTableCellView {
secondaryTextField?.stringValue = track.artistName
trackNumberTextField?.stringValue = "\(track.trackNumber)"
if track.associatedTracks.isEmpty {
imageView?.image = NSImage(named: "TickBW")
imageView?.image = TrackTableCellView.Images.grayTickImage
} else {
imageView?.image = NSImage(named: "Tick")
imageView?.image = TrackTableCellView.Images.tickImage
}
if track.saved {
let aspectRatioConstraint = NSLayoutConstraint(