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

Merge pull request #77 from Toxblh/customTitle

+ custom title
This commit is contained in:
Anton Palgunov 2018-05-15 20:45:26 +01:00 committed by GitHub
commit 6674b5aef7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
}