1 #import "ITSplashScreen.h"
2 #import "ITSplashWindow.h"
3 #import "ITSplashView.h"
5 static ITSplashScreen *_sharedController;
7 @implementation ITSplashScreen
9 + (ITSplashScreen *)sharedController
11 if (!_sharedController) {
12 _sharedController = [[ITSplashScreen alloc] init];
14 return _sharedController;
19 if ( (self = [super init]) ) {
20 _window = [[ITSplashWindow alloc] initWithContentRect:NSMakeRect(0, 0, 200, 200) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
21 _view = [[ITSplashView alloc] initWithFrame:NSMakeRect(0, 0, 200, 200)];
22 [_window setLevel:NSStatusWindowLevel];
23 [_window setContentView:[_view autorelease]];
34 - (double)progressValue
36 return ([[_view progressIndicator] doubleValue] / 100.0);
39 - (void)setProgressValue:(double)progress
41 if (progress >= 1.0) {
42 [[_view progressIndicator] setIndeterminate:YES];
44 [[_view progressIndicator] setDoubleValue:(progress * 100.0)];
53 - (void)setImage:(NSImage *)image
55 NSRect rect = NSZeroRect, newRect = [_window frame];
56 rect.size = [image size];
57 newRect.size = rect.size;
58 [_window setFrame:newRect display:NO];
61 [_view setFrame:newRect];
62 [_view setImage:image];
68 return [_view string];
71 - (void)setString:(NSString *)string
73 [_view setString:string];
76 - (void)setSettingsPath:(NSString *)path
78 [_view loadControlsFromPath:path];
81 - (void)showSplashWindow
83 //[_window setAlphaValue:0.0];
84 [_window makeKeyAndOrderFront:nil];
85 //_fadeTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / 30.0) target:self selector:@selector(showStep:) userInfo:nil repeats:YES];
88 - (void)showStep:(NSTimer *)timer
90 [_window setAlphaValue:[_window alphaValue] + 0.05];
91 if ([_window alphaValue] >= 1.0) {
97 - (void)closeSplashWindow
100 [_fadeTimer invalidate];
102 _fadeTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / 30.0) target:self selector:@selector(closeStep:) userInfo:nil repeats:YES];
105 - (void)closeStep:(NSTimer *)timer
107 [_window setAlphaValue:[_window alphaValue] - 0.05];
108 if ([_window alphaValue] <= 0.0) {
111 [_window orderOut:nil];
112 [_view stopAnimation];