mac: use custom touch bar item and slider instead of a touch bar slider

the NSSliderTouchBarItem seem to be broken in a way it can't be fixed.
it has constraints set by default that can't be removed and lead to
warnings and render performance regressions.

instead of using the preconfigured NSSliderTouchBarItem we use a custom
touch bar item (NSCustomTouchBarItem) with a slider, which essential are
the same. this way we can configure our constraints ourselves, which
aren't needed in the first place.

Fixes: #7047
This commit is contained in:
der richter 2021-01-19 19:39:56 +01:00
parent 968faef867
commit aa00ad06aa
1 changed files with 9 additions and 9 deletions

View File

@ -131,13 +131,13 @@
makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier
{
if ([self.touchbarItems[identifier][@"type"] isEqualToString:@"slider"]) {
NSSliderTouchBarItem *tbItem = [[NSSliderTouchBarItem alloc] initWithIdentifier:identifier];
tbItem.slider.minValue = 0.0f;
tbItem.slider.maxValue = 100.0f;
tbItem.target = self;
tbItem.action = @selector(seekbarChanged:);
NSCustomTouchBarItem *tbItem = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier];
NSSlider *slider = [NSSlider sliderWithTarget:self action:@selector(seekbarChanged:)];
slider.minValue = 0.0f;
slider.maxValue = 100.0f;
tbItem.view = slider;
tbItem.customizationLabel = self.touchbarItems[identifier][@"name"];
[self.touchbarItems[identifier] setObject:tbItem.slider forKey:@"view"];
[self.touchbarItems[identifier] setObject:slider forKey:@"view"];
return tbItem;
} else if ([self.touchbarItems[identifier][@"type"] isEqualToString:@"button"]) {
NSCustomTouchBarItem *tbItem = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier];
@ -261,11 +261,11 @@
[self.app queueCommand:(char *)[self.touchbarItems[identifier][@"cmd"] UTF8String]];
}
- (void)seekbarChanged:(NSSliderTouchBarItem *)sender
- (void)seekbarChanged:(NSSlider *)slider
{
NSString *identifier = [self getIdentifierFromView:sender.slider];
NSString *identifier = [self getIdentifierFromView:slider];
NSString *seek = [NSString stringWithFormat:
self.touchbarItems[identifier][@"cmd"], sender.slider.doubleValue];
self.touchbarItems[identifier][@"cmd"], slider.doubleValue];
[self.app queueCommand:(char *)[seek UTF8String]];
}