The dissolve, cut and slides all work properly now, I hope :D
[ITKit.git] / ITCutWindowEffect.m
1 #import "ITCutWindowEffect.h"
2 #import "ITTransientStatusWindow.h"
3 #import "ITCoreGraphicsHacks.h"
4
5 @implementation ITCutWindowEffect
6
7
8 /*************************************************************************/
9 #pragma mark -
10 #pragma mark APPEAR METHODS
11 /*************************************************************************/
12
13 - (void)performAppear
14 {
15     CGAffineTransform transform;
16     NSPoint appearPoint;
17     
18     //Set the location on the screen
19     if ( [(ITTransientStatusWindow *)_window horizontalPosition] == ITWindowPositionLeft ) {
20         appearPoint.x = -( 32.0 + [[_window screen] visibleFrame].origin.x );
21     } else if ( [(ITTransientStatusWindow *)_window horizontalPosition] == ITWindowPositionRight ) {
22         appearPoint.x = -(([[_window screen] visibleFrame].size.width + [[_window screen] visibleFrame].origin.x) - 32.0 - [_window frame].size.width);
23     } else if ( [(ITTransientStatusWindow *)_window horizontalPosition] == ITWindowPositionCenter ) {
24         appearPoint.x = ( [_window frame].size.width - [[_window screen] visibleFrame].size.width ) / 2;
25     }
26     
27     if ( [(ITTransientStatusWindow *)_window verticalPosition] == ITWindowPositionTop ) {
28         appearPoint.y = ( 64.0 + [[_window screen] visibleFrame].origin.y - [_window frame].size.height );
29     } else if ( [(ITTransientStatusWindow *)_window verticalPosition] == ITWindowPositionBottom ) {
30         appearPoint.y = -( [[_window screen] frame].size.height - ( [_window frame].size.height + 32.0 + [[_window screen] visibleFrame].origin.y) );
31     } else if ( [(ITTransientStatusWindow *)_window verticalPosition] == ITWindowPositionMiddle ) {
32         appearPoint.y = ( [_window frame].size.height - [[_window screen] visibleFrame].size.height) / 2;
33     }
34     
35     transform = CGAffineTransformMakeTranslation(appearPoint.x, appearPoint.y);
36     CGSSetWindowTransform([NSApp contextID],
37                           (CGSWindowID)[_window windowNumber],
38                           transform);
39     
40     [_window orderFront:self];
41     [self setWindowVisibility:ITWindowVisibleState];
42 }
43
44 - (void)cancelAppear
45 {
46     [self performVanish];
47 }
48
49
50 /*************************************************************************/
51 #pragma mark -
52 #pragma mark VANISH METHODS
53 /*************************************************************************/
54
55 - (void)performVanish
56 {
57     [_window orderOut:self];
58     [self setWindowVisibility:ITWindowHiddenState];
59 }
60
61 - (void)cancelVanish
62 {
63     [self performAppear];
64 }
65
66
67 @end