mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			105 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Matlab
		
	
		
		
			
		
	
	
			105 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Matlab
		
	
| 
								 
											9 years ago
										 
									 | 
							
								//
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								//  Copyright (c) 2018 Open Whisper Systems. All rights reserved.
							 | 
						||
| 
								 
											9 years ago
										 
									 | 
							
								//
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#import "OWSBezierPathView.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											9 years ago
										 
									 | 
							
								NS_ASSUME_NONNULL_BEGIN
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#pragma mark -
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											9 years ago
										 
									 | 
							
								@implementation OWSBezierPathView
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								- (id)init
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    self = [super init];
							 | 
						||
| 
								 | 
							
								    if (self) {
							 | 
						||
| 
								 | 
							
								        [self initCommon];
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    return self;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								- (id)initWithFrame:(CGRect)frame
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    self = [super initWithFrame:frame];
							 | 
						||
| 
								 | 
							
								    if (self) {
							 | 
						||
| 
								 | 
							
								        [self initCommon];
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								    return self;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								- (void)initCommon
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    self.opaque = NO;
							 | 
						||
| 
								 | 
							
								    self.userInteractionEnabled = NO;
							 | 
						||
| 
								 | 
							
								    self.backgroundColor = [UIColor clearColor];
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								- (void)setFrame:(CGRect)frame
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    BOOL didChangeSize = !CGSizeEqualToSize(frame.size, self.frame.size);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    [super setFrame:frame];
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    if (didChangeSize) {
							 | 
						||
| 
								 | 
							
								        [self updateLayers];
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								- (void)setBounds:(CGRect)bounds
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    BOOL didChangeSize = !CGSizeEqualToSize(bounds.size, self.bounds.size);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    [super setBounds:bounds];
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    if (didChangeSize) {
							 | 
						||
| 
								 | 
							
								        [self updateLayers];
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								- (void)setConfigureShapeLayerBlock:(ConfigureShapeLayerBlock)configureShapeLayerBlock
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								    OWSAssertDebug(configureShapeLayerBlock);
							 | 
						||
| 
								 
											9 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 | 
							
								    [self setConfigureShapeLayerBlocks:@[ configureShapeLayerBlock ]];
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								- (void)setConfigureShapeLayerBlocks:(NSArray<ConfigureShapeLayerBlock> *)configureShapeLayerBlocks
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								    OWSAssertDebug(configureShapeLayerBlocks.count > 0);
							 | 
						||
| 
								 
											9 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 | 
							
								    _configureShapeLayerBlocks = configureShapeLayerBlocks;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    [self updateLayers];
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								- (void)updateLayers
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    if (self.bounds.size.width <= 0.f || self.bounds.size.height <= 0.f) {
							 | 
						||
| 
								 | 
							
								        return;
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    for (CALayer *layer in self.layer.sublayers) {
							 | 
						||
| 
								 | 
							
								        [layer removeFromSuperlayer];
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								    // Prevent the shape layer from animating changes.
							 | 
						||
| 
								 | 
							
								    [CATransaction begin];
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								    [CATransaction setDisableActions:YES];
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											9 years ago
										 
									 | 
							
								    for (ConfigureShapeLayerBlock configureShapeLayerBlock in self.configureShapeLayerBlocks) {
							 | 
						||
| 
								 | 
							
								        CAShapeLayer *shapeLayer = [CAShapeLayer new];
							 | 
						||
| 
								 | 
							
								        configureShapeLayerBlock(shapeLayer, self.bounds);
							 | 
						||
| 
								 | 
							
								        [self.layer addSublayer:shapeLayer];
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								    [CATransaction commit];
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											9 years ago
										 
									 | 
							
								    [self setNeedsDisplay];
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								@end
							 | 
						||
| 
								 
											9 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 | 
							
								NS_ASSUME_NONNULL_END
							 |