Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions RSColorPicker/ColorPickerClasses/RSColorPickerView.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ - (void)generateBezierPaths;
- (void)handleStateChanged;

// Called to handle a state change (optionally disabling CA Actions for loupe).
- (void)handleStateChangedDisableActions:(BOOL)disable;
- (void)handleStateChangedDisableActions:(BOOL)disable tellDelegate:(BOOL)tell;

// touch handling
- (CGPoint)validPointForTouch:(CGPoint)touchPoint;
Expand Down Expand Up @@ -164,7 +164,7 @@ - (void)initRoutine {

[self.layer addSublayer:self.contentsLayer];

[self handleStateChangedDisableActions:NO];
[self handleStateChangedDisableActions:NO tellDelegate:YES];

self.contentsLayer.masksToBounds = YES;
self.cropToCircle = NO;
Expand Down Expand Up @@ -273,12 +273,12 @@ - (void)setSelection:(CGPoint)selection {

- (void)setBrightness:(CGFloat)bright {
state = [state stateBySettingBrightness:bright];
[self handleStateChanged];
[self handleStateChangedTellDelegate:YES];
}

- (void)setOpacity:(CGFloat)opacity {
state = [state stateBySettingAlpha:opacity];
[self handleStateChanged];
[self handleStateChangedTellDelegate:YES];
}

- (void)setCropToCircle:(BOOL)circle {
Expand All @@ -297,16 +297,21 @@ - (void)setCropToCircle:(BOOL)circle {

- (void)setSelectionColor:(UIColor *)selectionColor {
state = [[RSColorPickerState alloc] initWithColor:selectionColor];
[self handleStateChanged];
[self handleStateChangedTellDelegate:NO];
}

#pragma mark - Selection Updates -

- (void)handleStateChanged {
[self handleStateChangedDisableActions:YES];
- (void)handleStateChanged
{
[self handleStateChangedTellDelegate:NO];
}

- (void)handleStateChangedDisableActions:(BOOL)disable {
- (void)handleStateChangedTellDelegate:(BOOL)tellDelegate {
[self handleStateChangedDisableActions:YES tellDelegate:tellDelegate];
}

- (void)handleStateChangedDisableActions:(BOOL)disable tellDelegate:(BOOL)tellDelegate {
[CATransaction begin];
[CATransaction setDisableActions: disable];

Expand All @@ -329,14 +334,14 @@ - (void)handleStateChangedDisableActions:(BOOL)disable {
[CATransaction commit];

// notify delegate
if ([self.delegate respondsToSelector:@selector(colorPickerDidChangeSelection:)]) {
if (tellDelegate && [self.delegate respondsToSelector:@selector(colorPickerDidChangeSelection:)]) {
[self.delegate colorPickerDidChangeSelection:self];
}
}

- (void)updateStateForTouchPoint:(CGPoint)point {
state = [self stateForPoint:[self validPointForTouch:point]];
[self handleStateChanged];
[self handleStateChangedTellDelegate:YES];
}

#pragma mark - Metrics -
Expand Down