Skip to content

Commit

Permalink
formatting and whitespace fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kelan committed Jun 3, 2009
1 parent 8d18203 commit 7998a42
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 58 deletions.
2 changes: 1 addition & 1 deletion Code/SPILDAppController.h
Expand Up @@ -14,7 +14,7 @@
@interface SPILDAppController : NSObject {
IBOutlet NSWindow *_window;
IBOutlet SPILDTopLayerView *_mainView;

IBOutlet NSButton *_startStopButton;
IBOutlet NSColorWell *_fgColorWell;
IBOutlet NSColorWell *_bgColorWell;
Expand Down
14 changes: 9 additions & 5 deletions Code/SPILDAppController.m
Expand Up @@ -17,12 +17,13 @@ @implementation SPILDAppController
#pragma mark Init, Dealloc, etc
//------------------------------------------------------------------------------

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// start with a nice green
NSColor *niceGreenColor = [NSColor colorWithCalibratedRed:0.40f green:0.69f blue:0.45f alpha:1.0f];
_fgColorWell.color = niceGreenColor;
[self pickNewForeColor:_fgColorWell];

_bgColorWell.color = [NSColor blueColor];
[self pickNewBackColor:_bgColorWell];
}
Expand All @@ -33,15 +34,18 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
#pragma mark IB Actions
//------------------------------------------------------------------------------

- (IBAction)pickNewForeColor:(id)sender {
- (IBAction)pickNewForeColor:(id)sender
{
[_mainView progressIndicatorLayer].foreColor = [sender color];
}

- (IBAction)pickNewBackColor:(id)sender {
- (IBAction)pickNewBackColor:(id)sender
{
[_mainView setPlainBackgroundColor:[sender color]];
}

- (IBAction)startStopProgressIndicator:(id)sender {
- (IBAction)startStopProgressIndicator:(id)sender
{
if ([[_mainView progressIndicatorLayer] isRunning]) {
// it is running, so stop it
[[_mainView progressIndicatorLayer] stopProgressAnimation];
Expand Down
41 changes: 24 additions & 17 deletions Code/SPILDTopLayerView.m
Expand Up @@ -28,27 +28,30 @@ @implementation SPILDTopLayerView
#pragma mark Init, Dealloc, etc
//------------------------------------------------------------------------------

- (void)dealloc {
- (void)dealloc
{
[_rootLayer removeFromSuperlayer];
[_rootLayer release];

[_progressIndicatorLayer removeFromSuperlayer];
[_plainBackgroundLayer removeFromSuperlayer];
[_plainBackgroundLayer removeFromSuperlayer];
[_qcBackgroundLayer removeFromSuperlayer];

[super dealloc];
}

- (void)awakeFromNib {
- (void)awakeFromNib
{
[self setupLayers];
}


- (void)setupLayers {
- (void)setupLayers
{
_rootLayer = [CALayer layer];
[self setLayer:_rootLayer];
[self setWantsLayer:YES];

// Create the plain background layer
_plainBackgroundLayer = [CALayer layer];
_plainBackgroundLayer.name = @"plainBackgroundLayer";
Expand All @@ -59,12 +62,12 @@ - (void)setupLayers {
_plainBackgroundLayer.zPosition = 0;
_plainBackgroundLayer.backgroundColor = CGColorCreateFromNSColor([NSColor blueColor]);
[_rootLayer addSublayer:_plainBackgroundLayer];

// Start with QC background
[self useQCBackground];
// Put a YRKSpinningProgressIndicatorLayer in front of everything
_progressIndicatorLayer = [[YRKSpinningProgressIndicatorLayer alloc] init];

// Put a SpinningProgressIndicatorLayer in front of everything
_progressIndicatorLayer = [[SpinningProgressIndicatorLayer alloc] init];
_progressIndicatorLayer.name = @"progressIndicatorLayer";
_progressIndicatorLayer.anchorPoint = CGPointMake(0.0, 0.0);
_progressIndicatorLayer.position = CGPointMake(0, 0);
Expand All @@ -81,7 +84,8 @@ - (void)setupLayers {
#pragma mark Toggling Background
//------------------------------------------------------------------------------

- (IBAction)toggleBackground:(id)sender {
- (IBAction)toggleBackground:(id)sender
{
if (nil == _qcBackgroundLayer) {
[self useQCBackground];
}
Expand All @@ -90,20 +94,22 @@ - (IBAction)toggleBackground:(id)sender {
}
}

- (void)usePlainBackground {
- (void)usePlainBackground
{
// Hide the QC background and show the plain one
[CATransaction begin];
[CATransaction setValue:[NSNumber numberWithBool:YES] forKey:kCATransactionDisableActions];
_qcBackgroundLayer.hidden = YES;
_plainBackgroundLayer.hidden = NO;
[CATransaction commit];

// destroy the QC background completely, so we can test the CPU usage of just the progress indicator itself
[_qcBackgroundLayer removeFromSuperlayer];
_qcBackgroundLayer = nil;
}

- (void)useQCBackground {
- (void)useQCBackground
{
// Create the QC background layer
_qcBackgroundLayer = [QCCompositionLayer compositionLayerWithFile:
[[NSBundle mainBundle] pathForResource:@"Background" ofType:@"qtz"]];
Expand All @@ -114,7 +120,7 @@ - (void)useQCBackground {
_qcBackgroundLayer.autoresizingMask = (kCALayerWidthSizable|kCALayerHeightSizable);
_qcBackgroundLayer.zPosition = 0;
[_rootLayer addSublayer:_qcBackgroundLayer];

// Hide the plain background and show the QC one
[CATransaction begin];
[CATransaction setValue:[NSNumber numberWithBool:YES] forKey:kCATransactionDisableActions];
Expand All @@ -123,7 +129,8 @@ - (void)useQCBackground {
[CATransaction commit];
}

- (void)setPlainBackgroundColor:(NSColor *)newColor {
- (void)setPlainBackgroundColor:(NSColor *)newColor
{
[CATransaction begin];
[CATransaction setValue:[NSNumber numberWithBool:YES] forKey:kCATransactionDisableActions];
_plainBackgroundLayer.backgroundColor = CGColorCreateFromNSColor(newColor);
Expand Down
4 changes: 2 additions & 2 deletions Code/YRKSpinningProgressIndicatorLayer.h
Expand Up @@ -13,10 +13,10 @@
BOOL _isRunning;
NSTimer *_animationTimer;
NSUInteger _position;

CGColorRef _foreColor;
CGFloat _fadeDownOpacity;

NSUInteger _numFins;
NSMutableArray *_finLayers;
}
Expand Down

0 comments on commit 7998a42

Please sign in to comment.