mirror of
https://github.com/Toxblh/MTMR.git
synced 2026-01-11 17:38:38 +00:00
fix for colors in non-bordered buttons
This commit is contained in:
parent
4a03ba79ec
commit
12796d6387
@ -21,7 +21,10 @@ class CustomButtonTouchBarItem: NSCustomTouchBarItem, NSGestureRecognizerDelegat
|
||||
self.longTapClosure = callbackLong
|
||||
|
||||
super.init(identifier: identifier)
|
||||
button = NSButton(title: title, target: self, action: nil)
|
||||
button = NSButton(title: title, target: nil, action: nil)
|
||||
button.cell = NSButtonCell()
|
||||
button.isBordered = true
|
||||
button.bezelStyle = .rounded
|
||||
button.title = title
|
||||
self.view = button
|
||||
|
||||
|
||||
@ -211,21 +211,26 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
if case .width(let value)? = item.additionalParameters[.width], let widthBarItem = barItem as? CanSetWidth {
|
||||
widthBarItem.setWidth(value: value)
|
||||
}
|
||||
if case .bordered(let bordered)? = item.additionalParameters[.bordered], let item = barItem as? CustomButtonTouchBarItem {
|
||||
item.button.isBordered = bordered
|
||||
if bordered {
|
||||
item.button.bezelStyle = .rounded
|
||||
}
|
||||
}
|
||||
if case .background(let color)? = item.additionalParameters[.background], let item = barItem as? CustomButtonTouchBarItem {
|
||||
if item.button.cell?.isBordered == false {
|
||||
item.button.cell = NSButtonCell()
|
||||
item.button.cell?.isBordered = true
|
||||
}
|
||||
item.button.bezelColor = color
|
||||
(item.button.cell as? NSButtonCell)?.backgroundColor = color
|
||||
}
|
||||
if case .image(let source)? = item.additionalParameters[.image], let item = barItem as? CustomButtonTouchBarItem {
|
||||
let button = item.button!
|
||||
button.imageScaling = .scaleProportionallyDown
|
||||
button.imagePosition = .imageLeading
|
||||
button.imageHugsTitle = true
|
||||
button.cell?.image = source.image
|
||||
button.bezelColor = .clear
|
||||
}
|
||||
if case .bordered(let bordered)? = item.additionalParameters[.bordered], let item = barItem as? CustomButtonTouchBarItem {
|
||||
item.button.isBordered = bordered
|
||||
item.button.bezelStyle = bordered ? .rounded : .inline
|
||||
}
|
||||
if case .background(let color)? = item.additionalParameters[.background], let item = barItem as? CustomButtonTouchBarItem {
|
||||
item.button.bezelColor = color
|
||||
(item.button.cell as? NSButtonCell)?.backgroundColor = color
|
||||
button.image = source.image
|
||||
}
|
||||
return barItem
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user