Skip to content

Commit

Permalink
chore(mac): draw three-color stripe correctly in About box
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sgschantz committed Dec 5, 2024
1 parent 3dd5207 commit 4629cd1
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions mac/Keyman4MacIM/Keyman4MacIM/KMAboutWindow/KMBarView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 4629cd1

Please sign in to comment.