macOS: Don't draw custom VLCHUDCheckboxCell on 10.10+
authorMarvin Scholz <epirat07@gmail.com>
Wed, 21 Jun 2017 00:09:40 +0000 (02:09 +0200)
committerMarvin Scholz <epirat07@gmail.com>
Thu, 22 Jun 2017 21:53:36 +0000 (23:53 +0200)
modules/gui/macosx/VLCHUDCheckboxCell.m

index 93df527..b9e8c93 100644 (file)
 //     POSSIBILITY OF SUCH DAMAGE.
 
 #import "VLCHUDCheckboxCell.h"
+#import "CompatibilityFixes.h"
 
 @implementation VLCHUDCheckboxCell
 
++ (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.
+     * Just calling super will not work, as the AppKit implementation for the NSButton
+     * checkbox checks if the drawing related selectors below are overriden, and if
+     * that is the case, will fall back to legacy drawing, without animation,
+     * without vibrancy and non-layer-based.
+     */
+    if (OSX_YOSEMITE_AND_HIGHER) {
+        swapoutOverride([VLCHUDCheckboxCell class], @selector(initWithCoder:));
+        swapoutOverride([VLCHUDCheckboxCell class], @selector(drawImage:withFrame:inView:));
+        swapoutOverride([VLCHUDCheckboxCell class], @selector(drawTitle:withFrame:inView:));
+    }
+}
+
 - (instancetype)initWithCoder:(NSCoder *)coder
 {
     self = [super initWithCoder:coder];