Skip to content

Commit

Permalink
Added some documentation, updated READMEa
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanday committed Jul 19, 2011
1 parent 7345f8f commit 31fc7b8
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 16 deletions.
26 changes: 21 additions & 5 deletions Classes/NDRotator.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,36 +98,49 @@ enum NDThumbTint
/*!
@property minimumDomain
@abstract Contains the minimum angle of the receiver.
@discussion
The default value of this property is 0.0.
*/
@property(assign) CGFloat minimumDomain;
/*!
@property maximumDomain
@abstract Contains the maximum angle of the receiver.
*/
@discussion
The default value of this property is 2.0π.
*/
@property(assign) CGFloat maximumDomain;
/*!
@property linearSensitivity
@abstract Contains the value used to determin how vertical movement is mapped to angular movement of the control when the style is NDRotatorStyleLinear.
@abstract Contains the value used to determin how vertical movement is mapped to angular movement of the control when the style is NDRotatorStyleLinear.
@discussion The angle is propertional to y-value * linearSensitivity.
The default value of this property is 0.05.
*/
@property(assign) CGFloat linearSensitivity;
/*!
@property angle
@abstract Contains the angel of the receiver in radians.
@abstract Contains the angle of the receiver in radians.
@discussion This value will be constrained by the values (minimumDomain,maximumDomain) and so can represent a range of values greater than one turn.
*/
@property(assign,nonatomic) CGFloat angle;
/*!
@property radius
@abstract Contains the radial value of the receiver where 0.0 puts the thumb at the center and 1.0 puts the thumb at margin.
@discussion The values can be greater than 1.0, to reflect user movements outside of the control.
*/
@property(assign,nonatomic) CGFloat radius;
/*!
@property cartesianPoint
@abstract Contains the thumb point where (0.0,0.0) is the center, (1.0,0.0) is at 3 oclock and (0.0,-1.0) is at 12 oclock etc.
*/
@discussion The point can go beyound the bounds (-1.0,-1.0) and (1.0,1.0) for radius values greated the 1.0.
*/
@property(assign) CGPoint cartesianPoint;
/*!
@property constrainedCartesianPoint
@abstract Contains the thumb point where (0.0,0.0) is the center, (1.0,0.0) is at 3 oclock and (0.0,-1.0) is at 12 oclock etc. Constrained to a raius of 1.0.
@discussion Ths value is similar to cartesianPoint give a radius constrained to (0.0,1.0).
*/
@property(readonly) CGPoint constrainedCartesianPoint;
/*!
Expand All @@ -154,11 +167,14 @@ enum NDThumbTint
/*!
@property thumbTint
@abstract Contains the value used to set the color of the thumb.
@discussion
The default value of the property is NDThumbTintGrey.
*/
@property(nonatomic) enum NDThumbTint thumbTint;

/*!
@methodgroup methods and properties to override to change, these methods are not yet finalized.
@methodgroup methods and properties to override to change the apperance of a NDRotator, these methods are not yet finalized.
*/

