Revision: 15079
http://sourceforge.net/p/skim-app/code/15079
Author: hofman
Date: 2025-04-03 21:53:58 +0000 (Thu, 03 Apr 2025)
Log Message:
-----------
Draw text color in swatch at the side of the font well
Modified Paths:
--------------
trunk/SKFontWell.m
Modified: trunk/SKFontWell.m
===================================================================
--- trunk/SKFontWell.m 2025-04-03 21:33:36 UTC (rev 15078)
+++ trunk/SKFontWell.m 2025-04-03 21:53:58 UTC (rev 15079)
@@ -38,6 +38,7 @@
#import "SKFontWell.h"
#import "NSGraphics_SKExtensions.h"
+#import "NSGeometry_SKExtensions.h"
#import "NSColor_SKExtensions.h"
#import "NSObject_SKExtensions.h"
#import "NSImage_SKExtensions.h"
@@ -437,19 +438,22 @@
[NSBezierPath strokeRect:NSInsetRect(frame, 0.5, 0.5)];
[NSGraphicsContext restoreGraphicsState];
}
-}
-
-- (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];
+ NSRect rect = NSInsetRect(frame, 4.0, 4.0);
+ rect = SKSliceRect(rect, NSHeight(rect), NSMaxXEdge);
+ [NSGraphicsContext saveGraphicsState];
+ [[self textColor] drawSwatchInRect:rect];
+ if (SKHasDarkAppearance()) {
+ [[NSColor colorWithGenericGamma22White:1.0 alpha:0.55] setStroke];
+ [[NSGraphicsContext currentContext]
setCompositingOperation:NSCompositingOperationScreen];
+ } else {
+ [[NSColor colorWithGenericGamma22White:0.0 alpha:0.55] setStroke];
+ [[NSGraphicsContext currentContext]
setCompositingOperation:NSCompositingOperationMultiply];
}
+ [NSBezierPath strokeRect:NSInsetRect(rect, 0.5, 0.5)];
+ [NSGraphicsContext restoreGraphicsState];
}
- [super drawInteriorWithFrame:frame inView:controlView];
- drawShadow = NO;
}
- (NSRect)focusRingMaskBoundsForFrame:(NSRect)cellFrame inView:(NSView
*)controlView {
@@ -460,22 +464,6 @@
NSRectFill(cellFrame);
}
-- (NSAttributedString *)attributedTitle {
- if ([self hasTextColor]) {
- NSMutableAttributedString *attrString = [[super attributedTitle]
mutableCopy];
- [attrString addAttribute:NSForegroundColorAttributeName value:[self
textColor] range:NSMakeRange(0, [attrString length])];
- if (drawShadow) {
- NSShadow *shade = [[NSShadow alloc] init];
- [shade setShadowColor:SKHasDarkAppearance() ? [NSColor whiteColor]
: [NSColor blackColor]];
- [shade setShadowBlurRadius:1.0];
- [attrString addAttribute:NSShadowAttributeName value:shade
range:NSMakeRange(0, [attrString length])];
- }
- return attrString;
- } else {
- return [super attributedTitle];
- }
-}
-
- (NSString *)accessibilityRoleDescription {
return NSLocalizedString(@"font well", @"Accessibility description");
}
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