Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions Headers/Additions/GNUstepGUI/GSTheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,41 @@ APPKIT_EXPORT_CLASS
*/
- (NSString*) license;

/**
* Returns YES if Theme is able to display in Light NSAppearance
* For a theme supporting both Light and Dark modes, it should return both
* supportsLightAppearance and supportsDarkAppearance
* Light is the "default" of the GNUstep theme like Cocoa Aqua.
*/
- (BOOL) supportsLightAppearance;

/**
* Returns YES if Theme is able to display in Dark NSAppearance
* For a theme supporting both Light and Dark modes, it should return both
* supportsLightAppearance and supportsDarkAppearance
* Light is the default Aqua and GNUstep "classic", but a GNUstep can be dark only.
*/
- (BOOL) supportsDarkAppearance;

/**
* Returns YES if displaying in Light NSAppearance (or non-Dark)
* Should match if theme is equivalent to Cocoa names like
* NSAppearanceNameAqua or NSAppearanceNameAccessibilityHighContrastAqua
*
* Being only Light and Dark supported, must be opposite of inDarkAppearance
*/
- (BOOL) inLightAppearance;

/**
* Returns YES if displaying in dark NSAppearance
* Should match if theme is equivalent to Cocoa names like
* NSAppearanceNameDarkAqua or NSAppearanceNameAccessibilityHighContrastDarkAqua
*
* Being only Light and Dark supported, must be opposite of inLightAppearance
*/
- (BOOL) inDarkAppearance;


@end

/**
Expand Down
63 changes: 63 additions & 0 deletions Source/GSTheme.m
Original file line number Diff line number Diff line change
Expand Up @@ -1339,6 +1339,69 @@ - (NSString *) license
return [[self infoDictionary] objectForKey: @"GSThemeLicense"];
}

- (BOOL) supportsLightAppearance
{
NSString *val;
BOOL r;

r = YES; // default themes are light
val = [[self infoDictionary] objectForKey: @"GSThemeSupportsLightAppearance"];

if (val && [val isEqualToString: @"YES"])
r = YES;

return r;
}

- (BOOL) supportsDarkAppearance
{
NSString *val;
BOOL r;

r = NO; // default themes are light
val = [[self infoDictionary] objectForKey: @"GSThemeSupportsDarkAppearance"];

// Do we have the key or is it an old GSTheme?
if (val == nil)
{
// try heuristic on the theme name
if ([[self name] hasSuffix:@"Dark"])
{
r = YES;
}
}
else
{
if ([val isEqualToString: @"YES"])
{
r = YES;
}
}

return r;
}

- (BOOL) inLightAppearance
{
// NOTE: maybe we should cache this in an ivar
if (![self supportsLightAppearance] && [self supportsDarkAppearance])
{
return NO;
}
return YES;
}

- (BOOL) inDarkAppearance;
{
// NOTE: maybe we should cache this in an ivar
if (![self supportsLightAppearance] && [self supportsDarkAppearance])
{
return YES;
}
return NO;
}


@end

@implementation GSTheme (Private)
Expand Down
Loading