Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
758 additions
and
32 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// | ||
// CameraOverlayController.h | ||
// phototest | ||
// | ||
// Created by James Urquhart on 17/09/2009. | ||
// Copyright 2009 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
#import "OverlayDesc.h" | ||
|
||
@class TestView; | ||
|
||
@interface CameraOverlayController : UIViewController { | ||
IBOutlet TestView *theView; | ||
IBOutlet UIToolbar *toolbar; | ||
|
||
IBOutlet UIActivityIndicatorView *savingView; | ||
IBOutlet UILabel *savingDesc; | ||
|
||
UIImagePickerController *currentPicker; | ||
OverlayDesc *overlay; | ||
|
||
int saveCount; | ||
} | ||
|
||
@property(nonatomic, retain) TestView *theView; | ||
@property(nonatomic, retain) UIToolbar *toolbar; | ||
|
||
@property(nonatomic, retain) UIActivityIndicatorView *savingView; | ||
@property(nonatomic, retain) UILabel *savingDesc; | ||
|
||
@property(nonatomic, assign) UIImagePickerController *currentPicker; | ||
|
||
@property(nonatomic, assign) bool saving; | ||
@property(nonatomic, retain) OverlayDesc *overlay; | ||
|
||
- (void)setCameraToolbar:(BOOL)animated; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
// | ||
// CameraOverlayController.m | ||
// phototest | ||
// | ||
// Created by James Urquhart on 17/09/2009. | ||
// Copyright 2009 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import "CameraOverlayController.h" | ||
#import "phototestAppDelegate.h" | ||
#import "TestView.h" | ||
|
||
@implementation CameraOverlayController | ||
|
||
@synthesize theView; | ||
@synthesize toolbar; | ||
|
||
@synthesize savingView; | ||
@synthesize savingDesc; | ||
|
||
@synthesize currentPicker; | ||
@dynamic saving; | ||
@dynamic overlay; | ||
|
||
|
||
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. | ||
- (void)viewDidLoad { | ||
[super viewDidLoad]; | ||
|
||
UIView *myView = self.view; | ||
|
||
myView.opaque = NO; | ||
myView.backgroundColor = [UIColor clearColor]; | ||
|
||
theView = [[TestView alloc] initWithFrame:CGRectMake(0, 0, 320.0, 480.0-54)]; | ||
[myView addSubview:theView]; | ||
[myView bringSubviewToFront:savingView]; | ||
[myView bringSubviewToFront:savingDesc]; | ||
self.overlay = overlay; | ||
|
||
saveCount = 0; | ||
savingView.hidden = YES; | ||
savingDesc.hidden = YES; | ||
|
||
savingDesc.text = NSLocalizedString(@"sav_stat", @"SAVING"); | ||
|
||
[self setCameraToolbar:NO]; | ||
} | ||
|
||
- (void)cancelSelect:(id)sender | ||
{ | ||
phototestAppDelegate *del = [[UIApplication sharedApplication] delegate]; | ||
[del imagePickerControllerDidCancel:del.picker]; | ||
} | ||
|
||
- (void)cameraSelect:(id)sender | ||
{ | ||
[currentPicker takePicture]; | ||
} | ||
|
||
|
||
|
||
- (void)setCameraToolbar:(BOOL)animated | ||
{ | ||
UIImage *camImg = [UIImage imageNamed:@"CameraButton.png"]; | ||
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(cancelSelect:)]; | ||
UIBarButtonItem *fixedSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil]; | ||
UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; | ||
UIBarButtonItem *cameraButton = [[UIBarButtonItem alloc] initWithImage:camImg style:UIBarButtonItemStyleBordered target:self action:@selector(cameraSelect:)]; | ||
|
||
fixedSpace.width = 42.0; | ||
cameraButton.width = 96.0; | ||
|
||
UIEdgeInsets insets = cameraButton.imageInsets; | ||
insets.left = 0.0; | ||
cameraButton.imageInsets = insets; | ||
|
||
CGRect frame = toolbar.frame; | ||
frame.origin.y -= 10.0; | ||
toolbar.frame = frame; | ||
|
||
NSArray *theItems = [NSArray arrayWithObjects: | ||
cancelButton, | ||
fixedSpace, | ||
cameraButton, | ||
flexSpace, | ||
nil]; | ||
|
||
[toolbar setItems:theItems animated:animated]; | ||
|
||
// release allocated items | ||
for (UIView *view in theItems) { | ||
[view release]; | ||
} | ||
} | ||
|
||
- (void)setSaving:(bool)value | ||
{ | ||
bool hidden; | ||
|
||
if (value) { | ||
saveCount++; | ||
} else { | ||
saveCount--; | ||
if (saveCount < 0) | ||
saveCount = 0; | ||
} | ||
|
||
hidden = saveCount == 0; | ||
|
||
savingView.hidden = hidden; | ||
savingDesc.hidden = hidden; | ||
|
||
if (!hidden) | ||
[savingView startAnimating]; | ||
else | ||
[savingView stopAnimating]; | ||
|
||
} | ||
|
||
- (bool)saving | ||
{ | ||
return savingView.hidden; | ||
} | ||
|
||
|
||
- (void)didReceiveMemoryWarning { | ||
// Releases the view if it doesn't have a superview. | ||
[super didReceiveMemoryWarning]; | ||
|
||
// Release any cached data, images, etc that aren't in use. | ||
} | ||
|
||
- (void)viewDidUnload { | ||
// Release any retained subviews of the main view. | ||
// e.g. self.myOutlet = nil; | ||
self.theView = nil; | ||
self.toolbar = nil; | ||
|
||
self.savingDesc = nil; | ||
self.savingView = nil; | ||
} | ||
|
||
- (void)setOverlay:(OverlayDesc *)theOverlay | ||
{ | ||
if (overlay) | ||
[overlay release]; | ||
|
||
overlay = [theOverlay retain]; | ||
|
||
theView.theImage = overlay.image; | ||
theView.defaultOpacity = overlay.opacity; | ||
theView.alpha = overlay.opacity; | ||
} | ||
|
||
- (OverlayDesc*)overlay | ||
{ | ||
return overlay; | ||
} | ||
|
||
|
||
- (void)dealloc { | ||
[overlay release]; | ||
[super dealloc]; | ||
} | ||
|
||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.