diff --git a/.gitignore b/.gitignore
index 8ddd636..bc4d10c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,7 @@
*.mode2v3
*.perspectivev3
*.xcuserstate
+*.xccheckout
project.xcworkspace/
xcuserdata/
diff --git a/InfColorPicker.xcworkspace/contents.xcworkspacedata b/InfColorPicker.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..40ec9e7
--- /dev/null
+++ b/InfColorPicker.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
diff --git a/InfColorPicker/InfColorBarPicker.h b/InfColorPicker/InfColorBarPicker.h
index f1f7097..0243047 100644
--- a/InfColorPicker/InfColorBarPicker.h
+++ b/InfColorPicker/InfColorBarPicker.h
@@ -5,15 +5,13 @@
//
// Created by Troy Gaul on 8/9/10.
//
-// Copyright (c) 2011 InfinitApps LLC - http://infinitapps.com
+// Copyright (c) 2011-2013 InfinitApps LLC: http://infinitapps.com
// Some rights reserved: http://opensource.org/licenses/MIT
//
//==============================================================================
#import
-@class InfColorIndicatorView;
-
//------------------------------------------------------------------------------
@interface InfColorBarView : UIView
@@ -22,11 +20,9 @@
//------------------------------------------------------------------------------
-@interface InfColorBarPicker : UIControl {
- InfColorIndicatorView* indicator;
-}
+@interface InfColorBarPicker : UIControl
-@property( nonatomic ) float value;
+@property (nonatomic) float value;
@end
diff --git a/InfColorPicker/InfColorBarPicker.m b/InfColorPicker/InfColorBarPicker.m
index 4e9fc11..f19af2d 100644
--- a/InfColorPicker/InfColorBarPicker.m
+++ b/InfColorPicker/InfColorBarPicker.m
@@ -5,7 +5,7 @@
//
// Created by Troy Gaul on 8/9/10.
//
-// Copyright (c) 2011 InfinitApps LLC - http://infinitapps.com
+// Copyright (c) 2011-2013 InfinitApps LLC: http://infinitapps.com
// Some rights reserved: http://opensource.org/licenses/MIT
//
//==============================================================================
@@ -17,6 +17,12 @@
//------------------------------------------------------------------------------
+#if !__has_feature(objc_arc)
+#error This file must be compiled with ARC enabled (-fobjc-arc).
+#endif
+
+//------------------------------------------------------------------------------
+
#define kContentInsetX 20
//==============================================================================
@@ -28,7 +34,7 @@ @implementation InfColorBarView
static CGImageRef createContentImage()
{
float hsv[] = { 0.0f, 1.0f, 1.0f };
- return createHSVBarContentImage( InfComponentIndexHue, hsv );
+ return createHSVBarContentImage(InfComponentIndexHue, hsv);
}
//------------------------------------------------------------------------------
@@ -37,12 +43,12 @@ - (void) drawRect: (CGRect) rect
{
CGImageRef image = createContentImage();
- if( image ) {
+ if (image) {
CGContextRef context = UIGraphicsGetCurrentContext();
- CGContextDrawImage( context, [ self bounds ], image );
-
- CGImageRelease( image );
+ CGContextDrawImage(context, [self bounds], image);
+
+ CGImageRelease(image);
}
}
@@ -52,21 +58,8 @@ - (void) drawRect: (CGRect) rect
//==============================================================================
-@implementation InfColorBarPicker
-
-//------------------------------------------------------------------------------
-
-@synthesize value;
-
-//------------------------------------------------------------------------------
-#pragma mark Lifetime
-//------------------------------------------------------------------------------
-
-- (void) dealloc
-{
- [ indicator release ];
-
- [ super dealloc ];
+@implementation InfColorBarPicker {
+ InfColorIndicatorView* indicator;
}
//------------------------------------------------------------------------------
@@ -75,17 +68,19 @@ - (void) dealloc
- (void) layoutSubviews
{
- if( indicator == nil ) {
+ if (indicator == nil) {
CGFloat kIndicatorSize = 24.0f;
- indicator = [ [ InfColorIndicatorView alloc ] initWithFrame: CGRectMake( 0, 0, kIndicatorSize, kIndicatorSize ) ];
- [ self addSubview: indicator ];
+ indicator = [[InfColorIndicatorView alloc] initWithFrame: CGRectMake(0, 0, kIndicatorSize, kIndicatorSize)];
+ [self addSubview: indicator];
}
- indicator.color = [ UIColor colorWithHue: value saturation: 1.0f
- brightness: 1.0f alpha: 1.0f ];
+ indicator.color = [UIColor colorWithHue: self.value
+ saturation: 1.0f
+ brightness: 1.0f
+ alpha: 1.0f];
- CGFloat indicatorLoc = kContentInsetX + ( self.value * ( self.bounds.size.width - 2 * kContentInsetX ) );
- indicator.center = CGPointMake( indicatorLoc, CGRectGetMidY( self.bounds ) );
+ CGFloat indicatorLoc = kContentInsetX + (self.value * (self.bounds.size.width - 2 * kContentInsetX));
+ indicator.center = CGPointMake(indicatorLoc, CGRectGetMidY(self.bounds));
}
//------------------------------------------------------------------------------
@@ -94,11 +89,11 @@ - (void) layoutSubviews
- (void) setValue: (float) newValue
{
- if( newValue != value ) {
- value = newValue;
+ if (newValue != _value) {
+ _value = newValue;
- [ self sendActionsForControlEvents: UIControlEventValueChanged ];
- [ self setNeedsLayout ];
+ [self sendActionsForControlEvents: UIControlEventValueChanged];
+ [self setNeedsLayout];
}
}
@@ -106,34 +101,78 @@ - (void) setValue: (float) newValue
#pragma mark Tracking
//------------------------------------------------------------------------------
-- (void) trackIndicatorWithTouch: (UITouch*) touch
+- (void) trackIndicatorWithTouch: (UITouch*) touch
{
- float percent = ( [ touch locationInView: self ].x - kContentInsetX )
- / ( self.bounds.size.width - 2 * kContentInsetX );
+ float percent = ([touch locationInView: self].x - kContentInsetX)
+ / (self.bounds.size.width - 2 * kContentInsetX);
- self.value = pin( 0.0f, percent, 1.0f );
+ self.value = pin(0.0f, percent, 1.0f);
}
//------------------------------------------------------------------------------
- (BOOL) beginTrackingWithTouch: (UITouch*) touch
- withEvent: (UIEvent*) event
+ withEvent: (UIEvent*) event
{
- [ self trackIndicatorWithTouch: touch ];
+ [self trackIndicatorWithTouch: touch];
return YES;
}
//------------------------------------------------------------------------------
-- (BOOL) continueTrackingWithTouch: (UITouch*) touch
- withEvent: (UIEvent*) event
+- (BOOL) continueTrackingWithTouch: (UITouch*) touch
+ withEvent: (UIEvent*) event
{
- [ self trackIndicatorWithTouch: touch ];
+ [self trackIndicatorWithTouch: touch];
return YES;
}
+//------------------------------------------------------------------------------
+#pragma mark Accessibility
+//------------------------------------------------------------------------------
+
+- (UIAccessibilityTraits) accessibilityTraits
+{
+ UIAccessibilityTraits t = super.accessibilityTraits;
+
+ t |= UIAccessibilityTraitAdjustable;
+
+ return t;
+}
+
+//------------------------------------------------------------------------------
+
+- (void) accessibilityIncrement
+{
+ float newValue = self.value + 0.05;
+
+ if (newValue > 1.0)
+ newValue -= 1.0;
+
+ self.value = newValue;
+}
+
+//------------------------------------------------------------------------------
+
+- (void) accessibilityDecrement
+{
+ float newValue = self.value - 0.05;
+
+ if (newValue < 0)
+ newValue += 1.0;
+
+ self.value = newValue;
+}
+
+//------------------------------------------------------------------------------
+
+- (NSString*) accessibilityValue
+{
+ return [NSString stringWithFormat: @"%d degrees hue", (int) (self.value * 360.0)];
+}
+
//------------------------------------------------------------------------------
@end
diff --git a/InfColorPicker/InfColorIndicatorView.h b/InfColorPicker/InfColorIndicatorView.h
index 7a519b9..979cce8 100644
--- a/InfColorPicker/InfColorIndicatorView.h
+++ b/InfColorPicker/InfColorIndicatorView.h
@@ -5,7 +5,7 @@
//
// Created by Troy Gaul on 8/10/10.
//
-// Copyright (c) 2011 InfinitApps LLC - http://infinitapps.com
+// Copyright (c) 2011-2013 InfinitApps LLC: http://infinitapps.com
// Some rights reserved: http://opensource.org/licenses/MIT
//
//==============================================================================
@@ -16,7 +16,7 @@
@interface InfColorIndicatorView : UIView
-@property( retain, nonatomic ) UIColor* color;
+@property (nonatomic) UIColor* color;
@end
diff --git a/InfColorPicker/InfColorIndicatorView.m b/InfColorPicker/InfColorIndicatorView.m
index 99b0f4e..c1e3a08 100644
--- a/InfColorPicker/InfColorIndicatorView.m
+++ b/InfColorPicker/InfColorIndicatorView.m
@@ -5,28 +5,30 @@
//
// Created by Troy Gaul on 8/10/10.
//
-// Copyright (c) 2011 InfinitApps LLC - http://infinitapps.com
+// Copyright (c) 2011-2013 InfinitApps LLC: http://infinitapps.com
// Some rights reserved: http://opensource.org/licenses/MIT
//
//==============================================================================
#import "InfColorIndicatorView.h"
-//==============================================================================
+//------------------------------------------------------------------------------
-@implementation InfColorIndicatorView
+#if !__has_feature(objc_arc)
+#error This file must be compiled with ARC enabled (-fobjc-arc).
+#endif
-//------------------------------------------------------------------------------
+//==============================================================================
-@synthesize color;
+@implementation InfColorIndicatorView
//------------------------------------------------------------------------------
- (id) initWithFrame: (CGRect) frame
{
- self = [ super initWithFrame: frame ];
+ self = [super initWithFrame: frame];
- if( self ) {
+ if (self) {
self.opaque = NO;
self.userInteractionEnabled = NO;
}
@@ -36,22 +38,12 @@ - (id) initWithFrame: (CGRect) frame
//------------------------------------------------------------------------------
-- (void) dealloc
-{
- [ color release ];
-
- [ super dealloc ];
-}
-
-//------------------------------------------------------------------------------
-
- (void) setColor: (UIColor*) newColor
{
- if( ![ color isEqual: newColor ] ) {
- [ color release ];
- color = [ newColor retain ];
+ if (![_color isEqual: newColor]) {
+ _color = newColor;
- [ self setNeedsDisplay ];
+ [self setNeedsDisplay];
}
}
@@ -61,28 +53,28 @@ - (void) drawRect: (CGRect) rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
- CGPoint center = { CGRectGetMidX( self.bounds ), CGRectGetMidY( self.bounds ) };
- CGFloat radius = CGRectGetMidX( self.bounds );
+ CGPoint center = { CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds) };
+ CGFloat radius = CGRectGetMidX(self.bounds);
// Fill it:
- CGContextAddArc( context, center.x, center.y, radius - 1.0f, 0.0f, 2.0f * (float) M_PI, YES );
- [ self.color setFill ];
- CGContextFillPath( context );
-
+ CGContextAddArc(context, center.x, center.y, radius - 1.0f, 0.0f, 2.0f * (float) M_PI, YES);
+ [self.color setFill];
+ CGContextFillPath(context);
+
// Stroke it (black transucent, inner):
- CGContextAddArc( context, center.x, center.y, radius - 1.0f, 0.0f, 2.0f * (float) M_PI, YES );
- CGContextSetGrayStrokeColor( context, 0.0f, 0.5f );
- CGContextSetLineWidth( context, 2.0f );
- CGContextStrokePath( context );
-
+ CGContextAddArc(context, center.x, center.y, radius - 1.0f, 0.0f, 2.0f * (float) M_PI, YES);
+ CGContextSetGrayStrokeColor(context, 0.0f, 0.5f);
+ CGContextSetLineWidth(context, 2.0f);
+ CGContextStrokePath(context);
+
// Stroke it (white, outer):
- CGContextAddArc( context, center.x, center.y, radius - 2.0f, 0.0f, 2.0f * (float) M_PI, YES );
- CGContextSetGrayStrokeColor( context, 1.0f, 1.0f );
- CGContextSetLineWidth( context, 2.0f );
- CGContextStrokePath( context );
+ CGContextAddArc(context, center.x, center.y, radius - 2.0f, 0.0f, 2.0f * (float) M_PI, YES);
+ CGContextSetGrayStrokeColor(context, 1.0f, 1.0f);
+ CGContextSetLineWidth(context, 2.0f);
+ CGContextStrokePath(context);
}
//------------------------------------------------------------------------------
diff --git a/InfColorPicker/InfColorPicker.h b/InfColorPicker/InfColorPicker.h
index 206112f..ce7f869 100644
--- a/InfColorPicker/InfColorPicker.h
+++ b/InfColorPicker/InfColorPicker.h
@@ -5,7 +5,7 @@
//
// Created by Troy Gaul on 7 Aug 2010.
//
-// Copyright (c) 2011 InfinitApps LLC - http://infinitapps.com
+// Copyright (c) 2011-2013 InfinitApps LLC: http://infinitapps.com
// Some rights reserved: http://opensource.org/licenses/MIT
//
//==============================================================================
@@ -38,21 +38,21 @@ to have an object that implements one of the methods in the
Example
-------
- - (void) changeColor
+ - (IBAction) changeBackgroundColor
{
- InfColorPickerController* picker = [ InfColorPickerController colorPickerViewController ];
+ InfColorPickerController* picker = [InfColorPickerController colorPickerViewController];
- picker.sourceColor = self.color;
+ picker.sourceColor = self.view.backgroundColor;
picker.delegate = self;
- [ picker presentModallyOverViewController: self ];
+ [picker presentModallyOverViewController: self];
}
- (void) colorPickerControllerDidFinish: (InfColorPickerController*) picker
{
- self.color = picker.resultColor;
+ self.view.backgroundColor = picker.resultColor;
- [ self dismissModalViewControllerAnimated: YES ];
+ [self dismissModalViewControllerAnimated: YES];
}
*/
diff --git a/InfColorPicker/InfColorPickerController.h b/InfColorPicker/InfColorPickerController.h
index 4b34bd5..2024348 100644
--- a/InfColorPicker/InfColorPickerController.h
+++ b/InfColorPicker/InfColorPickerController.h
@@ -5,49 +5,30 @@
//
// Created by Troy Gaul on 7 Aug 2010.
//
-// Copyright (c) 2011 InfinitApps LLC - http://infinitapps.com
+// Copyright (c) 2011-2013 InfinitApps LLC: http://infinitapps.com
// Some rights reserved: http://opensource.org/licenses/MIT
//
//==============================================================================
#import
-@class InfColorBarView;
-@class InfColorSquareView;
-@class InfColorBarPicker;
-@class InfColorSquarePicker;
-
@protocol InfColorPickerControllerDelegate;
//------------------------------------------------------------------------------
-@interface InfColorPickerController : UIViewController {
- float hue;
- float saturation;
- float brightness;
-}
+@interface InfColorPickerController : UIViewController
- // Public API:
+// Public API:
+ (InfColorPickerController*) colorPickerViewController;
+ (CGSize) idealSizeForViewInPopover;
- (void) presentModallyOverViewController: (UIViewController*) controller;
-@property( retain, nonatomic ) UIColor* sourceColor;
-@property( retain, nonatomic ) UIColor* resultColor;
-
-@property( assign, nonatomic ) id< InfColorPickerControllerDelegate > delegate;
-
- // IB outlets:
+@property (nonatomic) UIColor* sourceColor;
+@property (nonatomic) UIColor* resultColor;
-@property( retain, nonatomic ) IBOutlet InfColorBarView* barView;
-@property( retain, nonatomic ) IBOutlet InfColorSquareView* squareView;
-@property( retain, nonatomic ) IBOutlet InfColorBarPicker* barPicker;
-@property( retain, nonatomic ) IBOutlet InfColorSquarePicker* squarePicker;
-@property( retain, nonatomic ) IBOutlet UIView* sourceColorView;
-@property( retain, nonatomic ) IBOutlet UIView* resultColorView;
-@property( retain, nonatomic ) IBOutlet UINavigationController* navController;
+@property (weak, nonatomic) id delegate;
@end
diff --git a/InfColorPicker/InfColorPickerController.m b/InfColorPicker/InfColorPickerController.m
index 2f87898..8cc2c83 100644
--- a/InfColorPicker/InfColorPickerController.m
+++ b/InfColorPicker/InfColorPickerController.m
@@ -1,11 +1,11 @@
//==============================================================================
//
-// MainViewController.m
+// InfColorPickerController.m
// InfColorPicker
//
// Created by Troy Gaul on 7 Aug 2010.
//
-// Copyright (c) 2011 InfinitApps LLC - http://infinitapps.com
+// Copyright (c) 2011-2013 InfinitApps LLC: http://infinitapps.com
// Some rights reserved: http://opensource.org/licenses/MIT
//
//==============================================================================
@@ -14,56 +14,59 @@
#import "InfColorBarPicker.h"
#import "InfColorSquarePicker.h"
+#import "InfColorPickerNavigationController.h"
#import "InfHSBSupport.h"
//------------------------------------------------------------------------------
-static void HSVFromUIColor( UIColor* color, float* h, float* s, float* v )
+#if !__has_feature(objc_arc)
+#error This file must be compiled with ARC enabled (-fobjc-arc).
+#endif
+
+//------------------------------------------------------------------------------
+
+static void HSVFromUIColor(UIColor* color, float* h, float* s, float* v)
{
- CGColorRef colorRef = [ color CGColor ];
+ CGColorRef colorRef = [color CGColor];
- const CGFloat* components = CGColorGetComponents( colorRef );
- size_t numComponents = CGColorGetNumberOfComponents( colorRef );
+ const CGFloat* components = CGColorGetComponents(colorRef);
+ size_t numComponents = CGColorGetNumberOfComponents(colorRef);
CGFloat r, g, b;
- if( numComponents < 3 ) {
- r = g = b = components[ 0 ];
+
+ if (numComponents < 3) {
+ r = g = b = components[0];
}
else {
- r = components[ 0 ];
- g = components[ 1 ];
- b = components[ 2 ];
+ r = components[0];
+ g = components[1];
+ b = components[2];
}
- RGBToHSV( r, g, b, h, s, v, YES );
+ RGBToHSV(r, g, b, h, s, v, YES);
}
//==============================================================================
-@interface InfColorPickerController()
-
-- (void) updateResultColor;
-
-// Outlets and actions:
+@interface InfColorPickerController ()
-- (IBAction) takeBarValue: (id) sender;
-- (IBAction) takeSquareValue: (id) sender;
-- (IBAction) takeBackgroundColor: (UIView*) sender;
-- (IBAction) done: (id) sender;
+@property (nonatomic) IBOutlet InfColorBarView* barView;
+@property (nonatomic) IBOutlet InfColorSquareView* squareView;
+@property (nonatomic) IBOutlet InfColorBarPicker* barPicker;
+@property (nonatomic) IBOutlet InfColorSquarePicker* squarePicker;
+@property (nonatomic) IBOutlet UIView* sourceColorView;
+@property (nonatomic) IBOutlet UIView* resultColorView;
+@property (nonatomic) IBOutlet UINavigationController* navController;
@end
//==============================================================================
-@implementation InfColorPickerController
-
-//------------------------------------------------------------------------------
-
-@synthesize delegate, resultColor, sourceColor;
-@synthesize barView, squareView;
-@synthesize barPicker, squarePicker;
-@synthesize sourceColorView, resultColorView;
-@synthesize navController;
+@implementation InfColorPickerController {
+ float _hue;
+ float _saturation;
+ float _brightness;
+}
//------------------------------------------------------------------------------
#pragma mark Class methods
@@ -71,107 +74,91 @@ @implementation InfColorPickerController
+ (InfColorPickerController*) colorPickerViewController
{
- return [ [ [ self alloc ] initWithNibName: @"InfColorPickerView" bundle: nil ] autorelease ];
+ return [[self alloc] initWithNibName: @"InfColorPickerView" bundle: nil];
}
//------------------------------------------------------------------------------
+ (CGSize) idealSizeForViewInPopover
{
- return CGSizeMake( 256 + ( 1 + 20 ) * 2, 420 );
+ return CGSizeMake(256 + (1 + 20) * 2, 420);
}
//------------------------------------------------------------------------------
-#pragma mark Memory management
+#pragma mark Creation
//------------------------------------------------------------------------------
-- (void) dealloc
+- (id) initWithNibName: (NSString*) nibNameOrNil bundle: (NSBundle*) nibBundleOrNil
{
- [ barView release ];
- [ squareView release ];
- [ barPicker release ];
- [ squarePicker release ];
- [ sourceColorView release ];
- [ resultColorView release ];
- [ navController release ];
+ self = [super initWithNibName: nibNameOrNil bundle: nibBundleOrNil];
- [ sourceColor release ];
- [ resultColor release ];
+ if (self) {
+ self.navigationItem.title = NSLocalizedString(@"Set Color",
+ @"InfColorPicker default nav item title");
+ }
- [ super dealloc ];
+ return self;
}
-//------------------------------------------------------------------------------
-#pragma mark Creation
//------------------------------------------------------------------------------
-- (id) initWithNibName: (NSString*) nibNameOrNil bundle: (NSBundle*) nibBundleOrNil
+- (void) presentModallyOverViewController: (UIViewController*) controller
{
- self = [ super initWithNibName: nibNameOrNil bundle: nibBundleOrNil ];
+ UINavigationController* nav = [[InfColorPickerNavigationController alloc] initWithRootViewController: self];
- if( self ) {
- self.navigationItem.title = NSLocalizedString( @"Set Color",
- @"InfColorPicker default nav item title" );
- }
+ nav.navigationBar.barStyle = UIBarStyleBlackOpaque;
- return self;
+ self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemDone
+ target: self
+ action: @selector(done:)];
+
+ [controller presentViewController: nav animated: YES completion: nil];
}
+//------------------------------------------------------------------------------
+#pragma mark UIViewController methods
//------------------------------------------------------------------------------
- (void) viewDidLoad
{
- [ super viewDidLoad ];
-
+ [super viewDidLoad];
+
self.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
-
- barPicker.value = hue;
- squareView.hue = hue;
- squarePicker.hue = hue;
- squarePicker.value = CGPointMake( saturation, brightness );
-
- if( sourceColor )
- sourceColorView.backgroundColor = sourceColor;
- if( resultColor )
- resultColorView.backgroundColor = resultColor;
+ _barPicker.value = _hue;
+ _squareView.hue = _hue;
+ _squarePicker.hue = _hue;
+ _squarePicker.value = CGPointMake(_saturation, _brightness);
+
+ if (_sourceColor)
+ _sourceColorView.backgroundColor = _sourceColor;
+
+ if (_resultColor)
+ _resultColorView.backgroundColor = _resultColor;
}
//------------------------------------------------------------------------------
-- (void) viewDidUnload
+- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation
{
- [ super viewDidUnload ];
-
- // Release any retained subviews of the main view.
-
- self.barView = nil;
- self.squareView = nil;
- self.barPicker = nil;
- self.squarePicker = nil;
- self.sourceColorView = nil;
- self.resultColorView = nil;
- self.navController = nil;
+ return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}
//------------------------------------------------------------------------------
-- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation
+- (NSUInteger) supportedInterfaceOrientations
{
- return interfaceOrientation == UIInterfaceOrientationPortrait;
+ if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
+ return UIInterfaceOrientationMaskAll;
+ else
+ return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
}
//------------------------------------------------------------------------------
-- (void) presentModallyOverViewController: (UIViewController*) controller
+- (UIRectEdge) edgesForExtendedLayout
{
- UINavigationController* nav = [ [ [ UINavigationController alloc ] initWithRootViewController: self ] autorelease ];
-
- nav.navigationBar.barStyle = UIBarStyleBlackOpaque;
-
- self.navigationItem.rightBarButtonItem = [ [ [ UIBarButtonItem alloc ] initWithBarButtonSystemItem: UIBarButtonSystemItemDone target: self action: @selector( done: ) ] autorelease ];
-
- [ controller presentModalViewController: nav animated: YES ];
+ return UIRectEdgeNone;
}
//------------------------------------------------------------------------------
@@ -180,22 +167,22 @@ - (void) presentModallyOverViewController: (UIViewController*) controller
- (IBAction) takeBarValue: (InfColorBarPicker*) sender
{
- hue = sender.value;
+ _hue = sender.value;
- squareView.hue = hue;
- squarePicker.hue = hue;
+ _squareView.hue = _hue;
+ _squarePicker.hue = _hue;
- [ self updateResultColor ];
+ [self updateResultColor];
}
//------------------------------------------------------------------------------
- (IBAction) takeSquareValue: (InfColorSquarePicker*) sender
{
- saturation = sender.value.x;
- brightness = sender.value.y;
-
- [ self updateResultColor ];
+ _saturation = sender.value.x;
+ _brightness = sender.value.y;
+
+ [self updateResultColor];
}
//------------------------------------------------------------------------------
@@ -209,7 +196,7 @@ - (IBAction) takeBackgroundColor: (UIView*) sender
- (IBAction) done: (id) sender
{
- [ self.delegate colorPickerControllerDidFinish: self ];
+ [self.delegate colorPickerControllerDidFinish: self];
}
//------------------------------------------------------------------------------
@@ -218,8 +205,8 @@ - (IBAction) done: (id) sender
- (void) informDelegateDidChangeColor
{
- if( self.delegate && [ (id) self.delegate respondsToSelector: @selector( colorPickerControllerDidChangeColor: ) ] )
- [ self.delegate colorPickerControllerDidChangeColor: self ];
+ if (self.delegate && [(id) self.delegate respondsToSelector: @selector(colorPickerControllerDidChangeColor:)])
+ [self.delegate colorPickerControllerDidChangeColor: self];
}
//------------------------------------------------------------------------------
@@ -228,46 +215,48 @@ - (void) updateResultColor
{
// This is used when code internally causes the update. We do this so that
// we don't cause push-back on the HSV values in case there are rounding
- // differences or anything. However, given protections from hue and sat
- // changes when not necessary elsewhere it's probably not actually needed.
+ // differences or anything.
- [ self willChangeValueForKey: @"resultColor" ];
+ [self willChangeValueForKey: @"resultColor"];
- [ resultColor release ];
- resultColor = [ [ UIColor colorWithHue: hue saturation: saturation
- brightness: brightness alpha: 1.0f ] retain ];
+ _resultColor = [UIColor colorWithHue: _hue
+ saturation: _saturation
+ brightness: _brightness
+ alpha: 1.0f];
- [ self didChangeValueForKey: @"resultColor" ];
+ [self didChangeValueForKey: @"resultColor"];
- resultColorView.backgroundColor = resultColor;
+ _resultColorView.backgroundColor = _resultColor;
- [ self informDelegateDidChangeColor ];
+ [self informDelegateDidChangeColor];
}
//------------------------------------------------------------------------------
- (void) setResultColor: (UIColor*) newValue
{
- if( ![ resultColor isEqual: newValue ] ) {
- [ resultColor release ];
- resultColor = [ newValue retain ];
+ if (![_resultColor isEqual: newValue]) {
+ _resultColor = newValue;
- float h = hue;
- HSVFromUIColor( newValue, &h, &saturation, &brightness );
+ float h = _hue;
+ HSVFromUIColor(newValue, &h, &_saturation, &_brightness);
- if( h != hue ) {
- hue = h;
+ if ((h == 0.0 && _hue == 1.0) || (h == 1.0 && _hue == 0.0)) {
+ // these are equivalent, so do nothing
+ }
+ else if (h != _hue) {
+ _hue = h;
- barPicker.value = hue;
- squareView.hue = hue;
- squarePicker.hue = hue;
+ _barPicker.value = _hue;
+ _squareView.hue = _hue;
+ _squarePicker.hue = _hue;
}
- squarePicker.value = CGPointMake( saturation, brightness );
-
- resultColorView.backgroundColor = resultColor;
-
- [ self informDelegateDidChangeColor ];
+ _squarePicker.value = CGPointMake(_saturation, _brightness);
+
+ _resultColorView.backgroundColor = _resultColor;
+
+ [self informDelegateDidChangeColor];
}
}
@@ -275,23 +264,22 @@ - (void) setResultColor: (UIColor*) newValue
- (void) setSourceColor: (UIColor*) newValue
{
- if( ![ sourceColor isEqual: newValue ] ) {
- [ sourceColor release ];
- sourceColor = [ newValue retain ];
+ if (![_sourceColor isEqual: newValue]) {
+ _sourceColor = newValue;
- sourceColorView.backgroundColor = sourceColor;
+ _sourceColorView.backgroundColor = _sourceColor;
self.resultColor = newValue;
}
}
//------------------------------------------------------------------------------
-#pragma mark UIViewController( UIPopoverController ) methods
+#pragma mark UIViewController(UIPopoverController) methods
//------------------------------------------------------------------------------
- (CGSize) contentSizeForViewInPopover
{
- return [ [ self class ] idealSizeForViewInPopover ];
+ return [[self class] idealSizeForViewInPopover];
}
//------------------------------------------------------------------------------
diff --git a/InfColorPicker/InfColorPickerNavigationController.h b/InfColorPicker/InfColorPickerNavigationController.h
new file mode 100644
index 0000000..6926756
--- /dev/null
+++ b/InfColorPicker/InfColorPickerNavigationController.h
@@ -0,0 +1,24 @@
+//==============================================================================
+//
+// InfColorPickerNavigationController.h
+// InfColorPicker
+//
+// Created by Troy Gaul on 11 Dec 2013.
+//
+// Copyright (c) 2013 InfinitApps LLC: http://infinitapps.com
+// Some rights reserved: http://opensource.org/licenses/MIT
+//
+//==============================================================================
+
+#import
+
+//------------------------------------------------------------------------------
+// This navigation controller subclass forwards orientation requests to
+// the top view controller hosted within it so that it can choose to limit
+// the orientations it is displayed in.
+
+@interface InfColorPickerNavigationController : UINavigationController
+
+@end
+
+//------------------------------------------------------------------------------
diff --git a/InfColorPicker/InfColorPickerNavigationController.m b/InfColorPicker/InfColorPickerNavigationController.m
new file mode 100644
index 0000000..4c7a95e
--- /dev/null
+++ b/InfColorPicker/InfColorPickerNavigationController.m
@@ -0,0 +1,50 @@
+//==============================================================================
+//
+// InfColorPickerNavigationController.m
+// InfColorPicker
+//
+// Created by Troy Gaul on 11 Dec 2013.
+//
+// Copyright (c) 2011-2013 InfinitApps LLC: http://infinitapps.com
+// Some rights reserved: http://opensource.org/licenses/MIT
+//
+//==============================================================================
+
+#import "InfColorPickerNavigationController.h"
+
+//------------------------------------------------------------------------------
+
+#if !__has_feature(objc_arc)
+#error This file must be compiled with ARC enabled (-fobjc-arc).
+#endif
+
+//==============================================================================
+
+@implementation InfColorPickerNavigationController
+
+//------------------------------------------------------------------------------
+
+- (BOOL) shouldAutorotate
+{
+ return [self.topViewController shouldAutorotate];
+}
+
+//------------------------------------------------------------------------------
+
+- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation
+{
+ return [self.topViewController shouldAutorotateToInterfaceOrientation: interfaceOrientation];
+}
+
+//------------------------------------------------------------------------------
+
+- (NSUInteger) supportedInterfaceOrientations
+{
+ return self.topViewController.supportedInterfaceOrientations;
+}
+
+//------------------------------------------------------------------------------
+
+@end
+
+//==============================================================================
diff --git a/InfColorPicker/InfColorPickerView.xib b/InfColorPicker/InfColorPickerView.xib
index ee49f33..fbf1f28 100644
--- a/InfColorPicker/InfColorPickerView.xib
+++ b/InfColorPicker/InfColorPickerView.xib
@@ -1,14 +1,14 @@
- 1056
- 11A2063
- 1617
- 1138.1
- 566.00
+ 1280
+ 11C74
+ 1938
+ 1138.23
+ 567.00
YES
@@ -57,6 +54,7 @@
{{1, 1}, {256, 256}}
+
3
MC43NQA
@@ -66,29 +64,45 @@
NO
NO
+
+
+
+
+
+
IBCocoaTouchFramework
{{19, 19}, {258, 258}}
+
3
MQA
NO
NO
+
+
+
IBCocoaTouchFramework
{{12, 60}, {296, 296}}
+
3
MC4yAA
NO
+
+ Sets the saturation and brightness of the color.
+ Color square
+
+
IBCocoaTouchFramework
@@ -107,6 +121,7 @@
{{1, 1}, {256, 40}}
+
3
MC43NQA
@@ -115,7 +130,10 @@
NO
NO
+
+
+
IBCocoaTouchFramework
@@ -123,6 +141,7 @@
{{19, 7}, {258, 42}}
+
NO
NO
@@ -132,11 +151,17 @@
{{12, 349}, {296, 56}}
+
3
MC4yAA
NO
+
+ Sets the hue of the color.
+ Color bar
+
+
IBCocoaTouchFramework
@@ -155,18 +180,24 @@
{{1, 1}, {80, 40}}
+
3
MC41AA
NO
+
+ Original color
+
+
IBCocoaTouchFramework
{{95, 0}, {82, 42}}
+
3
MQA
@@ -186,8 +217,13 @@
{{1, 1}, {40, 40}}
+
NO
+
+ White
+
+
IBCocoaTouchFramework
@@ -196,17 +232,23 @@
{{42, 1}, {40, 40}}
+
3
MAA
NO
+
+ Black
+
+
IBCocoaTouchFramework
{83, 42}
+
3
MQA
@@ -226,6 +268,7 @@
{{1, 1}, {80, 40}}
+
3
MC41AA
@@ -233,12 +276,18 @@
NO
NO
+
+ New color
+
+
+
IBCocoaTouchFramework
{{176, 0}, {82, 42}}
+
3
MQA
@@ -252,6 +301,7 @@
{{31, 18}, {258, 42}}
+
3
MCAwAA
@@ -262,6 +312,7 @@
{{0, 64}, {320, 416}}
+
3
MC4xOTg5Nzk1OTE4AA
@@ -302,24 +353,6 @@
46
-
-
- takeBarValue:
-
-
- 13
-
- 53
-
-
-
- takeSquareValue:
-
-
- 13
-
- 56
-
squarePicker
@@ -352,32 +385,50 @@
67
+
+
+ takeBarValue:
+
+
+ 13
+
+ 53
+
+
+
+ takeSquareValue:
+
+
+ 13
+
+ 56
+
takeBackgroundColor:
-
+
7
- 75
+ 78
takeBackgroundColor:
-
+
7
- 77
+ 75
takeBackgroundColor:
-
+
7
- 78
+ 77
@@ -385,7 +436,9 @@
YES
0
-
+
+ YES
+
@@ -615,6 +668,52 @@
InfColorPickerController
UIViewController
+
+ YES
+
+ YES
+ done:
+ takeBackgroundColor:
+ takeBarValue:
+ takeSquareValue:
+
+
+ YES
+ id
+ UIView
+ id
+ id
+
+
+
+ YES
+
+ YES
+ done:
+ takeBackgroundColor:
+ takeBarValue:
+ takeSquareValue:
+
+
+ YES
+
+ done:
+ id
+
+
+ takeBackgroundColor:
+ UIView
+
+
+ takeBarValue:
+ id
+
+
+ takeSquareValue:
+ id
+
+
+
YES
@@ -717,7 +816,7 @@
IBCocoaTouchFramework
com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS
-
+
com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3
@@ -725,6 +824,6 @@
YES
3
- 534
+ 933
diff --git a/InfColorPicker/InfColorSquarePicker.h b/InfColorPicker/InfColorSquarePicker.h
index c506834..3ae56dc 100644
--- a/InfColorPicker/InfColorSquarePicker.h
+++ b/InfColorPicker/InfColorSquarePicker.h
@@ -5,31 +5,27 @@
//
// Created by Troy Gaul on 8/9/10.
//
-// Copyright (c) 2011 InfinitApps LLC - http://infinitapps.com
+// Copyright (c) 2011-2013 InfinitApps LLC: http://infinitapps.com
// Some rights reserved: http://opensource.org/licenses/MIT
//
//==============================================================================
#import
-@class InfColorIndicatorView;
-
//------------------------------------------------------------------------------
@interface InfColorSquareView : UIImageView
-@property( nonatomic ) float hue;
+@property (nonatomic) float hue;
@end
//------------------------------------------------------------------------------
-@interface InfColorSquarePicker : UIControl {
- InfColorIndicatorView* indicator;
-}
+@interface InfColorSquarePicker : UIControl
-@property( nonatomic ) float hue;
-@property( nonatomic ) CGPoint value;
+@property (nonatomic) float hue;
+@property (nonatomic) CGPoint value;
@end
diff --git a/InfColorPicker/InfColorSquarePicker.m b/InfColorPicker/InfColorSquarePicker.m
index c22a69b..b84e33b 100644
--- a/InfColorPicker/InfColorSquarePicker.m
+++ b/InfColorPicker/InfColorSquarePicker.m
@@ -5,7 +5,7 @@
//
// Created by Troy Gaul on 8/9/10.
//
-// Copyright (c) 2011 InfinitApps LLC - http://infinitapps.com
+// Copyright (c) 2011-2013 InfinitApps LLC: http://infinitapps.com
// Some rights reserved: http://opensource.org/licenses/MIT
//
//==============================================================================
@@ -17,6 +17,12 @@
//------------------------------------------------------------------------------
+#if !__has_feature(objc_arc)
+#error This file must be compiled with ARC enabled (-fobjc-arc).
+#endif
+
+//------------------------------------------------------------------------------
+
#define kContentInsetX 20
#define kContentInsetY 20
@@ -28,15 +34,11 @@ @implementation InfColorSquareView
//------------------------------------------------------------------------------
-@synthesize hue;
-
-//------------------------------------------------------------------------------
-
- (void) updateContent
{
- CGImageRef imageRef = createSaturationBrightnessSquareContentImageWithHue( hue * 360 );
- self.image = [ UIImage imageWithCGImage: imageRef ];
- CGImageRelease( imageRef );
+ CGImageRef imageRef = createSaturationBrightnessSquareContentImageWithHue(self.hue * 360);
+ self.image = [UIImage imageWithCGImage: imageRef];
+ CGImageRelease(imageRef);
}
//------------------------------------------------------------------------------
@@ -45,10 +47,10 @@ - (void) updateContent
- (void) setHue: (float) value
{
- if( value != hue || self.image == nil ) {
- hue = value;
+ if (value != _hue || self.image == nil) {
+ _hue = value;
- [ self updateContent ];
+ [self updateContent];
}
}
@@ -58,54 +60,50 @@ - (void) setHue: (float) value
//==============================================================================
-@implementation InfColorSquarePicker
-
-//------------------------------------------------------------------------------
-
-@synthesize hue;
-@synthesize value;
+@implementation InfColorSquarePicker {
+ InfColorIndicatorView* indicator;
+}
//------------------------------------------------------------------------------
-#pragma mark Lifetime
+#pragma mark Appearance
//------------------------------------------------------------------------------
-- (void) dealloc
+- (void) setIndicatorColor
{
- [ indicator release ];
+ if (indicator == nil)
+ return;
- [ super dealloc ];
+ indicator.color = [UIColor colorWithHue: self.hue
+ saturation: self.value.x
+ brightness: self.value.y
+ alpha: 1.0f];
}
-//------------------------------------------------------------------------------
-#pragma mark Appearance
//------------------------------------------------------------------------------
-- (void) setIndicatorColor
+- (NSString*) spokenValue
{
- if( indicator == nil )
- return;
-
- indicator.color = [ UIColor colorWithHue: hue saturation: value.x
- brightness: value.y alpha: 1.0f ];
+ return [NSString stringWithFormat: @"%d%% saturation, %d%% brightness",
+ (int) (self.value.x * 100), (int) (self.value.y * 100)];
}
//------------------------------------------------------------------------------
- (void) layoutSubviews
{
- if( indicator == nil ) {
+ if (indicator == nil) {
CGRect indicatorRect = { CGPointZero, { kIndicatorSize, kIndicatorSize } };
- indicator = [ [ InfColorIndicatorView alloc ] initWithFrame: indicatorRect ];
- [ self addSubview: indicator ];
+ indicator = [[InfColorIndicatorView alloc] initWithFrame: indicatorRect];
+ [self addSubview: indicator];
}
- [ self setIndicatorColor ];
+ [self setIndicatorColor];
- CGFloat indicatorX = kContentInsetX + ( self.value.x * ( self.bounds.size.width - 2 * kContentInsetX ) );
- CGFloat indicatorY = self.bounds.size.height - kContentInsetY
- - ( self.value.y * ( self.bounds.size.height - 2 * kContentInsetY ) );
+ CGFloat indicatorX = kContentInsetX + (self.value.x * (self.bounds.size.width - 2 * kContentInsetX));
+ CGFloat indicatorY = self.bounds.size.height - kContentInsetY
+ - (self.value.y * (self.bounds.size.height - 2 * kContentInsetY));
- indicator.center = CGPointMake( indicatorX, indicatorY );
+ indicator.center = CGPointMake(indicatorX, indicatorY);
}
//------------------------------------------------------------------------------
@@ -114,10 +112,10 @@ - (void) layoutSubviews
- (void) setHue: (float) newValue
{
- if( newValue != hue ) {
- hue = newValue;
+ if (newValue != _hue) {
+ _hue = newValue;
- [ self setIndicatorColor ];
+ [self setIndicatorColor];
}
}
@@ -125,11 +123,11 @@ - (void) setHue: (float) newValue
- (void) setValue: (CGPoint) newValue
{
- if( !CGPointEqualToPoint( newValue, value ) ) {
- value = newValue;
+ if (!CGPointEqualToPoint(newValue, _value)) {
+ _value = newValue;
- [ self sendActionsForControlEvents: UIControlEventValueChanged ];
- [ self setNeedsLayout ];
+ [self sendActionsForControlEvents: UIControlEventValueChanged];
+ [self setNeedsLayout];
}
}
@@ -137,19 +135,20 @@ - (void) setValue: (CGPoint) newValue
#pragma mark Tracking
//------------------------------------------------------------------------------
-- (void) trackIndicatorWithTouch: (UITouch*) touch
+- (void) trackIndicatorWithTouch: (UITouch*) touch
{
CGRect bounds = self.bounds;
CGPoint touchValue;
- touchValue.x = ( [ touch locationInView: self ].x - kContentInsetX )
- / ( bounds.size.width - 2 * kContentInsetX );
- touchValue.y = ( [ touch locationInView: self ].y - kContentInsetY )
- / ( bounds.size.height - 2 * kContentInsetY );
+ touchValue.x = ([touch locationInView: self].x - kContentInsetX)
+ / (bounds.size.width - 2 * kContentInsetX);
+
+ touchValue.y = ([touch locationInView: self].y - kContentInsetY)
+ / (bounds.size.height - 2 * kContentInsetY);
- touchValue.x = pin( 0.0f, touchValue.x, 1.0f );
- touchValue.y = 1.0f - pin( 0.0f, touchValue.y, 1.0f );
+ touchValue.x = pin(0.0f, touchValue.x, 1.0f);
+ touchValue.y = 1.0f - pin(0.0f, touchValue.y, 1.0f);
self.value = touchValue;
}
@@ -157,18 +156,18 @@ - (void) trackIndicatorWithTouch: (UITouch*) touch
//------------------------------------------------------------------------------
- (BOOL) beginTrackingWithTouch: (UITouch*) touch
- withEvent: (UIEvent*) event
+ withEvent: (UIEvent*) event
{
- [ self trackIndicatorWithTouch: touch ];
+ [self trackIndicatorWithTouch: touch];
return YES;
}
//------------------------------------------------------------------------------
-- (BOOL) continueTrackingWithTouch: (UITouch*) touch
- withEvent: (UIEvent*) event
+- (BOOL) continueTrackingWithTouch: (UITouch*) touch
+ withEvent: (UIEvent*) event
{
- [ self trackIndicatorWithTouch: touch ];
+ [self trackIndicatorWithTouch: touch];
return YES;
}
diff --git a/InfColorPicker/InfHSBSupport.h b/InfColorPicker/InfHSBSupport.h
index 2b8071a..3750493 100644
--- a/InfColorPicker/InfHSBSupport.h
+++ b/InfColorPicker/InfHSBSupport.h
@@ -5,7 +5,7 @@
//
// Created by Troy Gaul on 7 Aug 2010.
//
-// Copyright (c) 2011 InfinitApps LLC - http://infinitapps.com
+// Copyright (c) 2011-2013 InfinitApps LLC: http://infinitapps.com
// Some rights reserved: http://opensource.org/licenses/MIT
//
//==============================================================================
@@ -14,26 +14,26 @@
//------------------------------------------------------------------------------
-float pin( float minValue, float value, float maxValue );
+float pin(float minValue, float value, float maxValue);
//------------------------------------------------------------------------------
// These functions convert between an RGB value with components in the
- // 0.0f..1.0f range to HSV where Hue is 0 .. 360 and Saturation and
+ // 0.0f..1.0f range to HSV where Hue is 0 .. 360 and Saturation and
// Value (aka Brightness) are percentages expressed as 0.0f..1.0f.
- //
+ //
// Note that HSB (B = Brightness) and HSV (V = Value) are interchangeable
// names that mean the same thing. I use V here as it is unambiguous
// relative to the B in RGB, which is Blue.
-void HSVtoRGB( float h, float s, float v, float* r, float* g, float* b );
+void HSVtoRGB(float h, float s, float v, float* r, float* g, float* b);
-void RGBToHSV( float r, float g, float b, float* h, float* s, float* v,
- BOOL preserveHS );
+void RGBToHSV(float r, float g, float b, float* h, float* s, float* v,
+ BOOL preserveHS);
//------------------------------------------------------------------------------
-CGImageRef createSaturationBrightnessSquareContentImageWithHue( float hue );
+CGImageRef createSaturationBrightnessSquareContentImageWithHue(float hue);
// Generates a 256x256 image with the specified constant hue where the
// Saturation and value vary in the X and Y axes respectively.
@@ -45,7 +45,7 @@ typedef enum {
InfComponentIndexBrightness = 2,
} InfComponentIndex;
-CGImageRef createHSVBarContentImage( InfComponentIndex barComponentIndex, float hsv[ 3 ] );
+CGImageRef createHSVBarContentImage(InfComponentIndex barComponentIndex, float hsv[3]);
// Generates an image where the specified barComponentIndex (0=H, 1=S, 2=V)
// varies across the x-axis of the 256x1 pixel image and the other components
// remain at the constant value specified in the hsv array.
diff --git a/InfColorPicker/InfHSBSupport.m b/InfColorPicker/InfHSBSupport.m
index e00f03a..6695c99 100644
--- a/InfColorPicker/InfHSBSupport.m
+++ b/InfColorPicker/InfHSBSupport.m
@@ -5,7 +5,7 @@
//
// Created by Troy Gaul on 7 Aug 2010.
//
-// Copyright (c) 2011 InfinitApps LLC - http://infinitapps.com
+// Copyright (c) 2011-2013 InfinitApps LLC: http://infinitapps.com
// Some rights reserved: http://opensource.org/licenses/MIT
//
//==============================================================================
@@ -14,11 +14,11 @@
//------------------------------------------------------------------------------
-float pin( float minValue, float value, float maxValue )
+float pin(float minValue, float value, float maxValue)
{
- if( minValue > value )
+ if (minValue > value)
return minValue;
- else if( maxValue < value )
+ else if (maxValue < value)
return maxValue;
else
return value;
@@ -28,32 +28,32 @@ float pin( float minValue, float value, float maxValue )
#pragma mark Floating point conversion
//------------------------------------------------------------------------------
-static void hueToComponentFactors( float h, float* r, float* g, float* b )
+static void hueToComponentFactors(float h, float* r, float* g, float* b)
{
float h_prime = h / 60.0f;
- float x = 1.0f - fabsf( fmodf( h_prime, 2.0f ) - 1.0f );
+ float x = 1.0f - fabsf(fmodf(h_prime, 2.0f) - 1.0f);
- if( h_prime < 1.0f ) {
+ if (h_prime < 1.0f) {
*r = 1;
*g = x;
*b = 0;
}
- else if( h_prime < 2.0f ) {
+ else if (h_prime < 2.0f) {
*r = x;
*g = 1;
*b = 0;
}
- else if( h_prime < 3.0f ) {
+ else if (h_prime < 3.0f) {
*r = 0;
*g = 1;
*b = x;
}
- else if( h_prime < 4.0f ) {
+ else if (h_prime < 4.0f) {
*r = 0;
*g = x;
*b = 1;
}
- else if( h_prime < 5.0f ) {
+ else if (h_prime < 5.0f) {
*r = x;
*g = 0;
*b = 1;
@@ -67,13 +67,13 @@ static void hueToComponentFactors( float h, float* r, float* g, float* b )
//------------------------------------------------------------------------------
-void HSVtoRGB( float h, float s, float v, float* r, float* g, float* b )
+void HSVtoRGB(float h, float s, float v, float* r, float* g, float* b)
{
- hueToComponentFactors( h, r, g, b );
+ hueToComponentFactors(h, r, g, b);
float c = v * s;
float m = v - c;
-
+
*r = *r * c + m;
*g = *g * c + m;
*b = *b * c + m;
@@ -81,18 +81,22 @@ void HSVtoRGB( float h, float s, float v, float* r, float* g, float* b )
//------------------------------------------------------------------------------
-void RGBToHSV( float r, float g, float b, float* h, float* s, float* v, BOOL preserveHS )
-{
+void RGBToHSV(float r, float g, float b, float* h, float* s, float* v, BOOL preserveHS)
+{
float max = r;
- if( max < g )
+
+ if (max < g)
max = g;
- if( max < b )
+
+ if (max < b)
max = b;
float min = r;
- if( min > g )
+
+ if (min > g)
min = g;
- if( min > b )
+
+ if (min > b)
min = b;
// Brightness (aka Value)
@@ -103,42 +107,44 @@ void RGBToHSV( float r, float g, float b, float* h, float* s, float* v, BOOL pre
float sat;
- if( max != 0.0f ) {
- sat = ( max - min ) / max;
+ if (max != 0.0f) {
+ sat = (max - min) / max;
*s = sat;
}
else {
sat = 0.0f;
- if( !preserveHS )
- *s = 0.0f; // Black, so sat is undefined, use 0
+
+ if (!preserveHS)
+ *s = 0.0f; // Black, so sat is undefined, use 0
}
// Hue
float delta;
- if( sat == 0.0f ) {
- if( !preserveHS )
- *h = 0.0f; // No color, so hue is undefined, use 0
+
+ if (sat == 0.0f) {
+ if (!preserveHS)
+ *h = 0.0f; // No color, so hue is undefined, use 0
}
else {
delta = max - min;
float hue;
- if( r == max )
- hue = ( g - b ) / delta;
- else if( g == max )
- hue = 2 + ( b - r ) / delta;
+ if (r == max)
+ hue = (g - b) / delta;
+ else if (g == max)
+ hue = 2 + (b - r) / delta;
else
- hue = 4 + ( r - g ) / delta;
-
+ hue = 4 + (r - g) / delta;
+
hue /= 6.0f;
-
- if( hue < 0.0f )
+
+ if (hue < 0.0f)
hue += 1.0f;
- if( !preserveHS || fabsf( hue - *h ) != 1.0f )
- *h = hue; // 0.0 and 1.0 hues are actually both the same (red)
+ if (!preserveHS || fabsf(hue - *h) != 1.0f)
+ *h = hue; // 0.0 and 1.0 hues are actually both the same (red)
}
}
@@ -146,70 +152,70 @@ void RGBToHSV( float r, float g, float b, float* h, float* s, float* v, BOOL pre
#pragma mark Square/Bar image creation
//------------------------------------------------------------------------------
-static UInt8 blend( UInt8 value, UInt8 percentIn255 )
+static UInt8 blend(UInt8 value, UInt8 percentIn255)
{
- return (UInt8) ( (int) value * percentIn255 / 255 );
+ return (UInt8) ((int) value * percentIn255 / 255);
}
//------------------------------------------------------------------------------
-static CGContextRef createBGRxImageContext( int w, int h, void* data )
+static CGContextRef createBGRxImageContext(int w, int h, void* data)
{
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGBitmapInfo kBGRxBitmapInfo = kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst;
- // BGRA is the most efficient on the iPhone.
+ // BGRA is the most efficient on the iPhone.
- CGContextRef context = CGBitmapContextCreate( data, w, h, 8, w * 4, colorSpace, kBGRxBitmapInfo );
+ CGContextRef context = CGBitmapContextCreate(data, w, h, 8, w * 4, colorSpace, kBGRxBitmapInfo);
+
+ CGColorSpaceRelease(colorSpace);
- CGColorSpaceRelease( colorSpace );
-
return context;
}
//------------------------------------------------------------------------------
-CGImageRef createSaturationBrightnessSquareContentImageWithHue( float hue )
+CGImageRef createSaturationBrightnessSquareContentImageWithHue(float hue)
{
- void* data = malloc( 256 * 256 * 4 );
- if( data == nil )
+ void* data = malloc(256 * 256 * 4);
+ if (data == nil)
return nil;
- CGContextRef context = createBGRxImageContext( 256, 256, data );
+ CGContextRef context = createBGRxImageContext(256, 256, data);
- if( context == nil ) {
- free( data );
+ if (context == nil) {
+ free(data);
return nil;
}
UInt8* dataPtr = data;
- size_t rowBytes = CGBitmapContextGetBytesPerRow( context );
+ size_t rowBytes = CGBitmapContextGetBytesPerRow(context);
float r, g, b;
- hueToComponentFactors( hue, &r, &g, &b );
+ hueToComponentFactors(hue, &r, &g, &b);
- UInt8 r_s = (UInt8) ( ( 1.0f - r ) * 255 );
- UInt8 g_s = (UInt8) ( ( 1.0f - g ) * 255 );
- UInt8 b_s = (UInt8) ( ( 1.0f - b ) * 255 );
+ UInt8 r_s = (UInt8) ((1.0f - r) * 255);
+ UInt8 g_s = (UInt8) ((1.0f - g) * 255);
+ UInt8 b_s = (UInt8) ((1.0f - b) * 255);
- for( int s = 0 ; s < 256 ; ++s ) {
+ for (int s = 0; s < 256; ++s) {
register UInt8* ptr = dataPtr;
- register unsigned int r_hs = 255 - blend( s, r_s );
- register unsigned int g_hs = 255 - blend( s, g_s );
- register unsigned int b_hs = 255 - blend( s, b_s );
+ register unsigned int r_hs = 255 - blend(s, r_s);
+ register unsigned int g_hs = 255 - blend(s, g_s);
+ register unsigned int b_hs = 255 - blend(s, b_s);
- for( register int v = 255 ; v >= 0 ; --v ) {
- ptr[ 0 ] = (UInt8) ( v * b_hs >> 8 );
- ptr[ 1 ] = (UInt8) ( v * g_hs >> 8 );
- ptr[ 2 ] = (UInt8) ( v * r_hs >> 8 );
+ for (register int v = 255; v >= 0; --v) {
+ ptr[0] = (UInt8) (v * b_hs >> 8);
+ ptr[1] = (UInt8) (v * g_hs >> 8);
+ ptr[2] = (UInt8) (v * r_hs >> 8);
// Really, these should all be of the form used in blend(),
// which does a divide by 255. However, integer divide is
- // implemented in software on ARM, so a divide by 256
- // (done as a bit shift) will be *nearly* the same value,
+ // implemented in software on ARM, so a divide by 256
+ // (done as a bit shift) will be *nearly* the same value,
// and is faster. The more-accurate versions would look like:
- // ptr[ 0 ] = blend( v, b_hs );
+ // ptr[0] = blend(v, b_hs);
ptr += rowBytes;
}
@@ -217,55 +223,55 @@ CGImageRef createSaturationBrightnessSquareContentImageWithHue( float hue )
dataPtr += 4;
}
- // Return an image of the context's content:
+ // Return an image of the context's content:
- CGImageRef image = CGBitmapContextCreateImage( context );
+ CGImageRef image = CGBitmapContextCreateImage(context);
- CGContextRelease( context );
- free( data );
+ CGContextRelease(context);
+ free(data);
return image;
}
//------------------------------------------------------------------------------
-CGImageRef createHSVBarContentImage( InfComponentIndex barComponentIndex, float hsv[ 3 ] )
+CGImageRef createHSVBarContentImage(InfComponentIndex barComponentIndex, float hsv[3])
{
- UInt8 data[ 256 * 4 ];
+ UInt8 data[256 * 4];
- // Set up the bitmap context for filling with color:
+ // Set up the bitmap context for filling with color:
- CGContextRef context = createBGRxImageContext( 256, 1, data );
+ CGContextRef context = createBGRxImageContext(256, 1, data);
- if( context == nil )
+ if (context == nil)
return nil;
- // Draw into context here:
+ // Draw into context here:
- UInt8* ptr = CGBitmapContextGetData( context );
- if( ptr == nil ) {
- CGContextRelease( context );
+ UInt8* ptr = CGBitmapContextGetData(context);
+ if (ptr == nil) {
+ CGContextRelease(context);
return nil;
}
float r, g, b;
- for( int x = 0 ; x < 256 ; ++x ) {
- hsv[ barComponentIndex ] = (float) x / 255.0f;
+ for (int x = 0; x < 256; ++x) {
+ hsv[barComponentIndex] = (float) x / 255.0f;
- HSVtoRGB( hsv[ 0 ] * 360.0f, hsv[ 1 ], hsv[ 2 ], &r, &g, &b );
+ HSVtoRGB(hsv[0] * 360.0f, hsv[1], hsv[2], &r, &g, &b);
+
+ ptr[0] = (UInt8) (b * 255.0f);
+ ptr[1] = (UInt8) (g * 255.0f);
+ ptr[2] = (UInt8) (r * 255.0f);
- ptr[ 0 ] = (UInt8) ( b * 255.0f );
- ptr[ 1 ] = (UInt8) ( g * 255.0f );
- ptr[ 2 ] = (UInt8) ( r * 255.0f );
-
ptr += 4;
}
- // Return an image of the context's content:
+ // Return an image of the context's content:
- CGImageRef image = CGBitmapContextCreateImage( context );
+ CGImageRef image = CGBitmapContextCreateImage(context);
- CGContextRelease( context );
+ CGContextRelease(context);
return image;
}
diff --git a/InfColorPicker/InfSourceColorView.h b/InfColorPicker/InfSourceColorView.h
index e7493d7..2521717 100644
--- a/InfColorPicker/InfSourceColorView.h
+++ b/InfColorPicker/InfSourceColorView.h
@@ -5,7 +5,7 @@
//
// Created by Troy Gaul on 8/10/10.
//
-// Copyright (c) 2011 InfinitApps LLC - http://infinitapps.com
+// Copyright (c) 2011-2013 InfinitApps LLC: http://infinitapps.com
// Some rights reserved: http://opensource.org/licenses/MIT
//
//==============================================================================
@@ -16,7 +16,7 @@
@interface InfSourceColorView : UIControl
-@property( nonatomic ) BOOL trackingInside;
+@property (nonatomic) BOOL trackingInside;
@end
diff --git a/InfColorPicker/InfSourceColorView.m b/InfColorPicker/InfSourceColorView.m
index 5488f59..2bc72b3 100644
--- a/InfColorPicker/InfSourceColorView.m
+++ b/InfColorPicker/InfSourceColorView.m
@@ -5,20 +5,22 @@
//
// Created by Troy Gaul on 8/10/10.
//
-// Copyright (c) 2011 InfinitApps LLC - http://infinitapps.com
+// Copyright (c) 2011-2013 InfinitApps LLC: http://infinitapps.com
// Some rights reserved: http://opensource.org/licenses/MIT
//
//==============================================================================
#import "InfSourceColorView.h"
-//==============================================================================
+//------------------------------------------------------------------------------
-@implementation InfSourceColorView
+#if !__has_feature(objc_arc)
+#error This file must be compiled with ARC enabled (-fobjc-arc).
+#endif
-//------------------------------------------------------------------------------
+//==============================================================================
-@synthesize trackingInside;
+@implementation InfSourceColorView
//------------------------------------------------------------------------------
#pragma mark UIView overrides
@@ -26,17 +28,17 @@ @implementation InfSourceColorView
- (void) drawRect: (CGRect) rect
{
- [ super drawRect: rect ];
+ [super drawRect: rect];
- if( self.enabled && self.trackingInside ) {
- CGRect bounds = [ self bounds ];
+ if (self.enabled && self.trackingInside) {
+ CGRect bounds = [self bounds];
- [ [ UIColor whiteColor ] set ];
- CGContextStrokeRectWithWidth( UIGraphicsGetCurrentContext(),
- CGRectInset( bounds, 1, 1 ), 2 );
+ [[UIColor whiteColor] set];
+ CGContextStrokeRectWithWidth(UIGraphicsGetCurrentContext(),
+ CGRectInset(bounds, 1, 1), 2);
- [ [ UIColor blackColor ] set ];
- UIRectFrame( CGRectInset( bounds, 2, 2 ) );
+ [[UIColor blackColor] set];
+ UIRectFrame(CGRectInset(bounds, 2, 2));
}
}
@@ -46,23 +48,21 @@ - (void) drawRect: (CGRect) rect
- (void) setTrackingInside: (BOOL) newValue
{
- if( newValue != trackingInside ) {
- trackingInside = newValue;
- [ self setNeedsDisplay ];
+ if (newValue != _trackingInside) {
+ _trackingInside = newValue;
+ [self setNeedsDisplay];
}
}
//------------------------------------------------------------------------------
- (BOOL) beginTrackingWithTouch: (UITouch*) touch
- withEvent: (UIEvent*) event
+ withEvent: (UIEvent*) event
{
- if( self.enabled ) {
+ if (self.enabled) {
self.trackingInside = YES;
- [ self sendActionsForControlEvents: UIControlEventTouchDown ];
-
- return YES;
+ return [super beginTrackingWithTouch: touch withEvent: event];
}
else {
return NO;
@@ -73,25 +73,11 @@ - (BOOL) beginTrackingWithTouch: (UITouch*) touch
- (BOOL) continueTrackingWithTouch: (UITouch*) touch withEvent: (UIEvent*) event
{
- BOOL wasTrackingInside = self.trackingInside;
- BOOL isTrackingInside = CGRectContainsPoint( [ self bounds ], [ touch locationInView: self ] );
+ BOOL isTrackingInside = CGRectContainsPoint([self bounds], [touch locationInView: self]);
self.trackingInside = isTrackingInside;
- if( isTrackingInside && !wasTrackingInside ) {
- [ self sendActionsForControlEvents: UIControlEventTouchDragEnter ];
- }
- else if( !isTrackingInside && wasTrackingInside ) {
- [ self sendActionsForControlEvents: UIControlEventTouchDragExit ];
- }
- else if( isTrackingInside ) {
- [ self sendActionsForControlEvents: UIControlEventTouchDragInside ];
- }
- else {
- [ self sendActionsForControlEvents: UIControlEventTouchDragOutside ];
- }
-
- return YES;
+ return [super continueTrackingWithTouch: touch withEvent: event];
}
//------------------------------------------------------------------------------
@@ -99,13 +85,8 @@ - (BOOL) continueTrackingWithTouch: (UITouch*) touch withEvent: (UIEvent*) event
- (void) endTrackingWithTouch: (UITouch*) touch withEvent: (UIEvent*) event
{
self.trackingInside = NO;
-
- if( CGRectContainsPoint( [ self bounds ], [ touch locationInView: self ] ) ) {
- [ self sendActionsForControlEvents: UIControlEventTouchUpInside ];
- }
- else {
- [ self sendActionsForControlEvents: UIControlEventTouchUpOutside ];
- }
+
+ [super endTrackingWithTouch: touch withEvent: event];
}
//------------------------------------------------------------------------------
@@ -113,8 +94,8 @@ - (void) endTrackingWithTouch: (UITouch*) touch withEvent: (UIEvent*) event
- (void) cancelTrackingWithEvent: (UIEvent*) event
{
self.trackingInside = NO;
-
- [ self sendActionsForControlEvents: UIControlEventTouchCancel ];
+
+ [super cancelTrackingWithEvent: event];
}
//------------------------------------------------------------------------------
diff --git a/PickerSamplePad/Classes/PickerSamplePadAppDelegate.h b/PickerSamplePad/Classes/PickerSamplePadAppDelegate.h
index 5499b9d..e49e875 100644
--- a/PickerSamplePad/Classes/PickerSamplePadAppDelegate.h
+++ b/PickerSamplePad/Classes/PickerSamplePadAppDelegate.h
@@ -5,7 +5,7 @@
//
// Created by Troy Gaul on 8/17/10.
//
-// Copyright (c) 2011 InfinitApps LLC - http://infinitapps.com
+// Copyright (c) 2011-2013 InfinitApps LLC: http://infinitapps.com
// Some rights reserved: http://opensource.org/licenses/MIT
//
//==============================================================================
@@ -18,8 +18,8 @@
@interface PickerSamplePadAppDelegate : NSObject< UIApplicationDelegate >
-@property( nonatomic, retain ) IBOutlet UIWindow* window;
-@property( nonatomic, retain ) IBOutlet PickerSamplePadViewController* viewController;
+@property (nonatomic) IBOutlet UIWindow* window;
+@property (nonatomic) IBOutlet PickerSamplePadViewController* viewController;
@end
diff --git a/PickerSamplePad/Classes/PickerSamplePadAppDelegate.m b/PickerSamplePad/Classes/PickerSamplePadAppDelegate.m
index 59780cf..766190b 100644
--- a/PickerSamplePad/Classes/PickerSamplePadAppDelegate.m
+++ b/PickerSamplePad/Classes/PickerSamplePadAppDelegate.m
@@ -5,7 +5,7 @@
//
// Created by Troy Gaul on 8/17/10.
//
-// Copyright (c) 2011 InfinitApps LLC - http://infinitapps.com
+// Copyright (c) 2011-2013 InfinitApps LLC: http://infinitapps.com
// Some rights reserved: http://opensource.org/licenses/MIT
//
//==============================================================================
@@ -25,21 +25,11 @@ @implementation PickerSamplePadAppDelegate
//------------------------------------------------------------------------------
- (BOOL) application: (UIApplication*) application didFinishLaunchingWithOptions: (NSDictionary*) launchOptions
-{
- [ window addSubview: viewController.view ];
- [ window makeKeyAndVisible ];
-
- return YES;
-}
-
-//------------------------------------------------------------------------------
-
-- (void) dealloc
{
- [ viewController release ];
- [ window release ];
+ [window setRootViewController: viewController];
+ [window makeKeyAndVisible];
- [ super dealloc ];
+ return YES;
}
//------------------------------------------------------------------------------
diff --git a/PickerSamplePad/Classes/PickerSamplePadViewController.h b/PickerSamplePad/Classes/PickerSamplePadViewController.h
index 59789b1..95dbc1d 100644
--- a/PickerSamplePad/Classes/PickerSamplePadViewController.h
+++ b/PickerSamplePad/Classes/PickerSamplePadViewController.h
@@ -5,7 +5,7 @@
//
// Created by Troy Gaul on 8/17/10.
//
-// Copyright (c) 2011 InfinitApps LLC - http://infinitapps.com
+// Copyright (c) 2011-2013 InfinitApps LLC: http://infinitapps.com
// Some rights reserved: http://opensource.org/licenses/MIT
//
//==============================================================================
@@ -16,13 +16,9 @@
//------------------------------------------------------------------------------
-@interface PickerSamplePadViewController : UIViewController< InfColorPickerControllerDelegate,
+@interface PickerSamplePadViewController : UIViewController
-{
- UIPopoverController* activePopover;
- BOOL updateLive;
-}
+ UITableViewDelegate>
- (IBAction) takeUpdateLive: (id) sender;
- (IBAction) changeColor: (id) sender;
diff --git a/PickerSamplePad/Classes/PickerSamplePadViewController.m b/PickerSamplePad/Classes/PickerSamplePadViewController.m
index 61ccdd6..6ab509e 100644
--- a/PickerSamplePad/Classes/PickerSamplePadViewController.m
+++ b/PickerSamplePad/Classes/PickerSamplePadViewController.m
@@ -5,7 +5,7 @@
//
// Created by Troy Gaul on 8/17/10.
//
-// Copyright (c) 2011 InfinitApps LLC - http://infinitapps.com
+// Copyright (c) 2011-2013 InfinitApps LLC: http://infinitapps.com
// Some rights reserved: http://opensource.org/licenses/MIT
//
//==============================================================================
@@ -16,22 +16,16 @@
//==============================================================================
-@implementation PickerSamplePadViewController
-
-//------------------------------------------------------------------------------
-
-- (void) dealloc
-{
- [ activePopover release ];
-
- [ super dealloc ];
+@implementation PickerSamplePadViewController {
+ UIPopoverController* activePopover;
+ BOOL updateLive;
}
//------------------------------------------------------------------------------
- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation
{
- return YES;
+ return YES;
}
//------------------------------------------------------------------------------
@@ -47,13 +41,12 @@ - (void) applyPickedColor: (InfColorPickerController*) picker
- (void) popoverControllerDidDismissPopover: (UIPopoverController*) popoverController
{
- if( [ popoverController.contentViewController isKindOfClass: [ InfColorPickerController class ] ] ) {
+ if ([popoverController.contentViewController isKindOfClass: [InfColorPickerController class]]) {
InfColorPickerController* picker = (InfColorPickerController*) popoverController.contentViewController;
- [ self applyPickedColor: picker ];
+ [self applyPickedColor: picker];
}
- if( popoverController == activePopover ) {
- [ activePopover release ];
+ if (popoverController == activePopover) {
activePopover = nil;
}
}
@@ -64,20 +57,19 @@ - (void) showPopover: (UIPopoverController*) popover from: (id) sender
{
popover.delegate = self;
- activePopover = [ popover retain ];
+ activePopover = popover;
- if( [ sender isKindOfClass: [ UIBarButtonItem class ] ] ) {
- [ activePopover presentPopoverFromBarButtonItem: sender
- permittedArrowDirections: UIPopoverArrowDirectionAny
- animated: YES ];
- }
- else {
+ if ([sender isKindOfClass: [UIBarButtonItem class]]) {
+ [activePopover presentPopoverFromBarButtonItem: sender
+ permittedArrowDirections: UIPopoverArrowDirectionAny
+ animated: YES];
+ } else {
UIView* senderView = sender;
- [ activePopover presentPopoverFromRect: [ senderView bounds ]
- inView: senderView
- permittedArrowDirections: UIPopoverArrowDirectionAny
- animated: YES ];
+ [activePopover presentPopoverFromRect: [senderView bounds]
+ inView: senderView
+ permittedArrowDirections: UIPopoverArrowDirectionAny
+ animated: YES];
}
}
@@ -85,9 +77,9 @@ - (void) showPopover: (UIPopoverController*) popover from: (id) sender
- (BOOL) dismissActivePopover
{
- if( activePopover ) {
- [ activePopover dismissPopoverAnimated: YES ];
- [ self popoverControllerDidDismissPopover: activePopover ];
+ if (activePopover) {
+ [activePopover dismissPopoverAnimated: YES];
+ [self popoverControllerDidDismissPopover: activePopover];
return YES;
}
@@ -101,17 +93,17 @@ - (BOOL) dismissActivePopover
- (void) colorPickerControllerDidChangeColor: (InfColorPickerController*) picker
{
- if( updateLive )
- [ self applyPickedColor: picker ];
+ if (updateLive)
+ [self applyPickedColor: picker];
}
//------------------------------------------------------------------------------
- (void) colorPickerControllerDidFinish: (InfColorPickerController*) picker
{
- [ self applyPickedColor: picker ];
-
- [ activePopover dismissPopoverAnimated: YES ];
+ [self applyPickedColor: picker];
+
+ [activePopover dismissPopoverAnimated: YES];
}
//------------------------------------------------------------------------------
@@ -120,48 +112,49 @@ - (void) colorPickerControllerDidFinish: (InfColorPickerController*) picker
- (IBAction) takeUpdateLive: (UISwitch*) sender
{
- updateLive = [ sender isOn ];
+ updateLive = [sender isOn];
}
//------------------------------------------------------------------------------
- (IBAction) finishColorTable
{
- [ self dismissActivePopover ];
+ [self dismissActivePopover];
}
- (IBAction) showColorTable: (id) sender
{
- if( [ self dismissActivePopover ] )
+ if ([self dismissActivePopover])
return;
- PickerSampleTableViewController* vc = [ [ [ PickerSampleTableViewController alloc ] init ] autorelease ];
- UINavigationController* nav = [ [ [ UINavigationController alloc ] initWithRootViewController: vc ] autorelease ];
+ PickerSampleTableViewController* vc = [[PickerSampleTableViewController alloc] init];
+ UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController: vc];
nav.navigationBar.barStyle = UIBarStyleBlackOpaque;
- vc.navigationItem.rightBarButtonItem = [ [ [ UIBarButtonItem alloc ] initWithBarButtonSystemItem: UIBarButtonSystemItemDone target: self action: @selector( finishColorTable ) ] autorelease ];
+ vc.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemDone
+ target: self
+ action: @selector(finishColorTable)];
- UIPopoverController* popover = [ [ [ UIPopoverController alloc ] initWithContentViewController: nav ] autorelease ];
+ UIPopoverController* popover = [[UIPopoverController alloc] initWithContentViewController: nav];
- [ self showPopover: popover from: sender ];
+ [self showPopover: popover from: sender];
}
//------------------------------------------------------------------------------
- (IBAction) changeColor: (id) sender
{
- if( [ self dismissActivePopover ] )
- return;
+ if ([self dismissActivePopover]) return;
- InfColorPickerController* picker = [ InfColorPickerController colorPickerViewController ];
+ InfColorPickerController* picker = [InfColorPickerController colorPickerViewController];
picker.sourceColor = self.view.backgroundColor;
picker.delegate = self;
- UIPopoverController* popover = [ [ [ UIPopoverController alloc ] initWithContentViewController: picker ] autorelease ];
+ UIPopoverController* popover = [[UIPopoverController alloc] initWithContentViewController: picker];
- [ self showPopover: popover from: sender ];
+ [self showPopover: popover from: sender];
}
//------------------------------------------------------------------------------
diff --git a/PickerSamplePad/Classes/PickerSampleTableViewController.h b/PickerSamplePad/Classes/PickerSampleTableViewController.h
index caecd1b..7db51f5 100644
--- a/PickerSamplePad/Classes/PickerSampleTableViewController.h
+++ b/PickerSamplePad/Classes/PickerSampleTableViewController.h
@@ -5,7 +5,7 @@
//
// Created by Troy Gaul on 9/7/11.
//
-// Copyright (c) 2011 InfinitApps LLC - http://infinitapps.com
+// Copyright (c) 2011-2013 InfinitApps LLC: http://infinitapps.com
// Some rights reserved: http://opensource.org/licenses/MIT
//
//==============================================================================
@@ -14,10 +14,6 @@
#import "InfColorPicker.h"
-@interface PickerSampleTableViewController : UITableViewController< InfColorPickerControllerDelegate >
-{
- UIColor* colors[ 3 ];
- int pickingColorIndex;
-}
+@interface PickerSampleTableViewController : UITableViewController
@end
diff --git a/PickerSamplePad/Classes/PickerSampleTableViewController.m b/PickerSamplePad/Classes/PickerSampleTableViewController.m
index 04920d4..04b3b3e 100644
--- a/PickerSamplePad/Classes/PickerSampleTableViewController.m
+++ b/PickerSamplePad/Classes/PickerSampleTableViewController.m
@@ -5,7 +5,7 @@
//
// Created by Troy Gaul on 9/7/11.
//
-// Copyright (c) 2011 InfinitApps LLC - http://infinitapps.com
+// Copyright (c) 2011-2013 InfinitApps LLC: http://infinitapps.com
// Some rights reserved: http://opensource.org/licenses/MIT
//
//==============================================================================
@@ -14,17 +14,9 @@
//==============================================================================
-@implementation PickerSampleTableViewController
-
-//------------------------------------------------------------------------------
-
-- (void) dealloc
-{
- [ colors[ 0 ] release ];
- [ colors[ 1 ] release ];
- [ colors[ 2 ] release ];
-
- [ super dealloc ];
+@implementation PickerSampleTableViewController {
+ NSMutableArray* colors;
+ int pickingColorIndex;
}
//------------------------------------------------------------------------------
@@ -33,15 +25,17 @@ - (void) dealloc
- (void) viewDidLoad
{
- [ super viewDidLoad ];
-
- if( colors[ 0 ] == nil ) {
- colors[ 0 ] = [ [ UIColor blackColor ] retain ];
- colors[ 1 ] = [ [ UIColor redColor ] retain ];
- colors[ 2 ] = [ [ UIColor greenColor ] retain ];
+ [super viewDidLoad];
+
+ if (colors == nil) {
+ colors = [NSMutableArray array];
+
+ [colors addObject: [UIColor blackColor]];
+ [colors addObject: [UIColor redColor]];
+ [colors addObject: [UIColor greenColor]];
}
- self.contentSizeForViewInPopover = [ InfColorPickerController idealSizeForViewInPopover ];
+ self.contentSizeForViewInPopover = [InfColorPickerController idealSizeForViewInPopover];
}
//------------------------------------------------------------------------------
@@ -55,16 +49,9 @@ - (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interf
#pragma mark - Table view data source
//------------------------------------------------------------------------------
-- (NSInteger) numberOfSectionsInTableView: (UITableView*) tableView
-{
- return 1;
-}
-
-//------------------------------------------------------------------------------
-
- (NSInteger) tableView: (UITableView*) tableView numberOfRowsInSection: (NSInteger) section
{
- return 3;
+ return colors.count;
}
//------------------------------------------------------------------------------
@@ -73,18 +60,19 @@ - (UITableViewCell*) tableView: (UITableView*) tableView cellForRowAtIndexPath:
{
static NSString* CellIdentifier = @"Cell";
- UITableViewCell* cell = [ tableView dequeueReusableCellWithIdentifier: CellIdentifier ];
- if( cell == nil ) {
- cell = [ [ [ UITableViewCell alloc ] initWithStyle: UITableViewCellStyleDefault
- reuseIdentifier: CellIdentifier ] autorelease ];
+ UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier: CellIdentifier];
+
+ if (cell == nil) {
+ cell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault
+ reuseIdentifier: CellIdentifier];
}
// Configure the cell:
- if( indexPath.row <= 3 ) // just a sanity test
- cell.textLabel.textColor = colors[ indexPath.row ];
+ if (indexPath.row < colors.count) // just a sanity test
+ cell.textLabel.textColor = colors[indexPath.row];
- cell.textLabel.text = [ NSString stringWithFormat: @"Color # %d", indexPath.row + 1 ];
+ cell.textLabel.text = [NSString stringWithFormat: @"Color # %d", indexPath.row + 1];
return cell;
}
@@ -95,17 +83,17 @@ - (UITableViewCell*) tableView: (UITableView*) tableView cellForRowAtIndexPath:
- (void) tableView: (UITableView*) tableView didSelectRowAtIndexPath: (NSIndexPath*) indexPath
{
- UITableViewCell* cell = [ self.tableView cellForRowAtIndexPath: indexPath ];
+ UITableViewCell* cell = [self.tableView cellForRowAtIndexPath: indexPath];
pickingColorIndex = indexPath.row;
- InfColorPickerController* picker = [ InfColorPickerController colorPickerViewController ];
+ InfColorPickerController* picker = [InfColorPickerController colorPickerViewController];
- picker.sourceColor = colors[ pickingColorIndex ];
+ picker.sourceColor = colors[pickingColorIndex];
picker.delegate = self;
picker.navigationItem.title = cell.textLabel.text;
- [ self.navigationController pushViewController: picker animated: YES ];
+ [self.navigationController pushViewController: picker animated: YES];
}
//------------------------------------------------------------------------------
@@ -114,12 +102,11 @@ - (void) tableView: (UITableView*) tableView didSelectRowAtIndexPath: (NSIndexPa
- (void) colorPickerControllerDidChangeColor: (InfColorPickerController*) controller
{
- NSUInteger indexes[ 2 ] = { 0, pickingColorIndex };
- NSIndexPath* indexPath = [ NSIndexPath indexPathWithIndexes: indexes length: 2 ];
- UITableViewCell* cell = [ self.tableView cellForRowAtIndexPath: indexPath ];
+ NSUInteger indexes[2] = { 0, pickingColorIndex };
+ NSIndexPath* indexPath = [NSIndexPath indexPathWithIndexes: indexes length: 2];
+ UITableViewCell* cell = [self.tableView cellForRowAtIndexPath: indexPath];
- [ colors[ pickingColorIndex ] release ];
- colors[ pickingColorIndex ] = [ controller.resultColor retain ];
+ colors[pickingColorIndex] = controller.resultColor;
cell.textLabel.textColor = controller.resultColor;
}
diff --git a/PickerSamplePad/PickerSamplePad-Info.plist b/PickerSamplePad/PickerSamplePad-Info.plist
index 7f00952..46f216c 100644
--- a/PickerSamplePad/PickerSamplePad-Info.plist
+++ b/PickerSamplePad/PickerSamplePad-Info.plist
@@ -21,7 +21,7 @@
CFBundleSignature
????
CFBundleVersion
- 1.0
+ 1.1
LSRequiresIPhoneOS
NSMainNibFile
diff --git a/PickerSamplePad/PickerSamplePad.xcodeproj/project.pbxproj b/PickerSamplePad/PickerSamplePad.xcodeproj/project.pbxproj
index e4d3a90..683bcd6 100755
--- a/PickerSamplePad/PickerSamplePad.xcodeproj/project.pbxproj
+++ b/PickerSamplePad/PickerSamplePad.xcodeproj/project.pbxproj
@@ -15,6 +15,7 @@
2899E5220DE3E06400AC0155 /* PickerSamplePadViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2899E5210DE3E06400AC0155 /* PickerSamplePadViewController.xib */; };
28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 28AD733E0D9D9553002E5188 /* MainWindow.xib */; };
28D7ACF80DDB3853001CB0EB /* PickerSamplePadViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28D7ACF70DDB3853001CB0EB /* PickerSamplePadViewController.m */; };
+ 6913A78B1858D7EF00A5C092 /* InfColorPickerNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6913A78A1858D7EF00A5C092 /* InfColorPickerNavigationController.m */; };
6923F3CE13F4725B0051A217 /* InfColorBarPicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 6923F3C213F4725B0051A217 /* InfColorBarPicker.m */; };
6923F3CF13F4725B0051A217 /* InfColorIndicatorView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6923F3C413F4725B0051A217 /* InfColorIndicatorView.m */; };
6923F3D013F4725B0051A217 /* InfColorPickerController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6923F3C613F4725B0051A217 /* InfColorPickerController.m */; };
@@ -38,6 +39,8 @@
28D7ACF70DDB3853001CB0EB /* PickerSamplePadViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PickerSamplePadViewController.m; sourceTree = ""; };
29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
32CA4F630368D1EE00C91783 /* PickerSamplePad_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PickerSamplePad_Prefix.pch; sourceTree = ""; };
+ 6913A7891858D7EF00A5C092 /* InfColorPickerNavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InfColorPickerNavigationController.h; sourceTree = ""; };
+ 6913A78A1858D7EF00A5C092 /* InfColorPickerNavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InfColorPickerNavigationController.m; sourceTree = ""; };
6923F3C113F4725B0051A217 /* InfColorBarPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InfColorBarPicker.h; sourceTree = ""; };
6923F3C213F4725B0051A217 /* InfColorBarPicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InfColorBarPicker.m; sourceTree = ""; };
6923F3C313F4725B0051A217 /* InfColorIndicatorView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InfColorIndicatorView.h; sourceTree = ""; };
@@ -137,14 +140,16 @@
6923F3C013F4725B0051A217 /* InfColorPicker */ = {
isa = PBXGroup;
children = (
- 69F47A2A1417E6E200E29503 /* InfColorPicker.h */,
- 6923F3C513F4725B0051A217 /* InfColorPickerController.h */,
- 6923F3C613F4725B0051A217 /* InfColorPickerController.m */,
- 6923F3C713F4725B0051A217 /* InfColorPickerView.xib */,
6923F3C113F4725B0051A217 /* InfColorBarPicker.h */,
6923F3C213F4725B0051A217 /* InfColorBarPicker.m */,
6923F3C313F4725B0051A217 /* InfColorIndicatorView.h */,
6923F3C413F4725B0051A217 /* InfColorIndicatorView.m */,
+ 69F47A2A1417E6E200E29503 /* InfColorPicker.h */,
+ 6923F3C513F4725B0051A217 /* InfColorPickerController.h */,
+ 6923F3C613F4725B0051A217 /* InfColorPickerController.m */,
+ 6913A7891858D7EF00A5C092 /* InfColorPickerNavigationController.h */,
+ 6913A78A1858D7EF00A5C092 /* InfColorPickerNavigationController.m */,
+ 6923F3C713F4725B0051A217 /* InfColorPickerView.xib */,
6923F3C813F4725B0051A217 /* InfColorSquarePicker.h */,
6923F3C913F4725B0051A217 /* InfColorSquarePicker.m */,
6923F3CA13F4725B0051A217 /* InfHSBSupport.h */,
@@ -182,7 +187,7 @@
29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject;
attributes = {
- LastUpgradeCheck = 0410;
+ LastUpgradeCheck = 0500;
};
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "PickerSamplePad" */;
compatibilityVersion = "Xcode 3.2";
@@ -229,6 +234,7 @@
6923F3D013F4725B0051A217 /* InfColorPickerController.m in Sources */,
6923F3D213F4725B0051A217 /* InfColorSquarePicker.m in Sources */,
6923F3D313F4725B0051A217 /* InfHSBSupport.m in Sources */,
+ 6913A78B1858D7EF00A5C092 /* InfColorPickerNavigationController.m in Sources */,
6923F3D413F4725B0051A217 /* InfSourceColorView.m in Sources */,
69F47A2D1417FEE800E29503 /* PickerSampleTableViewController.m in Sources */,
);
@@ -240,13 +246,11 @@
1D6058940D05DD3E006BFB54 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = PickerSamplePad_Prefix.pch;
- GCC_VERSION = com.apple.compilers.llvmgcc42;
INFOPLIST_FILE = "PickerSamplePad-Info.plist";
PRODUCT_NAME = PickerSamplePad;
};
@@ -255,11 +259,9 @@
1D6058950D05DD3E006BFB54 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
COPY_PHASE_STRIP = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = PickerSamplePad_Prefix.pch;
- GCC_VERSION = com.apple.compilers.llvmgcc42;
INFOPLIST_FILE = "PickerSamplePad-Info.plist";
PRODUCT_NAME = PickerSamplePad;
VALIDATE_PRODUCT = YES;
@@ -269,11 +271,13 @@
C01FCF4F08A954540054247B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
- ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
+ CLANG_ENABLE_OBJC_ARC = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.0;
+ ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = 2;
};
@@ -282,11 +286,12 @@
C01FCF5008A954540054247B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
- ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
+ CLANG_ENABLE_OBJC_ARC = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.0;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = 2;
diff --git a/PickerSamplePad/main.m b/PickerSamplePad/main.m
index 79212c6..e23ece2 100644
--- a/PickerSamplePad/main.m
+++ b/PickerSamplePad/main.m
@@ -4,8 +4,8 @@
// PickerSamplePad
//
// Created by Troy Gaul on 8/17/10.
-//
-// Copyright (c) 2011 InfinitApps LLC - http://infinitapps.com
+//
+// Copyright (c) 2011-2013 InfinitApps LLC: http://infinitapps.com
// Some rights reserved: http://opensource.org/licenses/MIT
//
//==============================================================================
@@ -14,13 +14,12 @@
//------------------------------------------------------------------------------
-int main( int argc, char* argv[] )
+int main(int argc, char* argv[])
{
- NSAutoreleasePool* pool = [ [ NSAutoreleasePool alloc ] init ];
- int retVal = UIApplicationMain( argc, argv, nil, nil );
- [ pool release ];
-
- return retVal;
+ @autoreleasepool {
+ int retVal = UIApplicationMain(argc, argv, nil, nil);
+ return retVal;
+ }
}
//------------------------------------------------------------------------------
diff --git a/PickerSamplePhone/Classes/PickerSamplePhoneAppDelegate.h b/PickerSamplePhone/Classes/PickerSamplePhoneAppDelegate.h
index c727417..4befd25 100644
--- a/PickerSamplePhone/Classes/PickerSamplePhoneAppDelegate.h
+++ b/PickerSamplePhone/Classes/PickerSamplePhoneAppDelegate.h
@@ -5,7 +5,7 @@
//
// Created by Troy Gaul on 8/12/10.
//
-// Copyright (c) 2011 InfinitApps LLC - http://infinitapps.com
+// Copyright (c) 2011-2013 InfinitApps LLC: http://infinitapps.com
// Some rights reserved: http://opensource.org/licenses/MIT
//
//==============================================================================
@@ -16,10 +16,10 @@
//------------------------------------------------------------------------------
-@interface PickerSamplePhoneAppDelegate : NSObject< UIApplicationDelegate >
+@interface PickerSamplePhoneAppDelegate : NSObject
-@property( nonatomic, retain ) IBOutlet UIWindow* window;
-@property( nonatomic, retain ) IBOutlet PickerSamplePhoneViewController* viewController;
+@property (nonatomic) IBOutlet UIWindow* window;
+@property (nonatomic) IBOutlet PickerSamplePhoneViewController* viewController;
@end
diff --git a/PickerSamplePhone/Classes/PickerSamplePhoneAppDelegate.m b/PickerSamplePhone/Classes/PickerSamplePhoneAppDelegate.m
index 424da8e..ddbde78 100644
--- a/PickerSamplePhone/Classes/PickerSamplePhoneAppDelegate.m
+++ b/PickerSamplePhone/Classes/PickerSamplePhoneAppDelegate.m
@@ -5,7 +5,7 @@
//
// Created by Troy Gaul on 8/12/10.
//
-// Copyright (c) 2011 InfinitApps LLC - http://infinitapps.com
+// Copyright (c) 2011-2013 InfinitApps LLC: http://infinitapps.com
// Some rights reserved: http://opensource.org/licenses/MIT
//
//==============================================================================
@@ -25,24 +25,17 @@ @implementation PickerSamplePhoneAppDelegate
//------------------------------------------------------------------------------
-- (BOOL) application: (UIApplication*) application
- didFinishLaunchingWithOptions: (NSDictionary*) launchOptions
+- (BOOL) application: (UIApplication*) application
+ didFinishLaunchingWithOptions: (NSDictionary*) launchOptions
{
- [ window addSubview: viewController.view ];
- [ window makeKeyAndVisible ];
+ [window setRootViewController: viewController];
+ [window makeKeyAndVisible];
- return YES;
+ return YES;
}
//------------------------------------------------------------------------------
-- (void) dealloc
-{
- [ viewController release ];
- [ window release ];
-
- [ super dealloc ];
-}
//------------------------------------------------------------------------------
diff --git a/PickerSamplePhone/Classes/PickerSamplePhoneViewController.h b/PickerSamplePhone/Classes/PickerSamplePhoneViewController.h
index f2df2c4..1464bc4 100644
--- a/PickerSamplePhone/Classes/PickerSamplePhoneViewController.h
+++ b/PickerSamplePhone/Classes/PickerSamplePhoneViewController.h
@@ -5,7 +5,7 @@
//
// Created by Troy Gaul on 8/12/10.
//
-// Copyright (c) 2011 InfinitApps LLC - http://infinitapps.com
+// Copyright (c) 2011-2013 InfinitApps LLC: http://infinitapps.com
// Some rights reserved: http://opensource.org/licenses/MIT
//
//==============================================================================
@@ -16,7 +16,7 @@
//------------------------------------------------------------------------------
-@interface PickerSamplePhoneViewController : UIViewController< InfColorPickerControllerDelegate >
+@interface PickerSamplePhoneViewController : UIViewController
- (IBAction) changeBackgroundColor;
diff --git a/PickerSamplePhone/Classes/PickerSamplePhoneViewController.m b/PickerSamplePhone/Classes/PickerSamplePhoneViewController.m
index 278f71e..d1f317e 100644
--- a/PickerSamplePhone/Classes/PickerSamplePhoneViewController.m
+++ b/PickerSamplePhone/Classes/PickerSamplePhoneViewController.m
@@ -5,7 +5,7 @@
//
// Created by Troy Gaul on 8/12/10.
//
-// Copyright (c) 2011 InfinitApps LLC - http://infinitapps.com
+// Copyright (c) 2011-2013 InfinitApps LLC: http://infinitapps.com
// Some rights reserved: http://opensource.org/licenses/MIT
//
//==============================================================================
@@ -22,12 +22,12 @@ @implementation PickerSamplePhoneViewController
- (IBAction) changeBackgroundColor
{
- InfColorPickerController* picker = [ InfColorPickerController colorPickerViewController ];
+ InfColorPickerController* picker = [InfColorPickerController colorPickerViewController];
picker.sourceColor = self.view.backgroundColor;
picker.delegate = self;
- [ picker presentModallyOverViewController: self ];
+ [picker presentModallyOverViewController: self];
}
//------------------------------------------------------------------------------
@@ -35,8 +35,8 @@ - (IBAction) changeBackgroundColor
- (void) colorPickerControllerDidFinish: (InfColorPickerController*) picker
{
self.view.backgroundColor = picker.resultColor;
-
- [ self dismissModalViewControllerAnimated: YES ];
+
+ [self dismissModalViewControllerAnimated: YES];
}
//------------------------------------------------------------------------------
diff --git a/PickerSamplePhone/PickerSamplePhone-Info.plist b/PickerSamplePhone/PickerSamplePhone-Info.plist
index f1bf568..ee18a43 100644
--- a/PickerSamplePhone/PickerSamplePhone-Info.plist
+++ b/PickerSamplePhone/PickerSamplePhone-Info.plist
@@ -21,7 +21,7 @@
CFBundleSignature
????
CFBundleVersion
- 1.0
+ 1.1
LSRequiresIPhoneOS
NSMainNibFile
diff --git a/PickerSamplePhone/PickerSamplePhone.xcodeproj/project.pbxproj b/PickerSamplePhone/PickerSamplePhone.xcodeproj/project.pbxproj
index 01c58f7..f1aad0d 100755
--- a/PickerSamplePhone/PickerSamplePhone.xcodeproj/project.pbxproj
+++ b/PickerSamplePhone/PickerSamplePhone.xcodeproj/project.pbxproj
@@ -15,6 +15,7 @@
2899E5220DE3E06400AC0155 /* PickerSamplePhoneViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2899E5210DE3E06400AC0155 /* PickerSamplePhoneViewController.xib */; };
28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 28AD733E0D9D9553002E5188 /* MainWindow.xib */; };
28D7ACF80DDB3853001CB0EB /* PickerSamplePhoneViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28D7ACF70DDB3853001CB0EB /* PickerSamplePhoneViewController.m */; };
+ 6913A78E1858D80600A5C092 /* InfColorPickerNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6913A78D1858D80600A5C092 /* InfColorPickerNavigationController.m */; };
6923F3E613F481720051A217 /* InfColorBarPicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 6923F3DA13F481720051A217 /* InfColorBarPicker.m */; };
6923F3E713F481720051A217 /* InfColorIndicatorView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6923F3DC13F481720051A217 /* InfColorIndicatorView.m */; };
6923F3E813F481720051A217 /* InfColorPickerController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6923F3DE13F481720051A217 /* InfColorPickerController.m */; };
@@ -26,30 +27,32 @@
/* Begin PBXFileReference section */
1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
- 1D3623240D0F684500981E51 /* PickerSamplePhoneAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PickerSamplePhoneAppDelegate.h; sourceTree = ""; };
- 1D3623250D0F684500981E51 /* PickerSamplePhoneAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PickerSamplePhoneAppDelegate.m; sourceTree = ""; };
+ 1D3623240D0F684500981E51 /* PickerSamplePhoneAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = PickerSamplePhoneAppDelegate.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
+ 1D3623250D0F684500981E51 /* PickerSamplePhoneAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = PickerSamplePhoneAppDelegate.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
1D6058910D05DD3D006BFB54 /* PickerSamplePhone.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PickerSamplePhone.app; sourceTree = BUILT_PRODUCTS_DIR; };
1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
288765A40DF7441C002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
2899E5210DE3E06400AC0155 /* PickerSamplePhoneViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PickerSamplePhoneViewController.xib; sourceTree = ""; };
28AD733E0D9D9553002E5188 /* MainWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = ""; };
- 28D7ACF60DDB3853001CB0EB /* PickerSamplePhoneViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PickerSamplePhoneViewController.h; sourceTree = ""; };
- 28D7ACF70DDB3853001CB0EB /* PickerSamplePhoneViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PickerSamplePhoneViewController.m; sourceTree = ""; };
- 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
- 6923F3D913F481720051A217 /* InfColorBarPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InfColorBarPicker.h; sourceTree = ""; };
- 6923F3DA13F481720051A217 /* InfColorBarPicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InfColorBarPicker.m; sourceTree = ""; };
- 6923F3DB13F481720051A217 /* InfColorIndicatorView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InfColorIndicatorView.h; sourceTree = ""; };
- 6923F3DC13F481720051A217 /* InfColorIndicatorView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InfColorIndicatorView.m; sourceTree = ""; };
- 6923F3DD13F481720051A217 /* InfColorPickerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InfColorPickerController.h; sourceTree = ""; };
+ 28D7ACF60DDB3853001CB0EB /* PickerSamplePhoneViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = PickerSamplePhoneViewController.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
+ 28D7ACF70DDB3853001CB0EB /* PickerSamplePhoneViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = PickerSamplePhoneViewController.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
+ 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = main.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
+ 6913A78C1858D80600A5C092 /* InfColorPickerNavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InfColorPickerNavigationController.h; sourceTree = ""; };
+ 6913A78D1858D80600A5C092 /* InfColorPickerNavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InfColorPickerNavigationController.m; sourceTree = ""; };
+ 6923F3D913F481720051A217 /* InfColorBarPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = InfColorBarPicker.h; sourceTree = ""; };
+ 6923F3DA13F481720051A217 /* InfColorBarPicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = InfColorBarPicker.m; sourceTree = ""; };
+ 6923F3DB13F481720051A217 /* InfColorIndicatorView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = InfColorIndicatorView.h; sourceTree = ""; };
+ 6923F3DC13F481720051A217 /* InfColorIndicatorView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = InfColorIndicatorView.m; sourceTree = ""; };
+ 6923F3DD13F481720051A217 /* InfColorPickerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = InfColorPickerController.h; sourceTree = ""; };
6923F3DE13F481720051A217 /* InfColorPickerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InfColorPickerController.m; sourceTree = ""; };
6923F3DF13F481720051A217 /* InfColorPickerView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = InfColorPickerView.xib; sourceTree = ""; };
- 6923F3E013F481720051A217 /* InfColorSquarePicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InfColorSquarePicker.h; sourceTree = ""; };
- 6923F3E113F481720051A217 /* InfColorSquarePicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InfColorSquarePicker.m; sourceTree = ""; };
- 6923F3E213F481720051A217 /* InfHSBSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InfHSBSupport.h; sourceTree = ""; };
- 6923F3E313F481720051A217 /* InfHSBSupport.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InfHSBSupport.m; sourceTree = ""; };
- 6923F3E413F481720051A217 /* InfSourceColorView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InfSourceColorView.h; sourceTree = ""; };
- 6923F3E513F481720051A217 /* InfSourceColorView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InfSourceColorView.m; sourceTree = ""; };
- 69F47A3114181FB700E29503 /* InfColorPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InfColorPicker.h; sourceTree = ""; };
+ 6923F3E013F481720051A217 /* InfColorSquarePicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = InfColorSquarePicker.h; sourceTree = ""; };
+ 6923F3E113F481720051A217 /* InfColorSquarePicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = InfColorSquarePicker.m; sourceTree = ""; };
+ 6923F3E213F481720051A217 /* InfHSBSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = InfHSBSupport.h; sourceTree = ""; };
+ 6923F3E313F481720051A217 /* InfHSBSupport.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = InfHSBSupport.m; sourceTree = ""; };
+ 6923F3E413F481720051A217 /* InfSourceColorView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = InfSourceColorView.h; sourceTree = ""; };
+ 6923F3E513F481720051A217 /* InfSourceColorView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = InfSourceColorView.m; sourceTree = ""; };
+ 69F47A3114181FB700E29503 /* InfColorPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = InfColorPicker.h; sourceTree = ""; };
8D1107310486CEB800E47090 /* PickerSamplePhone-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "PickerSamplePhone-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = ""; };
/* End PBXFileReference section */
@@ -130,14 +133,16 @@
6923F3D813F481720051A217 /* InfColorPicker */ = {
isa = PBXGroup;
children = (
- 69F47A3114181FB700E29503 /* InfColorPicker.h */,
- 6923F3DD13F481720051A217 /* InfColorPickerController.h */,
- 6923F3DE13F481720051A217 /* InfColorPickerController.m */,
- 6923F3DF13F481720051A217 /* InfColorPickerView.xib */,
6923F3D913F481720051A217 /* InfColorBarPicker.h */,
6923F3DA13F481720051A217 /* InfColorBarPicker.m */,
6923F3DB13F481720051A217 /* InfColorIndicatorView.h */,
6923F3DC13F481720051A217 /* InfColorIndicatorView.m */,
+ 69F47A3114181FB700E29503 /* InfColorPicker.h */,
+ 6923F3DD13F481720051A217 /* InfColorPickerController.h */,
+ 6923F3DE13F481720051A217 /* InfColorPickerController.m */,
+ 6913A78C1858D80600A5C092 /* InfColorPickerNavigationController.h */,
+ 6913A78D1858D80600A5C092 /* InfColorPickerNavigationController.m */,
+ 6923F3DF13F481720051A217 /* InfColorPickerView.xib */,
6923F3E013F481720051A217 /* InfColorSquarePicker.h */,
6923F3E113F481720051A217 /* InfColorSquarePicker.m */,
6923F3E213F481720051A217 /* InfHSBSupport.h */,
@@ -175,7 +180,7 @@
29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject;
attributes = {
- LastUpgradeCheck = 0420;
+ LastUpgradeCheck = 0500;
};
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "PickerSamplePhone" */;
compatibilityVersion = "Xcode 3.2";
@@ -221,6 +226,7 @@
6923F3E713F481720051A217 /* InfColorIndicatorView.m in Sources */,
6923F3E813F481720051A217 /* InfColorPickerController.m in Sources */,
6923F3EA13F481720051A217 /* InfColorSquarePicker.m in Sources */,
+ 6913A78E1858D80600A5C092 /* InfColorPickerNavigationController.m in Sources */,
6923F3EB13F481720051A217 /* InfHSBSupport.m in Sources */,
6923F3EC13F481720051A217 /* InfSourceColorView.m in Sources */,
);
@@ -233,12 +239,11 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
- GCC_VERSION = com.apple.compilers.llvmgcc42;
INFOPLIST_FILE = "PickerSamplePhone-Info.plist";
- IPHONEOS_DEPLOYMENT_TARGET = 3.0;
PRODUCT_NAME = PickerSamplePhone;
};
name = Debug;
@@ -247,10 +252,9 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = YES;
- GCC_VERSION = com.apple.compilers.llvmgcc42;
INFOPLIST_FILE = "PickerSamplePhone-Info.plist";
- IPHONEOS_DEPLOYMENT_TARGET = 3.0;
PRODUCT_NAME = PickerSamplePhone;
VALIDATE_PRODUCT = YES;
};
@@ -259,7 +263,6 @@
C01FCF4F08A954540054247B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
- ARCHS = "$(ARCHS_STANDARD_32_BIT)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
@@ -279,6 +282,8 @@
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_PARAMETER = NO;
GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.0;
+ ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
};
name = Debug;
@@ -286,7 +291,6 @@
C01FCF5008A954540054247B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
- ARCHS = "$(ARCHS_STANDARD_32_BIT)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_AUTO_VECTORIZATION = YES;
GCC_C_LANGUAGE_STANDARD = c99;
@@ -309,6 +313,7 @@
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_PARAMETER = NO;
GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.0;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
SDKROOT = iphoneos;
};
diff --git a/PickerSamplePhone/main.m b/PickerSamplePhone/main.m
index d2f4659..55f5180 100644
--- a/PickerSamplePhone/main.m
+++ b/PickerSamplePhone/main.m
@@ -5,7 +5,7 @@
//
// Created by Troy Gaul on 8/12/10.
//
-// Copyright (c) 2011 InfinitApps LLC - http://infinitapps.com
+// Copyright (c) 2011-2013 InfinitApps LLC: http://infinitapps.com
// Some rights reserved: http://opensource.org/licenses/MIT
//
//==============================================================================
@@ -14,13 +14,13 @@
//------------------------------------------------------------------------------
-int main( int argc, char* argv[] )
+int main(int argc, char* argv[])
{
- NSAutoreleasePool* pool = [ [ NSAutoreleasePool alloc ] init ];
- int retVal = UIApplicationMain( argc, argv, nil, nil );
- [ pool release ];
+ @autoreleasepool {
+ int retVal = UIApplicationMain(argc, argv, nil, nil);
- return retVal;
+ return retVal;
+ }
}
//------------------------------------------------------------------------------
diff --git a/README.markdown b/README.markdown
index 0eaeb23..dba9938 100644
--- a/README.markdown
+++ b/README.markdown
@@ -1,8 +1,10 @@
-The InfiniApps Color Picker, known as InfColorPicker, is a view controller for use in iOS applications to allow the selection of a color from RGB space, but using an HSB representation of that color space to make selection of a color easier for a human.
+The InfinitApps Color Picker, known as InfColorPicker, is a view controller for use in iOS applications to allow the selection of a color from RGB space, but using an HSB representation of that color space to make selection of a color easier for a human.

-InfColorPicker is distributed with an MIT license. It supports iPhone OS 3.x as well as iOS 4 and 5.
+InfColorPicker is distributed with an MIT license.
+
+It is ARC-based and supports iPhone OS 5 and later (with one small change it could be made compatible back to iOS 4 if that's necessary).
Usage
-----