Skip to content

Commit

Permalink
Fix the vertical layout being broken on certain iPad resolutions. Min…
Browse files Browse the repository at this point in the history
…or improvements to other iPad layouts. Fixes #678
  • Loading branch information
LIJI32 committed Jan 8, 2025
1 parent 9079c8b commit fb817c1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
7 changes: 4 additions & 3 deletions iOS/GBHorizontalLayout.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ - (instancetype)initWithTheme:(GBTheme *)theme cutoutOnRight:(bool)cutoutOnRight
break;
}

double screenBorderWidth = screenRect.size.width / 40;
double screenBorderWidth = MIN(screenRect.size.width / 40, 16 * self.factor);

screenRect.origin.x = (resolution.width - screenRect.size.width) / 2;
bool drawSameBoyLogo = false;
if (verticalMargin * 2 > screenBorderWidth * 7) {
Expand Down Expand Up @@ -100,7 +100,8 @@ - (instancetype)initWithTheme:(GBTheme *)theme cutoutOnRight:(bool)cutoutOnRight
if (drawSameBoyLogo) {
double bezelBottom = screenRect.origin.y + screenRect.size.height + screenBorderWidth;
double freeSpace = resolution.height - bezelBottom;
[self drawLogoInVerticalRange:(NSRange){bezelBottom + screenBorderWidth * 2, freeSpace - screenBorderWidth * 4}];
[self drawLogoInVerticalRange:(NSRange){bezelBottom + screenBorderWidth * 2, freeSpace - screenBorderWidth * 4}
controlPadding:0];
}

[self drawLabels];
Expand Down
2 changes: 1 addition & 1 deletion iOS/GBLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

- (void)drawBackground;
- (void)drawScreenBezels;
- (void)drawLogoInVerticalRange:(NSRange)range;
- (void)drawLogoInVerticalRange:(NSRange)range controlPadding:(double)padding;
- (void)drawLabels;
- (void)drawThemedLabelsWithBlock:(void (^)(void))block;

Expand Down
8 changes: 4 additions & 4 deletions iOS/GBLayout.m
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ - (void)drawScreenBezels
CGColorRef colors[] = {top, bottom};
CFArrayRef colorsArray = CFArrayCreate(NULL, (const void **)colors, 2, &kCFTypeArrayCallBacks);

double borderWidth = self.screenRect.size.width / 40;
double borderWidth = MIN(self.screenRect.size.width / 40, 16 * _factor);
CGRect bezelRect = self.screenRect;
bezelRect.origin.x -= borderWidth;
bezelRect.origin.y -= borderWidth;
Expand Down Expand Up @@ -140,7 +140,7 @@ - (void)drawScreenBezels
CFRelease(colorspace);
}

- (void)drawLogoInVerticalRange:(NSRange)range
- (void)drawLogoInVerticalRange:(NSRange)range controlPadding:(double)padding
{
UIFont *font = [UIFont fontWithName:@"AvenirNext-BoldItalic" size:range.length * 4 / 3];

Expand All @@ -160,8 +160,8 @@ - (void)drawLogoInVerticalRange:(NSRange)range
}];

_logoRect = (CGRect){
{(self.size.width - _screenRect.size.width) / 2, rect.origin.y},
{_screenRect.size.width, rect.size.height}
{(self.size.width - _screenRect.size.width) / 2 + padding, rect.origin.y},
{_screenRect.size.width - padding * 2, rect.size.height}
};
}

Expand Down
17 changes: 10 additions & 7 deletions iOS/GBVerticalLayout.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ - (instancetype)initWithTheme:(GBTheme *)theme
screenRect.origin.y = (resolution.height - screenRect.size.height) / 2;
self.fullScreenRect = screenRect;

double screenBorderWidth = screenRect.size.width / 40;
screenRect.origin.x = (resolution.width - screenRect.size.width) / 2;
screenRect.origin.y = self.minY + screenBorderWidth * 2;
double screenBorderWidth = MIN(screenRect.size.width / 40, 16 * self.factor);
screenRect.origin.y = self.minY + MIN(screenBorderWidth * 2, 20 * self.factor);
self.screenRect = screenRect;

double controlAreaStart = screenRect.origin.y + screenRect.size.height + screenBorderWidth * 2;
double controlAreaStart = screenRect.origin.y + screenRect.size.height + MIN(screenBorderWidth * 2, 20 * self.factor);

self.selectLocation = (CGPoint){
MIN(resolution.width / 4, 120 * self.factor),
Expand Down Expand Up @@ -74,9 +73,13 @@ - (instancetype)initWithTheme:(GBTheme *)theme
[self drawScreenBezels];

[self drawThemedLabelsWithBlock:^{
if (controlsTop - controlAreaStart > 24 * self.factor + screenBorderWidth * 2 ||
middleSpace > 160 * self.factor) {
[self drawLogoInVerticalRange:(NSRange){controlAreaStart + screenBorderWidth, 24 * self.factor}];
if (controlsTop - controlAreaStart > 24 * self.factor + screenBorderWidth * 2) {
[self drawLogoInVerticalRange:(NSRange){controlAreaStart + screenBorderWidth, 24 * self.factor}
controlPadding:0];
}
else if (middleSpace > 160 * self.factor) {
[self drawLogoInVerticalRange:(NSRange){controlAreaStart + screenBorderWidth, 24 * self.factor}
controlPadding:self.dpadLocation.x * 2];
}

[self drawLabels];
Expand Down

0 comments on commit fb817c1

Please sign in to comment.