Added a new core image ripple effect.
[ITKit.git] / ITWindowEffect.m
1 #import "ITWindowEffect.h"
2 #import "ITTransientStatusWindow.h"
3
4
5 @implementation ITWindowEffect
6
7 + (NSArray *)effectClasses
8 {
9     NSArray *classes = [NSArray arrayWithObjects:
10         NSClassFromString(@"ITCutWindowEffect"),
11         NSClassFromString(@"ITDissolveWindowEffect"),
12         NSClassFromString(@"ITSlideHorizontallyWindowEffect"),
13         NSClassFromString(@"ITSlideVerticallyWindowEffect"),
14         NSClassFromString(@"ITPivotWindowEffect"),
15         NSClassFromString(@"ITZoomWindowEffect"),
16         NSClassFromString(@"ITSpinWindowEffect"),
17         NSClassFromString(@"ITSpinAndZoomWindowEffect"),
18                 NSClassFromString(@"ITCoreImageWindowEffect"),
19         nil];
20         
21     return classes;
22 }
23
24 - (id)initWithWindow:(NSWindow *)window
25 {
26     if ( (self = [super init]) ) {
27         _window                 = [window retain];
28         _effectTime             = DEFAULT_EFFECT_TIME;
29         _effectTimer            = nil;
30         __shouldReleaseWhenIdle = NO;
31         __idle                  = YES;
32
33         if ( [window conformsToProtocol:@protocol(ITWindowPositioning)] ) {
34             _verticalPosition   = (ITVerticalWindowPosition)[(ITTransientStatusWindow *)window verticalPosition];
35             _horizontalPosition = (ITHorizontalWindowPosition)[(ITTransientStatusWindow *)window horizontalPosition];
36         } else {
37             NSLog(@"ITWindowEffect - initWithWindow: - window does not conform to ITWindowPositioning.");
38             _verticalPosition   = ITWindowPositionBottom;
39             _horizontalPosition = ITWindowPositionLeft;
40         }
41     }
42     return self;
43 }
44
45 - (NSWindow *)window
46 {
47     return _window;
48 }
49
50 - (void)setWindow:(NSWindow *)newWindow
51 {
52     [_window autorelease];
53     _window = [newWindow retain];
54 }
55
56 - (void)setWindowVisibility:(ITWindowVisibilityState)visibilityState
57 {
58     if ( [_window conformsToProtocol:@protocol(ITWindowMotility)] ) {
59        // Cast so the compiler won't gripe
60         [(ITTransientStatusWindow *)_window setVisibilityState:visibilityState];
61     } else {
62         NSLog(@"ITWindowEffect - setWindowVisibility: - window does not conform to ITWindowVisibility.");
63     }
64 }
65
66 - (float)effectTime
67 {
68     return _effectTime;
69 }
70
71 - (void)setEffectTime:(float)newTime
72 {
73     _effectTime = newTime;
74 }
75
76 + (NSString *)effectName
77 {
78     NSLog(@"ITWindowEffect does not implement +effectName.");
79     return nil;
80 }
81
82 + (NSDictionary *)supportedPositions
83 {
84     NSLog(@"ITWindowEffect does not implement +supportedPositions.");
85     
86 //  Below is an example dictionary.  Modify it appropriately when subclassing.
87     return [NSDictionary dictionaryWithObjectsAndKeys:
88         [NSDictionary dictionaryWithObjectsAndKeys:
89             [NSNumber numberWithBool:NO], @"Left",
90             [NSNumber numberWithBool:NO], @"Center",
91             [NSNumber numberWithBool:NO], @"Right", nil] , @"Top" ,
92         [NSDictionary dictionaryWithObjectsAndKeys:
93             [NSNumber numberWithBool:NO], @"Left",
94             [NSNumber numberWithBool:NO], @"Center",
95             [NSNumber numberWithBool:NO], @"Right", nil] , @"Middle" ,
96         [NSDictionary dictionaryWithObjectsAndKeys:
97             [NSNumber numberWithBool:NO], @"Left",
98             [NSNumber numberWithBool:NO], @"Center",
99             [NSNumber numberWithBool:NO], @"Right", nil] , @"Bottom" , nil];
100 }
101
102 + (unsigned int)listOrder
103 {
104     NSLog(@"ITWindowEffect does not implement +listOrder.");
105     return 0;
106 }
107
108 - (void)performAppear
109 {
110     NSLog(@"ITWindowEffect does not implement -performAppear.");
111 }
112
113 - (void)performVanish
114 {
115     NSLog(@"ITWindowEffect does not implement -performVanish.");
116 }
117
118 - (void)cancelAppear
119 {
120     NSLog(@"ITWindowEffect does not implement -cancelAppear.");
121 }
122
123 - (void)cancelVanish
124 {
125     NSLog(@"ITWindowEffect does not implement -cancelVanish.");
126 }
127
128 - (void)releaseWhenIdle;
129 {
130     if ( __idle ) {
131         [self release];
132     } else {
133         __shouldReleaseWhenIdle = YES;
134     }
135 }
136
137 - (void)dealloc
138 {
139         [_window release];
140         [super dealloc];
141 }
142
143
144 @end