From 4629cd11eb18b2b254e5107ff7de1f99d9e97d5b Mon Sep 17 00:00:00 2001 From: sgschantz Date: Thu, 5 Dec 2024 09:51:43 +0700 Subject: [PATCH] chore(mac): draw three-color stripe correctly in About box due to Sonoma change of default setting in UIView where clipsToBounds is defaulting to false, the stripe in the About box was appearing much taller than the expected 7 points --- .../Keyman4MacIM/KMAboutWindow/KMBarView.m | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/mac/Keyman4MacIM/Keyman4MacIM/KMAboutWindow/KMBarView.m b/mac/Keyman4MacIM/Keyman4MacIM/KMAboutWindow/KMBarView.m index b9a400706a3..8364a6cb310 100644 --- a/mac/Keyman4MacIM/Keyman4MacIM/KMAboutWindow/KMBarView.m +++ b/mac/Keyman4MacIM/Keyman4MacIM/KMAboutWindow/KMBarView.m @@ -7,31 +7,39 @@ // #import "KMBarView.h" +#import "KMLogs.h" @implementation KMBarView +/** + * draws stripe in three colors as part of Keyman branding + * over half is orange, followed by red and blue segments + */ - (void)drawRect:(NSRect)rect { CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] CGContext]; - NSRect rect1 = NSMakeRect(0, 0, rect.size.width*0.56, rect.size.height); - NSRect rect2 = NSMakeRect(rect1.size.width, 0, rect.size.width*0.23, rect.size.height); - NSRect rect3 = NSMakeRect(rect2.origin.x + rect2.size.width, 0, rect.size.width*0.21, rect.size.height); + NSRect barRect = self.frame; + os_log_debug([KMLogs uiLog], "KMBarView drawRect: %{public}@ frame: %{public}@", NSStringFromRect(rect), NSStringFromRect(barRect)); + + NSRect orangeRect = NSMakeRect(0, 0, barRect.size.width*0.56, barRect.size.height); + NSRect redRect = NSMakeRect(orangeRect.size.width, 0, barRect.size.width*0.23, barRect.size.height); + NSRect blueRect = NSMakeRect(redRect.origin.x + redRect.size.width, 0, barRect.size.width*0.21, barRect.size.height); CGContextSetFillColorWithColor(context, [NSColor colorWithSRGBRed:246.0/255.0 green:137.0/255.0 blue:36.0/255.0 alpha:1.0].CGColor); CGContextBeginPath(context); - CGContextAddRect(context, rect1); + CGContextAddRect(context, orangeRect); CGContextClosePath(context); CGContextDrawPath(context, kCGPathFill); CGContextSetFillColorWithColor(context, [NSColor colorWithSRGBRed:204.0/255.0 green:56.0/255.0 blue:70.0/255.0 alpha:1.0].CGColor); CGContextBeginPath(context); - CGContextAddRect(context, rect2); + CGContextAddRect(context, redRect); CGContextClosePath(context); CGContextDrawPath(context, kCGPathFill); CGContextSetFillColorWithColor(context, [NSColor colorWithSRGBRed:121.0/255.0 green:195.0/255.0 blue:218.0/255.0 alpha:1.0].CGColor); CGContextBeginPath(context); - CGContextAddRect(context, rect3); + CGContextAddRect(context, blueRect); CGContextClosePath(context); CGContextDrawPath(context, kCGPathFill); }