macOS: Workaround for VLCDefaultValueSlider misaligned default tickmark
authorMarvin Scholz <epirat07@gmail.com>
Wed, 28 Jun 2017 16:04:03 +0000 (18:04 +0200)
committerMarvin Scholz <epirat07@gmail.com>
Wed, 28 Jun 2017 16:11:12 +0000 (18:11 +0200)
Ugly workaround for alignment issues on non-retina displays on macOS
10.10 and higher.

modules/gui/macosx/VLCDefaultValueSliderCell.m

index 193bf33..9ae7723 100644 (file)
@@ -30,6 +30,7 @@
  *****************************************************************************/
 
 #import "VLCDefaultValueSliderCell.h"
+#import "CompatibilityFixes.h"
 
 @interface VLCDefaultValueSliderCell (){
     BOOL _isRTL;
             tickFrame.size.height = tickThickness;
         } else {
             CGFloat mid = NSMidX(tickFrame);
-            tickFrame.origin.x = mid - tickThickness/2.0;
+            // Ugly workaround
+            // Corrects minor alignment issue on non-retina
+            CGFloat scale = [[[self controlView] window] backingScaleFactor];
+            tickFrame.size.height = cellFrame.size.height;
             tickFrame.origin.y = cellFrame.origin.y;
+            if (scale > 1.0) {
+                tickFrame.origin.x = mid;
+            } else {
+                tickFrame.origin.x = mid - tickThickness;
+                if (OSX_YOSEMITE_AND_HIGHER) {
+                    tickFrame.size.height = cellFrame.size.height - 1;
+                    tickFrame.origin.y = cellFrame.origin.y - 1;
+                }
+            }
             tickFrame.size.width = tickThickness;
-            tickFrame.size.height = cellFrame.size.height;
         }
 
+        NSAlignmentOptions alignOpts = NSAlignMinXOutward | NSAlignMinYOutward |
+                                       NSAlignWidthOutward | NSAlignMaxYOutward;
+        NSRect alignedRect = [[self controlView] backingAlignedRect:tickFrame options:alignOpts];
+
         // Draw default tick mark
-        [self drawDefaultTickMarkWithFrame:tickFrame];
+        [self drawDefaultTickMarkWithFrame:alignedRect];
     }
 
     // Redraw knob