<|start_filename|>DCControls/DCSlider.h<|end_filename|>
//
//  DCSlider.h
//
//  Copyright 2011 Domestic Cat. All rights reserved.
//

#import "DCControl.h"

@interface DCSlider : DCControl
{
	CGFloat touchHandleOffset;
}

@property CGFloat handleSize;				// default: longest side / 6 (minimum of 35.0)
@property CGFloat cornerRadius;				// default: 3.0
@property BOOL isHorizontalSlider;			// default: NO
@property BOOL biDirectional;				// default: NO

/////////////////////////
// Init/Custom Setters //
/////////////////////////

- (id)initWithDelegate:(id)aDelegate;

////////////////////
// Touch Handling //
////////////////////

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;

////////////////////////
// Handle Positioning //
////////////////////////

- (CGRect)rectForHandle;

@end


<|start_filename|>DCControls/DCControlsAppDelegate.h<|end_filename|>
//
//  DCControlsAppDelegate.h
//
//  Copyright 2011 Domestic Cat Software. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface DCControlsAppDelegate : NSObject <UIApplicationDelegate>
{
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;

@end


<|start_filename|>DCControls/DCKnobDemoViewController.h<|end_filename|>
//
//  DCKnobDemoViewController.h
//
//  Copyright 2011 Domestic Cat Software. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>

#import "DCKnob.h"

@interface DCKnobDemoViewController : UIViewController <DCControlDelegate>
{
}

@property (nonatomic, retain) DCKnob *knob;
@property (nonatomic, retain) IBOutlet UIView *knobContainer;
@property (nonatomic, retain) IBOutlet UIScrollView *controlScrollView;
@property (nonatomic, retain) IBOutlet UILabel *doubleTapValueLabel;
@property (nonatomic, retain) IBOutlet UILabel *tripleTapValueLabel;
@property (nonatomic, retain) IBOutlet UILabel *ringBackgroundAlphaLabel;
@property (nonatomic, retain) IBOutlet UILabel *sizeLabel;
@property (nonatomic, retain) IBOutlet UISlider *sizeSlider;
@property (nonatomic, retain) IBOutlet UILabel *arcStartLabel;
@property (nonatomic, retain) IBOutlet UILabel *cutoutSizeLabel;
@property (nonatomic, retain) IBOutlet UILabel *ringWidthLabel;
@property (nonatomic, retain) IBOutlet UILabel *fontSizeLabel;
@property (nonatomic, retain) IBOutlet UILabel *labelOffsetXLabel;
@property (nonatomic, retain) IBOutlet UILabel *labelOffsetYLabel;

- (IBAction)biDirectionalDidChange:(id)sender;
- (IBAction)doubleTapValueDidChange:(id)sender;
- (IBAction)tripleTapValueDidChange:(id)sender;
- (IBAction)colorDidChange:(id)sender;
- (IBAction)ringBackgroundAlphaDidChange:(id)sender;
- (IBAction)sizeDidChange:(id)sender;
- (IBAction)arcStartDidChange:(id)sender;
- (IBAction)cutoutSizeDidChange:(id)sender;
- (IBAction)ringWidthDidChange:(id)sender;
- (IBAction)displayValueChanged:(id)sender;
- (IBAction)labelTextSizeDidChange:(id)sender;
- (IBAction)labelTextColorDidChange:(id)sender;
- (IBAction)labelOffsetXDidChange:(id)sender;
- (IBAction)labelOffsetYDidChange:(id)sender;

@end


<|start_filename|>DCControls/DCKnob.h<|end_filename|>
//
//  DCKnob.h
//
//  Copyright 2011 Domestic Cat. All rights reserved.
//

#import "DCControl.h"

#define kDCKnobRatio (M_PI * ((360.0 - self.cutoutSize) / 360.0))

static inline CGFloat angleBetweenPoints(CGPoint first, CGPoint second)
{
	CGFloat height = second.y - first.y;
	CGFloat width = first.x - second.x;
	CGFloat rads = atan2(height, width);
	return rads;
}

@interface DCKnob : DCControl
{
	CGAffineTransform initialTransform;
	CGPoint lastPoint;
	CGFloat initialAngle;
}

@property BOOL biDirectional;					// default: NO
@property CGFloat arcStartAngle;				// default: 90 (degrees)
@property CGFloat cutoutSize;					// default: 60 (degrees)
@property CGFloat valueArcWidth;				// default: 15.0

@property CGFloat doubleTapValue;				// default: 0%
@property CGFloat tripleTapValue;				// default: 0%

/////////////////////////
// Init/Custom Setters //
/////////////////////////

- (id)initWithDelegate:(id)aDelegate;
- (void)setFrame:(CGRect)frame;

////////////////////
// Touch Handling //
////////////////////

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;

////////////////////
// Helper Methods //
////////////////////

- (CGAffineTransform)initialTransform;
- (CGFloat)newValueFromTransform:(CGAffineTransform)transform;

@end


<|start_filename|>DCControls/DCControl.h<|end_filename|>
//
//  DCControl.h
//
//  Copyright 2011 Domestic Cat. All rights reserved.
//

#define	kDCControlIsPhone (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad)
#define kDCControlDegreesToRadians(x) (M_PI * (x) / 180.0)
#define kDCControlRadiansToDegrees(x) ((x) * 180.0 / M_PI)

@protocol DCControlDelegate <NSObject>

@required

- (void)controlValueDidChange:(float)value sender:(id)sender;

@end

@interface DCControl : UIView
{
}

@property (nonatomic, assign) id delegate;
@property (nonatomic, retain) UIColor *color;			// default: black
@property CGFloat backgroundColorAlpha;					// default: 0.3

@property (nonatomic, retain) UIFont *labelFont;		// default: bold, system, 12.5
@property (nonatomic, retain) UIColor *labelColor;		// default: use self.color
@property CGPoint labelOffset;							// default: CGPointZero

@property CGFloat min;									// default: 0.0
@property CGFloat max;									// default: 1.0
@property (nonatomic) CGFloat value;					// default: 0.0

@property BOOL displaysValue;							// default: YES
@property BOOL allowsGestures;							// default: YES

- (id)initWithDelegate:(id)aDelegate;

/////////////////////
// Drawing Methods //
/////////////////////

- (void)context:(CGContextRef)context addRoundedRect:(CGRect)rect cornerRadius:(float)cornerRadius;

@end


<|start_filename|>DCControls/DCSliderDemoViewController.h<|end_filename|>
//
//  DCSliderDemoViewController.h
//
//  Copyright 2011 Domestic Cat Software. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>

#import "DCSlider.h"

@interface DCSliderDemoViewController : UIViewController <DCControlDelegate>
{
	UILabel *cornerRadiusLabel;
	UILabel *heightLabel;
	UISlider *heightSlider;
	UILabel *handleSizeLabel;
	UISlider *handleSizeSlider;
	UISlider *widthSlider;
}

@property (nonatomic, retain) DCSlider *slider;
@property (nonatomic, retain) IBOutlet UIView *sliderContainer;
@property (nonatomic, retain) IBOutlet UIScrollView *controlScrollView;
@property (nonatomic, retain) IBOutlet UILabel *backgroundAlphaLabel;
@property (nonatomic, retain) IBOutlet UILabel *widthLabel;
@property (nonatomic, retain) IBOutlet UISlider *widthSlider;
@property (nonatomic, retain) IBOutlet UILabel *heightLabel;
@property (nonatomic, retain) IBOutlet UISlider *heightSlider;
@property (nonatomic, retain) IBOutlet UILabel *handleSizeLabel;
@property (nonatomic, retain) IBOutlet UISlider *handleSizeSlider;
@property (nonatomic, retain) IBOutlet UISlider *sizeSlider;
@property (nonatomic, retain) IBOutlet UILabel *cornerRadiusLabel;
@property (nonatomic, retain) IBOutlet UILabel *fontSizeLabel;

- (IBAction)horizontalDidChange:(id)sender;
- (IBAction)biDirectionalDidChange:(id)sender;
- (IBAction)colorDidChange:(id)sender;
- (IBAction)backgroundAlphaDidChange:(id)sender;
- (IBAction)widthDidChange:(id)sender;
- (IBAction)heightDidChange:(id)sender;
- (IBAction)handleSizeDidChange:(id)sender;
- (IBAction)cornerRadiusDidChange:(id)sender;
- (IBAction)displayValueChanged:(id)sender;
- (IBAction)labelTextSizeDidChange:(id)sender;
- (IBAction)labelTextColorDidChange:(id)sender;

@end
