static NSMutableArray *blackoutWindows = NULL;
+static bool b_old_spaces_style = YES;
+
+ (void)load
{
/* init our fake object attribute */
blackoutWindows = [[NSMutableArray alloc] initWithCapacity:1];
+
+ if (OSX_REDACTED) {
+ NSUserDefaults *userDefaults = [[NSUserDefaults alloc] init];
+ [userDefaults addSuiteNamed:@"com.apple.spaces"];
+ /* this is system settings -> mission control -> monitors using different spaces */
+ NSNumber *o_span_displays = [userDefaults objectForKey:@"spans-displays"];
+
+ b_old_spaces_style = [o_span_displays boolValue];
+ [userDefaults release];
+ }
}
+ (NSScreen *)screenWithDisplayID: (CGDirectDisplayID)displayID
NSUInteger count = [[NSScreen screens] count];
for ( NSUInteger i = 0; i < count; i++ ) {
- NSScreen *screen = [NSScreen screens][i];
+ NSScreen *screen = [[NSScreen screens] objectAtIndex:i];
if ([screen displayID] == displayID)
return screen;
}
- (BOOL)hasMenuBar
{
- return ([self displayID] == [[NSScreen screens][0] displayID]);
+ if (b_old_spaces_style)
+ return ([self displayID] == [[[NSScreen screens] objectAtIndex:0] displayID]);
+ else
+ return YES;
}
- (BOOL)hasDock
NSUInteger screenCount = [[NSScreen screens] count];
for (NSUInteger i = 0; i < screenCount; i++) {
- NSScreen *screen = [NSScreen screens][i];
+ NSScreen *screen = [[NSScreen screens] objectAtIndex:i];
VLCWindow *blackoutWindow;
NSRect screen_rect;
backing: NSBackingStoreBuffered defer: NO screen: screen];
[blackoutWindow setBackgroundColor:[NSColor blackColor]];
[blackoutWindow setLevel: NSFloatingWindowLevel]; /* Disappear when Expose is triggered */
+ [blackoutWindow setReleasedWhenClosed:NO]; // window is released when deleted from array above
[blackoutWindow displayIfNeeded];
[blackoutWindow orderFront: self animate: YES];
NSUInteger blackoutWindowCount = [blackoutWindows count];
for (NSUInteger i = 0; i < blackoutWindowCount; i++) {
- VLCWindow *blackoutWindow = blackoutWindows[i];
+ VLCWindow *blackoutWindow = [blackoutWindows objectAtIndex:i];
[[blackoutWindow screen] setNonFullscreenPresentationOptions];
[blackoutWindow closeAndAnimate: YES];
}
- (void)awakeFromNib
{
- [self registerForDraggedTypes:@[NSFilenamesPboardType]];
+ [self registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]];
[self setImageScaling: NSScaleToFit];
[self setImageFrameStyle: NSImageFrameNone];
[self setImageAlignment: NSImageAlignCenter];
@implementation VLCVolumeSliderCommon : NSSlider
+@synthesize usesBrightArtwork = _usesBrightArtwork;
+
- (void)scrollWheel:(NSEvent *)o_event
{
intf_thread_t * p_intf = VLCIntf;
}
}
+- (void)drawFullVolumeMarker
+{
+ CGFloat maxAudioVol = self.maxValue / AOUT_VOLUME_DEFAULT;
+ if (maxAudioVol < 1.)
+ return;
+
+ NSColor *drawingColor;
+ // for bright artwork, a black color is used and vice versa
+ if (_usesBrightArtwork)
+ drawingColor = [[NSColor blackColor] colorWithAlphaComponent:.4];
+ else
+ drawingColor = [[NSColor whiteColor] colorWithAlphaComponent:.4];
+
+ NSBezierPath* bezierPath = [NSBezierPath bezierPath];
+ [self drawFullVolBezierPath:bezierPath];
+ [bezierPath closePath];
+
+ bezierPath.lineWidth = 1.;
+ [drawingColor setStroke];
+ [bezierPath stroke];
+}
+
+- (CGFloat)fullVolumePos
+{
+ CGFloat maxAudioVol = self.maxValue / AOUT_VOLUME_DEFAULT;
+ CGFloat sliderRange = [self frame].size.width - [self knobThickness];
+ CGFloat sliderOrigin = [self knobThickness] / 2.;
+
+ return 1. / maxAudioVol * sliderRange + sliderOrigin;
+}
+
+- (void)drawFullVolBezierPath:(NSBezierPath*)bezierPath
+{
+ CGFloat fullVolPos = [self fullVolumePos];
+ [bezierPath moveToPoint:NSMakePoint(fullVolPos, [self frame].size.height - 3.)];
+ [bezierPath lineToPoint:NSMakePoint(fullVolPos, 2.)];
+}
+
+@end
+
+@implementation VolumeSliderCell
+
+- (BOOL)continueTracking:(NSPoint)lastPoint at:(NSPoint)currentPoint inView:(NSView *)controlView
+{
+ VLCVolumeSliderCommon *o_slider = (VLCVolumeSliderCommon *)controlView;
+ CGFloat fullVolumePos = [o_slider fullVolumePos] + 2.;
+
+ CGPoint snapToPoint = currentPoint;
+ if (ABS(fullVolumePos - currentPoint.x) <= 4.)
+ snapToPoint.x = fullVolumePos;
+
+ return [super continueTracking:lastPoint at:snapToPoint inView:controlView];
+}
+
@end
/*****************************************************************************
[super drawRect:rect];
[[NSGraphicsContext currentContext] restoreGraphicsState];
+ [self drawFullVolumeMarker];
+
NSRect knobRect = [[self cell] knobRectFlipped:NO];
knobRect.origin.y+=2;
[self drawKnobInRect: knobRect];
@"NO", @"DisplayTimeAsTimeRemaining",
@"YES", @"DisplayFullscreenTimeAsTimeRemaining",
nil];
-
+
[defaults registerDefaults:appDefaults];
}
textAlignment = NSCenterTextAlignment;
o_remaining_identifier = @"";
}
-
+
return self;
}
- (void)awakeFromNib
{
- [self registerForDraggedTypes:@[NSFilenamesPboardType]];
+ [self registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]];
}
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
- (NSString*)stringForObjectValue:(id)obj
{
- return obj;
+ if([obj isKindOfClass:[NSString class]])
+ return obj;
+ if([obj isKindOfClass:[NSNumber class]])
+ return [obj stringValue];
+
+ return nil;
}
- (BOOL)getObjectValue:(id*)obj forString:(NSString*)string errorDescription:(NSString**)error
}
+@end
+
+@implementation NSView (EnableSubviews)
+
+- (void)enableSubviews:(BOOL)b_enable
+{
+ for (NSView *o_view in [self subviews]) {
+ [o_view enableSubviews:b_enable];
+
+ // enable NSControl
+ if ([o_view respondsToSelector:@selector(setEnabled:)]) {
+ [(NSControl *)o_view setEnabled:b_enable];
+ }
+ // also "enable / disable" text views
+ if ([o_view respondsToSelector:@selector(setTextColor:)]) {
+ if (b_enable == NO) {
+ [(NSTextField *)o_view setTextColor:[NSColor disabledControlTextColor]];
+ } else {
+ [(NSTextField *)o_view setTextColor:[NSColor controlTextColor]];
+ }
+ }
+
+ }
+}
+
@end