macOS: No custom HUD drawing on macOS 10.10+
[vlc.git] / modules / gui / macosx / VLCHUDTextFieldCell.m
index 364b54e..a58a131 100644 (file)
 
 @implementation VLCHUDTextFieldCell
 
++ (void)load
+{
+    /* On 10.10+ we do not want custom drawing, therefore we swap out the implementation
+     * of the selectors below with their original implementations.
+     */
+    if (OSX_YOSEMITE_AND_HIGHER) {
+        swapoutOverride([VLCHUDTextFieldCell class], @selector(initTextCell:));
+        swapoutOverride([VLCHUDTextFieldCell class], @selector(initWithCoder:));
+        swapoutOverride([VLCHUDTextFieldCell class], @selector(setUpFieldEditorAttributes:));
+        swapoutOverride([VLCHUDTextFieldCell class], @selector(drawWithFrame:inView:));
+        swapoutOverride([VLCHUDTextFieldCell class], @selector(_drawKeyboardFocusRingWithFrame:inView:));
+    }
+}
+
 #pragma mark Drawing Functions
 
 - (instancetype)initTextCell:(NSString *)aString
 
 - (void)commonInit
 {
-    if (OSX_YOSEMITE_AND_HIGHER) {
-        return;
-    }
-
     // Init colors
     _focusRing = [[NSShadow alloc] init];
     [_focusRing setShadowColor:NSColor.whiteColor];
     [_focusRing setShadowOffset:NSMakeSize(0, 0)];
 
     _strokeColor = [NSColor colorWithDeviceRed:0.749f green:0.761f blue:0.788f alpha:1.0f];
-    _disabledStrokeColor = [NSColor colorWithDeviceRed:0.749f green:0.761f blue:0.788f alpha:0.2f];
+    _disabledStrokeColor = [NSColor colorWithDeviceRed:1 green:1 blue:1 alpha:0.2f];
+
     _selectionHighlightActiveColor = [NSColor darkGrayColor];
     _selectionTextActiveColor = [NSColor whiteColor];
     _selectionHighlightInActiveColor = [NSColor darkGrayColor];
     _selectionTextInActiveColor = [NSColor whiteColor];
+
     _placeholderTextColor = [NSColor grayColor];
     _cellTextColor = [NSColor whiteColor];
-    _disabledStrokeColor = [NSColor colorWithDeviceRed:1 green:1 blue:1 alpha:0.2f];
     _textFillColor = [NSColor colorWithDeviceRed:.224f green:.224f blue:.224f alpha:.95f];
 
     // Init some properties
 
 - (NSText *)setUpFieldEditorAttributes:(NSText *)textObj
 {
-    if (OSX_YOSEMITE_AND_HIGHER) {
-        return [super setUpFieldEditorAttributes:textObj];
-    }
-
     NSText *newText = [super setUpFieldEditorAttributes:textObj];
     NSColor *textColor = _cellTextColor;
     [(NSTextView *)newText setInsertionPointColor:textColor];
 
 - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
 {
-    if (OSX_YOSEMITE_AND_HIGHER) {
-        return [super drawWithFrame:cellFrame inView:controlView];
-    }
-
     // Adjust Rect
     cellFrame = NSInsetRect(cellFrame, 0.5f, 0.5f);
 
 
 - (void)_drawKeyboardFocusRingWithFrame:(NSRect)rect inView:(NSView*)view
 {
-    if (OSX_YOSEMITE_AND_HIGHER) {
-        if ([super respondsToSelector:@selector(_drawKeyboardFocusRingWithFrame:inView:)]) {
-            [super _drawKeyboardFocusRingWithFrame:rect inView:view];
-        }
-    }
-
     // Do nothing
 }