mirror of https://github.com/mpv-player/mpv
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:
parent
968faef867
commit
aa00ad06aa
|
@ -131,13 +131,13 @@
|
||||||
makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier
|
makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier
|
||||||
{
|
{
|
||||||
if ([self.touchbarItems[identifier][@"type"] isEqualToString:@"slider"]) {
|
if ([self.touchbarItems[identifier][@"type"] isEqualToString:@"slider"]) {
|
||||||
NSSliderTouchBarItem *tbItem = [[NSSliderTouchBarItem alloc] initWithIdentifier:identifier];
|
NSCustomTouchBarItem *tbItem = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier];
|
||||||
tbItem.slider.minValue = 0.0f;
|
NSSlider *slider = [NSSlider sliderWithTarget:self action:@selector(seekbarChanged:)];
|
||||||
tbItem.slider.maxValue = 100.0f;
|
slider.minValue = 0.0f;
|
||||||
tbItem.target = self;
|
slider.maxValue = 100.0f;
|
||||||
tbItem.action = @selector(seekbarChanged:);
|
tbItem.view = slider;
|
||||||
tbItem.customizationLabel = self.touchbarItems[identifier][@"name"];
|
tbItem.customizationLabel = self.touchbarItems[identifier][@"name"];
|
||||||
[self.touchbarItems[identifier] setObject:tbItem.slider forKey:@"view"];
|
[self.touchbarItems[identifier] setObject:slider forKey:@"view"];
|
||||||
return tbItem;
|
return tbItem;
|
||||||
} else if ([self.touchbarItems[identifier][@"type"] isEqualToString:@"button"]) {
|
} else if ([self.touchbarItems[identifier][@"type"] isEqualToString:@"button"]) {
|
||||||
NSCustomTouchBarItem *tbItem = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier];
|
NSCustomTouchBarItem *tbItem = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier];
|
||||||
|
@ -261,11 +261,11 @@
|
||||||
[self.app queueCommand:(char *)[self.touchbarItems[identifier][@"cmd"] UTF8String]];
|
[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:
|
NSString *seek = [NSString stringWithFormat:
|
||||||
self.touchbarItems[identifier][@"cmd"], sender.slider.doubleValue];
|
self.touchbarItems[identifier][@"cmd"], slider.doubleValue];
|
||||||
[self.app queueCommand:(char *)[seek UTF8String]];
|
[self.app queueCommand:(char *)[seek UTF8String]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue