macosx: Listen to float on top notification change in main video view controller

Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
This commit is contained in:
Claudio Cambra 2024-04-08 21:27:03 +08:00 committed by Steve Lhomme
parent ef0149ada8
commit 2432710464
1 changed files with 21 additions and 2 deletions

View File

@ -38,6 +38,7 @@
#import "views/VLCWrappableTextField.h"
#import "windows/video/VLCMainVideoViewController.h"
#import "windows/video/VLCVideoOutputProvider.h"
#import "windows/video/VLCVideoWindowCommon.h"
@interface VLCMainVideoViewControlsBar ()
@ -70,6 +71,10 @@
selector:@selector(updateDetailLabel:)
name:VLCPlayerCurrentMediaItemChanged
object:nil];
[notificationCenter addObserver:self
selector:@selector(updateFloatOnTopButton:)
name:VLCWindowFloatOnTopChangedNotificationName
object:nil];
}
- (void)updateDetailLabel:(NSNotification *)notification
@ -116,9 +121,23 @@
if (!p_vout) {
return;
}
const bool enabled = !var_ToggleBool(p_vout, "video-on-top");
self.floatOnTopButton.state = enabled ? NSControlStateValueOn : NSControlStateValueOff;
var_ToggleBool(p_vout, "video-on-top");
vout_Release(p_vout);
}
- (void)updateFloatOnTopButton:(NSNotification *)notification
{
VLCVideoWindowCommon * const videoWindow = (VLCVideoWindowCommon *)notification.object;
NSAssert(videoWindow != nil, @"Received video window should not be nil!");
NSDictionary<NSString *, NSNumber *> * const userInfo = notification.userInfo;
NSAssert(userInfo != nil, @"Received user info should not be nil!");
NSNumber * const enabledNumberWrapper = userInfo[VLCWindowFloatOnTopEnabledNotificationKey];
NSAssert(enabledNumberWrapper != nil, @"Received user info enabled wrapper should not be nil!");
if (@available(macOS 10.14, *)) {
self.floatOnTopButton.contentTintColor =
enabledNumberWrapper.boolValue ? NSColor.controlAccentColor : NSColor.controlTextColor;
}
}
@end