]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/misc.m
macosx: add visual markers for 100% of the volume (refs #8628)
[vlc] / modules / gui / macosx / misc.m
index 5985c1093793113411c8f1d74e3e31d21c39814d..875f4c50c70180ae1aaf761d91cecce0df50636f 100644 (file)
@@ -176,7 +176,7 @@ static NSMutableArray *blackoutWindows = NULL;
     NSUInteger count = [[NSScreen screens] count];
 
     for ( NSUInteger i = 0; i < count; i++ ) {
-        NSScreen *screen = [[NSScreen screens] objectAtIndex: i];
+        NSScreen *screen = [[NSScreen screens] objectAtIndex:i];
         if ([screen displayID] == displayID)
             return screen;
     }
@@ -221,7 +221,7 @@ static NSMutableArray *blackoutWindows = NULL;
 
     NSUInteger screenCount = [[NSScreen screens] count];
     for (NSUInteger i = 0; i < screenCount; i++) {
-        NSScreen *screen = [[NSScreen screens] objectAtIndex: i];
+        NSScreen *screen = [[NSScreen screens] objectAtIndex:i];
         VLCWindow *blackoutWindow;
         NSRect screen_rect;
 
@@ -255,7 +255,7 @@ static NSMutableArray *blackoutWindows = NULL;
     NSUInteger blackoutWindowCount = [blackoutWindows count];
 
     for (NSUInteger i = 0; i < blackoutWindowCount; i++) {
-        VLCWindow *blackoutWindow = [blackoutWindows objectAtIndex: i];
+        VLCWindow *blackoutWindow = [blackoutWindows objectAtIndex:i];
         [[blackoutWindow screen] setNonFullscreenPresentationOptions];
         [blackoutWindow closeAndAnimate: YES];
     }
@@ -511,6 +511,8 @@ void _drawFrameInRect(NSRect frameRect)
 
 @implementation VLCVolumeSliderCommon : NSSlider
 
+@synthesize usesBrightArtwork = _usesBrightArtwork;
+
 - (void)scrollWheel:(NSEvent *)o_event
 {
     intf_thread_t * p_intf = VLCIntf;
@@ -543,6 +545,30 @@ void _drawFrameInRect(NSRect frameRect)
     }
 }
 
+- (void)drawFullVolumeMarker
+{
+    NSRect frame = [self frame];
+
+    NSColor *drawingColor;
+    if (_usesBrightArtwork)
+        drawingColor = [[NSColor whiteColor] colorWithAlphaComponent:.8];
+    else
+        drawingColor = [[NSColor blackColor] colorWithAlphaComponent:.6];
+
+    NSBezierPath* bezierPath = [NSBezierPath bezierPath];
+
+    float fullVolPos = frame.size.width / 2.;
+    [bezierPath moveToPoint:NSMakePoint(fullVolPos, frame.size.height - 3.)];
+    [bezierPath lineToPoint:NSMakePoint(fullVolPos, 3.)];
+    [bezierPath closePath];
+
+    bezierPath.lineWidth = 1.;
+    [drawingColor setStroke];
+    [bezierPath stroke];
+    [drawingColor setFill];
+    [bezierPath fill];
+}
+
 @end
 
 /*****************************************************************************
@@ -584,6 +610,8 @@ void _drawFrameInRect(NSRect frameRect)
     [super drawRect:rect];
     [[NSGraphicsContext currentContext] restoreGraphicsState];
 
+    [self drawFullVolumeMarker];
+
     NSRect knobRect = [[self cell] knobRectFlipped:NO];
     knobRect.origin.y+=2;
     [self drawKnobInRect: knobRect];
@@ -786,4 +814,46 @@ void _drawFrameInRect(NSRect frameRect)
     [self setNeedsDisplay:YES];
 }
 
+@end
+
+@implementation PositionFormatter
+
+- (id)init
+{
+    self = [super init];
+    NSMutableCharacterSet *nonNumbers = [[[NSCharacterSet decimalDigitCharacterSet] invertedSet] mutableCopy];
+    [nonNumbers removeCharactersInString:@":"];
+    o_forbidden_characters = [nonNumbers copy];
+    [nonNumbers release];
+
+    return self;
+}
+
+- (void)dealloc
+{
+    [o_forbidden_characters release];
+    [super dealloc];
+}
+
+- (NSString*)stringForObjectValue:(id)obj
+{
+    return obj;
+}
+
+- (BOOL)getObjectValue:(id*)obj forString:(NSString*)string errorDescription:(NSString**)error
+{
+    *obj = [[string copy] autorelease];
+    return YES;
+}
+
+- (bool)isPartialStringValid:(NSString*)partialString newEditingString:(NSString**)newString errorDescription:(NSString**)error
+{
+    if ([partialString rangeOfCharacterFromSet:o_forbidden_characters options:NSLiteralSearch].location != NSNotFound) {
+        return NO;
+    } else {
+        return YES;
+    }
+}
+
+
 @end