diff --git a/bilibili/Player/Control/BGHUDSliderCell.h b/bilibili/Player/Control/BGHUDSliderCell.h deleted file mode 100644 index 522e637..0000000 --- a/bilibili/Player/Control/BGHUDSliderCell.h +++ /dev/null @@ -1,54 +0,0 @@ -// -// BGHUDSliderCell.h -// BGHUDAppKit -// -// Created by BinaryGod on 5/30/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. - -// Updated by TYPCN on 3/5/16 -// WARNING: There are some leaks after change to ARC , but not have much impacts - -#import -#import "BGThemeManager.h" - - -@interface BGHUDSliderCell : NSSliderCell { - - NSString *themeKey; -} - -@property (strong) NSString *themeKey; - --(void)drawHorizontalBarInFrame:(NSRect)frame; --(void)drawVerticalBarInFrame:(NSRect)frame; --(void)drawHorizontalKnobInFrame:(NSRect)frame; --(void)drawVerticalKnobInFrame:(NSRect)frame; - -@end diff --git a/bilibili/Player/Control/BGHUDSliderCell.m b/bilibili/Player/Control/BGHUDSliderCell.m deleted file mode 100644 index 7722a36..0000000 --- a/bilibili/Player/Control/BGHUDSliderCell.m +++ /dev/null @@ -1,673 +0,0 @@ -// -// BGHUDSliderCell.m -// BGHUDAppKit -// -// Created by BinaryGod on 5/30/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 "BGHUDSliderCell.h" - - -@implementation BGHUDSliderCell - -@synthesize themeKey; - -#pragma mark Init/Dealloc - --(id)init { - - self = [super init]; - - if(self) { - - self.themeKey = @"flatTheme"; - } - - return self; -} - --(id)initWithCoder:(NSCoder *)aDecoder { - - self = [super initWithCoder: aDecoder]; - - if(self) { - - if([aDecoder containsValueForKey: @"themeKey"]) { - - self.themeKey = [aDecoder decodeObjectForKey: @"themeKey"]; - } else { - self.themeKey = @"flatTheme"; - } - } - - return self; -} - --(void)encodeWithCoder: (NSCoder *)coder { - - [super encodeWithCoder: coder]; - - [coder encodeObject: self.themeKey forKey: @"themeKey"]; -} - --(id)copyWithZone:(NSZone *) zone { - - BGHUDSliderCell *copy = [super copyWithZone: zone]; - - copy->themeKey = nil; - [copy setThemeKey: [self themeKey]]; - - return copy; -} - - -#pragma mark - -#pragma mark Drawing Methods - -- (void)drawBarInside:(NSRect)aRect flipped:(BOOL)flipped { - - if([self sliderType] == NSLinearSlider) { - - if(![self isVertical]) { - - [self drawHorizontalBarInFrame: aRect]; - } else { - - [self drawVerticalBarInFrame: aRect]; - } - } else { - - //Placeholder for when I figure out how to draw NSCircularSlider - } -} - -- (void)drawKnob:(NSRect)aRect { - - // Prevent drawing outside the rectangle to prevent ghost lines - // when moving the slider - // The ghost lines appear because of the shadow in highlight - NSBezierPath *clipPath = [NSBezierPath new]; - [clipPath appendBezierPathWithRect:aRect]; - [clipPath addClip]; - - if([self sliderType] == NSLinearSlider) { - - if(![self isVertical]) { - - [self drawHorizontalKnobInFrame: aRect]; - } else { - - [self drawVerticalKnobInFrame: aRect]; - } - } else { - - //Place holder for when I figure out how to draw NSCircularSlider - } -} - -- (void)drawHorizontalBarInFrame:(NSRect)frame { - - frame = [self controlView].bounds; - // NSLog(@"%@", NSStringFromRect(frame)); - // Adjust frame based on ControlSize - switch ([self controlSize]) { - - case NSRegularControlSize: - - if([self numberOfTickMarks] != 0) { - - if([self tickMarkPosition] == NSTickMarkBelow) { - - frame.origin.y += 4; - } else { - - frame.origin.y += frame.size.height - 10; - } - } else { - - frame.origin.y = frame.origin.y + (((frame.origin.y + frame.size.height) /2) - 2); - } - - frame.origin.x += 3; - //frame.origin.y += 0.5f; - frame.size.width -= 5; - frame.size.height = 5; - break; - - case NSSmallControlSize: - - if([self numberOfTickMarks] != 0) { - - if([self tickMarkPosition] == NSTickMarkBelow) { - - frame.origin.y += 2; - } else { - - frame.origin.y += frame.size.height - 8; - } - } else { - - frame.origin.y = frame.origin.y + (((frame.origin.y + frame.size.height) /2) - 2); - } - - frame.origin.x += 1; - //frame.origin.y += 0.5f; - frame.size.width -= 1; - frame.size.height = 5; - break; - - case NSMiniControlSize: - - if([self numberOfTickMarks] != 0) { - - if([self tickMarkPosition] == NSTickMarkBelow) { - - frame.origin.y += 2; - } else { - - frame.origin.y += frame.size.height - 6; - } - } else { - - frame.origin.y = frame.origin.y + (((frame.origin.y + frame.size.height) /2) - 2); - } - - frame.origin.x += 1; - //frame.origin.y += 0.5f; - frame.size.width -= 1; - frame.size.height = 3; - break; - } - - //Draw Bar - NSBezierPath *path = [[NSBezierPath alloc] init]; - [path appendBezierPathWithRoundedRect:frame xRadius:2 yRadius:2]; - - if([self isEnabled]) { - - [[[[BGThemeManager keyedManager] themeForKey: self.themeKey] sliderTrackColor] set]; - [path fill]; - - // [[[[BGThemeManager keyedManager] themeForKey: self.themeKey] strokeColor] set]; - // [path stroke]; - } else { - - [[[[BGThemeManager keyedManager] themeForKey: self.themeKey] disabledSliderTrackColor] set]; - [path fill]; - - // [[[[BGThemeManager keyedManager] themeForKey: self.themeKey] disabledStrokeColor] set]; - // [path stroke]; - } -} - -- (void)drawVerticalBarInFrame:(NSRect)frame { - frame = [self controlView].bounds; - //Vertical Scroller - switch ([self controlSize]) { - - case NSRegularControlSize: - - if([self numberOfTickMarks] != 0) { - - if([self tickMarkPosition] == NSTickMarkRight) { - - frame.origin.x += 4; - } else { - - frame.origin.x += frame.size.width - 9; - } - } else { - - frame.origin.x = frame.origin.x + (((frame.origin.x + frame.size.width) /2) - 2.5f); - } - - //frame.origin.x += 0.5f; - frame.origin.y += 2.5f; - frame.size.height -= 6; - frame.size.width = 5; - break; - - case NSSmallControlSize: - - if([self numberOfTickMarks] != 0) { - - if([self tickMarkPosition] == NSTickMarkRight) { - - frame.origin.x += 3; - } else { - - frame.origin.x += frame.size.width - 8; - } - - } else { - - frame.origin.x = frame.origin.x + (((frame.origin.x + frame.size.width) /2) - 2.5f); - } - - frame.origin.y += 0.5f; - frame.size.height -= 1; - //frame.origin.x += 0.5f; - frame.size.width = 5; - break; - - case NSMiniControlSize: - - if([self numberOfTickMarks] != 0) { - - if([self tickMarkPosition] == NSTickMarkRight) { - - frame.origin.x += 2.5f; - } else { - - frame.origin.x += frame.size.width - 6.5f; - } - } else { - - frame.origin.x = frame.origin.x + (((frame.origin.x + frame.size.width) /2) - 2); - } - - frame.origin.x += 1; - frame.origin.y += 0.5f; - frame.size.height -= 1; - frame.size.width = 3; - break; - } - - //Draw Bar - NSBezierPath *path = [[NSBezierPath alloc] init]; - [path appendBezierPathWithRoundedRect: frame xRadius: 2 yRadius: 2]; - - [[[[BGThemeManager keyedManager] themeForKey: self.themeKey] sliderTrackColor] set]; - [path fill]; - - // [[[[BGThemeManager keyedManager] themeForKey: self.themeKey] strokeColor] set]; - // [path stroke]; - -} - -- (void)drawHorizontalKnobInFrame:(NSRect)frame { - - switch ([self controlSize]) { - - case NSRegularControlSize: - - if([self numberOfTickMarks] != 0) { - - if([self tickMarkPosition] == NSTickMarkAbove) { - - frame.origin.y += 2; - } - - frame.origin.x += 2; - frame.size.height = 19.0f; - frame.size.width = 15.0f; - } else { - - frame.origin.x += 3; - frame.origin.y += 3; - frame.size.height = 15; - frame.size.width = 15; - } - break; - - case NSSmallControlSize: - - if([self numberOfTickMarks] != 0) { - - if([self tickMarkPosition] == NSTickMarkAbove) { - - frame.origin.y += 1; - } - - frame.origin.x += 1; - frame.size.height = 13.0f; - frame.size.width = 11.0f; - } else { - - frame.origin.x += 2; - frame.origin.y += 2; - frame.size.height = 11; - frame.size.width = 11; - } - break; - - case NSMiniControlSize: - - if([self numberOfTickMarks] != 0) { - - frame.origin.x += 1; - frame.size.height = 11.0f; - frame.size.width = 9.0f; - } else { - - frame.origin.x += 2; - frame.origin.y += 1; - frame.size.height = 9; - frame.size.width = 9; - } - break; - } - - NSBezierPath *pathOuter = [[NSBezierPath alloc] init]; - NSBezierPath *pathInner = [[NSBezierPath alloc] init]; - NSPoint pointsOuter[7]; - NSPoint pointsInner[7]; - - if([self numberOfTickMarks] != 0) { - - if([self tickMarkPosition] == NSTickMarkBelow) { - - pointsOuter[0] = NSMakePoint(NSMinX(frame) + 2, NSMinY(frame)); - pointsOuter[1] = NSMakePoint(NSMaxX(frame) - 2, NSMinY(frame)); - pointsOuter[2] = NSMakePoint(NSMaxX(frame), NSMinY(frame) + 2); - pointsOuter[3] = NSMakePoint(NSMaxX(frame), NSMidY(frame) + 2); - pointsOuter[4] = NSMakePoint(NSMidX(frame), NSMaxY(frame)); - pointsOuter[5] = NSMakePoint(NSMinX(frame), NSMidY(frame) + 2); - pointsOuter[6] = NSMakePoint(NSMinX(frame), NSMinY(frame) + 2); - - [pathOuter appendBezierPathWithPoints: pointsOuter count: 7]; - - } else { - - pointsOuter[0] = NSMakePoint(NSMidX(frame), NSMinY(frame)); - pointsOuter[1] = NSMakePoint(NSMaxX(frame), NSMidY(frame) - 2); - pointsOuter[2] = NSMakePoint(NSMaxX(frame), NSMaxY(frame) - 2); - pointsOuter[3] = NSMakePoint(NSMaxX(frame) - 2, NSMaxY(frame)); - pointsOuter[4] = NSMakePoint(NSMinX(frame) + 2, NSMaxY(frame)); - pointsOuter[5] = NSMakePoint(NSMinX(frame), NSMaxY(frame) - 2); - pointsOuter[6] = NSMakePoint(NSMinX(frame), NSMidY(frame) - 2); - - [pathOuter appendBezierPathWithPoints: pointsOuter count: 7]; - } - - //Shrink frame for filling of center - frame = NSInsetRect(frame, 1, 1); - - if([self tickMarkPosition] == NSTickMarkBelow) { - - pointsInner[0] = NSMakePoint(NSMinX(frame) + 2, NSMinY(frame)); - pointsInner[1] = NSMakePoint(NSMaxX(frame) - 2, NSMinY(frame)); - pointsInner[2] = NSMakePoint(NSMaxX(frame), NSMinY(frame) + 2); - pointsInner[3] = NSMakePoint(NSMaxX(frame), NSMidY(frame) + 2); - pointsInner[4] = NSMakePoint(NSMidX(frame), NSMaxY(frame)); - pointsInner[5] = NSMakePoint(NSMinX(frame), NSMidY(frame) + 2); - pointsInner[6] = NSMakePoint(NSMinX(frame), NSMinY(frame) + 2); - - [pathInner appendBezierPathWithPoints: pointsInner count: 7]; - - } else { - - pointsInner[0] = NSMakePoint(NSMidX(frame), NSMinY(frame)); - pointsInner[1] = NSMakePoint(NSMaxX(frame), NSMidY(frame) - 2); - pointsInner[2] = NSMakePoint(NSMaxX(frame), NSMaxY(frame) - 2); - pointsInner[3] = NSMakePoint(NSMaxX(frame) - 2, NSMaxY(frame)); - pointsInner[4] = NSMakePoint(NSMinX(frame) + 2, NSMaxY(frame)); - pointsInner[5] = NSMakePoint(NSMinX(frame), NSMaxY(frame) - 2); - pointsInner[6] = NSMakePoint(NSMinX(frame), NSMidY(frame) - 2); - - [pathInner appendBezierPathWithPoints: pointsInner count: 7]; - } - - } else { - - // [pathOuter appendBezierPathWithOvalInRect: frame]; - // - // frame = NSInsetRect(frame, 1, 1); - - [pathInner appendBezierPathWithOvalInRect: frame]; - } - - //I use two NSBezierPaths here to create the border because doing a simple - //[path stroke] leaves ghost lines when the knob is moved. - - //Draw Base Layer - if([self isEnabled]) { - - [NSGraphicsContext saveGraphicsState]; - //Draw Focus ring or shadow depending on highlight state. - if([self isHighlighted] && ([self focusRingType] == NSFocusRingTypeDefault || - [self focusRingType] == NSFocusRingTypeExterior)) { - - [[[[BGThemeManager keyedManager] themeForKey: self.themeKey] focusRing] set]; - } else { - - [[[[BGThemeManager keyedManager] themeForKey: self.themeKey] dropShadow] set]; - } - - [[[[BGThemeManager keyedManager] themeForKey: self.themeKey] strokeColor] set]; - [pathOuter fill]; - - [NSGraphicsContext restoreGraphicsState]; - } else { - - [[[[BGThemeManager keyedManager] themeForKey: self.themeKey] disabledStrokeColor] set]; - [pathOuter fill]; - } - - //Draw Inner Layer - if([self isEnabled]) { - - if([self isHighlighted]) { - - [[[[BGThemeManager keyedManager] themeForKey: self.themeKey] highlightKnobColor] drawInBezierPath: pathInner angle: 90]; - } else { - - [[[[BGThemeManager keyedManager] themeForKey: self.themeKey] knobColor] drawInBezierPath: pathInner angle: 90]; - } - } else { - - [[[[BGThemeManager keyedManager] themeForKey: self.themeKey] disabledKnobColor] drawInBezierPath: pathInner angle: 90]; - } - -} - -- (void)drawVerticalKnobInFrame:(NSRect)frame { - - switch ([self controlSize]) { - - case NSRegularControlSize: - - if([self numberOfTickMarks] != 0) { - - if([self tickMarkPosition] == NSTickMarkRight) { - - frame.origin.x -= 3; - } - - frame.origin.x += 3; - frame.origin.y += 2; - frame.size.height = 15; - frame.size.width = 19; - } else { - - frame.origin.x += 3; - frame.origin.y += 3; - frame.size.height = 15; - frame.size.width = 15; - } - break; - - case NSSmallControlSize: - - if([self numberOfTickMarks] != 0) { - - frame.origin.x += 1; - frame.origin.y += 1; - frame.size.height = 11; - frame.size.width = 13; - } else { - - frame.origin.x += 2; - frame.origin.y += 2; - frame.size.height = 11; - frame.size.width = 11; - } - break; - - case NSMiniControlSize: - - if([self numberOfTickMarks] != 0) { - - frame.origin.y += 1; - frame.size.height = 9; - frame.size.width = 11; - } else { - - frame.origin.x += 1; - frame.origin.y += 1; - frame.size.height = 9; - frame.size.width = 9; - } - break; - } - - NSBezierPath *pathOuter = [[NSBezierPath alloc] init]; - NSBezierPath *pathInner = [[NSBezierPath alloc] init]; - NSPoint pointsOuter[7]; - NSPoint pointsInner[7]; - - if([self numberOfTickMarks] != 0) { - - if([self tickMarkPosition] == NSTickMarkRight) { - - pointsOuter[0] = NSMakePoint(NSMinX(frame), NSMinY(frame) + 2); - pointsOuter[1] = NSMakePoint(NSMinX(frame) + 2, NSMinY(frame)); - pointsOuter[2] = NSMakePoint(NSMidX(frame) + 2, NSMinY(frame)); - pointsOuter[3] = NSMakePoint(NSMaxX(frame), NSMidY(frame)); - pointsOuter[4] = NSMakePoint(NSMidX(frame) + 2, NSMaxY(frame)); - pointsOuter[5] = NSMakePoint(NSMinX(frame) + 2, NSMaxY(frame)); - pointsOuter[6] = NSMakePoint(NSMinX(frame), NSMaxY(frame) - 2); - - [pathOuter appendBezierPathWithPoints: pointsOuter count: 7]; - - } else { - - pointsOuter[0] = NSMakePoint(NSMinX(frame), NSMidY(frame)); - pointsOuter[1] = NSMakePoint(NSMidX(frame) - 2, NSMinY(frame)); - pointsOuter[2] = NSMakePoint(NSMaxX(frame) - 2, NSMinY(frame)); - pointsOuter[3] = NSMakePoint(NSMaxX(frame), NSMinY(frame) + 2); - pointsOuter[4] = NSMakePoint(NSMaxX(frame), NSMaxY(frame) - 2); - pointsOuter[5] = NSMakePoint(NSMaxX(frame) - 2, NSMaxY(frame)); - pointsOuter[6] = NSMakePoint(NSMidX(frame) - 2, NSMaxY(frame)); - - [pathOuter appendBezierPathWithPoints: pointsOuter count: 7]; - } - - frame = NSInsetRect(frame, 1, 1); - - if([self tickMarkPosition] == NSTickMarkRight) { - - pointsInner[0] = NSMakePoint(NSMinX(frame), NSMinY(frame) + 2); - pointsInner[1] = NSMakePoint(NSMinX(frame) + 2, NSMinY(frame)); - pointsInner[2] = NSMakePoint(NSMidX(frame) + 2, NSMinY(frame)); - pointsInner[3] = NSMakePoint(NSMaxX(frame), NSMidY(frame)); - pointsInner[4] = NSMakePoint(NSMidX(frame) + 2, NSMaxY(frame)); - pointsInner[5] = NSMakePoint(NSMinX(frame) + 2, NSMaxY(frame)); - pointsInner[6] = NSMakePoint(NSMinX(frame), NSMaxY(frame) - 2); - - [pathInner appendBezierPathWithPoints: pointsInner count: 7]; - - } else { - - pointsInner[0] = NSMakePoint(NSMinX(frame), NSMidY(frame)); - pointsInner[1] = NSMakePoint(NSMidX(frame) - 2, NSMinY(frame)); - pointsInner[2] = NSMakePoint(NSMaxX(frame) - 2, NSMinY(frame)); - pointsInner[3] = NSMakePoint(NSMaxX(frame), NSMinY(frame) + 2); - pointsInner[4] = NSMakePoint(NSMaxX(frame), NSMaxY(frame) - 2); - pointsInner[5] = NSMakePoint(NSMaxX(frame) - 2, NSMaxY(frame)); - pointsInner[6] = NSMakePoint(NSMidX(frame) - 2, NSMaxY(frame)); - - [pathInner appendBezierPathWithPoints: pointsInner count: 7]; - } - - } else { - - [pathOuter appendBezierPathWithOvalInRect: frame]; - - frame = NSInsetRect(frame, 1, 1); - - [pathInner appendBezierPathWithOvalInRect: frame]; - } - - //I use two NSBezierPaths here to create the border because doing a simple - //[path stroke] leaves ghost lines when the knob is moved. - - //Draw Base Layer - if([self isEnabled]) { - - [NSGraphicsContext saveGraphicsState]; - - if([self isHighlighted] && ([self focusRingType] == NSFocusRingTypeDefault || - [self focusRingType] == NSFocusRingTypeExterior)) { - - [[[[BGThemeManager keyedManager] themeForKey: self.themeKey] focusRing] set]; - } else { - - [[[[BGThemeManager keyedManager] themeForKey: self.themeKey] dropShadow] set]; - } - - [[[[BGThemeManager keyedManager] themeForKey: self.themeKey] strokeColor] set]; - [pathOuter fill]; - - [NSGraphicsContext restoreGraphicsState]; - } else { - - [[[[BGThemeManager keyedManager] themeForKey: self.themeKey] disabledStrokeColor] set]; - [pathOuter fill]; - } - - //Draw Inner Layer - if([self isEnabled]) { - - if([self isHighlighted]) { - - [[[[BGThemeManager keyedManager] themeForKey: self.themeKey] highlightKnobColor] drawInBezierPath: pathInner angle: 90]; - } else { - - [[[[BGThemeManager keyedManager] themeForKey: self.themeKey] knobColor] drawInBezierPath: pathInner angle: 90]; - } - } else { - - [[[[BGThemeManager keyedManager] themeForKey: self.themeKey] disabledKnobColor] drawInBezierPath: pathInner angle: 90]; - } - -} - -#pragma mark - -#pragma mark Overridden Methods - -- (BOOL)_usesCustomTrackImage { - - return YES; -} - -#pragma mark - - -@end diff --git a/bilibili/Player/Control/BGTheme.h b/bilibili/Player/Control/BGTheme.h deleted file mode 100755 index 1c06720..0000000 --- a/bilibili/Player/Control/BGTheme.h +++ /dev/null @@ -1,114 +0,0 @@ -// -// BGThemeManager.h -// BGHUDAppKit -// -// Created by BinaryGod on 6/15/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 - - -@interface BGTheme : NSObject { - - BOOL useAlpha; -} - -//Scroller Theme --(NSColor *)scrollerStroke; //Color for Arrows/Knob Border --(NSGradient *)scrollerKnobGradient; //Gradient used to draw knob --(NSGradient *)scrollerTrackGradient; //Gradient used to draw knob track --(NSGradient *)scrollerArrowNormalGradient; //Gradient used on normal Arrow button --(NSGradient *)scrollerArrowPushedGradient; //Gradient used on pushed Arrow button --(CGFloat)scrollerAlphaValue; - -//Slider Theme --(NSColor *)sliderTrackColor; //Color used to draw slider track --(NSColor *)disabledSliderTrackColor; //Color used to draw disabled slider track --(NSGradient *)knobColor; //Gradient used to draw the knob --(NSGradient *)highlightKnobColor; //Gradient used to draw highlighted knob --(NSGradient *)disabledKnobColor; //Gradient used to draw disabled knob - -//Text Based Theme --(BOOL)isOverrideFillColor; --(NSColor *)textFillColor; //Color of background if drawbackground set to ON --(NSColor *)selectionHighlightActiveColor; //Background color of higlighted text (active app) --(NSColor *)selectionHighlightInActiveColor; //Background color of higlighted text (inactive app) --(NSColor *)selectionTextActiveColor; //Selection text color (active app) --(NSColor *)selectionTextInActiveColor; //Selection text color (inactive app) --(NSColor *)placeholderTextColor; //Placeholder text color - -//Progress Theme --(NSGradient *)progressTrackGradient; //Gradient used to draw progress bar track - -//Token Theme --(NSColor *)tokenFillNormal; //Color used to fill normal token background --(NSColor *)tokenFillHighlight; //Color used to fill highlighted token background --(NSColor *)tokenBorder; //Color used to draw token border --(NSColor *)tokenTextColor; //Color used to draw token text - -//Table Theme --(NSColor *)cellHighlightColor; //Color used to highlight selected row --(NSArray *)cellAlternatingRowColors; //NSArray with 2 Colors used to draw alternating rows --(NSColor *)cellSelectedTextColor; //Color used to draw text when row selected --(NSColor *)cellEditingFillColor; //Color used to draw background of editing cell --(NSColor *)tableBackgroundColor; //Color used to fill table background --(NSColor *)tableHeaderCellBorderColor; //Color used to draw border in column headers --(NSGradient *)tableHeaderCellNormalFill; //Gradient used to draw normal column header --(NSGradient *)tableHeaderCellPushedFill; //Gradient used to draw pushed column header --(NSGradient *)tableHeaderCellSelectedFill; //Gradient used to draw selected column header - -//General Theme --(CGFloat)gradientAngle; --(NSGradient *)normalGradient; //Gradient used to draw normal background --(NSGradient *)disabledNormalGradient; //Gradient used for disabled background --(NSGradient *)pushedGradient; //Gradient used to draw pushed background --(NSGradient *)highlightGradient; //Gradient used to draw highlight background --(NSGradient *)normalComplexGradient; //Gradient used to draw normal 4 tone gradient --(NSGradient *)disabledNormalComplexGradient; //Gradient used to draw disabled 4 tone gradient --(NSGradient *)pushedComplexGradient; //Gradient used to draw pushed 4 tone gradient --(NSGradient *)highlightComplexGradient; //Gradient used to draw highlight 4 tone gradient --(NSColor *)normalSolidFill; //Solid color used to draw normal background --(NSColor *)disabledNormalSolidFill; //Solid color used to draw disabled background --(NSColor *)pushedSolidFill; //Solid color used to draw pushed background --(NSColor *)highlightSolidFill; //Solid color used to draw highlight background --(NSColor *)strokeColor; //Color used to draw border --(NSColor *)disabledStrokeColor; //Color used for disabled border --(NSColor *)darkStrokeColor; //Color used to draw dark shadow border --(NSColor *)textColor; //Color used to draw text --(NSColor *)highlightTextColor; --(NSColor *)disabledTextColor; //Color used to draw disabled text --(NSShadow *)dropShadow; //Drop shadow used on all controls --(CGFloat)alphaValue; //Alpha value that is an optional paremeter, used only - //if you want certain colors to be draw with the same - //alpha value. --(CGFloat)disabledAlphaValue; //Same as above but the disabled varient --(NSShadow *)focusRing; //Shadow used for the focus rings - -@end diff --git a/bilibili/Player/Control/BGTheme.m b/bilibili/Player/Control/BGTheme.m deleted file mode 100755 index 4231776..0000000 --- a/bilibili/Player/Control/BGTheme.m +++ /dev/null @@ -1,383 +0,0 @@ -// -// BGThemeManager.m -// BGHUDAppKit -// -// Created by BinaryGod on 6/15/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 "BGTheme.h" - - -@implementation BGTheme - -#pragma mark Scroller Theme - --(id)init { - - self = [super init]; - - return self; -} - --(NSColor *)scrollerStroke { - - return [NSColor colorWithDeviceRed: 0.749f green: 0.761f blue: 0.788f alpha: 1.0f]; -} - --(NSGradient *)scrollerKnobGradient { - - return [[NSGradient alloc] initWithStartingColor: [NSColor colorWithDeviceRed: 0.631f green: 0.639f blue: 0.655f alpha: 1.0f] - endingColor: [NSColor colorWithDeviceRed: 0.439f green: 0.447f blue: 0.471f alpha: 1.0f]]; -} - --(NSGradient *)scrollerTrackGradient { - - return [[NSGradient alloc] initWithStartingColor: [NSColor colorWithDeviceRed: 0.137f green: 0.137f blue: 0.137f alpha: .75f] - endingColor: [NSColor colorWithDeviceRed: 0.278f green: 0.278f blue: 0.278f alpha: .75f]]; -} - --(NSGradient *)scrollerArrowNormalGradient { - - return [[NSGradient alloc] initWithStartingColor: [NSColor colorWithDeviceRed: 0.251f green: 0.251f blue: 0.255f alpha: [self scrollerAlphaValue]] - endingColor: [NSColor colorWithDeviceRed: 0.118f green: 0.118f blue: 0.118f alpha: [self scrollerAlphaValue]]]; -} - --(NSGradient *)scrollerArrowPushedGradient { - - return [[NSGradient alloc] initWithStartingColor: [NSColor colorWithDeviceRed: 0.451f green: 0.451f blue: 0.455f alpha: [self scrollerAlphaValue]] - endingColor: [NSColor colorWithDeviceRed: 0.318f green: 0.318f blue: 0.318f alpha: [self scrollerAlphaValue]]]; -} - --(CGFloat)scrollerAlphaValue { - - return 0.5f; -} - -#pragma mark - -#pragma mark Slider Theme - -#define colorEnable (0.7f) -#define colorDisable (0.3f) - --(NSColor *)sliderTrackColor { - - return [NSColor colorWithDeviceRed: colorEnable green: colorEnable blue: colorEnable alpha: [self alphaValue]]; -} - --(NSColor *)disabledSliderTrackColor { - - return [NSColor colorWithDeviceRed: colorDisable green: colorDisable blue: colorDisable alpha: [self disabledAlphaValue]]; -} - --(NSGradient *)knobColor { - - return [[NSGradient alloc] initWithStartingColor: [NSColor colorWithDeviceRed: colorEnable green: colorEnable blue: colorEnable alpha: 1.0f] - endingColor: [NSColor colorWithDeviceRed: colorEnable green: colorEnable blue: colorEnable alpha: 1.0f]]; -} - --(NSGradient *)highlightKnobColor { - - return [[NSGradient alloc] initWithStartingColor: [NSColor colorWithDeviceRed: colorEnable green: colorEnable blue: colorEnable alpha: 1.0f] - endingColor: [NSColor colorWithDeviceRed: colorEnable green: colorEnable blue: colorEnable alpha: 1.0f]]; -} - --(NSGradient *)disabledKnobColor { - - return [[NSGradient alloc] initWithStartingColor: [NSColor colorWithDeviceRed: colorDisable green: colorDisable blue: colorDisable alpha: [self disabledAlphaValue]] - endingColor: [NSColor colorWithDeviceRed: colorDisable green: colorDisable blue: colorDisable alpha: [self disabledAlphaValue]]]; -} - -#pragma mark - -#pragma mark Text Based Theme - --(BOOL)isOverrideFillColor { - return YES; -} --(NSColor *)textFillColor { - - return [NSColor colorWithDeviceRed: .224f green: .224f blue: .224f alpha: .95f]; -} - --(NSColor *)selectionHighlightActiveColor { - - return [NSColor darkGrayColor]; -} - --(NSColor *)selectionHighlightInActiveColor { - - return [NSColor darkGrayColor]; -} - --(NSColor *)selectionTextActiveColor { - - return [NSColor whiteColor]; -} - --(NSColor *)selectionTextInActiveColor { - - return [NSColor whiteColor]; -} - --(NSColor *)placeholderTextColor { - - return [NSColor grayColor]; -} - -#pragma mark - -#pragma mark Progress Theme - --(NSGradient *)progressTrackGradient { - - return [[NSGradient alloc] initWithStartingColor: [NSColor colorWithCalibratedRed: 0.125f green: 0.125f blue: 0.125f alpha: 1.0f] - endingColor: [NSColor colorWithCalibratedRed: 0.208f green: 0.208f blue: 0.208f alpha: 1.0f]]; -} - -#pragma mark - -#pragma mark Token Theme - --(NSColor *)tokenFillNormal { - - return [NSColor colorWithDeviceRed: 0.249f green: 0.261f blue: 0.288f alpha: 1.0f]; -} - --(NSColor *)tokenFillHighlight { - - return [NSColor colorWithDeviceRed: 0.449f green: 0.461f blue: 0.488f alpha: 1.0f]; -} - --(NSColor *)tokenBorder { - - return [NSColor whiteColor]; -} - --(NSColor *)tokenTextColor { - - return [NSColor whiteColor]; -} - -#pragma mark - -#pragma mark Table Theme - --(NSColor *)cellHighlightColor { - - return [NSColor colorWithDeviceRed: 0.549f green: 0.561f blue: 0.588f alpha: 1]; -} - --(NSArray *)cellAlternatingRowColors { - - return [NSArray arrayWithObjects: - [NSColor colorWithCalibratedWhite: 0.16f alpha: 0.86f], - [NSColor colorWithCalibratedWhite: 0.15f alpha: 0.8f], - nil]; -} - --(NSColor *)cellSelectedTextColor { - - return [NSColor blackColor]; -} - --(NSColor *)cellEditingFillColor { - - return [NSColor colorWithDeviceRed: 0.141f green: 0.141f blue: 0.141f alpha: [self alphaValue]]; -} - --(NSColor *)tableBackgroundColor { - - return [NSColor colorWithCalibratedRed: 0 green: 0 blue: 0 alpha: 0]; -} - --(NSColor *)tableHeaderCellBorderColor { - - return [NSColor colorWithDeviceRed: 0.349f green: 0.361f blue: 0.388f alpha: 1.0f]; -} - --(NSGradient *)tableHeaderCellNormalFill { - - return [[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]]; -} - --(NSGradient *)tableHeaderCellPushedFill { - - return [[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]]; -} - --(NSGradient *)tableHeaderCellSelectedFill { - - return [[NSGradient alloc] initWithStartingColor: [NSColor colorWithDeviceRed: 0.651f green: 0.651f blue: 0.655f alpha: 1.0f] - endingColor: [NSColor colorWithDeviceRed: 0.518f green: 0.518f blue: 0.518f alpha: 1.0f]]; -} - -#pragma mark - -#pragma mark General Theme - --(CGFloat)gradientAngle { - return 90.0f; -} --(NSGradient *)normalGradient { - - return [[NSGradient alloc] initWithStartingColor: [NSColor colorWithDeviceRed: 0.118f green: 0.118f blue: 0.118f alpha: [self alphaValue]] - endingColor: [NSColor colorWithDeviceRed: 0.118f green: 0.118f blue: 0.118f alpha: [self alphaValue]]]; -} - --(NSGradient *)disabledNormalGradient { - - return [[NSGradient alloc] initWithStartingColor: [NSColor colorWithDeviceRed: 0.118f green: 0.118f blue: 0.118f alpha: [self disabledAlphaValue]] - endingColor: [NSColor colorWithDeviceRed: 0.118f green: 0.118f blue: 0.118f alpha: [self disabledAlphaValue]]]; -} - --(NSGradient *)pushedGradient { - - return [[NSGradient alloc] initWithStartingColor: [NSColor colorWithDeviceRed: 0.318f green: 0.318f blue: 0.318f alpha: [self alphaValue]] - endingColor: [NSColor colorWithDeviceRed: 0.318f green: 0.318f blue: 0.318f alpha: [self alphaValue]]]; -} - --(NSGradient *)highlightGradient { - - return [[NSGradient alloc] initWithStartingColor: [NSColor colorWithDeviceRed: 0.318f green: 0.318f blue: 0.318f alpha: [self alphaValue]] - endingColor: [NSColor colorWithDeviceRed: 0.318f green: 0.318f blue: 0.318f alpha: [self alphaValue]]]; -} - --(NSGradient *)normalComplexGradient { - - return [[NSGradient alloc] initWithColorsAndLocations: [NSColor colorWithDeviceRed: 0.324f green: 0.331f blue: 0.347f alpha: [self alphaValue]], - (CGFloat)0, [NSColor colorWithDeviceRed: 0.245f green: 0.253f blue: 0.269f alpha: [self alphaValue]], (CGFloat).5, - [NSColor colorWithDeviceRed: 0.206f green: 0.214f blue: 0.233f alpha: [self alphaValue]], (CGFloat).5, - [NSColor colorWithDeviceRed: 0.139f green: 0.147f blue: 0.167f alpha: [self alphaValue]], (CGFloat)1.0f, nil]; -} - --(NSGradient *)disabledNormalComplexGradient { - - return [[NSGradient alloc] initWithColorsAndLocations: [NSColor colorWithDeviceRed: 0.324f green: 0.331f blue: 0.347f alpha: [self disabledAlphaValue]], - (CGFloat)0, [NSColor colorWithDeviceRed: 0.245f green: 0.253f blue: 0.269f alpha: [self disabledAlphaValue]], (CGFloat).5, - [NSColor colorWithDeviceRed: 0.206f green: 0.214f blue: 0.233f alpha: [self disabledAlphaValue]], (CGFloat).5, - [NSColor colorWithDeviceRed: 0.139f green: 0.147f blue: 0.167f alpha: [self disabledAlphaValue]], (CGFloat)1.0f, nil]; -} - --(NSGradient *)pushedComplexGradient { - - return [[NSGradient alloc] initWithColorsAndLocations: [NSColor colorWithDeviceRed: 0.524f green: 0.531f blue: 0.547f alpha: [self alphaValue]], - (CGFloat)0, [NSColor colorWithDeviceRed: 0.445f green: 0.453f blue: 0.469f alpha: [self alphaValue]], (CGFloat).5, - [NSColor colorWithDeviceRed: 0.406f green: 0.414f blue: 0.433f alpha: [self alphaValue]], (CGFloat).5, - [NSColor colorWithDeviceRed: 0.339f green: 0.347f blue: 0.367f alpha: [self alphaValue]], (CGFloat)1.0f, nil]; -} - --(NSGradient *)highlightComplexGradient { - - return [[NSGradient alloc] initWithColorsAndLocations: [NSColor colorWithDeviceRed: 0.524f green: 0.531f blue: 0.547f alpha: [self alphaValue]], - (CGFloat)0, [NSColor colorWithDeviceRed: 0.445f green: 0.453f blue: 0.469f alpha: [self alphaValue]], (CGFloat).5, - [NSColor colorWithDeviceRed: 0.406f green: 0.414f blue: 0.433f alpha: [self alphaValue]], (CGFloat).5, - [NSColor colorWithDeviceRed: 0.339f green: 0.347f blue: 0.367f alpha: [self alphaValue]], (CGFloat)1.0f, nil]; -} - --(NSColor *)normalSolidFill { - - return [NSColor colorWithDeviceRed: 0.141f green: 0.141f blue: 0.141f alpha: [self alphaValue]]; -} - --(NSColor *)disabledNormalSolidFill { - - return [NSColor colorWithDeviceRed: 0.141f green: 0.141f blue: 0.141f alpha: [self disabledAlphaValue]]; -} - --(NSColor *)pushedSolidFill { - - return [NSColor colorWithDeviceRed: 0.941f green: 0.941f blue: 0.941f alpha: [self alphaValue]]; -} - --(NSColor *)highlightSolidFill { - - return [NSColor colorWithDeviceRed: 0.941f green: 0.941f blue: 0.941f alpha: [self alphaValue]]; -} - --(NSColor *)strokeColor { - - return [NSColor colorWithDeviceRed: 0.749f green: 0.761f blue: 0.788f alpha: 1.0f]; -} - --(NSColor *)disabledStrokeColor { - - return [NSColor colorWithDeviceRed: 0.749f green: 0.761f blue: 0.788f alpha: [self disabledAlphaValue]]; -} - --(NSColor *)darkStrokeColor { - - return [NSColor colorWithDeviceRed: 0.141f green: 0.141f blue: 0.141f alpha: 0.5f]; -} - --(NSColor *)textColor { - - return [NSColor whiteColor]; -} - --(NSColor *)highlightTextColor { - - return [NSColor whiteColor]; -} --(NSColor *)disabledTextColor { - - return [NSColor colorWithDeviceRed: 1 green: 1 blue: 1 alpha: [self disabledAlphaValue]]; -} - --(NSShadow *)dropShadow { - - NSShadow *shadow = [[NSShadow alloc] init]; - [shadow setShadowColor: [NSColor blackColor]]; - [shadow setShadowBlurRadius: 2]; - [shadow setShadowOffset: NSMakeSize( 0, -1)]; - - return shadow; -} - --(CGFloat)alphaValue { - - return 0.8f; -} - --(CGFloat)disabledAlphaValue { - - return 0.4f; -} - --(NSShadow *)focusRing { - - NSShadow *shadow = [[NSShadow alloc] init]; - [shadow setShadowColor: [NSColor whiteColor]]; - [shadow setShadowBlurRadius: 3]; - [shadow setShadowOffset: NSMakeSize( 0, 0)]; - - return shadow; -} - -#pragma mark - - - -@end diff --git a/bilibili/Player/Control/BGThemeManager.h b/bilibili/Player/Control/BGThemeManager.h deleted file mode 100644 index c775134..0000000 --- a/bilibili/Player/Control/BGThemeManager.h +++ /dev/null @@ -1,48 +0,0 @@ -// -// BGThemeManager.h -// BGHUDAppKit -// -// Created by BinaryGod on 6/15/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 -#import "BGTheme.h" - -@interface BGThemeManager : NSObject { - - NSMutableDictionary *themes; -} - -+ (BGThemeManager *)keyedManager; --(void)initDefaultThemes; -- (BGTheme *)themeForKey:(NSString *)key; -- (void)setTheme:(BGTheme *)theme forKey:(NSString *)key; - -@end diff --git a/bilibili/Player/Control/BGThemeManager.m b/bilibili/Player/Control/BGThemeManager.m deleted file mode 100755 index 0ba9680..0000000 --- a/bilibili/Player/Control/BGThemeManager.m +++ /dev/null @@ -1,91 +0,0 @@ -// -// BGThemeManager.m -// BGHUDAppKit -// -// Created by BinaryGod on 6/15/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 "BGThemeManager.h" - - -@implementation BGThemeManager - -static BGThemeManager *sharedThemeManager = nil; - -+ (BGThemeManager *)keyedManager; -{ - if (sharedThemeManager == nil) { - sharedThemeManager = [[super allocWithZone:NULL] init]; - [sharedThemeManager initDefaultThemes]; - } - return sharedThemeManager; -} - -+ (id)allocWithZone:(NSZone *)zone; -{ - return [self keyedManager]; -} - --(void)initDefaultThemes { - - //Init our Dictionary for 2 defaults - themes = [[NSMutableDictionary alloc] initWithCapacity: 2]; - - //Add the default Flat and Gradient themes - [themes setObject: [[BGTheme alloc] init] forKey: @"flatTheme"]; - //[themes setObject: [[BGGradientTheme alloc] init] forKey: @"gradientTheme"]; -} - -- (BGTheme *)themeForKey:(NSString *)key { - - //Make sure the key exists before we try to - //return it - if([themes objectForKey: key]) { - - return [themes objectForKey: key]; - } else { - - //Return the default gradient key - return [themes objectForKey: @"gradientTheme"]; - } - - -} - -- (void)setTheme:(BGTheme *)theme forKey:(NSString *)key { - - [themes setObject: theme forKey: key]; -} - -- (id)copyWithZone:(NSZone *)zone; { - return self; -} - -@end diff --git a/bilibili/Player/Control/PlayerControlView.m b/bilibili/Player/Control/PlayerControlView.m index 40f0649..78f3e16 100644 --- a/bilibili/Player/Control/PlayerControlView.m +++ b/bilibili/Player/Control/PlayerControlView.m @@ -178,6 +178,8 @@ - (void)show{ selector:@selector(updateTime) userInfo:nil repeats:YES]; + +/* if(playerWindow.level - NSNormalWindowLevel > -1){ [self.window setLevel:playerWindow.level + 1]; [self.window orderWindow:NSWindowAbove relativeTo:playerWindow.windowNumber]; @@ -187,6 +189,14 @@ - (void)show{ [self savePlayPosition]; } } +*/ + + [playerWindow addChildWindow:self.window ordered:1]; + [[self.window animator] setAlphaValue:1.0]; + isHided = NO; + if(needSaveTime){ + [self savePlayPosition]; + } } - (void)hide:(BOOL)noAnimation{ @@ -194,8 +204,13 @@ - (void)hide:(BOOL)noAnimation{ return; } [[self.window animator] setAlphaValue:0.0]; + +/* [self.window setLevel:NSNormalWindowLevel]; [self.window orderWindow:NSWindowAbove relativeTo:playerWindow.windowNumber]; +*/ + [playerWindow removeChildWindow:self.window]; + if(noAnimation){ [self orderOut]; }else{ diff --git a/bilibili/Player/Control/TimeSilderCell.swift b/bilibili/Player/Control/TimeSilderCell.swift new file mode 100644 index 0000000..e8aa5ef --- /dev/null +++ b/bilibili/Player/Control/TimeSilderCell.swift @@ -0,0 +1,29 @@ +// +// TimeSilderCell.swift +// bilibili +// +// Created by xjbeta on 2016/12/2. +// Copyright © 2016年 TYPCN. All rights reserved. +// + +import Cocoa + +class TimeSliderCell: NSSliderCell { + override func drawKnob(_ knobRect: NSRect) { + NSColor.white.setFill() + NSRectFill(knobRect) + } + override func knobRect(flipped: Bool) -> NSRect { + let knobWidth: CGFloat = 3 + let knobHeight: CGFloat = 12 + let width = barRect(flipped: true).size.width + var x: CGFloat = CGFloat(doubleValue / maxValue) * width - knobWidth / 2 + let y: CGFloat = (15 - knobHeight) / 2 + if x < 0 { + x = 0 + } else if x > width - knobWidth { + x = width - knobWidth + } + return NSRect(x: x, y: y, width: knobWidth, height: knobHeight) + } +} diff --git a/bilibili/Player/Control/TimeSliderCell.h b/bilibili/Player/Control/TimeSliderCell.h deleted file mode 100644 index 5d92757..0000000 --- a/bilibili/Player/Control/TimeSliderCell.h +++ /dev/null @@ -1,27 +0,0 @@ -// -// TimeSliderCell.h -// bilibili -// -// Created by TYPCN on 2016/3/5. -// Copyright © 2016 TYPCN. All rights reserved. -// - -#import -#import "BGHUDSliderCell.h" - -typedef enum -{ - kTSDragStopped = 0, - kTSDragStarted = 1, - kTSDragContinue = 2 -} TSDRAG_STATE; - -@interface TimeSliderCell : BGHUDSliderCell -{ - BOOL dragging; - TSDRAG_STATE dragState; -} - -@property (readonly, getter=isDragging) BOOL dragging; - -@end \ No newline at end of file diff --git a/bilibili/Player/Control/TimeSliderCell.m b/bilibili/Player/Control/TimeSliderCell.m deleted file mode 100644 index 49289b1..0000000 --- a/bilibili/Player/Control/TimeSliderCell.m +++ /dev/null @@ -1,201 +0,0 @@ -/* - * MPlayerX - TimeSliderCell.m - * - * Copyright (C) 2009 - 2011, Zongyao QU - * - * MPlayerX is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * MPlayerX is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with MPlayerX; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -// Updated by TYPCN on 3/5/16 - -#import "TimeSliderCell.h" - -@implementation TimeSliderCell - -@synthesize dragging; - --(id) initWithCoder:(NSCoder*) decoder -{ - self = [super initWithCoder:decoder]; - - if (self) { - dragging = NO; - dragState = kTSDragStopped; - } - return self; -} - --(BOOL) startTrackingAt:(NSPoint)startPoint inView:(NSView*)controlView -{ - // MPLog(@"Start Trackinng"); - dragState = kTSDragStarted; - - return [super startTrackingAt:startPoint inView:controlView]; -} - -- (void)stopTracking:(NSPoint)lastPoint at:(NSPoint)stopPoint inView:(NSView *)controlView mouseIsUp:(BOOL)flag -{ - // MPLog(@"Stop Tracking\n"); - dragState = kTSDragStopped; - - [super stopTracking:lastPoint at:stopPoint inView:controlView mouseIsUp:flag]; -} - -- (BOOL)continueTracking:(NSPoint)lastPoint at:(NSPoint)currentPoint inView:(NSView *)controlView -{ - // MPLog(@"Conti Tracking\n"); - switch (dragState) { - // stopped - case kTSDragStopped: - dragging = NO; - break; - // started - case kTSDragStarted: - dragState = kTSDragContinue; - break; - // continue - default: - dragging = YES; - break; - } - - return [super continueTracking:lastPoint at:currentPoint inView:controlView]; -} - -- (void)drawBarInside:(NSRect)aRect flipped:(BOOL)flipped { - - if([self sliderType] == NSLinearSlider) { - - if(![self isVertical]) { - - [self drawHorizontalBarInFrame: aRect]; - return; - } else { - // [self drawVerticalBarInFrame: aRect]; - } - } else { - //Placeholder for when I figure out how to draw NSCircularSlider - } - [super drawBarInside:aRect flipped:flipped]; -} - -- (void)drawKnob:(NSRect)aRect { - - if([self sliderType] == NSLinearSlider) { - - if(![self isVertical]) { - - [self drawHorizontalKnobInFrame: aRect]; - return; - } else { - // [self drawVerticalKnobInFrame: aRect]; - } - } else { - //Place holder for when I figure out how to draw NSCircularSlider - } - [super drawKnob:aRect]; -} - -- (void)drawHorizontalBarInFrame:(NSRect)frame { - - // Adjust frame based on ControlSize - switch ([self controlSize]) { - - case NSSmallControlSize: - - if([self numberOfTickMarks] != 0) { - - if([self tickMarkPosition] == NSTickMarkBelow) { - - frame.origin.y += 2; - } else { - - frame.origin.y += frame.size.height - 8; - } - } else { - - frame.origin.y = frame.origin.y + (((frame.origin.y + frame.size.height) /2) - 2.5f); - } - - frame.origin.x += 0.5f; - frame.origin.y -= 2.0f; - frame.size.width -= 1.0f; - frame.size.height = 3.0f; - break; - default: - [super drawHorizontalBarInFrame:frame]; - return; - } - - //Draw Bar - NSBezierPath *path = [[NSBezierPath alloc] init]; - - [path appendBezierPathWithRoundedRect:frame xRadius:1 yRadius:1]; - - if([self isEnabled]) { - [[NSColor colorWithDeviceWhite:1.00 alpha:0.20] set]; - [path fill]; - } else { - [[NSColor colorWithDeviceWhite:0.04 alpha:0.20] set]; - [path fill]; - } -} - -- (void)drawHorizontalKnobInFrame:(NSRect)frame { - - NSRect rcBounds = [[self controlView] bounds]; - NSBezierPath *path, *line; - - switch ([self controlSize]) { - - case NSSmallControlSize: - rcBounds.origin.y = rcBounds.origin.y + (((rcBounds.origin.y + rcBounds.size.height) /2) - 2.5f); - rcBounds.origin.x += 0.5f; - rcBounds.origin.y -= 0.0f; - rcBounds.size.width -= 0.5f; - rcBounds.size.height = 3.0f; - - rcBounds.size.width *= ([self floatValue]/[self maxValue]); - - path = [[NSBezierPath alloc] init]; - [path appendBezierPathWithRoundedRect:rcBounds xRadius:1 yRadius:1]; - - line = [[NSBezierPath alloc] init]; - CGFloat left = rcBounds.size.width - 3; - if(left < 0){ - left = 0; - } - [line appendBezierPathWithRect:NSMakeRect(left, rcBounds.origin.y - 4, 3, 12)]; - - if([self isEnabled]) { - [[NSColor colorWithDeviceWhite:0.6 alpha:1.0] set]; - [path fill]; - } else { - [[NSColor colorWithDeviceWhite:0.3 alpha:1.0] set]; - [path fill]; - } - -// [[NSColor colorWithDeviceWhite:0.0 alpha:0.3] set]; -// [path stroke]; - - [[NSColor whiteColor] set]; - [line fill]; - - break; - default: - [super drawHorizontalKnobInFrame:frame]; - break; - } -} -@end \ No newline at end of file