Revision: 13444
http://sourceforge.net/p/skim-app/code/13444
Author: hofman
Date: 2023-05-16 16:06:20 +0000 (Tue, 16 May 2023)
Log Message:
-----------
Add a hidden preference for an adjusted white point for the pdf display. This
worksbetter than a sepia tone as it does not have as much influence on darker
colors. Add AppleScript support for this setting.
Modified Paths:
--------------
trunk/NSGraphics_SKExtensions.m
trunk/SKBasePDFView.m
trunk/SKDisplayPrefs.h
trunk/SKDisplayPrefs.m
trunk/SKStringConstants.h
trunk/SKStringConstants.m
trunk/SKThumbnailImageView.m
trunk/Skim.sdef
Modified: trunk/NSGraphics_SKExtensions.m
===================================================================
--- trunk/NSGraphics_SKExtensions.m 2023-05-12 09:07:48 UTC (rev 13443)
+++ trunk/NSGraphics_SKExtensions.m 2023-05-16 16:06:20 UTC (rev 13444)
@@ -39,6 +39,7 @@
#import "NSGraphics_SKExtensions.h"
#import "NSGeometry_SKExtensions.h"
#import "NSColor_SKExtensions.h"
+#import "NSUserDefaults_SKExtensions.h"
#import <Quartz/Quartz.h>
#import "SKStringConstants.h"
@@ -212,6 +213,11 @@
if ((filter = [CIFilter filterWithName:@"CISepiaTone"
keysAndValues:@"inputIntensity", [NSNumber numberWithDouble:fmin(sepia, 1.0)],
nil]))
[filters addObject:filter];
}
+ NSColor *white = [[NSUserDefaults standardUserDefaults]
colorForKey:SKWhitePointKey];
+ if (white) {
+ if ((filter = [CIFilter filterWithName:@"CIWhitePointAdjust"
keysAndValues:@"inputColor", [[[CIColor alloc] initWithColor:white]
autorelease], nil]))
+ [filters addObject:filter];
+ }
if (SKHasDarkAppearance(NSApp) && [[NSUserDefaults standardUserDefaults]
boolForKey:SKInvertColorsInDarkModeKey]) {
// map the white page background to 45/255, or 30/255 with high
contrast
CGFloat f = SKHasHighContrastDarkAppearance(NSApp) ? 1.9337 : 1.8972;
Modified: trunk/SKBasePDFView.m
===================================================================
--- trunk/SKBasePDFView.m 2023-05-12 09:07:48 UTC (rev 13443)
+++ trunk/SKBasePDFView.m 2023-05-16 16:06:20 UTC (rev 13444)
@@ -90,9 +90,9 @@
static inline NSArray *defaultKeysToObserve() {
if (RUNNING_AFTER(10_13))
- return @[SKInvertColorsInDarkModeKey, SKSepiaToneKey];
+ return @[SKInvertColorsInDarkModeKey, SKSepiaToneKey, SKWhitePointKey];
else
- return @[SKSepiaToneKey];
+ return @[SKSepiaToneKey, SKWhitePointKey];
}
// make sure we don't use the same method name as a superclass or a subclass
Modified: trunk/SKDisplayPrefs.h
===================================================================
--- trunk/SKDisplayPrefs.h 2023-05-12 09:07:48 UTC (rev 13443)
+++ trunk/SKDisplayPrefs.h 2023-05-16 16:06:20 UTC (rev 13444)
@@ -47,6 +47,7 @@
@property (nonatomic, retain) NSDictionary *pdfViewSettings;
@property (nonatomic, retain) NSColor *backgroundColor;
@property (nonatomic) CGFloat sepiaTone;
+@property (nonatomic, retain) NSColor *whitePoint;
@property (nonatomic, getter=isInverted) BOOL inverted;
- (id)initForFullScreen:(BOOL)isFullScreen;
Modified: trunk/SKDisplayPrefs.m
===================================================================
--- trunk/SKDisplayPrefs.m 2023-05-12 09:07:48 UTC (rev 13443)
+++ trunk/SKDisplayPrefs.m 2023-05-16 16:06:20 UTC (rev 13444)
@@ -44,7 +44,7 @@
@implementation SKDisplayPrefs
-@dynamic name, pdfViewSettings, backgroundColor, sepiaTone, inverted;
+@dynamic name, pdfViewSettings, backgroundColor, sepiaTone, whitePoint,
inverted;
- (id)initForFullScreen:(BOOL)isFullScreen {
self = [super init];
@@ -116,6 +116,19 @@
[[NSUserDefaults standardUserDefaults] setDouble:fmin(sepiaTone, 1.0)
forKey:SKSepiaToneKey];
}
+- (NSColor *)whitePoint {
+ return [[NSUserDefaults standardUserDefaults] colorForKey:SKWhitePointKey]
?: [NSColor whiteColor];
+}
+
+- (void)setWhitePoint:(NSColor *)whitePoint {
+ CGFloat r = 1.0, g = 1.0, b = 1.0, a = 1.0;
+ [[whitePoint colorUsingColorSpace:[NSColorSpace sRGBColorSpace]] getRed:&r
green:&g blue:&b alpha:&a];
+ if (whitePoint == nil || a <= 0.0 || (r > 0.9999 && g > 0.9999 && b >
0.9999))
+ [[NSUserDefaults standardUserDefaults]
removeObjectForKey:SKWhitePointKey];
+ else
+ [[NSUserDefaults standardUserDefaults] setObject:@[[NSNumber
numberWithDouble:r], [NSNumber numberWithDouble:g], [NSNumber
numberWithDouble:b]] forKey:SKWhitePointKey];
+}
+
- (BOOL)isInverted {
return [[NSUserDefaults standardUserDefaults]
boolForKey:SKInvertColorsInDarkModeKey];
}
Modified: trunk/SKStringConstants.h
===================================================================
--- trunk/SKStringConstants.h 2023-05-12 09:07:48 UTC (rev 13443)
+++ trunk/SKStringConstants.h 2023-05-16 16:06:20 UTC (rev 13444)
@@ -144,3 +144,4 @@
extern NSString *SKDisableHistoryHighlightsKey;
extern NSString *SKInvertColorsInDarkModeKey;
extern NSString *SKSepiaToneKey;
+extern NSString *SKWhitePointKey;
Modified: trunk/SKStringConstants.m
===================================================================
--- trunk/SKStringConstants.m 2023-05-12 09:07:48 UTC (rev 13443)
+++ trunk/SKStringConstants.m 2023-05-16 16:06:20 UTC (rev 13444)
@@ -145,3 +145,4 @@
NSString *SKDisableHistoryHighlightsKey = @"SKDisableHistoryHighlights";
NSString *SKInvertColorsInDarkModeKey = @"SKInvertColorsInDarkMode";
NSString *SKSepiaToneKey = @"SKSepiaTone";
+NSString *SKWhitePointKey = @"SKWhitePoint";
Modified: trunk/SKThumbnailImageView.m
===================================================================
--- trunk/SKThumbnailImageView.m 2023-05-12 09:07:48 UTC (rev 13443)
+++ trunk/SKThumbnailImageView.m 2023-05-16 16:06:20 UTC (rev 13444)
@@ -47,9 +47,9 @@
static inline NSArray *defaultKeysToObserve() {
if (RUNNING_AFTER(10_13))
- return @[SKInvertColorsInDarkModeKey, SKSepiaToneKey];
+ return @[SKInvertColorsInDarkModeKey, SKSepiaToneKey, SKWhitePointKey];
else
- return @[SKSepiaToneKey];
+ return @[SKSepiaToneKey, SKWhitePointKey];
}
- (void)commonInit {
Modified: trunk/Skim.sdef
===================================================================
--- trunk/Skim.sdef 2023-05-12 09:07:48 UTC (rev 13443)
+++ trunk/Skim.sdef 2023-05-16 16:06:20 UTC (rev 13444)
@@ -956,6 +956,10 @@
description="The background color behind the pages.">
<cocoa key="backgroundColor"/>
</property>
+ <property name="white point" type="RGBA color" code="WhPt"
+ description="Adjusted white point color applied to the PDF
content. The same for normal and full screen mode.">
+ <cocoa key="whitePoint"/>
+ </property>
<property name="sepia tone" type="real" code="SepT"
description="Intensity of a sepia tone effect applied to the
PDF content. The same for normal and full screen mode.">
<cocoa key="sepiaTone"/>
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit