From 2714d48117ca71f3d08bd4cf2ecf733156a4f412 Mon Sep 17 00:00:00 2001 From: Heberti Almeida Date: Wed, 2 Dec 2015 00:37:16 -0200 Subject: [PATCH] Removed TGPControls from source --- Example/Podfile.lock | 5 +- FolioReaderKit.podspec | 4 +- Source/Vendor/TGPControls/TGPCamelLabels.h | 48 -- Source/Vendor/TGPControls/TGPCamelLabels.m | 45 -- Source/Vendor/TGPControls/TGPCamelLabels7.h | 51 -- Source/Vendor/TGPControls/TGPCamelLabels7.m | 306 --------- .../TGPControls/TGPControlsTicksProtocol.h | 38 -- Source/Vendor/TGPControls/TGPDiscreteSlider.h | 58 -- Source/Vendor/TGPControls/TGPDiscreteSlider.m | 62 -- .../Vendor/TGPControls/TGPDiscreteSlider7.h | 77 --- .../Vendor/TGPControls/TGPDiscreteSlider7.m | 590 ------------------ Source/Vendor/TGPControls/module.map | 4 - .../SMSegmentView/SMSegment.swift | 0 .../SMSegmentView/SMSegmentView.swift | 0 14 files changed, 6 insertions(+), 1282 deletions(-) delete mode 100755 Source/Vendor/TGPControls/TGPCamelLabels.h delete mode 100755 Source/Vendor/TGPControls/TGPCamelLabels.m delete mode 100755 Source/Vendor/TGPControls/TGPCamelLabels7.h delete mode 100755 Source/Vendor/TGPControls/TGPCamelLabels7.m delete mode 100755 Source/Vendor/TGPControls/TGPControlsTicksProtocol.h delete mode 100755 Source/Vendor/TGPControls/TGPDiscreteSlider.h delete mode 100755 Source/Vendor/TGPControls/TGPDiscreteSlider.m delete mode 100755 Source/Vendor/TGPControls/TGPDiscreteSlider7.h delete mode 100755 Source/Vendor/TGPControls/TGPDiscreteSlider7.m delete mode 100755 Source/Vendor/TGPControls/module.map rename {Source/Vendor => Vendor}/SMSegmentView/SMSegment.swift (100%) rename {Source/Vendor => Vendor}/SMSegmentView/SMSegmentView.swift (100%) diff --git a/Example/Podfile.lock b/Example/Podfile.lock index d3366de29..6329b61aa 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -5,11 +5,13 @@ PODS: - FontBlaster - JSQWebViewController - SSZipArchive + - TGPControls - UIMenuItem-CXAImageSupport - ZFDragableModalTransition - FontBlaster (2.0.2) - JSQWebViewController (2.0.1) - SSZipArchive (1.0.1) + - TGPControls (1.0.0) - UIMenuItem-CXAImageSupport (0.0.1) - ZFDragableModalTransition (0.5.1) @@ -22,10 +24,11 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: AEXML: d6bb5b994521fcf3667ee8ccc1ed533f31b19218 - FolioReaderKit: 6428b0d09360b739c6a9f3f1ff694ffd10fdb486 + FolioReaderKit: 2d959f64e0103895708e2a952efeff7d1d755135 FontBlaster: 8165fef7f0556ba766836a2f5654a16cd0251e27 JSQWebViewController: 2e416ae6604676510812bbda050d63a1488003a4 SSZipArchive: 5f30a0af2cb3d48c0ff83b1e18029f7041ac3c38 + TGPControls: cb814ac463c21d64a428aaad37d55d1763fb2e90 UIMenuItem-CXAImageSupport: 2945e2af4487414caad801ed8ff6ac8db274e986 ZFDragableModalTransition: 048189eda437f91944ce6d5151618b8bf770196d diff --git a/FolioReaderKit.podspec b/FolioReaderKit.podspec index eb38f25e6..f652b0e22 100644 --- a/FolioReaderKit.podspec +++ b/FolioReaderKit.podspec @@ -19,7 +19,7 @@ Pod::Spec.new do |s| s.source_files = [ 'Source/*.{h,swift}', 'Source/**/*.swift', - 'Source/Vendor/**/*.{swift,h,m,map}', # Temporary + 'Vendor/**/*.{swift,h,m}', # Temporary ] s.resources = [ 'Source/**/*.{js,css,xcdatamodeld}', @@ -37,6 +37,6 @@ Pod::Spec.new do |s| s.dependency 'AEXML' s.dependency 'FontBlaster' s.dependency 'JSQWebViewController' - # s.dependency 'TGPControls' + s.dependency 'TGPControls' # s.dependency 'SMSegmentView' end diff --git a/Source/Vendor/TGPControls/TGPCamelLabels.h b/Source/Vendor/TGPControls/TGPCamelLabels.h deleted file mode 100755 index 2225f8563..000000000 --- a/Source/Vendor/TGPControls/TGPCamelLabels.h +++ /dev/null @@ -1,48 +0,0 @@ -// @file: TGPCamelLabels.h -// @project: TGPControls -// -// @history: Created November 27, 2014 (Thanksgiving Day) -// @author: Xavier Schott -// mailto://xschott@gmail.com -// http://thegothicparty.com -// tel://+18089383634 -// -// @license: http://opensource.org/licenses/MIT -// Copyright (c) 2014, Xavier Schott -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "TGPCamelLabels7.h" - -IB_DESIGNABLE -@interface TGPCamelLabels : TGPCamelLabels7 - -@property (nonatomic) IBInspectable NSUInteger tickCount; // Only used if [labels count] < 1 -@property (nonatomic) IBInspectable CGFloat ticksDistance; -@property (nonatomic) IBInspectable NSUInteger value; - -@property (nonatomic) IBInspectable NSString * upFontName; -@property (nonatomic) IBInspectable CGFloat upFontSize; -@property (nonatomic) IBInspectable UIColor * upFontColor; - -@property (nonatomic) IBInspectable NSString * downFontName; -@property (nonatomic) IBInspectable CGFloat downFontSize; -@property (nonatomic) IBInspectable UIColor * downFontColor; - -@end diff --git a/Source/Vendor/TGPControls/TGPCamelLabels.m b/Source/Vendor/TGPControls/TGPCamelLabels.m deleted file mode 100755 index 4aabf848b..000000000 --- a/Source/Vendor/TGPControls/TGPCamelLabels.m +++ /dev/null @@ -1,45 +0,0 @@ -// @file: TGPCamelLabels.m -// @project: TGPControls -// -// @history: Created November 27, 2014 (Thanksgiving Day) -// @author: Xavier Schott -// mailto://xschott@gmail.com -// http://thegothicparty.com -// tel://+18089383634 -// -// @license: http://opensource.org/licenses/MIT -// Copyright (c) 2014, Xavier Schott -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "TGPCamelLabels.h" - -@implementation TGPCamelLabels - -@dynamic tickCount; -@dynamic ticksDistance; -@dynamic value; -@dynamic upFontName; -@dynamic upFontSize; -@dynamic upFontColor; -@dynamic downFontName; -@dynamic downFontSize; -@dynamic downFontColor; - -@end diff --git a/Source/Vendor/TGPControls/TGPCamelLabels7.h b/Source/Vendor/TGPControls/TGPCamelLabels7.h deleted file mode 100755 index 0e4ee6e12..000000000 --- a/Source/Vendor/TGPControls/TGPCamelLabels7.h +++ /dev/null @@ -1,51 +0,0 @@ -// @file: TGPCamelLabels7.h -// @project: TGPControls -// -// @history: Created July 4th, 2014 (Independence Day) -// @author: Xavier Schott -// mailto://xschott@gmail.com -// http://thegothicparty.com -// tel://+18089383634 -// -// @license: http://opensource.org/licenses/MIT -// Copyright (c) 2014, Xavier Schott -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import -#import "TGPControlsTicksProtocol.h" - -@interface TGPCamelLabels7 : UIControl - -@property (nonatomic, assign) NSUInteger tickCount; // Only used if [labels count] < 1 -@property (nonatomic, assign) CGFloat ticksDistance; -@property (nonatomic, assign) NSUInteger value; - -@property (nonatomic, strong) NSString * upFontName; -@property (nonatomic, assign) CGFloat upFontSize; -@property (nonatomic, strong) UIColor * upFontColor; - -@property (nonatomic, strong) NSString * downFontName; -@property (nonatomic, assign) CGFloat downFontSize; -@property (nonatomic, strong) UIColor * downFontColor; - -@property (nonatomic, strong) NSArray * names; // Will dictate the number of ticks -@property (nonatomic, assign) NSTimeInterval animationDuration; - -@end diff --git a/Source/Vendor/TGPControls/TGPCamelLabels7.m b/Source/Vendor/TGPControls/TGPCamelLabels7.m deleted file mode 100755 index eb17b4e0f..000000000 --- a/Source/Vendor/TGPControls/TGPCamelLabels7.m +++ /dev/null @@ -1,306 +0,0 @@ -// @file: TGPCamelLabels7.m -// @project: TGPControls -// -// @history: Created July 4th, 2014 (Independence Day) -// @author: Xavier Schott -// mailto://xschott@gmail.com -// http://thegothicparty.com -// tel://+18089383634 -// -// @license: http://opensource.org/licenses/MIT -// Copyright (c) 2014, Xavier Schott -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "TGPCamelLabels7.h" - -@interface TGPCamelLabels7() -@property (nonatomic, assign) NSUInteger lastValue; -@property (nonatomic, retain) NSMutableArray * upLabels; -@property (nonatomic, retain) NSMutableArray * dnLabels; -@end - -@implementation TGPCamelLabels7 - -#pragma mark properties - -- (void)setTickCount:(NSUInteger)tickCount { - // calculated property - // Put some order to tickCount: 1 >= count >= 128 - const unsigned int count = (unsigned int) MAX(1, MIN(tickCount, 128)); - [self debugNames:count]; - [self layoutTrack]; -} - -- (NSUInteger)tickCount { - // Dynamic property - return [_names count]; -} - -- (void)setTicksDistance:(CGFloat)ticksDistance { - _ticksDistance = MAX(0, ticksDistance); - [self layoutTrack]; -} - -- (void)setValue:(NSUInteger)value { - _value = value; - [self dockEffect:self.animationDuration]; -} - -- (void)setUpFontName:(NSString *)upFontName { - _upFontName = upFontName; - [self layoutTrack]; -} - -- (void)setUpFontSize:(CGFloat)upFontSize { - _upFontSize = upFontSize; - [self layoutTrack]; -} - -- (void)setUpFontColor:(UIColor *)upFontColor { - _upFontColor = upFontColor; - [self layoutTrack]; -} - -- (void)setDownFontName:(NSString *)downFontName { - _downFontName = downFontName; - [self layoutTrack]; -} - -- (void)setDownFontSize:(CGFloat)downFontSize { - _downFontSize = downFontSize; - [self layoutTrack]; -} - -- (void)setDownFontColor:(UIColor *)downFontColor { - _downFontColor = downFontColor; - [self layoutTrack]; -} - -// NSArray -- (void)setNames:(NSArray *)names { - NSAssert(names.count > 0, @"names.count"); - _names = names; - [self layoutTrack]; -} - -#pragma mark UIView - -- (id)initWithCoder:(NSCoder *)aDecoder { - self = [super initWithCoder:aDecoder]; - if(self != nil) { - [self initProperties]; - } - return self; -} - -- (instancetype)initWithFrame:(CGRect)frame { - self = [super initWithFrame:frame]; - if(self != nil) { - [self initProperties]; - } - return self; -} - -// When bounds change, recalculate layout -- (void)setBounds:(CGRect)bounds -{ - [super setBounds:bounds]; - [self layoutTrack]; - [self setNeedsDisplay]; -} - -// clickthrough --(BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event { - for (UIView *view in self.subviews) { - if (!view.hidden && view.alpha > 0 && view.userInteractionEnabled && [view pointInside:[self convertPoint:point toView:view] withEvent:event]) - return YES; - } - return NO; -} - -#pragma mark TGPCamelLabels - -- (void)initProperties { - _ticksDistance = 44.0; - _value = 0; - [self debugNames:10]; - - _upFontName = nil; - _upFontSize = 12; - _upFontColor = nil; - - _downFontName = nil; - _downFontSize = 12; - _downFontColor = nil; - - _upLabels = [NSMutableArray array]; - _dnLabels = [NSMutableArray array]; - - _lastValue = NSNotFound; // Never tapped - _animationDuration = 0.15; - - [self layoutTrack]; -} - -- (void)debugNames:(unsigned int)count { - // Dynamic property, will create an array with labels, generally for debugging purposes - const NSMutableArray * array = [NSMutableArray array]; - for(int iterate = 1; iterate <= count; iterate++) { - [array addObject:[NSString stringWithFormat:@"%d", iterate ]]; - } - [self setNames:(NSArray *) array]; -} - -- (void)layoutTrack { - [self.upLabels enumerateObjectsUsingBlock:^(UIView * view, NSUInteger idx, BOOL *stop) { - [view removeFromSuperview]; - }]; - [self.upLabels removeAllObjects]; - [self.dnLabels enumerateObjectsUsingBlock:^(UIView * view, NSUInteger idx, BOOL *stop) { - [view removeFromSuperview]; - }]; - [self.dnLabels removeAllObjects]; - - const NSUInteger count = self.names.count; - if( count > 0) { - CGFloat centerX = (self.bounds.size.width - ((count - 1) * self.ticksDistance))/2.0; - const CGFloat centerY = self.bounds.size.height / 2.0; - for(NSString * name in self.names) { - UILabel * upLabel = [[UILabel alloc] initWithFrame:CGRectZero]; - [self.upLabels addObject:upLabel]; - upLabel.text = name; - upLabel.font = ((self.upFontName != nil) - ? [UIFont fontWithName:self.upFontName size:self.upFontSize] - : [UIFont boldSystemFontOfSize:self.upFontSize]); - upLabel.textColor = ((self.upFontColor != nil) - ? self.upFontColor - : self.tintColor); - [upLabel sizeToFit]; - upLabel.center = CGPointMake(centerX, centerY); - upLabel.frame = ({ - CGRect frame = upLabel.frame; - // frame.origin.y = 0; - frame.origin.y = self.bounds.size.height - frame.size.height; - frame; - }); - upLabel.alpha = 0.0; - [self addSubview:upLabel]; - - UILabel * dnLabel = [[UILabel alloc] initWithFrame:CGRectZero]; - [self.dnLabels addObject:dnLabel]; - dnLabel.text = name; - dnLabel.font = ((self.downFontName != nil) - ? [UIFont fontWithName:self.downFontName size:self.downFontSize] - : [UIFont boldSystemFontOfSize:self.downFontSize]); - dnLabel.textColor = ((self.downFontColor != nil) - ? self.downFontColor - : [UIColor grayColor]); - [dnLabel sizeToFit]; - dnLabel.center = CGPointMake(centerX, centerY); - dnLabel.frame = ({ - CGRect frame = dnLabel.frame; - frame.origin.y = self.bounds.size.height - frame.size.height; - frame; - }); - [self addSubview:dnLabel]; - - centerX += self.ticksDistance; - } - [self dockEffect:0.0]; - } -} - -- (void)dockEffect:(NSTimeInterval)duration -{ - const NSUInteger up = self.value; - - // Unlike the National Parks from which it is inspired, this Dock Effect - // does not abruptly change from BOLD to plain. Instead, we have 2 sets of - // labels, which are faded back and forth, in unisson. - // - BOLD to plain - // - Black to gray - // - high to low - // Each animation picks up where the previous left off - void (^moveBlock)() = ^void() { - // Bring almost all down - [self.upLabels enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - if( up != idx) { - [self moveDown:obj withAlpha:0.f]; - } - }]; - [self.dnLabels enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - if( up != idx) { - [self moveDown:obj withAlpha:1.f]; - } - }]; - - // Bring the selection up - if(up < [self.upLabels count]) { - [self moveUp:[self.upLabels objectAtIndex:up] withAlpha:1.f]; - } - if(up < [self.dnLabels count]) { - [self moveUp:[self.dnLabels objectAtIndex:up] withAlpha:0.f]; - } - }; - - if(duration > 0) { - [UIView animateWithDuration:duration - delay:0 - options:(UIViewAnimationOptionBeginFromCurrentState + - UIViewAnimationOptionCurveLinear) - animations:moveBlock - completion:nil]; - } else { - moveBlock(); - } -} - -- (void)moveDown:(UIView*)aView withAlpha:(CGFloat) alpha -{ - aView.frame = ({ - CGRect frame = aView.frame; - frame.origin.y = self.bounds.size.height - frame.size.height; - frame; - }); - [aView setAlpha:alpha]; -} - -- (void)moveUp:(UIView*)aView withAlpha:(CGFloat) alpha -{ - aView.frame = ({ - CGRect frame = aView.frame; - frame.origin.y = 0; - frame; - }); - [aView setAlpha:alpha]; -} - -#pragma mark - TGPControlsTicksProtocol - -- (void)tgpTicksDistanceChanged:(CGFloat)ticksDistance sender:(id)sender -{ - self.ticksDistance = ticksDistance; -} - -- (void)tgpValueChanged:(unsigned int)value -{ - self.value = value; -} -@end diff --git a/Source/Vendor/TGPControls/TGPControlsTicksProtocol.h b/Source/Vendor/TGPControls/TGPControlsTicksProtocol.h deleted file mode 100755 index 9675f882d..000000000 --- a/Source/Vendor/TGPControls/TGPControlsTicksProtocol.h +++ /dev/null @@ -1,38 +0,0 @@ -// @file: TGPControlsTicksProtocol.h -// @project: TGPControls -// -// @history: Created November 27, 2014 (Thanksgiving Day) -// @author: Xavier Schott -// mailto://xschott@gmail.com -// http://thegothicparty.com -// tel://+18089383634 -// -// @license: http://opensource.org/licenses/MIT -// Copyright (c) 2014, Xavier Schott -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -@protocol TGPControlsTicksProtocol - -@required -- (void)tgpTicksDistanceChanged:(CGFloat)ticksDistance sender:(id)sender; - -@optional -- (void)tgpValueChanged:(unsigned int)value; -@end diff --git a/Source/Vendor/TGPControls/TGPDiscreteSlider.h b/Source/Vendor/TGPControls/TGPDiscreteSlider.h deleted file mode 100755 index 2f422d546..000000000 --- a/Source/Vendor/TGPControls/TGPDiscreteSlider.h +++ /dev/null @@ -1,58 +0,0 @@ -// @file: TGPDiscreteSlider.h -// @project: TGPControls -// -// @history: Created November 27, 2014 (Thanksgiving Day) -// @author: Xavier Schott -// mailto://xschott@gmail.com -// http://thegothicparty.com -// tel://+18089383634 -// -// @license: http://opensource.org/licenses/MIT -// Copyright (c) 2014, Xavier Schott -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "TGPDiscreteSlider7.h" - -IB_DESIGNABLE -@interface TGPDiscreteSlider : TGPDiscreteSlider7 - -@property (nonatomic) IBInspectable int tickStyle; -@property (nonatomic) IBInspectable CGSize tickSize; -@property (nonatomic) IBInspectable int tickCount; -@property (nonatomic) IBInspectable NSString * tickImage; - -@property (nonatomic) IBInspectable int trackStyle; -@property (nonatomic) IBInspectable CGFloat trackThickness; -@property (nonatomic) IBInspectable NSString * trackImage; - -@property (nonatomic) IBInspectable int thumbStyle; -@property (nonatomic) IBInspectable CGSize thumbSize; -@property (nonatomic) IBInspectable UIColor * thumbColor; -@property (nonatomic) IBInspectable CGFloat thumbSRadius; -@property (nonatomic) IBInspectable CGSize thumbSOffset; -@property (nonatomic) IBInspectable NSString * thumbImage; - -// AKA: UISlider value (as CGFloat for compatibility with UISlider API, but expected to contain integers) -@property (nonatomic) IBInspectable CGFloat minimumValue; -@property (nonatomic) IBInspectable CGFloat value; - -@property (nonatomic) IBInspectable int incrementValue; - -@end diff --git a/Source/Vendor/TGPControls/TGPDiscreteSlider.m b/Source/Vendor/TGPControls/TGPDiscreteSlider.m deleted file mode 100755 index 2bf8da793..000000000 --- a/Source/Vendor/TGPControls/TGPDiscreteSlider.m +++ /dev/null @@ -1,62 +0,0 @@ -// @file: TGPDiscreteSlider.m -// @project: TGPControls -// -// @history: Created November 27, 2014 (Thanksgiving Day) -// @author: Xavier Schott -// mailto://xschott@gmail.com -// http://thegothicparty.com -// tel://+18089383634 -// -// @license: http://opensource.org/licenses/MIT -// Copyright (c) 2014, Xavier Schott -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "TGPDiscreteSlider.h" - -@implementation TGPDiscreteSlider - -@dynamic tickStyle; -@dynamic tickSize; -@dynamic tickCount; -@dynamic tickImage; -@dynamic trackStyle; -@dynamic trackThickness; -@dynamic trackImage; -@dynamic thumbStyle; -@dynamic thumbSize; -@dynamic thumbColor; -@dynamic thumbImage; -@dynamic minimumValue; -@dynamic value; -@dynamic incrementValue; - -#pragma mark properties - -- (void)setThumbSRadius:(CGFloat)thumbSRadius { - // adapter - self.thumbShadowRadius = thumbSRadius; -} - -- (void)setThumbSOffset:(CGSize)thumbSOffset { - // adapter - self.thumbShadowOffset = thumbSOffset; -} - -@end diff --git a/Source/Vendor/TGPControls/TGPDiscreteSlider7.h b/Source/Vendor/TGPControls/TGPDiscreteSlider7.h deleted file mode 100755 index 59ae20fb7..000000000 --- a/Source/Vendor/TGPControls/TGPDiscreteSlider7.h +++ /dev/null @@ -1,77 +0,0 @@ -// @file: TGPDiscreteSlider7.h -// @project: TGPControls -// -// @history: Created July 4th, 2014 (Independence Day) -// @author: Xavier Schott -// mailto://xschott@gmail.com -// http://thegothicparty.com -// tel://+18089383634 -// -// @license: http://opensource.org/licenses/MIT -// Copyright (c) 2014, Xavier Schott -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import -#import "TGPControlsTicksProtocol.h" - -@interface TGPDiscreteSlider7 : - -// Interface builder hides the IBInspectable for UIControl -#if TARGET_INTERFACE_BUILDER -UIView -#else // !TARGET_INTERFACE_BUILDER -UIControl -#endif // TARGET_INTERFACE_BUILDER - -typedef NS_ENUM(int, ComponentStyle) { - ComponentStyleIOS = 0, - ComponentStyleRectangular, - ComponentStyleRounded, - ComponentStyleInvisible, - ComponentStyleImage -}; - -@property (nonatomic, assign) ComponentStyle tickStyle; -@property (nonatomic, assign) CGSize tickSize; -@property (nonatomic, assign) int tickCount; -@property (nonatomic, readonly) CGFloat ticksDistance; -@property (nonatomic, strong) NSString * tickImage; - - -@property (nonatomic, assign) ComponentStyle trackStyle; -@property (nonatomic, assign) CGFloat trackThickness; -@property (nonatomic, strong) NSString * trackImage; - -@property (nonatomic, assign) ComponentStyle thumbStyle; -@property (nonatomic, assign) CGSize thumbSize; -@property (nonatomic, strong) UIColor * thumbColor; -@property (nonatomic, assign) CGFloat thumbShadowRadius; -@property (nonatomic, assign) CGSize thumbShadowOffset; -@property (nonatomic, strong) NSString * thumbImage; - -@property (nonatomic, weak) NSObject * ticksListener; - -// AKA: UISlider value (as CGFloat for compatibility with UISlider API, but expected to contain integers) -@property (nonatomic, assign) CGFloat minimumValue; -@property (nonatomic, assign) CGFloat value; - -@property (nonatomic, assign) int incrementValue; - -@end diff --git a/Source/Vendor/TGPControls/TGPDiscreteSlider7.m b/Source/Vendor/TGPControls/TGPDiscreteSlider7.m deleted file mode 100755 index 24472680a..000000000 --- a/Source/Vendor/TGPControls/TGPDiscreteSlider7.m +++ /dev/null @@ -1,590 +0,0 @@ -// @file: TGPDiscreteSlider7.m -// @project: TGPControls -// -// @history: Created July 4th, 2014 (Independence Day) -// @author: Xavier Schott -// mailto://xschott@gmail.com -// http://thegothicparty.com -// tel://+18089383634 -// -// @license: http://opensource.org/licenses/MIT -// Copyright (c) 2014, Xavier Schott -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "TGPDiscreteSlider7.h" - -static CGFloat iOSThumbShadowRadius = 4.0; -static CGSize iosThumbShadowOffset = (CGSize){0, 3}; - -@interface TGPDiscreteSlider7 () { - int _intValue; - int _intMinimumValue; -} -@property (nonatomic) NSMutableArray * ticksAbscisses; -@property (nonatomic, assign) CGFloat thumbAbscisse; -@property (nonatomic) CALayer * thumbLayer; -@property (nonatomic) CALayer * colorTrackLayer; -@property (nonatomic) CGRect trackRectangle; -@end - -@implementation TGPDiscreteSlider7 - -#pragma mark properties - -- (void)setTickStyle:(ComponentStyle)tickStyle { - _tickStyle = tickStyle; - [self layoutTrack]; -} - -- (void)setTickSize:(CGSize)tickSize { - _tickSize.width = MAX(0, tickSize.width); - _tickSize.height = MAX(0, tickSize.height); - [self layoutTrack]; -} - -- (void)setTickCount:(int)tickCount { - _tickCount = MAX(2, tickCount); - [self layoutTrack]; -} - -- (CGFloat)ticksDistance { - NSAssert1(self.tickCount > 1, @"2 ticks minimum %d", self.tickCount); - const unsigned int segments = MAX(1, self.tickCount - 1); - return (self.trackRectangle.size.width / segments); -} - -- (void)setTickImage:(NSString *)tickImage { - _tickImage = tickImage; - [self layoutTrack]; -} - -- (void)setTrackStyle:(ComponentStyle)trackStyle { - _trackStyle = trackStyle; - [self layoutTrack]; -} - -- (void)setTrackThickness:(CGFloat)trackThickness { - _trackThickness = MAX(0, trackThickness); - [self layoutTrack]; -} - -- (void)setTrackImage:(NSString *)trackImage { - _trackImage = trackImage; - [self layoutTrack]; -} - -- (void)setThumbStyle:(ComponentStyle)thumbStyle { - _thumbStyle = thumbStyle; - [self layoutTrack]; -} - -- (void)setThumbSize:(CGSize)thumbSize { - _thumbSize.width = MAX(1, thumbSize.width); - _thumbSize.height = MAX(1, thumbSize.height); - [self layoutTrack]; -} - -- (void)setThumbImage:(NSString *)thumbImage { - _thumbImage = thumbImage; - - // Associate image to layer - NSString * imageName = self.thumbImage; - if(imageName.length > 0) { - UIImage * image = [UIImage imageNamed:imageName]; //[NSBundle bundleForClass:[self class]] - self.thumbLayer.contents = (id)image.CGImage; - } - - [self layoutTrack]; -} - -- (void)setThumbShadowRadius:(CGFloat)thumbShadowRadius { - _thumbShadowRadius = thumbShadowRadius; - [self layoutTrack]; -} - -- (void)setTicksListener:(NSObject *)ticksListener { - _ticksListener = ticksListener; - [self.ticksListener tgpTicksDistanceChanged:self.ticksDistance sender:self]; -} - -- (void)setIncrementValue:(int)incrementValue { - _incrementValue = incrementValue; - if(0 == incrementValue) { - _incrementValue = 1; // nonZeroIncrement - } - [self layoutTrack]; -} - -// AKA: UISlider value (as CGFloat for compatibility with UISlider API, but expected to contain integers) -- (void)setMinimumValue:(CGFloat)minimumValue { - _intMinimumValue = minimumValue; - [self layoutTrack]; -} - -- (CGFloat)minimumValue { - return _intMinimumValue; // calculated property, with a float-to-int adapter -} - -- (void)setValue:(CGFloat)value { - const unsigned int nonZeroIncrement = ((0 == _incrementValue) ? 1 : _incrementValue); - const int rootValue = ((value - self.minimumValue) / nonZeroIncrement); - _intValue = self.minimumValue + (int)(rootValue * nonZeroIncrement); - [self layoutTrack]; -} - -- (CGFloat)value { - return _intValue; // calculated property, with a float-to-int adapter -} - -// When bounds change, recalculate layout -- (void)setBounds:(CGRect)bounds -{ - [super setBounds:bounds]; - [self layoutTrack]; - [self setNeedsDisplay]; -} - -#pragma mark UIControl - -- (id)initWithCoder:(NSCoder *)aDecoder { - self = [super initWithCoder:aDecoder]; - if(self != nil) { - [self initProperties]; - } - return self; -} - -- (instancetype)initWithFrame:(CGRect)frame { - self = [super initWithFrame:frame]; - if(self != nil) { - [self initProperties]; - } - return self; -} - -- (void)drawRect:(CGRect)rect { - [self drawTrack]; - [self drawThumb]; -} - -- (void)sendActionsForControlEvents { - // Automatic UIControlEventValueChanged notification - if([self.ticksListener respondsToSelector:@selector(tgpValueChanged:)]) { - [self.ticksListener tgpValueChanged:self.value]; - } - - // Interface builder hides the IBInspectable for UIControl -#if !TARGET_INTERFACE_BUILDER - [self sendActionsForControlEvents:UIControlEventValueChanged]; -#endif // !TARGET_INTERFACE_BUILDER -} - -#pragma mark TGPDiscreteSlider7 - -- (void)initProperties { - _tickStyle = ComponentStyleRectangular; - _tickSize = (CGSize) {1.0, 4.0}; - _tickCount = 11; - _trackStyle = ComponentStyleIOS; - _trackThickness = 2.0; - _thumbStyle = ComponentStyleIOS; - _thumbSize = (CGSize) {10.0, 10.0}; - _thumbColor = [UIColor lightGrayColor]; - _thumbShadowRadius = 0.0; - _thumbShadowOffset = CGSizeZero; - _intMinimumValue = -5; - _incrementValue = 1; - _intValue = 0; - _ticksAbscisses = [NSMutableArray array]; - _thumbAbscisse = 0.0; - _trackRectangle = CGRectZero; - - // In case we need a colored track, initialize it now - // There may be a more elegant way to do this than with a CALayer, - // but then again CALayer brings free animation and will animate along the thumb - _colorTrackLayer = [CALayer layer]; - _colorTrackLayer.backgroundColor = [[UIColor colorWithHue:211.0/360.0 saturation:1 brightness:1 alpha:1] CGColor]; - _colorTrackLayer.cornerRadius = 2.0; - [self.layer addSublayer:self.colorTrackLayer]; - - // The thumb is its own CALayer, which brings in free animation - _thumbLayer = [CALayer layer]; - [self.layer addSublayer:self.thumbLayer]; - - self.multipleTouchEnabled = NO; - [self layoutTrack]; -} - -- (void)drawTrack { - const CGContextRef ctx = UIGraphicsGetCurrentContext(); - - // Track - switch(self.trackStyle) { - case ComponentStyleRectangular: - CGContextAddRect(ctx, self.trackRectangle); - break; - - case ComponentStyleInvisible: - // Nothing to draw - break; - - case ComponentStyleImage: { - // Draw image if exists - NSString * imageName = self.trackImage; - if(imageName.length > 0) { - UIImage * image = [UIImage imageNamed:imageName]; //[NSBundle bundleForClass:[self class]] - if(image) { - CGRect centered = CGRectMake((self.frame.size.width/2) - (image.size.width/2), - (self.frame.size.height/2) - (image.size.height/2), - image.size.width, - image.size.height); - CGContextDrawImage(ctx, centered, image.CGImage); - } - } - break; - } - - case ComponentStyleRounded: - case ComponentStyleIOS: - default: { - UIBezierPath * path = [UIBezierPath bezierPathWithRoundedRect:self.trackRectangle - cornerRadius:self.trackRectangle.size.height/2]; - CGContextAddPath(ctx, [path CGPath]) ; - break; - } - } - - // Ticks - if(ComponentStyleIOS != self.tickStyle) { - NSAssert(nil != self.ticksAbscisses, @"ticksAbscisses"); - if(nil != self.ticksAbscisses) { - - for(NSValue * originValue in self.ticksAbscisses) { - CGPoint originPoint = [originValue CGPointValue]; - CGRect rectangle = CGRectMake(originPoint.x-(self.tickSize.width/2), - originPoint.y-(self.tickSize.height/2), - self.tickSize.width, self.tickSize.height); - switch(self.tickStyle) { - case ComponentStyleRounded: { - UIBezierPath * path = [UIBezierPath bezierPathWithRoundedRect:rectangle - cornerRadius:rectangle.size.height/2]; - CGContextAddPath(ctx, [path CGPath]) ; - break; - } - - case ComponentStyleRectangular: - CGContextAddRect(ctx, rectangle); - break; - - case ComponentStyleImage: { - // Draw image if exists - NSString * imageName = self.tickImage; - if(imageName.length > 0) { - UIImage * image = [UIImage imageNamed:imageName]; //[NSBundle bundleForClass:[self class]] - if(image) { - CGRect centered = CGRectMake(rectangle.origin.x + (rectangle.size.width/2) - (image.size.width/2), - rectangle.origin.y + (rectangle.size.height/2) - (image.size.height/2), - image.size.width, - image.size.height); - CGContextDrawImage(ctx, centered, image.CGImage); - } - } - break; - } - - case ComponentStyleInvisible: - case ComponentStyleIOS: - default: - // Nothing to draw - break; - } - } - } - } // iOS UISlider aka ComponentStyleIOS does not have ticks - - CGContextSetFillColorWithColor(ctx, [self.tintColor CGColor]); - CGContextFillPath(ctx); - - // For colored track, we overlay a CALayer, which will animate along with the cursor - if(ComponentStyleIOS == self.trackStyle) { - self.colorTrackLayer.frame = ({ - CGRect frame = self.trackRectangle; - frame.size.width = self.thumbAbscisse - CGRectGetMinX(self.trackRectangle); - frame; - }); - } else { - self.colorTrackLayer.frame = CGRectZero; - } -} - -- (void)drawThumb { - if( self.value >= self.minimumValue) { // Feature: hide the thumb when below range - - const CGSize thumbSizeForStyle = [self thumbSizeIncludingShadow]; - const CGFloat thumbWidth = thumbSizeForStyle.width; - const CGFloat thumbHeight = thumbSizeForStyle.height; - const CGRect rectangle = CGRectMake(self.thumbAbscisse - (thumbWidth / 2), - (self.frame.size.height - thumbHeight)/2, - thumbWidth, - thumbHeight); - - const CGFloat shadowRadius = ((self.thumbStyle == ComponentStyleIOS) - ? iOSThumbShadowRadius - : self.thumbShadowRadius); - const CGSize shadowOffset = ((self.thumbStyle == ComponentStyleIOS) - ? iosThumbShadowOffset - : self.thumbShadowOffset); - - self.thumbLayer.frame = ((shadowRadius != 0.0) // Ignore offset if there is no shadow - ? CGRectInset(rectangle, - shadowRadius + shadowOffset.width, - shadowRadius + shadowOffset.height) - : CGRectInset(rectangle, shadowRadius, shadowRadius)); - - switch(self.thumbStyle) { - case ComponentStyleRounded: // A rounded thumb is circular - self.thumbLayer.backgroundColor = [self.thumbColor CGColor]; - self.thumbLayer.borderColor = [[UIColor clearColor] CGColor]; - self.thumbLayer.borderWidth = 0.0; - self.thumbLayer.cornerRadius = self.thumbLayer.frame.size.width/2; - self.thumbLayer.allowsEdgeAntialiasing = YES; - break; - - case ComponentStyleImage: { - // image is set using layer.contents - self.thumbLayer.backgroundColor = [[UIColor clearColor] CGColor]; - self.thumbLayer.borderColor = [[UIColor clearColor] CGColor]; - self.thumbLayer.borderWidth = 0.0; - self.thumbLayer.cornerRadius = 0.0; - self.thumbLayer.allowsEdgeAntialiasing = NO; - break; - } - - case ComponentStyleRectangular: - self.thumbLayer.backgroundColor = [self.thumbColor CGColor]; - self.thumbLayer.borderColor = [[UIColor clearColor] CGColor]; - self.thumbLayer.borderWidth = 0.0; - self.thumbLayer.cornerRadius = 0.0; - self.thumbLayer.allowsEdgeAntialiasing = NO; - break; - - case ComponentStyleInvisible: - self.thumbLayer.backgroundColor = [[UIColor clearColor] CGColor]; - self.thumbLayer.cornerRadius = 0.0; - break; - - case ComponentStyleIOS: - default: - self.thumbLayer.backgroundColor = [[UIColor whiteColor] CGColor]; - self.thumbLayer.borderColor = [[UIColor colorWithHue:0 saturation: 0 brightness: 0.8 alpha: 1] - CGColor]; - self.thumbLayer.borderWidth = 0.5; - self.thumbLayer.cornerRadius = self.thumbLayer.frame.size.width/2; - self.thumbLayer.allowsEdgeAntialiasing = YES; - break; - } - - // Shadow - if(shadowRadius != 0.0) { -#if TARGET_INTERFACE_BUILDER - self.thumbLayer.shadowOffset = CGSizeMake(shadowOffset.width, -shadowOffset.height); -#else // !TARGET_INTERFACE_BUILDER - self.thumbLayer.shadowOffset = shadowOffset; -#endif // TARGET_INTERFACE_BUILDER - - self.thumbLayer.shadowRadius = shadowRadius; - self.thumbLayer.shadowColor = [[UIColor blackColor] CGColor]; - self.thumbLayer.shadowOpacity = 0.15; - } else { - self.thumbLayer.shadowRadius = 0.0; - self.thumbLayer.shadowOffset = CGSizeZero; - self.thumbLayer.shadowColor = [[UIColor clearColor] CGColor]; - self.thumbLayer.shadowOpacity = 0.0; - } - } -} - -- (void)layoutTrack { - NSAssert1(self.tickCount > 1, @"2 ticks minimum %d", self.tickCount); - const unsigned int segments = MAX(1, self.tickCount - 1); - const CGFloat thumbWidth = [self thumbSizeIncludingShadow].width; - - // Calculate the track ticks positions - const CGFloat trackHeight = ((ComponentStyleIOS == self.trackStyle) - ? 2.0 - : self.trackThickness); - CGSize trackSize = CGSizeMake(self.frame.size.width - thumbWidth, trackHeight); - if(ComponentStyleImage == self.trackStyle) { - NSString * imageName = self.trackImage; - if(imageName.length > 0) { - UIImage * image = [UIImage imageNamed:imageName]; //[NSBundle bundleForClass:[self class]] - if(image) { - trackSize.width = image.size.width - thumbWidth; - } - } - } - - self.trackRectangle = CGRectMake((self.frame.size.width - trackSize.width)/2, - (self.frame.size.height - trackSize.height)/2, - trackSize.width, - trackSize.height); - const CGFloat trackY = self.frame.size.height / 2; - [self.ticksAbscisses removeAllObjects]; - for( int iterate = 0; iterate <= segments; iterate++) { - const double ratio = (double)iterate / (double)segments; - const CGFloat originX = self.trackRectangle.origin.x + (CGFloat)(trackSize.width * ratio); - [self.ticksAbscisses addObject: [NSValue valueWithCGPoint:CGPointMake(originX, trackY)]]; - } - [self layoutThumb]; - - // If we have a TGPDiscreteSliderTicksListener (such as TGPCamelLabels), broadcast new spacing - [self.ticksListener tgpTicksDistanceChanged:self.ticksDistance sender:self]; -} - -- (void)layoutThumb { - NSAssert1(self.tickCount > 1, @"2 ticks minimum %d", self.tickCount); - const unsigned int segments = MAX(1, self.tickCount - 1); - - // Calculate the thumb position - const unsigned int nonZeroIncrement = ((0 == self.incrementValue) ? 1 : self.incrementValue); - double thumbRatio = (double)(self.value - self.minimumValue) / (double)(segments * nonZeroIncrement); - thumbRatio = MAX(0.0, MIN(thumbRatio, 1.0)); // Normalized - self.thumbAbscisse = self.trackRectangle.origin.x + (self.trackRectangle.size.width * thumbRatio); -} - -- (CGSize)thumbSizeIncludingShadow { - switch (self.thumbStyle) { - case ComponentStyleInvisible: - case ComponentStyleRectangular: - case ComponentStyleRounded: - return ((self.thumbShadowRadius != 0.0) - ? CGSizeMake(self.thumbSize.width - + (self.thumbShadowRadius * 2) - + (self.thumbShadowOffset.width * 2), - self.thumbSize.height - + (self.thumbShadowRadius * 2) - + (self.thumbShadowOffset.height * 2)) - : self.thumbSize); - - case ComponentStyleIOS: - return CGSizeMake(33.0 - + (iOSThumbShadowRadius * 2) - + (iosThumbShadowOffset.width * 2), - 33.0 - + (iOSThumbShadowRadius * 2) - + (iosThumbShadowOffset.height * 2)); - - case ComponentStyleImage: { - NSString * imageName = self.thumbImage; - if (imageName.length > 0) { - return [UIImage imageNamed:imageName].size; - } - // Fall through - } - - default: - return (CGSize){33.0, 33.0}; - } -} - -#pragma mark Touches - -- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { - [self touchDown:touches duration:0.1]; -} - -- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { - [self touchDown:touches duration:0.0]; -} - -- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { - [self touchUp:touches]; -} - -- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { - [self touchUp:touches]; -} - -- (void)touchDown:(NSSet *)touches duration:(NSTimeInterval)duration { - const UITouch * touch = [touches anyObject]; - if(nil != touch) { - const CGPoint location = [touch locationInView:touch.view]; - [self moveThumbTo:location.x duration:duration]; - } -} - -- (void)touchUp:(NSSet *)touches { - const UITouch * touch = [touches anyObject]; - if(nil != touch) { - const CGPoint location = [touch locationInView:touch.view]; - const unsigned int tick = [self pickTickFromSliderPosition:location.x]; - [self moveThumbToTick:tick]; - } -} - -#pragma mark Notifications - -- (void)moveThumbToTick:(unsigned int)tick { - const unsigned int nonZeroIncrement = ((0 == self.incrementValue) ? 1 : self.incrementValue); - int intValue = self.minimumValue + (tick * nonZeroIncrement); - if( intValue != _intValue) { - _intValue = intValue; - [self sendActionsForControlEvents]; - } - - [self layoutThumb]; - [self setNeedsDisplay]; -} - -- (void)moveThumbTo:(CGFloat)abscisse duration:(CFTimeInterval)duration { - const CGFloat leftMost = CGRectGetMinX(self.trackRectangle); - const CGFloat rightMost = CGRectGetMaxX(self.trackRectangle); - - self.thumbAbscisse = MAX(leftMost, MIN(abscisse, rightMost)); - [CATransaction setAnimationDuration:duration]; - - const unsigned int tick = [self pickTickFromSliderPosition:self.thumbAbscisse]; - const unsigned int nonZeroIncrement = ((0 == self.incrementValue) ? 1 : self.incrementValue); - int intValue = self.minimumValue + (tick * nonZeroIncrement); - if( intValue != _intValue) { - _intValue = intValue; - [self sendActionsForControlEvents]; - } - - [self setNeedsDisplay]; -} - -- (unsigned int)pickTickFromSliderPosition:(CGFloat)abscisse { - const CGFloat leftMost = CGRectGetMinX(self.trackRectangle); - const CGFloat rightMost = CGRectGetMaxX(self.trackRectangle); - const CGFloat clampedAbscisse = MAX(leftMost, MIN(abscisse, rightMost)); - const double ratio = (double)(clampedAbscisse - leftMost) / (double)(rightMost - leftMost); - const unsigned int segments = MAX(1, self.tickCount - 1); - return (unsigned int) round( (double)segments * ratio); -} - -#pragma mark - Interface Builder - -#if TARGET_INTERFACE_BUILDER -// Interface builder hides the IBInspectable for UIControl -- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents {} -#endif // TARGET_INTERFACE_BUILDER - -@end diff --git a/Source/Vendor/TGPControls/module.map b/Source/Vendor/TGPControls/module.map deleted file mode 100755 index b11500012..000000000 --- a/Source/Vendor/TGPControls/module.map +++ /dev/null @@ -1,4 +0,0 @@ -module TGPControls { - header "TGPDiscreteSlider7.h" - export * -} \ No newline at end of file diff --git a/Source/Vendor/SMSegmentView/SMSegment.swift b/Vendor/SMSegmentView/SMSegment.swift similarity index 100% rename from Source/Vendor/SMSegmentView/SMSegment.swift rename to Vendor/SMSegmentView/SMSegment.swift diff --git a/Source/Vendor/SMSegmentView/SMSegmentView.swift b/Vendor/SMSegmentView/SMSegmentView.swift similarity index 100% rename from Source/Vendor/SMSegmentView/SMSegmentView.swift rename to Vendor/SMSegmentView/SMSegmentView.swift