X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fmacosx%2Fmisc.m;h=3a033f820aed22e43137cceaba0b5a8dbccd8d9e;hb=8a5d95d032dd1d3773858ece1d5efe2f970d6bab;hp=b466c6f905b3a2a24775043a91aebd175f8f4151;hpb=6ee1e193fd896ab9a4729fde14f009d9ce629815;p=vlc diff --git a/modules/gui/macosx/misc.m b/modules/gui/macosx/misc.m index b466c6f905..3a033f820a 100644 --- a/modules/gui/macosx/misc.m +++ b/modules/gui/macosx/misc.m @@ -1,10 +1,11 @@ /***************************************************************************** * misc.m: code not specific to vlc ***************************************************************************** - * Copyright (C) 2003-2007 the VideoLAN team + * Copyright (C) 2003-2008 the VideoLAN team * $Id$ * * Authors: Jon Lech Johansen + * Felix Paul Kühne * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,13 +22,67 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ -#include +#import +#import -#include "intf.h" /* VLCApplication */ -#include "misc.h" -#include "playlist.h" -#include "controls.h" +#import "intf.h" /* VLCApplication */ +#import "misc.h" +#import "playlist.h" +#import "controls.h" +/***************************************************************************** + * NSImage (VLCAdditions) + * + * Addition to NSImage + *****************************************************************************/ +@implementation NSImage (VLCAdditions) ++ (id)imageWithSystemName:(int)name +{ + /* ugly Carbon stuff following... + * regrettably, you can't get the icons through clean Cocoa */ + + /* retrieve our error icon */ + NSImage * icon; + IconRef ourIconRef; + int returnValue; + returnValue = GetIconRef(kOnSystemDisk, 'macs', name, &ourIconRef); + icon = [[[NSImage alloc] initWithSize:NSMakeSize(32,32)] autorelease]; + [icon lockFocus]; + CGRect rect = CGRectMake(0,0,32,32); + PlotIconRefInContext((CGContextRef)[[NSGraphicsContext currentContext] + graphicsPort], + &rect, + kAlignNone, + kTransformNone, + NULL /*inLabelColor*/, + kPlotIconRefNormalFlags, + (IconRef)ourIconRef); + [icon unlockFocus]; + returnValue = ReleaseIconRef(ourIconRef); + return icon; +} + ++ (id)imageWithWarningIcon +{ + static NSImage * imageWithWarningIcon = nil; + if( !imageWithWarningIcon ) + { + imageWithWarningIcon = [[[self class] imageWithSystemName:'caut'] retain]; + } + return imageWithWarningIcon; +} + ++ (id)imageWithErrorIcon +{ + static NSImage * imageWithErrorIcon = nil; + if( !imageWithErrorIcon ) + { + imageWithErrorIcon = [[[self class] imageWithSystemName:'stop'] retain]; + } + return imageWithErrorIcon; +} + +@end /***************************************************************************** * NSAnimation (VLCAdditions) * @@ -113,7 +168,6 @@ static NSMutableArray *blackoutWindows = NULL; [blackoutWindows makeObjectsPerformSelector:@selector(close)]; [blackoutWindows removeAllObjects]; - for(i = 0; i < [[NSScreen screens] count]; i++) { NSScreen *screen = [[NSScreen screens] objectAtIndex: i]; @@ -124,7 +178,7 @@ static NSMutableArray *blackoutWindows = NULL; continue; screen_rect = [screen frame]; - screen_rect.origin.x = screen_rect.origin.y = 0.0f; + screen_rect.origin.x = screen_rect.origin.y = 0; /* blackoutWindow alloc strategy - The NSMutableArray blackoutWindows has the blackoutWindow references @@ -135,10 +189,14 @@ static NSMutableArray *blackoutWindows = NULL; [blackoutWindow setBackgroundColor:[NSColor blackColor]]; [blackoutWindow setLevel: NSFloatingWindowLevel]; /* Disappear when Expose is triggered */ + [blackoutWindow displayIfNeeded]; [blackoutWindow orderFront: self animate: YES]; [blackoutWindows addObject: blackoutWindow]; [blackoutWindow release]; + + if( [screen isMainScreen ] ) + SetSystemUIMode( kUIModeAllHidden, kUIOptionAutoShowMenuBar); } } @@ -151,6 +209,8 @@ static NSMutableArray *blackoutWindows = NULL; VLCWindow *blackoutWindow = [blackoutWindows objectAtIndex: i]; [blackoutWindow closeAndAnimate: YES]; } + + SetSystemUIMode( kUIModeNormal, 0); } @end @@ -381,15 +441,6 @@ static NSMutableArray *blackoutWindows = NULL; [super dealloc]; } -#if GC_ENABLED -- (void)finalize -{ - /* dealloc doesn't get called on 10.5 if GC is enabled, so we need to provide the basic functionality here */ - [self unregisterDraggedTypes]; - [super finalize]; -} -#endif - - (void)awakeFromNib { [self registerForDraggedTypes:[NSArray arrayWithObjects:NSTIFFPboardType, @@ -468,15 +519,6 @@ static NSMutableArray *blackoutWindows = NULL; [super dealloc]; } -#if GC_ENABLED -- (void)finalize -{ - /* dealloc doesn't get called on 10.5 if GC is enabled, so we need to provide the basic functionality here */ - [self unregisterDraggedTypes]; - [super finalize]; -} -#endif - - (void)awakeFromNib { [self registerForDraggedTypes:[NSArray arrayWithObjects:NSTIFFPboardType, @@ -653,14 +695,27 @@ void _drawFrameInRect(NSRect frameRect) - (id)init { self = [super init]; - _knobOff = [[NSImage imageNamed:@"volumeslider_normal"] retain]; - _knobOn = [[NSImage imageNamed:@"volumeslider_blue"] retain]; + _knobOff = [NSImage imageNamed:@"volumeslider_normal"]; + [self controlTintChanged]; + [[NSNotificationCenter defaultCenter] addObserver: self + selector: @selector( controlTintChanged ) + name: NSControlTintDidChangeNotification + object: nil]; b_mouse_down = FALSE; return self; } +- (void)controlTintChanged +{ + if( [NSColor currentControlTint] == NSGraphiteControlTint ) + _knobOn = [NSImage imageNamed:@"volumeslider_graphite"]; + else + _knobOn = [NSImage imageNamed:@"volumeslider_blue"]; +} + - (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver: self]; [_knobOff release]; [_knobOn release]; [super dealloc];