From: Matthew Judy Date: Tue, 28 Jan 2003 14:40:46 +0000 (+0000) Subject: Progress Check In X-Git-Tag: v0.1~63 X-Git-Url: http://git.ithinksw.org/ITKit.git/commitdiff_plain/dd9a7dd8dd7d77b949d2548fb763c9b968c69cea Progress Check In ITCoreGraphicsHacks.h Added a few more definitions to the file. ITTransientStatusWindow.* Proof-of-concept for the pivot effect. Added a temporary support method which will be removed later (setRotation:). Showcase/Controller.* Proof-of-concept for the pivot effect. Showcase/English.lproj/MainMenu.nib/* Proof-of-concept for the pivot effect. Goodnight! --- diff --git a/ITCoreGraphicsHacks.h b/ITCoreGraphicsHacks.h index a6ac460..72069dc 100755 --- a/ITCoreGraphicsHacks.h +++ b/ITCoreGraphicsHacks.h @@ -43,5 +43,10 @@ extern void CGStyleRelease(CGStyleRef style); extern CGStyleRef CGStyleCreateShadow(const CGShadowStyle *shadow); extern CGSValueObj CGSCreateCString(const char *string); extern CGSValueObj CGSCreateBoolean(CGSBoolean boolean); -extern CGError CGSSetWindowProperty(const CGSConnectionID cid, - CGSWindowID wid, const CGSValueObj key, const CGSValueObj value); +extern CGError CGSSetWindowProperty(const CGSConnectionID cid, CGSWindowID wid, const CGSValueObj key, const CGSValueObj value); + +extern CGAffineTransform CGAffineTransformMakeRotation(float angle); +extern CGAffineTransform CGAffineTransformMakeScale(float sx, float sy); +extern CGAffineTransform CGAffineTransformTranslate(CGAffineTransform t, float tx, float ty); +extern CGError CGSSetWindowWarp(const CGSConnectionID cid, CGSWindowID wid, int w,int h, float *mesh); +extern CGError CGSSetWindowTransform(const CGSConnectionID cid, CGSWindowID wid, CGAffineTransform transform); diff --git a/ITTransientStatusWindow.h b/ITTransientStatusWindow.h index 1d1a218..9592601 100755 --- a/ITTransientStatusWindow.h +++ b/ITTransientStatusWindow.h @@ -18,11 +18,12 @@ #import -@class ITTextField; -@class ITGrayRoundedView; +#define DEFAULT_EXIT_DELAY 3.0 +#define DEFAULT_EFFECT_TIME 0.33 -#define DEFAULT_EXIT_DELAY 3.0 +@class ITTextField; +@class ITGrayRoundedView; typedef enum { @@ -61,19 +62,23 @@ typedef enum { // Note: Entry effects descri ITTransientStatusWindowEffectDissolve, // Fades in. ITTransientStatusWindowEffectSlideVertically, // Slides vertically onto the screen from the nearest edge ITTransientStatusWindowEffectSlideHorizontally // Slides horizontally onto the screen from the nearest edge + ITTransientStatusWindowEffectPivot // Rotate into place from perpendicular edge } ITTransientStatusWindowEffect; @interface ITTransientStatusWindow : NSWindow { - ITTransientStatusWindowVisibilityState _visibilityState; - ITTransientStatusWindowExitMode _exitMode; - float _exitDelay; - ITTransientStatusWindowBackgroundType _backgroundType; - ITTransientStatusWindowEffect _entryEffect; - ITTransientStatusWindowEffect _exitEffect; - ITTransientStatusWindowPosition _verticalPosition; - ITTransientStatusWindowPosition _horizontalPosition; + ITTransientStatusWindowVisibilityState _visibilityState; + ITTransientStatusWindowExitMode _exitMode; + float _exitDelay; + ITTransientStatusWindowBackgroundType _backgroundType; + ITTransientStatusWindowEffect _entryEffect; + ITTransientStatusWindowEffect _exitEffect; + float _effectTime; + ITTransientStatusWindowPosition _verticalPosition; + ITTransientStatusWindowPosition _horizontalPosition; + + BOOL _reallyIgnoresEvents; NSTimer *_delayTimer; NSTimer *_fadeTimer; @@ -106,4 +111,7 @@ typedef enum { // Note: Entry effects descri - (ITTransientStatusWindowEffect)exitEffect; - (void)setExitEffect:(ITTransientStatusWindowEffect)newEffect; +- (void)setRotation:(float)angle; + + @end diff --git a/ITTransientStatusWindow.m b/ITTransientStatusWindow.m index 098bd2d..e44f703 100755 --- a/ITTransientStatusWindow.m +++ b/ITTransientStatusWindow.m @@ -71,10 +71,7 @@ static ITTransientStatusWindow *staticWindow = nil; { NSRect contentRect; - CGSValueObj key; - CGSValueObj ignore; - - // If no Content View was provided, use a generic NSImageView with the app icon. + // If no Content View was provided, use a generic NSView with the app icon. if ( ! (contentView) ) { contentView = [[[NSView alloc] initWithFrame: NSMakeRect(100.0, 100.0, 200.0, 200.0)] autorelease]; @@ -88,15 +85,16 @@ static ITTransientStatusWindow *staticWindow = nil; backing:NSBackingStoreBuffered defer:NO] ) ) { - _visibilityState = ITTransientStatusWindowHiddenState; - _exitMode = exitMode; - _exitDelay = DEFAULT_EXIT_DELAY; - _backgroundType = backgroundType; - _verticalPosition = ITTransientStatusWindowPositionBottom; - _horizontalPosition = ITTransientStatusWindowPositionLeft; - _entryEffect = ITTransientStatusWindowEffectNone; - _exitEffect = ITTransientStatusWindowEffectDissolve; - + _visibilityState = ITTransientStatusWindowHiddenState; + _exitMode = exitMode; + _exitDelay = DEFAULT_EXIT_DELAY; + _backgroundType = backgroundType; + _verticalPosition = ITTransientStatusWindowPositionBottom; + _horizontalPosition = ITTransientStatusWindowPositionLeft; + _entryEffect = ITTransientStatusWindowEffectNone; + _exitEffect = ITTransientStatusWindowEffectDissolve; + _effectTime = DEFAULT_EFFECT_TIME; + _reallyIgnoresEvents = YES; _delayTimer = nil; _fadeTimer = nil; @@ -106,16 +104,7 @@ static ITTransientStatusWindow *staticWindow = nil; // [self setContentView:contentView]; // } -// [self setIgnoresMouseEvents:YES]; - - key = CGSCreateCString("IgnoreForEvents"); - ignore = CGSCreateBoolean(kCGSTrue); - - CGSSetWindowProperty([NSApp contextID], (CGSWindowID)[self windowNumber], key, ignore); - - CGSReleaseObj(key); - CGSReleaseObj(ignore); - + [self setIgnoresMouseEvents:YES]; [self setLevel:NSScreenSaverWindowLevel]; [self setContentView:contentView]; [self rebuildWindow]; @@ -129,6 +118,38 @@ static ITTransientStatusWindow *staticWindow = nil; #pragma mark INSTANCE METHODS /*************************************************************************/ +- (void)setRotation:(float)angle +{ + CGAffineTransform transform = CGAffineTransformMakeRotation(angle); + transform.tx = -32.0; + transform.ty = [self frame].size.height + 32.0; + CGSSetWindowTransform([NSApp contextID], + (CGSWindowID)[self windowNumber], + CGAffineTransformTranslate(transform, + (([self frame].origin.x - 32.0) * -1), + (([[self screen] frame].size.height - ([self frame].origin.y) + 32.0) * -1) )); + NSLog(@"%f %f", ([self frame].origin.x * -1), ([self frame].origin.y * -1)); +} + +- (BOOL)ignoresMouseEvents +{ + return _reallyIgnoresEvents; +} + +- (void)setIgnoresMouseEvents:(BOOL)flag +{ + CGSValueObj key; + CGSValueObj ignore; + + key = CGSCreateCString("IgnoreForEvents"); + ignore = CGSCreateBoolean( (flag ? kCGSTrue : kCGSFalse) ); + CGSSetWindowProperty([NSApp contextID], (CGSWindowID)[self windowNumber], key, ignore); + CGSReleaseObj(key); + CGSReleaseObj(ignore); + + _reallyIgnoresEvents = flag; +} + - (void)orderFront:(id)sender { if ( _exitMode == ITTransientStatusWindowExitAfterDelay ) { @@ -165,6 +186,11 @@ static ITTransientStatusWindow *staticWindow = nil; } } +- (NSTimeInterval)animationResizeTime:(NSRect)newFrame +{ + return _effectTime; +} + /* - (id)contentView diff --git a/Showcase/Controller.h b/Showcase/Controller.h index 46c871d..0ce4bee 100755 --- a/Showcase/Controller.h +++ b/Showcase/Controller.h @@ -41,5 +41,6 @@ - (IBAction)buildStatusWindow:(id)sender; - (IBAction)showStatusWindow:(id)sender; - (IBAction)hideStatusWindow:(id)sender; +- (IBAction)setRotation:(id)sender; @end diff --git a/Showcase/Controller.m b/Showcase/Controller.m index 8998a38..ee2a19c 100755 --- a/Showcase/Controller.m +++ b/Showcase/Controller.m @@ -186,6 +186,8 @@ textWidth, textHeight); textField = [[[ITTextField alloc] initWithFrame:textRect] autorelease]; + [textField setEditable:NO]; + [textField setSelectable:NO]; [textField setBordered:NO]; [textField setDrawsBackground:NO]; [textField setFont:[NSFont fontWithName:@"Lucida Grande Bold" size:18]]; @@ -197,39 +199,6 @@ [[statusWindow contentView] setNeedsDisplay:YES]; } -/* -- (IBAction)foo:(id)sender -{ - - maxLineHeight = ( ( maxLineHeight > [cdImage size].height ) ? maxLineHeight : [cdImage size].height ); - - totalWidth = ( ITTSWPADDING + [cdImage size].width + ITTSWSPACING + maxLineWidth + ITTSWPADDING ); - totalHeight = ( ITTSWPADDING + maxLineHeight + ITTSWPADDING ); - - totalWidth = ( ( totalWidth > ITTSWMINW ) ? totalWidth : ITTSWMINW ); - - - [statusWindow setFrame:NSMakeRect(72.0, 72.0, totalWidth, totalHeight) - display:YES]; - - textField = [[[ITTextField alloc] initWithFrame: - NSMakeRect((24.0 + [cdImage size].width + 32.0), 24.0, maxLineWidth, maxLineHeight)] autorelease]; - [[statusWindow contentView] addSubview:textField]; - [textField setBordered:NO]; - [textField setDrawsBackground:NO]; - [textField setFont:[NSFont fontWithName:@"Lucida Grande Bold" size:18]]; - [textField setTextColor:[NSColor whiteColor]]; - [textField setCastsShadow:YES]; - [textField setStringValue:text]; - - - [[statusWindow contentView] lockFocus]; - [cdImage compositeToPoint:NSMakePoint(ITTSWPADDING, ( ITTSWPADDING + ((maxLineHeight - [cdImage size].height) / ITTSWPADDING)) ) - operation:NSCompositeSourceOver]; - [[statusWindow contentView] unlockFocus]; -} -*/ - - (IBAction)showStatusWindow:(id)sender { // [[statusWindow contentView] setNeedsDisplay:YES]; @@ -252,6 +221,12 @@ [statusWindow orderOut:self]; } +- (IBAction)setRotation:(id)sender +{ + [statusWindow setRotation:([sender floatValue] * (pi / 180))]; +} + + /*************************************************************************/ #pragma mark - #pragma mark NSWindow DELEGATE METHODS diff --git a/Showcase/English.lproj/MainMenu.nib/classes.nib b/Showcase/English.lproj/MainMenu.nib/classes.nib index e064a23..880f379 100755 --- a/Showcase/English.lproj/MainMenu.nib/classes.nib +++ b/Showcase/English.lproj/MainMenu.nib/classes.nib @@ -4,6 +4,7 @@ ACTIONS = { buildStatusWindow = id; hideStatusWindow = id; + setRotation = id; showStatusWindow = id; toggleCastsShadow = id; toggleImage = id; diff --git a/Showcase/English.lproj/MainMenu.nib/keyedobjects.nib b/Showcase/English.lproj/MainMenu.nib/keyedobjects.nib index c54ceb5..8797e10 100755 Binary files a/Showcase/English.lproj/MainMenu.nib/keyedobjects.nib and b/Showcase/English.lproj/MainMenu.nib/keyedobjects.nib differ