1
0
mirror of https://github.com/Toxblh/MTMR.git synced 2026-01-11 17:38:38 +00:00

+ custom title

This commit is contained in:
ad 2018-05-15 15:11:34 +03:00
parent cd16c09dbd
commit f83f331a99
2 changed files with 8 additions and 0 deletions

View File

@ -355,6 +355,7 @@ enum GeneralParameter {
case align(_: Align)
case bordered(_: Bool)
case background(_:NSColor)
case title(_:String)
}
struct GeneralParameters: Decodable {
@ -366,6 +367,7 @@ struct GeneralParameters: Decodable {
case align
case bordered
case background
case title
}
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
@ -384,6 +386,9 @@ struct GeneralParameters: Decodable {
if let backgroundColor = try container.decodeIfPresent(String.self, forKey: .background)?.hexColor {
result[.background] = .background(backgroundColor)
}
if let title = try container.decodeIfPresent(String.self, forKey: .title) {
result[.title] = .title(title)
}
parameters = result
}
}

View File

@ -275,6 +275,9 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
if case .image(let source)? = item.additionalParameters[.image], let item = barItem as? CustomButtonTouchBarItem {
item.image = source.image
}
if case .title(let value)? = item.additionalParameters[.title], let item = barItem as? CustomButtonTouchBarItem {
item.title = value
}
return barItem
}