2017-05-27 19:43:27 +02:00
|
|
|
//
|
|
|
|
// UnreadIndicatorView.swift
|
2018-08-29 07:18:24 +02:00
|
|
|
// NetNewsWire
|
2017-05-27 19:43:27 +02:00
|
|
|
//
|
|
|
|
// Created by Brent Simmons on 2/16/16.
|
|
|
|
// Copyright © 2016 Ranchero Software, LLC. All rights reserved.
|
|
|
|
//
|
|
|
|
|
2018-02-03 07:51:32 +01:00
|
|
|
import AppKit
|
2017-05-27 19:43:27 +02:00
|
|
|
|
|
|
|
class UnreadIndicatorView: NSView {
|
|
|
|
|
2019-04-13 21:11:44 +02:00
|
|
|
static let unreadCircleDimension: CGFloat = 8.0
|
2017-05-27 19:43:27 +02:00
|
|
|
|
2019-05-21 23:08:16 +02:00
|
|
|
var isEmphasized = false {
|
|
|
|
didSet {
|
|
|
|
if isEmphasized != oldValue {
|
|
|
|
needsDisplay = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var isSelected = false {
|
|
|
|
didSet {
|
|
|
|
if isSelected != oldValue {
|
|
|
|
needsDisplay = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-27 19:43:27 +02:00
|
|
|
static let bezierPath: NSBezierPath = {
|
|
|
|
let r = NSRect(x: 0.0, y: 0.0, width: unreadCircleDimension, height: unreadCircleDimension)
|
|
|
|
return NSBezierPath(ovalIn: r)
|
|
|
|
}()
|
2018-01-06 23:33:16 +01:00
|
|
|
|
2017-05-27 19:43:27 +02:00
|
|
|
override func draw(_ dirtyRect: NSRect) {
|
2019-05-21 23:08:16 +02:00
|
|
|
if isSelected && isEmphasized {
|
|
|
|
NSColor.white.setFill()
|
|
|
|
} else {
|
|
|
|
NSColor.controlAccentColor.setFill()
|
|
|
|
}
|
2017-05-27 19:43:27 +02:00
|
|
|
UnreadIndicatorView.bezierPath.fill()
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|