Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added scaling for high-resolution displays #20

Merged
merged 1 commit into from
Mar 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion Activate/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -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],
}];
Expand All @@ -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
Expand Down