Skip to content

Commit 9b890f6

Browse files
committed
fix(SquirrelPanel): reimplement blendColors, tune background color fraction to increase contrast
1 parent 35b9ea7 commit 9b890f6

File tree

1 file changed

+5
-27
lines changed

1 file changed

+5
-27
lines changed

SquirrelPanel.m

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
#import "SquirrelConfig.h"
44

5-
static const int kOffsetHeight = 5;
6-
static const int kDefaultFontSize = 24;
5+
static const CGFloat kOffsetHeight = 5;
6+
static const CGFloat kDefaultFontSize = 24;
7+
static const CGFloat kBlendedBackgroundColorFraction = 1.0 / 5;
78
static const NSTimeInterval kShowStatusDuration = 1.2;
89
static NSString *const kDefaultCandidateFormat = @"%c. %@";
910

@@ -1109,31 +1110,8 @@ - (void)hideStatus:(NSTimer *)timer {
11091110
// return foregroundColor;
11101111
backgroundColor = [NSColor lightGrayColor];
11111112
}
1112-
1113-
struct {
1114-
CGFloat r, g, b, a;
1115-
} f, b;
1116-
1117-
[[foregroundColor colorUsingColorSpace:[NSColorSpace deviceRGBColorSpace]]
1118-
getRed:&f.r
1119-
green:&f.g
1120-
blue:&f.b
1121-
alpha:&f.a];
1122-
//NSLog(@"fg: %f %f %f %f", f.r, f.g, f.b, f.a);
1123-
1124-
[[backgroundColor colorUsingColorSpace:[NSColorSpace deviceRGBColorSpace]]
1125-
getRed:&b.r
1126-
green:&b.g
1127-
blue:&b.b
1128-
alpha:&b.a];
1129-
//NSLog(@"bg: %f %f %f %f", b.r, b.g, b.b, b.a);
1130-
1131-
#define blend_value(f, b) (((f)*2.0 + (b)) / 3.0)
1132-
return [NSColor colorWithDeviceRed:blend_value(f.r, b.r)
1133-
green:blend_value(f.g, b.g)
1134-
blue:blend_value(f.b, b.b)
1135-
alpha:f.a];
1136-
#undef blend_value
1113+
return [[foregroundColor blendedColorWithFraction:kBlendedBackgroundColorFraction ofColor:backgroundColor]
1114+
colorWithAlphaComponent:foregroundColor.alphaComponent];
11371115
}
11381116

11391117
static NSFontDescriptor *getFontDescriptor(NSString *fullname) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy