#import "ITSplashWindow.h"
#import "ITSplashView.h"
-static ITSplashScreen *_sharedController;
+static ITSplashScreen *_sharedScreen;
@implementation ITSplashScreen
-+ (ITSplashScreen *)sharedController
-{
- if (!_sharedController) {
- _sharedController = [[ITSplashScreen alloc] init];
++ (ITSplashScreen *)sharedController {
+ if (!_sharedScreen) {
+ _sharedScreen = [[ITSplashScreen alloc] init];
}
- return _sharedController;
+ return _sharedScreen;
}
-- (id)init
-{
- if ( (self = [super init]) ) {
+- (id)init {
+ if ((self = [super init])) {
_window = [[ITSplashWindow alloc] initWithContentRect:NSMakeRect(0, 0, 200, 200) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
_view = [[ITSplashView alloc] initWithFrame:NSMakeRect(0, 0, 200, 200)];
[_window setLevel:NSStatusWindowLevel];
return self;
}
-- (void)dealloc
-{
+- (void)dealloc {
[_window release];
[super dealloc];
}
-- (double)progressValue
-{
+- (double)progressValue {
return ([[_view progressIndicator] doubleValue] / 100.0);
}
-- (void)setProgressValue:(double)progress
-{
+- (void)setProgressValue:(double)progress {
if (progress >= 1.0) {
[[_view progressIndicator] setIndeterminate:YES];
} else {
}
}
-- (NSImage *)image
-{
+- (NSImage *)image {
return [_view image];
}
-- (void)setImage:(NSImage *)image
-{
+- (void)setImage:(NSImage *)image {
NSRect rect = NSZeroRect, newRect = [_window frame];
rect.size = [image size];
newRect.size = rect.size;
[_window center];
}
-- (NSString *)string
-{
+- (NSString *)string {
return [_view string];
}
-- (void)setString:(NSString *)string
-{
+- (void)setString:(NSString *)string {
[_view setString:string];
}
-- (void)setSettingsPath:(NSString *)path
-{
+- (void)setSettingsPath:(NSString *)path {
[_view loadControlsFromPath:path];
}
-- (void)showSplashWindow
-{
+- (void)showSplashWindow {
//[_window setAlphaValue:0.0];
[_window makeKeyAndOrderFront:nil];
//_fadeTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / 30.0) target:self selector:@selector(showStep:) userInfo:nil repeats:YES];
}
-- (void)showStep:(NSTimer *)timer
-{
- [_window setAlphaValue:[_window alphaValue] + 0.05];
+- (void)showStep:(NSTimer *)timer {
+ [_window setAlphaValue:([_window alphaValue] + 0.05)];
if ([_window alphaValue] >= 1.0) {
[timer invalidate];
_fadeTimer = nil;
}
}
-- (void)closeSplashWindow
-{
+- (void)closeSplashWindow {
if (_fadeTimer) {
[_fadeTimer invalidate];
}
_fadeTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / 30.0) target:self selector:@selector(closeStep:) userInfo:nil repeats:YES];
}
-- (void)closeStep:(NSTimer *)timer
-{
- [_window setAlphaValue:[_window alphaValue] - 0.05];
+- (void)closeStep:(NSTimer *)timer {
+ [_window setAlphaValue:([_window alphaValue] - 0.05)];
if ([_window alphaValue] <= 0.0) {
[timer invalidate];
_fadeTimer = nil;