Cocoa Port: The microphone and speaker icons now adapt their appearance to macOS Mojave's Dark Mode.
This commit is contained in:
parent
a73705bc50
commit
9035c193c8
|
@ -2,6 +2,8 @@
|
|||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSRequiresAquaSystemAppearance</key>
|
||||
<false/>
|
||||
<key>NSMicrophoneUsageDescription</key>
|
||||
<string>DeSmuME requires your host microphone to emulate the NDS microphone.</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSRequiresAquaSystemAppearance</key>
|
||||
<false/>
|
||||
<key>NSMicrophoneUsageDescription</key>
|
||||
<string>DeSmuME requires your host microphone to emulate the NDS microphone.</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Binary file not shown.
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 7.3 KiB |
|
@ -84,6 +84,7 @@ class AudioSampleBlockGenerator;
|
|||
|
||||
BOOL isSaveStateEdited;
|
||||
|
||||
BOOL isRunningDarkMode;
|
||||
BOOL isWorking;
|
||||
BOOL isRomLoading;
|
||||
NSString *statusText;
|
||||
|
@ -178,6 +179,7 @@ class AudioSampleBlockGenerator;
|
|||
|
||||
@property (readonly) CGFloat lastSetSpeedScalar;
|
||||
|
||||
@property (assign) BOOL isRunningDarkMode;
|
||||
@property (assign) BOOL isWorking;
|
||||
@property (assign) BOOL isRomLoading;
|
||||
@property (assign) NSString *statusText;
|
||||
|
@ -299,6 +301,7 @@ class AudioSampleBlockGenerator;
|
|||
- (BOOL) handleUnloadRom:(NSInteger)reasonID romToLoad:(NSURL *)romURL;
|
||||
- (BOOL) loadRomByURL:(NSURL *)romURL asynchronous:(BOOL)willLoadAsync;
|
||||
- (void) loadRomDidFinish:(NSNotification *)aNotification;
|
||||
- (void) handleSystemThemeChange:(NSNotification *) notification;
|
||||
- (BOOL) unloadRom;
|
||||
|
||||
- (void) addOutputToCore:(CocoaDSOutput *)theOutput;
|
||||
|
|
|
@ -86,6 +86,7 @@
|
|||
|
||||
@synthesize lastSetSpeedScalar;
|
||||
|
||||
@synthesize isRunningDarkMode;
|
||||
@synthesize isWorking;
|
||||
@synthesize isRomLoading;
|
||||
@synthesize statusText;
|
||||
|
@ -123,6 +124,26 @@
|
|||
mainWindow = nil;
|
||||
windowList = [[NSMutableArray alloc] initWithCapacity:32];
|
||||
|
||||
isRunningDarkMode = NO;
|
||||
|
||||
#if HAVE_OSAVAILABLE && defined(MAC_OS_X_VERSION_10_14) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14)
|
||||
if (IsOSXVersionSupported(10, 14, 0))
|
||||
{
|
||||
if (@available(macOS 10.14, *))
|
||||
{
|
||||
NSAppearanceName currentAppearanceName = [[NSApp effectiveAppearance] name];
|
||||
|
||||
if ( (currentAppearanceName == NSAppearanceNameDarkAqua) ||
|
||||
(currentAppearanceName == NSAppearanceNameVibrantDark) ||
|
||||
(currentAppearanceName == NSAppearanceNameAccessibilityHighContrastDarkAqua) ||
|
||||
(currentAppearanceName == NSAppearanceNameAccessibilityHighContrastVibrantDark) )
|
||||
{
|
||||
isRunningDarkMode = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
_displayRotationPanelTitle = nil;
|
||||
_displaySeparationPanelTitle = nil;
|
||||
_displayVideoSettingsPanelTitle = nil;
|
||||
|
@ -177,9 +198,8 @@
|
|||
statusText = NSSTRING_STATUS_READY;
|
||||
currentVolumeValue = MAX_VOLUME;
|
||||
micStatusTooltip = @"";
|
||||
BOOL isRunningDarkMode = NO;
|
||||
currentMicStatusIcon = (isRunningDarkMode) ? [iconMicDisabledDM retain] : [iconMicDisabled retain];
|
||||
currentVolumeIcon = [iconVolumeFull retain];
|
||||
currentVolumeIcon = (isRunningDarkMode) ? [iconVolumeFullDM retain] : [iconVolumeFull retain];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(loadRomDidFinish:)
|
||||
|
@ -196,6 +216,8 @@
|
|||
name:@"org.desmume.DeSmuME.handleEmulatorExecutionState"
|
||||
object:nil];
|
||||
|
||||
[[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(handleSystemThemeChange:) name:@"AppleInterfaceThemeChangedNotification" object:nil];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -321,8 +343,7 @@
|
|||
|
||||
- (void) setCurrentVolumeValue:(float)vol
|
||||
{
|
||||
BOOL isRunningDarkMode = NO;
|
||||
|
||||
const BOOL currentDarkModeState = [self isRunningDarkMode];
|
||||
currentVolumeValue = vol;
|
||||
|
||||
// Update the icon.
|
||||
|
@ -330,23 +351,23 @@
|
|||
NSImage *newImage = nil;
|
||||
if (vol <= 0.0f)
|
||||
{
|
||||
newImage = (isRunningDarkMode) ? iconVolumeMuteDM : iconVolumeMute;
|
||||
newImage = (currentDarkModeState) ? iconVolumeMuteDM : iconVolumeMute;
|
||||
}
|
||||
else if (vol > 0.0f && vol <= VOLUME_THRESHOLD_LOW)
|
||||
{
|
||||
newImage = (isRunningDarkMode) ? iconVolumeOneThirdDM : iconVolumeOneThird;
|
||||
newImage = (currentDarkModeState) ? iconVolumeOneThirdDM : iconVolumeOneThird;
|
||||
isSoundMuted = NO;
|
||||
lastSetVolumeValue = vol;
|
||||
}
|
||||
else if (vol > VOLUME_THRESHOLD_LOW && vol <= VOLUME_THRESHOLD_HIGH)
|
||||
{
|
||||
newImage = (isRunningDarkMode) ? iconVolumeTwoThirdDM : iconVolumeTwoThird;
|
||||
newImage = (currentDarkModeState) ? iconVolumeTwoThirdDM : iconVolumeTwoThird;
|
||||
isSoundMuted = NO;
|
||||
lastSetVolumeValue = vol;
|
||||
}
|
||||
else
|
||||
{
|
||||
newImage = (isRunningDarkMode) ? iconVolumeFullDM : iconVolumeFull;
|
||||
newImage = (currentDarkModeState) ? iconVolumeFullDM : iconVolumeFull;
|
||||
isSoundMuted = NO;
|
||||
lastSetVolumeValue = vol;
|
||||
}
|
||||
|
@ -2196,6 +2217,45 @@
|
|||
[cdsCore setFrameStatus:frameStatusString];
|
||||
}
|
||||
|
||||
- (void) handleSystemThemeChange:(NSNotification *) notification
|
||||
{
|
||||
BOOL newDarkModeState = NO;
|
||||
|
||||
#if HAVE_OSAVAILABLE && defined(MAC_OS_X_VERSION_10_14) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14)
|
||||
if (IsOSXVersionSupported(10, 14, 0))
|
||||
{
|
||||
if (@available(macOS 10.14, *))
|
||||
{
|
||||
NSAppearanceName currentAppearanceName = nil;
|
||||
|
||||
if (mainWindow != nil)
|
||||
{
|
||||
currentAppearanceName = [[[mainWindow view] effectiveAppearance] name];
|
||||
}
|
||||
else
|
||||
{
|
||||
currentAppearanceName = [[NSApp effectiveAppearance] name];
|
||||
}
|
||||
|
||||
if ( (currentAppearanceName == NSAppearanceNameDarkAqua) ||
|
||||
(currentAppearanceName == NSAppearanceNameVibrantDark) ||
|
||||
(currentAppearanceName == NSAppearanceNameAccessibilityHighContrastDarkAqua) ||
|
||||
(currentAppearanceName == NSAppearanceNameAccessibilityHighContrastVibrantDark) )
|
||||
{
|
||||
newDarkModeState = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (newDarkModeState != [self isRunningDarkMode])
|
||||
{
|
||||
[self setIsRunningDarkMode:newDarkModeState];
|
||||
[self setCurrentVolumeValue:[self currentVolumeValue]];
|
||||
[self updateMicStatusIcon];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) addOutputToCore:(CocoaDSOutput *)theOutput
|
||||
{
|
||||
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
|
||||
|
@ -2238,42 +2298,37 @@
|
|||
|
||||
- (void) updateMicStatusIcon
|
||||
{
|
||||
BOOL isRunningDarkMode = NO;
|
||||
|
||||
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
|
||||
CocoaDSController *cdsController = [cdsCore cdsController];
|
||||
NSImage *micIcon = (isRunningDarkMode) ? iconMicDisabledDM : iconMicDisabled;
|
||||
NSImage *micIcon = ([self isRunningDarkMode]) ? iconMicDisabledDM : iconMicDisabled;
|
||||
|
||||
if ([cdsController softwareMicState])
|
||||
if (![cdsCore emulationPaused])
|
||||
{
|
||||
micIcon = iconMicManualOverride;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ([cdsController hardwareMicPause])
|
||||
if ([cdsController softwareMicState])
|
||||
{
|
||||
micIcon = (isRunningDarkMode) ? iconMicDisabledDM : iconMicDisabled;
|
||||
micIcon = iconMicManualOverride;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ([cdsController isHardwareMicAvailable])
|
||||
micIcon = iconMicIdleNoHardware;
|
||||
|
||||
if (![cdsController hardwareMicMute])
|
||||
{
|
||||
if ([cdsController isHardwareMicInClip])
|
||||
if ([cdsController isHardwareMicAvailable])
|
||||
{
|
||||
micIcon = iconMicInClip;
|
||||
if ([cdsController isHardwareMicInClip])
|
||||
{
|
||||
micIcon = iconMicInClip;
|
||||
}
|
||||
else if ([cdsController isHardwareMicIdle])
|
||||
{
|
||||
micIcon = iconMicIdle;
|
||||
}
|
||||
else
|
||||
{
|
||||
micIcon = iconMicActive;
|
||||
}
|
||||
}
|
||||
else if ([cdsController isHardwareMicIdle])
|
||||
{
|
||||
micIcon = iconMicIdle;
|
||||
}
|
||||
else
|
||||
{
|
||||
micIcon = iconMicActive;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
micIcon = iconMicIdleNoHardware;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2550,13 +2605,13 @@
|
|||
CocoaDSController *cdsController = [cdsCore cdsController];
|
||||
|
||||
NSInteger authStatus = 0;
|
||||
BOOL authFlag = NO;
|
||||
|
||||
#if HAVE_OSAVAILABLE && defined(MAC_OS_X_VERSION_10_14) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14)
|
||||
if (IsOSXVersionSupported(10, 14, 0))
|
||||
{
|
||||
if (@available(macOS 10.14, *))
|
||||
{
|
||||
BOOL authFlag = NO;
|
||||
authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeAudio];
|
||||
|
||||
switch (authStatus)
|
||||
|
|
|
@ -228,6 +228,7 @@
|
|||
|
||||
// Init the DS emulation core.
|
||||
CocoaDSCore *newCore = [[[CocoaDSCore alloc] init] autorelease];
|
||||
[cdsCoreController setContent:newCore];
|
||||
|
||||
// Init the DS controller.
|
||||
[[newCore cdsController] setDelegate:emuControl];
|
||||
|
@ -245,7 +246,6 @@
|
|||
[emuControl setCdsSpeaker:newSpeaker];
|
||||
|
||||
// Set up all the object controllers.
|
||||
[cdsCoreController setContent:newCore];
|
||||
[prefWindowController setContent:[prefWindowDelegate bindings]];
|
||||
|
||||
[emuControl appInit];
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Copyright (C) 2011 Roger Manuel
|
||||
Copyright (C) 2012-2018 DeSmuME Team
|
||||
Copyright (C) 2012-2022 DeSmuME Team
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -80,6 +80,10 @@ class OGLImage;
|
|||
NSImage *iconVolumeTwoThird;
|
||||
NSImage *iconVolumeOneThird;
|
||||
NSImage *iconVolumeMute;
|
||||
NSImage *iconVolumeFullDM;
|
||||
NSImage *iconVolumeTwoThirdDM;
|
||||
NSImage *iconVolumeOneThirdDM;
|
||||
NSImage *iconVolumeMuteDM;
|
||||
NSPopUpButton *spuSyncMethodMenu;
|
||||
|
||||
DisplayPreviewView *previewView;
|
||||
|
@ -90,6 +94,7 @@ class OGLImage;
|
|||
NSString *subnetMaskString_AP3;
|
||||
|
||||
NSMutableDictionary *bindings;
|
||||
BOOL _isRunningDarkMode;
|
||||
}
|
||||
|
||||
@property (readonly) IBOutlet NSObject *dummyObject;
|
||||
|
|
|
@ -344,15 +344,41 @@
|
|||
subnetMaskString_AP2 = @"0.0.0.0";
|
||||
subnetMaskString_AP3 = @"0.0.0.0";
|
||||
|
||||
_isRunningDarkMode = NO;
|
||||
|
||||
#if HAVE_OSAVAILABLE && defined(MAC_OS_X_VERSION_10_14) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14)
|
||||
if (IsOSXVersionSupported(10, 14, 0))
|
||||
{
|
||||
if (@available(macOS 10.14, *))
|
||||
{
|
||||
NSAppearanceName currentAppearanceName = [[NSApp effectiveAppearance] name];
|
||||
|
||||
if ( (currentAppearanceName == NSAppearanceNameDarkAqua) ||
|
||||
(currentAppearanceName == NSAppearanceNameVibrantDark) ||
|
||||
(currentAppearanceName == NSAppearanceNameAccessibilityHighContrastDarkAqua) ||
|
||||
(currentAppearanceName == NSAppearanceNameAccessibilityHighContrastVibrantDark) )
|
||||
{
|
||||
_isRunningDarkMode = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Load the volume icons.
|
||||
iconVolumeFull = [[NSImage imageNamed:@"Icon_VolumeFull_16x16"] retain];
|
||||
iconVolumeTwoThird = [[NSImage imageNamed:@"Icon_VolumeTwoThird_16x16"] retain];
|
||||
iconVolumeOneThird = [[NSImage imageNamed:@"Icon_VolumeOneThird_16x16"] retain];
|
||||
iconVolumeMute = [[NSImage imageNamed:@"Icon_VolumeMute_16x16"] retain];
|
||||
[bindings setObject:iconVolumeFull forKey:@"volumeIconImage"];
|
||||
iconVolumeFull = [[NSImage imageNamed:@"Icon_VolumeFull_16x16"] retain];
|
||||
iconVolumeTwoThird = [[NSImage imageNamed:@"Icon_VolumeTwoThird_16x16"] retain];
|
||||
iconVolumeOneThird = [[NSImage imageNamed:@"Icon_VolumeOneThird_16x16"] retain];
|
||||
iconVolumeMute = [[NSImage imageNamed:@"Icon_VolumeMute_16x16"] retain];
|
||||
iconVolumeFullDM = [[NSImage imageNamed:@"Icon_VolumeFull_DarkMode_16x16"] retain];
|
||||
iconVolumeTwoThirdDM = [[NSImage imageNamed:@"Icon_VolumeTwoThird_DarkMode_16x16"] retain];
|
||||
iconVolumeOneThirdDM = [[NSImage imageNamed:@"Icon_VolumeOneThird_DarkMode_16x16"] retain];
|
||||
iconVolumeMuteDM = [[NSImage imageNamed:@"Icon_VolumeMute_DarkMode_16x16"] retain];
|
||||
[bindings setObject:((_isRunningDarkMode) ? iconVolumeFullDM : iconVolumeFull) forKey:@"volumeIconImage"];
|
||||
|
||||
prefViewDict = nil;
|
||||
|
||||
[[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(handleSystemThemeChange:) name:@"AppleInterfaceThemeChangedNotification" object:nil];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -362,6 +388,10 @@
|
|||
[iconVolumeTwoThird release];
|
||||
[iconVolumeOneThird release];
|
||||
[iconVolumeMute release];
|
||||
[iconVolumeFullDM release];
|
||||
[iconVolumeTwoThirdDM release];
|
||||
[iconVolumeOneThirdDM release];
|
||||
[iconVolumeMuteDM release];
|
||||
[bindings release];
|
||||
[prefViewDict release];
|
||||
|
||||
|
@ -672,19 +702,19 @@
|
|||
|
||||
if (vol <= 0.0f)
|
||||
{
|
||||
newIconImage = iconVolumeMute;
|
||||
newIconImage = (_isRunningDarkMode) ? iconVolumeMuteDM : iconVolumeMute;
|
||||
}
|
||||
else if (vol > 0.0f && vol <= VOLUME_THRESHOLD_LOW)
|
||||
{
|
||||
newIconImage = iconVolumeOneThird;
|
||||
newIconImage = (_isRunningDarkMode) ? iconVolumeOneThirdDM : iconVolumeOneThird;
|
||||
}
|
||||
else if (vol > VOLUME_THRESHOLD_LOW && vol <= VOLUME_THRESHOLD_HIGH)
|
||||
{
|
||||
newIconImage = iconVolumeTwoThird;
|
||||
newIconImage = (_isRunningDarkMode) ? iconVolumeTwoThirdDM : iconVolumeTwoThird;
|
||||
}
|
||||
else
|
||||
{
|
||||
newIconImage = iconVolumeFull;
|
||||
newIconImage = (_isRunningDarkMode) ? iconVolumeFullDM : iconVolumeFull;
|
||||
}
|
||||
|
||||
if (newIconImage == iconImage)
|
||||
|
@ -1131,6 +1161,35 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (void) handleSystemThemeChange:(NSNotification *) notification
|
||||
{
|
||||
BOOL newDarkModeState = NO;
|
||||
|
||||
#if HAVE_OSAVAILABLE && defined(MAC_OS_X_VERSION_10_14) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14)
|
||||
if (IsOSXVersionSupported(10, 14, 0))
|
||||
{
|
||||
if (@available(macOS 10.14, *))
|
||||
{
|
||||
NSAppearanceName currentAppearanceName = [[[self viewSound] effectiveAppearance] name];
|
||||
|
||||
if ( (currentAppearanceName == NSAppearanceNameDarkAqua) ||
|
||||
(currentAppearanceName == NSAppearanceNameVibrantDark) ||
|
||||
(currentAppearanceName == NSAppearanceNameAccessibilityHighContrastDarkAqua) ||
|
||||
(currentAppearanceName == NSAppearanceNameAccessibilityHighContrastVibrantDark) )
|
||||
{
|
||||
newDarkModeState = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (newDarkModeState != _isRunningDarkMode)
|
||||
{
|
||||
_isRunningDarkMode = newDarkModeState;
|
||||
[self updateVolumeIcon:self];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark NSWindowDelegate Protocol
|
||||
|
||||
- (void)windowDidBecomeKey:(NSNotification *)notification
|
||||
|
|
Loading…
Reference in New Issue