Browse Source

macosx: Remove VLCHUDCheckboxCell class

This was used on macOS versions lower than 10.10 to draw custom
HUD-style controls and is not necessary anymore.
pull/68/head
Marvin Scholz 9 years ago
parent
commit
ff61d869dd
  1. 6
      extras/package/macosx/VLC.xcodeproj/project.pbxproj
  2. 1
      modules/gui/macosx/Makefile.am
  3. 54
      modules/gui/macosx/VLCHUDCheckboxCell.h
  4. 156
      modules/gui/macosx/VLCHUDCheckboxCell.m

6
extras/package/macosx/VLC.xcodeproj/project.pbxproj

@ -61,7 +61,6 @@
1C3113EF1E508C7600D4DD76 /* VLCRendererDiscovery.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BBBB8B61D114628001BD9BA /* VLCRendererDiscovery.m */; };
1C3113F11E508C7600D4DD76 /* VLCRendererItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BBBB8B11D10A994001BD9BA /* VLCRendererItem.m */; };
1C3113F31E508C7600D4DD76 /* VLCRendererMenuController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BBBB8A81D108A17001BD9BA /* VLCRendererMenuController.m */; };
1C3113F91E508C7600D4DD76 /* VLCHUDCheckboxCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B846FDF1CF5D88C00112E54 /* VLCHUDCheckboxCell.m */; };
1C3113FD1E508C7600D4DD76 /* VLCHUDSliderCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B846FE31CF5D88C00112E54 /* VLCHUDSliderCell.m */; };
1C3114031E508C8800D4DD76 /* AppleRemote.m in Sources */ = {isa = PBXBuildFile; fileRef = CC6D8D9D0A878DED006F2BBE /* AppleRemote.m */; };
1C3114051E508C8800D4DD76 /* SideBarItem.m in Sources */ = {isa = PBXBuildFile; fileRef = CCCDDEF013E870BB00A35661 /* SideBarItem.m */; };
@ -612,8 +611,6 @@
6B8229FF1E4D2DD100833BE1 /* vlc.scriptSuite */ = {isa = PBXFileReference; lastKnownFileType = text.plist.scriptSuite; path = vlc.scriptSuite; sourceTree = "<group>"; };
6B822A001E4D2DD100833BE1 /* vlc.scriptTerminology */ = {isa = PBXFileReference; lastKnownFileType = text.plist.scriptTerminology; path = vlc.scriptTerminology; sourceTree = "<group>"; };
6B822A031E4D2DEB00833BE1 /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = "<group>"; };
6B846FDE1CF5D88C00112E54 /* VLCHUDCheckboxCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCHUDCheckboxCell.h; sourceTree = "<group>"; };
6B846FDF1CF5D88C00112E54 /* VLCHUDCheckboxCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCHUDCheckboxCell.m; sourceTree = "<group>"; };
6B846FE21CF5D88C00112E54 /* VLCHUDSliderCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCHUDSliderCell.h; sourceTree = "<group>"; };
6B846FE31CF5D88C00112E54 /* VLCHUDSliderCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCHUDSliderCell.m; sourceTree = "<group>"; };
6B9FD0371EEB5D8A0085151F /* VLCHUDScroller.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCHUDScroller.h; sourceTree = "<group>"; };
@ -1462,8 +1459,6 @@
6B846FE81CF5D89500112E54 /* HUD UI Classes */ = {
isa = PBXGroup;
children = (
6B846FDE1CF5D88C00112E54 /* VLCHUDCheckboxCell.h */,
6B846FDF1CF5D88C00112E54 /* VLCHUDCheckboxCell.m */,
6B846FE21CF5D88C00112E54 /* VLCHUDSliderCell.h */,
6B846FE31CF5D88C00112E54 /* VLCHUDSliderCell.m */,
6B9FD0371EEB5D8A0085151F /* VLCHUDScroller.h */,
@ -1753,7 +1748,6 @@
1C3113F11E508C7600D4DD76 /* VLCRendererItem.m in Sources */,
1C3113F31E508C7600D4DD76 /* VLCRendererMenuController.m in Sources */,
6B4D50931E7979CB004479B5 /* VLCSimplePrefsWindow.m in Sources */,
1C3113F91E508C7600D4DD76 /* VLCHUDCheckboxCell.m in Sources */,
1C3113FD1E508C7600D4DD76 /* VLCHUDSliderCell.m in Sources */,
1C31138E1E508C6900D4DD76 /* VLCAboutWindowController.m in Sources */,
1C3113901E508C6900D4DD76 /* VLCHelpWindowController.m in Sources */,

1
modules/gui/macosx/Makefile.am

@ -75,7 +75,6 @@ libmacosx_plugin_la_SOURCES = \
gui/macosx/VLCLogMessage.h gui/macosx/VLCLogMessage.m \
gui/macosx/VLCLogWindowController.h gui/macosx/VLCLogWindowController.m \
gui/macosx/VLCHUDSliderCell.h gui/macosx/VLCHUDSliderCell.m \
gui/macosx/VLCHUDCheckboxCell.h gui/macosx/VLCHUDCheckboxCell.m \
gui/macosx/VLCHUDScroller.h gui/macosx/VLCHUDScroller.m \
gui/macosx/VLCHUDOutlineView.h gui/macosx/VLCHUDOutlineView.m \
gui/macosx/VLCHUDTableView.h gui/macosx/VLCHUDTableView.m \

54
modules/gui/macosx/VLCHUDCheckboxCell.h

@ -1,54 +0,0 @@
//
// VLCHUDCheckboxCell.h
// BGHUDAppKit
//
// Created by BinaryGod on 5/25/08.
//
// Copyright (c) 2008, Tim Davis (BinaryMethod.com, binary.god@gmail.com)
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation and/or
// other materials provided with the distribution.
//
// Neither the name of the BinaryMethod.com nor the names of its contributors
// may be used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
#import <Cocoa/Cocoa.h>
/* Custom subclass that provides a dark NSButtonCell Checkbox style for HUD Panels.
*
* It is not possible to get from the coder if we are a checkbox or radio button
* that's why this class exists, so that it can be set easily in Interface Builder.
*/
@interface VLCHUDCheckboxCell : NSButtonCell
@property NSGradient *normalGradient;
@property NSGradient *highlightGradient;
@property NSGradient *pushedGradient;
@property NSColor *cellTextColor;
@property NSColor *disabledCellTextColor;
@property NSColor *strokeColor;
@property NSColor *disabledStrokeColor;
@end

156
modules/gui/macosx/VLCHUDCheckboxCell.m

@ -1,156 +0,0 @@
//
// VLCHUDCheckboxCell.m
// BGHUDAppKit
//
// Created by BinaryGod on 5/25/08.
//
// Copyright (c) 2008, Tim Davis (BinaryMethod.com, binary.god@gmail.com)
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation and/or
// other materials provided with the distribution.
//
// Neither the name of the BinaryMethod.com nor the names of its contributors
// may be used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// 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];
if (self) {
/* Colors */
_cellTextColor = [NSColor whiteColor];
_disabledCellTextColor = [NSColor colorWithCalibratedWhite:1.0f alpha:0.5f];
_strokeColor = [NSColor whiteColor];
_disabledStrokeColor = [NSColor colorWithCalibratedWhite:1.0f alpha:0.5f];
/* Gradients */
_normalGradient = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithDeviceRed:0.251f green:0.251f blue:0.255f alpha:1.0f]
endingColor:[NSColor colorWithDeviceRed:0.118f green:0.118f blue:0.118f alpha:1.0f]];
_highlightGradient = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithDeviceRed:0.451f green:0.451f blue:0.455f alpha:1.0f]
endingColor:[NSColor colorWithDeviceRed:0.318f green:0.318f blue:0.318f alpha:1.0f]];
_pushedGradient = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithDeviceRed:0.451f green:0.451f blue:0.455f alpha:1.0f]
endingColor:[NSColor colorWithDeviceRed:0.318f green:0.318f blue:0.318f alpha:1.0f]];
}
return self;
}
- (void)drawImage:(NSImage *)image withFrame:(NSRect)frame inView:(NSView *)controlView
{
// Set frame size correctly
NSRect backgroundFrame = frame;
if (self.controlSize == NSSmallControlSize) {
frame.origin.x += 4;
frame.origin.y += 2.5;
frame.size.width -= 5;
frame.size.height -= 5;
backgroundFrame = NSInsetRect(frame, 1.5, 1.5);
} else if (self.controlSize == NSMiniControlSize) {
frame.origin.x += 2.5;
frame.origin.y += 4;
frame.size.width -= 5;
frame.size.height -= 5;
backgroundFrame = NSInsetRect(frame, 2, 2);
}
// Set fill frame
NSBezierPath *backgroundPath = [NSBezierPath bezierPathWithRoundedRect:backgroundFrame
xRadius:2
yRadius:2];
// Draw background and stroke
if([self isEnabled]) {
if ([self isHighlighted]) {
[_highlightGradient drawInBezierPath:backgroundPath angle:90.0];
} else {
[_normalGradient drawInBezierPath:backgroundPath angle:90.0];
}
[_strokeColor setStroke];
} else {
[_disabledStrokeColor setStroke];
}
[NSGraphicsContext saveGraphicsState];
if ([super showsFirstResponder] && [[[self controlView] window] isKeyWindow] &&
([self focusRingType] == NSFocusRingTypeDefault ||
[self focusRingType] == NSFocusRingTypeExterior)) {
NSSetFocusRingStyle(NSFocusRingOnly);
}
[backgroundPath setLineWidth:1.0];
[backgroundPath stroke];
[NSGraphicsContext restoreGraphicsState];
// Now drawing tick
if ([self intValue]) {
NSBezierPath* bezierPath = [NSBezierPath bezierPath];
[bezierPath moveToPoint: NSMakePoint(NSMinX(frame) + 3.0, NSMidY(frame) - 2.0)];
[bezierPath lineToPoint: NSMakePoint(NSMidX(frame), NSMidY(frame) + 2.0)];
[bezierPath lineToPoint: NSMakePoint((NSMinX(frame) + NSWidth(frame) - 1), NSMinY(frame) - 2.0)];
[bezierPath setLineWidth: 1.5];
if([self isEnabled]) {
[_strokeColor setStroke];
} else {
[_disabledStrokeColor setStroke];
}
[bezierPath stroke];
}
}
- (NSRect)drawTitle:(NSAttributedString *)title withFrame:(NSRect)frame inView:(NSView *)controlView
{
NSMutableAttributedString *newTitle = [title mutableCopy];
if([self isEnabled]) {
[newTitle addAttribute:NSForegroundColorAttributeName
value:_cellTextColor
range:NSMakeRange(0, [newTitle length])];
} else {
[newTitle addAttribute:NSForegroundColorAttributeName
value:_disabledCellTextColor
range:NSMakeRange(0, [newTitle length])];
}
return [super drawTitle: newTitle withFrame: frame inView: controlView];
}
@end
Loading…
Cancel
Save