diff options
author | Damiano Galassi <[email protected]> | 2018-08-31 18:23:12 +0200 |
---|---|---|
committer | Damiano Galassi <[email protected]> | 2018-08-31 18:23:12 +0200 |
commit | f990512a1c0f1330cce7bf180cb52b6c9fd3b749 (patch) | |
tree | 58550d95892333202c534b97c88876baeed2bf67 /macosx/HBPreviewView.m | |
parent | ed9facff98fcce2020945d001303f44343c86b84 (diff) |
MacGui: improve the preview border alignment on retina screens.
Diffstat (limited to 'macosx/HBPreviewView.m')
-rw-r--r-- | macosx/HBPreviewView.m | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/macosx/HBPreviewView.m b/macosx/HBPreviewView.m index 3f10b7c10..8c3bd9209 100644 --- a/macosx/HBPreviewView.m +++ b/macosx/HBPreviewView.m @@ -212,8 +212,13 @@ self.pictureLayer.bounds = pictureRect; // Position the CALayers - CGPoint anchor = CGPointMake(floor((self.frame.size.width - pictureRect.size.width) / 2), - floor((self.frame.size.height - pictureRect.size.height) / 2)); + NSRect alignedRect = [self backingAlignedRect:NSMakeRect(0, 0, + self.frame.size.width - pictureRect.size.width, + self.frame.size.height - pictureRect.size.height) + options:NSAlignAllEdgesNearest]; + + CGPoint anchor = CGPointMake(alignedRect.size.width / 2, + alignedRect.size.height / 2); [self.pictureLayer setPosition:anchor]; CGPoint backAchor = CGPointMake(anchor.x - BORDER_SIZE, anchor.y - BORDER_SIZE); @@ -221,7 +226,7 @@ [NSAnimationContext endGrouping]; - // Update the proprierties + // Update the properties self.scale = self.pictureLayer.frame.size.width / imageSize.width * backingScaleFactor; self.pictureFrame = self.pictureLayer.frame; } @@ -270,8 +275,11 @@ resultSize.height += BORDER_SIZE * 2; } - resultSize.width = floor(resultSize.width); - resultSize.height = floor(resultSize.height); + NSRect alignedRect = [self backingAlignedRect:NSMakeRect(0, 0, resultSize.width, resultSize.height) + options:NSAlignAllEdgesNearest]; + + resultSize.width = alignedRect.size.width; + resultSize.height = alignedRect.size.height; return resultSize; } |