2020-11-20 00:21:29 +01:00
|
|
|
//
|
|
|
|
// AccountCell.swift
|
|
|
|
// NetNewsWire
|
|
|
|
//
|
|
|
|
// Created by Maurice Parker on 11/19/20.
|
|
|
|
// Copyright © 2020 Ranchero Software. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import AppKit
|
|
|
|
|
|
|
|
class AccountCell: NSTableCellView {
|
|
|
|
|
|
|
|
private var originalImage: NSImage?
|
|
|
|
|
|
|
|
var isImageTemplateCapable = true
|
|
|
|
|
2020-12-09 20:01:12 +01:00
|
|
|
override func prepareForReuse() {
|
|
|
|
originalImage = nil
|
|
|
|
}
|
|
|
|
|
2020-11-20 00:21:29 +01:00
|
|
|
override var backgroundStyle: NSView.BackgroundStyle {
|
|
|
|
didSet {
|
|
|
|
updateImage()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private extension AccountCell {
|
|
|
|
|
|
|
|
func updateImage() {
|
|
|
|
guard isImageTemplateCapable else { return }
|
|
|
|
|
|
|
|
if backgroundStyle != .normal {
|
2020-11-21 00:53:31 +01:00
|
|
|
guard !(imageView?.image?.isTemplate ?? false) else { return }
|
|
|
|
|
2020-11-20 00:21:29 +01:00
|
|
|
originalImage = imageView?.image
|
2020-11-21 00:53:31 +01:00
|
|
|
|
2020-11-20 00:21:29 +01:00
|
|
|
let templateImage = imageView?.image?.copy() as? NSImage
|
|
|
|
templateImage?.isTemplate = true
|
|
|
|
imageView?.image = templateImage
|
|
|
|
} else {
|
|
|
|
guard let originalImage = originalImage else { return }
|
|
|
|
imageView?.image = originalImage
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|