From 6bc15db1c1b25d1c21d3c97e8a20d892ba28cda2 Mon Sep 17 00:00:00 2001 From: Levi G Date: Sun, 5 Mar 2023 14:24:31 -0800 Subject: [PATCH] Added scaling for high-resolution displays --- Activate/main.m | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/Activate/main.m b/Activate/main.m index 5b6188f..49c810e 100644 --- a/Activate/main.m +++ b/Activate/main.m @@ -143,7 +143,34 @@ - (void)drawRect:(NSRect)dirtyRect { NSString *title = NSLocalizedString(@"TITLE", @""); NSString *description = NSLocalizedString(@"DESCRIPTION", @""); - NSAttributedString *firstLine = [[NSAttributedString alloc] initWithString:title + // check if screen height is larger than 1500px + if (self.bounds.size.height > 1500) { + // print height + NSLog(@"%f", self.bounds.size.height); + NSAttributedString *firstLine = [[NSAttributedString alloc] initWithString:title + attributes:@{ NSFontAttributeName: [NSFont systemFontOfSize:36.0], + NSForegroundColorAttributeName: [NSColor colorWithWhite:0.57 alpha:0.5], + }]; + + NSAttributedString *secondLine = [[NSAttributedString alloc] initWithString:description + attributes:@{ NSFontAttributeName: [NSFont systemFontOfSize:20.0], + NSForegroundColorAttributeName: [NSColor colorWithWhite:0.57 alpha:0.5], + }]; + + CGRect firstLineRect = [firstLine boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX) + options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading]; + CGRect secondLineRect = [secondLine boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX) + options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading]; + + CGFloat decisionWidth = MAX(firstLineRect.size.width, secondLineRect.size.width); + + CGFloat xPosition = self.bounds.size.width - 125 - decisionWidth; // padding to right 125 + [firstLine drawAtPoint:CGPointMake(xPosition, 150)]; + [secondLine drawAtPoint:CGPointMake(xPosition, 125)]; + } else { + //print height + NSLog(@"%f", self.bounds.size.height); +NSAttributedString *firstLine = [[NSAttributedString alloc] initWithString:title attributes:@{ NSFontAttributeName: [NSFont systemFontOfSize:24.0], NSForegroundColorAttributeName: [NSColor colorWithWhite:0.57 alpha:0.5], }]; @@ -163,6 +190,9 @@ - (void)drawRect:(NSRect)dirtyRect { CGFloat xPosition = self.bounds.size.width - 125 - decisionWidth; // padding to right 125 [firstLine drawAtPoint:CGPointMake(xPosition, 134)]; [secondLine drawAtPoint:CGPointMake(xPosition, 116)]; + } + + } @end