macOS: No custom HUD drawing on macOS 10.10+
[vlc.git] / modules / gui / macosx / VLCHUDTextFieldCell.m
index e5b8bd8..a58a131 100644 (file)
 //                                     provided by [tylerb](GitHub).
 
 #import "VLCHUDTextFieldCell.h"
+#import "CompatibilityFixes.h"
+
+@interface NSTextFieldCell (Private)
+
+- (void)_drawKeyboardFocusRingWithFrame:(NSRect)rect inView:(NSView*)view;
+
+@end
 
 @interface VLCHUDTextFieldCell () {
     bool fillsBackground;
 
 @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
     [_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