//
//  DepthAppDelegate.m
//  Depth
//
//  Created by Bill Dudney on 7/10/08.
//  Copyright Gala Factory 2008. All rights reserved.
//
//
//  Licensed with the Apache 2.0 License
//  http://apache.org/licenses/LICENSE-2.0
//

#import "DepthViewController.h"
#import <QuartzCore/QuartzCore.h>

@implementation DepthViewController

@synthesize blue;
@synthesize red;

//START:code.depth.layers
- (void)viewDidLoad {
	[super viewDidLoad];
  self.blue = [CALayer layer];
  blue.backgroundColor = [[UIColor blueColor] CGColor];
  blue.bounds = CGRectMake(0.0f, 0.0f, 100.0f, 100.0f);
  blue.position = CGPointMake(160.0f - 20.0f, 240.0f - 20.0f);
  blue.zPosition = 5.0f;
  [self.view.layer addSublayer:blue];
  self.red = [CALayer layer];
  red.backgroundColor = [[UIColor redColor] CGColor];
  red.bounds = CGRectMake(0.0f, 0.0f, 100.0f, 100.0f);
  red.position = CGPointMake(160.0f + 20.0f, 240.0f + 20.0f);
  red.zPosition = -5.0f;
  [self.view.layer addSublayer:red];
}
//END:code.depth.layers

//START:code.depth.event
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
  CGFloat oldBlue = self.blue.zPosition;
  self.blue.zPosition = self.red.zPosition;
  self.red.zPosition = oldBlue;
}
//END:code.depth.event

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
	// Return YES for supported orientations
	return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (void)didReceiveMemoryWarning {
	[super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
	// Release anything that's not essential, such as cached data
}

- (void)dealloc {
	[super dealloc];
}

@end
