]> granicus.if.org Git - handbrake/commitdiff
MacGui: improve the preview border alignment on retina screens.
authorDamiano Galassi <damiog@gmail.com>
Fri, 31 Aug 2018 16:23:12 +0000 (18:23 +0200)
committerDamiano Galassi <damiog@gmail.com>
Fri, 31 Aug 2018 16:23:12 +0000 (18:23 +0200)
macosx/HBPreviewView.m

index 3f10b7c10756537ef91f86802c047d262475fc71..8c3bd9209dd3f0f4cdb7f0d124fed1c25d2698f0 100644 (file)
         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);
         
         [NSAnimationContext endGrouping];
         
-        // Update the proprierties
+        // Update the properties
         self.scale = self.pictureLayer.frame.size.width / imageSize.width * backingScaleFactor;
         self.pictureFrame = self.pictureLayer.frame;
     }
         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;
 }