]> granicus.if.org Git - handbrake/commitdiff
MacGUI: Move toolbar item badge and vary type size with scale factor.
authorBradley Sepos <bradley@bradleysepos.com>
Wed, 24 Jan 2018 22:49:37 +0000 (17:49 -0500)
committerBradley Sepos <bradley@bradleysepos.com>
Thu, 25 Jan 2018 22:56:43 +0000 (17:56 -0500)
10 pt for standard displays, 8 pt for high dpi displays. Alignment considerations.

macosx/HBToolbarBadgedItem.m

index b149dc0aa8f5994cd928416657a2de5d4240f96d..35fdf680885dccae44ba498ddaf3ccfedf89f766 100644 (file)
 
         // Work out the area
         CGFloat scaleFactor = rep.pixelsWide / rep.size.width;
-        CGFloat pointSize = 10 * scaleFactor;
+        CGFloat typeSize = 10;
+        if (scaleFactor > 1)
+        {
+            typeSize = 8;
+        }
+        CGFloat pointSize = typeSize * scaleFactor;
 
         NSFont *font = [NSFont boldSystemFontOfSize:pointSize];
         NSDictionary *attr = @{NSParagraphStyleAttributeName : paragraphStyle,
                                                       options:0
                                                    attributes:attr];
 
-        NSPoint indent = NSMakePoint(10 * scaleFactor, 2 * scaleFactor);
+        NSPoint indent = NSMakePoint(typeSize * scaleFactor, 2 * scaleFactor);
         CGFloat radius = (textBounds.size.height + indent.y) * 0.5f;
 
-        NSRect badgeRect = NSMakeRect(0, 0,
+        CGFloat offset_x = 0;
+        CGFloat offset_y = 0;
+        if (scaleFactor > 1)
+        {
+            offset_y = 2 * scaleFactor;
+        }
+        NSRect badgeRect = NSMakeRect(size.width - textBounds.size.width - indent.x - offset_x, offset_y,
                                       textBounds.size.width + indent.x, textBounds.size.height + indent.y);
         badgeRect = NSIntegralRect(badgeRect);