1 #import "ITSplashScreen.h"
2 #import "ITSplashWindow.h"
3 #import "ITSplashView.h"
5 static ITSplashScreen *_sharedScreen;
7 @implementation ITSplashScreen
9 + (ITSplashScreen *)sharedController {
11 _sharedScreen = [[ITSplashScreen alloc] init];
17 if ((self = [super init])) {
18 _window = [[ITSplashWindow alloc] initWithContentRect:NSMakeRect(0, 0, 200, 200) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
19 _view = [[ITSplashView alloc] initWithFrame:NSMakeRect(0, 0, 200, 200)];
20 [_window setLevel:NSStatusWindowLevel];
21 [_window setContentView:[_view autorelease]];
31 - (double)progressValue {
32 return ([[_view progressIndicator] doubleValue] / 100.0);
35 - (void)setProgressValue:(double)progress {
36 if (progress >= 1.0) {
37 [[_view progressIndicator] setIndeterminate:YES];
39 [[_view progressIndicator] setDoubleValue:(progress * 100.0)];
47 - (void)setImage:(NSImage *)image {
48 NSRect rect = NSZeroRect, newRect = [_window frame];
49 rect.size = [image size];
50 newRect.size = rect.size;
51 [_window setFrame:newRect display:NO];
54 [_view setFrame:newRect];
55 [_view setImage:image];
59 - (NSString *)string {
60 return [_view string];
63 - (void)setString:(NSString *)string {
64 [_view setString:string];
67 - (void)setSettingsPath:(NSString *)path {
68 [_view loadControlsFromPath:path];
71 - (void)showSplashWindow {
72 //[_window setAlphaValue:0.0];
73 [_window makeKeyAndOrderFront:nil];
74 //_fadeTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / 30.0) target:self selector:@selector(showStep:) userInfo:nil repeats:YES];
77 - (void)showStep:(NSTimer *)timer {
78 [_window setAlphaValue:([_window alphaValue] + 0.05)];
79 if ([_window alphaValue] >= 1.0) {
85 - (void)closeSplashWindow {
87 [_fadeTimer invalidate];
89 _fadeTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / 30.0) target:self selector:@selector(closeStep:) userInfo:nil repeats:YES];
92 - (void)closeStep:(NSTimer *)timer {
93 [_window setAlphaValue:([_window alphaValue] - 0.05)];
94 if ([_window alphaValue] <= 0.0) {
97 [_window orderOut:nil];
98 [_view stopAnimation];