Small code cleanups.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@28976 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2009-11-08 19:26:49 +00:00
parent 2da5479a9e
commit b55e89950b
6 changed files with 128 additions and 104 deletions

View file

@ -1,3 +1,12 @@
2009-11-08 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSActionCell.m,
* Source/NSAffineTransform.m
White space changes and cleanup.
* Headers/AppKit/NSAnimation.h: Change to new MacOSX type definitions.
* Source/NSAnimation.m: Remove externs and white space changes.
* Source/externs.m: Move externs from NSAnimation to here.
2009-11-08 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSApplication.m (-finishLaunching): Only activate the

View file

@ -33,8 +33,8 @@
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
#include <Foundation/NSObject.h>
#include <AppKit/AppKitDefines.h>
#import <Foundation/NSObject.h>
#import <AppKit/AppKitDefines.h>
#include <GNUstepGUI/GSAnimator.h>
@class NSString;
@ -45,22 +45,24 @@
/** These constants describe the curve of an animation,
that is, the relative speed of an animation from start to finish. */
typedef enum _NSAnimationCurve
enum _NSAnimationCurve
{
NSAnimationEaseInOut = 0, // default
NSAnimationEaseIn,
NSAnimationEaseOut,
NSAnimationLinear,
NSAnimationSpeedInOut // GNUstep only
} NSAnimationCurve;
};
typedef NSUInteger NSAnimationCurve;
/** These constants indicate the blocking mode of an NSAnimation object when it is running. */
typedef enum _NSAnimationBlockingMode
enum _NSAnimationBlockingMode
{
NSAnimationBlocking,
NSAnimationNonblocking,
NSAnimationNonblockingThreaded
} NSAnimationBlockingMode;
};
typedef NSUInteger NSAnimationBlockingMode;
typedef float NSAnimationProgress;
@ -97,6 +99,9 @@ APPKIT_EXPORT NSString *NSAnimationProgressMarkNotification;
/** Key used in the [NSNotification-userInfo] disctionary to access the current progress mark. */
APPKIT_EXPORT NSString *NSAnimationProgressMark;
APPKIT_EXPORT NSString *NSAnimationTriggerOrderIn;
APPKIT_EXPORT NSString *NSAnimationTriggerOrderOut;
/**
* Objects of the NSAnimation class manage the timing and progress of
* animations in the user interface. The class also lets you link together

View file

@ -27,9 +27,9 @@
*/
#include "config.h"
#include <Foundation/NSCoder.h>
#include "AppKit/NSActionCell.h"
#include "AppKit/NSControl.h"
#import <Foundation/NSCoder.h>
#import "AppKit/NSActionCell.h"
#import "AppKit/NSControl.h"
@implementation NSActionCell
@ -145,7 +145,7 @@ static Class controlClass;
/**
* Retrieve the value of the receiver
*/
- (id)objectValue
- (id) objectValue
{
if (_cell.in_editing && _control_view)
if ([_control_view isKindOfClass: controlClass])
@ -156,7 +156,7 @@ static Class controlClass;
/**
* Retrieve the value of the receiver as an NSAttributedString.
*/
- (NSAttributedString*)attributedStringValue
- (NSAttributedString*) attributedStringValue
{
if (_cell.in_editing && _control_view)
if ([_control_view isKindOfClass: controlClass])
@ -167,7 +167,7 @@ static Class controlClass;
/**
* Retrieve the value of the receiver as an NSString.
*/
- (NSString *)stringValue
- (NSString *) stringValue
{
if (_cell.in_editing && _control_view)
if ([_control_view isKindOfClass: controlClass])
@ -178,7 +178,7 @@ static Class controlClass;
/**
* Retrieve the value of the receiver as a double.
*/
- (double)doubleValue
- (double) doubleValue
{
if (_cell.in_editing && _control_view)
if ([_control_view isKindOfClass: controlClass])
@ -189,7 +189,7 @@ static Class controlClass;
/**
* Retrieve the value of the receiver as a float.
*/
- (float)floatValue
- (float) floatValue
{
if (_cell.in_editing && _control_view)
if ([_control_view isKindOfClass: controlClass])
@ -200,7 +200,7 @@ static Class controlClass;
/**
* Retrieve the value of the receiver as an int.
*/
- (int)intValue
- (int) intValue
{
if (_cell.in_editing && _control_view)
if ([_control_view isKindOfClass: controlClass])
@ -287,7 +287,7 @@ static Class controlClass;
/**
* Returns the control view of the receiver.
*/
-(NSView *)controlView
-(NSView *) controlView
{
return _control_view;
}
@ -318,11 +318,11 @@ static Class controlClass;
if ([aCoder allowsKeyedCoding])
{
[aCoder encodeInt: [self tag] forKey: @"NSTag"];
if([self target] != nil)
if ([self target] != nil)
{
[aCoder encodeObject: [self target] forKey: @"NSTarget"];
}
if([self action] != NULL)
if ([self action] != NULL)
{
[aCoder encodeObject: NSStringFromSelector([self action]) forKey: @"NSAction"];
}
@ -341,6 +341,8 @@ static Class controlClass;
- (id) initWithCoder: (NSCoder*)aDecoder
{
self = [super initWithCoder: aDecoder];
if (!self)
return nil;
if ([aDecoder allowsKeyedCoding])
{

View file

@ -33,13 +33,13 @@
#include "config.h"
#include <math.h>
#include <Foundation/NSArray.h>
#include <Foundation/NSException.h>
#include <Foundation/NSString.h>
#import <Foundation/NSArray.h>
#import <Foundation/NSException.h>
#import <Foundation/NSString.h>
#include "AppKit/NSAffineTransform.h"
#include "AppKit/NSBezierPath.h"
#include "AppKit/PSOperators.h"
#import "AppKit/NSAffineTransform.h"
#import "AppKit/NSBezierPath.h"
#import "AppKit/PSOperators.h"
/* Private definitions */
#define A matrix.m11
@ -67,7 +67,7 @@ static const float pi = 3.1415926535897932384626434;
*/
- (void) concat
{
NSAffineTransformStruct matrix = [self transformStruct];
NSAffineTransformStruct matrix = [self transformStruct];
PSconcat((float*)&matrix);
}
@ -194,9 +194,9 @@ static const float pi = 3.1415926535897932384626434;
- (BOOL) isRotated
{
NSAffineTransformStruct matrix = [self transformStruct];
NSAffineTransformStruct matrix = [self transformStruct];
if (B == 0 && C == 0)
if (B == 0 && C == 0)
{
return NO;
}
@ -208,7 +208,7 @@ static const float pi = 3.1415926535897932384626434;
- (void) boundingRectFor: (NSRect)rect result: (NSRect*)newRect
{
NSAffineTransformStruct matrix = [self transformStruct];
NSAffineTransformStruct matrix = [self transformStruct];
/* Shortcuts of the usual rect values */
float x = rect.origin.x;
float y = rect.origin.y;
@ -261,7 +261,7 @@ static const float pi = 3.1415926535897932384626434;
- (NSPoint) deltaPointInMatrixSpace: (NSPoint)point
{
NSAffineTransformStruct matrix = [self transformStruct];
NSAffineTransformStruct matrix = [self transformStruct];
NSPoint new;
new.x = A * point.x + C * point.y;
@ -300,7 +300,7 @@ static const float pi = 3.1415926535897932384626434;
- (void) setMatrix: (const float[6])replace
{
NSAffineTransformStruct matrix;
NSAffineTransformStruct matrix;
GSOnceMLog(@"deprecated ... use -setTransformStruct:");
matrix.m11 = replace[0];
@ -314,7 +314,7 @@ static const float pi = 3.1415926535897932384626434;
- (void) getMatrix: (float[6])replace
{
NSAffineTransformStruct matrix = [self transformStruct];
NSAffineTransformStruct matrix = [self transformStruct];
GSOnceMLog(@"deprecated ... use -transformStruct");
replace[0] = matrix.m11;
@ -327,7 +327,7 @@ static const float pi = 3.1415926535897932384626434;
- (void) takeMatrixFromTransform: (NSAffineTransform *)aTransform
{
NSAffineTransformStruct matrix;
NSAffineTransformStruct matrix;
GSOnceMLog(@"deprecated ... use -transformStruct and setTransformStruct:");
matrix = [aTransform transformStruct];

View file

@ -26,41 +26,32 @@
Boston, MA 02110-1301, USA.
*/
#include <AppKit/NSAnimation.h>
#import <Foundation/NSDate.h>
#import <Foundation/NSDebug.h>
#import <Foundation/NSException.h>
#import <Foundation/NSLock.h>
#import <Foundation/NSNotification.h>
#import <Foundation/NSRunLoop.h>
#import <Foundation/NSThread.h>
#import <Foundation/NSValue.h>
#include <GNUstepBase/GSLock.h>
#include <Foundation/NSNotification.h>
#include <Foundation/NSValue.h>
#include <Foundation/NSException.h>
#include <Foundation/NSRunLoop.h>
#include <Foundation/NSThread.h>
#include <Foundation/NSLock.h>
#include <Foundation/NSDate.h>
#include <AppKit/NSApplication.h>
#import <AppKit/NSAnimation.h>
#import <AppKit/NSApplication.h>
// needed by NSViewAnimation
#include <AppKit/NSWindow.h>
#include <AppKit/NSView.h>
#import <AppKit/NSView.h>
#import <AppKit/NSWindow.h>
#include <Foundation/NSDebug.h>
#include <math.h>
NSString* NSAnimationBlockingRunLoopMode = @"NSAnimationBlockingRunLoopMode";
/*===================*
* NSAnimation class *
*===================*/
NSString* NSAnimationProgressMarkNotification
= @"NSAnimationProgressMarkNotification";
NSString *NSAnimationProgressMark
= @"NSAnimationProgressMark";
NSString* NSAnimationBlockingRunLoopMode
= @"NSAnimationBlockingRunLoopMode";
#define GSI_ARRAY_NO_RETAIN
#define GSI_ARRAY_NO_RELEASE
#define GSIArrayItem NSAnimationProgress
#include <math.h>
#include <GNUstepBase/GSIArray.h>
// 'reasonable value' ?
@ -69,7 +60,7 @@ NSString* NSAnimationBlockingRunLoopMode
static NSArray* _NSAnimationDefaultRunLoopModes;
static inline void
_GSBezierComputeCoefficients ( _GSBezierDesc *b )
_GSBezierComputeCoefficients(_GSBezierDesc *b)
{
b->a[0] = b->p[0];
b->a[1] =-3.0*b->p[0] + 3.0*b->p[1];
@ -79,49 +70,50 @@ _GSBezierComputeCoefficients ( _GSBezierDesc *b )
}
static inline float
_GSBezierEval (_GSBezierDesc *b, float t )
_GSBezierEval(_GSBezierDesc *b, float t)
{
if (!b->areCoefficientsComputed)
_GSBezierComputeCoefficients (b);
_GSBezierComputeCoefficients(b);
return b->a[0] + t * (b->a[1] + t * (b->a[2] + t * b->a[3]));
}
static inline float
_GSBezierDerivEval (_GSBezierDesc *b, float t )
_GSBezierDerivEval(_GSBezierDesc *b, float t)
{
if (!b->areCoefficientsComputed)
_GSBezierComputeCoefficients (b);
_GSBezierComputeCoefficients(b);
return b->a[1] + t * (2.0 * b->a[2] + t * 3.0 * b->a[3]);
}
static inline void
_GSRationalBezierComputeBezierDesc (_GSRationalBezierDesc *rb )
_GSRationalBezierComputeBezierDesc(_GSRationalBezierDesc *rb)
{
unsigned i;
for (i=0; i<4; i++)
for (i = 0; i < 4; i++)
rb->n.p[i] = (rb->d.p[i] = rb->w[i]) * rb->p[i];
_GSBezierComputeCoefficients (&rb->n);
_GSBezierComputeCoefficients (&rb->d);
_GSBezierComputeCoefficients(&rb->n);
_GSBezierComputeCoefficients(&rb->d);
rb->areBezierDescComputed = YES;
}
static inline float
_GSRationalBezierEval (_GSRationalBezierDesc *rb, float t)
_GSRationalBezierEval(_GSRationalBezierDesc *rb, float t)
{
if (!rb->areBezierDescComputed)
_GSRationalBezierComputeBezierDesc (rb);
return _GSBezierEval(&(rb->n),t) / _GSBezierEval(&(rb->d),t);
_GSRationalBezierComputeBezierDesc(rb);
return _GSBezierEval(&(rb->n), t) / _GSBezierEval(&(rb->d), t);
}
static inline float
_GSRationalBezierDerivEval (_GSRationalBezierDesc *rb, float t)
_GSRationalBezierDerivEval(_GSRationalBezierDesc *rb, float t)
{
float h;
if (!rb->areBezierDescComputed)
_GSRationalBezierComputeBezierDesc (rb);
h = _GSBezierEval (&(rb->d),t);
return ( _GSBezierDerivEval(&(rb->n),t) * h
- _GSBezierEval (&(rb->n),t) * _GSBezierDerivEval(&(rb->d),t) )
_GSRationalBezierComputeBezierDesc(rb);
h = _GSBezierEval(&(rb->d), t);
return (_GSBezierDerivEval(&(rb->n), t) * h
- _GSBezierEval (&(rb->n), t) * _GSBezierDerivEval(&(rb->d), t))
/ (h*h);
}
@ -144,7 +136,7 @@ _NSAnimationCurveDesc _gs_animationCurveDesc[] =
* gradients) to GSRBezier data (4 control points), then evaluate it.
*/
static inline float
_gs_animationValueForCurve ( _NSAnimationCurveDesc *c, float t, float t0 )
_gs_animationValueForCurve(_NSAnimationCurveDesc *c, float t, float t0)
{
if (!c->isRBezierComputed)
{
@ -172,10 +164,10 @@ _gs_animationValueForCurve ( _NSAnimationCurveDesc *c, float t, float t0 )
@end
NSComparisonResult
nsanimation_progressMarkSorter ( NSAnimationProgress first,NSAnimationProgress second)
nsanimation_progressMarkSorter(NSAnimationProgress first, NSAnimationProgress second)
{
float diff = first - second;
return (NSComparisonResult)(diff / fabs (diff));
return (NSComparisonResult)(diff / fabs(diff));
}
/* Thread locking/unlocking support macros.
@ -216,8 +208,9 @@ nsanimation_progressMarkSorter ( NSAnimationProgress first,NSAnimationProgress s
+ (void) initialize
{
unsigned i;
for (i=0; i<5; i++) // compute Bezier curve parameters...
_gs_animationValueForCurve (&_gs_animationCurveDesc[i],0.0,0.0);
for (i = 0; i < 5; i++) // compute Bezier curve parameters...
_gs_animationValueForCurve(&_gs_animationCurveDesc[i], 0.0, 0.0);
_NSAnimationDefaultRunLoopModes
= [[NSArray alloc] initWithObjects:
NSDefaultRunLoopMode,
@ -233,7 +226,6 @@ nsanimation_progressMarkSorter ( NSAnimationProgress first,NSAnimationProgress s
if (progress < 0.0) progress = 0.0;
if (progress > 1.0) progress = 1.0;
_NSANIMATION_LOCK;
if (GSIArrayCount(_progressMarks) == 0)
{ // First mark
@ -1208,14 +1200,6 @@ nsanimation_progressMarkSorter ( NSAnimationProgress first,NSAnimationProgress s
* NSViewAnimation class *
*=======================*/
NSString *NSViewAnimationTargetKey = @"NSViewAnimationTargetKey";
NSString *NSViewAnimationStartFrameKey = @"NSViewAnimationStartFrameKey";
NSString *NSViewAnimationEndFrameKey = @"NSViewAnimationEndFrameKey";
NSString *NSViewAnimationEffectKey = @"NSViewAnimationEffectKey";
NSString *NSViewAnimationFadeInEffect = @"NSViewAnimationFadeInEffect";
NSString *NSViewAnimationFadeOutEffect = @"NSViewAnimationFadeOutEffect";
@interface _GSViewAnimationBaseDesc : NSObject
{
id _target;
@ -1231,7 +1215,7 @@ NSString *NSViewAnimationFadeOutEffect = @"NSViewAnimationFadeOutEffect";
@end
@interface _GSViewAnimationDesc : _GSViewAnimationBaseDesc
{
{
BOOL _shouldHide;
BOOL _shouldUnhide;
}
@ -1251,17 +1235,18 @@ NSString *NSViewAnimationFadeOutEffect = @"NSViewAnimationFadeOutEffect";
{
NSZone* zone;
id target;
zone = [self zone];
RELEASE (self);
target = [properties objectForKey: NSViewAnimationTargetKey];
if (target!=nil)
if (target != nil)
{
if ([target isKindOfClass: [NSView class]])
self = [[_GSViewAnimationDesc allocWithZone: zone]
initWithProperties : properties];
initWithProperties: properties];
else if ([target isKindOfClass: [NSWindow class]])
self = [(_GSWindowAnimationDesc*)[_GSWindowAnimationDesc allocWithZone: zone]
initWithProperties : properties];
initWithProperties: properties];
else
[NSException
raise: NSInvalidArgumentException
@ -1296,11 +1281,12 @@ NSString *NSViewAnimationFadeOutEffect = @"NSViewAnimationFadeOutEffect";
return self;
}
- (void) setCurrentProgress: (float) progress
- (void) setCurrentProgress: (float)progress
{
if (progress < 1.0f)
{
NSRect r;
r.origin.x = _startFrame.origin.x
+ progress*( _endFrame.origin.x - _startFrame.origin.x );
r.origin.y = _startFrame.origin.y
@ -1310,7 +1296,7 @@ NSString *NSViewAnimationFadeOutEffect = @"NSViewAnimationFadeOutEffect";
r.size.height = _startFrame.size.height
+ progress*( _endFrame.size.height - _startFrame.size.height );
[self setTargetFrame:r];
[self setTargetFrame: r];
if (_effect == NSViewAnimationFadeOutEffect)
/* subclassResponsibility */;
@ -1323,8 +1309,10 @@ NSString *NSViewAnimationFadeOutEffect = @"NSViewAnimationFadeOutEffect";
}
}
- (void) setTargetFrame: (NSRect) frame;
{ [self subclassResponsibility: _cmd]; }
- (void) setTargetFrame: (NSRect)frame
{
[self subclassResponsibility: _cmd];
}
@end // implementation _GSViewAnimationDesc
@ -1342,7 +1330,7 @@ NSString *NSViewAnimationFadeOutEffect = @"NSViewAnimationFadeOutEffect";
return self;
}
- (void) setCurrentProgress: (float) progress
- (void) setCurrentProgress: (float)progress
{
[super setCurrentProgress: progress];
if (_effect == NSViewAnimationFadeOutEffect)
@ -1359,8 +1347,10 @@ NSString *NSViewAnimationFadeOutEffect = @"NSViewAnimationFadeOutEffect";
}
}
- (void) setTargetFrame: (NSRect) frame;
{ [_target setFrame:frame]; }
- (void) setTargetFrame: (NSRect)frame
{
[_target setFrame: frame];
}
@end // implementation _GSViewAnimationDesc
@ -1375,15 +1365,15 @@ NSString *NSViewAnimationFadeOutEffect = @"NSViewAnimationFadeOutEffect";
return self;
}
- (void) setCurrentProgress: (float) progress
- (void) setCurrentProgress: (float)progress
{
[super setCurrentProgress: progress];
if (_effect == NSViewAnimationFadeOutEffect)
[_target setAlphaValue: _startAlpha*(1.0f-progress)];
[_target setAlphaValue: _startAlpha * (1.0f - progress)];
if (_effect == NSViewAnimationFadeInEffect)
[_target setAlphaValue: _startAlpha+(1.0f-_startAlpha)*progress];
[_target setAlphaValue: _startAlpha + (1.0f - _startAlpha) * progress];
if (progress>=1.0f)
if (progress >= 1.0f)
{
if (_effect == NSViewAnimationFadeOutEffect)
[_target orderBack: self];
@ -1392,8 +1382,10 @@ NSString *NSViewAnimationFadeOutEffect = @"NSViewAnimationFadeOutEffect";
}
}
- (void) setTargetFrame: (NSRect) frame;
{ [_target setFrame:frame display:YES]; }
- (void) setTargetFrame: (NSRect) frame
{
[_target setFrame: frame display: YES];
}
@end // implementation _GSWindowAnimationDesc

View file

@ -76,6 +76,13 @@ NSString *NSWordTablesWriteException = @"WordTablesWrite";
NSString *GSWindowServerInternalException = @"WindowServerInternal";
// NSAnimation
NSString* NSAnimationProgressMarkNotification
= @"NSAnimationProgressMarkNotification";
NSString *NSAnimationProgressMark = @"NSAnimationProgressMark";
NSString *NSAnimationTriggerOrderIn = @"NSAnimationTriggerOrderIn";
NSString *NSAnimationTriggerOrderOut = @"NSAnimationTriggerOrderOut";
// Application notifications
NSString *NSApplicationDidBecomeActiveNotification
= @"ApplicationDidBecomeActive";
@ -384,6 +391,15 @@ NSString *NSViewBoundsDidChangeNotification
NSString *NSViewGlobalFrameDidChangeNotification
= @"NSViewGlobalFrameDidChangeNotification";
// NSViewAnimation
NSString *NSViewAnimationTargetKey = @"NSViewAnimationTargetKey";
NSString *NSViewAnimationStartFrameKey = @"NSViewAnimationStartFrameKey";
NSString *NSViewAnimationEndFrameKey = @"NSViewAnimationEndFrameKey";
NSString *NSViewAnimationEffectKey = @"NSViewAnimationEffectKey";
NSString *NSViewAnimationFadeInEffect = @"NSViewAnimationFadeInEffect";
NSString *NSViewAnimationFadeOutEffect = @"NSViewAnimationFadeOutEffect";
// NSMenu notifications
NSString* const NSMenuDidSendActionNotification = @"MenuDidSendAction";
NSString* const NSMenuWillSendActionNotification = @"MenuWillSendAction";