@property(readonly) CGRect controlRect;
Expand Down
16 changes: 8 additions & 8 deletions Classes/NDRotator.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
kDefaultLinearSensitivity = 0.05,
kDefaultMinimumValue = 0.0,
kDefaultMaximumValue = 1.0,
kDefaultMinimumDomain = 0,
kDefaultMinimumDomain = 0.0*M_PI,
kDefaultMaximumDomain = 2.0*M_PI;
static enum NDThumbTint kDefaultThumbTint = NDThumbTintLime;
static const BOOL kDefaultContinuousValue = YES,
Expand Down Expand Up @@ -176,15 +176,15 @@ static CGFloat meanFloat( const CGFloat * f, NSUInteger c )
@interface NDRotator ()
{
@private
CGFloat touchDownAngel,
CGFloat touchDownAngle,
touchDownYLocation;
UIImage * cachedDiscImage,
* cachedHilightedDiscImage,
* cachedThumbImage,
* cachedHilightedThumbImage;
}
@property(assign) CGPoint location;
@property(assign) CGFloat touchDownAngel,
@property(assign) CGFloat touchDownAngle,
touchDownYLocation;
@property(readonly) UIImage * cachedDiscImage,
* cachedHilightedDiscImage,
Expand Down Expand Up @@ -420,8 +420,8 @@ - (void)encodeWithCoder:(NSCoder *)anEncoder
[anEncoder encodeDouble:self.minimumDomain forKey:kMinimumDomainCodingKey];
[anEncoder encodeDouble:self.maximumDomain forKey:kMaximumDomainCodingKey];
[anEncoder encodeObject:stringForInteger(self.thumbTint, kThumbTintStr, sizeof(kThumbTintStr)/sizeof(*kThumbTintStr)) forKey:kThumbTintCodingKey];
[anEncoder encodeBool:self.continuous forKey:kDefaultContinuousValue];
[anEncoder encodeBool:self.wrapAround forKey:kDefaultWrapAroundValue];
[anEncoder encodeBool:self.continuous forKey:kContinuousCodingKey];
[anEncoder encodeBool:self.wrapAround forKey:kWrapAroundCodingKey];
}
else
{
Expand All @@ -447,7 +447,7 @@ - (BOOL)beginTrackingWithTouch:(UITouch *)aTouch withEvent:(UIEvent *)anEvent
{
CGPoint thePoint = [aTouch locationInView:self];
self.touchDownYLocation = thePoint.y;
self.touchDownAngel = self.angle;
self.touchDownAngle = self.angle;
self.location = thePoint;
if( self.isContinuous )
[self sendActionsForControlEvents:UIControlEventValueChanged];
Expand Down Expand Up @@ -651,7 +651,7 @@ - (BOOL)drawThumbInRect:(CGRect)aRect hilighted:(BOOL)aHilighted
#pragma mark -
#pragma mark Private

@synthesize touchDownAngel,
@synthesize touchDownAngle,
touchDownYLocation;

- (CGPoint)location
Expand All @@ -670,7 +670,7 @@ - (void)setLocation:(CGPoint)aPoint
}
else
{
self.angle = self.touchDownAngel - (aPoint.y - self.touchDownYLocation) * self.linearSensitivity;
self.angle = self.touchDownAngle - (aPoint.y - self.touchDownYLocation) * self.linearSensitivity;
self.radius = 1.0;
}
}
Expand Down
6 changes: 5 additions & 1 deletion README
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
This is an initial release and still requires documentation. I also want to make it easier for people to override the methods for drawing the control elements so that developers can use it to create rotary controls of there own.
This is an initial release and still requires documentation. I also want to make it easier for people to override the methods for drawing the control elements so that developers can use it to create rotary controls of there own.

Know Issues
- Currently the minimumDomain and maximumDomain are not respected when the style is NDRotatorStyleLinear and wrapAround is YES.
- No unit tests.
4 changes: 2 additions & 2 deletions Standard/StandardViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ - (IBAction)changeRotatorAction:(NDRotator *)aSender
[self.xTextView setNeedsDisplay];
self.yTextView.text = [NSString stringWithFormat:@"%.2f", self.rotatorView.cartesianPoint.y];
[self.yTextView setNeedsDisplay];
self.valueTextView.text = [NSString stringWithFormat:@"%.1f", self.rotatorView.value];
self.valueTextView.text = [NSString stringWithFormat:@"%.2f", self.rotatorView.value];
[self.valueTextView setNeedsDisplay];
}
#pragma mark -
Expand Down Expand Up @@ -228,7 +228,7 @@ - (void)updateOutputValueFields
[self.xTextView setNeedsDisplay];
self.yTextView.text = [NSString stringWithFormat:@"%.2f", self.rotatorView.cartesianPoint.y];
[self.yTextView setNeedsDisplay];
self.valueTextView.text = [NSString stringWithFormat:@"%.1f", self.rotatorView.value];
self.valueTextView.text = [NSString stringWithFormat:@"%.2f", self.rotatorView.value];
[self.valueTextView setNeedsDisplay];
switch( self.rotatorView.style )
{
Expand Down

0 comments on commit 31fc7b8

Please sign in to comment.