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

Merge pull request #19 from ad/master

* prevent crash on return from sleep (removed lockFocus/unlockFocus)
This commit is contained in:
Anton Palgunov 2018-04-15 11:58:50 +01:00 committed by GitHub
commit 75ea408370
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -26,6 +26,10 @@ class BrightnessViewController: NSCustomTouchBarItem {
fatalError("init(coder:) has not been implemented")
}
deinit {
sliderItem.unbind(NSBindingName.value)
}
@objc func updateBrightnessSlider() {
DispatchQueue.main.async {
self.sliderItem.floatValue = self.getBrightness() * 100

View File

@ -56,6 +56,10 @@ class VolumeViewController: NSCustomTouchBarItem {
fatalError("init(coder:) has not been implemented")
}
deinit {
sliderItem.unbind(NSBindingName.value)
}
@objc func sliderValueChanged(_ sender: Any) {
if let sliderItem = sender as? NSSlider {
_ = setInputGain(Float32(sliderItem.intValue)/100.0)
@ -139,15 +143,11 @@ class CustomSliderCell: NSSliderCell {
_currentKnobRect = knobRect;
drawBar(inside: _barRect, flipped: false)
self.controlView?.lockFocus()
let newOriginX:CGFloat = knobRect.origin.x *
(_barRect.size.width - (knobImage.size.width - knobRect.size.width)) / _barRect.size.width;
knobImage.draw(at: NSPoint(x: newOriginX, y: knobRect.origin.y+3), from: NSRect(x: 0, y: 0, width: knobImage.size.width, height: knobImage.size.height), operation: NSCompositingOperation.sourceOver, fraction: 1)
self.controlView?.unlockFocus()
}
override func drawBar(inside aRect: NSRect, flipped: Bool) {