Revision: 15077
http://sourceforge.net/p/skim-app/code/15077
Author: hofman
Date: 2025-04-03 17:24:08 +0000 (Thu, 03 Apr 2025)
Log Message:
-----------
Draw shadowed text twice to make it more pronounced
Modified Paths:
--------------
trunk/SKFontWell.h
trunk/SKFontWell.m
Modified: trunk/SKFontWell.h
===================================================================
--- trunk/SKFontWell.h 2025-04-03 16:21:42 UTC (rev 15076)
+++ trunk/SKFontWell.h 2025-04-03 17:24:08 UTC (rev 15077)
@@ -62,6 +62,7 @@
@interface SKFontWellCell : NSButtonCell {
NSColor *textColor;
BOOL hasTextColor;
+ BOOL drawShadow;
}
@property (nonatomic, nullable, copy) NSColor *textColor;
Modified: trunk/SKFontWell.m
===================================================================
--- trunk/SKFontWell.m 2025-04-03 16:21:42 UTC (rev 15076)
+++ trunk/SKFontWell.m 2025-04-03 17:24:08 UTC (rev 15077)
@@ -431,6 +431,19 @@
}
}
+- (void)drawInteriorWithFrame:(NSRect)frame inView:(NSView *)controlView {
+ if ([self hasTextColor]) {
+ CGFloat textLuminance = [[self textColor] luminance];
+ CGFloat backgroundLuminance = [([self state] == NSControlStateValueOn
? [NSColor selectedControlColor] : [NSColor controlBackgroundColor]) luminance];
+ if ((fmax(textLuminance, backgroundLuminance) + 0.05) /
(fmin(textLuminance, backgroundLuminance) + 0.05) < 4.5) {
+ drawShadow = YES;
+ [super drawInteriorWithFrame:frame inView:controlView];
+ }
+ }
+ [super drawInteriorWithFrame:frame inView:controlView];
+ drawShadow = NO;
+}
+
- (NSRect)focusRingMaskBoundsForFrame:(NSRect)cellFrame inView:(NSView
*)controlView {
return cellFrame;
}
@@ -443,11 +456,9 @@
if ([self hasTextColor]) {
NSMutableAttributedString *attrString = [[super attributedTitle]
mutableCopy];
[attrString addAttribute:NSForegroundColorAttributeName value:[self
textColor] range:NSMakeRange(0, [attrString length])];
- CGFloat textLuminance = [[self textColor] luminance];
- CGFloat backgroundLuminance = [([self state] == NSControlStateValueOn
? [NSColor selectedControlColor] : [self backgroundColor]) luminance];
- if ((fmax(textLuminance, backgroundLuminance) + 0.05) /
(fmin(textLuminance, backgroundLuminance) + 0.05) < 4.5) {
+ if (drawShadow) {
NSShadow *shade = [[NSShadow alloc] init];
- [shade setShadowColor:backgroundLuminance < 0.5 ? [NSColor
whiteColor] : [NSColor blackColor]];
+ [shade setShadowColor:SKHasDarkAppearance() ? [NSColor whiteColor]
: [NSColor blackColor]];
[shade setShadowBlurRadius:1.0];
[attrString addAttribute:NSShadowAttributeName value:shade
range:NSMakeRange(0, [attrString length])];
}
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