Alexandre Lision | f47a256 | 2015-06-15 15:48:29 -0400 | [diff] [blame^] | 1 | //Copyright 2013-2015 Ilija Tovilo |
| 2 | // |
| 3 | //Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | //you may not use this file except in compliance with the License. |
| 5 | //You may obtain a copy of the License at |
| 6 | // |
| 7 | //http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | //Unless required by applicable law or agreed to in writing, software |
| 10 | //distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | //See the License for the specific language governing permissions and |
| 13 | //limitations under the License. |
| 14 | |
| 15 | |
| 16 | #import <Cocoa/Cocoa.h> |
| 17 | #import <QuartzCore/QuartzCore.h> |
| 18 | |
| 19 | // |
| 20 | // !!!IMPORTANT!!! - Embedd ITProgressIndicator in a layer-backed view to avoid side-effects! |
| 21 | // |
| 22 | |
| 23 | /** |
| 24 | * @class ITProgressIndicator |
| 25 | * |
| 26 | * A replacement for `NSProgressIndicator`. |
| 27 | * It's a highly customizable control, driven by Core Animation, which makes it much more performant. |
| 28 | * |
| 29 | * So basically, it's awesome. |
| 30 | * |
| 31 | */ |
| 32 | @interface ITProgressIndicator : NSView |
| 33 | |
| 34 | #pragma mark - Methods |
| 35 | |
| 36 | /** |
| 37 | * Override this method to achieve a custom animation |
| 38 | * |
| 39 | * @return CAKeyframeAnimation - animation which will be put on the progress indicator layer |
| 40 | */ |
| 41 | - (CAKeyframeAnimation *)keyFrameAnimationForCurrentPreferences; |
| 42 | |
| 43 | #pragma mark - Properties |
| 44 | |
| 45 | |
| 46 | /// @property isIndeterminate - Indicates if the view will show the progress, or just spin |
| 47 | @property (nonatomic, setter = setIndeterminate:) BOOL isIndeterminate; |
| 48 | |
| 49 | |
| 50 | /// @property progress - The amount that should be shown when `isIndeterminate` is set to `YES` |
| 51 | @property (nonatomic) CGFloat progress; |
| 52 | |
| 53 | |
| 54 | /// @property animates - Indicates if the view is animating |
| 55 | @property (nonatomic) BOOL animates; |
| 56 | |
| 57 | |
| 58 | /// @property hideWhenStopped - Indicates if the view will be hidden if it's stopped |
| 59 | @property (nonatomic) BOOL hideWhenStopped; |
| 60 | |
| 61 | |
| 62 | /// @property lengthOfLine - The length of a single line |
| 63 | @property (nonatomic) CGFloat lengthOfLine; |
| 64 | |
| 65 | |
| 66 | /// @property widthOfLine - The width of a single line |
| 67 | @property (nonatomic) CGFloat widthOfLine; |
| 68 | |
| 69 | |
| 70 | /// @property numberOfLines - The number of lines of the indicator |
| 71 | @property (nonatomic) NSUInteger numberOfLines; |
| 72 | |
| 73 | |
| 74 | /// @property innerMargin - The distance of the lines from the middle |
| 75 | @property (nonatomic) CGFloat innerMargin; |
| 76 | |
| 77 | |
| 78 | /// @property animationDuration - Duration of a single rotation |
| 79 | @property (nonatomic) CGFloat animationDuration; |
| 80 | |
| 81 | |
| 82 | /// @property gradualAnimation - Defines if the animation is smooth or gradual |
| 83 | @property (nonatomic) BOOL steppedAnimation; |
| 84 | |
| 85 | /// @property color - The color of the progress indicator |
| 86 | @property (nonatomic, strong) NSColor *color; |
| 87 | |
| 88 | @end |